@take-out/cli 0.4.3 → 0.4.5

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 (69) hide show
  1. package/dist/cjs/cli.cjs +53 -35
  2. package/dist/cjs/commands/changed.cjs +133 -95
  3. package/dist/cjs/commands/docs.cjs +276 -203
  4. package/dist/cjs/commands/env-setup.cjs +45 -33
  5. package/dist/cjs/commands/onboard.cjs +668 -224
  6. package/dist/cjs/commands/run-all.cjs +54 -45
  7. package/dist/cjs/commands/run.cjs +80 -65
  8. package/dist/cjs/commands/script.cjs +263 -187
  9. package/dist/cjs/commands/skills.cjs +174 -118
  10. package/dist/cjs/commands/sync.cjs +193 -93
  11. package/dist/cjs/constants/ascii.cjs +14 -12
  12. package/dist/cjs/index.cjs +12 -10
  13. package/dist/cjs/types.cjs +7 -5
  14. package/dist/cjs/utils/env-categories.cjs +53 -48
  15. package/dist/cjs/utils/env-setup.cjs +214 -106
  16. package/dist/cjs/utils/env.cjs +65 -44
  17. package/dist/cjs/utils/files.cjs +186 -113
  18. package/dist/cjs/utils/parallel-runner.cjs +125 -75
  19. package/dist/cjs/utils/ports.cjs +21 -21
  20. package/dist/cjs/utils/prerequisites.cjs +42 -34
  21. package/dist/cjs/utils/prompts.cjs +66 -41
  22. package/dist/cjs/utils/script-listing.cjs +130 -60
  23. package/dist/cjs/utils/script-utils.cjs +29 -19
  24. package/dist/cjs/utils/sync.cjs +67 -45
  25. package/dist/esm/cli.mjs +40 -24
  26. package/dist/esm/cli.mjs.map +1 -1
  27. package/dist/esm/commands/changed.mjs +104 -68
  28. package/dist/esm/commands/changed.mjs.map +1 -1
  29. package/dist/esm/commands/docs.mjs +245 -174
  30. package/dist/esm/commands/docs.mjs.map +1 -1
  31. package/dist/esm/commands/env-setup.mjs +18 -8
  32. package/dist/esm/commands/env-setup.mjs.map +1 -1
  33. package/dist/esm/commands/onboard.mjs +631 -189
  34. package/dist/esm/commands/onboard.mjs.map +1 -1
  35. package/dist/esm/commands/run-all.mjs +26 -19
  36. package/dist/esm/commands/run-all.mjs.map +1 -1
  37. package/dist/esm/commands/run.mjs +52 -39
  38. package/dist/esm/commands/run.mjs.map +1 -1
  39. package/dist/esm/commands/script.mjs +230 -156
  40. package/dist/esm/commands/script.mjs.map +1 -1
  41. package/dist/esm/commands/skills.mjs +143 -89
  42. package/dist/esm/commands/skills.mjs.map +1 -1
  43. package/dist/esm/commands/sync.mjs +160 -62
  44. package/dist/esm/commands/sync.mjs.map +1 -1
  45. package/dist/esm/constants/ascii.mjs +2 -2
  46. package/dist/esm/constants/ascii.mjs.map +1 -1
  47. package/dist/esm/utils/env-categories.mjs +29 -26
  48. package/dist/esm/utils/env-categories.mjs.map +1 -1
  49. package/dist/esm/utils/env-setup.mjs +184 -78
  50. package/dist/esm/utils/env-setup.mjs.map +1 -1
  51. package/dist/esm/utils/env.mjs +50 -31
  52. package/dist/esm/utils/env.mjs.map +1 -1
  53. package/dist/esm/utils/files.mjs +171 -100
  54. package/dist/esm/utils/files.mjs.map +1 -1
  55. package/dist/esm/utils/parallel-runner.mjs +111 -63
  56. package/dist/esm/utils/parallel-runner.mjs.map +1 -1
  57. package/dist/esm/utils/ports.mjs +9 -11
  58. package/dist/esm/utils/ports.mjs.map +1 -1
  59. package/dist/esm/utils/prerequisites.mjs +30 -24
  60. package/dist/esm/utils/prerequisites.mjs.map +1 -1
  61. package/dist/esm/utils/prompts.mjs +40 -17
  62. package/dist/esm/utils/prompts.mjs.map +1 -1
  63. package/dist/esm/utils/script-listing.mjs +101 -33
  64. package/dist/esm/utils/script-listing.mjs.map +1 -1
  65. package/dist/esm/utils/script-utils.mjs +14 -6
  66. package/dist/esm/utils/script-utils.mjs.map +1 -1
  67. package/dist/esm/utils/sync.mjs +38 -18
  68. package/dist/esm/utils/sync.mjs.map +1 -1
  69. package/package.json +5 -5
@@ -2,33 +2,35 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
16
  get: () => from[key],
16
17
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
18
  });
18
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)),
29
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
- value: !0
31
- }), mod);
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: true
33
+ }), mod);
32
34
  var script_exports = {};
33
35
  __export(script_exports, {
34
36
  createShorthandCommand: () => createShorthandCommand,
@@ -38,49 +40,59 @@ __export(script_exports, {
38
40
  scriptCommand: () => scriptCommand
39
41
  });
40
42
  module.exports = __toCommonJS(script_exports);
41
- var import_node_fs = require("node:fs"),
42
- import_node_path = require("node:path"),
43
- import_node_url = require("node:url"),
44
- import_citty = require("citty"),
45
- import_picocolors = __toESM(require("picocolors"), 1),
46
- import_script_listing = require("../utils/script-listing.cjs"),
47
- import_script_utils = require("../utils/script-utils.cjs"),
48
- import_sync = require("../utils/sync.cjs"),
49
- import_script_listing2 = require("../utils/script-listing.cjs");
43
+ var import_node_fs = require("node:fs");
44
+ var import_node_path = require("node:path");
45
+ var import_node_url = require("node:url");
46
+ var import_citty = require("citty");
47
+ var import_picocolors = __toESM(require("picocolors"), 1);
48
+ var import_script_listing = require("../utils/script-listing.cjs");
49
+ var import_script_utils = require("../utils/script-utils.cjs");
50
+ var import_sync = require("../utils/sync.cjs");
51
+ var import_script_listing2 = require("../utils/script-listing.cjs");
50
52
  const import_meta = {};
51
53
  function findScriptsPackageRoot() {
52
54
  try {
53
- const resolved = import_meta.resolve("@take-out/scripts/package.json"),
54
- packageJsonPath = (0, import_node_url.fileURLToPath)(new URL(resolved)),
55
- packageRoot = (0, import_node_path.join)(packageJsonPath, ".."),
56
- srcPath = (0, import_node_path.join)(packageRoot, "src");
57
- if ((0, import_node_fs.existsSync)(srcPath)) return srcPath;
58
- } catch {}
55
+ const resolved = import_meta.resolve("@take-out/scripts/package.json");
56
+ const packageJsonPath = (0, import_node_url.fileURLToPath)(new URL(resolved));
57
+ const packageRoot = (0, import_node_path.join)(packageJsonPath, "..");
58
+ const srcPath = (0, import_node_path.join)(packageRoot, "src");
59
+ if ((0, import_node_fs.existsSync)(srcPath)) {
60
+ return srcPath;
61
+ }
62
+ } catch (err) {}
59
63
  return null;
60
64
  }
61
65
  function findScript(name) {
62
- const normalizedName = name.replace(/:/g, "/"),
63
- localDir = (0, import_script_utils.getLocalScriptsDir)();
66
+ const normalizedName = name.replace(/:/g, "/");
67
+ const localDir = (0, import_script_utils.getLocalScriptsDir)();
64
68
  for (const ext of [".ts", ".js", ""]) {
65
69
  const localPath = (0, import_node_path.join)(localDir, `${normalizedName}${ext}`);
66
- if ((0, import_node_fs.existsSync)(localPath)) return localPath;
70
+ if ((0, import_node_fs.existsSync)(localPath)) {
71
+ return localPath;
72
+ }
67
73
  }
68
74
  const builtInDir = findScriptsPackageRoot();
69
- if (builtInDir) for (const ext of [".ts", ".js", ""]) {
70
- const builtInPath = (0, import_node_path.join)(builtInDir, `${normalizedName}${ext}`);
71
- if ((0, import_node_fs.existsSync)(builtInPath)) return builtInPath;
75
+ if (builtInDir) {
76
+ for (const ext of [".ts", ".js", ""]) {
77
+ const builtInPath = (0, import_node_path.join)(builtInDir, `${normalizedName}${ext}`);
78
+ if ((0, import_node_fs.existsSync)(builtInPath)) {
79
+ return builtInPath;
80
+ }
81
+ }
72
82
  }
73
83
  return null;
74
84
  }
75
85
  async function runScript(scriptPath, args) {
76
- console.info(import_picocolors.default.dim(`Running: ${(0, import_node_path.relative)(process.cwd(), scriptPath)}`)), console.info();
86
+ console.info(import_picocolors.default.dim(`Running: ${(0, import_node_path.relative)(process.cwd(), scriptPath)}`));
87
+ console.info();
77
88
  try {
78
89
  const {
79
90
  $
80
91
  } = await import("bun");
81
92
  await $`bun ${scriptPath} ${args}`;
82
93
  } catch (err) {
83
- console.error(import_picocolors.default.red(`\u2717 Error running script: ${err}`)), process.exit(1);
94
+ console.error(import_picocolors.default.red(`\u2717 Error running script: ${err}`));
95
+ process.exit(1);
84
96
  }
85
97
  }
86
98
  const newCommand = (0, import_citty.defineCommand)({
@@ -92,19 +104,25 @@ const newCommand = (0, import_citty.defineCommand)({
92
104
  path: {
93
105
  type: "positional",
94
106
  description: "Path for the new script (e.g., ci/test)",
95
- required: !0
107
+ required: true
96
108
  }
97
109
  },
98
110
  async run({
99
111
  args
100
112
  }) {
101
- const scriptPath = args.path,
102
- localDir = (0, import_script_utils.getLocalScriptsDir)(),
103
- fullPath = (0, import_node_path.join)(localDir, `${scriptPath}.ts`),
104
- dir = (0, import_node_path.dirname)(fullPath);
105
- (0, import_node_fs.existsSync)(dir) || (0, import_node_fs.mkdirSync)(dir, {
106
- recursive: !0
107
- }), (0, import_node_fs.existsSync)(fullPath) && (console.error(import_picocolors.default.red(`\u2717 Script already exists: ${(0, import_node_path.relative)(process.cwd(), fullPath)}`)), process.exit(1));
113
+ const scriptPath = args.path;
114
+ const localDir = (0, import_script_utils.getLocalScriptsDir)();
115
+ const fullPath = (0, import_node_path.join)(localDir, `${scriptPath}.ts`);
116
+ const dir = (0, import_node_path.dirname)(fullPath);
117
+ if (!(0, import_node_fs.existsSync)(dir)) {
118
+ (0, import_node_fs.mkdirSync)(dir, {
119
+ recursive: true
120
+ });
121
+ }
122
+ if ((0, import_node_fs.existsSync)(fullPath)) {
123
+ console.error(import_picocolors.default.red(`\u2717 Script already exists: ${(0, import_node_path.relative)(process.cwd(), fullPath)}`));
124
+ process.exit(1);
125
+ }
108
126
  const template = `#!/usr/bin/env bun
109
127
 
110
128
  /**
@@ -132,143 +150,199 @@ async function main() {
132
150
 
133
151
  main().catch(console.error)
134
152
  `;
135
- (0, import_node_fs.writeFileSync)(fullPath, template), console.info(import_picocolors.default.green(`\u2713 Created new script: ${(0, import_node_path.relative)(process.cwd(), fullPath)}`)), console.info(), console.info(import_picocolors.default.dim("Edit the script and update the TODO sections"));
153
+ (0, import_node_fs.writeFileSync)(fullPath, template);
154
+ console.info(import_picocolors.default.green(`\u2713 Created new script: ${(0, import_node_path.relative)(process.cwd(), fullPath)}`));
155
+ console.info();
156
+ console.info(import_picocolors.default.dim(`Edit the script and update the TODO sections`));
136
157
  }
137
158
  });
138
159
  function getAllScriptFiles(dir, baseDir = dir) {
139
160
  const files = [];
140
- if (!(0, import_node_fs.existsSync)(dir)) return files;
161
+ if (!(0, import_node_fs.existsSync)(dir)) {
162
+ return files;
163
+ }
141
164
  try {
142
165
  const entries = (0, import_node_fs.readdirSync)(dir);
143
166
  for (const entry of entries) {
144
167
  const fullPath = (0, import_node_path.join)(dir, entry);
145
- (0, import_node_fs.statSync)(fullPath).isDirectory() ? files.push(...getAllScriptFiles(fullPath, baseDir)) : (entry.endsWith(".ts") || entry.endsWith(".js") || entry.endsWith(".cjs")) && files.push((0, import_node_path.relative)(baseDir, fullPath).split("\\").join("/"));
168
+ const stat = (0, import_node_fs.statSync)(fullPath);
169
+ if (stat.isDirectory()) {
170
+ files.push(...getAllScriptFiles(fullPath, baseDir));
171
+ } else if (entry.endsWith(".ts") || entry.endsWith(".js") || entry.endsWith(".cjs")) {
172
+ files.push((0, import_node_path.relative)(baseDir, fullPath).split("\\").join("/"));
173
+ }
146
174
  }
147
- } catch {}
175
+ } catch (err) {}
148
176
  return files;
149
177
  }
150
178
  const ejectCommand = (0, import_citty.defineCommand)({
151
- meta: {
152
- name: "eject",
153
- description: "Eject built-in scripts into your project"
154
- },
155
- args: {
156
- yes: {
157
- type: "boolean",
158
- description: "Skip confirmations and eject all files",
159
- default: !1
160
- }
161
- },
162
- async run({
163
- args
164
- }) {
165
- const cwd = process.cwd(),
166
- targetScriptsDir = (0, import_node_path.join)(cwd, "scripts"),
167
- sourceScriptsDir = findScriptsPackageRoot();
168
- console.info(), console.info(import_picocolors.default.bold(import_picocolors.default.cyan("\u2699\uFE0F Eject Scripts"))), console.info(), sourceScriptsDir || (console.error(import_picocolors.default.red("\u2717 Built-in scripts package (@take-out/scripts) not found or not installed")), console.info(), console.info(import_picocolors.default.dim("Install with: bun add -d @take-out/scripts")), process.exit(1)), console.info(import_picocolors.default.dim(`Source: ${sourceScriptsDir}`)), console.info(import_picocolors.default.dim(`Target: ${targetScriptsDir}`)), console.info(), (0, import_node_fs.existsSync)(targetScriptsDir) || (console.info(import_picocolors.default.yellow("\u26A0 Target scripts directory does not exist, will create it")), (0, import_node_fs.mkdirSync)(targetScriptsDir, {
169
- recursive: !0
170
- }));
171
- const sourceFiles = getAllScriptFiles(sourceScriptsDir);
172
- if (sourceFiles.length === 0) {
173
- console.info(import_picocolors.default.yellow("No script files found in built-in scripts package"));
174
- return;
175
- }
176
- const filesToSync = [],
177
- stats = {
178
- new: 0,
179
- modified: 0,
180
- identical: 0
181
- };
182
- for (const file of sourceFiles) {
183
- const sourcePath = (0, import_node_path.join)(sourceScriptsDir, file),
184
- targetPath = (0, import_node_path.join)(targetScriptsDir, file),
185
- status = (0, import_sync.compareFiles)(sourcePath, targetPath);
186
- stats[status]++, filesToSync.push({
187
- name: file,
188
- sourcePath,
189
- targetPath,
190
- status,
191
- sourceSize: (0, import_sync.getFileSize)(sourcePath),
192
- targetSize: (0, import_sync.getFileSize)(targetPath)
193
- });
194
- }
195
- if (console.info(import_picocolors.default.bold("Summary:")), console.info(` ${import_picocolors.default.green(`${stats.new} new`)}`), console.info(` ${import_picocolors.default.yellow(`${stats.modified} modified`)}`), console.info(` ${import_picocolors.default.dim(`${stats.identical} identical`)}`), console.info(), stats.new === 0 && stats.modified === 0) {
196
- console.info(import_picocolors.default.green("\u2713 All scripts are already up to date!"));
197
- return;
198
- }
199
- const sortOrder = {
200
- new: 0,
201
- modified: 1,
202
- identical: 2
203
- };
204
- filesToSync.sort((a, b) => sortOrder[a.status] - sortOrder[b.status]);
205
- let syncedCount = 0;
206
- for (const file of filesToSync) if (args.yes && file.status !== "identical") {
179
+ meta: {
180
+ name: "eject",
181
+ description: "Eject built-in scripts into your project"
182
+ },
183
+ args: {
184
+ yes: {
185
+ type: "boolean",
186
+ description: "Skip confirmations and eject all files",
187
+ default: false
188
+ }
189
+ },
190
+ async run({
191
+ args
192
+ }) {
193
+ const cwd = process.cwd();
194
+ const targetScriptsDir = (0, import_node_path.join)(cwd, "scripts");
195
+ const sourceScriptsDir = findScriptsPackageRoot();
196
+ console.info();
197
+ console.info(import_picocolors.default.bold(import_picocolors.default.cyan("\u2699\uFE0F Eject Scripts")));
198
+ console.info();
199
+ if (!sourceScriptsDir) {
200
+ console.error(import_picocolors.default.red("\u2717 Built-in scripts package (@take-out/scripts) not found or not installed"));
201
+ console.info();
202
+ console.info(import_picocolors.default.dim("Install with: bun add -d @take-out/scripts"));
203
+ process.exit(1);
204
+ }
205
+ console.info(import_picocolors.default.dim(`Source: ${sourceScriptsDir}`));
206
+ console.info(import_picocolors.default.dim(`Target: ${targetScriptsDir}`));
207
+ console.info();
208
+ if (!(0, import_node_fs.existsSync)(targetScriptsDir)) {
209
+ console.info(import_picocolors.default.yellow("\u26A0 Target scripts directory does not exist, will create it"));
210
+ (0, import_node_fs.mkdirSync)(targetScriptsDir, {
211
+ recursive: true
212
+ });
213
+ }
214
+ const sourceFiles = getAllScriptFiles(sourceScriptsDir);
215
+ if (sourceFiles.length === 0) {
216
+ console.info(import_picocolors.default.yellow("No script files found in built-in scripts package"));
217
+ return;
218
+ }
219
+ const filesToSync = [];
220
+ const stats = {
221
+ new: 0,
222
+ modified: 0,
223
+ identical: 0
224
+ };
225
+ for (const file of sourceFiles) {
226
+ const sourcePath = (0, import_node_path.join)(sourceScriptsDir, file);
227
+ const targetPath = (0, import_node_path.join)(targetScriptsDir, file);
228
+ const status = (0, import_sync.compareFiles)(sourcePath, targetPath);
229
+ stats[status]++;
230
+ filesToSync.push({
231
+ name: file,
232
+ sourcePath,
233
+ targetPath,
234
+ status,
235
+ sourceSize: (0, import_sync.getFileSize)(sourcePath),
236
+ targetSize: (0, import_sync.getFileSize)(targetPath)
237
+ });
238
+ }
239
+ console.info(import_picocolors.default.bold("Summary:"));
240
+ console.info(` ${import_picocolors.default.green(`${stats.new} new`)}`);
241
+ console.info(` ${import_picocolors.default.yellow(`${stats.modified} modified`)}`);
242
+ console.info(` ${import_picocolors.default.dim(`${stats.identical} identical`)}`);
243
+ console.info();
244
+ if (stats.new === 0 && stats.modified === 0) {
245
+ console.info(import_picocolors.default.green("\u2713 All scripts are already up to date!"));
246
+ return;
247
+ }
248
+ const sortOrder = {
249
+ new: 0,
250
+ modified: 1,
251
+ identical: 2
252
+ };
253
+ filesToSync.sort((a, b) => sortOrder[a.status] - sortOrder[b.status]);
254
+ let syncedCount = 0;
255
+ for (const file of filesToSync) {
256
+ if (args.yes && file.status !== "identical") {
207
257
  const targetDir = (0, import_node_path.dirname)(file.targetPath);
208
- (0, import_node_fs.existsSync)(targetDir) || (0, import_node_fs.mkdirSync)(targetDir, {
209
- recursive: !0
210
- });
258
+ if (!(0, import_node_fs.existsSync)(targetDir)) {
259
+ (0, import_node_fs.mkdirSync)(targetDir, {
260
+ recursive: true
261
+ });
262
+ }
211
263
  const content = (0, import_node_fs.readFileSync)(file.sourcePath);
212
- (0, import_node_fs.writeFileSync)(file.targetPath, content), console.info(import_picocolors.default.green(` \u2713 ${file.name}`)), syncedCount++;
213
- } else (await (0, import_sync.syncFileWithConfirmation)(file)) && syncedCount++;
214
- console.info(), console.info(import_picocolors.default.bold(import_picocolors.default.green(`\u2713 Complete: ${syncedCount} file(s) ejected`))), console.info();
215
- }
216
- }),
217
- runSubCommand = (0, import_citty.defineCommand)({
218
- meta: {
219
- name: "run",
220
- description: "Run a script (for backwards compatibility)"
221
- },
222
- args: {
223
- name: {
224
- type: "positional",
225
- description: "Script name",
226
- required: !0
264
+ (0, import_node_fs.writeFileSync)(file.targetPath, content);
265
+ console.info(import_picocolors.default.green(` \u2713 ${file.name}`));
266
+ syncedCount++;
267
+ } else {
268
+ const wasSynced = await (0, import_sync.syncFileWithConfirmation)(file);
269
+ if (wasSynced) {
270
+ syncedCount++;
271
+ }
227
272
  }
228
- },
229
- async run({
230
- args,
231
- rawArgs
232
- }) {
233
- const scriptPath = findScript(args.name);
234
- scriptPath || (console.error(import_picocolors.default.red(`\u2717 Script not found: ${args.name}`)), console.info(), console.info(import_picocolors.default.dim("Run 'tko script' to see available scripts")), process.exit(1));
235
- const scriptArgs = rawArgs.slice(rawArgs.indexOf(args.name) + 1);
236
- await runScript(scriptPath, scriptArgs);
237
273
  }
238
- }),
239
- scriptCommand = (0, import_citty.defineCommand)({
240
- meta: {
241
- name: "script",
242
- description: "Hybrid script runner with filesystem discovery"
243
- },
244
- args: {
245
- name: {
246
- type: "positional",
247
- description: "Script name or category to run/list",
248
- required: !1
249
- }
250
- },
251
- subCommands: {
252
- new: newCommand,
253
- run: runSubCommand,
254
- eject: ejectCommand
255
- },
256
- async run({
257
- args,
258
- rawArgs
259
- }) {
260
- const scriptName = args.name || rawArgs[1];
261
- if (!scriptName) {
262
- await (0, import_script_listing.listAllScripts)(!1);
263
- return;
264
- }
265
- if (await (0, import_script_listing.listCategoryScripts)(scriptName)) return;
266
- const scriptPath = findScript(scriptName);
267
- scriptPath || (console.error(import_picocolors.default.red(`\u2717 Script not found: ${scriptName}`)), console.info(), console.info(import_picocolors.default.dim("Run 'tko script' to see available scripts")), process.exit(1));
268
- const scriptArgs = rawArgs.slice(rawArgs.indexOf(scriptName) + 1);
269
- await runScript(scriptPath, scriptArgs);
274
+ console.info();
275
+ console.info(import_picocolors.default.bold(import_picocolors.default.green(`\u2713 Complete: ${syncedCount} file(s) ejected`)));
276
+ console.info();
277
+ }
278
+ });
279
+ const runSubCommand = (0, import_citty.defineCommand)({
280
+ meta: {
281
+ name: "run",
282
+ description: "Run a script (for backwards compatibility)"
283
+ },
284
+ args: {
285
+ name: {
286
+ type: "positional",
287
+ description: "Script name",
288
+ required: true
270
289
  }
271
- });
290
+ },
291
+ async run({
292
+ args,
293
+ rawArgs
294
+ }) {
295
+ const scriptPath = findScript(args.name);
296
+ if (!scriptPath) {
297
+ console.error(import_picocolors.default.red(`\u2717 Script not found: ${args.name}`));
298
+ console.info();
299
+ console.info(import_picocolors.default.dim(`Run 'tko script' to see available scripts`));
300
+ process.exit(1);
301
+ }
302
+ const scriptArgs = rawArgs.slice(rawArgs.indexOf(args.name) + 1);
303
+ await runScript(scriptPath, scriptArgs);
304
+ }
305
+ });
306
+ const scriptCommand = (0, import_citty.defineCommand)({
307
+ meta: {
308
+ name: "script",
309
+ description: "Hybrid script runner with filesystem discovery"
310
+ },
311
+ args: {
312
+ name: {
313
+ type: "positional",
314
+ description: "Script name or category to run/list",
315
+ required: false
316
+ }
317
+ },
318
+ subCommands: {
319
+ new: newCommand,
320
+ run: runSubCommand,
321
+ eject: ejectCommand
322
+ },
323
+ async run({
324
+ args,
325
+ rawArgs
326
+ }) {
327
+ const scriptName = args.name || rawArgs[1];
328
+ if (!scriptName) {
329
+ await (0, import_script_listing.listAllScripts)(false);
330
+ return;
331
+ }
332
+ if (await (0, import_script_listing.listCategoryScripts)(scriptName)) {
333
+ return;
334
+ }
335
+ const scriptPath = findScript(scriptName);
336
+ if (!scriptPath) {
337
+ console.error(import_picocolors.default.red(`\u2717 Script not found: ${scriptName}`));
338
+ console.info();
339
+ console.info(import_picocolors.default.dim(`Run 'tko script' to see available scripts`));
340
+ process.exit(1);
341
+ }
342
+ const scriptArgs = rawArgs.slice(rawArgs.indexOf(scriptName) + 1);
343
+ await runScript(scriptPath, scriptArgs);
344
+ }
345
+ });
272
346
  function createShorthandCommand(name) {
273
347
  return (0, import_citty.defineCommand)({
274
348
  meta: {
@@ -279,25 +353,27 @@ function createShorthandCommand(name) {
279
353
  args: {
280
354
  type: "positional",
281
355
  description: "Script and arguments",
282
- required: !1
356
+ required: false
283
357
  }
284
358
  },
285
359
  async run({
286
360
  rawArgs
287
361
  }) {
288
- const scriptName = rawArgs.length > 0 ? `${name}/${rawArgs[0]}` : name,
289
- scriptArgs = rawArgs.length > 0 ? ["script", scriptName, ...rawArgs.slice(1)] : ["script", name],
290
- {
291
- run
292
- } = scriptCommand;
293
- run && (await run({
294
- args: {
295
- name: scriptName,
296
- _: rawArgs.slice(1)
297
- },
298
- rawArgs: scriptArgs,
299
- cmd: scriptCommand
300
- }));
362
+ const scriptName = rawArgs.length > 0 ? `${name}/${rawArgs[0]}` : name;
363
+ const scriptArgs = rawArgs.length > 0 ? ["script", scriptName, ...rawArgs.slice(1)] : ["script", name];
364
+ const {
365
+ run
366
+ } = scriptCommand;
367
+ if (run) {
368
+ await run({
369
+ args: {
370
+ name: scriptName,
371
+ _: rawArgs.slice(1)
372
+ },
373
+ rawArgs: scriptArgs,
374
+ cmd: scriptCommand
375
+ });
376
+ }
301
377
  }
302
378
  });
303
379
  }