@take-out/cli 0.0.43 → 0.0.44

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 (43) hide show
  1. package/dist/cjs/cli.native.js +28 -35
  2. package/dist/cjs/cli.native.js.map +1 -6
  3. package/dist/cjs/commands/changed.native.js +132 -111
  4. package/dist/cjs/commands/changed.native.js.map +1 -6
  5. package/dist/cjs/commands/docs.native.js +405 -326
  6. package/dist/cjs/commands/docs.native.js.map +1 -6
  7. package/dist/cjs/commands/env-setup.native.js +75 -64
  8. package/dist/cjs/commands/env-setup.native.js.map +1 -6
  9. package/dist/cjs/commands/onboard.native.js +206 -193
  10. package/dist/cjs/commands/onboard.native.js.map +1 -6
  11. package/dist/cjs/commands/run.native.js +139 -109
  12. package/dist/cjs/commands/run.native.js.map +1 -6
  13. package/dist/cjs/commands/script.native.js +269 -227
  14. package/dist/cjs/commands/script.native.js.map +1 -6
  15. package/dist/cjs/commands/sync.native.js +58 -58
  16. package/dist/cjs/commands/sync.native.js.map +1 -6
  17. package/dist/cjs/constants/ascii.native.js +19 -16
  18. package/dist/cjs/constants/ascii.native.js.map +1 -6
  19. package/dist/cjs/index.native.js +22 -49
  20. package/dist/cjs/index.native.js.map +1 -6
  21. package/dist/cjs/types.native.js +9 -5
  22. package/dist/cjs/types.native.js.map +1 -6
  23. package/dist/cjs/utils/env-categories.native.js +181 -210
  24. package/dist/cjs/utils/env-categories.native.js.map +1 -6
  25. package/dist/cjs/utils/env-setup.native.js +104 -87
  26. package/dist/cjs/utils/env-setup.native.js.map +1 -6
  27. package/dist/cjs/utils/env.native.js +48 -46
  28. package/dist/cjs/utils/env.native.js.map +1 -6
  29. package/dist/cjs/utils/files.native.js +123 -111
  30. package/dist/cjs/utils/files.native.js.map +1 -6
  31. package/dist/cjs/utils/parallel-runner.native.js +70 -58
  32. package/dist/cjs/utils/parallel-runner.native.js.map +1 -6
  33. package/dist/cjs/utils/ports.native.js +37 -44
  34. package/dist/cjs/utils/ports.native.js.map +1 -6
  35. package/dist/cjs/utils/prerequisites.native.js +38 -37
  36. package/dist/cjs/utils/prerequisites.native.js.map +1 -6
  37. package/dist/cjs/utils/prompts.native.js +60 -72
  38. package/dist/cjs/utils/prompts.native.js.map +1 -6
  39. package/dist/cjs/utils/script-listing.native.js +73 -56
  40. package/dist/cjs/utils/script-listing.native.js.map +1 -6
  41. package/dist/cjs/utils/sync.native.js +39 -30
  42. package/dist/cjs/utils/sync.native.js.map +1 -6
  43. package/package.json +4 -4
@@ -1,26 +1,36 @@
1
1
  "use strict";
2
+
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __getProtoOf = Object.getPrototypeOf,
8
+ __hasOwnProp = Object.prototype.hasOwnProperty;
7
9
  var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: !0 });
10
- }, __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from == "object" || typeof from == "function")
12
- for (let key of __getOwnPropNames(from))
13
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- return to;
15
- };
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: !0
13
+ });
14
+ },
15
+ __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ return to;
21
+ };
16
22
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
23
  // If the importer is in node compatibility mode or this is not an ESM
18
24
  // file that has been converted to a CommonJS file using a Babel-
19
25
  // compatible transform (i.e. "__esModule" has not been set), then set
20
26
  // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
22
- mod
23
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: !0
30
+ }) : target, mod)),
31
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: !0
33
+ }), mod);
24
34
  var script_exports = {};
25
35
  __export(script_exports, {
26
36
  createShorthandCommand: () => createShorthandCommand,
@@ -34,16 +44,26 @@ __export(script_exports, {
34
44
  scriptCommand: () => scriptCommand
35
45
  });
36
46
  module.exports = __toCommonJS(script_exports);
37
- var import_fs = require("fs"), import_os = require("os"), import_path = require("path"), import_url = require("url"), import_citty = require("citty"), import_picocolors = __toESM(require("picocolors"), 1), import_script_listing = require("../utils/script-listing"), import_sync = require("../utils/sync"), import_script_listing2 = require("../utils/script-listing");
47
+ var import_fs = require("fs"),
48
+ import_os = require("os"),
49
+ import_path = require("path"),
50
+ import_url = require("url"),
51
+ import_citty = require("citty"),
52
+ import_picocolors = __toESM(require("picocolors"), 1),
53
+ import_script_listing = require("../utils/script-listing.native.js"),
54
+ import_sync = require("../utils/sync.native.js"),
55
+ import_script_listing2 = require("../utils/script-listing.native.js");
38
56
  const import_meta = {};
39
- var CACHE_DIR = (0, import_path.join)((0, import_os.homedir)(), ".takeout"), CACHE_FILE = (0, import_path.join)(CACHE_DIR, "script-cache.json");
57
+ var CACHE_DIR = (0, import_path.join)((0, import_os.homedir)(), ".takeout"),
58
+ CACHE_FILE = (0, import_path.join)(CACHE_DIR, "script-cache.json");
40
59
  function findScriptsPackageRoot() {
41
60
  try {
42
- var resolved = import_meta.resolve("@take-out/scripts/package.json"), packageJsonPath = (0, import_url.fileURLToPath)(new URL(resolved)), packageRoot = (0, import_path.join)(packageJsonPath, ".."), srcPath = (0, import_path.join)(packageRoot, "src");
43
- if ((0, import_fs.existsSync)(srcPath))
44
- return srcPath;
45
- } catch {
46
- }
61
+ var resolved = import_meta.resolve("@take-out/scripts/package.json"),
62
+ packageJsonPath = (0, import_url.fileURLToPath)(new URL(resolved)),
63
+ packageRoot = (0, import_path.join)(packageJsonPath, ".."),
64
+ srcPath = (0, import_path.join)(packageRoot, "src");
65
+ if ((0, import_fs.existsSync)(srcPath)) return srcPath;
66
+ } catch {}
47
67
  return null;
48
68
  }
49
69
  function getLocalScriptsDir() {
@@ -51,14 +71,20 @@ function getLocalScriptsDir() {
51
71
  }
52
72
  function extractMetadata(filePath) {
53
73
  try {
54
- var content = (0, import_fs.readFileSync)(filePath, "utf-8"), lines = content.split(`
55
- `).slice(0, 20), metadata = {}, _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
74
+ var content = (0, import_fs.readFileSync)(filePath, "utf-8"),
75
+ lines = content.split(`
76
+ `).slice(0, 20),
77
+ metadata = {},
78
+ _iteratorNormalCompletion = !0,
79
+ _didIteratorError = !1,
80
+ _iteratorError = void 0;
56
81
  try {
57
82
  for (var _iterator = lines[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
58
- var line = _step.value, descMatch = line.match(/@description\s+(.+)/);
83
+ var line = _step.value,
84
+ descMatch = line.match(/@description\s+(.+)/);
59
85
  descMatch && descMatch[1] && (metadata.description = descMatch[1].trim());
60
86
  var argsMatch = line.match(/@args\s+(.+)/);
61
- argsMatch && argsMatch[1] && (metadata.args = argsMatch[1].split(",").map(function(a) {
87
+ argsMatch && argsMatch[1] && (metadata.args = argsMatch[1].split(",").map(function (a) {
62
88
  return a.trim();
63
89
  }));
64
90
  }
@@ -68,8 +94,7 @@ function extractMetadata(filePath) {
68
94
  try {
69
95
  !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
70
96
  } finally {
71
- if (_didIteratorError)
72
- throw _iteratorError;
97
+ if (_didIteratorError) throw _iteratorError;
73
98
  }
74
99
  }
75
100
  var stat = (0, import_fs.statSync)(filePath);
@@ -80,10 +105,8 @@ function extractMetadata(filePath) {
80
105
  }
81
106
  function loadCache() {
82
107
  try {
83
- if ((0, import_fs.existsSync)(CACHE_FILE))
84
- return JSON.parse((0, import_fs.readFileSync)(CACHE_FILE, "utf-8"));
85
- } catch {
86
- }
108
+ if ((0, import_fs.existsSync)(CACHE_FILE)) return JSON.parse((0, import_fs.readFileSync)(CACHE_FILE, "utf-8"));
109
+ } catch {}
87
110
  return {};
88
111
  }
89
112
  function saveCache(cache) {
@@ -91,29 +114,37 @@ function saveCache(cache) {
91
114
  (0, import_fs.existsSync)(CACHE_DIR) || (0, import_fs.mkdirSync)(CACHE_DIR, {
92
115
  recursive: !0
93
116
  }), (0, import_fs.writeFileSync)(CACHE_FILE, JSON.stringify(cache, null, 2));
94
- } catch {
95
- }
117
+ } catch {}
96
118
  }
97
119
  function getScriptMetadata(filePath) {
98
- var cache = loadCache(), stat = (0, import_fs.statSync)(filePath);
99
- if (cache[filePath] && cache[filePath].mtime === stat.mtimeMs)
100
- return cache[filePath];
120
+ var cache = loadCache(),
121
+ stat = (0, import_fs.statSync)(filePath);
122
+ if (cache[filePath] && cache[filePath].mtime === stat.mtimeMs) return cache[filePath];
101
123
  var metadata = extractMetadata(filePath);
102
124
  return cache[filePath] = metadata, saveCache(cache), metadata;
103
125
  }
104
126
  function discoverScripts(dir) {
105
- var baseDir = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : dir, depth = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0, maxDepth = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 1, scripts = /* @__PURE__ */ new Map();
106
- if (!(0, import_fs.existsSync)(dir))
107
- return scripts;
127
+ var baseDir = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : dir,
128
+ depth = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0,
129
+ maxDepth = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 1,
130
+ scripts = /* @__PURE__ */new Map();
131
+ if (!(0, import_fs.existsSync)(dir)) return scripts;
108
132
  try {
109
- var entries = (0, import_fs.readdirSync)(dir), _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
133
+ var entries = (0, import_fs.readdirSync)(dir),
134
+ _iteratorNormalCompletion = !0,
135
+ _didIteratorError = !1,
136
+ _iteratorError = void 0;
110
137
  try {
111
138
  for (var _iterator = entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
112
- var entry = _step.value, fullPath = (0, import_path.join)(dir, entry), stat = (0, import_fs.statSync)(fullPath);
139
+ var entry = _step.value,
140
+ fullPath = (0, import_path.join)(dir, entry),
141
+ stat = (0, import_fs.statSync)(fullPath);
113
142
  if (stat.isDirectory()) {
114
- if (entry === "helpers" || depth >= maxDepth)
115
- continue;
116
- var subScripts = discoverScripts(fullPath, baseDir, depth + 1, maxDepth), _iteratorNormalCompletion1 = !0, _didIteratorError1 = !1, _iteratorError1 = void 0;
143
+ if (entry === "helpers" || depth >= maxDepth) continue;
144
+ var subScripts = discoverScripts(fullPath, baseDir, depth + 1, maxDepth),
145
+ _iteratorNormalCompletion1 = !0,
146
+ _didIteratorError1 = !1,
147
+ _iteratorError1 = void 0;
117
148
  try {
118
149
  for (var _iterator1 = subScripts[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) {
119
150
  var [name, path] = _step1.value;
@@ -125,12 +156,12 @@ function discoverScripts(dir) {
125
156
  try {
126
157
  !_iteratorNormalCompletion1 && _iterator1.return != null && _iterator1.return();
127
158
  } finally {
128
- if (_didIteratorError1)
129
- throw _iteratorError1;
159
+ if (_didIteratorError1) throw _iteratorError1;
130
160
  }
131
161
  }
132
162
  } else if (entry.endsWith(".ts") || entry.endsWith(".js")) {
133
- var relativePath = (0, import_path.relative)(baseDir, fullPath).split("\\").join("/"), scriptName = relativePath.replace(/\.(ts|js)$/, "");
163
+ var relativePath = (0, import_path.relative)(baseDir, fullPath).split("\\").join("/"),
164
+ scriptName = relativePath.replace(/\.(ts|js)$/, "");
134
165
  scripts.set(scriptName, fullPath);
135
166
  }
136
167
  }
@@ -140,41 +171,32 @@ function discoverScripts(dir) {
140
171
  try {
141
172
  !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
142
173
  } finally {
143
- if (_didIteratorError)
144
- throw _iteratorError;
174
+ if (_didIteratorError) throw _iteratorError;
145
175
  }
146
176
  }
147
- } catch {
148
- }
177
+ } catch {}
149
178
  return scripts;
150
179
  }
151
180
  function findScript(name) {
152
- for (var normalizedName = name.replace(/:/g, "/"), localDir = getLocalScriptsDir(), _i = 0, _iter = [
153
- ".ts",
154
- ".js",
155
- ""
156
- ]; _i < _iter.length; _i++) {
157
- var ext = _iter[_i], localPath = (0, import_path.join)(localDir, `${normalizedName}${ext}`);
158
- if ((0, import_fs.existsSync)(localPath))
159
- return localPath;
181
+ for (var normalizedName = name.replace(/:/g, "/"), localDir = getLocalScriptsDir(), _i = 0, _iter = [".ts", ".js", ""]; _i < _iter.length; _i++) {
182
+ var ext = _iter[_i],
183
+ localPath = (0, import_path.join)(localDir, `${normalizedName}${ext}`);
184
+ if ((0, import_fs.existsSync)(localPath)) return localPath;
160
185
  }
161
186
  var builtInDir = findScriptsPackageRoot();
162
- if (builtInDir)
163
- for (var _i1 = 0, _iter1 = [
164
- ".ts",
165
- ".js",
166
- ""
167
- ]; _i1 < _iter1.length; _i1++) {
168
- var ext1 = _iter1[_i1], builtInPath = (0, import_path.join)(builtInDir, `${normalizedName}${ext1}`);
169
- if ((0, import_fs.existsSync)(builtInPath))
170
- return builtInPath;
171
- }
187
+ if (builtInDir) for (var _i1 = 0, _iter1 = [".ts", ".js", ""]; _i1 < _iter1.length; _i1++) {
188
+ var ext1 = _iter1[_i1],
189
+ builtInPath = (0, import_path.join)(builtInDir, `${normalizedName}${ext1}`);
190
+ if ((0, import_fs.existsSync)(builtInPath)) return builtInPath;
191
+ }
172
192
  return null;
173
193
  }
174
194
  async function runScript(scriptPath, args) {
175
195
  console.info(import_picocolors.default.dim(`Running: ${(0, import_path.relative)(process.cwd(), scriptPath)}`)), console.info();
176
196
  try {
177
- var { $ } = await import("bun");
197
+ var {
198
+ $
199
+ } = await import("bun");
178
200
  await $`bun ${scriptPath} ${args}`;
179
201
  } catch (err) {
180
202
  console.error(import_picocolors.default.red(`\u2717 Error running script: ${err}`)), process.exit(1);
@@ -193,7 +215,13 @@ var newCommand = (0, import_citty.defineCommand)({
193
215
  }
194
216
  },
195
217
  async run(param) {
196
- var { args } = param, scriptPath = args.path, localDir = getLocalScriptsDir(), fullPath = (0, import_path.join)(localDir, `${scriptPath}.ts`), dir = (0, import_path.dirname)(fullPath);
218
+ var {
219
+ args
220
+ } = param,
221
+ scriptPath = args.path,
222
+ localDir = getLocalScriptsDir(),
223
+ fullPath = (0, import_path.join)(localDir, `${scriptPath}.ts`),
224
+ dir = (0, import_path.dirname)(fullPath);
197
225
  (0, import_fs.existsSync)(dir) || (0, import_fs.mkdirSync)(dir, {
198
226
  recursive: !0
199
227
  }), (0, import_fs.existsSync)(fullPath) && (console.error(import_picocolors.default.red(`\u2717 Script already exists: ${(0, import_path.relative)(process.cwd(), fullPath)}`)), process.exit(1));
@@ -239,14 +267,19 @@ main().catch(console.error)
239
267
  }
240
268
  });
241
269
  function getAllScriptFiles(dir) {
242
- var baseDir = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : dir, files = [];
243
- if (!(0, import_fs.existsSync)(dir))
244
- return files;
270
+ var baseDir = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : dir,
271
+ files = [];
272
+ if (!(0, import_fs.existsSync)(dir)) return files;
245
273
  try {
246
- var entries = (0, import_fs.readdirSync)(dir), _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
274
+ var entries = (0, import_fs.readdirSync)(dir),
275
+ _iteratorNormalCompletion = !0,
276
+ _didIteratorError = !1,
277
+ _iteratorError = void 0;
247
278
  try {
248
279
  for (var _iterator = entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
249
- var entry = _step.value, fullPath = (0, import_path.join)(dir, entry), stat = (0, import_fs.statSync)(fullPath);
280
+ var entry = _step.value,
281
+ fullPath = (0, import_path.join)(dir, entry),
282
+ stat = (0, import_fs.statSync)(fullPath);
250
283
  stat.isDirectory() ? files.push(...getAllScriptFiles(fullPath, baseDir)) : (entry.endsWith(".ts") || entry.endsWith(".js") || entry.endsWith(".cjs")) && files.push((0, import_path.relative)(baseDir, fullPath).split("\\").join("/"));
251
284
  }
252
285
  } catch (err) {
@@ -255,152 +288,173 @@ function getAllScriptFiles(dir) {
255
288
  try {
256
289
  !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
257
290
  } finally {
258
- if (_didIteratorError)
259
- throw _iteratorError;
291
+ if (_didIteratorError) throw _iteratorError;
260
292
  }
261
293
  }
262
- } catch {
263
- }
294
+ } catch {}
264
295
  return files;
265
296
  }
266
297
  var ejectCommand = (0, import_citty.defineCommand)({
267
- meta: {
268
- name: "eject",
269
- description: "Eject built-in scripts into your project"
270
- },
271
- args: {
272
- yes: {
273
- type: "boolean",
274
- description: "Skip confirmations and eject all files",
275
- default: !1
276
- }
277
- },
278
- async run(param) {
279
- var { args } = param, cwd = process.cwd(), targetScriptsDir = (0, import_path.join)(cwd, "scripts"), sourceScriptsDir = findScriptsPackageRoot();
280
- 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_fs.existsSync)(targetScriptsDir) || (console.info(import_picocolors.default.yellow("\u26A0 Target scripts directory does not exist, will create it")), (0, import_fs.mkdirSync)(targetScriptsDir, {
281
- recursive: !0
282
- }));
283
- var sourceFiles = getAllScriptFiles(sourceScriptsDir);
284
- if (sourceFiles.length === 0) {
285
- console.info(import_picocolors.default.yellow("No script files found in built-in scripts package"));
286
- return;
287
- }
288
- var filesToSync = [], stats = {
289
- new: 0,
290
- modified: 0,
291
- identical: 0
292
- }, _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
293
- try {
294
- for (var _iterator = sourceFiles[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
295
- var file = _step.value, sourcePath = (0, import_path.join)(sourceScriptsDir, file), targetPath = (0, import_path.join)(targetScriptsDir, file), status = (0, import_sync.compareFiles)(sourcePath, targetPath);
296
- stats[status]++, filesToSync.push({
297
- name: file,
298
- sourcePath,
299
- targetPath,
300
- status,
301
- sourceSize: (0, import_sync.getFileSize)(sourcePath),
302
- targetSize: (0, import_sync.getFileSize)(targetPath)
303
- });
298
+ meta: {
299
+ name: "eject",
300
+ description: "Eject built-in scripts into your project"
301
+ },
302
+ args: {
303
+ yes: {
304
+ type: "boolean",
305
+ description: "Skip confirmations and eject all files",
306
+ default: !1
304
307
  }
305
- } catch (err) {
306
- _didIteratorError = !0, _iteratorError = err;
307
- } finally {
308
- try {
309
- !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
310
- } finally {
311
- if (_didIteratorError)
312
- throw _iteratorError;
308
+ },
309
+ async run(param) {
310
+ var {
311
+ args
312
+ } = param,
313
+ cwd = process.cwd(),
314
+ targetScriptsDir = (0, import_path.join)(cwd, "scripts"),
315
+ sourceScriptsDir = findScriptsPackageRoot();
316
+ 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_fs.existsSync)(targetScriptsDir) || (console.info(import_picocolors.default.yellow("\u26A0 Target scripts directory does not exist, will create it")), (0, import_fs.mkdirSync)(targetScriptsDir, {
317
+ recursive: !0
318
+ }));
319
+ var sourceFiles = getAllScriptFiles(sourceScriptsDir);
320
+ if (sourceFiles.length === 0) {
321
+ console.info(import_picocolors.default.yellow("No script files found in built-in scripts package"));
322
+ return;
313
323
  }
314
- }
315
- 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) {
316
- console.info(import_picocolors.default.green("\u2713 All scripts are already up to date!"));
317
- return;
318
- }
319
- var sortOrder = {
320
- new: 0,
321
- modified: 1,
322
- identical: 2
323
- };
324
- filesToSync.sort(function(a, b) {
325
- return sortOrder[a.status] - sortOrder[b.status];
326
- });
327
- var syncedCount = 0, _iteratorNormalCompletion1 = !0, _didIteratorError1 = !1, _iteratorError1 = void 0;
328
- try {
329
- for (var _iterator1 = filesToSync[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) {
330
- var file1 = _step1.value;
331
- if (args.yes && file1.status !== "identical") {
332
- var targetDir = (0, import_path.dirname)(file1.targetPath);
333
- (0, import_fs.existsSync)(targetDir) || (0, import_fs.mkdirSync)(targetDir, {
334
- recursive: !0
324
+ var filesToSync = [],
325
+ stats = {
326
+ new: 0,
327
+ modified: 0,
328
+ identical: 0
329
+ },
330
+ _iteratorNormalCompletion = !0,
331
+ _didIteratorError = !1,
332
+ _iteratorError = void 0;
333
+ try {
334
+ for (var _iterator = sourceFiles[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
335
+ var file = _step.value,
336
+ sourcePath = (0, import_path.join)(sourceScriptsDir, file),
337
+ targetPath = (0, import_path.join)(targetScriptsDir, file),
338
+ status = (0, import_sync.compareFiles)(sourcePath, targetPath);
339
+ stats[status]++, filesToSync.push({
340
+ name: file,
341
+ sourcePath,
342
+ targetPath,
343
+ status,
344
+ sourceSize: (0, import_sync.getFileSize)(sourcePath),
345
+ targetSize: (0, import_sync.getFileSize)(targetPath)
335
346
  });
336
- var content = (0, import_fs.readFileSync)(file1.sourcePath);
337
- (0, import_fs.writeFileSync)(file1.targetPath, content), console.info(import_picocolors.default.green(` \u2713 ${file1.name}`)), syncedCount++;
338
- } else {
339
- var wasSynced = await (0, import_sync.syncFileWithConfirmation)(file1);
340
- wasSynced && syncedCount++;
347
+ }
348
+ } catch (err) {
349
+ _didIteratorError = !0, _iteratorError = err;
350
+ } finally {
351
+ try {
352
+ !_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
353
+ } finally {
354
+ if (_didIteratorError) throw _iteratorError;
341
355
  }
342
356
  }
343
- } catch (err) {
344
- _didIteratorError1 = !0, _iteratorError1 = err;
345
- } finally {
357
+ 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) {
358
+ console.info(import_picocolors.default.green("\u2713 All scripts are already up to date!"));
359
+ return;
360
+ }
361
+ var sortOrder = {
362
+ new: 0,
363
+ modified: 1,
364
+ identical: 2
365
+ };
366
+ filesToSync.sort(function (a, b) {
367
+ return sortOrder[a.status] - sortOrder[b.status];
368
+ });
369
+ var syncedCount = 0,
370
+ _iteratorNormalCompletion1 = !0,
371
+ _didIteratorError1 = !1,
372
+ _iteratorError1 = void 0;
346
373
  try {
347
- !_iteratorNormalCompletion1 && _iterator1.return != null && _iterator1.return();
374
+ for (var _iterator1 = filesToSync[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) {
375
+ var file1 = _step1.value;
376
+ if (args.yes && file1.status !== "identical") {
377
+ var targetDir = (0, import_path.dirname)(file1.targetPath);
378
+ (0, import_fs.existsSync)(targetDir) || (0, import_fs.mkdirSync)(targetDir, {
379
+ recursive: !0
380
+ });
381
+ var content = (0, import_fs.readFileSync)(file1.sourcePath);
382
+ (0, import_fs.writeFileSync)(file1.targetPath, content), console.info(import_picocolors.default.green(` \u2713 ${file1.name}`)), syncedCount++;
383
+ } else {
384
+ var wasSynced = await (0, import_sync.syncFileWithConfirmation)(file1);
385
+ wasSynced && syncedCount++;
386
+ }
387
+ }
388
+ } catch (err) {
389
+ _didIteratorError1 = !0, _iteratorError1 = err;
348
390
  } finally {
349
- if (_didIteratorError1)
350
- throw _iteratorError1;
391
+ try {
392
+ !_iteratorNormalCompletion1 && _iterator1.return != null && _iterator1.return();
393
+ } finally {
394
+ if (_didIteratorError1) throw _iteratorError1;
395
+ }
351
396
  }
397
+ console.info(), console.info(import_picocolors.default.bold(import_picocolors.default.green(`\u2713 Complete: ${syncedCount} file(s) ejected`))), console.info();
352
398
  }
353
- console.info(), console.info(import_picocolors.default.bold(import_picocolors.default.green(`\u2713 Complete: ${syncedCount} file(s) ejected`))), console.info();
354
- }
355
- }), runSubCommand = (0, import_citty.defineCommand)({
356
- meta: {
357
- name: "run",
358
- description: "Run a script (for backwards compatibility)"
359
- },
360
- args: {
361
- name: {
362
- type: "positional",
363
- description: "Script name",
364
- required: !0
365
- }
366
- },
367
- async run(param) {
368
- var { args, rawArgs } = param, scriptPath = findScript(args.name);
369
- 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));
370
- var scriptArgs = rawArgs.slice(rawArgs.indexOf(args.name) + 1);
371
- await runScript(scriptPath, scriptArgs);
372
- }
373
- }), scriptCommand = (0, import_citty.defineCommand)({
374
- meta: {
375
- name: "script",
376
- description: "Hybrid script runner with filesystem discovery"
377
- },
378
- args: {
379
- name: {
380
- type: "positional",
381
- description: "Script name or category to run/list",
382
- required: !1
383
- }
384
- },
385
- subCommands: {
386
- new: newCommand,
387
- run: runSubCommand,
388
- eject: ejectCommand
389
- },
390
- async run(param) {
391
- var { args, rawArgs } = param, scriptName = args.name || rawArgs[1];
392
- if (!scriptName) {
393
- (0, import_script_listing.listAllScripts)(!1);
394
- return;
395
- }
396
- if (!(0, import_script_listing.listCategoryScripts)(scriptName)) {
397
- var scriptPath = findScript(scriptName);
398
- 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));
399
- var scriptArgs = rawArgs.slice(rawArgs.indexOf(scriptName) + 1);
399
+ }),
400
+ runSubCommand = (0, import_citty.defineCommand)({
401
+ meta: {
402
+ name: "run",
403
+ description: "Run a script (for backwards compatibility)"
404
+ },
405
+ args: {
406
+ name: {
407
+ type: "positional",
408
+ description: "Script name",
409
+ required: !0
410
+ }
411
+ },
412
+ async run(param) {
413
+ var {
414
+ args,
415
+ rawArgs
416
+ } = param,
417
+ scriptPath = findScript(args.name);
418
+ 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));
419
+ var scriptArgs = rawArgs.slice(rawArgs.indexOf(args.name) + 1);
400
420
  await runScript(scriptPath, scriptArgs);
401
421
  }
402
- }
403
- });
422
+ }),
423
+ scriptCommand = (0, import_citty.defineCommand)({
424
+ meta: {
425
+ name: "script",
426
+ description: "Hybrid script runner with filesystem discovery"
427
+ },
428
+ args: {
429
+ name: {
430
+ type: "positional",
431
+ description: "Script name or category to run/list",
432
+ required: !1
433
+ }
434
+ },
435
+ subCommands: {
436
+ new: newCommand,
437
+ run: runSubCommand,
438
+ eject: ejectCommand
439
+ },
440
+ async run(param) {
441
+ var {
442
+ args,
443
+ rawArgs
444
+ } = param,
445
+ scriptName = args.name || rawArgs[1];
446
+ if (!scriptName) {
447
+ (0, import_script_listing.listAllScripts)(!1);
448
+ return;
449
+ }
450
+ if (!(0, import_script_listing.listCategoryScripts)(scriptName)) {
451
+ var scriptPath = findScript(scriptName);
452
+ 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));
453
+ var scriptArgs = rawArgs.slice(rawArgs.indexOf(scriptName) + 1);
454
+ await runScript(scriptPath, scriptArgs);
455
+ }
456
+ }
457
+ });
404
458
  function createShorthandCommand(name) {
405
459
  return (0, import_citty.defineCommand)({
406
460
  meta: {
@@ -415,35 +469,23 @@ function createShorthandCommand(name) {
415
469
  }
416
470
  },
417
471
  async run(param) {
418
- var { rawArgs } = param, scriptName = rawArgs.length > 0 ? `${name}/${rawArgs[0]}` : name, scriptArgs = rawArgs.length > 0 ? [
419
- "script",
420
- scriptName,
421
- ...rawArgs.slice(1)
422
- ] : [
423
- "script",
424
- name
425
- ], { run } = scriptCommand;
426
- run && await run({
472
+ var {
473
+ rawArgs
474
+ } = param,
475
+ scriptName = rawArgs.length > 0 ? `${name}/${rawArgs[0]}` : name,
476
+ scriptArgs = rawArgs.length > 0 ? ["script", scriptName, ...rawArgs.slice(1)] : ["script", name],
477
+ {
478
+ run
479
+ } = scriptCommand;
480
+ run && (await run({
427
481
  args: {
428
482
  name: scriptName,
429
483
  _: rawArgs.slice(1)
430
484
  },
431
485
  rawArgs: scriptArgs,
432
486
  cmd: scriptCommand
433
- });
487
+ }));
434
488
  }
435
489
  });
436
490
  }
437
- // Annotate the CommonJS export names for ESM import in node:
438
- 0 && (module.exports = {
439
- createShorthandCommand,
440
- discoverScripts,
441
- findScript,
442
- formatScriptList,
443
- getLocalScriptsDir,
444
- getScriptMetadata,
445
- listAllScripts,
446
- listCategoryScripts,
447
- scriptCommand
448
- });
449
- //# sourceMappingURL=script.js.map
491
+ //# sourceMappingURL=script.native.js.map