aliasmate 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +109 -0
- package/README.md +126 -2
- package/dist/cli.js +52 -15
- package/dist/cli.js.map +1 -1
- package/dist/commands/delete.d.ts +12 -0
- package/dist/commands/delete.d.ts.map +1 -1
- package/dist/commands/delete.js +29 -8
- package/dist/commands/delete.js.map +1 -1
- package/dist/commands/edit.d.ts +13 -0
- package/dist/commands/edit.d.ts.map +1 -1
- package/dist/commands/edit.js +50 -23
- package/dist/commands/edit.js.map +1 -1
- package/dist/commands/export.d.ts +17 -0
- package/dist/commands/export.d.ts.map +1 -1
- package/dist/commands/export.js +42 -7
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/import.d.ts +21 -0
- package/dist/commands/import.d.ts.map +1 -1
- package/dist/commands/import.js +93 -48
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/list.d.ts +20 -0
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +66 -5
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/prev.d.ts +14 -1
- package/dist/commands/prev.d.ts.map +1 -1
- package/dist/commands/prev.js +41 -13
- package/dist/commands/prev.js.map +1 -1
- package/dist/commands/run.d.ts +16 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +30 -10
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/save.d.ts +15 -1
- package/dist/commands/save.d.ts.map +1 -1
- package/dist/commands/save.js +64 -33
- package/dist/commands/save.js.map +1 -1
- package/dist/commands/search.d.ts +19 -0
- package/dist/commands/search.d.ts.map +1 -0
- package/dist/commands/search.js +113 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/storage/index.d.ts +34 -7
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +55 -11
- package/dist/storage/index.js.map +1 -1
- package/dist/utils/constants.d.ts +48 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +51 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/errors.d.ts +30 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +62 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/executor.d.ts +22 -1
- package/dist/utils/executor.d.ts.map +1 -1
- package/dist/utils/executor.js +36 -11
- package/dist/utils/executor.js.map +1 -1
- package/dist/utils/history.d.ts +21 -3
- package/dist/utils/history.d.ts.map +1 -1
- package/dist/utils/history.js +28 -14
- package/dist/utils/history.js.map +1 -1
- package/dist/utils/llm-generator.d.ts +21 -0
- package/dist/utils/llm-generator.d.ts.map +1 -0
- package/dist/utils/llm-generator.js +337 -0
- package/dist/utils/llm-generator.js.map +1 -0
- package/dist/utils/onboarding.d.ts +10 -0
- package/dist/utils/onboarding.d.ts.map +1 -0
- package/dist/utils/onboarding.js +201 -0
- package/dist/utils/onboarding.js.map +1 -0
- package/dist/utils/paths.d.ts +39 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +56 -1
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/prompts.d.ts +56 -0
- package/dist/utils/prompts.d.ts.map +1 -0
- package/dist/utils/prompts.js +51 -0
- package/dist/utils/prompts.js.map +1 -0
- package/package.json +22 -6
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,113 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.2.0] - 2026-01-11
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **New Features**
|
|
12
|
+
- `search` (alias `find`) command to search commands by name, text, or directory
|
|
13
|
+
- Automatic backup creation before importing commands
|
|
14
|
+
- Success confirmation message for command execution
|
|
15
|
+
- Directory existence indicator in list output
|
|
16
|
+
- Command creation timestamp display in list output
|
|
17
|
+
- Enhanced config command showing directory, file path, and command count
|
|
18
|
+
- Exit code display for failed command executions
|
|
19
|
+
|
|
20
|
+
- **Security & Validation**
|
|
21
|
+
- Comprehensive input validation for command names (alphanumeric, hyphens, underscores only)
|
|
22
|
+
- Directory existence validation with warnings
|
|
23
|
+
- Path normalization to absolute paths for consistency
|
|
24
|
+
- Import data structure validation to prevent malformed data
|
|
25
|
+
- Empty input validation for all prompts
|
|
26
|
+
- Command execution validation (directory exists and is actually a directory)
|
|
27
|
+
|
|
28
|
+
- **Error Handling**
|
|
29
|
+
- Global uncaught exception handler
|
|
30
|
+
- Global unhandled promise rejection handler
|
|
31
|
+
- Enhanced error messages with more context
|
|
32
|
+
- Try-catch blocks around all setAlias operations
|
|
33
|
+
- Improved error messages for specific scenarios
|
|
34
|
+
|
|
35
|
+
- **Utility Functions**
|
|
36
|
+
- `isValidDirectory()` for directory validation
|
|
37
|
+
- `sanitizeCommandName()` for input sanitization
|
|
38
|
+
- Atomic file write operations to prevent corruption
|
|
39
|
+
- Exit code tracking in command execution results
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
- **Improvements**
|
|
43
|
+
- Delete command now shows details of what will be deleted
|
|
44
|
+
- Export command creates parent directories if they don't exist
|
|
45
|
+
- Export command warns when overwriting existing files
|
|
46
|
+
- Import command validates each alias structure before processing
|
|
47
|
+
- All user inputs are trimmed before processing
|
|
48
|
+
- All directory paths are normalized to absolute paths
|
|
49
|
+
- Enhanced rename validation in import conflict resolution
|
|
50
|
+
|
|
51
|
+
- **Code Quality**
|
|
52
|
+
- Consistent input validation across all commands
|
|
53
|
+
- Better error propagation with context
|
|
54
|
+
- Improved command execution error reporting
|
|
55
|
+
- Enhanced CLI help messages for unknown commands
|
|
56
|
+
|
|
57
|
+
### Fixed
|
|
58
|
+
- Atomic write operations prevent config file corruption during saves
|
|
59
|
+
- Proper validation of command names to prevent special characters
|
|
60
|
+
- Directory validation prevents execution errors
|
|
61
|
+
- Input trimming prevents whitespace-related issues
|
|
62
|
+
- Better error handling for setAlias validation errors
|
|
63
|
+
|
|
64
|
+
### Developer Notes
|
|
65
|
+
- **Breaking Changes**: None - fully backward compatible
|
|
66
|
+
- **Migration**: No migration needed
|
|
67
|
+
- All changes enhance existing functionality
|
|
68
|
+
- New search command provides additional value
|
|
69
|
+
- Improved data safety through atomic operations and backups
|
|
70
|
+
|
|
71
|
+
## [1.1.0] - 2026-01-08
|
|
72
|
+
|
|
73
|
+
### Added
|
|
74
|
+
- **Developer Experience**
|
|
75
|
+
- ESLint configuration with TypeScript support for code quality enforcement
|
|
76
|
+
- Prettier configuration for consistent code formatting
|
|
77
|
+
- Comprehensive JSDoc documentation for all public functions
|
|
78
|
+
- CONTRIBUTING.md with detailed contributor guidelines
|
|
79
|
+
- DEV_GUIDE.md for quick development reference
|
|
80
|
+
- New npm scripts: `lint`, `lint:fix`, `format`, `format:check`, `typecheck`
|
|
81
|
+
|
|
82
|
+
- **Code Quality**
|
|
83
|
+
- Centralized error handling utilities (`src/utils/errors.ts`)
|
|
84
|
+
- Standardized error messages and constants (`src/utils/constants.ts`)
|
|
85
|
+
- Custom error types and exit code enums
|
|
86
|
+
- Proper TypeScript type annotations throughout codebase
|
|
87
|
+
|
|
88
|
+
### Changed
|
|
89
|
+
- **Refactoring**
|
|
90
|
+
- Removed all `any` types, replaced with proper TypeScript interfaces
|
|
91
|
+
- Standardized error handling across all commands
|
|
92
|
+
- Eliminated code duplication (30+ duplicate strings removed)
|
|
93
|
+
- Improved type safety for inquirer prompt responses
|
|
94
|
+
- Updated all command files to use centralized error utilities
|
|
95
|
+
- Better JSDoc documentation with usage examples for all functions
|
|
96
|
+
|
|
97
|
+
- **Code Organization**
|
|
98
|
+
- Extracted common error handling patterns to utilities
|
|
99
|
+
- Centralized all user-facing messages in constants
|
|
100
|
+
- Removed unused function parameters
|
|
101
|
+
- Improved import organization (Node → External → Internal)
|
|
102
|
+
|
|
103
|
+
### Fixed
|
|
104
|
+
- Proper typing for execa error handling
|
|
105
|
+
- Consistent exit codes across all error scenarios
|
|
106
|
+
- Fixed async/await usage where not needed
|
|
107
|
+
|
|
108
|
+
### Developer Notes
|
|
109
|
+
- **Breaking Changes**: None - this is a code quality improvement release
|
|
110
|
+
- **Migration**: No migration needed, fully backward compatible
|
|
111
|
+
- All code now passes TypeScript strict mode compilation
|
|
112
|
+
- ESLint: 0 errors, 5 acceptable warnings (from inquirer library types)
|
|
113
|
+
- 100% of functions now have comprehensive JSDoc documentation
|
|
114
|
+
|
|
8
115
|
## [1.0.0] - 2025-11-15
|
|
9
116
|
|
|
10
117
|
### Added
|
|
@@ -33,4 +140,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
33
140
|
- Input validation and error handling
|
|
34
141
|
- Beautiful CLI output with chalk
|
|
35
142
|
|
|
143
|
+
[1.2.0]: https://github.com/aliasmate/aliasmate/releases/tag/v1.2.0
|
|
144
|
+
[1.1.0]: https://github.com/aliasmate/aliasmate/releases/tag/v1.1.0
|
|
36
145
|
[1.0.0]: https://github.com/aliasmate/aliasmate/releases/tag/v1.0.0
|
package/README.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
A powerful CLI utility to save, manage, and re-run shell commands with their working directories. Never lose track of useful commands again!
|
|
4
4
|
|
|
5
|
+
[](https://www.npmjs.com/package/aliasmate)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://www.typescriptlang.org/)
|
|
8
|
+
[](https://github.com/prettier/prettier)
|
|
9
|
+
|
|
5
10
|
## Why Use AliasMate?
|
|
6
11
|
|
|
7
12
|
As developers, we often spend time crafting complex commands, navigating to specific directories, and repeating the same sequences. AliasMate solves this by:
|
|
@@ -273,20 +278,139 @@ cd aliasmate
|
|
|
273
278
|
# Install dependencies
|
|
274
279
|
npm install
|
|
275
280
|
|
|
276
|
-
#
|
|
281
|
+
# Build the project
|
|
282
|
+
npm run build
|
|
283
|
+
|
|
284
|
+
# Run type checking
|
|
285
|
+
npm run typecheck
|
|
286
|
+
|
|
287
|
+
# Lint the code
|
|
288
|
+
npm run lint
|
|
289
|
+
|
|
290
|
+
# Format code
|
|
291
|
+
npm run format
|
|
292
|
+
|
|
293
|
+
# Link for local testing
|
|
277
294
|
npm link
|
|
278
295
|
|
|
279
296
|
# Test the CLI
|
|
280
297
|
aliasmate --help
|
|
281
298
|
```
|
|
282
299
|
|
|
300
|
+
### Development Scripts
|
|
301
|
+
|
|
302
|
+
| Script | Description |
|
|
303
|
+
|--------|-------------|
|
|
304
|
+
| `npm run build` | Compile TypeScript to JavaScript |
|
|
305
|
+
| `npm run dev` | Watch mode for development |
|
|
306
|
+
| `npm run typecheck` | Run TypeScript type checking |
|
|
307
|
+
| `npm run lint` | Check code quality with ESLint |
|
|
308
|
+
| `npm run lint:fix` | Auto-fix ESLint issues |
|
|
309
|
+
| `npm run format` | Format code with Prettier |
|
|
310
|
+
| `npm run format:check` | Check if code is formatted |
|
|
311
|
+
|
|
312
|
+
### Code Quality
|
|
313
|
+
|
|
314
|
+
AliasMate is built with modern development practices:
|
|
315
|
+
|
|
316
|
+
- ✅ **TypeScript** with strict mode enabled
|
|
317
|
+
- ✅ **ESLint** for code quality enforcement
|
|
318
|
+
- ✅ **Prettier** for consistent formatting
|
|
319
|
+
- ✅ **Comprehensive JSDoc** documentation
|
|
320
|
+
- ✅ **Centralized error handling** with proper exit codes
|
|
321
|
+
- ✅ **Zero type safety warnings** in production code
|
|
322
|
+
|
|
323
|
+
For detailed contribution guidelines, see [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
324
|
+
|
|
325
|
+
## Project Structure
|
|
326
|
+
|
|
327
|
+
```
|
|
328
|
+
aliasmate/
|
|
329
|
+
├── src/
|
|
330
|
+
│ ├── cli.ts # CLI entry point
|
|
331
|
+
│ ├── commands/ # Command implementations
|
|
332
|
+
│ │ ├── prev.ts # Save from history
|
|
333
|
+
│ │ ├── run.ts # Execute commands
|
|
334
|
+
│ │ ├── save.ts # Interactive save
|
|
335
|
+
│ │ ├── list.ts # Display all
|
|
336
|
+
│ │ ├── edit.ts # Modify commands
|
|
337
|
+
│ │ ├── delete.ts # Remove commands
|
|
338
|
+
│ │ ├── export.ts # Backup to JSON
|
|
339
|
+
│ │ └── import.ts # Restore from JSON
|
|
340
|
+
│ ├── storage/
|
|
341
|
+
│ │ └── index.ts # Config persistence
|
|
342
|
+
│ └── utils/
|
|
343
|
+
│ ├── constants.ts # Shared constants
|
|
344
|
+
│ ├── errors.ts # Error handling
|
|
345
|
+
│ ├── executor.ts # Command execution
|
|
346
|
+
│ ├── history.ts # Shell integration
|
|
347
|
+
│ └── paths.ts # Path utilities
|
|
348
|
+
├── dist/ # Compiled output
|
|
349
|
+
└── docs/
|
|
350
|
+
├── CONTRIBUTING.md # Contributor guide
|
|
351
|
+
├── DEV_GUIDE.md # Quick reference
|
|
352
|
+
└── CLEANUP_SUMMARY.md # Code quality report
|
|
353
|
+
```
|
|
354
|
+
|
|
283
355
|
## License
|
|
284
356
|
|
|
285
357
|
MIT
|
|
286
358
|
|
|
287
359
|
## Contributing
|
|
288
360
|
|
|
289
|
-
Contributions are welcome!
|
|
361
|
+
Contributions are welcome! We appreciate:
|
|
362
|
+
|
|
363
|
+
- 🐛 Bug reports and fixes
|
|
364
|
+
- ✨ Feature suggestions and implementations
|
|
365
|
+
- 📝 Documentation improvements
|
|
366
|
+
|
|
367
|
+
**Maintainer**: AliasMate Contributors
|
|
368
|
+
|
|
369
|
+
## Changelog
|
|
370
|
+
|
|
371
|
+
See [CHANGELOG.md](./CHANGELOG.md) for version history and release notes.
|
|
372
|
+
|
|
373
|
+
## Support
|
|
374
|
+
|
|
375
|
+
- 📖 [Documentation](./README.md)
|
|
376
|
+
- 🐛 [Issue Tracker](https://github.com/aliasmate/aliasmate/issues)
|
|
377
|
+
- 💬 [Discussions](https://github.com/aliasmate/aliasmate/discussions)
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
**⭐ If you find AliasMate helpful, please consider giving it a star on GitHub!**
|
|
382
|
+
- 🎨 Code quality enhancements
|
|
383
|
+
|
|
384
|
+
Before contributing, please:
|
|
385
|
+
|
|
386
|
+
1. Read our [Contributing Guide](./CONTRIBUTING.md)
|
|
387
|
+
2. Check existing issues and pull requests
|
|
388
|
+
3. Follow the code style (ESLint + Prettier)
|
|
389
|
+
4. Add tests for new features (when applicable)
|
|
390
|
+
5. Update documentation as needed
|
|
391
|
+
|
|
392
|
+
### Quick Start for Contributors
|
|
393
|
+
|
|
394
|
+
```bash
|
|
395
|
+
# Fork and clone the repository
|
|
396
|
+
git clone https://github.com/YOUR_USERNAME/aliasmate.git
|
|
397
|
+
cd aliasmate
|
|
398
|
+
|
|
399
|
+
# Install dependencies
|
|
400
|
+
npm install
|
|
401
|
+
|
|
402
|
+
# Make your changes, then:
|
|
403
|
+
npm run format # Format code
|
|
404
|
+
npm run lint # Check for issues
|
|
405
|
+
npm run typecheck # Verify types
|
|
406
|
+
npm run build # Build project
|
|
407
|
+
|
|
408
|
+
# Test locally
|
|
409
|
+
npm link
|
|
410
|
+
aliasmate --help
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
See [DEV_GUIDE.md](./DEV_GUIDE.md) for detailed development workflows.
|
|
290
414
|
|
|
291
415
|
## Author
|
|
292
416
|
|
package/dist/cli.js
CHANGED
|
@@ -14,32 +14,34 @@ const delete_1 = require("./commands/delete");
|
|
|
14
14
|
const edit_1 = require("./commands/edit");
|
|
15
15
|
const export_1 = require("./commands/export");
|
|
16
16
|
const import_1 = require("./commands/import");
|
|
17
|
+
const search_1 = require("./commands/search");
|
|
17
18
|
const storage_1 = require("./storage");
|
|
19
|
+
const constants_1 = require("./utils/constants");
|
|
18
20
|
const program = new commander_1.Command();
|
|
19
21
|
program
|
|
20
22
|
.name('aliasmate')
|
|
21
23
|
.description('A CLI utility to save, manage, and re-run shell commands with their working directories')
|
|
22
|
-
.version(
|
|
24
|
+
.version(constants_1.APP_VERSION);
|
|
23
25
|
// prev command - save previous command from history
|
|
24
26
|
program
|
|
25
27
|
.command('prev <name>')
|
|
26
28
|
.description('Save the previous command from shell history')
|
|
27
|
-
.action((name
|
|
28
|
-
(0, prev_1.prevCommand)(name,
|
|
29
|
+
.action((name) => {
|
|
30
|
+
(0, prev_1.prevCommand)(name, process.cwd());
|
|
29
31
|
});
|
|
30
32
|
// run command - execute a saved command
|
|
31
33
|
program
|
|
32
34
|
.command('run <name> [path]')
|
|
33
35
|
.description('Run a saved command (optionally override the working directory)')
|
|
34
|
-
.action((name, path
|
|
35
|
-
(0, run_1.runCommand)(name, path
|
|
36
|
+
.action((name, path) => {
|
|
37
|
+
void (0, run_1.runCommand)(name, path);
|
|
36
38
|
});
|
|
37
39
|
// save command - interactively save a new command
|
|
38
40
|
program
|
|
39
41
|
.command('save')
|
|
40
42
|
.description('Interactively save a new command')
|
|
41
|
-
.action((
|
|
42
|
-
(0, save_1.saveCommand)(
|
|
43
|
+
.action(() => {
|
|
44
|
+
void (0, save_1.saveCommand)(process.cwd());
|
|
43
45
|
});
|
|
44
46
|
// list commands
|
|
45
47
|
program
|
|
@@ -49,6 +51,14 @@ program
|
|
|
49
51
|
.action(() => {
|
|
50
52
|
(0, list_1.listCommand)();
|
|
51
53
|
});
|
|
54
|
+
// search commands
|
|
55
|
+
program
|
|
56
|
+
.command('search <query>')
|
|
57
|
+
.alias('find')
|
|
58
|
+
.description('Search for commands by name, command text, or directory')
|
|
59
|
+
.action((query) => {
|
|
60
|
+
(0, search_1.searchCommand)(query);
|
|
61
|
+
});
|
|
52
62
|
// delete command
|
|
53
63
|
program
|
|
54
64
|
.command('delete <name>')
|
|
@@ -62,7 +72,7 @@ program
|
|
|
62
72
|
.command('edit <name>')
|
|
63
73
|
.description('Edit a saved command')
|
|
64
74
|
.action((name) => {
|
|
65
|
-
(0, edit_1.editCommand)(name);
|
|
75
|
+
void (0, edit_1.editCommand)(name);
|
|
66
76
|
});
|
|
67
77
|
// export commands
|
|
68
78
|
program
|
|
@@ -76,23 +86,50 @@ program
|
|
|
76
86
|
.command('import <file>')
|
|
77
87
|
.description('Import commands from a JSON file')
|
|
78
88
|
.action((file) => {
|
|
79
|
-
(0, import_1.importCommand)(file);
|
|
89
|
+
void (0, import_1.importCommand)(file);
|
|
80
90
|
});
|
|
81
91
|
// config command - show config location
|
|
82
92
|
program
|
|
83
93
|
.command('config')
|
|
84
|
-
.description('Show the location of the config file')
|
|
94
|
+
.description('Show the location of the config file and directory')
|
|
85
95
|
.action(() => {
|
|
86
|
-
|
|
87
|
-
|
|
96
|
+
const aliases = (0, storage_1.loadAliases)();
|
|
97
|
+
const commandCount = Object.keys(aliases).length;
|
|
98
|
+
console.log(chalk_1.default.blue('AliasMate Configuration:'));
|
|
99
|
+
console.log(chalk_1.default.gray(` Config directory: ${(0, storage_1.getConfigDir)()}`));
|
|
100
|
+
console.log(chalk_1.default.gray(` Config file: ${(0, storage_1.getConfigPath)()}`));
|
|
101
|
+
console.log(chalk_1.default.gray(` Saved commands: ${commandCount}`));
|
|
88
102
|
});
|
|
89
103
|
// Handle unknown commands
|
|
90
104
|
program.on('command:*', () => {
|
|
91
|
-
console.error(chalk_1.default.red('
|
|
92
|
-
console.log(chalk_1.default.yellow('
|
|
105
|
+
console.error(chalk_1.default.red('Error: Unknown command "%s"'), program.args.join(' '));
|
|
106
|
+
console.log(chalk_1.default.yellow('\nAvailable commands:'));
|
|
107
|
+
console.log(chalk_1.default.gray(' prev <name> - Save previous command from history'));
|
|
108
|
+
console.log(chalk_1.default.gray(' run <name> [path] - Run a saved command'));
|
|
109
|
+
console.log(chalk_1.default.gray(' save - Interactively save a command'));
|
|
110
|
+
console.log(chalk_1.default.gray(' list (ls) - List all saved commands'));
|
|
111
|
+
console.log(chalk_1.default.gray(' search <query> - Search for commands'));
|
|
112
|
+
console.log(chalk_1.default.gray(' edit <name> - Edit a saved command'));
|
|
113
|
+
console.log(chalk_1.default.gray(' delete <name> - Delete a saved command'));
|
|
114
|
+
console.log(chalk_1.default.gray(' export <file> - Export commands to JSON'));
|
|
115
|
+
console.log(chalk_1.default.gray(' import <file> - Import commands from JSON'));
|
|
116
|
+
console.log(chalk_1.default.gray(' config - Show config file location'));
|
|
117
|
+
console.log(chalk_1.default.yellow('\nUse --help for more information.'));
|
|
118
|
+
process.exit(1);
|
|
119
|
+
});
|
|
120
|
+
// Add global error handler
|
|
121
|
+
process.on('uncaughtException', (error) => {
|
|
122
|
+
console.error(chalk_1.default.red('\nUnexpected error:'), error.message);
|
|
123
|
+
if (process.env.DEBUG) {
|
|
124
|
+
console.error(error.stack);
|
|
125
|
+
}
|
|
126
|
+
process.exit(1);
|
|
127
|
+
});
|
|
128
|
+
process.on('unhandledRejection', (reason) => {
|
|
129
|
+
console.error(chalk_1.default.red('\nUnhandled promise rejection:'), reason);
|
|
93
130
|
process.exit(1);
|
|
94
131
|
});
|
|
95
|
-
// Parse arguments
|
|
132
|
+
// Parse command line arguments
|
|
96
133
|
program.parse(process.argv);
|
|
97
134
|
// Show help if no arguments provided
|
|
98
135
|
if (!process.argv.slice(2).length) {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,kDAA0B;AAC1B,0CAA8C;AAC9C,wCAA4C;AAC5C,0CAA8C;AAC9C,0CAA8C;AAC9C,8CAAkD;AAClD,0CAA8C;AAC9C,8CAAkD;AAClD,8CAAkD;AAClD,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,kDAA0B;AAC1B,0CAA8C;AAC9C,wCAA4C;AAC5C,0CAA8C;AAC9C,0CAA8C;AAC9C,8CAAkD;AAClD,0CAA8C;AAC9C,8CAAkD;AAClD,8CAAkD;AAClD,8CAAkD;AAClD,uCAAqE;AAC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|
+
* Delete a saved command by name
|
|
3
|
+
*
|
|
4
|
+
* @param name - The name of the command to delete
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```
|
|
8
|
+
* // Delete a command
|
|
9
|
+
* deleteCommand('old-build');
|
|
10
|
+
* // Output: ✓ Deleted command "old-build"
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
1
13
|
export declare function deleteCommand(name: string): void;
|
|
2
14
|
//# sourceMappingURL=delete.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../src/commands/delete.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../src/commands/delete.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAgChD"}
|
package/dist/commands/delete.js
CHANGED
|
@@ -6,28 +6,49 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.deleteCommand = deleteCommand;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const storage_1 = require("../storage");
|
|
9
|
+
const errors_1 = require("../utils/errors");
|
|
10
|
+
const constants_1 = require("../utils/constants");
|
|
11
|
+
/**
|
|
12
|
+
* Delete a saved command by name
|
|
13
|
+
*
|
|
14
|
+
* @param name - The name of the command to delete
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```
|
|
18
|
+
* // Delete a command
|
|
19
|
+
* deleteCommand('old-build');
|
|
20
|
+
* // Output: ✓ Deleted command "old-build"
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
9
23
|
function deleteCommand(name) {
|
|
10
24
|
try {
|
|
25
|
+
// Validate command name
|
|
26
|
+
if (!name || !name.trim()) {
|
|
27
|
+
(0, errors_1.exitWithError)('Command name cannot be empty', errors_1.ExitCode.InvalidInput);
|
|
28
|
+
}
|
|
11
29
|
// Check if alias exists
|
|
12
30
|
const alias = (0, storage_1.getAlias)(name);
|
|
13
31
|
if (!alias) {
|
|
14
|
-
console.error(chalk_1.default.red(`Error:
|
|
15
|
-
console.log(chalk_1.default.yellow(
|
|
16
|
-
process.exit(
|
|
32
|
+
console.error(chalk_1.default.red(`Error: ${constants_1.ERROR_MESSAGES.commandNotFound(name)}`));
|
|
33
|
+
console.log(chalk_1.default.yellow(constants_1.HELP_MESSAGES.useList));
|
|
34
|
+
process.exit(errors_1.ExitCode.InvalidInput);
|
|
17
35
|
}
|
|
36
|
+
// Show what will be deleted
|
|
37
|
+
console.log(chalk_1.default.yellow(`About to delete:`));
|
|
38
|
+
console.log(chalk_1.default.gray(` Name: ${name}`));
|
|
39
|
+
console.log(chalk_1.default.gray(` Command: ${alias.command}`));
|
|
40
|
+
console.log(chalk_1.default.gray(` Directory: ${alias.directory}\n`));
|
|
18
41
|
// Delete the alias
|
|
19
42
|
const success = (0, storage_1.deleteAlias)(name);
|
|
20
43
|
if (success) {
|
|
21
|
-
console.log(chalk_1.default.green(`✓
|
|
44
|
+
console.log(chalk_1.default.green(`✓ ${constants_1.SUCCESS_MESSAGES.deleted(name)}`));
|
|
22
45
|
}
|
|
23
46
|
else {
|
|
24
|
-
|
|
25
|
-
process.exit(1);
|
|
47
|
+
(0, errors_1.exitWithError)(constants_1.ERROR_MESSAGES.couldNotDelete);
|
|
26
48
|
}
|
|
27
49
|
}
|
|
28
50
|
catch (error) {
|
|
29
|
-
|
|
30
|
-
process.exit(1);
|
|
51
|
+
(0, errors_1.handleError)(error, 'Failed to delete command');
|
|
31
52
|
}
|
|
32
53
|
}
|
|
33
54
|
//# sourceMappingURL=delete.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../src/commands/delete.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../src/commands/delete.ts"],"names":[],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;YACZ,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,KAAK,4BAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QAClE,CAAC;aAAM,CAAC;YACN,IAAA,sBAAa,EAAC,0BAAc,CAAC,cAAc,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAA,oBAAW,EAAC,KAAK,EAAE,0BAA0B,CAAC,CAAC;IACjD,CAAC;AACH,CAAC"}
|
package/dist/commands/edit.d.ts
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edit an existing command interactively
|
|
3
|
+
*
|
|
4
|
+
* @param name - The name of the command to edit
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```
|
|
8
|
+
* // User is prompted to update:
|
|
9
|
+
* // - Command (pre-filled with current value)
|
|
10
|
+
* // - Working directory (pre-filled with current value)
|
|
11
|
+
* await editCommand('build-prod');
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
1
14
|
export declare function editCommand(name: string): Promise<void>;
|
|
2
15
|
//# sourceMappingURL=edit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../src/commands/edit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../src/commands/edit.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;GAYG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAwE7D"}
|
package/dist/commands/edit.js
CHANGED
|
@@ -4,65 +4,92 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.editCommand = editCommand;
|
|
7
|
-
const inquirer_1 = __importDefault(require("inquirer"));
|
|
8
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
8
|
const storage_1 = require("../storage");
|
|
9
|
+
const errors_1 = require("../utils/errors");
|
|
10
|
+
const constants_1 = require("../utils/constants");
|
|
11
|
+
const prompts_1 = require("../utils/prompts");
|
|
12
|
+
/**
|
|
13
|
+
* Edit an existing command interactively
|
|
14
|
+
*
|
|
15
|
+
* @param name - The name of the command to edit
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```
|
|
19
|
+
* // User is prompted to update:
|
|
20
|
+
* // - Command (pre-filled with current value)
|
|
21
|
+
* // - Working directory (pre-filled with current value)
|
|
22
|
+
* await editCommand('build-prod');
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
10
25
|
async function editCommand(name) {
|
|
11
26
|
try {
|
|
12
27
|
// Get the existing alias
|
|
13
28
|
const alias = (0, storage_1.getAlias)(name);
|
|
14
29
|
if (!alias) {
|
|
15
|
-
console.error(chalk_1.default.red(`Error:
|
|
16
|
-
console.log(chalk_1.default.yellow(
|
|
17
|
-
process.exit(
|
|
30
|
+
console.error(chalk_1.default.red(`Error: ${constants_1.ERROR_MESSAGES.commandNotFound(name)}`));
|
|
31
|
+
console.log(chalk_1.default.yellow(constants_1.HELP_MESSAGES.useList));
|
|
32
|
+
process.exit(errors_1.ExitCode.InvalidInput);
|
|
18
33
|
}
|
|
19
34
|
console.log(chalk_1.default.blue(`Editing command: ${name}\n`));
|
|
20
35
|
// Prompt for new values
|
|
21
|
-
const
|
|
36
|
+
const prompts = [
|
|
22
37
|
{
|
|
23
38
|
type: 'input',
|
|
24
39
|
name: 'command',
|
|
25
40
|
message: 'Command:',
|
|
26
41
|
default: alias.command,
|
|
27
42
|
validate: (input) => {
|
|
28
|
-
|
|
29
|
-
|
|
43
|
+
const trimmed = input.trim();
|
|
44
|
+
if (!trimmed) {
|
|
45
|
+
return constants_1.HELP_MESSAGES.emptyValue('Command');
|
|
30
46
|
}
|
|
31
47
|
return true;
|
|
32
|
-
}
|
|
48
|
+
},
|
|
33
49
|
},
|
|
34
50
|
{
|
|
35
51
|
type: 'input',
|
|
36
52
|
name: 'directory',
|
|
37
53
|
message: 'Working directory:',
|
|
38
|
-
default: alias.directory
|
|
39
|
-
|
|
40
|
-
|
|
54
|
+
default: alias.directory,
|
|
55
|
+
validate: (input) => {
|
|
56
|
+
const trimmed = input.trim();
|
|
57
|
+
if (!trimmed) {
|
|
58
|
+
return constants_1.HELP_MESSAGES.emptyValue('Directory');
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
const answers = await (0, prompts_1.promptMultiple)(prompts);
|
|
41
65
|
// Check if anything changed
|
|
42
66
|
if (answers.command === alias.command && answers.directory === alias.directory) {
|
|
43
67
|
console.log(chalk_1.default.yellow('No changes made'));
|
|
44
68
|
return;
|
|
45
69
|
}
|
|
46
70
|
// Update the alias
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
71
|
+
try {
|
|
72
|
+
const success = (0, storage_1.setAlias)(name, answers.command, answers.directory);
|
|
73
|
+
if (success) {
|
|
74
|
+
console.log(chalk_1.default.green(`✓ ${constants_1.SUCCESS_MESSAGES.updated(name)}`));
|
|
75
|
+
console.log(chalk_1.default.gray(` Command: ${answers.command}`));
|
|
76
|
+
console.log(chalk_1.default.gray(` Directory: ${answers.directory}`));
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
(0, errors_1.exitWithError)(constants_1.ERROR_MESSAGES.couldNotUpdate);
|
|
80
|
+
}
|
|
52
81
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
process.exit(1);
|
|
82
|
+
catch (error) {
|
|
83
|
+
(0, errors_1.exitWithError)(`${constants_1.ERROR_MESSAGES.couldNotUpdate}: ${error.message}`);
|
|
56
84
|
}
|
|
57
85
|
}
|
|
58
86
|
catch (error) {
|
|
59
|
-
if (
|
|
60
|
-
|
|
87
|
+
if ((0, errors_1.isInquirerTTYError)(error)) {
|
|
88
|
+
(0, errors_1.exitWithError)(constants_1.ERROR_MESSAGES.interactiveNotSupported, errors_1.ExitCode.GeneralError);
|
|
61
89
|
}
|
|
62
90
|
else {
|
|
63
|
-
|
|
91
|
+
(0, errors_1.handleError)(error, 'Failed to edit command');
|
|
64
92
|
}
|
|
65
|
-
process.exit(1);
|
|
66
93
|
}
|
|
67
94
|
}
|
|
68
95
|
//# sourceMappingURL=edit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../src/commands/edit.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../src/commands/edit.ts"],"names":[],"mappings":";;;;;AAmBA,kCAwEC;AA3FD,kDAA0B;AAC1B,wCAAgD;AAChD,4CAA2F;AAC3F,kDAAqF;AACrF,8CAAmE;AAEnE;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,WAAW,CAAC,IAAY;IAC5C,IAAI,CAAC;QACH,yBAAyB;QACzB,MAAM,KAAK,GAAG,IAAA,kBAAQ,EAAC,IAAI,CAAC,CAAC;QAE7B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,UAAU,0BAAc,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;YAC3E,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,yBAAa,CAAC,OAAO,CAAC,CAAC,CAAC;YACjD,OAAO,CAAC,IAAI,CAAC,iBAAQ,CAAC,YAAY,CAAC,CAAC;QACtC,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,CAAC,CAAC;QAEtD,wBAAwB;QACxB,MAAM,OAAO,GAAsB;YACjC;gBACE,IAAI,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