@take-out/cli 0.0.42 → 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.
- package/dist/cjs/cli.native.js +28 -35
- package/dist/cjs/cli.native.js.map +1 -6
- package/dist/cjs/commands/changed.cjs +1 -1
- package/dist/cjs/commands/changed.js +1 -1
- package/dist/cjs/commands/changed.native.js +132 -111
- package/dist/cjs/commands/changed.native.js.map +1 -6
- package/dist/cjs/commands/docs.native.js +405 -326
- package/dist/cjs/commands/docs.native.js.map +1 -6
- package/dist/cjs/commands/env-setup.native.js +75 -64
- package/dist/cjs/commands/env-setup.native.js.map +1 -6
- package/dist/cjs/commands/onboard.native.js +206 -193
- package/dist/cjs/commands/onboard.native.js.map +1 -6
- package/dist/cjs/commands/run.cjs +18 -17
- package/dist/cjs/commands/run.js +8 -11
- package/dist/cjs/commands/run.js.map +2 -2
- package/dist/cjs/commands/run.native.js +139 -108
- package/dist/cjs/commands/run.native.js.map +1 -6
- package/dist/cjs/commands/script.native.js +269 -227
- package/dist/cjs/commands/script.native.js.map +1 -6
- package/dist/cjs/commands/sync.cjs +1 -1
- package/dist/cjs/commands/sync.js +1 -1
- package/dist/cjs/commands/sync.native.js +58 -58
- package/dist/cjs/commands/sync.native.js.map +1 -6
- package/dist/cjs/constants/ascii.native.js +19 -16
- package/dist/cjs/constants/ascii.native.js.map +1 -6
- package/dist/cjs/index.native.js +22 -49
- package/dist/cjs/index.native.js.map +1 -6
- package/dist/cjs/types.native.js +9 -5
- package/dist/cjs/types.native.js.map +1 -6
- package/dist/cjs/utils/env-categories.native.js +181 -210
- package/dist/cjs/utils/env-categories.native.js.map +1 -6
- package/dist/cjs/utils/env-setup.native.js +104 -87
- package/dist/cjs/utils/env-setup.native.js.map +1 -6
- package/dist/cjs/utils/env.native.js +48 -46
- package/dist/cjs/utils/env.native.js.map +1 -6
- package/dist/cjs/utils/files.native.js +123 -111
- package/dist/cjs/utils/files.native.js.map +1 -6
- package/dist/cjs/utils/parallel-runner.cjs +9 -3
- package/dist/cjs/utils/parallel-runner.js +8 -3
- package/dist/cjs/utils/parallel-runner.js.map +1 -1
- package/dist/cjs/utils/parallel-runner.native.js +79 -58
- package/dist/cjs/utils/parallel-runner.native.js.map +1 -6
- package/dist/cjs/utils/ports.native.js +37 -44
- package/dist/cjs/utils/ports.native.js.map +1 -6
- package/dist/cjs/utils/prerequisites.native.js +38 -37
- package/dist/cjs/utils/prerequisites.native.js.map +1 -6
- package/dist/cjs/utils/prompts.native.js +60 -72
- package/dist/cjs/utils/prompts.native.js.map +1 -6
- package/dist/cjs/utils/script-listing.native.js +73 -56
- package/dist/cjs/utils/script-listing.native.js.map +1 -6
- package/dist/cjs/utils/sync.native.js +39 -30
- package/dist/cjs/utils/sync.native.js.map +1 -6
- package/dist/esm/commands/changed.js +1 -1
- package/dist/esm/commands/changed.mjs +1 -1
- package/dist/esm/commands/changed.native.js +1 -1
- package/dist/esm/commands/run.js +8 -11
- package/dist/esm/commands/run.js.map +2 -2
- package/dist/esm/commands/run.mjs +18 -17
- package/dist/esm/commands/run.mjs.map +1 -1
- package/dist/esm/commands/run.native.js +12 -9
- package/dist/esm/commands/run.native.js.map +1 -1
- package/dist/esm/commands/sync.js +1 -1
- package/dist/esm/commands/sync.mjs +1 -1
- package/dist/esm/commands/sync.native.js +1 -1
- package/dist/esm/utils/parallel-runner.js +8 -3
- package/dist/esm/utils/parallel-runner.js.map +1 -1
- package/dist/esm/utils/parallel-runner.mjs +9 -3
- package/dist/esm/utils/parallel-runner.mjs.map +1 -1
- package/dist/esm/utils/parallel-runner.native.js +12 -3
- package/dist/esm/utils/parallel-runner.native.js.map +1 -1
- package/package.json +4 -4
- package/src/commands/changed.ts +1 -1
- package/src/commands/run.ts +6 -10
- package/src/commands/sync.ts +1 -1
- package/src/utils/parallel-runner.ts +34 -9
- package/types/commands/run.d.ts.map +1 -1
- package/types/utils/parallel-runner.d.ts.map +1 -1
|
@@ -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,
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
8
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
9
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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", {
|
|
22
|
-
|
|
23
|
-
|
|
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"),
|
|
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"),
|
|
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"),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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"),
|
|
55
|
-
|
|
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,
|
|
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
|
-
|
|
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(),
|
|
99
|
-
|
|
100
|
-
|
|
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,
|
|
106
|
-
|
|
107
|
-
|
|
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),
|
|
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,
|
|
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
|
-
|
|
116
|
-
|
|
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("/"),
|
|
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
|
-
|
|
154
|
-
|
|
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
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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 {
|
|
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 {
|
|
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,
|
|
243
|
-
|
|
244
|
-
|
|
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),
|
|
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,
|
|
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
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
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
|
-
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
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
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
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
|
-
|
|
344
|
-
|
|
345
|
-
|
|
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
|
-
|
|
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
|
-
|
|
350
|
-
|
|
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
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
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 {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
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
|
-
|
|
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
|