@foxford/cli 1.3.3 → 1.4.0
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 +1 -1
- package/fox.cjs +304 -108
- package/fox.cjs.map +1 -1
- package/package.json +17 -18
- package/fox.d.cts +0 -1
- package/fox.d.ts +0 -1032
package/fox.cjs
CHANGED
|
@@ -30,11 +30,22 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
mod
|
|
31
31
|
));
|
|
32
32
|
|
|
33
|
+
// ../../node_modules/.pnpm/tsup@8.5.1_jiti@1.21.7_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js
|
|
34
|
+
var getImportMetaUrl, importMetaUrl;
|
|
35
|
+
var init_cjs_shims = __esm({
|
|
36
|
+
"../../node_modules/.pnpm/tsup@8.5.1_jiti@1.21.7_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3_yaml@2.4.5/node_modules/tsup/assets/cjs_shims.js"() {
|
|
37
|
+
"use strict";
|
|
38
|
+
getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
39
|
+
importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
33
43
|
// src/logger/index.ts
|
|
34
44
|
var import_logger, logger;
|
|
35
45
|
var init_logger = __esm({
|
|
36
46
|
"src/logger/index.ts"() {
|
|
37
47
|
"use strict";
|
|
48
|
+
init_cjs_shims();
|
|
38
49
|
import_logger = require("@foxford/logger");
|
|
39
50
|
logger = import_logger.log.getLogger("cli");
|
|
40
51
|
logger.setLevel("info");
|
|
@@ -46,6 +57,7 @@ var AbstractAction;
|
|
|
46
57
|
var init_abstract_action = __esm({
|
|
47
58
|
"src/program/abstract.action.ts"() {
|
|
48
59
|
"use strict";
|
|
60
|
+
init_cjs_shims();
|
|
49
61
|
AbstractAction = class {
|
|
50
62
|
constructor(program) {
|
|
51
63
|
this.program = program;
|
|
@@ -59,6 +71,7 @@ var AbstractCommand;
|
|
|
59
71
|
var init_abstract_command = __esm({
|
|
60
72
|
"src/program/abstract.command.ts"() {
|
|
61
73
|
"use strict";
|
|
74
|
+
init_cjs_shims();
|
|
62
75
|
AbstractCommand = class {
|
|
63
76
|
constructor(action) {
|
|
64
77
|
this.action = action;
|
|
@@ -71,6 +84,7 @@ var init_abstract_command = __esm({
|
|
|
71
84
|
var init_runner = __esm({
|
|
72
85
|
"src/lib/runners/runner.ts"() {
|
|
73
86
|
"use strict";
|
|
87
|
+
init_cjs_shims();
|
|
74
88
|
}
|
|
75
89
|
});
|
|
76
90
|
|
|
@@ -79,6 +93,7 @@ var import_node_path, import_chalk, import_fluent_ffmpeg, FFMpegRunner;
|
|
|
79
93
|
var init_ffmpeg_runner = __esm({
|
|
80
94
|
"src/lib/runners/ffmpeg.runner.ts"() {
|
|
81
95
|
"use strict";
|
|
96
|
+
init_cjs_shims();
|
|
82
97
|
import_node_path = __toESM(require("path"), 1);
|
|
83
98
|
import_chalk = __toESM(require("chalk"), 1);
|
|
84
99
|
import_fluent_ffmpeg = __toESM(require("fluent-ffmpeg"), 1);
|
|
@@ -123,6 +138,7 @@ var import_child_process, import_chalk2, ShellRunner;
|
|
|
123
138
|
var init_shell_runner = __esm({
|
|
124
139
|
"src/lib/runners/shell.runner.ts"() {
|
|
125
140
|
"use strict";
|
|
141
|
+
init_cjs_shims();
|
|
126
142
|
import_child_process = require("child_process");
|
|
127
143
|
import_chalk2 = __toESM(require("chalk"), 1);
|
|
128
144
|
ShellRunner = class {
|
|
@@ -133,8 +149,8 @@ var init_shell_runner = __esm({
|
|
|
133
149
|
async run(command, args = [], options = {}, collect = false) {
|
|
134
150
|
const spawnOptions = {
|
|
135
151
|
cwd: this.options.cwd,
|
|
136
|
-
stdio: collect ? "pipe" : "inherit",
|
|
137
152
|
shell: true,
|
|
153
|
+
stdio: collect ? "pipe" : "inherit",
|
|
138
154
|
...options
|
|
139
155
|
};
|
|
140
156
|
return new Promise((resolve, reject) => {
|
|
@@ -177,6 +193,7 @@ var NodeRunner;
|
|
|
177
193
|
var init_node_runner = __esm({
|
|
178
194
|
"src/lib/runners/node.runner.ts"() {
|
|
179
195
|
"use strict";
|
|
196
|
+
init_cjs_shims();
|
|
180
197
|
init_shell_runner();
|
|
181
198
|
NodeRunner = class extends ShellRunner {
|
|
182
199
|
constructor(options) {
|
|
@@ -191,6 +208,7 @@ var NpmRunner;
|
|
|
191
208
|
var init_npm_runner = __esm({
|
|
192
209
|
"src/lib/runners/npm.runner.ts"() {
|
|
193
210
|
"use strict";
|
|
211
|
+
init_cjs_shims();
|
|
194
212
|
init_shell_runner();
|
|
195
213
|
NpmRunner = class extends ShellRunner {
|
|
196
214
|
constructor(options) {
|
|
@@ -205,6 +223,7 @@ var PnpmRunner;
|
|
|
205
223
|
var init_pnpm_runner = __esm({
|
|
206
224
|
"src/lib/runners/pnpm.runner.ts"() {
|
|
207
225
|
"use strict";
|
|
226
|
+
init_cjs_shims();
|
|
208
227
|
init_shell_runner();
|
|
209
228
|
PnpmRunner = class extends ShellRunner {
|
|
210
229
|
constructor(options) {
|
|
@@ -228,8 +247,8 @@ function loadEnv(pkgPath) {
|
|
|
228
247
|
].filter(truthy);
|
|
229
248
|
dotenvFiles.forEach((dotenvFile) => {
|
|
230
249
|
if (import_fs_extra.default.existsSync(dotenvFile)) {
|
|
231
|
-
import_dotenv_expand.
|
|
232
|
-
import_dotenv.
|
|
250
|
+
(0, import_dotenv_expand.expand)(
|
|
251
|
+
(0, import_dotenv.config)({
|
|
233
252
|
path: dotenvFile
|
|
234
253
|
})
|
|
235
254
|
);
|
|
@@ -241,9 +260,10 @@ var import_node_path2, import_dotenv, import_dotenv_expand, import_fs_extra;
|
|
|
241
260
|
var init_env = __esm({
|
|
242
261
|
"src/helpers/env.ts"() {
|
|
243
262
|
"use strict";
|
|
263
|
+
init_cjs_shims();
|
|
244
264
|
import_node_path2 = __toESM(require("path"), 1);
|
|
245
|
-
import_dotenv =
|
|
246
|
-
import_dotenv_expand =
|
|
265
|
+
import_dotenv = require("dotenv");
|
|
266
|
+
import_dotenv_expand = require("dotenv-expand");
|
|
247
267
|
import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
248
268
|
}
|
|
249
269
|
});
|
|
@@ -253,6 +273,7 @@ var label;
|
|
|
253
273
|
var init_logger2 = __esm({
|
|
254
274
|
"src/helpers/logger.ts"() {
|
|
255
275
|
"use strict";
|
|
276
|
+
init_cjs_shims();
|
|
256
277
|
label = (chalk13, label2) => chalk13.black(` ${label2} `);
|
|
257
278
|
}
|
|
258
279
|
});
|
|
@@ -262,6 +283,7 @@ var import_chalk3, getLabel, getFailLabel, ScriptRunner;
|
|
|
262
283
|
var init_script_runner = __esm({
|
|
263
284
|
"src/lib/runners/script.runner.ts"() {
|
|
264
285
|
"use strict";
|
|
286
|
+
init_cjs_shims();
|
|
265
287
|
import_chalk3 = __toESM(require("chalk"), 1);
|
|
266
288
|
init_pnpm_runner();
|
|
267
289
|
init_env();
|
|
@@ -302,8 +324,8 @@ var init_script_runner = __esm({
|
|
|
302
324
|
}
|
|
303
325
|
const pnpmRunner = new PnpmRunner();
|
|
304
326
|
pnpmRunner.run("run", [`--filter ${pkg.localName}`, script], {
|
|
305
|
-
|
|
306
|
-
|
|
327
|
+
cwd: pkg.path,
|
|
328
|
+
env: Object.assign(process.env, { FORCE_COLOR: "1" })
|
|
307
329
|
});
|
|
308
330
|
}
|
|
309
331
|
};
|
|
@@ -315,6 +337,7 @@ var import_chalk4, import_tinify, TinyPngRunner;
|
|
|
315
337
|
var init_tinypng_runner = __esm({
|
|
316
338
|
"src/lib/runners/tinypng.runner.ts"() {
|
|
317
339
|
"use strict";
|
|
340
|
+
init_cjs_shims();
|
|
318
341
|
import_chalk4 = __toESM(require("chalk"), 1);
|
|
319
342
|
import_tinify = __toESM(require("tinify"), 1);
|
|
320
343
|
TinyPngRunner = class {
|
|
@@ -344,6 +367,7 @@ var RunnerMap, RunnerFactory;
|
|
|
344
367
|
var init_runner_factory = __esm({
|
|
345
368
|
"src/lib/runners/runner.factory.ts"() {
|
|
346
369
|
"use strict";
|
|
370
|
+
init_cjs_shims();
|
|
347
371
|
init_ffmpeg_runner();
|
|
348
372
|
init_node_runner();
|
|
349
373
|
init_npm_runner();
|
|
@@ -375,23 +399,29 @@ var init_runner_factory = __esm({
|
|
|
375
399
|
var init_runners = __esm({
|
|
376
400
|
"src/lib/runners/index.ts"() {
|
|
377
401
|
"use strict";
|
|
402
|
+
init_cjs_shims();
|
|
378
403
|
init_runner();
|
|
379
404
|
init_runner_factory();
|
|
380
405
|
}
|
|
381
406
|
});
|
|
382
407
|
|
|
383
408
|
// src/program/program.ts
|
|
384
|
-
var import_node_path3, import_commander, import_dotenv2,
|
|
409
|
+
var import_fs, import_node_module, import_node_path3, import_node_url, import_commander, import_dotenv2, import_zx, require2, __dirname, Program;
|
|
385
410
|
var init_program = __esm({
|
|
386
411
|
"src/program/program.ts"() {
|
|
387
412
|
"use strict";
|
|
413
|
+
init_cjs_shims();
|
|
414
|
+
import_fs = require("fs");
|
|
415
|
+
import_node_module = require("module");
|
|
388
416
|
import_node_path3 = __toESM(require("path"), 1);
|
|
417
|
+
import_node_url = require("url");
|
|
389
418
|
import_commander = require("commander");
|
|
390
|
-
import_dotenv2 =
|
|
391
|
-
import_fs_extra2 = require("fs-extra");
|
|
419
|
+
import_dotenv2 = require("dotenv");
|
|
392
420
|
import_zx = require("zx");
|
|
393
421
|
init_runners();
|
|
394
422
|
init_logger();
|
|
423
|
+
require2 = (0, import_node_module.createRequire)(importMetaUrl);
|
|
424
|
+
__dirname = import_node_path3.default.dirname((0, import_node_url.fileURLToPath)(importMetaUrl));
|
|
395
425
|
Program = class _Program extends import_commander.Command {
|
|
396
426
|
constructor(packageManager, rootPath) {
|
|
397
427
|
super();
|
|
@@ -405,8 +435,8 @@ var init_program = __esm({
|
|
|
405
435
|
import_node_path3.default.resolve(__dirname, "../.env")
|
|
406
436
|
];
|
|
407
437
|
dotenvFiles.forEach((dotenvFile) => {
|
|
408
|
-
if ((0,
|
|
409
|
-
import_dotenv2.
|
|
438
|
+
if ((0, import_fs.existsSync)(dotenvFile)) {
|
|
439
|
+
(0, import_dotenv2.config)({
|
|
410
440
|
path: dotenvFile
|
|
411
441
|
});
|
|
412
442
|
}
|
|
@@ -448,7 +478,7 @@ var init_program = __esm({
|
|
|
448
478
|
if (name === packageJson.name) continue;
|
|
449
479
|
let packageDir = null;
|
|
450
480
|
try {
|
|
451
|
-
const packagePath =
|
|
481
|
+
const packagePath = require2.resolve(name, { paths: [this.rootPath] });
|
|
452
482
|
packageDir = import_node_path3.default.dirname(packagePath);
|
|
453
483
|
} catch {
|
|
454
484
|
}
|
|
@@ -500,6 +530,7 @@ var init_program = __esm({
|
|
|
500
530
|
var init_program2 = __esm({
|
|
501
531
|
"src/program/index.ts"() {
|
|
502
532
|
"use strict";
|
|
533
|
+
init_cjs_shims();
|
|
503
534
|
init_abstract_action();
|
|
504
535
|
init_abstract_command();
|
|
505
536
|
init_program();
|
|
@@ -511,6 +542,7 @@ var BANNER;
|
|
|
511
542
|
var init_banner = __esm({
|
|
512
543
|
"src/lib/ui/banner.ts"() {
|
|
513
544
|
"use strict";
|
|
545
|
+
init_cjs_shims();
|
|
514
546
|
BANNER = `
|
|
515
547
|
\xB7\u2584\u2584\u2584 \u2590\u2584\u2022 \u2584 \xB7\u2584\u2584\u2584 \u2584\u2584\u2584 \xB7\u2584\u2584\u2584\u2584
|
|
516
548
|
\u2590\u2584\u2584\xB7\u25AA \u2588\u258C\u2588\u258C\u25AA\u2590\u2584\u2584\xB7\u25AA \u2580\u2584 \u2588\xB7\u2588\u2588\u25AA \u2588\u2588
|
|
@@ -526,6 +558,7 @@ var import_chalk5, ERROR_PREFIX, INFO_PREFIX;
|
|
|
526
558
|
var init_prefixes = __esm({
|
|
527
559
|
"src/lib/ui/prefixes.ts"() {
|
|
528
560
|
"use strict";
|
|
561
|
+
init_cjs_shims();
|
|
529
562
|
import_chalk5 = __toESM(require("chalk"), 1);
|
|
530
563
|
ERROR_PREFIX = import_chalk5.default.bgRgb(210, 0, 75).bold.rgb(0, 0, 0)(" Error ");
|
|
531
564
|
INFO_PREFIX = import_chalk5.default.bgRgb(60, 190, 100).bold.rgb(0, 0, 0)(" Info ");
|
|
@@ -536,6 +569,7 @@ var init_prefixes = __esm({
|
|
|
536
569
|
var init_ui = __esm({
|
|
537
570
|
"src/lib/ui/index.ts"() {
|
|
538
571
|
"use strict";
|
|
572
|
+
init_cjs_shims();
|
|
539
573
|
init_banner();
|
|
540
574
|
init_prefixes();
|
|
541
575
|
}
|
|
@@ -546,6 +580,7 @@ var CodemodAction;
|
|
|
546
580
|
var init_action = __esm({
|
|
547
581
|
"src/processes/codemod/action.ts"() {
|
|
548
582
|
"use strict";
|
|
583
|
+
init_cjs_shims();
|
|
549
584
|
init_runners();
|
|
550
585
|
init_program2();
|
|
551
586
|
CodemodAction = class extends AbstractAction {
|
|
@@ -572,6 +607,7 @@ var init_action = __esm({
|
|
|
572
607
|
var init_collection = __esm({
|
|
573
608
|
"src/lib/collection/collection.ts"() {
|
|
574
609
|
"use strict";
|
|
610
|
+
init_cjs_shims();
|
|
575
611
|
}
|
|
576
612
|
});
|
|
577
613
|
|
|
@@ -580,6 +616,7 @@ var AbstractCollection;
|
|
|
580
616
|
var init_abstract_collection = __esm({
|
|
581
617
|
"src/lib/collection/abstract.collection.ts"() {
|
|
582
618
|
"use strict";
|
|
619
|
+
init_cjs_shims();
|
|
583
620
|
AbstractCollection = class {
|
|
584
621
|
constructor(collection) {
|
|
585
622
|
this.collection = collection;
|
|
@@ -600,17 +637,19 @@ function normalizeToKebabOrSnakeCase(str) {
|
|
|
600
637
|
var init_formatting = __esm({
|
|
601
638
|
"src/lib/utils/formatting.ts"() {
|
|
602
639
|
"use strict";
|
|
640
|
+
init_cjs_shims();
|
|
603
641
|
}
|
|
604
642
|
});
|
|
605
643
|
|
|
606
644
|
// src/lib/collection/fox-codemod.collection.ts
|
|
607
|
-
var import_node_path4, import_chalk6,
|
|
645
|
+
var import_node_path4, import_chalk6, import_fs_extra2, FoxCodemodCollection;
|
|
608
646
|
var init_fox_codemod_collection = __esm({
|
|
609
647
|
"src/lib/collection/fox-codemod.collection.ts"() {
|
|
610
648
|
"use strict";
|
|
649
|
+
init_cjs_shims();
|
|
611
650
|
import_node_path4 = __toESM(require("path"), 1);
|
|
612
651
|
import_chalk6 = __toESM(require("chalk"), 1);
|
|
613
|
-
|
|
652
|
+
import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
614
653
|
init_abstract_collection();
|
|
615
654
|
init_collection();
|
|
616
655
|
init_formatting();
|
|
@@ -630,7 +669,7 @@ var init_fox_codemod_collection = __esm({
|
|
|
630
669
|
process.exit(1);
|
|
631
670
|
}
|
|
632
671
|
const collectionPath = import_node_path4.default.join(import_node_path4.default.dirname(pathCollection), pkgJson.codemods ?? "");
|
|
633
|
-
if (!
|
|
672
|
+
if (!import_fs_extra2.default.existsSync(collectionPath)) {
|
|
634
673
|
console.log(
|
|
635
674
|
import_chalk6.default.red('Collection path specified in "codemods" section in your package.json is not valid: ', collectionPath)
|
|
636
675
|
);
|
|
@@ -664,6 +703,7 @@ var CollectionFactory;
|
|
|
664
703
|
var init_collection_factory = __esm({
|
|
665
704
|
"src/lib/collection/collection.factory.ts"() {
|
|
666
705
|
"use strict";
|
|
706
|
+
init_cjs_shims();
|
|
667
707
|
init_collection();
|
|
668
708
|
init_fox_codemod_collection();
|
|
669
709
|
CollectionFactory = class {
|
|
@@ -681,6 +721,7 @@ var init_collection_factory = __esm({
|
|
|
681
721
|
var init_collection2 = __esm({
|
|
682
722
|
"src/lib/collection/index.ts"() {
|
|
683
723
|
"use strict";
|
|
724
|
+
init_cjs_shims();
|
|
684
725
|
init_collection_factory();
|
|
685
726
|
init_collection();
|
|
686
727
|
init_abstract_collection();
|
|
@@ -692,6 +733,7 @@ var import_chalk7, import_cli_table3, import_commander2, CodemodCommand;
|
|
|
692
733
|
var init_command = __esm({
|
|
693
734
|
"src/processes/codemod/command.ts"() {
|
|
694
735
|
"use strict";
|
|
736
|
+
init_cjs_shims();
|
|
695
737
|
import_chalk7 = __toESM(require("chalk"), 1);
|
|
696
738
|
import_cli_table3 = __toESM(require("cli-table3"), 1);
|
|
697
739
|
import_commander2 = require("commander");
|
|
@@ -761,16 +803,16 @@ ${import_chalk7.default.greenBright(
|
|
|
761
803
|
buildSchematicsListAsTable(items) {
|
|
762
804
|
const leftMargin = " ";
|
|
763
805
|
const tableConfig = {
|
|
764
|
-
head: ["name", "description"],
|
|
765
806
|
chars: {
|
|
766
|
-
left: leftMargin.concat("\u2502"),
|
|
767
|
-
"top-left": leftMargin.concat("\u250C"),
|
|
768
807
|
"bottom-left": leftMargin.concat("\u2514"),
|
|
769
|
-
|
|
808
|
+
left: leftMargin.concat("\u2502"),
|
|
770
809
|
"left-mid": "",
|
|
810
|
+
mid: "",
|
|
771
811
|
"mid-mid": "",
|
|
772
|
-
"right-mid": ""
|
|
773
|
-
|
|
812
|
+
"right-mid": "",
|
|
813
|
+
"top-left": leftMargin.concat("\u250C")
|
|
814
|
+
},
|
|
815
|
+
head: ["name", "description"]
|
|
774
816
|
};
|
|
775
817
|
const table = new import_cli_table3.default(tableConfig);
|
|
776
818
|
for (const item of items) {
|
|
@@ -807,6 +849,7 @@ var codemod_default;
|
|
|
807
849
|
var init_codemod = __esm({
|
|
808
850
|
"src/processes/codemod/index.ts"() {
|
|
809
851
|
"use strict";
|
|
852
|
+
init_cjs_shims();
|
|
810
853
|
init_action();
|
|
811
854
|
init_command();
|
|
812
855
|
codemod_default = (program) => {
|
|
@@ -815,13 +858,31 @@ var init_codemod = __esm({
|
|
|
815
858
|
}
|
|
816
859
|
});
|
|
817
860
|
|
|
861
|
+
// src/utils/versioning.ts
|
|
862
|
+
function getBetaPackageVersion(version, sha) {
|
|
863
|
+
const now = /* @__PURE__ */ new Date();
|
|
864
|
+
const year = now.getFullYear();
|
|
865
|
+
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
866
|
+
const day = String(now.getDate()).padStart(2, "0");
|
|
867
|
+
const date = `${year}${month}${day}`;
|
|
868
|
+
return `${version}-beta-${sha}-${date}`;
|
|
869
|
+
}
|
|
870
|
+
var init_versioning = __esm({
|
|
871
|
+
"src/utils/versioning.ts"() {
|
|
872
|
+
"use strict";
|
|
873
|
+
init_cjs_shims();
|
|
874
|
+
}
|
|
875
|
+
});
|
|
876
|
+
|
|
818
877
|
// src/processes/deploy/providers/abstract.provider.ts
|
|
819
878
|
var import_zx2, DeployProvider;
|
|
820
879
|
var init_abstract_provider = __esm({
|
|
821
880
|
"src/processes/deploy/providers/abstract.provider.ts"() {
|
|
822
881
|
"use strict";
|
|
882
|
+
init_cjs_shims();
|
|
823
883
|
import_zx2 = require("zx");
|
|
824
884
|
init_logger();
|
|
885
|
+
init_versioning();
|
|
825
886
|
DeployProvider = class {
|
|
826
887
|
constructor(providerName) {
|
|
827
888
|
this.providerName = providerName;
|
|
@@ -830,22 +891,16 @@ var init_abstract_provider = __esm({
|
|
|
830
891
|
this.buildDir = "./build";
|
|
831
892
|
}
|
|
832
893
|
/**
|
|
833
|
-
* Генерирует строку
|
|
894
|
+
* Генерирует строку бета-версии пакета на основе SHA коммита и текущей даты.
|
|
895
|
+
*
|
|
896
|
+
* Делегирует вызов утилитной функции {@link getBetaPackageVersion} для обратной совместимости.
|
|
834
897
|
*
|
|
835
898
|
* @param version - Версия пакета из package.json
|
|
836
|
-
* @param sha - Короткий SHA коммита, используемый в строке
|
|
837
|
-
* @returns
|
|
838
|
-
* Для цели 'latest' возвращает текущую версию пакета.
|
|
839
|
-
* Для цели 'beta' возвращает строку версии в формате:
|
|
840
|
-
* "<текущая_версия>-beta-<sha>-<текущая_дата>"
|
|
899
|
+
* @param sha - Короткий SHA коммита, используемый в строке бета-версии
|
|
900
|
+
* @returns Строка версии в формате `<version>-beta-<sha>-<YYYYMMDD>`
|
|
841
901
|
*/
|
|
842
902
|
getBetaPackageVersion(version, sha) {
|
|
843
|
-
|
|
844
|
-
const year = now.getFullYear();
|
|
845
|
-
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
846
|
-
const day = String(now.getDate()).padStart(2, "0");
|
|
847
|
-
const date = `${year}${month}${day}`;
|
|
848
|
-
return `${version}-beta-${sha}-${date}`;
|
|
903
|
+
return getBetaPackageVersion(version, sha);
|
|
849
904
|
}
|
|
850
905
|
/**
|
|
851
906
|
* Читает и парсит файл package.json из текущей рабочей директории.
|
|
@@ -872,6 +927,79 @@ var init_abstract_provider = __esm({
|
|
|
872
927
|
}
|
|
873
928
|
});
|
|
874
929
|
|
|
930
|
+
// src/processes/deploy/utils/resolve-workspace-deps.ts
|
|
931
|
+
function hasWorkspaceOrCatalogDeps(packageJson) {
|
|
932
|
+
for (const section of DEP_SECTIONS) {
|
|
933
|
+
const deps = packageJson[section];
|
|
934
|
+
if (!deps) continue;
|
|
935
|
+
for (const version of Object.values(deps)) {
|
|
936
|
+
if (version.startsWith("workspace:") || version.startsWith("catalog:")) {
|
|
937
|
+
return true;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
return false;
|
|
942
|
+
}
|
|
943
|
+
async function resolveWorkspaceAndCatalogDeps(packageJson, options) {
|
|
944
|
+
if (!hasWorkspaceOrCatalogDeps(packageJson)) return;
|
|
945
|
+
const { target, commitSha, affected = [], workspaceRoot, packageDir } = options;
|
|
946
|
+
const workspaceDeps = /* @__PURE__ */ new Map();
|
|
947
|
+
for (const section of DEP_SECTIONS) {
|
|
948
|
+
const deps = packageJson[section];
|
|
949
|
+
if (!deps) continue;
|
|
950
|
+
const sectionMap = /* @__PURE__ */ new Map();
|
|
951
|
+
for (const [depName, spec] of Object.entries(deps)) {
|
|
952
|
+
if (spec.startsWith("workspace:")) {
|
|
953
|
+
sectionMap.set(depName, spec);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
if (sectionMap.size > 0) {
|
|
957
|
+
workspaceDeps.set(section, sectionMap);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
const workspaceManifest = await (0, import_workspace.readWorkspaceManifest)(workspaceRoot);
|
|
961
|
+
if (workspaceManifest === null) {
|
|
962
|
+
throw new Error(`pnpm-workspace.yaml \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D \u0432 \u0434\u0438\u0440\u0435\u043A\u0442\u043E\u0440\u0438\u0438: ${workspaceRoot}`);
|
|
963
|
+
}
|
|
964
|
+
const catalogs = (0, import_catalogs.getCatalogsFromWorkspaceManifest)(workspaceManifest);
|
|
965
|
+
const resolved = await (0, import_exportable_manifest.createExportableManifest)(packageDir, packageJson, {
|
|
966
|
+
catalogs
|
|
967
|
+
});
|
|
968
|
+
for (const section of DEP_SECTIONS) {
|
|
969
|
+
if (resolved[section] != null) {
|
|
970
|
+
packageJson[section] = resolved[section];
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
if (target === "beta" && affected.length > 0) {
|
|
974
|
+
for (const section of DEP_SECTIONS) {
|
|
975
|
+
const deps = packageJson[section];
|
|
976
|
+
if (!deps) continue;
|
|
977
|
+
const originalSpecs = workspaceDeps.get(section);
|
|
978
|
+
if (!originalSpecs) continue;
|
|
979
|
+
for (const depName of Object.keys(deps)) {
|
|
980
|
+
if (!affected.includes(depName)) continue;
|
|
981
|
+
if (!originalSpecs.has(depName)) continue;
|
|
982
|
+
const resolvedVersion = deps[depName];
|
|
983
|
+
const prefix = resolvedVersion.startsWith("^") ? "^" : resolvedVersion.startsWith("~") ? "~" : "";
|
|
984
|
+
const baseVersion = resolvedVersion.slice(prefix.length);
|
|
985
|
+
deps[depName] = `${prefix}${getBetaPackageVersion(baseVersion, commitSha)}`;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
var import_catalogs, import_exportable_manifest, import_workspace, DEP_SECTIONS;
|
|
991
|
+
var init_resolve_workspace_deps = __esm({
|
|
992
|
+
"src/processes/deploy/utils/resolve-workspace-deps.ts"() {
|
|
993
|
+
"use strict";
|
|
994
|
+
init_cjs_shims();
|
|
995
|
+
import_catalogs = require("@pnpm/catalogs.config");
|
|
996
|
+
import_exportable_manifest = require("@pnpm/exportable-manifest");
|
|
997
|
+
import_workspace = require("@pnpm/workspace.read-manifest");
|
|
998
|
+
init_versioning();
|
|
999
|
+
DEP_SECTIONS = ["dependencies", "peerDependencies", "optionalDependencies"];
|
|
1000
|
+
}
|
|
1001
|
+
});
|
|
1002
|
+
|
|
875
1003
|
// src/processes/deploy/providers/npm.ts
|
|
876
1004
|
function sleep(ms) {
|
|
877
1005
|
if (false) {
|
|
@@ -883,9 +1011,11 @@ var import_zx3, NpmDeploy;
|
|
|
883
1011
|
var init_npm = __esm({
|
|
884
1012
|
"src/processes/deploy/providers/npm.ts"() {
|
|
885
1013
|
"use strict";
|
|
1014
|
+
init_cjs_shims();
|
|
886
1015
|
import_zx3 = require("zx");
|
|
887
1016
|
init_abstract_provider();
|
|
888
1017
|
init_logger();
|
|
1018
|
+
init_resolve_workspace_deps();
|
|
889
1019
|
NpmDeploy = class extends DeployProvider {
|
|
890
1020
|
constructor() {
|
|
891
1021
|
super("npm");
|
|
@@ -944,18 +1074,30 @@ var init_npm = __esm({
|
|
|
944
1074
|
* указанного в файле package.json. Затем он парсит JSON-ответ
|
|
945
1075
|
* и сохраняет результат в свойстве `versionLists` класса.
|
|
946
1076
|
*
|
|
1077
|
+
* Если пакет ещё не опубликован в npm (HTTP 404), метод возвращает пустой
|
|
1078
|
+
* массив и логирует информационное сообщение — процесс деплоя продолжается
|
|
1079
|
+
* без очистки beta-версий.
|
|
1080
|
+
*
|
|
947
1081
|
* @param pkgName - Имя пакета в регистре.
|
|
948
1082
|
*
|
|
949
1083
|
* @returns Промис, который разрешается в массив строк, где каждая строка
|
|
950
|
-
* представляет версию пакета. Если
|
|
951
|
-
* пустой массив.
|
|
952
|
-
*
|
|
953
|
-
* @throws Записывает ошибку в консоль, если парсинг JSON не удался, но не
|
|
954
|
-
* выбрасывает исключение.
|
|
1084
|
+
* представляет версию пакета. Если пакет не найден или парсинг
|
|
1085
|
+
* не удался, возвращает пустой массив.
|
|
955
1086
|
*/
|
|
956
1087
|
async getVersionsList(pkgName) {
|
|
957
1088
|
logger.info("Getting versions list...");
|
|
958
|
-
|
|
1089
|
+
let outputProcess;
|
|
1090
|
+
try {
|
|
1091
|
+
outputProcess = await import_zx3.$`npm view ${pkgName} versions --json`;
|
|
1092
|
+
} catch (error) {
|
|
1093
|
+
const errorText = String(error);
|
|
1094
|
+
if (errorText.includes("E404")) {
|
|
1095
|
+
logger.info(`\u041F\u0430\u043A\u0435\u0442 ${pkgName} \u0435\u0449\u0451 \u043D\u0435 \u043E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u043D \u0432 npm, \u043F\u0440\u043E\u043F\u0443\u0441\u043A\u0430\u0435\u043C \u043E\u0447\u0438\u0441\u0442\u043A\u0443 beta-\u0432\u0435\u0440\u0441\u0438\u0439`);
|
|
1096
|
+
} else {
|
|
1097
|
+
logger.warn(`\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u043E\u043B\u0443\u0447\u0438\u0442\u044C \u0441\u043F\u0438\u0441\u043E\u043A \u0432\u0435\u0440\u0441\u0438\u0439: ${errorText}`);
|
|
1098
|
+
}
|
|
1099
|
+
return [];
|
|
1100
|
+
}
|
|
959
1101
|
const versionsListPo = outputProcess.toString();
|
|
960
1102
|
logger.info("Versions list recieved", versionsListPo);
|
|
961
1103
|
try {
|
|
@@ -1064,16 +1206,22 @@ var init_npm = __esm({
|
|
|
1064
1206
|
* обновление package.json, публикацию npm и пост-публикационные действия, такие как пометка
|
|
1065
1207
|
* предыдущих версий как устаревших или удаление бета-версий.
|
|
1066
1208
|
*
|
|
1209
|
+
* Если в package.json присутствуют зависимости с префиксами `workspace:` или `catalog:`,
|
|
1210
|
+
* они автоматически резолвятся в конкретные версии перед публикацией.
|
|
1211
|
+
*
|
|
1067
1212
|
* @param params - Параметры развертывания.
|
|
1068
1213
|
* @param params.dry - Если true, выполняет пробный запуск без фактической публикации.
|
|
1069
1214
|
* @param params.target - Цель развертывания, либо 'beta', либо 'latest'. По умолчанию 'beta'.
|
|
1215
|
+
* @param params.affected - Comma-separated список пакетов, публикуемых в текущем цикле.
|
|
1216
|
+
* Используется для резолва бета-версий workspace-зависимостей при target=beta.
|
|
1070
1217
|
*
|
|
1071
1218
|
* @throws Завершает процесс, если директория сборки не найдена.
|
|
1072
1219
|
* @returns Промис, который разрешается, когда процесс развертывания завершен.
|
|
1073
1220
|
*/
|
|
1074
1221
|
async deploy(params) {
|
|
1075
1222
|
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);
|
|
1076
|
-
const
|
|
1223
|
+
const packageDir = process.cwd();
|
|
1224
|
+
const localDir = import_zx3.path.join(packageDir, params.localDir ?? this.buildDir);
|
|
1077
1225
|
if (!import_zx3.fs.existsSync(localDir)) {
|
|
1078
1226
|
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`);
|
|
1079
1227
|
process.exit(1);
|
|
@@ -1109,6 +1257,25 @@ var init_npm = __esm({
|
|
|
1109
1257
|
if (packageJson.devDependencies) {
|
|
1110
1258
|
delete packageJson.devDependencies;
|
|
1111
1259
|
}
|
|
1260
|
+
if (hasWorkspaceOrCatalogDeps(packageJson)) {
|
|
1261
|
+
logger.info("\u041E\u0431\u043D\u0430\u0440\u0443\u0436\u0435\u043D\u044B workspace/catalog \u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u0438, \u0437\u0430\u043F\u0443\u0441\u043A\u0430\u0435\u043C \u0440\u0435\u0437\u043E\u043B\u0432...");
|
|
1262
|
+
if (params.packageManager !== "pnpm") {
|
|
1263
|
+
logger.error(
|
|
1264
|
+
`\u0420\u0435\u0437\u043E\u043B\u0432 workspace: \u0438 catalog: \u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u0435\u0439 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044F \u0442\u043E\u043B\u044C\u043A\u043E \u043F\u0440\u0438 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0438 pnpm. \u0422\u0435\u043A\u0443\u0449\u0438\u0439 packageManager: "${params.packageManager ?? "\u043D\u0435 \u043E\u043F\u0440\u0435\u0434\u0435\u043B\u0451\u043D"}". \u0418\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 pnpm \u0434\u043B\u044F \u043F\u0443\u0431\u043B\u0438\u043A\u0430\u0446\u0438\u0438 \u043F\u0430\u043A\u0435\u0442\u043E\u0432 \u0441 workspace/catalog \u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u044F\u043C\u0438.`
|
|
1265
|
+
);
|
|
1266
|
+
process.exit(1);
|
|
1267
|
+
}
|
|
1268
|
+
const workspaceRoot = (await import_zx3.$`git rev-parse --show-toplevel`).toString().trim();
|
|
1269
|
+
const affectedPackages = params.affected ? params.affected.split(",").map((s) => s.trim()) : void 0;
|
|
1270
|
+
await resolveWorkspaceAndCatalogDeps(packageJson, {
|
|
1271
|
+
affected: affectedPackages,
|
|
1272
|
+
commitSha,
|
|
1273
|
+
packageDir,
|
|
1274
|
+
target,
|
|
1275
|
+
workspaceRoot
|
|
1276
|
+
});
|
|
1277
|
+
logger.info("Workspace/catalog \u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u0438 \u0437\u0430\u0440\u0435\u0437\u043E\u043B\u0432\u043B\u0435\u043D\u044B", packageJson);
|
|
1278
|
+
}
|
|
1112
1279
|
logger.info("\u041F\u0443\u0431\u043B\u0438\u043A\u0443\u0435\u043C\u044B\u0439 package.json", packageJson);
|
|
1113
1280
|
await import_zx3.fs.writeJson("package.json", packageJson, {
|
|
1114
1281
|
spaces: 2
|
|
@@ -1138,6 +1305,7 @@ var import_zx4, S3Deploy;
|
|
|
1138
1305
|
var init_s3 = __esm({
|
|
1139
1306
|
"src/processes/deploy/providers/s3.ts"() {
|
|
1140
1307
|
"use strict";
|
|
1308
|
+
init_cjs_shims();
|
|
1141
1309
|
import_zx4 = require("zx");
|
|
1142
1310
|
init_abstract_provider();
|
|
1143
1311
|
init_logger();
|
|
@@ -1317,6 +1485,7 @@ var DeployAction;
|
|
|
1317
1485
|
var init_action2 = __esm({
|
|
1318
1486
|
"src/processes/deploy/action.ts"() {
|
|
1319
1487
|
"use strict";
|
|
1488
|
+
init_cjs_shims();
|
|
1320
1489
|
init_program2();
|
|
1321
1490
|
init_npm();
|
|
1322
1491
|
init_s3();
|
|
@@ -1344,6 +1513,7 @@ var import_commander3, DeployCommand;
|
|
|
1344
1513
|
var init_command2 = __esm({
|
|
1345
1514
|
"src/processes/deploy/command.ts"() {
|
|
1346
1515
|
"use strict";
|
|
1516
|
+
init_cjs_shims();
|
|
1347
1517
|
import_commander3 = require("commander");
|
|
1348
1518
|
init_program2();
|
|
1349
1519
|
DeployCommand = class extends AbstractCommand {
|
|
@@ -1364,13 +1534,20 @@ var init_command2 = __esm({
|
|
|
1364
1534
|
s3Command.addOption(localDirOption);
|
|
1365
1535
|
s3Command.addOption(dryOption);
|
|
1366
1536
|
s3Command.addOption(verboseOption);
|
|
1367
|
-
const
|
|
1368
|
-
|
|
1537
|
+
const skipGitChecksOption = new import_commander3.Option("--skip-git-checks", "\u041E\u0442\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0435 git \u043F\u0440\u043E\u0432\u0435\u0440\u043E\u043A \u043F\u0440\u0438 \u043F\u0443\u0431\u043B\u0438\u043A\u0430\u0446\u0438\u0438");
|
|
1538
|
+
const affectedOption = new import_commander3.Option(
|
|
1539
|
+
"--affected <packages>",
|
|
1540
|
+
"Comma-separated \u0441\u043F\u0438\u0441\u043E\u043A affected-\u043F\u0430\u043A\u0435\u0442\u043E\u0432, \u043F\u0443\u0431\u043B\u0438\u043A\u0443\u0435\u043C\u044B\u0445 \u0432 \u0442\u0435\u043A\u0443\u0449\u0435\u043C \u0446\u0438\u043A\u043B\u0435 (\u0434\u043B\u044F \u0440\u0435\u0437\u043E\u043B\u0432\u0430 \u0431\u0435\u0442\u0430-\u0432\u0435\u0440\u0441\u0438\u0439 workspace-\u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u0435\u0439)"
|
|
1541
|
+
);
|
|
1542
|
+
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) => {
|
|
1543
|
+
await this.action.handle({ ...params, packageManager: program.packageManager, provider: "npm" });
|
|
1369
1544
|
});
|
|
1370
1545
|
npmCommand.addOption(targetOption);
|
|
1371
1546
|
npmCommand.addOption(localDirOption);
|
|
1372
1547
|
npmCommand.addOption(dryOption);
|
|
1373
1548
|
npmCommand.addOption(verboseOption);
|
|
1549
|
+
npmCommand.addOption(skipGitChecksOption);
|
|
1550
|
+
npmCommand.addOption(affectedOption);
|
|
1374
1551
|
deployCommand.addCommand(s3Command);
|
|
1375
1552
|
deployCommand.addCommand(npmCommand);
|
|
1376
1553
|
program.addCommand(deployCommand);
|
|
@@ -1388,6 +1565,7 @@ var deploy_default;
|
|
|
1388
1565
|
var init_deploy = __esm({
|
|
1389
1566
|
"src/processes/deploy/index.ts"() {
|
|
1390
1567
|
"use strict";
|
|
1568
|
+
init_cjs_shims();
|
|
1391
1569
|
init_action2();
|
|
1392
1570
|
init_command2();
|
|
1393
1571
|
deploy_default = (program) => {
|
|
@@ -1401,10 +1579,11 @@ var import_os, import_chalk8, import_filesize, import_systeminformation, import_
|
|
|
1401
1579
|
var init_action3 = __esm({
|
|
1402
1580
|
"src/processes/info/action.ts"() {
|
|
1403
1581
|
"use strict";
|
|
1582
|
+
init_cjs_shims();
|
|
1404
1583
|
import_os = require("os");
|
|
1405
1584
|
import_chalk8 = __toESM(require("chalk"), 1);
|
|
1406
1585
|
import_filesize = require("filesize");
|
|
1407
|
-
import_systeminformation =
|
|
1586
|
+
import_systeminformation = require("systeminformation");
|
|
1408
1587
|
import_zx5 = require("zx");
|
|
1409
1588
|
init_ui();
|
|
1410
1589
|
init_program2();
|
|
@@ -1428,15 +1607,15 @@ var init_action3 = __esm({
|
|
|
1428
1607
|
console.info("NVM_DIR :", import_chalk8.default.blue(process.env.NVM_DIR));
|
|
1429
1608
|
}
|
|
1430
1609
|
console.log();
|
|
1431
|
-
const
|
|
1432
|
-
const
|
|
1433
|
-
console.info("CPU Family:", import_chalk8.default.blue(`${
|
|
1434
|
-
console.info("CPU Ph Cores:", import_chalk8.default.blue(
|
|
1435
|
-
console.info("CPU Speed:", import_chalk8.default.blue(`${
|
|
1436
|
-
console.info("Memory:", import_chalk8.default.blue(`${(0, import_filesize.filesize)(
|
|
1437
|
-
console.info("Memory Free:", import_chalk8.default.blue(`${(0, import_filesize.filesize)(
|
|
1438
|
-
console.info("Memory Used:", import_chalk8.default.blue(`${(0, import_filesize.filesize)(
|
|
1439
|
-
console.info("Memory Available:", import_chalk8.default.blue(`${(0, import_filesize.filesize)(
|
|
1610
|
+
const cpuDevice = await (0, import_systeminformation.cpu)();
|
|
1611
|
+
const memDevice = await (0, import_systeminformation.mem)();
|
|
1612
|
+
console.info("CPU Family:", import_chalk8.default.blue(`${cpuDevice.vendor} ${cpuDevice.brand}`));
|
|
1613
|
+
console.info("CPU Ph Cores:", import_chalk8.default.blue(cpuDevice.cores));
|
|
1614
|
+
console.info("CPU Speed:", import_chalk8.default.blue(`${cpuDevice.speed}GHz`));
|
|
1615
|
+
console.info("Memory:", import_chalk8.default.blue(`${(0, import_filesize.filesize)(memDevice.total)}`));
|
|
1616
|
+
console.info("Memory Free:", import_chalk8.default.blue(`${(0, import_filesize.filesize)(memDevice.free)}`));
|
|
1617
|
+
console.info("Memory Used:", import_chalk8.default.blue(`${(0, import_filesize.filesize)(memDevice.used)}`));
|
|
1618
|
+
console.info("Memory Available:", import_chalk8.default.blue(`${(0, import_filesize.filesize)(memDevice.available)}`));
|
|
1440
1619
|
}
|
|
1441
1620
|
rightPad(name, length) {
|
|
1442
1621
|
while (name.length < length) {
|
|
@@ -1453,6 +1632,7 @@ var InfoCommand;
|
|
|
1453
1632
|
var init_command3 = __esm({
|
|
1454
1633
|
"src/processes/info/command.ts"() {
|
|
1455
1634
|
"use strict";
|
|
1635
|
+
init_cjs_shims();
|
|
1456
1636
|
init_program2();
|
|
1457
1637
|
InfoCommand = class extends AbstractCommand {
|
|
1458
1638
|
constructor() {
|
|
@@ -1477,6 +1657,7 @@ var info_default;
|
|
|
1477
1657
|
var init_info = __esm({
|
|
1478
1658
|
"src/processes/info/index.ts"() {
|
|
1479
1659
|
"use strict";
|
|
1660
|
+
init_cjs_shims();
|
|
1480
1661
|
init_action3();
|
|
1481
1662
|
init_command3();
|
|
1482
1663
|
info_default = (program) => {
|
|
@@ -1486,14 +1667,15 @@ var init_info = __esm({
|
|
|
1486
1667
|
});
|
|
1487
1668
|
|
|
1488
1669
|
// src/processes/optimize/action.ts
|
|
1489
|
-
var
|
|
1670
|
+
var import_fs2, import_node_path5, import_chalk9, import_cli_progress, import_cli_table32, import_filesize2, import_glob, OptimizeAction;
|
|
1490
1671
|
var init_action4 = __esm({
|
|
1491
1672
|
"src/processes/optimize/action.ts"() {
|
|
1492
1673
|
"use strict";
|
|
1493
|
-
|
|
1674
|
+
init_cjs_shims();
|
|
1675
|
+
import_fs2 = __toESM(require("fs"), 1);
|
|
1494
1676
|
import_node_path5 = __toESM(require("path"), 1);
|
|
1495
1677
|
import_chalk9 = __toESM(require("chalk"), 1);
|
|
1496
|
-
import_cli_progress =
|
|
1678
|
+
import_cli_progress = require("cli-progress");
|
|
1497
1679
|
import_cli_table32 = __toESM(require("cli-table3"), 1);
|
|
1498
1680
|
import_filesize2 = require("filesize");
|
|
1499
1681
|
import_glob = require("glob");
|
|
@@ -1507,16 +1689,16 @@ var init_action4 = __esm({
|
|
|
1507
1689
|
const failed = results.filter((item) => item.status === false);
|
|
1508
1690
|
const leftMargin = "";
|
|
1509
1691
|
const table = new import_cli_table32.default({
|
|
1510
|
-
head: ["\u041E\u0431\u0440\u0430\u0431\u043E\u0442\u0430\u043D\u043E", "\u041D\u0435 \u043E\u0431\u0440\u0430\u0431\u043E\u0442\u0430\u043D\u043E", "\u0418\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0435 \u0440\u0430\u0437\u043C\u0435\u0440\u0430"],
|
|
1511
1692
|
chars: {
|
|
1512
|
-
left: leftMargin.concat("\u2502"),
|
|
1513
|
-
"top-left": leftMargin.concat("\u250C"),
|
|
1514
1693
|
"bottom-left": leftMargin.concat("\u2514"),
|
|
1515
|
-
|
|
1694
|
+
left: leftMargin.concat("\u2502"),
|
|
1516
1695
|
"left-mid": "",
|
|
1696
|
+
mid: "",
|
|
1517
1697
|
"mid-mid": "",
|
|
1518
|
-
"right-mid": ""
|
|
1519
|
-
|
|
1698
|
+
"right-mid": "",
|
|
1699
|
+
"top-left": leftMargin.concat("\u250C")
|
|
1700
|
+
},
|
|
1701
|
+
head: ["\u041E\u0431\u0440\u0430\u0431\u043E\u0442\u0430\u043D\u043E", "\u041D\u0435 \u043E\u0431\u0440\u0430\u0431\u043E\u0442\u0430\u043D\u043E", "\u0418\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0435 \u0440\u0430\u0437\u043C\u0435\u0440\u0430"]
|
|
1520
1702
|
});
|
|
1521
1703
|
const sumFilesize = results.reduce((acc, task) => {
|
|
1522
1704
|
if (task.__originalStat && task.__optimizedStat) {
|
|
@@ -1543,27 +1725,27 @@ var init_action4 = __esm({
|
|
|
1543
1725
|
const inquirer = await import("inquirer");
|
|
1544
1726
|
const answers = await inquirer.default.prompt([
|
|
1545
1727
|
{
|
|
1546
|
-
type: "list",
|
|
1547
|
-
message: "\u041F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u044C?",
|
|
1548
1728
|
choices: [
|
|
1549
1729
|
{ name: "Yes", value: 1 },
|
|
1550
1730
|
{ name: "No", value: 0 }
|
|
1551
1731
|
],
|
|
1552
1732
|
default: 1,
|
|
1553
|
-
|
|
1733
|
+
message: "\u041F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u044C?",
|
|
1734
|
+
name: "continue",
|
|
1735
|
+
type: "list"
|
|
1554
1736
|
}
|
|
1555
1737
|
]);
|
|
1556
1738
|
if (!answers.continue) return;
|
|
1557
1739
|
console.log();
|
|
1558
|
-
const bar = new import_cli_progress.
|
|
1740
|
+
const bar = new import_cli_progress.SingleBar({ fps: 25 }, import_cli_progress.Presets.shades_classic);
|
|
1559
1741
|
bar.start(resources.length, 0);
|
|
1560
1742
|
const ft = await import("file-type");
|
|
1561
1743
|
const promises = resources.map(async (resource) => {
|
|
1562
1744
|
const fileType = await ft.fileTypeFromFile(resource);
|
|
1563
1745
|
if (!fileType)
|
|
1564
1746
|
return {
|
|
1565
|
-
__originalPath: resource,
|
|
1566
1747
|
__optimizedPath: resource,
|
|
1748
|
+
__originalPath: resource,
|
|
1567
1749
|
status: false
|
|
1568
1750
|
};
|
|
1569
1751
|
const { mime } = fileType;
|
|
@@ -1587,32 +1769,32 @@ var init_action4 = __esm({
|
|
|
1587
1769
|
}
|
|
1588
1770
|
if (!runner) {
|
|
1589
1771
|
return {
|
|
1590
|
-
__originalPath: resource,
|
|
1591
1772
|
__optimizedPath: resource,
|
|
1773
|
+
__originalPath: resource,
|
|
1592
1774
|
status: false
|
|
1593
1775
|
};
|
|
1594
1776
|
}
|
|
1595
1777
|
try {
|
|
1596
|
-
const beforeStat =
|
|
1778
|
+
const beforeStat = import_fs2.default.statSync(resource);
|
|
1597
1779
|
await runner.run({
|
|
1598
|
-
|
|
1780
|
+
extraFlags,
|
|
1599
1781
|
output: outputPath,
|
|
1600
|
-
|
|
1782
|
+
resource
|
|
1601
1783
|
});
|
|
1602
|
-
const afterStat =
|
|
1784
|
+
const afterStat = import_fs2.default.statSync(outputPath);
|
|
1603
1785
|
return {
|
|
1604
|
-
__originalPath: resource,
|
|
1605
|
-
__originalStat: beforeStat,
|
|
1606
1786
|
__optimizedPath: resource,
|
|
1607
1787
|
__optimizedStat: afterStat,
|
|
1788
|
+
__originalPath: resource,
|
|
1789
|
+
__originalStat: beforeStat,
|
|
1608
1790
|
status: true
|
|
1609
1791
|
};
|
|
1610
1792
|
} catch (err) {
|
|
1611
1793
|
return {
|
|
1612
|
-
__originalPath: resource,
|
|
1613
1794
|
__optimizedPath: resource,
|
|
1614
|
-
|
|
1615
|
-
err
|
|
1795
|
+
__originalPath: resource,
|
|
1796
|
+
err,
|
|
1797
|
+
status: false
|
|
1616
1798
|
};
|
|
1617
1799
|
} finally {
|
|
1618
1800
|
bar.increment();
|
|
@@ -1650,6 +1832,7 @@ var import_chalk10, OptimizeCommand;
|
|
|
1650
1832
|
var init_command4 = __esm({
|
|
1651
1833
|
"src/processes/optimize/command.ts"() {
|
|
1652
1834
|
"use strict";
|
|
1835
|
+
init_cjs_shims();
|
|
1653
1836
|
import_chalk10 = __toESM(require("chalk"), 1);
|
|
1654
1837
|
init_program2();
|
|
1655
1838
|
OptimizeCommand = class extends AbstractCommand {
|
|
@@ -1667,8 +1850,8 @@ var init_command4 = __esm({
|
|
|
1667
1850
|
{
|
|
1668
1851
|
filePath: path10,
|
|
1669
1852
|
list: option.list,
|
|
1670
|
-
|
|
1671
|
-
|
|
1853
|
+
prefix: option.prefix,
|
|
1854
|
+
replace: option.replace
|
|
1672
1855
|
},
|
|
1673
1856
|
extraFlags
|
|
1674
1857
|
);
|
|
@@ -1687,6 +1870,7 @@ var optimize_default;
|
|
|
1687
1870
|
var init_optimize = __esm({
|
|
1688
1871
|
"src/processes/optimize/index.ts"() {
|
|
1689
1872
|
"use strict";
|
|
1873
|
+
init_cjs_shims();
|
|
1690
1874
|
init_action4();
|
|
1691
1875
|
init_command4();
|
|
1692
1876
|
optimize_default = (program) => {
|
|
@@ -1696,23 +1880,24 @@ var init_optimize = __esm({
|
|
|
1696
1880
|
});
|
|
1697
1881
|
|
|
1698
1882
|
// src/bin/fox.ts
|
|
1883
|
+
init_cjs_shims();
|
|
1699
1884
|
var import_chalk12 = __toESM(require("chalk"), 1);
|
|
1700
1885
|
|
|
1701
1886
|
// package.json
|
|
1702
1887
|
var package_default = {
|
|
1703
1888
|
name: "@foxford/cli",
|
|
1704
|
-
version: "1.
|
|
1889
|
+
version: "1.4.0",
|
|
1705
1890
|
description: "Foxford Cli",
|
|
1706
1891
|
keywords: [
|
|
1707
1892
|
"foxford",
|
|
1708
1893
|
"cli",
|
|
1709
1894
|
"tool"
|
|
1710
1895
|
],
|
|
1711
|
-
homepage: "https://github.com/foxford/
|
|
1712
|
-
bugs: "https://github.com/foxford/
|
|
1896
|
+
homepage: "https://github.com/foxford/frontend-platform",
|
|
1897
|
+
bugs: "https://github.com/foxford/frontend-platform/issues",
|
|
1713
1898
|
repository: {
|
|
1714
1899
|
type: "git",
|
|
1715
|
-
url: "git+https://github.com/foxford/
|
|
1900
|
+
url: "git+https://github.com/foxford/frontend-platform.git"
|
|
1716
1901
|
},
|
|
1717
1902
|
license: "MIT",
|
|
1718
1903
|
author: "Foxford Co",
|
|
@@ -1753,20 +1938,21 @@ var package_default = {
|
|
|
1753
1938
|
},
|
|
1754
1939
|
dependencies: {
|
|
1755
1940
|
"@foxford/logger": "workspace:*",
|
|
1941
|
+
"@pnpm/catalogs.config": "1000.0.5",
|
|
1942
|
+
"@pnpm/exportable-manifest": "1000.4.1",
|
|
1943
|
+
"@pnpm/workspace.read-manifest": "1000.3.0",
|
|
1756
1944
|
"@tsconfig/node16": "16.1.3",
|
|
1757
|
-
"@types/cli-progress": "3.11.5",
|
|
1758
|
-
"@types/fluent-ffmpeg": "2.1.24",
|
|
1759
1945
|
chalk: "4.1.0",
|
|
1760
|
-
"cli-progress": "
|
|
1761
|
-
"cli-table3": "
|
|
1762
|
-
commander: "
|
|
1946
|
+
"cli-progress": "catalog:cli",
|
|
1947
|
+
"cli-table3": "catalog:cli",
|
|
1948
|
+
commander: "catalog:cli",
|
|
1763
1949
|
dotenv: "16.4.5",
|
|
1764
1950
|
"dotenv-expand": "11.0.6",
|
|
1765
|
-
"file-type": "
|
|
1951
|
+
"file-type": "21.3.1",
|
|
1766
1952
|
filesize: "10.1.2",
|
|
1767
1953
|
"fluent-ffmpeg": "2.1.2",
|
|
1768
|
-
"fs-extra": "
|
|
1769
|
-
glob: "
|
|
1954
|
+
"fs-extra": "catalog:dev",
|
|
1955
|
+
glob: "catalog:dev",
|
|
1770
1956
|
inquirer: "12.4.3",
|
|
1771
1957
|
"os-name": "7.0.0",
|
|
1772
1958
|
"package-manager-detector": "1.3.0",
|
|
@@ -1774,17 +1960,21 @@ var package_default = {
|
|
|
1774
1960
|
systeminformation: "5.31.1",
|
|
1775
1961
|
tinify: "1.7.1",
|
|
1776
1962
|
tsx: "4.21.0",
|
|
1777
|
-
typescript: "
|
|
1963
|
+
typescript: "catalog:dev",
|
|
1778
1964
|
yaml: "2.4.5",
|
|
1779
|
-
zx: "
|
|
1965
|
+
zx: "catalog:dev"
|
|
1780
1966
|
},
|
|
1781
1967
|
devDependencies: {
|
|
1782
1968
|
"@foxford/eslint-config": "workspace:*",
|
|
1783
1969
|
"@foxford/typescript-config": "workspace:*",
|
|
1784
1970
|
"@foxford/vitest-config": "workspace:*",
|
|
1971
|
+
"@foxford/prettier-config": "workspace:*",
|
|
1972
|
+
"@types/fs-extra": "11.0.4",
|
|
1973
|
+
"@types/cli-progress": "catalog:cli",
|
|
1974
|
+
"@types/fluent-ffmpeg": "2.1.24",
|
|
1785
1975
|
"dts-bundle-generator": "9.5.1",
|
|
1786
|
-
tsup: "
|
|
1787
|
-
vitest: "
|
|
1976
|
+
tsup: "catalog:dev",
|
|
1977
|
+
vitest: "catalog:dev"
|
|
1788
1978
|
}
|
|
1789
1979
|
};
|
|
1790
1980
|
|
|
@@ -1793,13 +1983,19 @@ init_logger();
|
|
|
1793
1983
|
init_program2();
|
|
1794
1984
|
|
|
1795
1985
|
// src/program/loader.ts
|
|
1796
|
-
|
|
1986
|
+
init_cjs_shims();
|
|
1987
|
+
var import_node_fs = require("fs");
|
|
1988
|
+
var import_promises = require("fs/promises");
|
|
1989
|
+
var import_node_module2 = require("module");
|
|
1797
1990
|
var import_node_path6 = __toESM(require("path"), 1);
|
|
1991
|
+
var import_node_url2 = require("url");
|
|
1798
1992
|
var import_chalk11 = __toESM(require("chalk"), 1);
|
|
1799
|
-
var
|
|
1993
|
+
var import_fs_extra3 = require("fs-extra");
|
|
1800
1994
|
init_ui();
|
|
1801
1995
|
init_logger();
|
|
1802
1996
|
var log2 = logger.getLogger("command-loader");
|
|
1997
|
+
var require3 = (0, import_node_module2.createRequire)(importMetaUrl);
|
|
1998
|
+
var __dirname2 = import_node_path6.default.dirname((0, import_node_url2.fileURLToPath)(importMetaUrl));
|
|
1803
1999
|
var _CommandLoader = class _CommandLoader {
|
|
1804
2000
|
static async load(program) {
|
|
1805
2001
|
if (true) {
|
|
@@ -1836,7 +2032,7 @@ var _CommandLoader = class _CommandLoader {
|
|
|
1836
2032
|
}
|
|
1837
2033
|
}
|
|
1838
2034
|
static async loadDevelopmentProcesses(program) {
|
|
1839
|
-
if (!await
|
|
2035
|
+
if (!await (0, import_fs_extra3.pathExists)(_CommandLoader.PROCESSES_DIR)) {
|
|
1840
2036
|
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}`);
|
|
1841
2037
|
return;
|
|
1842
2038
|
}
|
|
@@ -1846,7 +2042,7 @@ var _CommandLoader = class _CommandLoader {
|
|
|
1846
2042
|
try {
|
|
1847
2043
|
log2.debug(`\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043C \u043C\u043E\u0434\u0443\u043B\u044C: ${import_chalk11.default.cyan(processName)}`);
|
|
1848
2044
|
const modulePath = import_node_path6.default.join(_CommandLoader.PROCESSES_DIR, processName);
|
|
1849
|
-
const module2 =
|
|
2045
|
+
const module2 = require3(modulePath);
|
|
1850
2046
|
module2.default(program);
|
|
1851
2047
|
} catch (err) {
|
|
1852
2048
|
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);
|
|
@@ -1891,24 +2087,24 @@ var _CommandLoader = class _CommandLoader {
|
|
|
1891
2087
|
log2.debug(`\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043C \u043C\u043E\u0434\u0443\u043B\u044C: ${import_chalk11.default.cyan(plugin.pkgJson.name)}`);
|
|
1892
2088
|
const dirname = import_node_path6.default.dirname(plugin.path);
|
|
1893
2089
|
if (false) {
|
|
1894
|
-
const module2 =
|
|
2090
|
+
const module2 = require3(`${plugin.pkgJson.name}`);
|
|
1895
2091
|
module2.default(program);
|
|
1896
2092
|
continue;
|
|
1897
2093
|
}
|
|
1898
2094
|
let targetPath = import_node_path6.default.resolve(dirname);
|
|
1899
|
-
if (
|
|
2095
|
+
if ((0, import_node_fs.existsSync)(import_node_path6.default.resolve(targetPath, "build"))) {
|
|
1900
2096
|
targetPath = import_node_path6.default.resolve(targetPath, "build");
|
|
1901
2097
|
}
|
|
1902
|
-
if (
|
|
1903
|
-
const packageJson =
|
|
2098
|
+
if ((0, import_node_fs.existsSync)(import_node_path6.default.join(targetPath, "package.json"))) {
|
|
2099
|
+
const packageJson = require3(import_node_path6.default.join(targetPath, "package.json"));
|
|
1904
2100
|
try {
|
|
1905
|
-
const
|
|
2101
|
+
const require4 = (0, import_node_module2.createRequire)(__filename);
|
|
1906
2102
|
let module2;
|
|
1907
2103
|
const modulePath = this.getModulePath(packageJson);
|
|
1908
2104
|
if (packageJson.type === "module") {
|
|
1909
2105
|
module2 = await import(import_node_path6.default.join(targetPath, modulePath));
|
|
1910
2106
|
} else {
|
|
1911
|
-
module2 =
|
|
2107
|
+
module2 = require4(import_node_path6.default.join(targetPath, modulePath));
|
|
1912
2108
|
}
|
|
1913
2109
|
if (typeof module2.default === "function") {
|
|
1914
2110
|
module2.default(program);
|
|
@@ -1924,10 +2120,10 @@ var _CommandLoader = class _CommandLoader {
|
|
|
1924
2120
|
}
|
|
1925
2121
|
}
|
|
1926
2122
|
static async getProcesses(processesPath) {
|
|
1927
|
-
const files = await
|
|
2123
|
+
const files = await (0, import_promises.readdir)(processesPath);
|
|
1928
2124
|
return files.filter((file) => {
|
|
1929
2125
|
const filePath = import_node_path6.default.join(processesPath, file, "index.ts");
|
|
1930
|
-
const stat =
|
|
2126
|
+
const stat = (0, import_node_fs.statSync)(filePath);
|
|
1931
2127
|
return stat.isFile();
|
|
1932
2128
|
}).map((file) => import_node_path6.default.parse(file).name);
|
|
1933
2129
|
}
|
|
@@ -1941,7 +2137,7 @@ ${ERROR_PREFIX} \u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u043A\u043E\u0
|
|
|
1941
2137
|
});
|
|
1942
2138
|
}
|
|
1943
2139
|
};
|
|
1944
|
-
_CommandLoader.PROCESSES_DIR = import_node_path6.default.resolve(
|
|
2140
|
+
_CommandLoader.PROCESSES_DIR = import_node_path6.default.resolve(__dirname2, "..", "processes");
|
|
1945
2141
|
var CommandLoader = _CommandLoader;
|
|
1946
2142
|
|
|
1947
2143
|
// src/bin/fox.ts
|