@git.zone/cli 8.2.0 → 8.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/gitzone.cli.js +8 -2
- package/dist_ts/gitzone.logging.js +2 -2
- package/dist_ts/helpers.prompts.d.ts +23 -0
- package/dist_ts/helpers.prompts.js +30 -0
- package/dist_ts/mod_commit/index.js +30 -41
- package/dist_ts/mod_commit/mod.plugins.d.ts +1 -2
- package/dist_ts/mod_commit/mod.plugins.js +2 -3
- package/dist_ts/mod_config/index.js +45 -61
- package/dist_ts/mod_deprecate/helpers.deprecation.d.ts +1 -1
- package/dist_ts/mod_deprecate/helpers.deprecation.js +32 -9
- package/dist_ts/mod_deprecate/index.js +9 -10
- package/dist_ts/mod_deprecate/mod.plugins.d.ts +1 -2
- package/dist_ts/mod_deprecate/mod.plugins.js +2 -3
- package/dist_ts/mod_docker/index.js +4 -4
- package/dist_ts/mod_format/formatters/smartconfig.formatter.js +10 -16
- package/dist_ts/mod_format/index.js +6 -6
- package/dist_ts/mod_format/mod.plugins.d.ts +1 -2
- package/dist_ts/mod_format/mod.plugins.js +2 -3
- package/dist_ts/mod_meta/meta.classes.meta.js +5 -4
- package/dist_ts/mod_meta/meta.plugins.d.ts +1 -2
- package/dist_ts/mod_meta/meta.plugins.js +2 -3
- package/dist_ts/mod_release/helpers.npmartifact.d.ts +2 -0
- package/dist_ts/mod_release/helpers.npmartifact.js +3 -2
- package/dist_ts/mod_release/index.js +5 -4
- package/dist_ts/mod_services/classes.servicemanager.js +9 -13
- package/dist_ts/mod_services/index.js +10 -17
- package/dist_ts/mod_services/mod.plugins.d.ts +1 -2
- package/dist_ts/mod_services/mod.plugins.js +2 -3
- package/dist_ts/mod_standard/index.js +3 -4
- package/dist_ts/mod_template/index.js +5 -6
- package/dist_ts/mod_template/mod.plugins.d.ts +1 -2
- package/dist_ts/mod_template/mod.plugins.js +2 -3
- package/dist_ts/mod_tools/index.js +5 -10
- package/dist_ts/plugins.d.ts +2 -3
- package/dist_ts/plugins.js +3 -4
- package/package.json +4 -5
- package/readme.md +8 -4
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/gitzone.cli.ts +8 -5
- package/ts/gitzone.logging.ts +1 -1
- package/ts/helpers.prompts.ts +70 -0
- package/ts/mod_commit/index.ts +37 -48
- package/ts/mod_commit/mod.plugins.ts +1 -2
- package/ts/mod_config/index.ts +44 -63
- package/ts/mod_deprecate/helpers.deprecation.ts +63 -15
- package/ts/mod_deprecate/index.ts +8 -9
- package/ts/mod_deprecate/mod.plugins.ts +1 -2
- package/ts/mod_docker/index.ts +3 -3
- package/ts/mod_format/formatters/smartconfig.formatter.ts +15 -22
- package/ts/mod_format/index.ts +9 -5
- package/ts/mod_format/mod.plugins.ts +0 -2
- package/ts/mod_meta/meta.classes.meta.ts +7 -3
- package/ts/mod_meta/meta.plugins.ts +1 -2
- package/ts/mod_release/helpers.npmartifact.ts +2 -1
- package/ts/mod_release/index.ts +4 -3
- package/ts/mod_services/classes.servicemanager.ts +8 -14
- package/ts/mod_services/index.ts +17 -24
- package/ts/mod_services/mod.plugins.ts +1 -2
- package/ts/mod_standard/index.ts +2 -4
- package/ts/mod_template/index.ts +4 -5
- package/ts/mod_template/mod.plugins.ts +1 -2
- package/ts/mod_tools/index.ts +4 -10
- package/ts/plugins.ts +2 -4
package/ts/mod_config/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { CommitConfig } from "./classes.commitconfig.js";
|
|
|
6
6
|
import { runFormatter, type ICheckResult } from "../mod_format/index.js";
|
|
7
7
|
import type { ICliMode } from "../helpers.climode.js";
|
|
8
8
|
import { getCliMode, printJson } from "../helpers.climode.js";
|
|
9
|
+
import { ask, confirm, stringChoices } from "../helpers.prompts.js";
|
|
9
10
|
import {
|
|
10
11
|
CLI_NAMESPACE,
|
|
11
12
|
getCliConfigValueFromData,
|
|
@@ -67,7 +68,7 @@ async function formatSmartconfigWithDiff(mode: ICliMode): Promise<void> {
|
|
|
67
68
|
|
|
68
69
|
if (checkResult && checkResult.hasDiff) {
|
|
69
70
|
const shouldApply =
|
|
70
|
-
await
|
|
71
|
+
await confirm(
|
|
71
72
|
"Apply formatting changes to .smartconfig.json?",
|
|
72
73
|
true,
|
|
73
74
|
);
|
|
@@ -169,8 +170,7 @@ async function handleInteractiveMenu(): Promise<void> {
|
|
|
169
170
|
);
|
|
170
171
|
console.log("");
|
|
171
172
|
|
|
172
|
-
const
|
|
173
|
-
const response = await interactInstance.askQuestion({
|
|
173
|
+
const action = await ask({
|
|
174
174
|
type: "list",
|
|
175
175
|
name: "action",
|
|
176
176
|
message: "What would you like to do?",
|
|
@@ -193,8 +193,6 @@ async function handleInteractiveMenu(): Promise<void> {
|
|
|
193
193
|
],
|
|
194
194
|
});
|
|
195
195
|
|
|
196
|
-
const action = (response as any).value;
|
|
197
|
-
|
|
198
196
|
switch (action) {
|
|
199
197
|
case "show":
|
|
200
198
|
await handleShow(defaultCliMode);
|
|
@@ -371,8 +369,7 @@ async function handleAdd(
|
|
|
371
369
|
}
|
|
372
370
|
|
|
373
371
|
// Interactive mode
|
|
374
|
-
|
|
375
|
-
const response = await interactInstance.askQuestion({
|
|
372
|
+
url = await ask({
|
|
376
373
|
type: "input",
|
|
377
374
|
name: "registryUrl",
|
|
378
375
|
message: "Enter npm target registry URL:",
|
|
@@ -381,7 +378,6 @@ async function handleAdd(
|
|
|
381
378
|
return !!(input && input.trim() !== "");
|
|
382
379
|
},
|
|
383
380
|
});
|
|
384
|
-
url = (response as any).value;
|
|
385
381
|
}
|
|
386
382
|
|
|
387
383
|
const config = await ReleaseConfig.fromCwd();
|
|
@@ -429,15 +425,13 @@ async function handleRemove(
|
|
|
429
425
|
}
|
|
430
426
|
|
|
431
427
|
// Interactive mode - show list to select from
|
|
432
|
-
|
|
433
|
-
const response = await interactInstance.askQuestion({
|
|
428
|
+
url = await ask({
|
|
434
429
|
type: "list",
|
|
435
430
|
name: "registryUrl",
|
|
436
431
|
message: "Select npm target registry to remove:",
|
|
437
|
-
choices: registries,
|
|
432
|
+
choices: stringChoices(registries),
|
|
438
433
|
default: registries[0],
|
|
439
434
|
});
|
|
440
|
-
url = (response as any).value;
|
|
441
435
|
}
|
|
442
436
|
|
|
443
437
|
const removed = config.removeRegistry(url!);
|
|
@@ -473,7 +467,7 @@ async function handleClear(mode: ICliMode): Promise<void> {
|
|
|
473
467
|
|
|
474
468
|
// Confirm before clearing
|
|
475
469
|
const confirmed = mode.interactive
|
|
476
|
-
? await
|
|
470
|
+
? await confirm(
|
|
477
471
|
"Clear all configured npm target registries?",
|
|
478
472
|
false,
|
|
479
473
|
)
|
|
@@ -509,15 +503,13 @@ async function handleAccessLevel(
|
|
|
509
503
|
}
|
|
510
504
|
|
|
511
505
|
// Interactive mode - toggle or ask
|
|
512
|
-
|
|
513
|
-
const response = await interactInstance.askQuestion({
|
|
506
|
+
level = await ask<string>({
|
|
514
507
|
type: "list",
|
|
515
508
|
name: "accessLevel",
|
|
516
509
|
message: "Select npm access level for publishing:",
|
|
517
|
-
choices: ["public", "private"],
|
|
510
|
+
choices: stringChoices(["public", "private"]),
|
|
518
511
|
default: currentLevel,
|
|
519
512
|
});
|
|
520
|
-
level = (response as any).value;
|
|
521
513
|
}
|
|
522
514
|
|
|
523
515
|
// Validate the level
|
|
@@ -593,8 +585,7 @@ async function handleCommitInteractive(config: CommitConfig): Promise<void> {
|
|
|
593
585
|
);
|
|
594
586
|
console.log("");
|
|
595
587
|
|
|
596
|
-
const
|
|
597
|
-
const response = await interactInstance.askQuestion({
|
|
588
|
+
const selected = await ask({
|
|
598
589
|
type: "checkbox",
|
|
599
590
|
name: "commitOptions",
|
|
600
591
|
message: "Select commit options to enable:",
|
|
@@ -607,8 +598,6 @@ async function handleCommitInteractive(config: CommitConfig): Promise<void> {
|
|
|
607
598
|
...(config.getAlwaysBuild() ? ["alwaysBuild"] : []),
|
|
608
599
|
],
|
|
609
600
|
});
|
|
610
|
-
|
|
611
|
-
const selected = (response as any).value || [];
|
|
612
601
|
config.setAlwaysTest(selected.includes("alwaysTest"));
|
|
613
602
|
config.setAlwaysBuild(selected.includes("alwaysBuild"));
|
|
614
603
|
syncCommitStepsFromBooleans(config);
|
|
@@ -685,40 +674,39 @@ async function handleProject(mode: ICliMode): Promise<void> {
|
|
|
685
674
|
const cliConfig = getCliConfigValueFromData(smartconfigData, "") || {};
|
|
686
675
|
const moduleConfig = cliConfig.module || {};
|
|
687
676
|
const packageJson = await readPackageJson();
|
|
688
|
-
const interactInstance = new plugins.smartinteract.SmartInteract();
|
|
689
677
|
|
|
690
|
-
const projectType = await
|
|
678
|
+
const projectType = await ask<string>({
|
|
691
679
|
type: "list",
|
|
692
680
|
name: "projectType",
|
|
693
681
|
message: "What kind of project is this?",
|
|
694
|
-
choices: ["npm", "service", "wcc", "website"],
|
|
682
|
+
choices: stringChoices(["npm", "service", "wcc", "website"]),
|
|
695
683
|
default: cliConfig.projectType || "npm",
|
|
696
684
|
});
|
|
697
|
-
const githost = await
|
|
685
|
+
const githost = await ask({
|
|
698
686
|
type: "input",
|
|
699
687
|
name: "githost",
|
|
700
688
|
message: "Git host:",
|
|
701
689
|
default: moduleConfig.githost || "code.foss.global",
|
|
702
690
|
});
|
|
703
|
-
const gitscope = await
|
|
691
|
+
const gitscope = await ask({
|
|
704
692
|
type: "input",
|
|
705
693
|
name: "gitscope",
|
|
706
694
|
message: "Git scope/owner:",
|
|
707
695
|
default: moduleConfig.gitscope || "git.zone",
|
|
708
696
|
});
|
|
709
|
-
const gitrepo = await
|
|
697
|
+
const gitrepo = await ask({
|
|
710
698
|
type: "input",
|
|
711
699
|
name: "gitrepo",
|
|
712
700
|
message: "Git repository name:",
|
|
713
701
|
default: moduleConfig.gitrepo || inferRepoName(packageJson.name),
|
|
714
702
|
});
|
|
715
|
-
const description = await
|
|
703
|
+
const description = await ask({
|
|
716
704
|
type: "input",
|
|
717
705
|
name: "description",
|
|
718
706
|
message: "Project description:",
|
|
719
707
|
default: moduleConfig.description || packageJson.description || "",
|
|
720
708
|
});
|
|
721
|
-
const npmPackagename = await
|
|
709
|
+
const npmPackagename = await ask({
|
|
722
710
|
type: "input",
|
|
723
711
|
name: "npmPackagename",
|
|
724
712
|
message: "npm package name:",
|
|
@@ -728,13 +716,13 @@ async function handleProject(mode: ICliMode): Promise<void> {
|
|
|
728
716
|
packageJson.name ||
|
|
729
717
|
"",
|
|
730
718
|
});
|
|
731
|
-
const license = await
|
|
719
|
+
const license = await ask({
|
|
732
720
|
type: "input",
|
|
733
721
|
name: "license",
|
|
734
722
|
message: "License:",
|
|
735
723
|
default: moduleConfig.license || packageJson.license || "MIT",
|
|
736
724
|
});
|
|
737
|
-
const keywords = await
|
|
725
|
+
const keywords = await ask({
|
|
738
726
|
type: "input",
|
|
739
727
|
name: "keywords",
|
|
740
728
|
message: "Keywords (comma-separated):",
|
|
@@ -775,22 +763,21 @@ async function handleCli(mode: ICliMode): Promise<void> {
|
|
|
775
763
|
|
|
776
764
|
const smartconfigData = await readSmartconfigFile();
|
|
777
765
|
const cliConfig = getCliConfigValueFromData(smartconfigData, "cli") || {};
|
|
778
|
-
const interactInstance = new plugins.smartinteract.SmartInteract();
|
|
779
766
|
|
|
780
|
-
const output = await
|
|
767
|
+
const output = await ask<string>({
|
|
781
768
|
type: "list",
|
|
782
769
|
name: "output",
|
|
783
770
|
message: "Default output mode:",
|
|
784
|
-
choices: ["human", "plain", "json"],
|
|
771
|
+
choices: stringChoices(["human", "plain", "json"]),
|
|
785
772
|
default: cliConfig.output || "human",
|
|
786
773
|
});
|
|
787
|
-
const interactive = await
|
|
774
|
+
const interactive = await ask({
|
|
788
775
|
type: "confirm",
|
|
789
776
|
name: "interactive",
|
|
790
777
|
message: "Enable interactive prompts by default?",
|
|
791
778
|
default: cliConfig.interactive ?? true,
|
|
792
779
|
});
|
|
793
|
-
const checkUpdates = await
|
|
780
|
+
const checkUpdates = await ask({
|
|
794
781
|
type: "confirm",
|
|
795
782
|
name: "checkUpdates",
|
|
796
783
|
message: "Check for gitzone updates in human mode?",
|
|
@@ -823,41 +810,40 @@ async function handleRelease(mode: ICliMode): Promise<void> {
|
|
|
823
810
|
const currentRelease =
|
|
824
811
|
getCliConfigValueFromData(smartconfigData, "release") || {};
|
|
825
812
|
const currentTargets = currentRelease.targets || {};
|
|
826
|
-
const interactInstance = new plugins.smartinteract.SmartInteract();
|
|
827
813
|
|
|
828
|
-
const confirmation = await
|
|
814
|
+
const confirmation = await ask<string>({
|
|
829
815
|
type: "list",
|
|
830
816
|
name: "confirmation",
|
|
831
817
|
message: "Release confirmation mode:",
|
|
832
|
-
choices: ["prompt", "auto", "plan"],
|
|
818
|
+
choices: stringChoices(["prompt", "auto", "plan"]),
|
|
833
819
|
default: currentRelease.confirmation || "prompt",
|
|
834
820
|
});
|
|
835
|
-
const runTests = await
|
|
821
|
+
const runTests = await ask({
|
|
836
822
|
type: "confirm",
|
|
837
823
|
name: "runTests",
|
|
838
824
|
message: "Run tests during release preflight?",
|
|
839
825
|
default: currentRelease.preflight?.test ?? false,
|
|
840
826
|
});
|
|
841
|
-
const runBuild = await
|
|
827
|
+
const runBuild = await ask({
|
|
842
828
|
type: "confirm",
|
|
843
829
|
name: "runBuild",
|
|
844
830
|
message: "Run build during release?",
|
|
845
831
|
default: currentRelease.preflight?.build ?? true,
|
|
846
832
|
});
|
|
847
|
-
const testCommand = await
|
|
833
|
+
const testCommand = await ask({
|
|
848
834
|
type: "input",
|
|
849
835
|
name: "testCommand",
|
|
850
836
|
message: "Release test command:",
|
|
851
837
|
default: currentRelease.preflight?.testCommand || "pnpm test",
|
|
852
838
|
});
|
|
853
|
-
const buildCommand = await
|
|
839
|
+
const buildCommand = await ask({
|
|
854
840
|
type: "input",
|
|
855
841
|
name: "buildCommand",
|
|
856
842
|
message: "Release build command:",
|
|
857
843
|
default: currentRelease.preflight?.buildCommand || "pnpm build",
|
|
858
844
|
});
|
|
859
845
|
|
|
860
|
-
const enabledTargets = await
|
|
846
|
+
const enabledTargets = await ask<string>({
|
|
861
847
|
type: "checkbox",
|
|
862
848
|
name: "targets",
|
|
863
849
|
message: "Enable release targets:",
|
|
@@ -875,7 +861,7 @@ async function handleRelease(mode: ICliMode): Promise<void> {
|
|
|
875
861
|
releaseTargets.git = {
|
|
876
862
|
...(currentTargets.git || {}),
|
|
877
863
|
enabled: true,
|
|
878
|
-
remote: await
|
|
864
|
+
remote: await ask({
|
|
879
865
|
type: "input",
|
|
880
866
|
name: "gitRemote",
|
|
881
867
|
message: "Git remote:",
|
|
@@ -889,7 +875,7 @@ async function handleRelease(mode: ICliMode): Promise<void> {
|
|
|
889
875
|
}
|
|
890
876
|
|
|
891
877
|
if (enabledTargets.includes("npm")) {
|
|
892
|
-
const registries = await
|
|
878
|
+
const registries = await ask({
|
|
893
879
|
type: "input",
|
|
894
880
|
name: "npmRegistries",
|
|
895
881
|
message: "npm registries (comma-separated):",
|
|
@@ -901,18 +887,18 @@ async function handleRelease(mode: ICliMode): Promise<void> {
|
|
|
901
887
|
...(currentTargets.npm || {}),
|
|
902
888
|
enabled: true,
|
|
903
889
|
registries: parseCsv(registries).map(normalizeRegistryUrl),
|
|
904
|
-
accessLevel: await
|
|
890
|
+
accessLevel: await ask<string>({
|
|
905
891
|
type: "list",
|
|
906
892
|
name: "npmAccessLevel",
|
|
907
893
|
message: "npm publish access level:",
|
|
908
|
-
choices: ["public", "private"],
|
|
894
|
+
choices: stringChoices(["public", "private"]),
|
|
909
895
|
default: currentTargets.npm?.accessLevel || "public",
|
|
910
896
|
}),
|
|
911
|
-
alreadyPublished: await
|
|
897
|
+
alreadyPublished: await ask<string>({
|
|
912
898
|
type: "list",
|
|
913
899
|
name: "alreadyPublished",
|
|
914
900
|
message: "When a package version is already published:",
|
|
915
|
-
choices: ["success", "error"],
|
|
901
|
+
choices: stringChoices(["success", "error"]),
|
|
916
902
|
default: currentTargets.npm?.alreadyPublished || "success",
|
|
917
903
|
}),
|
|
918
904
|
};
|
|
@@ -921,14 +907,14 @@ async function handleRelease(mode: ICliMode): Promise<void> {
|
|
|
921
907
|
}
|
|
922
908
|
|
|
923
909
|
if (enabledTargets.includes("docker")) {
|
|
924
|
-
const registry = await
|
|
910
|
+
const registry = await ask({
|
|
925
911
|
type: "input",
|
|
926
912
|
name: "dockerRegistry",
|
|
927
913
|
message:
|
|
928
914
|
"Single tsdocker registry target (empty means all configured registries):",
|
|
929
915
|
default: currentTargets.docker?.registry || "",
|
|
930
916
|
});
|
|
931
|
-
const buildRegistries = await
|
|
917
|
+
const buildRegistries = await ask({
|
|
932
918
|
type: "input",
|
|
933
919
|
name: "dockerBuildRegistries",
|
|
934
920
|
message:
|
|
@@ -937,7 +923,7 @@ async function handleRelease(mode: ICliMode): Promise<void> {
|
|
|
937
923
|
? currentTargets.docker.buildRegistries.join(", ")
|
|
938
924
|
: "",
|
|
939
925
|
});
|
|
940
|
-
const patterns = await
|
|
926
|
+
const patterns = await ask({
|
|
941
927
|
type: "input",
|
|
942
928
|
name: "dockerPatterns",
|
|
943
929
|
message:
|
|
@@ -946,25 +932,25 @@ async function handleRelease(mode: ICliMode): Promise<void> {
|
|
|
946
932
|
? currentTargets.docker.patterns.join(", ")
|
|
947
933
|
: "",
|
|
948
934
|
});
|
|
949
|
-
const test = await
|
|
935
|
+
const test = await ask({
|
|
950
936
|
type: "confirm",
|
|
951
937
|
name: "dockerTest",
|
|
952
938
|
message: "Run configured image tests before destination publication?",
|
|
953
939
|
default: currentTargets.docker?.test ?? false,
|
|
954
940
|
});
|
|
955
|
-
const cached = await
|
|
941
|
+
const cached = await ask({
|
|
956
942
|
type: "confirm",
|
|
957
943
|
name: "dockerCached",
|
|
958
944
|
message: "Use tsdocker cached builds?",
|
|
959
945
|
default: currentTargets.docker?.cached ?? false,
|
|
960
946
|
});
|
|
961
|
-
const parallel = await
|
|
947
|
+
const parallel = await ask({
|
|
962
948
|
type: "input",
|
|
963
949
|
name: "dockerParallel",
|
|
964
950
|
message: "tsdocker parallel mode (false, true, or concurrency number):",
|
|
965
951
|
default: formatDockerParallel(currentTargets.docker?.parallel ?? false),
|
|
966
952
|
});
|
|
967
|
-
const context = await
|
|
953
|
+
const context = await ask({
|
|
968
954
|
type: "input",
|
|
969
955
|
name: "dockerContext",
|
|
970
956
|
message: "Docker context for tsdocker (empty for default):",
|
|
@@ -1045,7 +1031,7 @@ async function handleFix(argvArg: any, mode: ICliMode): Promise<void> {
|
|
|
1045
1031
|
);
|
|
1046
1032
|
}
|
|
1047
1033
|
const confirmed =
|
|
1048
|
-
await
|
|
1034
|
+
await confirm(
|
|
1049
1035
|
`Run configuration fixes for .smartconfig.json? (${counts.error} error, ${counts.warn} warning)`,
|
|
1050
1036
|
true,
|
|
1051
1037
|
);
|
|
@@ -1633,11 +1619,6 @@ function formatTarget(enabled: unknown, targetConfig: any): string {
|
|
|
1633
1619
|
return details.length > 0 ? `${state} (${details.join(", ")})` : state;
|
|
1634
1620
|
}
|
|
1635
1621
|
|
|
1636
|
-
async function askValue<T>(interactInstance: any, options: any): Promise<T> {
|
|
1637
|
-
const response = await interactInstance.askQuestion(options);
|
|
1638
|
-
return response.value as T;
|
|
1639
|
-
}
|
|
1640
|
-
|
|
1641
1622
|
async function readPackageJson(): Promise<Record<string, any>> {
|
|
1642
1623
|
const packageJsonPath = plugins.path.join(process.cwd(), "package.json");
|
|
1643
1624
|
if (!(await plugins.smartfs.file(packageJsonPath).exists())) {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import * as plugins from "./mod.plugins.js";
|
|
2
|
-
import {
|
|
2
|
+
import { logger } from "../gitzone.logging.js";
|
|
3
|
+
import {
|
|
4
|
+
normalizeNpmRegistryUrl,
|
|
5
|
+
planNpmAvailabilityProbes,
|
|
6
|
+
probeDelayForAttempt,
|
|
7
|
+
} from "../mod_release/helpers.npmartifact.js";
|
|
3
8
|
|
|
4
9
|
export interface IDeprecationPlan {
|
|
5
10
|
packageName: string;
|
|
@@ -82,15 +87,16 @@ const readMetadata = async (
|
|
|
82
87
|
packageName: string,
|
|
83
88
|
fetchImplementation: typeof fetch,
|
|
84
89
|
): Promise<IPackageMetadata> => {
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
const url = new URL(`${registry}/${encodeURIComponent(packageName)}`);
|
|
91
|
+
// CDNs such as the one in front of npmjs key cached metadata by URL and
|
|
92
|
+
// ignore no-cache request headers; a unique query reaches the origin.
|
|
93
|
+
url.searchParams.set("cache-bust", plugins.crypto.randomUUID());
|
|
94
|
+
const response = await fetchImplementation(url, {
|
|
95
|
+
method: "GET",
|
|
96
|
+
redirect: "error",
|
|
97
|
+
signal: AbortSignal.timeout(30_000),
|
|
98
|
+
headers: { accept: "application/json", "cache-control": "no-cache" },
|
|
99
|
+
});
|
|
94
100
|
if (response.status === 404)
|
|
95
101
|
throw new Error(`${packageName} is not published on ${registry}.`);
|
|
96
102
|
if (!response.ok)
|
|
@@ -125,6 +131,15 @@ const isDeprecationComplete = (
|
|
|
125
131
|
(version) => version.deprecated === message,
|
|
126
132
|
);
|
|
127
133
|
|
|
134
|
+
/**
|
|
135
|
+
* npmjs serves an accepted deprecation only after replication, which can take
|
|
136
|
+
* tens of seconds. Verification backs off from two seconds to twenty across a
|
|
137
|
+
* ninety-second window before it reports the registry as not yet verified.
|
|
138
|
+
*/
|
|
139
|
+
const deprecationVerificationWindowMs = 90_000;
|
|
140
|
+
const deprecationVerificationDelayMs = 2_000;
|
|
141
|
+
const deprecationVerificationMaxDelayMs = 20_000;
|
|
142
|
+
|
|
128
143
|
/**
|
|
129
144
|
* Verify the old package (and its replacement, when one is named) on every
|
|
130
145
|
* registry before changing metadata for any of them.
|
|
@@ -134,8 +149,15 @@ export const executeDeprecation = async (
|
|
|
134
149
|
shell: plugins.smartshell.Smartshell,
|
|
135
150
|
cwd: string,
|
|
136
151
|
fetchImplementation: typeof fetch = fetch,
|
|
152
|
+
delayImplementation: (millisecondsArg: number) => Promise<unknown> =
|
|
153
|
+
plugins.smartdelay.delayFor,
|
|
137
154
|
): Promise<void> => {
|
|
138
155
|
const plan = createDeprecationPlan(planArg);
|
|
156
|
+
const verification = planNpmAvailabilityProbes(
|
|
157
|
+
deprecationVerificationWindowMs,
|
|
158
|
+
deprecationVerificationDelayMs,
|
|
159
|
+
deprecationVerificationMaxDelayMs,
|
|
160
|
+
);
|
|
139
161
|
for (const registry of plan.registries) {
|
|
140
162
|
if (plan.replacement !== null) {
|
|
141
163
|
const replacement = await readMetadata(
|
|
@@ -163,7 +185,14 @@ export const executeDeprecation = async (
|
|
|
163
185
|
plan.packageName,
|
|
164
186
|
fetchImplementation,
|
|
165
187
|
);
|
|
166
|
-
if (isDeprecationComplete(existing, plan.message))
|
|
188
|
+
if (isDeprecationComplete(existing, plan.message)) {
|
|
189
|
+
logger.log(
|
|
190
|
+
"info",
|
|
191
|
+
`${plan.packageName} already carries this deprecation on ${registry}.`,
|
|
192
|
+
);
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
logger.log("info", `Deprecating ${plan.packageName} on ${registry}.`);
|
|
167
196
|
const result = await shell.execSpawn(
|
|
168
197
|
"pnpm",
|
|
169
198
|
[
|
|
@@ -179,8 +208,13 @@ export const executeDeprecation = async (
|
|
|
179
208
|
timeoutKillGraceMs: 5_000,
|
|
180
209
|
},
|
|
181
210
|
);
|
|
211
|
+
if (result.exitCode !== 0)
|
|
212
|
+
logger.log(
|
|
213
|
+
"warn",
|
|
214
|
+
`pnpm deprecate exited with code ${result.exitCode} on ${registry}; checking whether the registry accepted the deprecation.`,
|
|
215
|
+
);
|
|
182
216
|
let verified = false;
|
|
183
|
-
for (let attempt = 0; attempt <
|
|
217
|
+
for (let attempt = 0; attempt < verification.attempts; attempt++) {
|
|
184
218
|
const metadata = await readMetadata(
|
|
185
219
|
registry,
|
|
186
220
|
plan.packageName,
|
|
@@ -190,15 +224,29 @@ export const executeDeprecation = async (
|
|
|
190
224
|
verified = true;
|
|
191
225
|
break;
|
|
192
226
|
}
|
|
193
|
-
if (attempt <
|
|
194
|
-
|
|
227
|
+
if (attempt + 1 < verification.attempts) {
|
|
228
|
+
const delayMs = probeDelayForAttempt(
|
|
229
|
+
attempt,
|
|
230
|
+
verification.delayMs,
|
|
231
|
+
verification.maxDelayMs,
|
|
232
|
+
);
|
|
233
|
+
logger.log(
|
|
234
|
+
"info",
|
|
235
|
+
`Deprecation is not yet visible for every version on ${registry}; checking again in ${delayMs / 1_000} s.`,
|
|
236
|
+
);
|
|
237
|
+
await delayImplementation(delayMs);
|
|
238
|
+
}
|
|
195
239
|
}
|
|
196
240
|
if (!verified) {
|
|
197
241
|
if (result.exitCode !== 0)
|
|
198
242
|
throw new Error(`Deprecation failed on ${registry}.`);
|
|
199
243
|
throw new Error(
|
|
200
|
-
`Deprecation is not yet verified for every version on ${registry}; rerunning the same deprecation is safe.`,
|
|
244
|
+
`Deprecation is not yet verified for every version on ${registry} after ${deprecationVerificationWindowMs / 1_000} s; rerunning the same deprecation is safe.`,
|
|
201
245
|
);
|
|
202
246
|
}
|
|
247
|
+
logger.log(
|
|
248
|
+
"ok",
|
|
249
|
+
`Verified the deprecation of every ${plan.packageName} version on ${registry}.`,
|
|
250
|
+
);
|
|
203
251
|
}
|
|
204
252
|
};
|
|
@@ -2,6 +2,7 @@ import * as plugins from "./mod.plugins.js";
|
|
|
2
2
|
|
|
3
3
|
import { logger } from "../gitzone.logging.js";
|
|
4
4
|
import { getCliMode, printJson } from "../helpers.climode.js";
|
|
5
|
+
import { ask, confirm, withPrompts } from "../helpers.prompts.js";
|
|
5
6
|
import {
|
|
6
7
|
createDeprecationPlan,
|
|
7
8
|
describeDeprecationPlan,
|
|
@@ -35,7 +36,7 @@ export const run = async (argvArg: any = {}) => {
|
|
|
35
36
|
throw new Error(
|
|
36
37
|
"Specify --package, --registries, and --replacement or --message.",
|
|
37
38
|
);
|
|
38
|
-
const
|
|
39
|
+
const answers = await withPrompts((prompts) => prompts.askAll([
|
|
39
40
|
{
|
|
40
41
|
name: `registryUrls`,
|
|
41
42
|
message: `What are the comma separated registry URLs?`,
|
|
@@ -63,14 +64,13 @@ export const run = async (argvArg: any = {}) => {
|
|
|
63
64
|
return !process.env.CI;
|
|
64
65
|
},
|
|
65
66
|
},
|
|
66
|
-
]);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const newPackageAnswer = answerBucket.getAnswerFor("newPackageName");
|
|
67
|
+
]));
|
|
68
|
+
registryInput = answers.registryUrls;
|
|
69
|
+
oldPackageName = answers.oldPackageName;
|
|
70
|
+
const newPackageAnswer = answers.newPackageName;
|
|
71
71
|
newPackageName = newPackageAnswer === "" ? undefined : newPackageAnswer;
|
|
72
72
|
if (newPackageName === undefined && message === undefined) {
|
|
73
|
-
|
|
73
|
+
message = await ask({
|
|
74
74
|
name: `message`,
|
|
75
75
|
message: `What deprecation message guides users of the OLD package?`,
|
|
76
76
|
type: `input`,
|
|
@@ -79,7 +79,6 @@ export const run = async (argvArg: any = {}) => {
|
|
|
79
79
|
return stringInput !== "" && !process.env.CI;
|
|
80
80
|
},
|
|
81
81
|
});
|
|
82
|
-
message = messageAnswer.value;
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
84
|
if (
|
|
@@ -106,7 +105,7 @@ export const run = async (argvArg: any = {}) => {
|
|
|
106
105
|
if (!mode.interactive)
|
|
107
106
|
throw new Error("Deprecation requires -y or interactive confirmation.");
|
|
108
107
|
if (
|
|
109
|
-
!(await
|
|
108
|
+
!(await confirm(
|
|
110
109
|
`Deprecate every version of ${plan.packageName}?`,
|
|
111
110
|
false,
|
|
112
111
|
))
|
package/ts/mod_docker/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as plugins from './mod.plugins.js';
|
|
|
2
2
|
import { logger } from '../gitzone.logging.js';
|
|
3
3
|
import type { ICliMode } from '../helpers.climode.js';
|
|
4
4
|
import { getCliMode, printJson } from '../helpers.climode.js';
|
|
5
|
+
import { ask } from '../helpers.prompts.js';
|
|
5
6
|
import {
|
|
6
7
|
DockerPruner,
|
|
7
8
|
pruneConsentLabelKey,
|
|
@@ -51,14 +52,13 @@ async function handlePrune(argvArg: any, mode: ICliMode) {
|
|
|
51
52
|
'`docker prune --volumes --apply` destroys persisted data. Re-run with --yes to confirm non-interactively.',
|
|
52
53
|
);
|
|
53
54
|
}
|
|
54
|
-
const
|
|
55
|
-
const confirmAnswer = await smartinteraction.askQuestion({
|
|
55
|
+
const confirmAnswer = await ask({
|
|
56
56
|
name: 'confirm',
|
|
57
57
|
type: 'input',
|
|
58
58
|
message: `Type "yes" to permanently delete ${reclaimableVolumes.length} volume(s) and their data:`,
|
|
59
59
|
default: 'no',
|
|
60
60
|
});
|
|
61
|
-
return confirmAnswer
|
|
61
|
+
return confirmAnswer === 'yes';
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
if (mode.json) {
|
|
@@ -3,6 +3,10 @@ import type { IPlannedChange } from "../interfaces.format.js";
|
|
|
3
3
|
import * as plugins from "../mod.plugins.js";
|
|
4
4
|
import { logger, logVerbose } from "../../gitzone.logging.js";
|
|
5
5
|
import { migrateSmartconfigData } from "../../helpers.smartconfigmigrations.js";
|
|
6
|
+
import {
|
|
7
|
+
answerDefaultsWithoutTerminal,
|
|
8
|
+
withPrompts,
|
|
9
|
+
} from "../../helpers.prompts.js";
|
|
6
10
|
|
|
7
11
|
const CONFIG_FILE = ".smartconfig.json";
|
|
8
12
|
|
|
@@ -68,7 +72,6 @@ export class SmartconfigFormatter extends BaseFormatter {
|
|
|
68
72
|
"module.license",
|
|
69
73
|
];
|
|
70
74
|
|
|
71
|
-
const interactInstance = new plugins.smartinteract.SmartInteract();
|
|
72
75
|
const missingRepoInformation = expectedRepoInformation.filter(
|
|
73
76
|
(expectedRepoInformationItem) => {
|
|
74
77
|
return !plugins.smartobject.smartGet(
|
|
@@ -84,29 +87,19 @@ export class SmartconfigFormatter extends BaseFormatter {
|
|
|
84
87
|
);
|
|
85
88
|
}
|
|
86
89
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
)
|
|
94
|
-
interactInstance.addQuestions([
|
|
95
|
-
{
|
|
96
|
-
message: `What is the value of ${expectedRepoInformationItem}`,
|
|
97
|
-
name: expectedRepoInformationItem,
|
|
98
|
-
type: "input",
|
|
99
|
-
default: "undefined variable",
|
|
100
|
-
},
|
|
101
|
-
]);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
90
|
+
const missingRepoQuestions: plugins.smartconsole.IInputQuestion[] =
|
|
91
|
+
missingRepoInformation.map((missingRepoInformationItem) => ({
|
|
92
|
+
message: `What is the value of ${missingRepoInformationItem}`,
|
|
93
|
+
name: missingRepoInformationItem,
|
|
94
|
+
type: "input",
|
|
95
|
+
default: "undefined variable",
|
|
96
|
+
}));
|
|
104
97
|
|
|
105
|
-
const
|
|
98
|
+
const answers = await withPrompts((prompts) =>
|
|
99
|
+
prompts.add(missingRepoQuestions).runQueue(answerDefaultsWithoutTerminal),
|
|
100
|
+
);
|
|
106
101
|
for (const expectedRepoInformationItem of expectedRepoInformation) {
|
|
107
|
-
const cliProvidedValue =
|
|
108
|
-
expectedRepoInformationItem,
|
|
109
|
-
);
|
|
102
|
+
const cliProvidedValue = answers[expectedRepoInformationItem];
|
|
110
103
|
if (cliProvidedValue) {
|
|
111
104
|
plugins.smartobject.smartAdd(
|
|
112
105
|
smartconfigJson["@git.zone/cli"],
|