@foxford/cli 1.0.0-beta-6f7848f0-20250318 → 1.1.0-beta-cf9c517f-20250513
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/README.mdx +56 -1
- package/fox.d.ts +1031 -0
- package/fox.js +681 -643
- package/fox.js.map +1 -1
- package/package.json +6 -3
package/fox.js
CHANGED
|
@@ -2,27 +2,10 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
|
-
var __defProps = Object.defineProperties;
|
|
6
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
8
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
10
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
11
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
13
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
14
|
-
var __spreadValues = (a, b) => {
|
|
15
|
-
for (var prop in b || (b = {}))
|
|
16
|
-
if (__hasOwnProp.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
if (__getOwnPropSymbols)
|
|
19
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
20
|
-
if (__propIsEnum.call(b, prop))
|
|
21
|
-
__defNormalProp(a, prop, b[prop]);
|
|
22
|
-
}
|
|
23
|
-
return a;
|
|
24
|
-
};
|
|
25
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
26
9
|
var __esm = (fn, res) => function __init() {
|
|
27
10
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
28
11
|
};
|
|
@@ -46,26 +29,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
46
29
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
47
30
|
mod
|
|
48
31
|
));
|
|
49
|
-
var __async = (__this, __arguments, generator) => {
|
|
50
|
-
return new Promise((resolve, reject) => {
|
|
51
|
-
var fulfilled = (value) => {
|
|
52
|
-
try {
|
|
53
|
-
step(generator.next(value));
|
|
54
|
-
} catch (e) {
|
|
55
|
-
reject(e);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
var rejected = (value) => {
|
|
59
|
-
try {
|
|
60
|
-
step(generator.throw(value));
|
|
61
|
-
} catch (e) {
|
|
62
|
-
reject(e);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
66
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
32
|
|
|
70
33
|
// src/logger/index.ts
|
|
71
34
|
var import_logger, logger;
|
|
@@ -121,37 +84,34 @@ var init_ffmpeg_runner = __esm({
|
|
|
121
84
|
import_fluent_ffmpeg = __toESM(require("fluent-ffmpeg"));
|
|
122
85
|
FFMpegRunner = class {
|
|
123
86
|
constructor(options) {
|
|
124
|
-
this.options = options
|
|
125
|
-
}
|
|
126
|
-
run(payload) {
|
|
127
|
-
return
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
reject(err);
|
|
153
|
-
}).run();
|
|
154
|
-
});
|
|
87
|
+
this.options = options ?? {};
|
|
88
|
+
}
|
|
89
|
+
async run(payload) {
|
|
90
|
+
return new Promise((resolve, reject) => {
|
|
91
|
+
(0, import_fluent_ffmpeg.default)(payload.resource).output(payload.output ?? import_node_path.default.basename(payload.resource)).outputOptions([
|
|
92
|
+
"-hide_banner",
|
|
93
|
+
"-movflags +faststart",
|
|
94
|
+
"-pix_fmt yuv420p",
|
|
95
|
+
"-c:v libx264",
|
|
96
|
+
"-preset:v veryslow",
|
|
97
|
+
"-profile:v high",
|
|
98
|
+
"-level 3.1",
|
|
99
|
+
"-tune:v ssim",
|
|
100
|
+
"-r 30",
|
|
101
|
+
"-g 180",
|
|
102
|
+
"-keyint_min 180",
|
|
103
|
+
"-sc_threshold 0",
|
|
104
|
+
"-max_muxing_queue_size 1024",
|
|
105
|
+
// '-vf scale=1920:-1',
|
|
106
|
+
"-f mp4",
|
|
107
|
+
...payload.extraFlags ?? []
|
|
108
|
+
]).on("end", function() {
|
|
109
|
+
resolve(payload.resource);
|
|
110
|
+
}).on("error", function(err) {
|
|
111
|
+
console.log();
|
|
112
|
+
console.log(import_chalk.default.redBright("Cannot process video: " + err.message));
|
|
113
|
+
reject(err);
|
|
114
|
+
}).run();
|
|
155
115
|
});
|
|
156
116
|
}
|
|
157
117
|
};
|
|
@@ -168,29 +128,28 @@ var init_shell_runner = __esm({
|
|
|
168
128
|
ShellRunner = class {
|
|
169
129
|
constructor(binary, options) {
|
|
170
130
|
this.binary = binary;
|
|
171
|
-
this.options = options
|
|
172
|
-
}
|
|
173
|
-
run(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
131
|
+
this.options = options ?? { cwd: process.cwd() };
|
|
132
|
+
}
|
|
133
|
+
async run(command, args = [], options = {}, collect = false) {
|
|
134
|
+
const spawnOptions = {
|
|
135
|
+
cwd: this.options.cwd,
|
|
136
|
+
stdio: collect ? "pipe" : "inherit",
|
|
137
|
+
shell: true,
|
|
138
|
+
...options
|
|
139
|
+
};
|
|
140
|
+
return new Promise((resolve, reject) => {
|
|
141
|
+
const child = (0, import_child_process.spawn)(`${this.binary}`, [command, ...args], spawnOptions);
|
|
142
|
+
if (collect && child.stdout) {
|
|
143
|
+
child.stdout.on("data", (data) => resolve(data.toString().replace(/\r\n|\n/, "")));
|
|
144
|
+
}
|
|
145
|
+
child.on("close", (code) => {
|
|
146
|
+
if (code === 0) {
|
|
147
|
+
resolve(child.stdout);
|
|
148
|
+
} else {
|
|
149
|
+
console.error(import_chalk2.default.red(`
|
|
190
150
|
\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u044C \u043A\u043E\u043C\u0430\u043D\u0434\u0443: ${this.binary} ${command} ${args} `));
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
});
|
|
151
|
+
reject(code);
|
|
152
|
+
}
|
|
194
153
|
});
|
|
195
154
|
});
|
|
196
155
|
}
|
|
@@ -315,38 +274,36 @@ var init_script_runner = __esm({
|
|
|
315
274
|
};
|
|
316
275
|
ScriptRunner = class {
|
|
317
276
|
constructor(options) {
|
|
318
|
-
this.options = options
|
|
319
|
-
}
|
|
320
|
-
run(
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
process.exit(1);
|
|
343
|
-
}
|
|
277
|
+
this.options = options ?? {};
|
|
278
|
+
}
|
|
279
|
+
async run(script, { pkg }) {
|
|
280
|
+
const label2 = getLabel(pkg.localName.toUpperCase());
|
|
281
|
+
const failLabel = getFailLabel(pkg.localName.toUpperCase());
|
|
282
|
+
console.log(label2 + import_chalk3.default.blue(`Start ${import_chalk3.default.white.underline(script)} process`));
|
|
283
|
+
if (this.options.verbose) {
|
|
284
|
+
console.log(label2 + import_chalk3.default.blue(`Print typescript config`));
|
|
285
|
+
console.log();
|
|
286
|
+
}
|
|
287
|
+
console.log(
|
|
288
|
+
label2 + import_chalk3.default.blue(`Env ${import_chalk3.default.magenta("process.env.NODE_ENV")} is ${import_chalk3.default.yellow("production")}`)
|
|
289
|
+
);
|
|
290
|
+
console.log(
|
|
291
|
+
label2 + import_chalk3.default.blue(`Env ${import_chalk3.default.magenta("process.env.NODE_OPTIONS")} is ${import_chalk3.default.yellow(process.env.NODE_OPTIONS)}`)
|
|
292
|
+
);
|
|
293
|
+
try {
|
|
294
|
+
console.log(label2 + import_chalk3.default.blue(`Load .env files`));
|
|
295
|
+
const envFiles = loadEnv(pkg.path);
|
|
296
|
+
console.log(JSON.stringify(envFiles, null, 2));
|
|
297
|
+
} catch (err) {
|
|
298
|
+
if (err instanceof Error) {
|
|
299
|
+
console.log(failLabel + import_chalk3.default.red(err.message));
|
|
300
|
+
process.exit(1);
|
|
344
301
|
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
302
|
+
}
|
|
303
|
+
const pnpmRunner = new PnpmRunner();
|
|
304
|
+
pnpmRunner.run("run", [`--filter ${pkg.localName}`, script], {
|
|
305
|
+
env: Object.assign(process.env, { FORCE_COLOR: "1" }),
|
|
306
|
+
cwd: pkg.path
|
|
350
307
|
});
|
|
351
308
|
}
|
|
352
309
|
};
|
|
@@ -362,21 +319,18 @@ var init_tinypng_runner = __esm({
|
|
|
362
319
|
import_tinify = __toESM(require("tinify"));
|
|
363
320
|
TinyPngRunner = class {
|
|
364
321
|
constructor(options) {
|
|
365
|
-
this.options = options
|
|
366
|
-
if (!
|
|
367
|
-
}
|
|
368
|
-
run(payload) {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
}
|
|
378
|
-
return payload.resource;
|
|
379
|
-
});
|
|
322
|
+
this.options = options ?? {};
|
|
323
|
+
if (!options?.token) throw new Error("You must specify process.env.TINIFY_API_KEY env variable with tinify key");
|
|
324
|
+
}
|
|
325
|
+
async run(payload) {
|
|
326
|
+
const source = import_tinify.default.fromFile(payload.resource);
|
|
327
|
+
import_tinify.default.key = this.options?.token ?? "";
|
|
328
|
+
try {
|
|
329
|
+
await source.toFile(payload.output ?? payload.resource);
|
|
330
|
+
} catch (err) {
|
|
331
|
+
if (err instanceof Error) console.log(import_chalk4.default.redBright("Cannot compress resource with tinify: " + err.message));
|
|
332
|
+
}
|
|
333
|
+
return payload.resource;
|
|
380
334
|
}
|
|
381
335
|
runSync() {
|
|
382
336
|
throw new TypeError("this method not implemented");
|
|
@@ -438,10 +392,12 @@ var init_program = __esm({
|
|
|
438
392
|
import_fs_extra2 = require("fs-extra");
|
|
439
393
|
import_zx = require("zx");
|
|
440
394
|
init_runners();
|
|
395
|
+
init_logger();
|
|
441
396
|
Program = class extends import_commander.Command {
|
|
442
397
|
constructor() {
|
|
443
398
|
super();
|
|
444
399
|
this.rootPath = process.cwd();
|
|
400
|
+
this.logger = logger;
|
|
445
401
|
this.commandList = [];
|
|
446
402
|
import_zx.$.verbose = false;
|
|
447
403
|
const dotenvFiles = [
|
|
@@ -459,18 +415,68 @@ var init_program = __esm({
|
|
|
459
415
|
});
|
|
460
416
|
this.determineRootPath().then((path10) => this.rootPath = path10);
|
|
461
417
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
418
|
+
async getPluginPaths() {
|
|
419
|
+
const nodeModulesPlugins = [];
|
|
420
|
+
const readPkgUp = await import("read-package-up");
|
|
421
|
+
const result = await readPkgUp.readPackageUp({ cwd: this.rootPath });
|
|
422
|
+
if (!result) {
|
|
423
|
+
throw new Error("Unable to find package.json");
|
|
424
|
+
}
|
|
425
|
+
const { packageJson } = result;
|
|
426
|
+
const dependencies = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
427
|
+
for (const [name] of Object.entries(dependencies)) {
|
|
428
|
+
if (this.shouldSkipPackage(name)) continue;
|
|
429
|
+
if (name === packageJson.name) continue;
|
|
430
|
+
let packageDir = null;
|
|
431
|
+
try {
|
|
432
|
+
const packagePath = require.resolve(name, { paths: [this.rootPath] });
|
|
433
|
+
packageDir = import_node_path3.default.dirname(packagePath);
|
|
434
|
+
} catch {
|
|
472
435
|
}
|
|
473
|
-
|
|
436
|
+
if (!packageDir) {
|
|
437
|
+
try {
|
|
438
|
+
packageDir = import_node_path3.default.join(this.rootPath, "node_modules", name);
|
|
439
|
+
if (!await import_zx.fs.pathExists(packageDir)) {
|
|
440
|
+
logger.debug(`Package directory not found for ${name}`);
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
} catch (error) {
|
|
444
|
+
logger.debug(`Error finding package directory for ${name}:`, error);
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
try {
|
|
449
|
+
const result2 = await readPkgUp.readPackageUp({ cwd: packageDir });
|
|
450
|
+
if (!result2) {
|
|
451
|
+
logger.debug(`Unable to find package.json for ${name}`);
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
const { packageJson: packageJson2, path: packageJsonPath } = result2;
|
|
455
|
+
if (packageJson2.keywords && packageJson2.keywords.includes("foxford-cli-plugin")) {
|
|
456
|
+
nodeModulesPlugins.push({
|
|
457
|
+
path: packageJsonPath,
|
|
458
|
+
pkgJson: packageJson2
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
} catch (error) {
|
|
462
|
+
logger.debug(`Error reading package.json for ${name}:`, error);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
return nodeModulesPlugins;
|
|
466
|
+
}
|
|
467
|
+
shouldSkipPackage(name) {
|
|
468
|
+
return name.startsWith("@types/") || name.startsWith("@foxford/types") || name === "@foxford/cli" || name === "typescript" || name.includes("eslint") || name.includes("@babel") || name.includes("react");
|
|
469
|
+
}
|
|
470
|
+
async determineRootPath() {
|
|
471
|
+
const packageManager = await (0, import_detect_package_manager.detect)();
|
|
472
|
+
switch (packageManager) {
|
|
473
|
+
case "npm":
|
|
474
|
+
return import_node_path3.default.dirname(RunnerFactory.create("NPM" /* NPM */).runSync("root"));
|
|
475
|
+
case "pnpm":
|
|
476
|
+
return import_node_path3.default.dirname(RunnerFactory.create("PNPM" /* PNPM */).runSync("root"));
|
|
477
|
+
default:
|
|
478
|
+
return process.cwd();
|
|
479
|
+
}
|
|
474
480
|
}
|
|
475
481
|
defineCommand(command) {
|
|
476
482
|
this.commandList.push(command);
|
|
@@ -527,20 +533,6 @@ var init_ui = __esm({
|
|
|
527
533
|
}
|
|
528
534
|
});
|
|
529
535
|
|
|
530
|
-
// src/processes/codegen/index.ts
|
|
531
|
-
var codegen_exports = {};
|
|
532
|
-
__export(codegen_exports, {
|
|
533
|
-
default: () => codegen_default
|
|
534
|
-
});
|
|
535
|
-
var codegen_default;
|
|
536
|
-
var init_codegen = __esm({
|
|
537
|
-
"src/processes/codegen/index.ts"() {
|
|
538
|
-
"use strict";
|
|
539
|
-
codegen_default = (_program) => {
|
|
540
|
-
};
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
|
|
544
536
|
// src/processes/codemod/action.ts
|
|
545
537
|
var CodemodAction;
|
|
546
538
|
var init_action = __esm({
|
|
@@ -549,22 +541,20 @@ var init_action = __esm({
|
|
|
549
541
|
init_runners();
|
|
550
542
|
init_program2();
|
|
551
543
|
CodemodAction = class extends AbstractAction {
|
|
552
|
-
handle(options) {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
verbose: options.verbose
|
|
562
|
-
});
|
|
563
|
-
runner.run("", [], {
|
|
564
|
-
cwd: process.cwd()
|
|
565
|
-
});
|
|
566
|
-
return;
|
|
544
|
+
async handle(options) {
|
|
545
|
+
const flags = [];
|
|
546
|
+
if (options.dry) flags.push("--dry");
|
|
547
|
+
if (options.verbose) flags.push("--verbose");
|
|
548
|
+
console.log("options", options);
|
|
549
|
+
console.log("flags", flags);
|
|
550
|
+
console.log("extra", options.extra);
|
|
551
|
+
const runner = RunnerFactory.create("NODE" /* NODE */, {
|
|
552
|
+
verbose: options.verbose
|
|
567
553
|
});
|
|
554
|
+
runner.run("", [], {
|
|
555
|
+
cwd: process.cwd()
|
|
556
|
+
});
|
|
557
|
+
return;
|
|
568
558
|
}
|
|
569
559
|
};
|
|
570
560
|
}
|
|
@@ -586,10 +576,8 @@ var init_abstract_collection = __esm({
|
|
|
586
576
|
constructor(collection) {
|
|
587
577
|
this.collection = collection;
|
|
588
578
|
}
|
|
589
|
-
execute(_name, _inputs, _extraFlags, _cwd) {
|
|
590
|
-
return
|
|
591
|
-
return;
|
|
592
|
-
});
|
|
579
|
+
async execute(_name, _inputs, _extraFlags, _cwd) {
|
|
580
|
+
return;
|
|
593
581
|
}
|
|
594
582
|
};
|
|
595
583
|
}
|
|
@@ -620,7 +608,6 @@ var init_fox_codemod_collection = __esm({
|
|
|
620
608
|
init_formatting();
|
|
621
609
|
FoxCodemodCollection = class extends AbstractCollection {
|
|
622
610
|
constructor() {
|
|
623
|
-
var _a;
|
|
624
611
|
super("@foxford/codemods" /* FOX_CODEMODS */);
|
|
625
612
|
this.codemods = [];
|
|
626
613
|
const pathCollection = require.resolve("@foxford/codemods" /* FOX_CODEMODS */);
|
|
@@ -631,7 +618,7 @@ var init_fox_codemod_collection = __esm({
|
|
|
631
618
|
);
|
|
632
619
|
process.exit(1);
|
|
633
620
|
}
|
|
634
|
-
const collectionPath = import_node_path4.default.join(import_node_path4.default.dirname(pathCollection),
|
|
621
|
+
const collectionPath = import_node_path4.default.join(import_node_path4.default.dirname(pathCollection), pkgJson.codemods ?? "");
|
|
635
622
|
if (!import_fs_extra3.default.existsSync(collectionPath)) {
|
|
636
623
|
console.log(
|
|
637
624
|
import_chalk6.default.red('Collection path specified in "codemods" section in your package.json is not valid: ', collectionPath)
|
|
@@ -639,10 +626,11 @@ var init_fox_codemod_collection = __esm({
|
|
|
639
626
|
}
|
|
640
627
|
try {
|
|
641
628
|
const collectionJson = require(collectionPath);
|
|
642
|
-
this.codemods = collectionJson.codemods.map((codemod) =>
|
|
629
|
+
this.codemods = collectionJson.codemods.map((codemod) => ({
|
|
630
|
+
...codemod,
|
|
643
631
|
name: normalizeToKebabOrSnakeCase(codemod.name)
|
|
644
632
|
}));
|
|
645
|
-
} catch
|
|
633
|
+
} catch {
|
|
646
634
|
console.log(import_chalk6.default.red("Collection json is not valid"));
|
|
647
635
|
}
|
|
648
636
|
}
|
|
@@ -701,61 +689,56 @@ var init_command = __esm({
|
|
|
701
689
|
const verbose = new import_commander2.Option("--verbose", "\u0412\u044B\u0432\u043E\u0434 \u0434\u0430\u043D\u043D\u044B\u0445");
|
|
702
690
|
const dry = new import_commander2.Option("--dry", "\u041F\u0440\u043E\u0433\u043E\u043D \u0431\u0435\u0437 \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0439");
|
|
703
691
|
const run = new import_commander2.Command("run");
|
|
704
|
-
run.description("\u0417\u0430\u043F\u0443\u0441\u0438\u0442\u044C \u043A\u043E\u0434\u043C\u043E\u0434 \u0441 \u0438\u043C\u0435\u043D\u0435\u043C <name>").argument("<name>", "\u0418\u043C\u044F \u043A\u043E\u0434\u043C\u043E\u0434\u0430 (codemod --list)").argument("<input...>", "Glob \u043F\u0430\u0442\u0442\u0435\u0440\u043D \u0444\u0430\u0439\u043B\u043E\u0432 \u0434\u043B\u044F \u043A\u043E\u0442\u043E\u0440\u044B\u0445 \u0431\u0443\u0434\u0435\u0442 \u043F\u0440\u0438\u043C\u0435\u043D\u0438\u043C \u043A\u043E\u0434\u043C\u043E\u0434").addOption(verbose).addOption(dry).allowUnknownOption(true).showHelpAfterError().action((name, input, options, command) =>
|
|
705
|
-
var _a, _b;
|
|
692
|
+
run.description("\u0417\u0430\u043F\u0443\u0441\u0438\u0442\u044C \u043A\u043E\u0434\u043C\u043E\u0434 \u0441 \u0438\u043C\u0435\u043D\u0435\u043C <name>").argument("<name>", "\u0418\u043C\u044F \u043A\u043E\u0434\u043C\u043E\u0434\u0430 (codemod --list)").argument("<input...>", "Glob \u043F\u0430\u0442\u0442\u0435\u0440\u043D \u0444\u0430\u0439\u043B\u043E\u0432 \u0434\u043B\u044F \u043A\u043E\u0442\u043E\u0440\u044B\u0445 \u0431\u0443\u0434\u0435\u0442 \u043F\u0440\u0438\u043C\u0435\u043D\u0438\u043C \u043A\u043E\u0434\u043C\u043E\u0434").addOption(verbose).addOption(dry).allowUnknownOption(true).showHelpAfterError().action(async (name, input, options, command) => {
|
|
706
693
|
if (!this.items.filter((item) => item.name === name)) {
|
|
707
694
|
console.error("Name not found");
|
|
708
695
|
return;
|
|
709
696
|
}
|
|
710
|
-
const unknownOptions =
|
|
697
|
+
const unknownOptions = command.parseOptions(command.args)?.unknown ?? [];
|
|
711
698
|
const paths = input.filter((item) => !unknownOptions.includes(item));
|
|
712
699
|
if (unknownOptions.length) {
|
|
713
700
|
options.extra = unknownOptions;
|
|
714
701
|
}
|
|
715
702
|
options.paths = paths;
|
|
716
|
-
|
|
717
|
-
})
|
|
703
|
+
await this.action.handle(options);
|
|
704
|
+
});
|
|
718
705
|
return run;
|
|
719
706
|
}
|
|
720
707
|
buildListCommand() {
|
|
721
708
|
const run = new import_commander2.Command("list");
|
|
722
|
-
run.description("\u0412\u044B\u0432\u0435\u0441\u0442\u0438 \u043F\u043E\u043B\u043D\u044B\u0439 \u0441\u043F\u0438\u0441\u043E\u043A \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B\u0445 \u043A\u043E\u0434\u043C\u043E\u0434\u043E\u0432").showHelpAfterError().action(() =>
|
|
723
|
-
const list =
|
|
709
|
+
run.description("\u0412\u044B\u0432\u0435\u0441\u0442\u0438 \u043F\u043E\u043B\u043D\u044B\u0439 \u0441\u043F\u0438\u0441\u043E\u043A \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B\u0445 \u043A\u043E\u0434\u043C\u043E\u0434\u043E\u0432").showHelpAfterError().action(async () => {
|
|
710
|
+
const list = await this.getCollectionItems();
|
|
724
711
|
console.log(
|
|
725
712
|
`\u0414\u043E\u0441\u0442\u0443\u043F\u043D\u044B\u0435 \u043A\u043E\u0434\u043C\u043E\u0434\u044B \u0438\u0437 ${import_chalk7.default.bold(this.getCollection())}:
|
|
726
713
|
` + this.buildSchematicsListAsTable(list)
|
|
727
714
|
);
|
|
728
|
-
})
|
|
715
|
+
});
|
|
729
716
|
return run;
|
|
730
717
|
}
|
|
731
|
-
getCollectionItems() {
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
return list;
|
|
736
|
-
});
|
|
718
|
+
async getCollectionItems() {
|
|
719
|
+
const list = await this.getItems(this.getCollection());
|
|
720
|
+
this.items = list;
|
|
721
|
+
return list;
|
|
737
722
|
}
|
|
738
|
-
load(program) {
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
`
|
|
723
|
+
async load(program) {
|
|
724
|
+
const codemod = new import_commander2.Command("codemod");
|
|
725
|
+
codemod.addHelpText(
|
|
726
|
+
"before",
|
|
727
|
+
`
|
|
744
728
|
---------------------------------------
|
|
745
729
|
${import_chalk7.default.greenBright(
|
|
746
|
-
|
|
747
|
-
|
|
730
|
+
"\u{1F6E0} Codemod manager"
|
|
731
|
+
)}
|
|
748
732
|
---------------------------------------
|
|
749
733
|
`
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
}));
|
|
757
|
-
program.addCommand(codemod);
|
|
734
|
+
).usage("<command>").helpOption(false).description(await this.buildDescription()).summary("\u0423\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u043A\u043E\u0434\u043C\u043E\u0434\u0430\u043C\u0438").addCommand(this.buildRunCommand()).addCommand(this.buildListCommand()).action(async (options) => {
|
|
735
|
+
if (!options || Object.keys(options).length === 0) {
|
|
736
|
+
codemod.outputHelp();
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
await this.action.handle(options);
|
|
758
740
|
});
|
|
741
|
+
program.addCommand(codemod);
|
|
759
742
|
}
|
|
760
743
|
buildSchematicsListAsTable(items) {
|
|
761
744
|
const leftMargin = " ";
|
|
@@ -780,22 +763,18 @@ ${import_chalk7.default.greenBright(
|
|
|
780
763
|
getCollection() {
|
|
781
764
|
return "@foxford/codemods" /* FOX_CODEMODS */;
|
|
782
765
|
}
|
|
783
|
-
getItems(collection) {
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
return this.items;
|
|
788
|
-
});
|
|
766
|
+
async getItems(collection) {
|
|
767
|
+
const abstractCollection = CollectionFactory.create(collection);
|
|
768
|
+
this.items = await abstractCollection.getItems();
|
|
769
|
+
return this.items;
|
|
789
770
|
}
|
|
790
|
-
buildDescription() {
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
return `\u0414\u043E\u0441\u0442\u0443\u043F\u043D\u044B\u0435 \u043A\u043E\u0434\u043C\u043E\u0434\u044B \u0438\u0437 ${import_chalk7.default.bold(this.getCollection())}:
|
|
771
|
+
async buildDescription() {
|
|
772
|
+
const list = await this.getCollectionItems();
|
|
773
|
+
const shortList = list.slice(0, 20);
|
|
774
|
+
return `\u0414\u043E\u0441\u0442\u0443\u043F\u043D\u044B\u0435 \u043A\u043E\u0434\u043C\u043E\u0434\u044B \u0438\u0437 ${import_chalk7.default.bold(this.getCollection())}:
|
|
795
775
|
` + this.buildSchematicsListAsTable(shortList) + import_chalk7.default.yellowBright(`
|
|
796
776
|
|
|
797
777
|
\u0427\u0442\u043E\u0431\u044B \u0443\u0432\u0438\u0434\u0435\u0442\u044C \u043F\u043E\u043B\u043D\u044B\u0439 \u0441\u043F\u0438\u0441\u043E\u043A \u043A\u043E\u0434\u043C\u043E\u0434\u043E\u0432 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 \u043A\u043E\u043C\u0430\u043D\u0434\u0443 `) + import_chalk7.default.greenBright(`codemod list`);
|
|
798
|
-
});
|
|
799
778
|
}
|
|
800
779
|
};
|
|
801
780
|
}
|
|
@@ -833,6 +812,25 @@ var init_abstract_provider = __esm({
|
|
|
833
812
|
this.buildDir = "./build";
|
|
834
813
|
this.packageJson = this.readPackageJson();
|
|
835
814
|
}
|
|
815
|
+
/**
|
|
816
|
+
* Генерирует строку версии пакета на основе цели и SHA коммита.
|
|
817
|
+
*
|
|
818
|
+
* @param target - Цель развертывания. Может быть 'beta' или 'latest'.
|
|
819
|
+
* Определяет, возвращать ли бета-версию или текущую версию пакета.
|
|
820
|
+
* @param sha - Короткий SHA коммита, используемый в строке бета-версии.
|
|
821
|
+
* @returns Строка, представляющая версию пакета.
|
|
822
|
+
* Для цели 'latest' возвращает текущую версию пакета.
|
|
823
|
+
* Для цели 'beta' возвращает строку версии в формате:
|
|
824
|
+
* "<текущая_версия>-beta-<sha>-<текущая_дата>"
|
|
825
|
+
*/
|
|
826
|
+
getBetaPackageVersion(sha) {
|
|
827
|
+
const now = /* @__PURE__ */ new Date();
|
|
828
|
+
const year = now.getFullYear();
|
|
829
|
+
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
830
|
+
const day = String(now.getDate()).padStart(2, "0");
|
|
831
|
+
const date = `${year}${month}${day}`;
|
|
832
|
+
return `${this.packageJson.version}-beta-${sha}-${date}`;
|
|
833
|
+
}
|
|
836
834
|
/**
|
|
837
835
|
* Читает и парсит файл package.json из текущей рабочей директории.
|
|
838
836
|
*
|
|
@@ -845,7 +843,6 @@ var init_abstract_provider = __esm({
|
|
|
845
843
|
*/
|
|
846
844
|
readPackageJson(rootPath = this.cwd) {
|
|
847
845
|
const packageJsonPath = import_zx2.path.resolve(rootPath, "package.json");
|
|
848
|
-
console.log(packageJsonPath);
|
|
849
846
|
if (!import_zx2.fs.existsSync(packageJsonPath)) {
|
|
850
847
|
throw new Error("package.json \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D \u0432 \u0442\u0435\u043A\u0443\u0449\u0435\u0439 \u0434\u0438\u0440\u0435\u043A\u0442\u043E\u0440\u0438\u0438");
|
|
851
848
|
}
|
|
@@ -918,34 +915,60 @@ var init_cdn = __esm({
|
|
|
918
915
|
*
|
|
919
916
|
* @throws Завершает процесс, если локальная директория не существует.
|
|
920
917
|
*/
|
|
921
|
-
deploy(params) {
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
918
|
+
async deploy(params) {
|
|
919
|
+
logger.info("\u041D\u0430\u0447\u0438\u043D\u0430\u0435\u043C \u043F\u0440\u043E\u0446\u0435\u0441\u0441 \u0434\u0435\u043F\u043B\u043E\u044F \u0432 CDN", params);
|
|
920
|
+
const { OS_USERNAME, OS_PASSWORD } = process.env;
|
|
921
|
+
if (!OS_USERNAME || !OS_PASSWORD) {
|
|
922
|
+
this.logger.warn("\u041D\u0435 \u0443\u043A\u0430\u0437\u0430\u043D\u044B \u043F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u044B\u0435 \u043E\u043A\u0440\u0443\u0436\u0435\u043D\u0438\u044F OS_USERNAME \u0438\u043B\u0438 OS_PASSWORD");
|
|
923
|
+
}
|
|
924
|
+
const localDir = import_zx3.path.join(process.cwd(), params.localDir ?? this.buildDir);
|
|
925
|
+
if (!import_zx3.fs.existsSync(localDir)) {
|
|
926
|
+
logger.error(`\u0414\u0438\u0440\u0435\u043A\u0442\u043E\u0440\u0438\u044F "${localDir}" \u043D\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442`);
|
|
927
|
+
process.exit(1);
|
|
928
|
+
}
|
|
929
|
+
this.packageJson = this.readPackageJson(localDir);
|
|
930
|
+
const bucket = params.bucket ?? process.env.BUCKET ?? "dist.ngcdn.ru";
|
|
931
|
+
const remoteDirs = [];
|
|
932
|
+
const packageName = params.packageName ?? this.packageJson.name;
|
|
933
|
+
logger.info("\u041F\u043E\u043B\u0443\u0447\u0430\u0435\u043C sha \u043A\u043E\u043C\u043C\u0438\u0442\u0430");
|
|
934
|
+
const commitSha = (await import_zx3.$`git rev-parse --short HEAD`).toString().replace("\n", "");
|
|
935
|
+
logger.info("\u041A\u043E\u043C\u043C\u0438\u0442:", commitSha);
|
|
936
|
+
const target = params.target ?? this.getTarget();
|
|
937
|
+
logger.info("\u0426\u0435\u043B\u0435\u0432\u0430\u044F \u0432\u0435\u0440\u0441\u0438\u044F:", target);
|
|
938
|
+
logger.info("\u0411\u0430\u043A\u0435\u0442:", bucket);
|
|
939
|
+
if (target === "beta") {
|
|
940
|
+
this.packageJson.version = this.packageJson.version.includes("beta") ? this.packageJson.version : this.getBetaPackageVersion(commitSha);
|
|
941
|
+
}
|
|
942
|
+
this.packageJson.sha = commitSha;
|
|
943
|
+
logger.info("\u0412\u0435\u0440\u0441\u0438\u044F \u043F\u0430\u043A\u0435\u0442\u0430:", this.packageJson.version);
|
|
944
|
+
if (this.packageJson.scripts && this.packageJson.scripts.postinstall) {
|
|
945
|
+
this.packageJson.scripts = {
|
|
946
|
+
postinstall: this.packageJson.scripts.postinstall
|
|
947
|
+
};
|
|
948
|
+
} else {
|
|
949
|
+
this.packageJson.scripts = {};
|
|
950
|
+
}
|
|
951
|
+
logger.info("\u041F\u0443\u0431\u043B\u0438\u043A\u0443\u0435\u043C\u044B\u0439 package.json", this.packageJson);
|
|
952
|
+
await import_zx3.fs.writeJson(import_zx3.path.resolve(localDir, "package.json"), this.packageJson, {
|
|
953
|
+
spaces: 2
|
|
948
954
|
});
|
|
955
|
+
remoteDirs.push(this.getRemoteDirByVersion(bucket, packageName));
|
|
956
|
+
remoteDirs.push(this.getRemoteDirByTarget(bucket, packageName, target));
|
|
957
|
+
logger.info("\u0423\u0434\u0430\u043B\u0435\u043D\u043D\u044B\u0435 \u0434\u0438\u0440\u0435\u043A\u0442\u043E\u0440\u0438\u0438:", remoteDirs);
|
|
958
|
+
await Promise.allSettled(
|
|
959
|
+
remoteDirs.map(async (remoteDir) => {
|
|
960
|
+
const href = `https://${remoteDir}`;
|
|
961
|
+
const files = this.packageJson.files ?? [];
|
|
962
|
+
const fileList = files.map((file) => href + file).join("\n ");
|
|
963
|
+
const rclone = `rclone copy ${localDir} myremote:${remoteDir} --progress --error-on-no-transfer`;
|
|
964
|
+
logger.info(`\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043C \u0432\u0435\u0440\u0441\u0438\u044E \u0432 ${remoteDir} \u0441 \u043A\u043E\u043C\u0430\u043D\u0434\u043E\u0439:
|
|
965
|
+
`, rclone);
|
|
966
|
+
await import_zx3.$`rclone copy ${localDir} myremote:${remoteDir} --progress --error-on-no-transfer ${params.dry ? "--dry-run" : ""}`;
|
|
967
|
+
logger.info(`\u041F\u0430\u043A\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043D. \u0420\u0435\u0441\u0443\u0440\u0441\u044B \u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B \u043F\u043E \u0430\u0434\u0440\u0435\u0441\u0443:
|
|
968
|
+
`, href);
|
|
969
|
+
logger.info(fileList);
|
|
970
|
+
})
|
|
971
|
+
);
|
|
949
972
|
}
|
|
950
973
|
};
|
|
951
974
|
}
|
|
@@ -976,11 +999,9 @@ var init_npm = __esm({
|
|
|
976
999
|
*
|
|
977
1000
|
* @returns Промис, который разрешается строкой сообщения об устаревании.
|
|
978
1001
|
*/
|
|
979
|
-
getDeprecationMessage() {
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
return `deprecated by ${commitSha}`;
|
|
983
|
-
});
|
|
1002
|
+
async getDeprecationMessage() {
|
|
1003
|
+
const commitSha = (await import_zx4.$`git rev-parse --short HEAD`).toString().trim();
|
|
1004
|
+
return `deprecated by ${commitSha}`;
|
|
984
1005
|
}
|
|
985
1006
|
/**
|
|
986
1007
|
* Создает или обновляет файл .npmrc с токеном аутентификации для реестра npm.
|
|
@@ -992,29 +1013,8 @@ var init_npm = __esm({
|
|
|
992
1013
|
* @returns Промис, который разрешается, когда файл .npmrc успешно обновлен.
|
|
993
1014
|
* @throws Выбрасывает ошибку, если операция с файлом не удалась или если NPM_TOKEN не установлен.
|
|
994
1015
|
*/
|
|
995
|
-
touchNpmrc() {
|
|
996
|
-
|
|
997
|
-
yield import_zx4.$`echo "//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}" >> .npmrc`;
|
|
998
|
-
});
|
|
999
|
-
}
|
|
1000
|
-
/**
|
|
1001
|
-
* Генерирует строку версии пакета на основе цели и SHA коммита.
|
|
1002
|
-
*
|
|
1003
|
-
* @param target - Цель развертывания. Может быть 'beta' или 'latest'.
|
|
1004
|
-
* Определяет, возвращать ли бета-версию или текущую версию пакета.
|
|
1005
|
-
* @param sha - Короткий SHA коммита, используемый в строке бета-версии.
|
|
1006
|
-
* @returns Строка, представляющая версию пакета.
|
|
1007
|
-
* Для цели 'latest' возвращает текущую версию пакета.
|
|
1008
|
-
* Для цели 'beta' возвращает строку версии в формате:
|
|
1009
|
-
* "<текущая_версия>-beta-<sha>-<текущая_дата>"
|
|
1010
|
-
*/
|
|
1011
|
-
getBetaPackageVersion(sha) {
|
|
1012
|
-
const now = /* @__PURE__ */ new Date();
|
|
1013
|
-
const year = now.getFullYear();
|
|
1014
|
-
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
1015
|
-
const day = String(now.getDate()).padStart(2, "0");
|
|
1016
|
-
const date = `${year}${month}${day}`;
|
|
1017
|
-
return `${this.packageJson.version}-beta-${sha}-${date}`;
|
|
1016
|
+
async touchNpmrc() {
|
|
1017
|
+
await import_zx4.$`echo "//registry.npmjs.org/:_authToken=${process.env.NPM_TOKEN}" >> .npmrc`;
|
|
1018
1018
|
}
|
|
1019
1019
|
/**
|
|
1020
1020
|
* Фильтрует устаревшие версии из заданного списка версий пакета.
|
|
@@ -1025,18 +1025,16 @@ var init_npm = __esm({
|
|
|
1025
1025
|
* @param versions - Массив строк версий для проверки на устаревание.
|
|
1026
1026
|
* @returns Промис, который разрешается в массив строк версий, которые не являются устаревшими.
|
|
1027
1027
|
*/
|
|
1028
|
-
getNotDeprecatedVersions(versions) {
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
notDeprecatedVersions.push(ver);
|
|
1036
|
-
}
|
|
1028
|
+
async getNotDeprecatedVersions(versions) {
|
|
1029
|
+
const notDeprecatedVersions = [];
|
|
1030
|
+
for (const ver of versions) {
|
|
1031
|
+
const cmd = ["npm", "view", `${this.packageJson.name}@${ver}`, "deprecated"];
|
|
1032
|
+
const result = await import_zx4.$`${cmd}`;
|
|
1033
|
+
if (!result.toString().trim().includes("deprecated by")) {
|
|
1034
|
+
notDeprecatedVersions.push(ver);
|
|
1037
1035
|
}
|
|
1038
|
-
|
|
1039
|
-
|
|
1036
|
+
}
|
|
1037
|
+
return notDeprecatedVersions;
|
|
1040
1038
|
}
|
|
1041
1039
|
/**
|
|
1042
1040
|
* Получает список всех версий текущего пакета из реестра npm.
|
|
@@ -1052,24 +1050,22 @@ var init_npm = __esm({
|
|
|
1052
1050
|
* @throws Записывает ошибку в консоль, если парсинг JSON не удался, но не
|
|
1053
1051
|
* выбрасывает исключение.
|
|
1054
1052
|
*/
|
|
1055
|
-
getVersionsList() {
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
return [parsed];
|
|
1067
|
-
}
|
|
1068
|
-
} catch (e) {
|
|
1069
|
-
logger.error("Error parsing versions list");
|
|
1070
|
-
return [];
|
|
1053
|
+
async getVersionsList() {
|
|
1054
|
+
logger.info("Getting versions list...");
|
|
1055
|
+
const outputProcess = await import_zx4.$`npm view ${this.packageJson.name} versions --json`;
|
|
1056
|
+
const versionsListPo = outputProcess.toString();
|
|
1057
|
+
logger.info("Versions list recieved", versionsListPo);
|
|
1058
|
+
try {
|
|
1059
|
+
const parsed = JSON.parse(versionsListPo);
|
|
1060
|
+
if (Array.isArray(parsed)) {
|
|
1061
|
+
return parsed;
|
|
1062
|
+
} else {
|
|
1063
|
+
return [parsed];
|
|
1071
1064
|
}
|
|
1072
|
-
}
|
|
1065
|
+
} catch {
|
|
1066
|
+
logger.error("Error parsing versions list");
|
|
1067
|
+
return [];
|
|
1068
|
+
}
|
|
1073
1069
|
}
|
|
1074
1070
|
/**
|
|
1075
1071
|
* Получает список бэта версий на текущую версию из списка всех версий.
|
|
@@ -1079,12 +1075,11 @@ var init_npm = __esm({
|
|
|
1079
1075
|
*/
|
|
1080
1076
|
getBetaVersions(currentVersion) {
|
|
1081
1077
|
return this.versionLists.filter((ver) => {
|
|
1082
|
-
var _a;
|
|
1083
1078
|
if (!ver.includes("beta")) return false;
|
|
1084
1079
|
if (ver === currentVersion) return false;
|
|
1085
1080
|
const semverFromVersion = currentVersion.match(/^[0-9]{1,9}.[0-9]{1,9}.[0-9]{1,9}/gi);
|
|
1086
1081
|
if (!semverFromVersion) return false;
|
|
1087
|
-
const matchedVersion =
|
|
1082
|
+
const matchedVersion = semverFromVersion[0] ?? null;
|
|
1088
1083
|
if (!matchedVersion) return false;
|
|
1089
1084
|
return ver.includes(matchedVersion);
|
|
1090
1085
|
});
|
|
@@ -1098,29 +1093,27 @@ var init_npm = __esm({
|
|
|
1098
1093
|
* @param currentVersion - Текущая версия пакета для сравнения при поиске похожих версий.
|
|
1099
1094
|
* @returns Промис, который разрешается, когда все похожие, не устаревшие версии были помечены как устаревшие или была попытка их пометить.
|
|
1100
1095
|
*/
|
|
1101
|
-
deprecatePrevBetaVersions(currentVersion) {
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
yield import_zx4.$`${cmd}`;
|
|
1117
|
-
}
|
|
1118
|
-
} catch (error) {
|
|
1119
|
-
logger.error(error);
|
|
1120
|
-
continue;
|
|
1096
|
+
async deprecatePrevBetaVersions(currentVersion) {
|
|
1097
|
+
logger.info("\u041E\u0442\u043C\u0435\u0447\u0430\u0435\u043C \u043F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0438\u0435 \u0431\u044D\u0442\u0430 \u0432\u0435\u0440\u0441\u0438\u0438 \u043A\u0430\u043A deprecated");
|
|
1098
|
+
this.versionLists = await this.getVersionsList();
|
|
1099
|
+
const betaVersions = this.getBetaVersions(currentVersion);
|
|
1100
|
+
logger.info("\u041D\u0430\u0439\u0434\u0435\u043D\u044B beta \u0432\u0435\u0440\u0441\u0438\u0438:", betaVersions);
|
|
1101
|
+
const notDeprecatedVersions = await this.getNotDeprecatedVersions(betaVersions);
|
|
1102
|
+
logger.info("Beta \u0432\u0435\u0440\u0441\u0438\u0438 \u0431\u0435\u0437 deprecated:", notDeprecatedVersions);
|
|
1103
|
+
const deprecationMessage = await this.getDeprecationMessage();
|
|
1104
|
+
for (const ver of notDeprecatedVersions) {
|
|
1105
|
+
await sleep(500);
|
|
1106
|
+
try {
|
|
1107
|
+
if (!this.dry) {
|
|
1108
|
+
const cmd = ["npm", "deprecate", `${this.packageJson.name}@${ver}`, deprecationMessage];
|
|
1109
|
+
logger.info("\u041F\u043E\u043C\u0435\u0447\u0430\u0435\u043C \u0432\u0435\u0440\u0441\u0438\u044E \u043A\u0430\u043A deprecated:", cmd);
|
|
1110
|
+
await import_zx4.$`${cmd}`;
|
|
1121
1111
|
}
|
|
1112
|
+
} catch (error) {
|
|
1113
|
+
logger.error(error);
|
|
1114
|
+
continue;
|
|
1122
1115
|
}
|
|
1123
|
-
}
|
|
1116
|
+
}
|
|
1124
1117
|
}
|
|
1125
1118
|
/**
|
|
1126
1119
|
* Удаляет бета-версии пакета, которые похожи на текущую версию.
|
|
@@ -1132,30 +1125,28 @@ var init_npm = __esm({
|
|
|
1132
1125
|
* @returns Промис, который разрешается, когда все бета-версии были удалены или была попытка их удалить.
|
|
1133
1126
|
* @throws Записывает ошибки в консоль, если удаление не удалось для какой-либо версии, но продолжает со следующей версией.
|
|
1134
1127
|
*/
|
|
1135
|
-
unpublishBetaVersions(currentVersion) {
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
continue;
|
|
1155
|
-
}
|
|
1156
|
-
yield sleep(500);
|
|
1128
|
+
async unpublishBetaVersions(currentVersion) {
|
|
1129
|
+
logger.info("\u0420\u0430\u0437\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u044B\u0432\u0430\u0435\u043C beta \u0432\u0435\u0440\u0441\u0438\u0438");
|
|
1130
|
+
this.versionLists = await this.getVersionsList();
|
|
1131
|
+
logger.info("\u0421\u043F\u0438\u0441\u043E\u043A \u0432\u0435\u0440\u0441\u0438\u0439: ", this.versionLists);
|
|
1132
|
+
const betaVersions = this.getBetaVersions(currentVersion);
|
|
1133
|
+
logger.info("\u0421\u043F\u0438\u0441\u043E\u043A \u0434\u043B\u044F \u0440\u0430\u0437\u043F\u0443\u0431\u043B\u0438\u043A\u0430\u0446\u0438\u0438 \u0438 \u0434\u0435\u043F\u0440\u0435\u043A\u0435\u0439\u0442\u0430: ", betaVersions);
|
|
1134
|
+
const deprecationMessage = await this.getDeprecationMessage();
|
|
1135
|
+
for (const ver of betaVersions) {
|
|
1136
|
+
if (!ver.includes("beta")) continue;
|
|
1137
|
+
try {
|
|
1138
|
+
const deprecate = ["npm", "deprecate", `${this.packageJson.name}@${ver}`, deprecationMessage];
|
|
1139
|
+
logger.info("\u041F\u043E\u043C\u0435\u0447\u0430\u0435\u043C \u0432\u0435\u0440\u0441\u0438\u044E \u043A\u0430\u043A deprecated:", deprecate);
|
|
1140
|
+
await import_zx4.$`${deprecate}`;
|
|
1141
|
+
const unpublish = ["npm", "unpublish", `${this.packageJson.name}@${ver}`, "--force", this.dry];
|
|
1142
|
+
logger.info("\u0420\u0430\u0437\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u044B\u0432\u0435\u043C \u0432\u0435\u0440\u0441\u0438\u044E:", unpublish);
|
|
1143
|
+
await import_zx4.$`${unpublish}`;
|
|
1144
|
+
} catch (error) {
|
|
1145
|
+
logger.error(error);
|
|
1146
|
+
continue;
|
|
1157
1147
|
}
|
|
1158
|
-
|
|
1148
|
+
await sleep(500);
|
|
1149
|
+
}
|
|
1159
1150
|
}
|
|
1160
1151
|
/**
|
|
1161
1152
|
* Разворачивает пакет в реестре npm.
|
|
@@ -1171,54 +1162,51 @@ var init_npm = __esm({
|
|
|
1171
1162
|
* @throws Завершает процесс, если директория сборки не найдена.
|
|
1172
1163
|
* @returns Промис, который разрешается, когда процесс развертывания завершен.
|
|
1173
1164
|
*/
|
|
1174
|
-
deploy(params) {
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
yield import_zx4.fs.writeJson("package.json", this.packageJson, {
|
|
1211
|
-
spaces: 2
|
|
1212
|
-
});
|
|
1213
|
-
const cmd = ["npm", "publish", "--access=public", `--tag=${target}`, this.dry];
|
|
1214
|
-
logger.info("Publish with args:", cmd);
|
|
1215
|
-
yield import_zx4.$`${cmd}`;
|
|
1216
|
-
if (target === "beta") {
|
|
1217
|
-
yield this.deprecatePrevBetaVersions(this.packageJson.version);
|
|
1218
|
-
} else {
|
|
1219
|
-
yield this.unpublishBetaVersions(this.packageJson.version);
|
|
1220
|
-
}
|
|
1165
|
+
async deploy(params) {
|
|
1166
|
+
logger.info("\u041D\u0430\u0447\u0438\u043D\u0430\u0435\u043C \u043F\u0440\u043E\u0446\u0435\u0441\u0441 \u0434\u0435\u043F\u043B\u043E\u044F \u0432 NPM", params);
|
|
1167
|
+
const localDir = import_zx4.path.join(process.cwd(), params.localDir ?? this.buildDir);
|
|
1168
|
+
if (!import_zx4.fs.existsSync(localDir)) {
|
|
1169
|
+
logger.error(`\u0414\u0438\u0440\u0435\u043A\u0442\u043E\u0440\u0438\u044F "${localDir}" \u043D\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442`);
|
|
1170
|
+
process.exit(1);
|
|
1171
|
+
}
|
|
1172
|
+
this.packageJson = this.readPackageJson(localDir);
|
|
1173
|
+
if (params.dry === true) this.dry = "--dry-run";
|
|
1174
|
+
logger.info("\u041C\u0435\u043D\u044F\u0435\u043C \u0434\u0438\u0440\u0435\u043A\u0442\u043E\u0440\u0438\u044E \u043D\u0430", localDir);
|
|
1175
|
+
(0, import_zx4.cd)(localDir);
|
|
1176
|
+
logger.info("\u041F\u043E\u043B\u0443\u0447\u0430\u0435\u043C sha \u043A\u043E\u043C\u043C\u0438\u0442\u0430");
|
|
1177
|
+
const commitSha = (await import_zx4.$`git rev-parse --short HEAD`).toString().replace("\n", "");
|
|
1178
|
+
logger.info("\u041A\u043E\u043C\u043C\u0438\u0442:", commitSha);
|
|
1179
|
+
const target = params.target ?? "beta";
|
|
1180
|
+
logger.info("\u0426\u0435\u043B\u0435\u0432\u0430\u044F \u0432\u0435\u0440\u0441\u0438\u044F:", target);
|
|
1181
|
+
await this.touchNpmrc();
|
|
1182
|
+
logger.info("\u0421\u043E\u0437\u0434\u0430\u0435\u043C .npmrc");
|
|
1183
|
+
if (target === "beta") {
|
|
1184
|
+
this.packageJson.version = this.packageJson.version.includes("beta") ? this.packageJson.version : this.getBetaPackageVersion(commitSha);
|
|
1185
|
+
}
|
|
1186
|
+
this.packageJson.sha = commitSha;
|
|
1187
|
+
logger.info("\u0412\u0435\u0440\u0441\u0438\u044F \u043F\u0430\u043A\u0435\u0442\u0430:", this.packageJson.version);
|
|
1188
|
+
if (this.packageJson.scripts && this.packageJson.scripts.postinstall) {
|
|
1189
|
+
this.packageJson.scripts = {
|
|
1190
|
+
postinstall: this.packageJson.scripts.postinstall
|
|
1191
|
+
};
|
|
1192
|
+
} else {
|
|
1193
|
+
this.packageJson.scripts = {};
|
|
1194
|
+
}
|
|
1195
|
+
if (this.packageJson.devDependencies) {
|
|
1196
|
+
delete this.packageJson.devDependencies;
|
|
1197
|
+
}
|
|
1198
|
+
logger.info("\u041F\u0443\u0431\u043B\u0438\u043A\u0443\u0435\u043C\u044B\u0439 package.json", this.packageJson);
|
|
1199
|
+
await import_zx4.fs.writeJson("package.json", this.packageJson, {
|
|
1200
|
+
spaces: 2
|
|
1221
1201
|
});
|
|
1202
|
+
const cmd = ["npm", "publish", "--access=public", `--tag=${target}`, this.dry];
|
|
1203
|
+
logger.info("\u041F\u0443\u0431\u043B\u0438\u043A\u0443\u0435\u043C \u0441 \u0430\u0440\u0433\u0443\u043C\u0435\u043D\u0442\u0430\u043C\u0438:", cmd);
|
|
1204
|
+
await import_zx4.$`${cmd}`;
|
|
1205
|
+
if (target === "beta") {
|
|
1206
|
+
await this.deprecatePrevBetaVersions(this.packageJson.version);
|
|
1207
|
+
} else {
|
|
1208
|
+
await this.unpublishBetaVersions(this.packageJson.version);
|
|
1209
|
+
}
|
|
1222
1210
|
}
|
|
1223
1211
|
};
|
|
1224
1212
|
}
|
|
@@ -1233,21 +1221,19 @@ var init_action2 = __esm({
|
|
|
1233
1221
|
init_cdn();
|
|
1234
1222
|
init_npm();
|
|
1235
1223
|
DeployAction = class extends AbstractAction {
|
|
1236
|
-
handle(params) {
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
yield provider.deploy(params);
|
|
1250
|
-
});
|
|
1224
|
+
async handle(params) {
|
|
1225
|
+
let provider;
|
|
1226
|
+
switch (params.provider) {
|
|
1227
|
+
case "npm":
|
|
1228
|
+
provider = new NpmDeploy();
|
|
1229
|
+
break;
|
|
1230
|
+
case "cdn":
|
|
1231
|
+
provider = new CdnDeploy();
|
|
1232
|
+
break;
|
|
1233
|
+
default:
|
|
1234
|
+
throw new Error(`Unsupported deploy provider: ${params.provider}`);
|
|
1235
|
+
}
|
|
1236
|
+
await provider.deploy(params);
|
|
1251
1237
|
}
|
|
1252
1238
|
};
|
|
1253
1239
|
}
|
|
@@ -1265,28 +1251,26 @@ var init_command2 = __esm({
|
|
|
1265
1251
|
super(...arguments);
|
|
1266
1252
|
this.id = "deploy";
|
|
1267
1253
|
}
|
|
1268
|
-
load(program) {
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
yield this.action.handle(__spreadProps(__spreadValues({}, params), { provider: "npm" }));
|
|
1282
|
-
}));
|
|
1283
|
-
npmCommand.addOption(targetOption);
|
|
1284
|
-
npmCommand.addOption(localDirOption);
|
|
1285
|
-
npmCommand.addOption(dryOption);
|
|
1286
|
-
deployCommand.addCommand(cdnCommand);
|
|
1287
|
-
deployCommand.addCommand(npmCommand);
|
|
1288
|
-
program.addCommand(deployCommand);
|
|
1254
|
+
async load(program) {
|
|
1255
|
+
const deployCommand = new import_commander3.Command("deploy").description("\u0417\u0430\u0434\u0435\u043F\u043B\u043E\u0438\u0442\u044C \u043F\u0430\u043A\u0435\u0442");
|
|
1256
|
+
const targetOption = new import_commander3.Option("--target <target>", "\u0420\u0435\u043B\u0438\u0437 beta \u0438\u043B\u0438 latest").choices(["beta", "latest"]).default("beta");
|
|
1257
|
+
const localDirOption = new import_commander3.Option("--localDir <path>", "\u0418\u0437 \u043A\u0430\u043A\u043E\u0439 \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u043E\u0439 \u0434\u0438\u0440\u0435\u043A\u0442\u043E\u0440\u0438\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u043C\u043E\u0435");
|
|
1258
|
+
const dryOption = new import_commander3.Option("--dry", "\u0417\u0430\u043F\u0443\u0441\u043A \u0431\u0435\u0437 \u0432\u044B\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u044F \u043E\u043F\u0435\u0440\u0430\u0446\u0438\u0438").default(false);
|
|
1259
|
+
const cdnCommand = new import_commander3.Command("cdn").description("\u0414\u0435\u043F\u043B\u043E\u0439 \u043F\u0430\u043A\u0435\u0442\u0430 \u0432 cdn").option("--bucket <name>", "\u0412 \u043A\u0430\u043A\u043E\u0439 \u0431\u0430\u043A\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u043F\u0430\u043A\u0435\u0442").option("--packageName <name>", "\u0418\u043C\u044F \u043F\u0430\u043A\u0435\u0442\u0430 \u0432\u043C\u0435\u0441\u0442\u043E packageJson.name").action(async (params) => {
|
|
1260
|
+
await this.action.handle({ ...params, provider: "cdn" });
|
|
1261
|
+
});
|
|
1262
|
+
cdnCommand.addOption(targetOption);
|
|
1263
|
+
cdnCommand.addOption(localDirOption);
|
|
1264
|
+
cdnCommand.addOption(dryOption);
|
|
1265
|
+
const npmCommand = new import_commander3.Command("npm").description("\u0414\u0435\u043F\u043B\u043E\u0439 \u043F\u0430\u043A\u0435\u0442\u0430 \u0432 npm").action(async (params) => {
|
|
1266
|
+
await this.action.handle({ ...params, provider: "npm" });
|
|
1289
1267
|
});
|
|
1268
|
+
npmCommand.addOption(targetOption);
|
|
1269
|
+
npmCommand.addOption(localDirOption);
|
|
1270
|
+
npmCommand.addOption(dryOption);
|
|
1271
|
+
deployCommand.addCommand(cdnCommand);
|
|
1272
|
+
deployCommand.addCommand(npmCommand);
|
|
1273
|
+
program.addCommand(deployCommand);
|
|
1290
1274
|
}
|
|
1291
1275
|
};
|
|
1292
1276
|
}
|
|
@@ -1323,37 +1307,33 @@ var init_action3 = __esm({
|
|
|
1323
1307
|
init_ui();
|
|
1324
1308
|
init_program2();
|
|
1325
1309
|
InfoAction = class extends AbstractAction {
|
|
1326
|
-
handle() {
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
yield this.displaySystemInformation();
|
|
1330
|
-
});
|
|
1310
|
+
async handle() {
|
|
1311
|
+
this.displayBanner();
|
|
1312
|
+
await this.displaySystemInformation();
|
|
1331
1313
|
}
|
|
1332
1314
|
displayBanner() {
|
|
1333
1315
|
console.info(import_chalk8.default.red(BANNER));
|
|
1334
1316
|
}
|
|
1335
|
-
displaySystemInformation() {
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
console.info("Memory Available:", import_chalk8.default.blue(`${(0, import_filesize.filesize)(mem.available)}`));
|
|
1356
|
-
});
|
|
1317
|
+
async displaySystemInformation() {
|
|
1318
|
+
console.info(import_chalk8.default.green("[System Information]"));
|
|
1319
|
+
console.info("OS Version :", import_chalk8.default.blue((0, import_os_name.default)((0, import_os.platform)(), (0, import_os.release)())));
|
|
1320
|
+
console.info("NodeJS Version :", import_chalk8.default.blue(process.version));
|
|
1321
|
+
const where = await import_zx5.$`which node`;
|
|
1322
|
+
console.info("NodeJS path :", where.toString());
|
|
1323
|
+
console.info("NODE_OPTIONS :", import_chalk8.default.blue(process.env.NODE_OPTIONS));
|
|
1324
|
+
if (where.toString().includes("nvm")) {
|
|
1325
|
+
console.info("NVM_DIR :", import_chalk8.default.blue(process.env.NVM_DIR));
|
|
1326
|
+
}
|
|
1327
|
+
console.log();
|
|
1328
|
+
const cpu = await import_systeminformation.default.cpu();
|
|
1329
|
+
const mem = await import_systeminformation.default.mem();
|
|
1330
|
+
console.info("CPU Family:", import_chalk8.default.blue(`${cpu.vendor} ${cpu.brand}`));
|
|
1331
|
+
console.info("CPU Ph Cores:", import_chalk8.default.blue(cpu.cores));
|
|
1332
|
+
console.info("CPU Speed:", import_chalk8.default.blue(`${cpu.speed}GHz`));
|
|
1333
|
+
console.info("Memory:", import_chalk8.default.blue(`${(0, import_filesize.filesize)(mem.total)}`));
|
|
1334
|
+
console.info("Memory Free:", import_chalk8.default.blue(`${(0, import_filesize.filesize)(mem.free)}`));
|
|
1335
|
+
console.info("Memory Used:", import_chalk8.default.blue(`${(0, import_filesize.filesize)(mem.used)}`));
|
|
1336
|
+
console.info("Memory Available:", import_chalk8.default.blue(`${(0, import_filesize.filesize)(mem.available)}`));
|
|
1357
1337
|
}
|
|
1358
1338
|
rightPad(name, length) {
|
|
1359
1339
|
while (name.length < length) {
|
|
@@ -1376,11 +1356,9 @@ var init_command3 = __esm({
|
|
|
1376
1356
|
super(...arguments);
|
|
1377
1357
|
this.id = "info";
|
|
1378
1358
|
}
|
|
1379
|
-
load(program) {
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
yield this.action.handle();
|
|
1383
|
-
}));
|
|
1359
|
+
async load(program) {
|
|
1360
|
+
program.command("info").alias("i").description("\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0438\u043D\u0444\u043E").action(async () => {
|
|
1361
|
+
await this.action.handle();
|
|
1384
1362
|
});
|
|
1385
1363
|
}
|
|
1386
1364
|
};
|
|
@@ -1453,96 +1431,93 @@ var init_action4 = __esm({
|
|
|
1453
1431
|
return table.toString();
|
|
1454
1432
|
};
|
|
1455
1433
|
}
|
|
1456
|
-
handle(
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
const
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
token: (_b = process.env.TINIFY_API_KEY) != null ? _b : "",
|
|
1498
|
-
verbose: true
|
|
1499
|
-
});
|
|
1500
|
-
break;
|
|
1501
|
-
case "video/mp4":
|
|
1502
|
-
runner = RunnerFactory.create("FFMPEG" /* FFMPEG */, {
|
|
1503
|
-
verbose: true
|
|
1504
|
-
});
|
|
1505
|
-
break;
|
|
1506
|
-
default:
|
|
1507
|
-
console.log(import_chalk9.default.yellowBright(`Unsupported mime type for ${import_chalk9.default.white(resource)}`));
|
|
1508
|
-
}
|
|
1509
|
-
if (!runner) {
|
|
1510
|
-
return {
|
|
1511
|
-
__originalPath: resource,
|
|
1512
|
-
__optimizedPath: resource,
|
|
1513
|
-
status: false
|
|
1514
|
-
};
|
|
1515
|
-
}
|
|
1516
|
-
try {
|
|
1517
|
-
const beforeStat = import_fs.default.statSync(resource);
|
|
1518
|
-
yield runner.run({
|
|
1519
|
-
resource,
|
|
1520
|
-
output: outputPath,
|
|
1521
|
-
extraFlags
|
|
1434
|
+
async handle(options, extraFlags = []) {
|
|
1435
|
+
const resources = await (0, import_glob.glob)(import_node_path5.default.join(process.cwd(), options.filePath), { ignore: "node_modules/**" });
|
|
1436
|
+
console.log(import_chalk9.default.white(`\u041D\u0430\u0439\u0434\u0435\u043D\u043E ${import_chalk9.default.green(resources.length)} \u0440\u0435\u0441\u0443\u0440\u0441\u043E\u0432 \u0434\u043B\u044F \u043E\u043F\u0442\u0438\u043C\u0438\u0437\u0430\u0446\u0438\u0438`));
|
|
1437
|
+
console.log(
|
|
1438
|
+
import_chalk9.default.yellowBright(`\u0415\u0441\u043B\u0438 \u0432\u044B \u0445\u043E\u0442\u0438\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044C \u0441\u043F\u0438\u0441\u043E\u043A \u0440\u0435\u0441\u0443\u0440\u0441\u043E\u0432, \u0432\u043E\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435\u0441\u044C \u043E\u043F\u0446\u0438\u0435\u0439 ${import_chalk9.default.green("--list")}`)
|
|
1439
|
+
);
|
|
1440
|
+
if (options.list) console.log(resources);
|
|
1441
|
+
const answers = await import_inquirer.default.prompt([
|
|
1442
|
+
{
|
|
1443
|
+
type: "list",
|
|
1444
|
+
message: "\u041F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u044C?",
|
|
1445
|
+
choices: [
|
|
1446
|
+
{ name: "Yes", value: 1 },
|
|
1447
|
+
{ name: "No", value: 0 }
|
|
1448
|
+
],
|
|
1449
|
+
default: 0,
|
|
1450
|
+
name: "continue"
|
|
1451
|
+
}
|
|
1452
|
+
]);
|
|
1453
|
+
if (!answers.continue) return;
|
|
1454
|
+
console.log();
|
|
1455
|
+
const bar = new import_cli_progress.default.SingleBar({ fps: 25 }, import_cli_progress.default.Presets.shades_classic);
|
|
1456
|
+
bar.start(resources.length, 0);
|
|
1457
|
+
const ft = await import("file-type");
|
|
1458
|
+
const promises = resources.map(async (resource) => {
|
|
1459
|
+
const fileType = await ft.fileTypeFromFile(resource);
|
|
1460
|
+
if (!fileType)
|
|
1461
|
+
return {
|
|
1462
|
+
__originalPath: resource,
|
|
1463
|
+
__optimizedPath: resource,
|
|
1464
|
+
status: false
|
|
1465
|
+
};
|
|
1466
|
+
const { mime } = fileType;
|
|
1467
|
+
let runner;
|
|
1468
|
+
const outputPath = options.replace ? resource : import_node_path5.default.join(import_node_path5.default.dirname(resource), `${options.prefix ?? ""}${import_node_path5.default.basename(resource)}`);
|
|
1469
|
+
switch (mime) {
|
|
1470
|
+
case "image/png":
|
|
1471
|
+
case "image/jpeg":
|
|
1472
|
+
runner = RunnerFactory.create("TINYPNG" /* TINYPNG */, {
|
|
1473
|
+
token: process.env.TINIFY_API_KEY ?? "",
|
|
1474
|
+
verbose: true
|
|
1522
1475
|
});
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
};
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1476
|
+
break;
|
|
1477
|
+
case "video/mp4":
|
|
1478
|
+
runner = RunnerFactory.create("FFMPEG" /* FFMPEG */, {
|
|
1479
|
+
verbose: true
|
|
1480
|
+
});
|
|
1481
|
+
break;
|
|
1482
|
+
default:
|
|
1483
|
+
console.log(import_chalk9.default.yellowBright(`Unsupported mime type for ${import_chalk9.default.white(resource)}`));
|
|
1484
|
+
}
|
|
1485
|
+
if (!runner) {
|
|
1486
|
+
return {
|
|
1487
|
+
__originalPath: resource,
|
|
1488
|
+
__optimizedPath: resource,
|
|
1489
|
+
status: false
|
|
1490
|
+
};
|
|
1491
|
+
}
|
|
1492
|
+
try {
|
|
1493
|
+
const beforeStat = import_fs.default.statSync(resource);
|
|
1494
|
+
await runner.run({
|
|
1495
|
+
resource,
|
|
1496
|
+
output: outputPath,
|
|
1497
|
+
extraFlags
|
|
1498
|
+
});
|
|
1499
|
+
const afterStat = import_fs.default.statSync(outputPath);
|
|
1500
|
+
return {
|
|
1501
|
+
__originalPath: resource,
|
|
1502
|
+
__originalStat: beforeStat,
|
|
1503
|
+
__optimizedPath: resource,
|
|
1504
|
+
__optimizedStat: afterStat,
|
|
1505
|
+
status: true
|
|
1506
|
+
};
|
|
1507
|
+
} catch (err) {
|
|
1508
|
+
return {
|
|
1509
|
+
__originalPath: resource,
|
|
1510
|
+
__optimizedPath: resource,
|
|
1511
|
+
status: false,
|
|
1512
|
+
err
|
|
1513
|
+
};
|
|
1514
|
+
} finally {
|
|
1515
|
+
bar.increment();
|
|
1516
|
+
}
|
|
1517
|
+
});
|
|
1518
|
+
await Promise.all(promises).then((result) => {
|
|
1519
|
+
bar.stop();
|
|
1520
|
+
this.printResult(result);
|
|
1546
1521
|
});
|
|
1547
1522
|
}
|
|
1548
1523
|
printResult(result) {
|
|
@@ -1573,23 +1548,21 @@ var init_command4 = __esm({
|
|
|
1573
1548
|
super(...arguments);
|
|
1574
1549
|
this.id = "optimize";
|
|
1575
1550
|
}
|
|
1576
|
-
load(program) {
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
);
|
|
1592
|
-
}));
|
|
1551
|
+
async load(program) {
|
|
1552
|
+
program.command("optimize [path] [extraFlags...]").alias("opt").option("-l, --list", "\u0412\u044B\u0432\u0435\u0441\u0442\u0438 \u0441\u043F\u0438\u0441\u043E\u043A \u0444\u0430\u0439\u043B\u043E\u0432 \u0434\u043B\u044F \u043E\u043F\u0442\u0438\u043C\u0438\u0437\u0430\u0446\u0438\u0438", false).option("-r, --replace", "\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C \u0438\u0441\u0445\u043E\u0434\u043D\u044B\u0439 \u0444\u0430\u0439\u043B", false).option("-p, --prefix", "\u041F\u0440\u0435\u0444\u0438\u043A\u0441 \u0432 \u0438\u043C\u0435\u043D\u0438 \u043E\u043F\u0442\u0438\u043C\u0430\u0439\u0437\u043D\u0443\u0442\u043E\u0433\u043E \u0444\u0430\u0439\u043B\u0430", "__").description("\u041E\u043F\u0442\u0438\u043C\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0440\u0435\u0441\u0443\u0440\u0441(jpg,png,mp4)").action(async (path10, extraFlags, option) => {
|
|
1553
|
+
if (!path10) {
|
|
1554
|
+
console.log(import_chalk10.default.yellow("\u0423\u043A\u0430\u0436\u0438\u0442\u0435 \u043F\u0443\u0442\u044C \u0434\u043E \u0440\u0435\u0441\u0443\u0440\u0441\u0430(\u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044F glob)"));
|
|
1555
|
+
process.exit(1);
|
|
1556
|
+
}
|
|
1557
|
+
await this.action.handle(
|
|
1558
|
+
{
|
|
1559
|
+
filePath: path10,
|
|
1560
|
+
list: option.list,
|
|
1561
|
+
replace: option.replace,
|
|
1562
|
+
prefix: option.prefix
|
|
1563
|
+
},
|
|
1564
|
+
extraFlags
|
|
1565
|
+
);
|
|
1593
1566
|
});
|
|
1594
1567
|
}
|
|
1595
1568
|
};
|
|
@@ -1619,7 +1592,7 @@ var import_chalk12 = __toESM(require("chalk"));
|
|
|
1619
1592
|
// package.json
|
|
1620
1593
|
var package_default = {
|
|
1621
1594
|
name: "@foxford/cli",
|
|
1622
|
-
version: "1.
|
|
1595
|
+
version: "1.1.0",
|
|
1623
1596
|
description: "Foxford Cli",
|
|
1624
1597
|
keywords: [
|
|
1625
1598
|
"foxford",
|
|
@@ -1642,8 +1615,12 @@ var package_default = {
|
|
|
1642
1615
|
}
|
|
1643
1616
|
],
|
|
1644
1617
|
main: "./README.mdx",
|
|
1618
|
+
types: "./src/types/index.ts",
|
|
1645
1619
|
exports: {
|
|
1646
|
-
"./README.mdx": "./README.mdx"
|
|
1620
|
+
"./README.mdx": "./README.mdx",
|
|
1621
|
+
".": {
|
|
1622
|
+
types: "./src/types/index.ts"
|
|
1623
|
+
}
|
|
1647
1624
|
},
|
|
1648
1625
|
bin: {
|
|
1649
1626
|
"fox-dev": "./scripts/dev.js",
|
|
@@ -1653,9 +1630,12 @@ var package_default = {
|
|
|
1653
1630
|
"============================ BUILD =============================": "",
|
|
1654
1631
|
build: "tsup",
|
|
1655
1632
|
prebuild: 'pnpm -w run build:workspace-deps "$PWD"',
|
|
1633
|
+
postbuild: "pnpm run build-dts",
|
|
1634
|
+
"build-dts": "dts-bundle-generator -o build/fox.d.ts src/types/index.ts --no-banner --external-inlines=commander loglevel --sort --inline-declare-externals",
|
|
1656
1635
|
"============================ DEPLOY =============================": "",
|
|
1657
1636
|
deploy: "fox deploy npm",
|
|
1658
1637
|
"============================ LINT =============================": "",
|
|
1638
|
+
"lint:clean": "rm -f .eslintcache",
|
|
1659
1639
|
"lint:type-check": "tsc --noEmit --pretty",
|
|
1660
1640
|
"lint:eslint": "eslint --cache --cache-strategy content --max-warnings=0 ./",
|
|
1661
1641
|
"============================ TEST =============================": "",
|
|
@@ -1681,17 +1661,20 @@ var package_default = {
|
|
|
1681
1661
|
glob: "10.4.2",
|
|
1682
1662
|
inquirer: "12.4.3",
|
|
1683
1663
|
"os-name": "4.0.1",
|
|
1664
|
+
"read-package-up": "11.0.0",
|
|
1684
1665
|
systeminformation: "5.25.11",
|
|
1685
1666
|
tinify: "1.7.1",
|
|
1686
1667
|
tsx: "4.15.7",
|
|
1687
|
-
typescript: "5.
|
|
1668
|
+
typescript: "5.8.3",
|
|
1688
1669
|
yaml: "2.4.5",
|
|
1689
1670
|
zx: "8.1.3"
|
|
1690
1671
|
},
|
|
1691
1672
|
devDependencies: {
|
|
1692
1673
|
"@foxford/eslint-config": "workspace:*",
|
|
1693
1674
|
"@foxford/typescript-config": "workspace:*",
|
|
1694
|
-
|
|
1675
|
+
"dts-bundle-generator": "9.5.1",
|
|
1676
|
+
tsup: "8.4.0",
|
|
1677
|
+
vitest: "3.0.9"
|
|
1695
1678
|
}
|
|
1696
1679
|
};
|
|
1697
1680
|
|
|
@@ -1700,6 +1683,7 @@ init_logger();
|
|
|
1700
1683
|
init_program2();
|
|
1701
1684
|
|
|
1702
1685
|
// src/program/loader.ts
|
|
1686
|
+
var import_node_module = require("module");
|
|
1703
1687
|
var import_node_path6 = __toESM(require("path"));
|
|
1704
1688
|
var import_chalk11 = __toESM(require("chalk"));
|
|
1705
1689
|
var import_fs_extra4 = __toESM(require("fs-extra"));
|
|
@@ -1707,74 +1691,128 @@ init_ui();
|
|
|
1707
1691
|
init_logger();
|
|
1708
1692
|
var log2 = logger.getLogger("command-loader");
|
|
1709
1693
|
var _CommandLoader = class _CommandLoader {
|
|
1710
|
-
static load(program) {
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
return yield command.load(program);
|
|
1719
|
-
})));
|
|
1720
|
-
this.handleInvalidCommand(program);
|
|
1721
|
-
});
|
|
1694
|
+
static async load(program) {
|
|
1695
|
+
if (true) {
|
|
1696
|
+
await this.loadProductionProcesses(program);
|
|
1697
|
+
} else {
|
|
1698
|
+
await this.loadDevelopmentProcesses(program);
|
|
1699
|
+
}
|
|
1700
|
+
await Promise.all(program.getCommands().map(async (command) => await command.load(program)));
|
|
1701
|
+
this.handleInvalidCommand(program);
|
|
1722
1702
|
}
|
|
1723
|
-
static loadProductionProcesses(program) {
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
} catch (err) {
|
|
1738
|
-
log2.error(`\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0435 \u043C\u043E\u0434\u0443\u043B\u044F "${processName}":`, err);
|
|
1739
|
-
}
|
|
1703
|
+
static async loadProductionProcesses(program) {
|
|
1704
|
+
try {
|
|
1705
|
+
for (const [processName, moduleLoader] of Object.entries({
|
|
1706
|
+
codemod: () => Promise.resolve().then(() => (init_codemod(), codemod_exports)),
|
|
1707
|
+
deploy: () => Promise.resolve().then(() => (init_deploy(), deploy_exports)),
|
|
1708
|
+
info: () => Promise.resolve().then(() => (init_info(), info_exports)),
|
|
1709
|
+
optimize: () => Promise.resolve().then(() => (init_optimize(), optimize_exports))
|
|
1710
|
+
})) {
|
|
1711
|
+
try {
|
|
1712
|
+
log2.debug(`\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043C \u043C\u043E\u0434\u0443\u043B\u044C: ${import_chalk11.default.cyan(processName)}`);
|
|
1713
|
+
const module2 = await moduleLoader();
|
|
1714
|
+
module2.default(program);
|
|
1715
|
+
} catch (err) {
|
|
1716
|
+
log2.error(`\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0435 \u043C\u043E\u0434\u0443\u043B\u044F "${processName}":`, err);
|
|
1740
1717
|
}
|
|
1741
|
-
} catch (err) {
|
|
1742
|
-
log2.error("\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0435 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u043E\u0432:", err);
|
|
1743
1718
|
}
|
|
1744
|
-
})
|
|
1719
|
+
} catch (err) {
|
|
1720
|
+
log2.error("\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0435 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u043E\u0432:", err);
|
|
1721
|
+
}
|
|
1722
|
+
try {
|
|
1723
|
+
await this.loadPlugins(program);
|
|
1724
|
+
} catch (err) {
|
|
1725
|
+
log2.error("\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0438 \u0447\u0442\u0435\u043D\u0438\u0438 \u043F\u043B\u0430\u0433\u0438\u043D\u0430:", err);
|
|
1726
|
+
}
|
|
1745
1727
|
}
|
|
1746
|
-
static loadDevelopmentProcesses(program) {
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1728
|
+
static async loadDevelopmentProcesses(program) {
|
|
1729
|
+
if (!await import_fs_extra4.default.pathExists(_CommandLoader.PROCESSES_DIR)) {
|
|
1730
|
+
log2.error(`\u0414\u0438\u0440\u0435\u043A\u0442\u043E\u0440\u0438\u044F \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u043E\u0432 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u0430: ${_CommandLoader.PROCESSES_DIR}`);
|
|
1731
|
+
return;
|
|
1732
|
+
}
|
|
1733
|
+
try {
|
|
1734
|
+
const processes = await this.getProcesses(_CommandLoader.PROCESSES_DIR);
|
|
1735
|
+
for (const processName of processes) {
|
|
1736
|
+
try {
|
|
1737
|
+
log2.debug(`\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043C \u043C\u043E\u0434\u0443\u043B\u044C: ${import_chalk11.default.cyan(processName)}`);
|
|
1738
|
+
const modulePath = import_node_path6.default.join(_CommandLoader.PROCESSES_DIR, processName);
|
|
1739
|
+
const module2 = require(modulePath);
|
|
1740
|
+
module2.default(program);
|
|
1741
|
+
} catch (err) {
|
|
1742
|
+
log2.error(`\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0435 \u043C\u043E\u0434\u0443\u043B\u044F "${processName}":`, err);
|
|
1752
1743
|
}
|
|
1753
|
-
|
|
1754
|
-
|
|
1744
|
+
}
|
|
1745
|
+
} catch (err) {
|
|
1746
|
+
log2.error("\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0438 \u0447\u0442\u0435\u043D\u0438\u0438 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u043E\u0432:", err);
|
|
1747
|
+
}
|
|
1748
|
+
try {
|
|
1749
|
+
await this.loadPlugins(program);
|
|
1750
|
+
} catch (err) {
|
|
1751
|
+
log2.error("\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0438 \u0447\u0442\u0435\u043D\u0438\u0438 \u043F\u043B\u0430\u0433\u0438\u043D\u0430:", err);
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
static async loadPlugins(program) {
|
|
1755
|
+
const plugins = await program.getPluginPaths();
|
|
1756
|
+
for (const plugin of plugins) {
|
|
1757
|
+
log2.debug(`\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043C \u043C\u043E\u0434\u0443\u043B\u044C: ${import_chalk11.default.cyan(plugin.pkgJson.name)}`);
|
|
1758
|
+
const dirname = import_node_path6.default.dirname(plugin.path);
|
|
1759
|
+
if (false) {
|
|
1760
|
+
const module2 = require(`${plugin.pkgJson.name}`);
|
|
1761
|
+
module2.default(program);
|
|
1762
|
+
continue;
|
|
1763
|
+
}
|
|
1764
|
+
if (import_fs_extra4.default.existsSync(import_node_path6.default.resolve(dirname, "build", "package.json"))) {
|
|
1765
|
+
const buildPath = import_node_path6.default.resolve(dirname, "build");
|
|
1766
|
+
const buildPackageJson = require(import_node_path6.default.join(buildPath, "package.json"));
|
|
1767
|
+
let modulePath;
|
|
1768
|
+
if (buildPackageJson.exports) {
|
|
1769
|
+
if (typeof buildPackageJson.exports === "string") {
|
|
1770
|
+
modulePath = import_node_path6.default.join(buildPath, buildPackageJson.exports);
|
|
1771
|
+
} else if (buildPackageJson.exports["."]) {
|
|
1772
|
+
const defaultExport = buildPackageJson.exports["."];
|
|
1773
|
+
if (typeof defaultExport === "string") {
|
|
1774
|
+
modulePath = import_node_path6.default.join(buildPath, defaultExport);
|
|
1775
|
+
} else if (defaultExport.require) {
|
|
1776
|
+
modulePath = import_node_path6.default.join(buildPath, defaultExport.require);
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
} else if (buildPackageJson.main) {
|
|
1780
|
+
modulePath = import_node_path6.default.join(buildPath, buildPackageJson.main);
|
|
1781
|
+
} else {
|
|
1782
|
+
modulePath = import_node_path6.default.join(buildPath, "index.js");
|
|
1783
|
+
}
|
|
1784
|
+
if (modulePath) {
|
|
1755
1785
|
try {
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1786
|
+
const require2 = (0, import_node_module.createRequire)(__filename);
|
|
1787
|
+
let module2;
|
|
1788
|
+
if (buildPackageJson.type === "module") {
|
|
1789
|
+
module2 = await import(modulePath);
|
|
1790
|
+
} else {
|
|
1791
|
+
module2 = require2(modulePath);
|
|
1792
|
+
}
|
|
1793
|
+
if (typeof module2.default === "function") {
|
|
1794
|
+
module2.default(program);
|
|
1795
|
+
} else if (typeof module2 === "function") {
|
|
1796
|
+
module2(program);
|
|
1797
|
+
} else {
|
|
1798
|
+
log2.warn(`\u041C\u043E\u0434\u0443\u043B\u044C "${plugin.pkgJson.name}" \u043D\u0435 \u044D\u043A\u0441\u043F\u043E\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0444\u0443\u043D\u043A\u0446\u0438\u044E \u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E`);
|
|
1799
|
+
}
|
|
1800
|
+
} catch (error) {
|
|
1801
|
+
log2.error(`\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0435 \u043C\u043E\u0434\u0443\u043B\u044F "${plugin.pkgJson.name}" \u0438\u0437 build \u0434\u0438\u0440\u0435\u043A\u0442\u043E\u0440\u0438\u0438:`, error);
|
|
1762
1802
|
}
|
|
1803
|
+
} else {
|
|
1804
|
+
log2.error(`\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0438\u0442\u044C \u0442\u043E\u0447\u043A\u0443 \u0432\u0445\u043E\u0434\u0430 \u0434\u043B\u044F \u043C\u043E\u0434\u0443\u043B\u044F "${plugin.pkgJson.name}"`);
|
|
1763
1805
|
}
|
|
1764
|
-
} catch (err) {
|
|
1765
|
-
log2.error("\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u0440\u0438 \u0447\u0442\u0435\u043D\u0438\u0438 \u0434\u0438\u0440\u0435\u043A\u0442\u043E\u0440\u0438\u0438 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u043E\u0432:", err);
|
|
1766
1806
|
}
|
|
1767
|
-
}
|
|
1807
|
+
}
|
|
1768
1808
|
}
|
|
1769
|
-
static getProcesses(processesPath) {
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
}).map((file) => import_node_path6.default.parse(file).name);
|
|
1777
|
-
});
|
|
1809
|
+
static async getProcesses(processesPath) {
|
|
1810
|
+
const files = await import_fs_extra4.default.readdir(processesPath);
|
|
1811
|
+
return files.filter((file) => {
|
|
1812
|
+
const filePath = import_node_path6.default.join(processesPath, file, "index.ts");
|
|
1813
|
+
const stat = import_fs_extra4.default.statSync(filePath);
|
|
1814
|
+
return stat.isFile();
|
|
1815
|
+
}).map((file) => import_node_path6.default.parse(file).name);
|
|
1778
1816
|
}
|
|
1779
1817
|
static handleInvalidCommand(program) {
|
|
1780
1818
|
program.on("command:*", () => {
|
|
@@ -1795,18 +1833,18 @@ var welcomeText = `${import_chalk12.default.green(`\u041F\u0440\u0438\u0432\u043
|
|
|
1795
1833
|
${import_chalk12.default.magenta(`\u042D\u0442\u0430 \u0448\u0442\u0443\u043A\u0430 \u043F\u0440\u0438\u0437\u0432\u0430\u043D\u0430 \u043F\u043E\u043C\u043E\u0447\u044C \u0442\u0435\u0431\u0435 \u0432 \u043A\u043E\u0434\u043E\u0433\u0435\u043D\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u0432 \u0447\u0435\u043C-\u043D\u0438\u0431\u0443\u0434\u044C \u0435\u0449\u0451\u{1F37F}`)}
|
|
1796
1834
|
${import_chalk12.default.yellowBright("\u0427\u0430\u0439 \u043D\u0430\u043B\u0438\u0432\u0430\u0439 \u0441\u0435\u0431\u0435 \u0441\u0430\u043C \u{1F36E}\u{1F36A}")}
|
|
1797
1835
|
`;
|
|
1798
|
-
var bootstrap = () =>
|
|
1836
|
+
var bootstrap = async () => {
|
|
1799
1837
|
logger.debug("Start program");
|
|
1800
1838
|
const program = new Program();
|
|
1801
1839
|
program.version(package_default.version, "-v, --version", "\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0442\u0435\u043A\u0443\u0449\u0443\u044E \u0432\u0435\u0440\u0441\u0438\u044E \u0442\u0443\u043B\u0437\u044B").name(PROGRAM_NAME).description(welcomeText).usage("<command> [options]").helpOption(false).addHelpCommand(false);
|
|
1802
1840
|
logger.debug("Load processes");
|
|
1803
|
-
|
|
1841
|
+
await CommandLoader.load(program);
|
|
1804
1842
|
logger.debug("Loading complete");
|
|
1805
1843
|
logger.debug("Parse process.argv", process.argv);
|
|
1806
|
-
|
|
1844
|
+
await program.parseAsync(process.argv);
|
|
1807
1845
|
if (!process.argv.slice(2).length) {
|
|
1808
1846
|
program.outputHelp();
|
|
1809
1847
|
}
|
|
1810
|
-
}
|
|
1848
|
+
};
|
|
1811
1849
|
bootstrap();
|
|
1812
1850
|
//# sourceMappingURL=fox.js.map
|