aliasmate 1.0.0 → 1.3.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +159 -0
  2. package/README.md +188 -3
  3. package/dist/cli.js +66 -15
  4. package/dist/cli.js.map +1 -1
  5. package/dist/commands/delete.d.ts +12 -0
  6. package/dist/commands/delete.d.ts.map +1 -1
  7. package/dist/commands/delete.js +29 -8
  8. package/dist/commands/delete.js.map +1 -1
  9. package/dist/commands/edit.d.ts +13 -0
  10. package/dist/commands/edit.d.ts.map +1 -1
  11. package/dist/commands/edit.js +72 -26
  12. package/dist/commands/edit.js.map +1 -1
  13. package/dist/commands/export.d.ts +17 -0
  14. package/dist/commands/export.d.ts.map +1 -1
  15. package/dist/commands/export.js +42 -7
  16. package/dist/commands/export.js.map +1 -1
  17. package/dist/commands/import.d.ts +21 -0
  18. package/dist/commands/import.d.ts.map +1 -1
  19. package/dist/commands/import.js +93 -48
  20. package/dist/commands/import.js.map +1 -1
  21. package/dist/commands/list.d.ts +20 -0
  22. package/dist/commands/list.d.ts.map +1 -1
  23. package/dist/commands/list.js +83 -6
  24. package/dist/commands/list.js.map +1 -1
  25. package/dist/commands/prev.d.ts +14 -1
  26. package/dist/commands/prev.d.ts.map +1 -1
  27. package/dist/commands/prev.js +43 -14
  28. package/dist/commands/prev.js.map +1 -1
  29. package/dist/commands/run.d.ts +16 -1
  30. package/dist/commands/run.d.ts.map +1 -1
  31. package/dist/commands/run.js +52 -11
  32. package/dist/commands/run.js.map +1 -1
  33. package/dist/commands/save.d.ts +15 -1
  34. package/dist/commands/save.d.ts.map +1 -1
  35. package/dist/commands/save.js +82 -35
  36. package/dist/commands/save.js.map +1 -1
  37. package/dist/commands/search.d.ts +19 -0
  38. package/dist/commands/search.d.ts.map +1 -0
  39. package/dist/commands/search.js +113 -0
  40. package/dist/commands/search.js.map +1 -0
  41. package/dist/storage/index.d.ts +44 -8
  42. package/dist/storage/index.d.ts.map +1 -1
  43. package/dist/storage/index.js +58 -12
  44. package/dist/storage/index.js.map +1 -1
  45. package/dist/utils/constants.d.ts +48 -0
  46. package/dist/utils/constants.d.ts.map +1 -0
  47. package/dist/utils/constants.js +51 -0
  48. package/dist/utils/constants.js.map +1 -0
  49. package/dist/utils/errors.d.ts +30 -0
  50. package/dist/utils/errors.d.ts.map +1 -0
  51. package/dist/utils/errors.js +62 -0
  52. package/dist/utils/errors.js.map +1 -0
  53. package/dist/utils/executor.d.ts +22 -1
  54. package/dist/utils/executor.d.ts.map +1 -1
  55. package/dist/utils/executor.js +36 -11
  56. package/dist/utils/executor.js.map +1 -1
  57. package/dist/utils/history.d.ts +21 -3
  58. package/dist/utils/history.d.ts.map +1 -1
  59. package/dist/utils/history.js +28 -14
  60. package/dist/utils/history.js.map +1 -1
  61. package/dist/utils/llm-generator.d.ts +21 -0
  62. package/dist/utils/llm-generator.d.ts.map +1 -0
  63. package/dist/utils/llm-generator.js +337 -0
  64. package/dist/utils/llm-generator.js.map +1 -0
  65. package/dist/utils/onboarding.d.ts +10 -0
  66. package/dist/utils/onboarding.d.ts.map +1 -0
  67. package/dist/utils/onboarding.js +201 -0
  68. package/dist/utils/onboarding.js.map +1 -0
  69. package/dist/utils/paths.d.ts +39 -1
  70. package/dist/utils/paths.d.ts.map +1 -1
  71. package/dist/utils/paths.js +56 -1
  72. package/dist/utils/paths.js.map +1 -1
  73. package/dist/utils/prompts.d.ts +56 -0
  74. package/dist/utils/prompts.d.ts.map +1 -0
  75. package/dist/utils/prompts.js +51 -0
  76. package/dist/utils/prompts.js.map +1 -0
  77. package/package.json +22 -6
@@ -0,0 +1,113 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.searchCommand = searchCommand;
40
+ const chalk_1 = __importDefault(require("chalk"));
41
+ const fs = __importStar(require("fs"));
42
+ const storage_1 = require("../storage");
43
+ const errors_1 = require("../utils/errors");
44
+ const constants_1 = require("../utils/constants");
45
+ /**
46
+ * Search for commands by name or command text
47
+ *
48
+ * Performs case-insensitive search across command names and command text.
49
+ *
50
+ * @param query - The search query string
51
+ *
52
+ * @example
53
+ * ```
54
+ * // Search for commands containing 'build'
55
+ * searchCommand('build');
56
+ * // Output:
57
+ * // build-prod
58
+ * // Command: npm run build --production
59
+ * // Directory: /home/user/project
60
+ * ```
61
+ */
62
+ function searchCommand(query) {
63
+ try {
64
+ if (!query || !query.trim()) {
65
+ console.log(chalk_1.default.yellow('Please provide a search query'));
66
+ return;
67
+ }
68
+ const aliases = (0, storage_1.loadAliases)();
69
+ const names = Object.keys(aliases);
70
+ if (names.length === 0) {
71
+ console.log(chalk_1.default.yellow(constants_1.HELP_MESSAGES.noCommands));
72
+ console.log(chalk_1.default.gray(constants_1.HELP_MESSAGES.useSaveOrPrev));
73
+ return;
74
+ }
75
+ const searchTerm = query.toLowerCase().trim();
76
+ const results = [];
77
+ // Search in command names and command text
78
+ for (const name of names) {
79
+ const alias = aliases[name];
80
+ const nameMatch = name.toLowerCase().includes(searchTerm);
81
+ const commandMatch = alias.command.toLowerCase().includes(searchTerm);
82
+ const dirMatch = alias.directory.toLowerCase().includes(searchTerm);
83
+ if (nameMatch || commandMatch || dirMatch) {
84
+ let matchType = '';
85
+ if (nameMatch)
86
+ matchType = 'name';
87
+ else if (commandMatch)
88
+ matchType = 'command';
89
+ else if (dirMatch)
90
+ matchType = 'directory';
91
+ results.push({ name, matchType });
92
+ }
93
+ }
94
+ if (results.length === 0) {
95
+ console.log(chalk_1.default.yellow(`No commands found matching "${query}"`));
96
+ return;
97
+ }
98
+ console.log(chalk_1.default.bold(`\nFound ${results.length} command(s) matching "${query}":\n`));
99
+ for (const { name, matchType } of results) {
100
+ const alias = aliases[name];
101
+ const dirExists = fs.existsSync(alias.directory);
102
+ const dirIndicator = dirExists ? '' : chalk_1.default.red(' [DIR NOT FOUND]');
103
+ console.log(chalk_1.default.cyan(` ${name}${dirIndicator}`) + chalk_1.default.gray(` (matched in ${matchType})`));
104
+ console.log(chalk_1.default.gray(` Command: ${alias.command}`));
105
+ console.log(chalk_1.default.gray(` Directory: ${alias.directory}`));
106
+ console.log();
107
+ }
108
+ }
109
+ catch (error) {
110
+ (0, errors_1.handleError)(error, 'Failed to search commands');
111
+ }
112
+ }
113
+ //# sourceMappingURL=search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/commands/search.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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YACzD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,kBAAkB,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;YAC7D,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAA,oBAAW,EAAC,KAAK,EAAE,2BAA2B,CAAC,CAAC;IAClD,CAAC;AACH,CAAC"}
@@ -1,42 +1,78 @@
1
+ /**
2
+ * Path mode determines where a command should be executed
3
+ * - 'saved': Always run in the directory saved with the command
4
+ * - 'current': Run in the user's current working directory
5
+ */
6
+ export type PathMode = 'saved' | 'current';
7
+ /**
8
+ * Represents a saved command alias with its metadata
9
+ */
1
10
  export interface CommandAlias {
11
+ /** The shell command to execute */
2
12
  command: string;
13
+ /** The working directory where the command should be executed */
3
14
  directory: string;
15
+ /** Path mode: 'saved' (use stored directory) or 'current' (use current directory) */
16
+ pathMode?: PathMode;
17
+ /** ISO 8601 timestamp when the command was created */
4
18
  createdAt: string;
19
+ /** ISO 8601 timestamp when the command was last modified */
5
20
  updatedAt: string;
6
21
  }
22
+ /**
23
+ * Configuration object containing all saved command aliases
24
+ */
7
25
  export interface AliasConfig {
8
26
  [name: string]: CommandAlias;
9
27
  }
10
28
  /**
11
- * Get the config directory path
29
+ * Get the config directory path, creating it if it doesn't exist
30
+ * @returns The absolute path to the config directory
12
31
  */
13
32
  export declare function getConfigDir(): string;
14
33
  /**
15
34
  * Get the config file path
35
+ * @returns The absolute path to the config.json file
16
36
  */
17
37
  export declare function getConfigPath(): string;
18
38
  /**
19
- * Load all saved aliases
39
+ * Load all saved aliases from the config file
40
+ * @returns The alias configuration object, or an empty object if the file doesn't exist
20
41
  */
21
42
  export declare function loadAliases(): AliasConfig;
22
43
  /**
23
- * Save all aliases
44
+ * Save all aliases to the config file
45
+ * Uses atomic write pattern to prevent data corruption
46
+ * @param aliases - The alias configuration to save
47
+ * @returns true if successful, false otherwise
24
48
  */
25
49
  export declare function saveAliases(aliases: AliasConfig): boolean;
26
50
  /**
27
- * Get a specific alias
51
+ * Get a specific alias by name
52
+ * @param name - The name of the alias to retrieve
53
+ * @returns The command alias if found, undefined otherwise
28
54
  */
29
55
  export declare function getAlias(name: string): CommandAlias | undefined;
30
56
  /**
31
- * Set/update an alias
57
+ * Set or update an alias
58
+ * @param name - The name of the alias
59
+ * @param command - The shell command to save
60
+ * @param directory - The working directory for the command
61
+ * @param pathMode - Optional path mode ('saved' or 'current'), defaults to 'saved'
62
+ * @returns true if successful, false otherwise
63
+ * @throws {Error} If the directory doesn't exist or isn't accessible
32
64
  */
33
- export declare function setAlias(name: string, command: string, directory: string): boolean;
65
+ export declare function setAlias(name: string, command: string, directory: string, pathMode?: PathMode): boolean;
34
66
  /**
35
- * Delete an alias
67
+ * Delete an alias by name
68
+ * @param name - The name of the alias to delete
69
+ * @returns true if the alias was deleted, false if it didn't exist
36
70
  */
37
71
  export declare function deleteAlias(name: string): boolean;
38
72
  /**
39
- * Check if alias exists
73
+ * Check if an alias exists
74
+ * @param name - The name of the alias to check
75
+ * @returns true if the alias exists, false otherwise
40
76
  */
41
77
  export declare function aliasExists(name: string): boolean;
42
78
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAUrC;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,WAAW,CAczC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MAAM,GAAG,YAAY,GAAG,SAAS,CAG/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,QAAQ,GAAE,QAAkB,GAC3B,OAAO,CA0BT;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOjD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGjD"}
@@ -45,7 +45,8 @@ const fs = __importStar(require("fs"));
45
45
  const path = __importStar(require("path"));
46
46
  const os = __importStar(require("os"));
47
47
  /**
48
- * Get the config directory path
48
+ * Get the config directory path, creating it if it doesn't exist
49
+ * @returns The absolute path to the config directory
49
50
  */
50
51
  function getConfigDir() {
51
52
  const homeDir = os.homedir();
@@ -58,12 +59,14 @@ function getConfigDir() {
58
59
  }
59
60
  /**
60
61
  * Get the config file path
62
+ * @returns The absolute path to the config.json file
61
63
  */
62
64
  function getConfigPath() {
63
65
  return path.join(getConfigDir(), 'config.json');
64
66
  }
65
67
  /**
66
- * Load all saved aliases
68
+ * Load all saved aliases from the config file
69
+ * @returns The alias configuration object, or an empty object if the file doesn't exist
67
70
  */
68
71
  function loadAliases() {
69
72
  const configPath = getConfigPath();
@@ -80,41 +83,82 @@ function loadAliases() {
80
83
  }
81
84
  }
82
85
  /**
83
- * Save all aliases
86
+ * Save all aliases to the config file
87
+ * Uses atomic write pattern to prevent data corruption
88
+ * @param aliases - The alias configuration to save
89
+ * @returns true if successful, false otherwise
84
90
  */
85
91
  function saveAliases(aliases) {
86
92
  const configPath = getConfigPath();
93
+ const tempPath = `${configPath}.tmp`;
87
94
  try {
88
- fs.writeFileSync(configPath, JSON.stringify(aliases, null, 2), 'utf8');
95
+ // Write to temporary file first
96
+ fs.writeFileSync(tempPath, JSON.stringify(aliases, null, 2), 'utf8');
97
+ // Atomic rename
98
+ fs.renameSync(tempPath, configPath);
89
99
  return true;
90
100
  }
91
101
  catch (error) {
92
102
  console.error('Error writing config file:', error.message);
103
+ // Clean up temp file if it exists
104
+ try {
105
+ if (fs.existsSync(tempPath)) {
106
+ fs.unlinkSync(tempPath);
107
+ }
108
+ }
109
+ catch {
110
+ // Ignore cleanup errors
111
+ }
93
112
  return false;
94
113
  }
95
114
  }
96
115
  /**
97
- * Get a specific alias
116
+ * Get a specific alias by name
117
+ * @param name - The name of the alias to retrieve
118
+ * @returns The command alias if found, undefined otherwise
98
119
  */
99
120
  function getAlias(name) {
100
121
  const aliases = loadAliases();
101
122
  return aliases[name];
102
123
  }
103
124
  /**
104
- * Set/update an alias
125
+ * Set or update an alias
126
+ * @param name - The name of the alias
127
+ * @param command - The shell command to save
128
+ * @param directory - The working directory for the command
129
+ * @param pathMode - Optional path mode ('saved' or 'current'), defaults to 'saved'
130
+ * @returns true if successful, false otherwise
131
+ * @throws {Error} If the directory doesn't exist or isn't accessible
105
132
  */
106
- function setAlias(name, command, directory) {
133
+ function setAlias(name, command, directory, pathMode = 'saved') {
134
+ // Validate inputs
135
+ if (!name || !name.trim()) {
136
+ throw new Error('Alias name cannot be empty');
137
+ }
138
+ if (!command || !command.trim()) {
139
+ throw new Error('Command cannot be empty');
140
+ }
141
+ if (!directory || !directory.trim()) {
142
+ throw new Error('Directory cannot be empty');
143
+ }
144
+ // Validate directory exists (warning only, don't block)
145
+ if (!fs.existsSync(directory)) {
146
+ console.warn(`Warning: Directory does not exist: ${directory}`);
147
+ }
107
148
  const aliases = loadAliases();
108
149
  aliases[name] = {
109
- command,
110
- directory,
150
+ command: command.trim(),
151
+ directory: path.resolve(directory),
152
+ pathMode,
111
153
  createdAt: aliases[name]?.createdAt || new Date().toISOString(),
112
- updatedAt: new Date().toISOString()
154
+ updatedAt: new Date().toISOString(),
113
155
  };
114
156
  return saveAliases(aliases);
115
157
  }
116
158
  /**
117
- * Delete an alias
159
+ * Delete an alias by name
160
+ * @param name - The name of the alias to delete
161
+ * @returns true if the alias was deleted, false if it didn't exist
118
162
  */
119
163
  function deleteAlias(name) {
120
164
  const aliases = loadAliases();
@@ -125,7 +169,9 @@ function deleteAlias(name) {
125
169
  return saveAliases(aliases);
126
170
  }
127
171
  /**
128
- * Check if alias exists
172
+ * Check if an alias exists
173
+ * @param name - The name of the alias to check
174
+ * @returns true if the alias exists, false otherwise
129
175
  */
130
176
  function aliasExists(name) {
131
177
  const aliases = loadAliases();
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,oCAUC;AAKD,sCAEC;AAKD,kCAcC;AAKD,kCAUC;AAKD,4BAGC;AAKD,4BASC;AAKD,kCAOC;AAKD,kCAGC;AA/GD,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AAazB;;GAEG;AACH,SAAgB,YAAY;IAC1B,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;IAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;IAE7D,uCAAuC;IACvC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9B,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa;IAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,aAAa,CAAC,CAAC;AAClD,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW;IACzB,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IAEnC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,OAAO,EAA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C9B,CAAC;AAED;;;;GAIG;AACH,SAAgB,WAAW,CAAC,IAAY;IACtC,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAC9B,IAAI,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,SAAgB,WAAW,CAAC,IAAY;IACtC,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAC9B,OAAO,IAAI,IAAI,OAAO,CAAC;AACzB,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Application constants
3
+ */
4
+ export declare const APP_NAME = "aliasmate";
5
+ export declare const APP_VERSION = "1.3.0";
6
+ export declare const CONFIG_DIR_NAME = ".config/aliasmate";
7
+ export declare const CONFIG_FILE_NAME = "config.json";
8
+ /**
9
+ * Help messages
10
+ */
11
+ export declare const HELP_MESSAGES: {
12
+ readonly noCommands: "No saved commands found.";
13
+ readonly useSaveOrPrev: "Use \"aliasmate save\" or \"aliasmate prev <name>\" to save a command";
14
+ readonly useList: "Use \"aliasmate list\" to see all saved commands";
15
+ readonly invalidName: "Name cannot contain spaces";
16
+ readonly emptyValue: (field: string) => string;
17
+ };
18
+ /**
19
+ * Success messages
20
+ */
21
+ export declare const SUCCESS_MESSAGES: {
22
+ readonly saved: (name: string) => string;
23
+ readonly deleted: (name: string) => string;
24
+ readonly updated: (name: string) => string;
25
+ readonly exported: (count: number, path: string) => string;
26
+ readonly importComplete: "Import complete";
27
+ };
28
+ /**
29
+ * Error messages
30
+ */
31
+ export declare const ERROR_MESSAGES: {
32
+ readonly commandNotFound: (name: string) => string;
33
+ readonly couldNotSave: "Could not save command";
34
+ readonly couldNotDelete: "Could not delete command";
35
+ readonly couldNotUpdate: "Could not update command";
36
+ readonly couldNotRead: "Could not read config file";
37
+ readonly couldNotWrite: "Could not write to file";
38
+ readonly fileNotFound: (path: string) => string;
39
+ readonly invalidJson: "Could not parse file. Make sure it is valid JSON.";
40
+ readonly invalidFormat: "Invalid file format. Expected an \"aliases\" object.";
41
+ readonly invalidAliasStructure: (name: string) => string;
42
+ readonly directoryNotFound: (path: string) => string;
43
+ readonly historyNotAvailable: "Could not retrieve previous command from history.";
44
+ readonly interactiveNotSupported: "Interactive prompt not supported in this environment";
45
+ readonly emptyInput: (field: string) => string;
46
+ readonly invalidCharacters: (field: string) => string;
47
+ };
48
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,QAAQ,cAAc,CAAC;AACpC,eAAO,MAAM,WAAW,UAAU,CAAC;AACnC,eAAO,MAAM,eAAe,sBAAsB,CAAC;AACnD,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;iCAKJ,MAAM;CAClB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,gBAAgB;2BACb,MAAM;6BACJ,MAAM;6BACN,MAAM;+BACJ,MAAM,QAAQ,MAAM;;CAE9B,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,cAAc;qCACD,MAAM;;;;;;kCAMT,MAAM;;;2CAGG,MAAM;uCAEV,MAAM;;;iCAGZ,MAAM;wCACC,MAAM;CACzB,CAAC"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ /**
3
+ * Application constants
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ERROR_MESSAGES = exports.SUCCESS_MESSAGES = exports.HELP_MESSAGES = exports.CONFIG_FILE_NAME = exports.CONFIG_DIR_NAME = exports.APP_VERSION = exports.APP_NAME = void 0;
7
+ exports.APP_NAME = 'aliasmate';
8
+ exports.APP_VERSION = '1.3.0';
9
+ exports.CONFIG_DIR_NAME = '.config/aliasmate';
10
+ exports.CONFIG_FILE_NAME = 'config.json';
11
+ /**
12
+ * Help messages
13
+ */
14
+ exports.HELP_MESSAGES = {
15
+ noCommands: 'No saved commands found.',
16
+ useSaveOrPrev: 'Use "aliasmate save" or "aliasmate prev <name>" to save a command',
17
+ useList: 'Use "aliasmate list" to see all saved commands',
18
+ invalidName: 'Name cannot contain spaces',
19
+ emptyValue: (field) => `${field} cannot be empty`,
20
+ };
21
+ /**
22
+ * Success messages
23
+ */
24
+ exports.SUCCESS_MESSAGES = {
25
+ saved: (name) => `Saved command as "${name}"`,
26
+ deleted: (name) => `Deleted command "${name}"`,
27
+ updated: (name) => `Updated command "${name}"`,
28
+ exported: (count, path) => `Exported ${count} command(s) to ${path}`,
29
+ importComplete: 'Import complete',
30
+ };
31
+ /**
32
+ * Error messages
33
+ */
34
+ exports.ERROR_MESSAGES = {
35
+ commandNotFound: (name) => `No saved command found with name "${name}"`,
36
+ couldNotSave: 'Could not save command',
37
+ couldNotDelete: 'Could not delete command',
38
+ couldNotUpdate: 'Could not update command',
39
+ couldNotRead: 'Could not read config file',
40
+ couldNotWrite: 'Could not write to file',
41
+ fileNotFound: (path) => `File not found: ${path}`,
42
+ invalidJson: 'Could not parse file. Make sure it is valid JSON.',
43
+ invalidFormat: 'Invalid file format. Expected an "aliases" object.',
44
+ invalidAliasStructure: (name) => `Invalid alias structure for "${name}". Missing required fields (command, directory).`,
45
+ directoryNotFound: (path) => `Directory does not exist: ${path}`,
46
+ historyNotAvailable: 'Could not retrieve previous command from history.',
47
+ interactiveNotSupported: 'Interactive prompt not supported in this environment',
48
+ emptyInput: (field) => `${field} cannot be empty`,
49
+ invalidCharacters: (field) => `${field} contains invalid characters`,
50
+ };
51
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEU,QAAA,Q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A6B,IAAI,EAAE;IACxE,mBAAmB,EAAE,mDAAmD;IACxE,uBAAuB,EAAE,sDAAsD;IAC/E,UAAU,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,KAAK,kBAAkB;IACzD,iBAAiB,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,KAAK,8BAA8B;CACpE,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Custom error class for AliasMate specific errors
3
+ */
4
+ export declare class AliasMateError extends Error {
5
+ readonly code?: string | undefined;
6
+ constructor(message: string, code?: string | undefined);
7
+ }
8
+ /**
9
+ * Exit codes for the CLI
10
+ */
11
+ export declare enum ExitCode {
12
+ Success = 0,
13
+ GeneralError = 1,
14
+ InvalidInput = 2,
15
+ FileNotFound = 3,
16
+ PermissionDenied = 4
17
+ }
18
+ /**
19
+ * Display an error message and exit with the appropriate code
20
+ */
21
+ export declare function exitWithError(message: string, exitCode?: ExitCode): never;
22
+ /**
23
+ * Handle errors consistently across commands
24
+ */
25
+ export declare function handleError(error: unknown, context?: string): never;
26
+ /**
27
+ * Check if error is an inquirer TTY error
28
+ */
29
+ export declare function isInquirerTTYError(error: unknown): boolean;
30
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;aAGrB,IAAI,CAAC,EAAE,MAAM;gBAD7B,OAAO,EAAE,MAAM,EACC,IAAI,CAAC,EAAE,MAAM,YAAA;CAKhC;AAED;;GAEG;AACH,oBAAY,QAAQ;IAClB,OAAO,IAAI;IACX,YAAY,IAAI;IAChB,YAAY,IAAI;IAChB,YAAY,IAAI;IAChB,gBAAgB,IAAI;CACrB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAE,QAAgC,GAAG,KAAK,CAGhG;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAWnE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAO1D"}
@@ -0,0 +1,62 @@
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.ExitCode = exports.AliasMateError = void 0;
7
+ exports.exitWithError = exitWithError;
8
+ exports.handleError = handleError;
9
+ exports.isInquirerTTYError = isInquirerTTYError;
10
+ const chalk_1 = __importDefault(require("chalk"));
11
+ /**
12
+ * Custom error class for AliasMate specific errors
13
+ */
14
+ class AliasMateError extends Error {
15
+ constructor(message, code) {
16
+ super(message);
17
+ this.code = code;
18
+ this.name = 'AliasMateError';
19
+ }
20
+ }
21
+ exports.AliasMateError = AliasMateError;
22
+ /**
23
+ * Exit codes for the CLI
24
+ */
25
+ var ExitCode;
26
+ (function (ExitCode) {
27
+ ExitCode[ExitCode["Success"] = 0] = "Success";
28
+ ExitCode[ExitCode["GeneralError"] = 1] = "GeneralError";
29
+ ExitCode[ExitCode["InvalidInput"] = 2] = "InvalidInput";
30
+ ExitCode[ExitCode["FileNotFound"] = 3] = "FileNotFound";
31
+ ExitCode[ExitCode["PermissionDenied"] = 4] = "PermissionDenied";
32
+ })(ExitCode || (exports.ExitCode = ExitCode = {}));
33
+ /**
34
+ * Display an error message and exit with the appropriate code
35
+ */
36
+ function exitWithError(message, exitCode = ExitCode.GeneralError) {
37
+ console.error(chalk_1.default.red('Error:'), message);
38
+ process.exit(exitCode);
39
+ }
40
+ /**
41
+ * Handle errors consistently across commands
42
+ */
43
+ function handleError(error, context) {
44
+ if (error instanceof AliasMateError) {
45
+ exitWithError(error.message);
46
+ }
47
+ if (error instanceof Error) {
48
+ const message = context ? `${context}: ${error.message}` : error.message;
49
+ exitWithError(message);
50
+ }
51
+ exitWithError('An unknown error occurred');
52
+ }
53
+ /**
54
+ * Check if error is an inquirer TTY error
55
+ */
56
+ function isInquirerTTYError(error) {
57
+ return (typeof error === 'object' &&
58
+ error !== null &&
59
+ 'isTtyError' in error &&
60
+ error.isTtyError === true);
61
+ }
62
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":";;;;;;AA6BA,sCAGC;AAKD,kCAWC;AAKD,gDAOC;AA5DD,kDAA0B;AAE1B;;GAEG;AACH,MAAa,cAAe,SAAQ,KAAK;IACvC,YACE,OAAe,EACC,IAAa;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,SAAI,GAAJ,IAAI,CAAS;QAG7B,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AARD,wCAQC;AAED;;GAEG;AACH,IAAY,QAMX;AAND,WAAY,QAAQ;IAClB,6CAAW,CAAA;IACX,uDAAgB,CAAA;IAChB,uDAAgB,CAAA;IAChB,uDAAgB,CAAA;IAChB,+DAAoB,CAAA;AACtB,CAAC,EANW,QAAQ,wBAAR,QAAQ,QAMnB;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,OAAe,EAAE,WAAqB,QAAQ,CAAC,YAAY;IACvF,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;IAC5C,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAc,EAAE,OAAgB;IAC1D,IAAI,KAAK,YAAY,cAAc,EAAE,CAAC;QACpC,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;QACzE,aAAa,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAED,aAAa,CAAC,2BAA2B,CAAC,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,KAAc;IAC/C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,YAAY,IAAI,KAAK;QACrB,KAAK,CAAC,UAAU,KAAK,IAAI,CAC1B,CAAC;AACJ,CAAC"}
@@ -1,11 +1,32 @@
1
+ /**
2
+ * Result of a command execution
3
+ */
1
4
  export interface ExecutionResult {
5
+ /** Whether the command executed successfully */
2
6
  success: boolean;
7
+ /** Standard output (may be empty when using stdio: 'inherit') */
3
8
  stdout: string;
9
+ /** Standard error or error message */
4
10
  stderr: string;
11
+ /** Exit code of the command (if available) */
12
+ exitCode?: number;
5
13
  }
6
14
  /**
7
15
  * Execute a command in a specific directory
8
- * Cross-platform command execution using execa
16
+ * Uses execa with shell mode for cross-platform compatibility
17
+ *
18
+ * @param command - The shell command to execute
19
+ * @param cwd - The working directory to execute the command in
20
+ * @returns A promise that resolves with the execution result
21
+ * @throws {Error} If the directory doesn't exist
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const result = await executeCommand('npm install', '/path/to/project');
26
+ * if (result.success) {
27
+ * console.log('Installation successful');
28
+ * }
29
+ * ```
9
30
  */
10
31
  export declare function executeCommand(command: string, cwd: string): Promise<ExecutionResult>;
11
32
  //# sourceMappingURL=executor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/utils/executor.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CA8B3F"}
1
+ {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/utils/executor.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,gDAAgD;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CA4C3F"}