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
|
@@ -1,2 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Export all saved commands to a JSON file
|
|
3
|
+
*
|
|
4
|
+
* Creates a portable backup of all commands with metadata, suitable for:
|
|
5
|
+
* - Sharing with team members
|
|
6
|
+
* - Backing up your command library
|
|
7
|
+
* - Migrating between machines
|
|
8
|
+
*
|
|
9
|
+
* @param filePath - The path where the export file should be created
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```
|
|
13
|
+
* // Export to a file
|
|
14
|
+
* exportCommand('./my-commands.json');
|
|
15
|
+
* // Output: ✓ Exported 15 command(s) to /path/to/my-commands.json
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
1
18
|
export declare function exportCommand(filePath: string): void;
|
|
2
19
|
//# sourceMappingURL=export.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAyDpD"}
|
package/dist/commands/export.js
CHANGED
|
@@ -41,34 +41,69 @@ const fs = __importStar(require("fs"));
|
|
|
41
41
|
const path = __importStar(require("path"));
|
|
42
42
|
const chalk_1 = __importDefault(require("chalk"));
|
|
43
43
|
const storage_1 = require("../storage");
|
|
44
|
+
const errors_1 = require("../utils/errors");
|
|
45
|
+
const constants_1 = require("../utils/constants");
|
|
46
|
+
/**
|
|
47
|
+
* Export all saved commands to a JSON file
|
|
48
|
+
*
|
|
49
|
+
* Creates a portable backup of all commands with metadata, suitable for:
|
|
50
|
+
* - Sharing with team members
|
|
51
|
+
* - Backing up your command library
|
|
52
|
+
* - Migrating between machines
|
|
53
|
+
*
|
|
54
|
+
* @param filePath - The path where the export file should be created
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```
|
|
58
|
+
* // Export to a file
|
|
59
|
+
* exportCommand('./my-commands.json');
|
|
60
|
+
* // Output: ✓ Exported 15 command(s) to /path/to/my-commands.json
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
44
63
|
function exportCommand(filePath) {
|
|
45
64
|
try {
|
|
65
|
+
// Validate file path
|
|
66
|
+
if (!filePath || !filePath.trim()) {
|
|
67
|
+
(0, errors_1.exitWithError)('File path cannot be empty', errors_1.ExitCode.InvalidInput);
|
|
68
|
+
}
|
|
46
69
|
const aliases = (0, storage_1.loadAliases)();
|
|
47
70
|
const names = Object.keys(aliases);
|
|
48
71
|
if (names.length === 0) {
|
|
49
|
-
console.log(chalk_1.default.yellow(
|
|
72
|
+
console.log(chalk_1.default.yellow(constants_1.HELP_MESSAGES.noCommands));
|
|
50
73
|
return;
|
|
51
74
|
}
|
|
52
75
|
// Resolve the file path
|
|
53
76
|
const resolvedPath = path.resolve(filePath);
|
|
77
|
+
// Check if file already exists and warn user
|
|
78
|
+
if (fs.existsSync(resolvedPath)) {
|
|
79
|
+
console.log(chalk_1.default.yellow(`Warning: File already exists and will be overwritten: ${resolvedPath}`));
|
|
80
|
+
}
|
|
81
|
+
// Ensure directory exists
|
|
82
|
+
const dirPath = path.dirname(resolvedPath);
|
|
83
|
+
if (!fs.existsSync(dirPath)) {
|
|
84
|
+
try {
|
|
85
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
86
|
+
}
|
|
87
|
+
catch (mkdirError) {
|
|
88
|
+
(0, errors_1.exitWithError)(`Could not create directory: ${mkdirError.message}`, errors_1.ExitCode.PermissionDenied);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
54
91
|
// Export as JSON
|
|
55
92
|
const exportData = {
|
|
56
93
|
exportedAt: new Date().toISOString(),
|
|
57
94
|
version: '1.0',
|
|
58
|
-
aliases: aliases
|
|
95
|
+
aliases: aliases,
|
|
59
96
|
};
|
|
60
97
|
try {
|
|
61
98
|
fs.writeFileSync(resolvedPath, JSON.stringify(exportData, null, 2), 'utf8');
|
|
62
|
-
console.log(chalk_1.default.green(`✓
|
|
99
|
+
console.log(chalk_1.default.green(`✓ ${constants_1.SUCCESS_MESSAGES.exported(names.length, resolvedPath)}`));
|
|
63
100
|
}
|
|
64
101
|
catch (writeError) {
|
|
65
|
-
|
|
66
|
-
process.exit(1);
|
|
102
|
+
(0, errors_1.exitWithError)(`${constants_1.ERROR_MESSAGES.couldNotWrite}: ${writeError.message}`, errors_1.ExitCode.PermissionDenied);
|
|
67
103
|
}
|
|
68
104
|
}
|
|
69
105
|
catch (error) {
|
|
70
|
-
|
|
71
|
-
process.exit(1);
|
|
106
|
+
(0, errors_1.handleError)(error, 'Failed to export commands');
|
|
72
107
|
}
|
|
73
108
|
}
|
|
74
109
|
//# sourceMappingURL=export.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,sCAyDC;AAjFD,uCAAyB;AACzB,2CAA6B;AAC7B,kDAA0B;AAC1B,wCAAyC;AACzC,4CAAuE;AACvE,kDAAqF;AAErF;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,aAAa,CAAC,QAAgB;IAC5C,IAAI,CAAC;QACH,qBAAqB;QACrB,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;YAClC,IAAA,sBAAa,EAAC,2BAA2B,EAAE,iBAAQ,CAAC,YAAY,CAAC,CAAC;QACpE,CAAC;QAED,MAAM,OAAO,GAAG,IAAA,qBAAW,GAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEnC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,yBAAa,CAAC,UAAU,CAAC,CAAC,CAAC;YACpD,OAAO;QACT,CAAC;QAED,wBAAwB;QACxB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAE5C,6CAA6C;QAC7C,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YAChC,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,MAAM,C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+1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import commands from a JSON file
|
|
3
|
+
*
|
|
4
|
+
* Handles conflicts intelligently by prompting the user for each conflict:
|
|
5
|
+
* - Overwrite: Replace existing command with imported one
|
|
6
|
+
* - Skip: Keep existing command, discard imported one
|
|
7
|
+
* - Rename: Save imported command with a different name
|
|
8
|
+
*
|
|
9
|
+
* @param filePath - The path to the JSON file to import from
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```
|
|
13
|
+
* // Import commands from a file
|
|
14
|
+
* await importCommand('./team-commands.json');
|
|
15
|
+
*
|
|
16
|
+
* // If conflicts are found, user is prompted:
|
|
17
|
+
* // - Overwrite existing
|
|
18
|
+
* // - Skip this command
|
|
19
|
+
* // - Rename imported command
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
1
22
|
export declare function importCommand(filePath: string): Promise<void>;
|
|
2
23
|
//# sourceMappingURL=import.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/commands/import.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/commands/import.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuLnE"}
|
package/dist/commands/import.js
CHANGED
|
@@ -39,17 +39,39 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.importCommand = importCommand;
|
|
40
40
|
const fs = __importStar(require("fs"));
|
|
41
41
|
const path = __importStar(require("path"));
|
|
42
|
-
const inquirer_1 = __importDefault(require("inquirer"));
|
|
43
42
|
const chalk_1 = __importDefault(require("chalk"));
|
|
44
43
|
const storage_1 = require("../storage");
|
|
44
|
+
const errors_1 = require("../utils/errors");
|
|
45
|
+
const constants_1 = require("../utils/constants");
|
|
46
|
+
const prompts_1 = require("../utils/prompts");
|
|
47
|
+
/**
|
|
48
|
+
* Import commands from a JSON file
|
|
49
|
+
*
|
|
50
|
+
* Handles conflicts intelligently by prompting the user for each conflict:
|
|
51
|
+
* - Overwrite: Replace existing command with imported one
|
|
52
|
+
* - Skip: Keep existing command, discard imported one
|
|
53
|
+
* - Rename: Save imported command with a different name
|
|
54
|
+
*
|
|
55
|
+
* @param filePath - The path to the JSON file to import from
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```
|
|
59
|
+
* // Import commands from a file
|
|
60
|
+
* await importCommand('./team-commands.json');
|
|
61
|
+
*
|
|
62
|
+
* // If conflicts are found, user is prompted:
|
|
63
|
+
* // - Overwrite existing
|
|
64
|
+
* // - Skip this command
|
|
65
|
+
* // - Rename imported command
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
45
68
|
async function importCommand(filePath) {
|
|
46
69
|
try {
|
|
47
70
|
// Resolve the file path
|
|
48
71
|
const resolvedPath = path.resolve(filePath);
|
|
49
72
|
// Check if file exists
|
|
50
73
|
if (!fs.existsSync(resolvedPath)) {
|
|
51
|
-
|
|
52
|
-
process.exit(1);
|
|
74
|
+
(0, errors_1.exitWithError)(constants_1.ERROR_MESSAGES.fileNotFound(resolvedPath), errors_1.ExitCode.FileNotFound);
|
|
53
75
|
}
|
|
54
76
|
// Read and parse the file
|
|
55
77
|
let importData;
|
|
@@ -58,24 +80,46 @@ async function importCommand(filePath) {
|
|
|
58
80
|
importData = JSON.parse(fileContent);
|
|
59
81
|
}
|
|
60
82
|
catch (parseError) {
|
|
61
|
-
console.error(chalk_1.default.red(
|
|
83
|
+
console.error(chalk_1.default.red(`Error: ${constants_1.ERROR_MESSAGES.invalidJson}`));
|
|
62
84
|
console.error(parseError.message);
|
|
63
|
-
process.exit(
|
|
85
|
+
process.exit(errors_1.ExitCode.InvalidInput);
|
|
64
86
|
}
|
|
65
87
|
// Validate the import data structure
|
|
66
88
|
if (!importData.aliases || typeof importData.aliases !== 'object') {
|
|
67
|
-
|
|
68
|
-
process.exit(1);
|
|
89
|
+
(0, errors_1.exitWithError)(constants_1.ERROR_MESSAGES.invalidFormat, errors_1.ExitCode.InvalidInput);
|
|
69
90
|
}
|
|
70
91
|
const importAliases = importData.aliases;
|
|
71
92
|
const importNames = Object.keys(importAliases);
|
|
93
|
+
// Validate each alias structure
|
|
94
|
+
for (const name of importNames) {
|
|
95
|
+
const alias = importAliases[name];
|
|
96
|
+
if (!alias ||
|
|
97
|
+
typeof alias !== 'object' ||
|
|
98
|
+
typeof alias.command !== 'string' ||
|
|
99
|
+
typeof alias.directory !== 'string' ||
|
|
100
|
+
!alias.command.trim() ||
|
|
101
|
+
!alias.directory.trim()) {
|
|
102
|
+
(0, errors_1.exitWithError)(constants_1.ERROR_MESSAGES.invalidAliasStructure(name), errors_1.ExitCode.InvalidInput);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
72
105
|
if (importNames.length === 0) {
|
|
73
|
-
console.log(chalk_1.default.yellow(
|
|
106
|
+
console.log(chalk_1.default.yellow(constants_1.HELP_MESSAGES.noCommands));
|
|
74
107
|
return;
|
|
75
108
|
}
|
|
76
109
|
console.log(chalk_1.default.blue(`Found ${importNames.length} command(s) to import\n`));
|
|
77
|
-
//
|
|
110
|
+
// Create backup of existing config before importing
|
|
78
111
|
const existingAliases = (0, storage_1.loadAliases)();
|
|
112
|
+
if (Object.keys(existingAliases).length > 0) {
|
|
113
|
+
const configPath = (0, storage_1.getConfigPath)();
|
|
114
|
+
const backupPath = `${configPath}.backup.${Date.now()}`;
|
|
115
|
+
try {
|
|
116
|
+
fs.copyFileSync(configPath, backupPath);
|
|
117
|
+
console.log(chalk_1.default.gray(`Backup created: ${backupPath}\n`));
|
|
118
|
+
}
|
|
119
|
+
catch (backupError) {
|
|
120
|
+
console.warn(chalk_1.default.yellow(`Warning: Could not create backup: ${backupError.message}`));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
79
123
|
const conflicts = [];
|
|
80
124
|
const newAliases = [];
|
|
81
125
|
// Check for conflicts
|
|
@@ -96,40 +140,43 @@ async function importCommand(filePath) {
|
|
|
96
140
|
console.log(chalk_1.default.gray(` ${existingAliases[name].command}`));
|
|
97
141
|
console.log(chalk_1.default.gray(`Importing: ${name}`));
|
|
98
142
|
console.log(chalk_1.default.gray(` ${importAliases[name].command}\n`));
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
]);
|
|
143
|
+
const actionPrompt = {
|
|
144
|
+
type: 'list',
|
|
145
|
+
name: 'action',
|
|
146
|
+
message: `What should we do with "${name}"?`,
|
|
147
|
+
choices: [
|
|
148
|
+
{ name: 'Overwrite existing', value: 'overwrite' },
|
|
149
|
+
{ name: 'Skip this command', value: 'skip' },
|
|
150
|
+
{ name: 'Rename imported command', value: 'rename' },
|
|
151
|
+
],
|
|
152
|
+
};
|
|
153
|
+
const action = await (0, prompts_1.promptList)(actionPrompt);
|
|
111
154
|
if (action === 'rename') {
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
155
|
+
const renamePrompt = {
|
|
156
|
+
type: 'input',
|
|
157
|
+
name: 'newName',
|
|
158
|
+
message: 'Enter new name:',
|
|
159
|
+
default: `${name}_imported`,
|
|
160
|
+
validate: (input) => {
|
|
161
|
+
const trimmed = input.trim();
|
|
162
|
+
if (!trimmed) {
|
|
163
|
+
return constants_1.HELP_MESSAGES.emptyValue('Name');
|
|
164
|
+
}
|
|
165
|
+
if (trimmed.includes(' ')) {
|
|
166
|
+
return constants_1.HELP_MESSAGES.invalidName;
|
|
167
|
+
}
|
|
168
|
+
// Check for invalid characters
|
|
169
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(trimmed)) {
|
|
170
|
+
return 'Name can only contain letters, numbers, hyphens, and underscores';
|
|
171
|
+
}
|
|
172
|
+
if ((0, storage_1.aliasExists)(trimmed) || resolutions[trimmed]) {
|
|
173
|
+
return `Name "${trimmed}" is already taken`;
|
|
129
174
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
175
|
+
return true;
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
const newName = await (0, prompts_1.promptText)(renamePrompt);
|
|
179
|
+
resolutions[name] = { action: 'rename', newName: newName.trim() };
|
|
133
180
|
}
|
|
134
181
|
else {
|
|
135
182
|
resolutions[name] = { action };
|
|
@@ -166,25 +213,23 @@ async function importCommand(filePath) {
|
|
|
166
213
|
// Save the updated aliases
|
|
167
214
|
const success = (0, storage_1.saveAliases)(updatedAliases);
|
|
168
215
|
if (success) {
|
|
169
|
-
console.log(chalk_1.default.green(`✓
|
|
216
|
+
console.log(chalk_1.default.green(`✓ ${constants_1.SUCCESS_MESSAGES.importComplete}:`));
|
|
170
217
|
console.log(chalk_1.default.gray(` Imported: ${importedCount} command(s)`));
|
|
171
218
|
if (skippedCount > 0) {
|
|
172
219
|
console.log(chalk_1.default.gray(` Skipped: ${skippedCount} command(s)`));
|
|
173
220
|
}
|
|
174
221
|
}
|
|
175
222
|
else {
|
|
176
|
-
|
|
177
|
-
process.exit(1);
|
|
223
|
+
(0, errors_1.exitWithError)('Could not save imported commands');
|
|
178
224
|
}
|
|
179
225
|
}
|
|
180
226
|
catch (error) {
|
|
181
|
-
if (
|
|
182
|
-
|
|
227
|
+
if ((0, errors_1.isInquirerTTYError)(error)) {
|
|
228
|
+
(0, errors_1.exitWithError)(constants_1.ERROR_MESSAGES.interactiveNotSupported, errors_1.ExitCode.GeneralError);
|
|
183
229
|
}
|
|
184
230
|
else {
|
|
185
|
-
|
|
231
|
+
(0, errors_1.handleError)(error, 'Failed to import commands');
|
|
186
232
|
}
|
|
187
|
-
process.exit(1);
|
|
188
233
|
}
|
|
189
234
|
}
|
|
190
235
|
//# sourceMappingURL=import.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.js","sourceRoot":"","sources":["../../src/commands/import.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"import.js","sourceRoot":"","sources":["../../src/commands/import.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,sCAuLC;AAhOD,uCAAyB;AACzB,2CAA6B;AAC7B,kDAA0B;AAC1B,wCAA+F;AAC/F,4CAA2F;AAC3F,kDAAqF;AACrF,8CAAuF;AAcvF;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,KAAK,UAAU,aAAa,CAAC,QAAgB;IAClD,IAAI,CAAC;QACH,wBAAwB;QACxB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAE5C,uBAAuB;QACvB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YACjC,IAAA,sBAAa,EAAC,0BAAc,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,iBAAQ,CAAC,YAAY,CAAC,CAAC;QAClF,CAAC;QAED,0BAA0B;QAC1B,IAAI,UAAsB,CAAC;QAC3B,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;YAC1D,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAe,CAAC;QACrD,CAAC;QAAC,OAAO,UAAU,EAAE,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,UAAU,0BAAc,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;YACjE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;QAClD,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/commands/list.d.ts
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List all saved commands with their details
|
|
3
|
+
*
|
|
4
|
+
* Displays commands alphabetically with their command text and working directory.
|
|
5
|
+
* If no commands are saved, provides guidance on how to save commands.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```
|
|
9
|
+
* // Output:
|
|
10
|
+
* // Saved commands (3):
|
|
11
|
+
* //
|
|
12
|
+
* // build-prod
|
|
13
|
+
* // Command: npm run build --production
|
|
14
|
+
* // Directory: /home/user/project
|
|
15
|
+
* //
|
|
16
|
+
* // deploy
|
|
17
|
+
* // Command: ./deploy.sh
|
|
18
|
+
* // Directory: /home/user/scripts
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
1
21
|
export declare function listCommand(): void;
|
|
2
22
|
//# sourceMappingURL=list.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAiClC"}
|
package/dist/commands/list.js
CHANGED
|
@@ -1,18 +1,74 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
5
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
39
|
exports.listCommand = listCommand;
|
|
7
40
|
const chalk_1 = __importDefault(require("chalk"));
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
8
42
|
const storage_1 = require("../storage");
|
|
43
|
+
const errors_1 = require("../utils/errors");
|
|
44
|
+
const constants_1 = require("../utils/constants");
|
|
45
|
+
/**
|
|
46
|
+
* List all saved commands with their details
|
|
47
|
+
*
|
|
48
|
+
* Displays commands alphabetically with their command text and working directory.
|
|
49
|
+
* If no commands are saved, provides guidance on how to save commands.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```
|
|
53
|
+
* // Output:
|
|
54
|
+
* // Saved commands (3):
|
|
55
|
+
* //
|
|
56
|
+
* // build-prod
|
|
57
|
+
* // Command: npm run build --production
|
|
58
|
+
* // Directory: /home/user/project
|
|
59
|
+
* //
|
|
60
|
+
* // deploy
|
|
61
|
+
* // Command: ./deploy.sh
|
|
62
|
+
* // Directory: /home/user/scripts
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
9
65
|
function listCommand() {
|
|
10
66
|
try {
|
|
11
67
|
const aliases = (0, storage_1.loadAliases)();
|
|
12
68
|
const names = Object.keys(aliases);
|
|
13
69
|
if (names.length === 0) {
|
|
14
|
-
console.log(chalk_1.default.yellow(
|
|
15
|
-
console.log(chalk_1.default.gray(
|
|
70
|
+
console.log(chalk_1.default.yellow(constants_1.HELP_MESSAGES.noCommands));
|
|
71
|
+
console.log(chalk_1.default.gray(constants_1.HELP_MESSAGES.useSaveOrPrev));
|
|
16
72
|
return;
|
|
17
73
|
}
|
|
18
74
|
console.log(chalk_1.default.bold(`\nSaved commands (${names.length}):\n`));
|
|
@@ -20,15 +76,20 @@ function listCommand() {
|
|
|
20
76
|
names.sort();
|
|
21
77
|
for (const name of names) {
|
|
22
78
|
const alias = aliases[name];
|
|
23
|
-
|
|
79
|
+
// Check if directory still exists
|
|
80
|
+
const dirExists = fs.existsSync(alias.directory);
|
|
81
|
+
const dirIndicator = dirExists ? '' : chalk_1.default.red(' [DIR NOT FOUND]');
|
|
82
|
+
console.log(chalk_1.default.cyan(` ${name}${dirIndicator}`));
|
|
24
83
|
console.log(chalk_1.default.gray(` Command: ${alias.command}`));
|
|
25
84
|
console.log(chalk_1.default.gray(` Directory: ${alias.directory}`));
|
|
85
|
+
if (alias.createdAt) {
|
|
86
|
+
console.log(chalk_1.default.gray(` Created: ${new Date(alias.createdAt).toLocaleString()}`));
|
|
87
|
+
}
|
|
26
88
|
console.log();
|
|
27
89
|
}
|
|
28
90
|
}
|
|
29
91
|
catch (error) {
|
|
30
|
-
|
|
31
|
-
process.exit(1);
|
|
92
|
+
(0, errors_1.handleError)(error, 'Failed to list commands');
|
|
32
93
|
}
|
|
33
94
|
}
|
|
34
95
|
//# sourceMappingURL=list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,kCAiCC;AA3DD,kDAA0B;AAC1B,uCAAyB;AACzB,wCAAyC;AACzC,4CAA8C;AAC9C,kDAAmD;AAEnD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,WAAW;IACzB,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAA,qBAAW,GAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEnC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,yBAAa,CAAC,UAAU,CAAC,CAAC,CAAC;YACpD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,yBAAa,CAAC,aAAa,CAAC,CAAC,CAAC;YACrD,OAAO;QACT,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,qBAAqB,KAAK,CAAC,MAAM,MAAM,CAAC,CAAC,CAAC;QAEjE,sBAAsB;QACtB,KAAK,CAAC,IAAI,EAAE,CAAC;QAEb,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;YAC5B,kCAAkC;YAClC,MAAM,SAAS,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YACjD,MAAM,YAAY,GAAG,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;YAEpE,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,KAAK,IAAI,GAAG,YAAY,EAAE,CAAC,CAAC,CAAC;YACpD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,gBAAgB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACzD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,kBAAkB,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;YAC7D,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;gBACpB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC;YACxF,CAAC;YACD,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAA,oBAAW,EAAC,KAAK,EAAE,yBAAyB,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
|
package/dist/commands/prev.d.ts
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Save the previous command from shell history
|
|
3
|
+
*
|
|
4
|
+
* @param name - The name to save the command under
|
|
5
|
+
* @param cwd - The working directory to save with the command (defaults to process.cwd())
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```
|
|
9
|
+
* // After running: npm run build --production
|
|
10
|
+
* // Execute: aliasmate prev build-prod
|
|
11
|
+
* // The npm command is saved and can be re-run from anywhere
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function prevCommand(name: string, cwd?: string): void;
|
|
2
15
|
//# sourceMappingURL=prev.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prev.d.ts","sourceRoot":"","sources":["../../src/commands/prev.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prev.d.ts","sourceRoot":"","sources":["../../src/commands/prev.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAE,MAAsB,GAAG,IAAI,CA8C3E"}
|
package/dist/commands/prev.js
CHANGED
|
@@ -7,34 +7,62 @@ exports.prevCommand = prevCommand;
|
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const history_1 = require("../utils/history");
|
|
9
9
|
const storage_1 = require("../storage");
|
|
10
|
-
|
|
10
|
+
const errors_1 = require("../utils/errors");
|
|
11
|
+
const constants_1 = require("../utils/constants");
|
|
12
|
+
/**
|
|
13
|
+
* Save the previous command from shell history
|
|
14
|
+
*
|
|
15
|
+
* @param name - The name to save the command under
|
|
16
|
+
* @param cwd - The working directory to save with the command (defaults to process.cwd())
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```
|
|
20
|
+
* // After running: npm run build --production
|
|
21
|
+
* // Execute: aliasmate prev build-prod
|
|
22
|
+
* // The npm command is saved and can be re-run from anywhere
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
function prevCommand(name, cwd = process.cwd()) {
|
|
11
26
|
try {
|
|
12
27
|
// Get the last command from history
|
|
13
28
|
const lastCommand = (0, history_1.getLastCommand)();
|
|
14
29
|
if (!lastCommand) {
|
|
15
|
-
console.error(chalk_1.default.red(
|
|
30
|
+
console.error(chalk_1.default.red(`Error: ${constants_1.ERROR_MESSAGES.historyNotAvailable}`));
|
|
16
31
|
console.log(chalk_1.default.yellow('\nTroubleshooting:'));
|
|
17
32
|
console.log(chalk_1.default.gray('1. Make sure your shell history is enabled'));
|
|
18
33
|
console.log(chalk_1.default.gray('2. For real-time history capture, configure your shell:'));
|
|
19
34
|
console.log(chalk_1.default.gray(` ${(0, history_1.getHistoryConfigInstructions)()}`));
|
|
20
35
|
console.log(chalk_1.default.gray('3. Or use "aliasmate save" to manually enter the command'));
|
|
21
|
-
process.exit(
|
|
36
|
+
process.exit(errors_1.ExitCode.GeneralError);
|
|
37
|
+
}
|
|
38
|
+
// Validate command name
|
|
39
|
+
if (!name || !name.trim()) {
|
|
40
|
+
(0, errors_1.exitWithError)('Command name cannot be empty', errors_1.ExitCode.InvalidInput);
|
|
41
|
+
}
|
|
42
|
+
if (name.includes(' ')) {
|
|
43
|
+
(0, errors_1.exitWithError)('Command name cannot contain spaces', errors_1.ExitCode.InvalidInput);
|
|
44
|
+
}
|
|
45
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(name)) {
|
|
46
|
+
(0, errors_1.exitWithError)('Command name can only contain letters, numbers, hyphens, and underscores', errors_1.ExitCode.InvalidInput);
|
|
22
47
|
}
|
|
23
48
|
// Save the command with the current directory
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
49
|
+
try {
|
|
50
|
+
const success = (0, storage_1.setAlias)(name, lastCommand, cwd);
|
|
51
|
+
if (success) {
|
|
52
|
+
console.log(chalk_1.default.green(`✓ ${constants_1.SUCCESS_MESSAGES.saved(name)}`));
|
|
53
|
+
console.log(chalk_1.default.gray(` Command: ${lastCommand}`));
|
|
54
|
+
console.log(chalk_1.default.gray(` Directory: ${cwd}`));
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
(0, errors_1.exitWithError)(constants_1.ERROR_MESSAGES.couldNotSave);
|
|
58
|
+
}
|
|
29
59
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
process.exit(1);
|
|
60
|
+
catch (error) {
|
|
61
|
+
(0, errors_1.exitWithError)(`${constants_1.ERROR_MESSAGES.couldNotSave}: ${error.message}`);
|
|
33
62
|
}
|
|
34
63
|
}
|
|
35
64
|
catch (error) {
|
|
36
|
-
|
|
37
|
-
process.exit(1);
|
|
65
|
+
(0, errors_1.handleError)(error, 'Failed to save command from history');
|
|
38
66
|
}
|
|
39
67
|
}
|
|
40
68
|
//# sourceMappingURL=prev.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prev.js","sourceRoot":"","sources":["../../src/commands/prev.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"prev.js","sourceRoot":"","sources":["../../src/commands/prev.ts"],"names":[],"mappings":";;;;;AAmBA,kCA8CC;AAjED,kDAA0B;AAC1B,8CAAgF;AAChF,wCAAsC;AACtC,4CAAuE;AACvE,kDAAsE;AAEtE;;;;;;;;;;;;GAYG;AACH,SAAgB,WAAW,CAAC,IAAY,EAAE,MAAc,OAAO,CAAC,GAAG,EAAE;IACnE,IAAI,CAAC;QACH,oCAAoC;QACpC,MAAM,WAAW,GAAG,IAAA,wBAAc,GAAE,CAAC;QAErC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,UAAU,0BAAc,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;YACzE,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;YAChD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC,CAAC;YACtE,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC,CAAC;YACnF,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,MAAM,IAAA,sCAA4B,GAAE,EAAE,CAAC,CAAC,CAAC;YAChE,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAC,CAAC;YACpF,OAAO,CAAC,IAAI,CAAC,i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