Package Exports
- @latentsearch/timemachine-cli
- @latentsearch/timemachine-cli/dist/time-entry-generator.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@latentsearch/timemachine-cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
TimeMachine CLI Tool
Version: 1.3.0
A CLI tool for interacting with the TimeMachine Timesheet System. This tool is useful for:
- Generating bulk time entries (e.g., for data migration or testing)
- Listing users and their IDs
- Listing projects and their IDs
Installation
- Clone this repository or copy the script files to your local machine.
- Navigate to the script directory (
cd scripts/timeentrygenerator). - Install dependencies:
npm install- Make the main script executable (optional, depending on usage):
chmod +x time-entry-generator.ts- Link the package for global use (optional, allows running
time-entry-generatordirectly):
npm link (If you link, you might call it as time-entry-generator <command> instead of npx ts-node time-entry-generator.ts <command>)
Configuration
Create a .env file in the script's directory (scripts/timeentrygenerator) with your API key:
TIMEMACHINE_API_KEY=your_api_key_hereGlobal Options
These options can be used with any command:
| Option | Short | Description | Default |
|---|---|---|---|
--base-url |
-b |
API base URL | https://www.codeclock.xyz/api |
--verbose |
-v |
Show detailed output | false |
--help |
-h |
Display help for command |
Commands
The script now uses a command-based structure. You must specify a command after the script name.
generate
Generates time entries based on specified criteria. The initial configuration summary will display user and project names (if fetched) and day names for clarity in both live and dry runs.
Usage:
npx ts-node time-entry-generator.ts generate [options]Options for generate:
| Option | Short | Description | Default |
|---|---|---|---|
--user-id |
-u |
User ID (required) | - |
--project-id |
-p |
Project ID (required) | - |
--start-date |
-s |
Start date (YYYY-MM-DD) | 30 days ago |
--end-date |
-e |
End date (YYYY-MM-DD) | Today |
--days |
-d |
Days to log time (1=Monday, 7=Sunday) | 1,2,3,4,5 (weekdays) |
--hours |
-H |
Hours per day (Note: short option changed to -H) | 8 |
--dry-run |
Perform a dry run. The summary will show user/project names and day names. The per-entry preview will also use these descriptive names. No actual API calls to create entries are made. | false |
Examples for generate:
Generate 8-hour entries for user 1, project 1, for weekdays over the last 30 days:
npx ts-node time-entry-generator.ts generate -u 1 -p 1Create 4-hour entries for user 1, project 2, for Mondays and Wednesdays only:
npx ts-node time-entry-generator.ts generate -u 1 -p 2 -d 1,3 -H 4Create entries for a specific date range with verbose logging:
npx ts-node time-entry-generator.ts generate -u 1 -p 2 -s 2025-01-01 -e 2025-01-31 -vTest without making actual API calls (dry run):
npx ts-node time-entry-generator.ts generate -u 1 -p 2 --dry-runlist-users
Lists all users and their details from the TimeMachine API.
Usage:
npx ts-node time-entry-generator.ts list-users [global options]Example:
npx ts-node time-entry-generator.ts list-usersTo use a different base URL:
npx ts-node time-entry-generator.ts list-users --base-url https://custom.api.comlist-projects
Lists all projects and their details from the TimeMachine API.
Usage:
npx ts-node time-entry-generator.ts list-projects [global options]Example:
npx ts-node time-entry-generator.ts list-projectsIntegration with TimeMachine API
The tool interacts with the TimeMachine API using the API key from your .env file.
generateuses the/api/time-entriesendpoint.list-usersuses the/api/usersendpoint.list-projectsuses the/api/projectsendpoint.
Troubleshooting
If you encounter issues:
- Ensure your
TIMEMACHINE_API_KEYin.envis correct and the file is in thescripts/timeentrygeneratordirectory. - Check that the
--base-url(or its default) is pointing to the correct API endpoint. - For
generate, verify that the user and project IDs exist in the system (you can uselist-usersandlist-projectsto check!). - Use the global
--verboseor-vflag with any command to see detailed error messages or API responses. - For
generate, try--dry-runfirst to verify your configuration before making live changes.
Dependencies
- axios: For making HTTP requests
- commander: For parsing command-line arguments
- dotenv: For loading environment variables
- luxon: For date handling
- ora: For displaying progress spinner
- chalk: For colored console output