@foxford/cli 1.0.0-beta-6f7848f0-20250318 → 1.1.0-beta-0acd9fac-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.
Files changed (5) hide show
  1. package/README.mdx +56 -1
  2. package/fox.d.ts +1031 -0
  3. package/fox.js +682 -643
  4. package/fox.js.map +1 -1
  5. package/package.json +7 -4
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 != null ? options : {};
125
- }
126
- run(payload) {
127
- return __async(this, null, function* () {
128
- return new Promise((resolve, reject) => {
129
- var _a, _b;
130
- (0, import_fluent_ffmpeg.default)(payload.resource).output((_a = payload.output) != null ? _a : import_node_path.default.basename(payload.resource)).outputOptions([
131
- "-hide_banner",
132
- "-movflags +faststart",
133
- "-pix_fmt yuv420p",
134
- "-c:v libx264",
135
- "-preset:v veryslow",
136
- "-profile:v high",
137
- "-level 3.1",
138
- "-tune:v ssim",
139
- "-r 30",
140
- "-g 180",
141
- "-keyint_min 180",
142
- "-sc_threshold 0",
143
- "-max_muxing_queue_size 1024",
144
- // '-vf scale=1920:-1',
145
- "-f mp4",
146
- ...(_b = payload.extraFlags) != null ? _b : []
147
- ]).on("end", function() {
148
- resolve(payload.resource);
149
- }).on("error", function(err) {
150
- console.log();
151
- console.log(import_chalk.default.redBright("Cannot process video: " + err.message));
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 != null ? options : { cwd: process.cwd() };
172
- }
173
- run(_0) {
174
- return __async(this, arguments, function* (command, args = [], options = {}, collect = false) {
175
- const spawnOptions = __spreadValues({
176
- cwd: this.options.cwd,
177
- stdio: collect ? "pipe" : "inherit",
178
- shell: true
179
- }, options);
180
- return new Promise((resolve, reject) => {
181
- const child = (0, import_child_process.spawn)(`${this.binary}`, [command, ...args], spawnOptions);
182
- if (collect && child.stdout) {
183
- child.stdout.on("data", (data) => resolve(data.toString().replace(/\r\n|\n/, "")));
184
- }
185
- child.on("close", (code) => {
186
- if (code === 0) {
187
- resolve(child.stdout);
188
- } else {
189
- console.error(import_chalk2.default.red(`
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
- reject(code);
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 != null ? options : {};
319
- }
320
- run(_0, _1) {
321
- return __async(this, arguments, function* (script, { pkg }) {
322
- const label2 = getLabel(pkg.localName.toUpperCase());
323
- const failLabel = getFailLabel(pkg.localName.toUpperCase());
324
- console.log(label2 + import_chalk3.default.blue(`Start ${import_chalk3.default.white.underline(script)} process`));
325
- if (this.options.verbose) {
326
- console.log(label2 + import_chalk3.default.blue(`Print typescript config`));
327
- console.log();
328
- }
329
- console.log(
330
- label2 + import_chalk3.default.blue(`Env ${import_chalk3.default.magenta("process.env.NODE_ENV")} is ${import_chalk3.default.yellow("production")}`)
331
- );
332
- console.log(
333
- label2 + import_chalk3.default.blue(`Env ${import_chalk3.default.magenta("process.env.NODE_OPTIONS")} is ${import_chalk3.default.yellow(process.env.NODE_OPTIONS)}`)
334
- );
335
- try {
336
- console.log(label2 + import_chalk3.default.blue(`Load .env files`));
337
- const envFiles = loadEnv(pkg.path);
338
- console.log(JSON.stringify(envFiles, null, 2));
339
- } catch (err) {
340
- if (err instanceof Error) {
341
- console.log(failLabel + import_chalk3.default.red(err.message));
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
- const pnpmRunner = new PnpmRunner();
346
- pnpmRunner.run("run", [`--filter ${pkg.localName}`, script], {
347
- env: Object.assign(process.env, { FORCE_COLOR: "1" }),
348
- cwd: pkg.path
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 != null ? options : {};
366
- if (!(options == null ? void 0 : options.token)) throw new Error("You must specify process.env.TINIFY_API_KEY env variable with tinify key");
367
- }
368
- run(payload) {
369
- return __async(this, null, function* () {
370
- var _a, _b, _c;
371
- const source = import_tinify.default.fromFile(payload.resource);
372
- import_tinify.default.key = (_b = (_a = this.options) == null ? void 0 : _a.token) != null ? _b : "";
373
- try {
374
- yield source.toFile((_c = payload.output) != null ? _c : payload.resource);
375
- } catch (err) {
376
- if (err instanceof Error) console.log(import_chalk4.default.redBright("Cannot compress resource with tinify: " + err.message));
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
- determineRootPath() {
463
- return __async(this, null, function* () {
464
- const packageManager = yield (0, import_detect_package_manager.detect)();
465
- switch (packageManager) {
466
- case "npm":
467
- return import_node_path3.default.dirname(RunnerFactory.create("NPM" /* NPM */).runSync("root"));
468
- case "pnpm":
469
- return import_node_path3.default.dirname(RunnerFactory.create("PNPM" /* PNPM */).runSync("root"));
470
- default:
471
- return process.cwd();
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
- return __async(this, null, function* () {
554
- const flags = [];
555
- if (options.dry) flags.push("--dry");
556
- if (options.verbose) flags.push("--verbose");
557
- console.log("options", options);
558
- console.log("flags", flags);
559
- console.log("extra", options.extra);
560
- const runner = RunnerFactory.create("NODE" /* NODE */, {
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 __async(this, null, function* () {
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), (_a = pkgJson.codemods) != null ? _a : "");
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) => __spreadProps(__spreadValues({}, codemod), {
629
+ this.codemods = collectionJson.codemods.map((codemod) => ({
630
+ ...codemod,
643
631
  name: normalizeToKebabOrSnakeCase(codemod.name)
644
632
  }));
645
- } catch (e) {
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) => __async(this, null, function* () {
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 = (_b = (_a = command.parseOptions(command.args)) == null ? void 0 : _a.unknown) != null ? _b : [];
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
- yield this.action.handle(options);
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(() => __async(this, null, function* () {
723
- const list = yield this.getCollectionItems();
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
- return __async(this, null, function* () {
733
- const list = yield this.getItems(this.getCollection());
734
- this.items = list;
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
- return __async(this, null, function* () {
740
- const codemod = new import_commander2.Command("codemod");
741
- codemod.addHelpText(
742
- "before",
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
- "\u{1F6E0} Codemod manager"
747
- )}
730
+ "\u{1F6E0} Codemod manager"
731
+ )}
748
732
  ---------------------------------------
749
733
  `
750
- ).usage("<command>").helpOption(false).description(yield 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((options) => __async(this, null, function* () {
751
- if (!options || Object.keys(options).length === 0) {
752
- codemod.outputHelp();
753
- return;
754
- }
755
- yield this.action.handle(options);
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
- return __async(this, null, function* () {
785
- const abstractCollection = CollectionFactory.create(collection);
786
- this.items = yield abstractCollection.getItems();
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
- return __async(this, null, function* () {
792
- const list = yield this.getCollectionItems();
793
- const shortList = list.slice(0, 20);
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
- return __async(this, null, function* () {
923
- var _a, _b, _c, _d, _e;
924
- const { OS_USERNAME, OS_PASSWORD } = process.env;
925
- if (!OS_USERNAME || !OS_PASSWORD) {
926
- 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");
927
- }
928
- const localDir = import_zx3.path.join(process.cwd(), (_a = params.localDir) != null ? _a : this.buildDir);
929
- this.packageJson = this.readPackageJson(localDir);
930
- const bucket = (_c = (_b = params.bucket) != null ? _b : process.env.BUCKET) != null ? _c : "dist.ngcdn.ru";
931
- const remoteDirs = [];
932
- const packageName = (_d = params.packageName) != null ? _d : this.packageJson.name;
933
- const target = (_e = params.target) != null ? _e : this.getTarget();
934
- remoteDirs.push(this.getRemoteDirByVersion(bucket, packageName));
935
- remoteDirs.push(this.getRemoteDirByTarget(bucket, packageName, target));
936
- if (!import_zx3.fs.existsSync(localDir)) {
937
- 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`);
938
- process.exit(1);
939
- }
940
- yield Promise.allSettled(
941
- remoteDirs.map((remoteDir) => __async(this, null, function* () {
942
- const rclone = `rclone copy ${localDir} myremote:${remoteDir} --progress --error-on-no-transfer`;
943
- logger.log(`\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430 \u043F\u0430\u043A\u0435\u0442\u0430 \u0432 ${remoteDir} \u0441 \u043A\u043E\u043C\u0430\u043D\u0434\u043E\u0439:
944
- `, rclone);
945
- yield import_zx3.$`rclone copy ${localDir} myremote:${remoteDir} --progress --error-on-no-transfer ${params.dry ? "--dry-run" : ""}`;
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
- return __async(this, null, function* () {
981
- const commitSha = (yield import_zx4.$`git rev-parse --short HEAD`).toString().trim();
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
- return __async(this, null, function* () {
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
- return __async(this, null, function* () {
1030
- const notDeprecatedVersions = [];
1031
- for (const ver of versions) {
1032
- const cmd = ["npm", "view", `${this.packageJson.name}@${ver}`, "deprecated"];
1033
- const result = yield import_zx4.$`${cmd}`;
1034
- if (!result.toString().trim().includes("deprecated by")) {
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
- return notDeprecatedVersions;
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
- return __async(this, null, function* () {
1057
- logger.info("Getting versions list...");
1058
- const outputProcess = yield import_zx4.$`npm view ${this.packageJson.name} versions --json`;
1059
- const versionsListPo = outputProcess.toString();
1060
- logger.info("Versions list recieved", versionsListPo);
1061
- try {
1062
- const parsed = JSON.parse(versionsListPo);
1063
- if (Array.isArray(parsed)) {
1064
- return parsed;
1065
- } else {
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 = (_a = semverFromVersion[0]) != null ? _a : null;
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
- return __async(this, null, function* () {
1103
- logger.info("Set previous beta versions as deprecated");
1104
- this.versionLists = yield this.getVersionsList();
1105
- const betaVersions = this.getBetaVersions(currentVersion);
1106
- logger.info("Founded beta versions:", betaVersions);
1107
- const notDeprecatedVersions = yield this.getNotDeprecatedVersions(betaVersions);
1108
- logger.info("Not deprecated versions:", notDeprecatedVersions);
1109
- const deprecationMessage = yield this.getDeprecationMessage();
1110
- for (const ver of notDeprecatedVersions) {
1111
- yield sleep(500);
1112
- try {
1113
- if (!this.dry) {
1114
- const cmd = ["npm", "deprecate", `${this.packageJson.name}@${ver}`, deprecationMessage];
1115
- logger.info("Deprecate version:", cmd);
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
- return __async(this, null, function* () {
1137
- logger.info("Unpublish beta versions");
1138
- this.versionLists = yield this.getVersionsList();
1139
- logger.info("Version list: ", this.versionLists);
1140
- const betaVersions = this.getBetaVersions(currentVersion);
1141
- logger.info("List for unpublish & deprecating: ", betaVersions);
1142
- const deprecationMessage = yield this.getDeprecationMessage();
1143
- for (const ver of betaVersions) {
1144
- if (!ver.includes("beta")) continue;
1145
- try {
1146
- const deprecate = ["npm", "deprecate", `${this.packageJson.name}@${ver}`, deprecationMessage];
1147
- logger.info("Deprecate version:", deprecate);
1148
- yield import_zx4.$`${deprecate}`;
1149
- const unpublish = ["npm", "unpublish", `${this.packageJson.name}@${ver}`, "--force", this.dry];
1150
- logger.info("Unpublish version:", unpublish);
1151
- yield import_zx4.$`${unpublish}`;
1152
- } catch (error) {
1153
- logger.error(error);
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
- return __async(this, null, function* () {
1176
- var _a, _b;
1177
- logger.info("Start deploy process to npm", params);
1178
- const localDir = import_zx4.path.join(process.cwd(), (_a = params.localDir) != null ? _a : this.buildDir);
1179
- if (!import_zx4.fs.existsSync(localDir)) {
1180
- 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`);
1181
- process.exit(1);
1182
- }
1183
- this.packageJson = this.readPackageJson(localDir);
1184
- if (params.dry === true) this.dry = "--dry-run";
1185
- logger.info("Change directory to", localDir);
1186
- (0, import_zx4.cd)(localDir);
1187
- logger.info("Get commit sha");
1188
- const commitSha = (yield import_zx4.$`git rev-parse --short HEAD`).toString().replace("\n", "");
1189
- logger.info("Commit sha:", commitSha);
1190
- const target = (_b = params.target) != null ? _b : "beta";
1191
- logger.info("Target is:", target);
1192
- yield this.touchNpmrc();
1193
- logger.info("Touch .npmrc");
1194
- if (target === "beta") {
1195
- this.packageJson.version = this.packageJson.version.includes("beta") ? this.packageJson.version : this.getBetaPackageVersion(commitSha);
1196
- }
1197
- this.packageJson.sha = commitSha;
1198
- logger.info("Target version is:", this.packageJson.version);
1199
- if (this.packageJson.scripts && this.packageJson.scripts.postinstall) {
1200
- this.packageJson.scripts = {
1201
- postinstall: this.packageJson.scripts.postinstall
1202
- };
1203
- } else {
1204
- this.packageJson.scripts = {};
1205
- }
1206
- if (this.packageJson.devDependencies) {
1207
- delete this.packageJson.devDependencies;
1208
- }
1209
- logger.info("Resulted package.json", this.packageJson);
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
- return __async(this, null, function* () {
1238
- let provider;
1239
- switch (params.provider) {
1240
- case "npm":
1241
- provider = new NpmDeploy();
1242
- break;
1243
- case "cdn":
1244
- provider = new CdnDeploy();
1245
- break;
1246
- default:
1247
- throw new Error(`Unsupported deploy provider: ${params.provider}`);
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
- return __async(this, null, function* () {
1270
- const deployCommand = new import_commander3.Command("deploy").description("\u0417\u0430\u0434\u0435\u043F\u043B\u043E\u0438\u0442\u044C \u043F\u0430\u043A\u0435\u0442");
1271
- const targetOption = new import_commander3.Option("--target <target>", "\u0420\u0435\u043B\u0438\u0437 beta \u0438\u043B\u0438 latest").choices(["beta", "latest"]).default("beta");
1272
- 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");
1273
- 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);
1274
- 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((params) => __async(this, null, function* () {
1275
- yield this.action.handle(__spreadProps(__spreadValues({}, params), { provider: "cdn" }));
1276
- }));
1277
- cdnCommand.addOption(targetOption);
1278
- cdnCommand.addOption(localDirOption);
1279
- cdnCommand.addOption(dryOption);
1280
- const npmCommand = new import_commander3.Command("npm").description("\u0414\u0435\u043F\u043B\u043E\u0439 \u043F\u0430\u043A\u0435\u0442\u0430 \u0432 npm").action((params) => __async(this, null, function* () {
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
- return __async(this, null, function* () {
1328
- this.displayBanner();
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
- return __async(this, null, function* () {
1337
- console.info(import_chalk8.default.green("[System Information]"));
1338
- console.info("OS Version :", import_chalk8.default.blue((0, import_os_name.default)((0, import_os.platform)(), (0, import_os.release)())));
1339
- console.info("NodeJS Version :", import_chalk8.default.blue(process.version));
1340
- const where = yield import_zx5.$`which node`;
1341
- console.info("NodeJS path :", where.toString());
1342
- console.info("NODE_OPTIONS :", import_chalk8.default.blue(process.env.NODE_OPTIONS));
1343
- if (where.toString().includes("nvm")) {
1344
- console.info("NVM_DIR :", import_chalk8.default.blue(process.env.NVM_DIR));
1345
- }
1346
- console.log();
1347
- const cpu = yield import_systeminformation.default.cpu();
1348
- const mem = yield import_systeminformation.default.mem();
1349
- console.info("CPU Family:", import_chalk8.default.blue(`${cpu.vendor} ${cpu.brand}`));
1350
- console.info("CPU Ph Cores:", import_chalk8.default.blue(cpu.cores));
1351
- console.info("CPU Speed:", import_chalk8.default.blue(`${cpu.speed}GHz`));
1352
- console.info("Memory:", import_chalk8.default.blue(`${(0, import_filesize.filesize)(mem.total)}`));
1353
- console.info("Memory Free:", import_chalk8.default.blue(`${(0, import_filesize.filesize)(mem.free)}`));
1354
- console.info("Memory Used:", import_chalk8.default.blue(`${(0, import_filesize.filesize)(mem.used)}`));
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
- return __async(this, null, function* () {
1381
- program.command("info").alias("i").description("\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0438\u043D\u0444\u043E").action(() => __async(this, null, function* () {
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(_0) {
1457
- return __async(this, arguments, function* (options, extraFlags = []) {
1458
- const resources = yield (0, import_glob.glob)(import_node_path5.default.join(process.cwd(), options.filePath), { ignore: "node_modules/**" });
1459
- 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`));
1460
- console.log(
1461
- 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")}`)
1462
- );
1463
- if (options.list) console.log(resources);
1464
- const answers = yield import_inquirer.default.prompt([
1465
- {
1466
- type: "list",
1467
- message: "\u041F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u044C?",
1468
- choices: [
1469
- { name: "Yes", value: 1 },
1470
- { name: "No", value: 0 }
1471
- ],
1472
- default: 0,
1473
- name: "continue"
1474
- }
1475
- ]);
1476
- if (!answers.continue) return;
1477
- console.log();
1478
- const bar = new import_cli_progress.default.SingleBar({ fps: 25 }, import_cli_progress.default.Presets.shades_classic);
1479
- bar.start(resources.length, 0);
1480
- const ft = yield import("file-type");
1481
- const promises = resources.map((resource) => __async(this, null, function* () {
1482
- var _a, _b;
1483
- const fileType = yield ft.fileTypeFromFile(resource);
1484
- if (!fileType)
1485
- return {
1486
- __originalPath: resource,
1487
- __optimizedPath: resource,
1488
- status: false
1489
- };
1490
- const { mime } = fileType;
1491
- let runner;
1492
- const outputPath = options.replace ? resource : import_node_path5.default.join(import_node_path5.default.dirname(resource), `${(_a = options.prefix) != null ? _a : ""}${import_node_path5.default.basename(resource)}`);
1493
- switch (mime) {
1494
- case "image/png":
1495
- case "image/jpeg":
1496
- runner = RunnerFactory.create("TINYPNG" /* TINYPNG */, {
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
- const afterStat = import_fs.default.statSync(outputPath);
1524
- return {
1525
- __originalPath: resource,
1526
- __originalStat: beforeStat,
1527
- __optimizedPath: resource,
1528
- __optimizedStat: afterStat,
1529
- status: true
1530
- };
1531
- } catch (err) {
1532
- return {
1533
- __originalPath: resource,
1534
- __optimizedPath: resource,
1535
- status: false,
1536
- err
1537
- };
1538
- } finally {
1539
- bar.increment();
1540
- }
1541
- }));
1542
- yield Promise.all(promises).then((result) => {
1543
- bar.stop();
1544
- this.printResult(result);
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
- return __async(this, null, function* () {
1578
- 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((path10, extraFlags, option) => __async(this, null, function* () {
1579
- if (!path10) {
1580
- 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)"));
1581
- process.exit(1);
1582
- }
1583
- yield this.action.handle(
1584
- {
1585
- filePath: path10,
1586
- list: option.list,
1587
- replace: option.replace,
1588
- prefix: option.prefix
1589
- },
1590
- extraFlags
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.0.0",
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,21 @@ 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.6.3",
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
- tsup: "8.4.0"
1675
+ "dts-bundle-generator": "9.5.1",
1676
+ tsup: "8.4.0",
1677
+ vitest: "3.0.9",
1678
+ "read-package-up": "11.0.0"
1695
1679
  }
1696
1680
  };
1697
1681
 
@@ -1700,6 +1684,7 @@ init_logger();
1700
1684
  init_program2();
1701
1685
 
1702
1686
  // src/program/loader.ts
1687
+ var import_node_module = require("module");
1703
1688
  var import_node_path6 = __toESM(require("path"));
1704
1689
  var import_chalk11 = __toESM(require("chalk"));
1705
1690
  var import_fs_extra4 = __toESM(require("fs-extra"));
@@ -1707,74 +1692,128 @@ init_ui();
1707
1692
  init_logger();
1708
1693
  var log2 = logger.getLogger("command-loader");
1709
1694
  var _CommandLoader = class _CommandLoader {
1710
- static load(program) {
1711
- return __async(this, null, function* () {
1712
- if (true) {
1713
- yield this.loadProductionProcesses(program);
1714
- } else {
1715
- yield this.loadDevelopmentProcesses(program);
1716
- }
1717
- yield Promise.all(program.getCommands().map((command) => __async(this, null, function* () {
1718
- return yield command.load(program);
1719
- })));
1720
- this.handleInvalidCommand(program);
1721
- });
1695
+ static async load(program) {
1696
+ if (true) {
1697
+ await this.loadProductionProcesses(program);
1698
+ } else {
1699
+ await this.loadDevelopmentProcesses(program);
1700
+ }
1701
+ await Promise.all(program.getCommands().map(async (command) => await command.load(program)));
1702
+ this.handleInvalidCommand(program);
1722
1703
  }
1723
- static loadProductionProcesses(program) {
1724
- return __async(this, null, function* () {
1725
- try {
1726
- for (const [processName, moduleLoader] of Object.entries({
1727
- codegen: () => Promise.resolve().then(() => (init_codegen(), codegen_exports)),
1728
- codemod: () => Promise.resolve().then(() => (init_codemod(), codemod_exports)),
1729
- deploy: () => Promise.resolve().then(() => (init_deploy(), deploy_exports)),
1730
- info: () => Promise.resolve().then(() => (init_info(), info_exports)),
1731
- optimize: () => Promise.resolve().then(() => (init_optimize(), optimize_exports))
1732
- })) {
1733
- try {
1734
- log2.debug(`\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043C \u043C\u043E\u0434\u0443\u043B\u044C: ${import_chalk11.default.cyan(processName)}`);
1735
- const module2 = yield moduleLoader();
1736
- module2.default(program);
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
- }
1704
+ static async loadProductionProcesses(program) {
1705
+ try {
1706
+ for (const [processName, moduleLoader] of Object.entries({
1707
+ codemod: () => Promise.resolve().then(() => (init_codemod(), codemod_exports)),
1708
+ deploy: () => Promise.resolve().then(() => (init_deploy(), deploy_exports)),
1709
+ info: () => Promise.resolve().then(() => (init_info(), info_exports)),
1710
+ optimize: () => Promise.resolve().then(() => (init_optimize(), optimize_exports))
1711
+ })) {
1712
+ try {
1713
+ log2.debug(`\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043C \u043C\u043E\u0434\u0443\u043B\u044C: ${import_chalk11.default.cyan(processName)}`);
1714
+ const module2 = await moduleLoader();
1715
+ module2.default(program);
1716
+ } catch (err) {
1717
+ 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
1718
  }
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
1719
  }
1744
- });
1720
+ } catch (err) {
1721
+ 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);
1722
+ }
1723
+ try {
1724
+ await this.loadPlugins(program);
1725
+ } catch (err) {
1726
+ 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);
1727
+ }
1745
1728
  }
1746
- static loadDevelopmentProcesses(program) {
1747
- return __async(this, null, function* () {
1748
- try {
1749
- if (!(yield import_fs_extra4.default.pathExists(_CommandLoader.PROCESSES_DIR))) {
1750
- 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}`);
1751
- return;
1729
+ static async loadDevelopmentProcesses(program) {
1730
+ if (!await import_fs_extra4.default.pathExists(_CommandLoader.PROCESSES_DIR)) {
1731
+ 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}`);
1732
+ return;
1733
+ }
1734
+ try {
1735
+ const processes = await this.getProcesses(_CommandLoader.PROCESSES_DIR);
1736
+ for (const processName of processes) {
1737
+ try {
1738
+ log2.debug(`\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043C \u043C\u043E\u0434\u0443\u043B\u044C: ${import_chalk11.default.cyan(processName)}`);
1739
+ const modulePath = import_node_path6.default.join(_CommandLoader.PROCESSES_DIR, processName);
1740
+ const module2 = require(modulePath);
1741
+ module2.default(program);
1742
+ } catch (err) {
1743
+ 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
1744
  }
1753
- const processes = yield this.getProcesses(_CommandLoader.PROCESSES_DIR);
1754
- for (const processName of processes) {
1745
+ }
1746
+ } catch (err) {
1747
+ 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);
1748
+ }
1749
+ try {
1750
+ await this.loadPlugins(program);
1751
+ } catch (err) {
1752
+ 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);
1753
+ }
1754
+ }
1755
+ static async loadPlugins(program) {
1756
+ const plugins = await program.getPluginPaths();
1757
+ for (const plugin of plugins) {
1758
+ log2.debug(`\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043C \u043C\u043E\u0434\u0443\u043B\u044C: ${import_chalk11.default.cyan(plugin.pkgJson.name)}`);
1759
+ const dirname = import_node_path6.default.dirname(plugin.path);
1760
+ if (false) {
1761
+ const module2 = require(`${plugin.pkgJson.name}`);
1762
+ module2.default(program);
1763
+ continue;
1764
+ }
1765
+ if (import_fs_extra4.default.existsSync(import_node_path6.default.resolve(dirname, "build", "package.json"))) {
1766
+ const buildPath = import_node_path6.default.resolve(dirname, "build");
1767
+ const buildPackageJson = require(import_node_path6.default.join(buildPath, "package.json"));
1768
+ let modulePath;
1769
+ if (buildPackageJson.exports) {
1770
+ if (typeof buildPackageJson.exports === "string") {
1771
+ modulePath = import_node_path6.default.join(buildPath, buildPackageJson.exports);
1772
+ } else if (buildPackageJson.exports["."]) {
1773
+ const defaultExport = buildPackageJson.exports["."];
1774
+ if (typeof defaultExport === "string") {
1775
+ modulePath = import_node_path6.default.join(buildPath, defaultExport);
1776
+ } else if (defaultExport.require) {
1777
+ modulePath = import_node_path6.default.join(buildPath, defaultExport.require);
1778
+ }
1779
+ }
1780
+ } else if (buildPackageJson.main) {
1781
+ modulePath = import_node_path6.default.join(buildPath, buildPackageJson.main);
1782
+ } else {
1783
+ modulePath = import_node_path6.default.join(buildPath, "index.js");
1784
+ }
1785
+ if (modulePath) {
1755
1786
  try {
1756
- log2.debug(`\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043C \u043C\u043E\u0434\u0443\u043B\u044C: ${import_chalk11.default.cyan(processName)}`);
1757
- const modulePath = import_node_path6.default.join(_CommandLoader.PROCESSES_DIR, processName);
1758
- const module2 = require(modulePath);
1759
- module2.default(program);
1760
- } catch (err) {
1761
- 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);
1787
+ const require2 = (0, import_node_module.createRequire)(__filename);
1788
+ let module2;
1789
+ if (buildPackageJson.type === "module") {
1790
+ module2 = await import(modulePath);
1791
+ } else {
1792
+ module2 = require2(modulePath);
1793
+ }
1794
+ if (typeof module2.default === "function") {
1795
+ module2.default(program);
1796
+ } else if (typeof module2 === "function") {
1797
+ module2(program);
1798
+ } else {
1799
+ 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`);
1800
+ }
1801
+ } catch (error) {
1802
+ 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
1803
  }
1804
+ } else {
1805
+ 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
1806
  }
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
1807
  }
1767
- });
1808
+ }
1768
1809
  }
1769
- static getProcesses(processesPath) {
1770
- return __async(this, null, function* () {
1771
- const files = yield import_fs_extra4.default.readdir(processesPath);
1772
- return files.filter((file) => {
1773
- const filePath = import_node_path6.default.join(processesPath, file, "index.ts");
1774
- const stat = import_fs_extra4.default.statSync(filePath);
1775
- return stat.isFile();
1776
- }).map((file) => import_node_path6.default.parse(file).name);
1777
- });
1810
+ static async getProcesses(processesPath) {
1811
+ const files = await import_fs_extra4.default.readdir(processesPath);
1812
+ return files.filter((file) => {
1813
+ const filePath = import_node_path6.default.join(processesPath, file, "index.ts");
1814
+ const stat = import_fs_extra4.default.statSync(filePath);
1815
+ return stat.isFile();
1816
+ }).map((file) => import_node_path6.default.parse(file).name);
1778
1817
  }
1779
1818
  static handleInvalidCommand(program) {
1780
1819
  program.on("command:*", () => {
@@ -1795,18 +1834,18 @@ var welcomeText = `${import_chalk12.default.green(`\u041F\u0440\u0438\u0432\u043
1795
1834
  ${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
1835
  ${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
1836
  `;
1798
- var bootstrap = () => __async(exports, null, function* () {
1837
+ var bootstrap = async () => {
1799
1838
  logger.debug("Start program");
1800
1839
  const program = new Program();
1801
1840
  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
1841
  logger.debug("Load processes");
1803
- yield CommandLoader.load(program);
1842
+ await CommandLoader.load(program);
1804
1843
  logger.debug("Loading complete");
1805
1844
  logger.debug("Parse process.argv", process.argv);
1806
- yield program.parseAsync(process.argv);
1845
+ await program.parseAsync(process.argv);
1807
1846
  if (!process.argv.slice(2).length) {
1808
1847
  program.outputHelp();
1809
1848
  }
1810
- });
1849
+ };
1811
1850
  bootstrap();
1812
1851
  //# sourceMappingURL=fox.js.map