aliasmate 1.5.1 → 1.6.1
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 +125 -0
- package/README.md +304 -3
- package/dist/cli.js +99 -13
- package/dist/cli.js.map +1 -1
- package/dist/commands/alias.d.ts +30 -0
- package/dist/commands/alias.d.ts.map +1 -0
- package/dist/commands/alias.js +213 -0
- package/dist/commands/alias.js.map +1 -0
- package/dist/commands/completion.d.ts +17 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +363 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/edit.d.ts +2 -1
- package/dist/commands/edit.d.ts.map +1 -1
- package/dist/commands/edit.js +44 -1
- package/dist/commands/edit.js.map +1 -1
- package/dist/commands/export.d.ts +7 -3
- package/dist/commands/export.d.ts.map +1 -1
- package/dist/commands/export.js +23 -10
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/list.d.ts +4 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +14 -71
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/recent.d.ts +24 -0
- package/dist/commands/recent.d.ts.map +1 -0
- package/dist/commands/recent.js +132 -0
- package/dist/commands/recent.js.map +1 -0
- package/dist/commands/run.d.ts +6 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +123 -11
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/save.d.ts +2 -1
- package/dist/commands/save.d.ts.map +1 -1
- package/dist/commands/save.js +44 -1
- package/dist/commands/save.js.map +1 -1
- package/dist/commands/validate.d.ts +10 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +162 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/utils/constants.d.ts +1 -1
- package/dist/utils/constants.js +1 -1
- package/dist/utils/formatters.d.ts +30 -0
- package/dist/utils/formatters.d.ts.map +1 -0
- package/dist/utils/formatters.js +188 -0
- package/dist/utils/formatters.js.map +1 -0
- package/dist/utils/llm-generator.d.ts.map +1 -1
- package/dist/utils/llm-generator.js +489 -27
- package/dist/utils/llm-generator.js.map +1 -1
- package/dist/utils/onboarding.d.ts.map +1 -1
- package/dist/utils/onboarding.js +57 -3
- package/dist/utils/onboarding.js.map +1 -1
- package/dist/utils/recent.d.ts +55 -0
- package/dist/utils/recent.d.ts.map +1 -0
- package/dist/utils/recent.js +102 -0
- package/dist/utils/recent.js.map +1 -0
- package/dist/utils/validator.d.ts +56 -0
- package/dist/utils/validator.d.ts.map +1 -0
- package/dist/utils/validator.js +413 -0
- package/dist/utils/validator.js.map +1 -0
- package/package.json +1 -1
- package/whats-new.json +48 -0
package/dist/commands/edit.js
CHANGED
|
@@ -10,10 +10,12 @@ const errors_1 = require("../utils/errors");
|
|
|
10
10
|
const constants_1 = require("../utils/constants");
|
|
11
11
|
const prompts_1 = require("../utils/prompts");
|
|
12
12
|
const env_1 = require("../utils/env");
|
|
13
|
+
const validator_1 = require("../utils/validator");
|
|
13
14
|
/**
|
|
14
15
|
* Edit an existing command interactively
|
|
15
16
|
*
|
|
16
17
|
* @param name - The name of the command to edit
|
|
18
|
+
* @param shouldValidate - Whether to validate the command (defaults to true)
|
|
17
19
|
*
|
|
18
20
|
* @example
|
|
19
21
|
* ```
|
|
@@ -23,7 +25,7 @@ const env_1 = require("../utils/env");
|
|
|
23
25
|
* await editCommand('build-prod');
|
|
24
26
|
* ```
|
|
25
27
|
*/
|
|
26
|
-
async function editCommand(name) {
|
|
28
|
+
async function editCommand(name, shouldValidate = true) {
|
|
27
29
|
try {
|
|
28
30
|
// Get the existing alias
|
|
29
31
|
const alias = (0, storage_1.getAlias)(name);
|
|
@@ -153,6 +155,47 @@ async function editCommand(name) {
|
|
|
153
155
|
console.log(chalk_1.default.yellow('No changes made'));
|
|
154
156
|
return;
|
|
155
157
|
}
|
|
158
|
+
// Validate the command if requested
|
|
159
|
+
if (shouldValidate) {
|
|
160
|
+
console.log(chalk_1.default.blue('\nValidating command...'));
|
|
161
|
+
const report = (0, validator_1.validateCommandAlias)(answers.command, answers.directory, selectedEnv);
|
|
162
|
+
if (report.issues.length > 0) {
|
|
163
|
+
const errors = report.issues.filter((issue) => issue.type === 'error');
|
|
164
|
+
const warnings = report.issues.filter((issue) => issue.type === 'warning');
|
|
165
|
+
if (errors.length > 0) {
|
|
166
|
+
console.log(chalk_1.default.red(`\n✗ Validation failed with ${errors.length} error(s):\n`));
|
|
167
|
+
for (const error of errors) {
|
|
168
|
+
console.log(chalk_1.default.red(` [${error.field}] ${error.message}`));
|
|
169
|
+
}
|
|
170
|
+
console.log();
|
|
171
|
+
console.log(chalk_1.default.yellow('Use --no-validate flag to skip validation'));
|
|
172
|
+
process.exit(errors_1.ExitCode.InvalidInput);
|
|
173
|
+
}
|
|
174
|
+
if (warnings.length > 0) {
|
|
175
|
+
console.log(chalk_1.default.yellow(`\n⚠ ${warnings.length} warning(s):\n`));
|
|
176
|
+
for (const warning of warnings) {
|
|
177
|
+
console.log(chalk_1.default.yellow(` [${warning.field}] ${warning.message}`));
|
|
178
|
+
}
|
|
179
|
+
const continuePrompt = {
|
|
180
|
+
type: 'confirm',
|
|
181
|
+
name: 'continue',
|
|
182
|
+
message: 'Continue saving despite warnings?',
|
|
183
|
+
default: true,
|
|
184
|
+
};
|
|
185
|
+
const shouldContinue = await (0, prompts_1.promptConfirm)(continuePrompt);
|
|
186
|
+
if (!shouldContinue) {
|
|
187
|
+
console.log(chalk_1.default.yellow('Edit cancelled'));
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
console.log(chalk_1.default.green('✓ Validation passed'));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
console.log(chalk_1.default.green('✓ Validation passed'));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
156
199
|
// Update the alias with path mode and env vars
|
|
157
200
|
try {
|
|
158
201
|
const success = (0, storage_1.setAlias)(name, answers.command, answers.directory, answers.pathMode, selectedEnv);
|
|
@@ -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":";;;;;AA6BA,kCAgPC;AA7QD,kDAA0B;AAC1B,wCAA0D;AAC1D,4CAA2F;AAC3F,kDAAqF;AACrF,8CAO0B;AAC1B,sCAAgF;AAChF,kDAA0D;AAE1D;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,WAAW,CAAC,IAAY,EAAE,iBAA0B,IAAI;IAC5E,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,4CAA4C;QAC5C,MAAM,OAAO,GAAqC;YAChD;gBACE,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,UAAU;gBACnB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,QAAQ,EAAE,CAAC,KAAa,EAAE,EAAE;oBAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;oBAC7B,IAAI,CAAC,OAAO,EAAE,CA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AAM,CAAC;gBACN,IAAA,sBAAa,EAAC,0BAAc,CAAC,cAAc,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAA,sBAAa,EAAC,GAAG,0BAAc,CAAC,cAAc,KAAM,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;QACjF,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,IAAA,2BAAkB,EAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,IAAA,sBAAa,EAAC,0BAAc,CAAC,uBAAuB,EAAE,iBAAQ,CAAC,YAAY,CAAC,CAAC;QAC/E,CAAC;aAAM,CAAC;YACN,IAAA,oBAAW,EAAC,KAAK,EAAE,wBAAwB,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Export all saved commands to a
|
|
2
|
+
* Export all saved commands to a file
|
|
3
3
|
*
|
|
4
4
|
* Creates a portable backup of all commands with metadata, suitable for:
|
|
5
5
|
* - Sharing with team members
|
|
@@ -7,13 +7,17 @@
|
|
|
7
7
|
* - Migrating between machines
|
|
8
8
|
*
|
|
9
9
|
* @param filePath - The path where the export file should be created
|
|
10
|
+
* @param format - Output format: 'json' (default) or 'yaml'
|
|
10
11
|
*
|
|
11
12
|
* @example
|
|
12
13
|
* ```
|
|
13
|
-
* // Export to
|
|
14
|
+
* // Export to JSON file
|
|
14
15
|
* exportCommand('./my-commands.json');
|
|
15
16
|
* // Output: ✓ Exported 15 command(s) to /path/to/my-commands.json
|
|
17
|
+
*
|
|
18
|
+
* // Export to YAML file
|
|
19
|
+
* exportCommand('./my-commands.yaml', 'yaml');
|
|
16
20
|
* ```
|
|
17
21
|
*/
|
|
18
|
-
export declare function exportCommand(filePath: string): void;
|
|
22
|
+
export declare function exportCommand(filePath: string, format?: 'json' | 'yaml'): void;
|
|
19
23
|
//# 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":"AAQA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,GAAG,MAAe,GAAG,IAAI,CAiEtF"}
|
package/dist/commands/export.js
CHANGED
|
@@ -43,8 +43,9 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
43
43
|
const storage_1 = require("../storage");
|
|
44
44
|
const errors_1 = require("../utils/errors");
|
|
45
45
|
const constants_1 = require("../utils/constants");
|
|
46
|
+
const formatters_1 = require("../utils/formatters");
|
|
46
47
|
/**
|
|
47
|
-
* Export all saved commands to a
|
|
48
|
+
* Export all saved commands to a file
|
|
48
49
|
*
|
|
49
50
|
* Creates a portable backup of all commands with metadata, suitable for:
|
|
50
51
|
* - Sharing with team members
|
|
@@ -52,15 +53,19 @@ const constants_1 = require("../utils/constants");
|
|
|
52
53
|
* - Migrating between machines
|
|
53
54
|
*
|
|
54
55
|
* @param filePath - The path where the export file should be created
|
|
56
|
+
* @param format - Output format: 'json' (default) or 'yaml'
|
|
55
57
|
*
|
|
56
58
|
* @example
|
|
57
59
|
* ```
|
|
58
|
-
* // Export to
|
|
60
|
+
* // Export to JSON file
|
|
59
61
|
* exportCommand('./my-commands.json');
|
|
60
62
|
* // Output: ✓ Exported 15 command(s) to /path/to/my-commands.json
|
|
63
|
+
*
|
|
64
|
+
* // Export to YAML file
|
|
65
|
+
* exportCommand('./my-commands.yaml', 'yaml');
|
|
61
66
|
* ```
|
|
62
67
|
*/
|
|
63
|
-
function exportCommand(filePath) {
|
|
68
|
+
function exportCommand(filePath, format = 'json') {
|
|
64
69
|
try {
|
|
65
70
|
// Validate file path
|
|
66
71
|
if (!filePath || !filePath.trim()) {
|
|
@@ -88,14 +93,22 @@ function exportCommand(filePath) {
|
|
|
88
93
|
(0, errors_1.exitWithError)(`Could not create directory: ${mkdirError.message}`, errors_1.ExitCode.PermissionDenied);
|
|
89
94
|
}
|
|
90
95
|
}
|
|
91
|
-
// Export
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
// Export in the specified format
|
|
97
|
+
let content;
|
|
98
|
+
if (format === 'yaml') {
|
|
99
|
+
content = (0, formatters_1.formatAsYAML)(aliases);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
// JSON format with metadata
|
|
103
|
+
const exportData = {
|
|
104
|
+
exportedAt: new Date().toISOString(),
|
|
105
|
+
version: '1.0',
|
|
106
|
+
aliases: aliases,
|
|
107
|
+
};
|
|
108
|
+
content = JSON.stringify(exportData, null, 2);
|
|
109
|
+
}
|
|
97
110
|
try {
|
|
98
|
-
fs.writeFileSync(resolvedPath,
|
|
111
|
+
fs.writeFileSync(resolvedPath, content, 'utf8');
|
|
99
112
|
console.log(chalk_1.default.green(`✓ ${constants_1.SUCCESS_MESSAGES.exported(names.length, resolvedPath)}`));
|
|
100
113
|
}
|
|
101
114
|
catch (writeError) {
|
|
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,sCAiEC;AA9FD,uCAAyB;AACzB,2CAA6B;AAC7B,kDAA0B;AAC1B,wCAAyC;AACzC,4CAAuE;AACvE,kDAAqF;AACrF,oDAAmD;AAEnD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,aAAa,CAAC,QAA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AAM,KAAK,MAAM,EAAE,CAAC;YACtB,OAAO,GAAG,IAAA,yBAAY,EAAC,OAAO,CAAC,CAAC;QAClC,CAAC;aAAM,CAAC;YACN,4BAA4B;YAC5B,MAAM,UAAU,GAAG;gBACjB,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACpC,OAAO,EAAE,KAAK;gBACd,OAAO,EAAE,OAAO;aACjB,CAAC;YACF,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAChD,CAAC;QAED,IAAI,CAAC;YACH,EAAE,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAChD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,KAAK,4BAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC;QACzF,CAAC;QAAC,OAAO,UAAU,EAAE,CAAC;YACpB,IAAA,sBAAa,EACX,GAAG,0BAAc,CAAC,aAAa,KAAM,UAAoB,CAAC,OAAO,EAAE,EACnE,iBAAQ,CAAC,gBAAgB,CAC1B,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAA,oBAAW,EAAC,KAAK,EAAE,2BAA2B,CAAC,CAAC;IAClD,CAAC;AACH,CAAC"}
|
package/dist/commands/list.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { OutputFormat } from '../utils/formatters';
|
|
1
2
|
/**
|
|
2
3
|
* List all saved commands with their details
|
|
3
4
|
*
|
|
4
5
|
* Displays commands alphabetically with their command text and working directory.
|
|
5
6
|
* If no commands are saved, provides guidance on how to save commands.
|
|
6
7
|
*
|
|
8
|
+
* @param format - Output format: 'table' (default), 'json', 'yaml', or 'compact'
|
|
9
|
+
*
|
|
7
10
|
* @example
|
|
8
11
|
* ```
|
|
9
12
|
* // Output:
|
|
@@ -18,5 +21,5 @@
|
|
|
18
21
|
* // Directory: /home/user/scripts
|
|
19
22
|
* ```
|
|
20
23
|
*/
|
|
21
|
-
export declare function listCommand(): void;
|
|
24
|
+
export declare function listCommand(format?: OutputFormat): void;
|
|
22
25
|
//# 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":"AAIA,OAAO,EAAiB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CAAC,MAAM,GAAE,YAAsB,GAAG,IAAI,CAsBhE"}
|
package/dist/commands/list.js
CHANGED
|
@@ -1,53 +1,22 @@
|
|
|
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
|
-
})();
|
|
35
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
38
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
6
|
exports.listCommand = listCommand;
|
|
40
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
41
|
-
const fs = __importStar(require("fs"));
|
|
42
8
|
const storage_1 = require("../storage");
|
|
43
9
|
const errors_1 = require("../utils/errors");
|
|
44
10
|
const constants_1 = require("../utils/constants");
|
|
11
|
+
const formatters_1 = require("../utils/formatters");
|
|
45
12
|
/**
|
|
46
13
|
* List all saved commands with their details
|
|
47
14
|
*
|
|
48
15
|
* Displays commands alphabetically with their command text and working directory.
|
|
49
16
|
* If no commands are saved, provides guidance on how to save commands.
|
|
50
17
|
*
|
|
18
|
+
* @param format - Output format: 'table' (default), 'json', 'yaml', or 'compact'
|
|
19
|
+
*
|
|
51
20
|
* @example
|
|
52
21
|
* ```
|
|
53
22
|
* // Output:
|
|
@@ -62,51 +31,25 @@ const constants_1 = require("../utils/constants");
|
|
|
62
31
|
* // Directory: /home/user/scripts
|
|
63
32
|
* ```
|
|
64
33
|
*/
|
|
65
|
-
function listCommand() {
|
|
34
|
+
function listCommand(format = 'table') {
|
|
66
35
|
try {
|
|
67
36
|
const aliases = (0, storage_1.loadAliases)();
|
|
68
37
|
const names = Object.keys(aliases);
|
|
69
38
|
if (names.length === 0) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
console.log(chalk_1.default.bold(`\nSaved commands (${names.length}):\n`));
|
|
75
|
-
// Sort alphabetically
|
|
76
|
-
names.sort();
|
|
77
|
-
for (const name of names) {
|
|
78
|
-
const alias = aliases[name];
|
|
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
|
-
// Get path mode with backward compatibility
|
|
83
|
-
const pathMode = alias.pathMode || 'saved';
|
|
84
|
-
// Truncate long commands for display
|
|
85
|
-
const maxCommandLength = 100;
|
|
86
|
-
let displayCommand = alias.command;
|
|
87
|
-
if (displayCommand.length > maxCommandLength) {
|
|
88
|
-
// Check if it's the llm command or other multi-line command
|
|
89
|
-
const firstLine = displayCommand.split('\n')[0];
|
|
90
|
-
if (firstLine.length > maxCommandLength) {
|
|
91
|
-
displayCommand = firstLine.substring(0, maxCommandLength) + '...';
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
displayCommand = firstLine + ' [...]';
|
|
95
|
-
}
|
|
39
|
+
if (format === 'json') {
|
|
40
|
+
console.log('{}');
|
|
96
41
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
console.log(chalk_1.default.gray(` Directory: ${alias.directory}`));
|
|
100
|
-
console.log(chalk_1.default.gray(` Path Mode: ${pathMode === 'saved' ? '📁 Saved' : '📍 Current'}`));
|
|
101
|
-
// Show env var count if any are saved
|
|
102
|
-
if (alias.env && Object.keys(alias.env).length > 0) {
|
|
103
|
-
console.log(chalk_1.default.gray(` Environment Variables: ${Object.keys(alias.env).length} saved`));
|
|
42
|
+
else if (format === 'yaml') {
|
|
43
|
+
console.log('');
|
|
104
44
|
}
|
|
105
|
-
|
|
106
|
-
console.log(chalk_1.default.
|
|
45
|
+
else {
|
|
46
|
+
console.log(chalk_1.default.yellow(constants_1.HELP_MESSAGES.noCommands));
|
|
47
|
+
console.log(chalk_1.default.gray(constants_1.HELP_MESSAGES.useSaveOrPrev));
|
|
107
48
|
}
|
|
108
|
-
|
|
49
|
+
return;
|
|
109
50
|
}
|
|
51
|
+
const output = (0, formatters_1.formatAliases)(aliases, format);
|
|
52
|
+
console.log(output);
|
|
110
53
|
}
|
|
111
54
|
catch (error) {
|
|
112
55
|
(0, errors_1.handleError)(error, 'Failed to list commands');
|
|
@@ -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":";;;;;AA4BA,kCAsBC;AAlDD,kDAA0B;AAC1B,wCAAyC;AACzC,4CAA8C;AAC9C,kDAAmD;AACnD,oDAAkE;AAElE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,WAAW,CAAC,SAAuB,OAAO;IACxD,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,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;gBACtB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACpB,CAAC;iBAAM,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;gBAC7B,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAClB,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,yBAAa,CAAC,UAAU,CAAC,CAAC,CAAC;gBACpD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,yBAAa,CAAC,aAAa,CAAC,CAAC,CAAC;YACvD,CAAC;YACD,OAAO;QACT,CAAC;QAED,MAAM,MAAM,GAAG,IAAA,0BAAa,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAA,oBAAW,EAAC,KAAK,EAAE,yBAAyB,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display recently executed commands
|
|
3
|
+
*
|
|
4
|
+
* @param options - Options for the recent command
|
|
5
|
+
* @param options.limit - Maximum number of commands to display
|
|
6
|
+
* @param options.clear - Clear the execution history
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```
|
|
10
|
+
* // Show recent commands
|
|
11
|
+
* recentCommand({});
|
|
12
|
+
*
|
|
13
|
+
* // Show last 10 commands
|
|
14
|
+
* recentCommand({ limit: 10 });
|
|
15
|
+
*
|
|
16
|
+
* // Clear history
|
|
17
|
+
* recentCommand({ clear: true });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function recentCommand(options: {
|
|
21
|
+
limit?: number;
|
|
22
|
+
clear?: boolean;
|
|
23
|
+
}): void;
|
|
24
|
+
//# sourceMappingURL=recent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recent.d.ts","sourceRoot":"","sources":["../../src/commands/recent.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CA4EhF"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.recentCommand = recentCommand;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const storage_1 = require("../storage");
|
|
9
|
+
const recent_1 = require("../utils/recent");
|
|
10
|
+
const errors_1 = require("../utils/errors");
|
|
11
|
+
/**
|
|
12
|
+
* Display recently executed commands
|
|
13
|
+
*
|
|
14
|
+
* @param options - Options for the recent command
|
|
15
|
+
* @param options.limit - Maximum number of commands to display
|
|
16
|
+
* @param options.clear - Clear the execution history
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```
|
|
20
|
+
* // Show recent commands
|
|
21
|
+
* recentCommand({});
|
|
22
|
+
*
|
|
23
|
+
* // Show last 10 commands
|
|
24
|
+
* recentCommand({ limit: 10 });
|
|
25
|
+
*
|
|
26
|
+
* // Clear history
|
|
27
|
+
* recentCommand({ clear: true });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
function recentCommand(options) {
|
|
31
|
+
try {
|
|
32
|
+
// Handle clear operation
|
|
33
|
+
if (options.clear) {
|
|
34
|
+
const success = (0, recent_1.clearExecutionHistory)();
|
|
35
|
+
if (success) {
|
|
36
|
+
console.log(chalk_1.default.green('✓ Execution history cleared'));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
console.error(chalk_1.default.red('✗ Failed to clear execution history'));
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// Get execution history
|
|
45
|
+
const config = (0, recent_1.getRecentConfig)();
|
|
46
|
+
const limit = options.limit || config.maxSize;
|
|
47
|
+
const history = (0, recent_1.getRecentCommandsWithTimestamps)(limit);
|
|
48
|
+
if (history.length === 0) {
|
|
49
|
+
console.log(chalk_1.default.yellow('No recent commands found.'));
|
|
50
|
+
console.log(chalk_1.default.gray('Commands will appear here after you run them with "aliasmate run"'));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
console.log(chalk_1.default.bold(`\nRecent commands (${history.length}):\n`));
|
|
54
|
+
// Group by command name and show timestamps
|
|
55
|
+
const groupedByCommand = new Map();
|
|
56
|
+
for (const entry of history) {
|
|
57
|
+
if (!groupedByCommand.has(entry.commandName)) {
|
|
58
|
+
groupedByCommand.set(entry.commandName, []);
|
|
59
|
+
}
|
|
60
|
+
groupedByCommand.get(entry.commandName).push(entry.executedAt);
|
|
61
|
+
}
|
|
62
|
+
// Display with @N syntax reference
|
|
63
|
+
let index = 0;
|
|
64
|
+
const seenCommands = new Set();
|
|
65
|
+
for (const entry of history) {
|
|
66
|
+
if (!seenCommands.has(entry.commandName)) {
|
|
67
|
+
seenCommands.add(entry.commandName);
|
|
68
|
+
const alias = (0, storage_1.getAlias)(entry.commandName);
|
|
69
|
+
const timestamp = new Date(entry.executedAt);
|
|
70
|
+
const timeAgo = getTimeAgo(timestamp);
|
|
71
|
+
const executionCount = groupedByCommand.get(entry.commandName).length;
|
|
72
|
+
console.log(chalk_1.default.cyan(` @${index} ${entry.commandName}`));
|
|
73
|
+
if (alias) {
|
|
74
|
+
console.log(chalk_1.default.gray(` Command: ${truncateCommand(alias.command, 80)}`));
|
|
75
|
+
console.log(chalk_1.default.gray(` Directory: ${alias.directory}`));
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
console.log(chalk_1.default.red(` [Command no longer exists]`));
|
|
79
|
+
}
|
|
80
|
+
console.log(chalk_1.default.gray(` Last run: ${timeAgo} (${executionCount} time${executionCount > 1 ? 's' : ''})`));
|
|
81
|
+
console.log();
|
|
82
|
+
index++;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
console.log(chalk_1.default.gray('Tip: Run a recent command with "aliasmate run @N" where N is the index above'));
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
(0, errors_1.handleError)(error, 'Failed to display recent commands');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Truncate command for display
|
|
93
|
+
*/
|
|
94
|
+
function truncateCommand(command, maxLength) {
|
|
95
|
+
if (command.length <= maxLength) {
|
|
96
|
+
return command;
|
|
97
|
+
}
|
|
98
|
+
const firstLine = command.split('\n')[0];
|
|
99
|
+
if (firstLine.length <= maxLength) {
|
|
100
|
+
return firstLine + ' [...]';
|
|
101
|
+
}
|
|
102
|
+
return firstLine.substring(0, maxLength) + '...';
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Get human-readable time ago string
|
|
106
|
+
*/
|
|
107
|
+
function getTimeAgo(date) {
|
|
108
|
+
const now = new Date();
|
|
109
|
+
const seconds = Math.floor((now.getTime() - date.getTime()) / 1000);
|
|
110
|
+
if (seconds < 60) {
|
|
111
|
+
return 'just now';
|
|
112
|
+
}
|
|
113
|
+
const minutes = Math.floor(seconds / 60);
|
|
114
|
+
if (minutes < 60) {
|
|
115
|
+
return `${minutes} minute${minutes > 1 ? 's' : ''} ago`;
|
|
116
|
+
}
|
|
117
|
+
const hours = Math.floor(minutes / 60);
|
|
118
|
+
if (hours < 24) {
|
|
119
|
+
return `${hours} hour${hours > 1 ? 's' : ''} ago`;
|
|
120
|
+
}
|
|
121
|
+
const days = Math.floor(hours / 24);
|
|
122
|
+
if (days < 7) {
|
|
123
|
+
return `${days} day${days > 1 ? 's' : ''} ago`;
|
|
124
|
+
}
|
|
125
|
+
const weeks = Math.floor(days / 7);
|
|
126
|
+
if (weeks < 4) {
|
|
127
|
+
return `${weeks} week${weeks > 1 ? 's' : ''} ago`;
|
|
128
|
+
}
|
|
129
|
+
const months = Math.floor(days / 30);
|
|
130
|
+
return `${months} month${months > 1 ? 's' : ''} ago`;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=recent.js.map
|
|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AAC,CAAC;IACrC,OAAO,GAAG,MAAM,SAAS,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;AACvD,CAAC"}
|
package/dist/commands/run.d.ts
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param name - The name of the saved command to run
|
|
5
5
|
* @param overridePath - Optional path to override the saved working directory
|
|
6
|
+
* @param dryRun - If true, preview what will execute without running
|
|
7
|
+
* @param verbose - If true, show detailed information (used with dryRun)
|
|
6
8
|
*
|
|
7
9
|
* @example
|
|
8
10
|
* ```
|
|
@@ -11,7 +13,10 @@
|
|
|
11
13
|
*
|
|
12
14
|
* // Run command in a different directory
|
|
13
15
|
* await runCommand('build-prod', '/path/to/other/project');
|
|
16
|
+
*
|
|
17
|
+
* // Preview command without executing
|
|
18
|
+
* await runCommand('build-prod', undefined, true);
|
|
14
19
|
* ```
|
|
15
20
|
*/
|
|
16
|
-
export declare function runCommand(name: string, overridePath?: string): Promise<void>;
|
|
21
|
+
export declare function runCommand(name: string, overridePath?: string, dryRun?: boolean, verbose?: boolean): Promise<void>;
|
|
17
22
|
//# sourceMappingURL=run.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,MAAM,EACrB,MAAM,CAAC,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,OAAO,GAChB,OAAO,CAAC,IAAI,CAAC,CAmNf"}
|