@git.zone/cli 8.1.0 → 8.2.1

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 (57) hide show
  1. package/dist_ts/00_commitinfo_data.js +1 -1
  2. package/dist_ts/helpers.prompts.d.ts +23 -0
  3. package/dist_ts/helpers.prompts.js +30 -0
  4. package/dist_ts/mod_commit/index.js +30 -41
  5. package/dist_ts/mod_commit/mod.plugins.d.ts +1 -2
  6. package/dist_ts/mod_commit/mod.plugins.js +2 -3
  7. package/dist_ts/mod_config/index.js +45 -61
  8. package/dist_ts/mod_deprecate/helpers.deprecation.d.ts +14 -4
  9. package/dist_ts/mod_deprecate/helpers.deprecation.js +34 -15
  10. package/dist_ts/mod_deprecate/index.js +38 -18
  11. package/dist_ts/mod_deprecate/mod.plugins.d.ts +1 -2
  12. package/dist_ts/mod_deprecate/mod.plugins.js +2 -3
  13. package/dist_ts/mod_docker/index.js +4 -4
  14. package/dist_ts/mod_format/formatters/smartconfig.formatter.js +10 -16
  15. package/dist_ts/mod_format/index.js +6 -6
  16. package/dist_ts/mod_format/mod.plugins.d.ts +1 -2
  17. package/dist_ts/mod_format/mod.plugins.js +2 -3
  18. package/dist_ts/mod_meta/meta.classes.meta.js +5 -4
  19. package/dist_ts/mod_meta/meta.plugins.d.ts +1 -2
  20. package/dist_ts/mod_meta/meta.plugins.js +2 -3
  21. package/dist_ts/mod_release/index.js +5 -4
  22. package/dist_ts/mod_services/classes.servicemanager.js +9 -13
  23. package/dist_ts/mod_services/index.js +10 -17
  24. package/dist_ts/mod_services/mod.plugins.d.ts +1 -2
  25. package/dist_ts/mod_services/mod.plugins.js +2 -3
  26. package/dist_ts/mod_standard/index.js +3 -4
  27. package/dist_ts/mod_template/index.js +5 -6
  28. package/dist_ts/mod_template/mod.plugins.d.ts +1 -2
  29. package/dist_ts/mod_template/mod.plugins.js +2 -3
  30. package/dist_ts/mod_tools/index.js +5 -10
  31. package/dist_ts/plugins.d.ts +2 -3
  32. package/dist_ts/plugins.js +3 -4
  33. package/package.json +3 -4
  34. package/readme.md +10 -2
  35. package/ts/00_commitinfo_data.ts +1 -1
  36. package/ts/helpers.prompts.ts +70 -0
  37. package/ts/mod_commit/index.ts +37 -48
  38. package/ts/mod_commit/mod.plugins.ts +1 -2
  39. package/ts/mod_config/index.ts +44 -63
  40. package/ts/mod_deprecate/helpers.deprecation.ts +54 -22
  41. package/ts/mod_deprecate/index.ts +43 -17
  42. package/ts/mod_deprecate/mod.plugins.ts +1 -2
  43. package/ts/mod_docker/index.ts +3 -3
  44. package/ts/mod_format/formatters/smartconfig.formatter.ts +15 -22
  45. package/ts/mod_format/index.ts +9 -5
  46. package/ts/mod_format/mod.plugins.ts +0 -2
  47. package/ts/mod_meta/meta.classes.meta.ts +7 -3
  48. package/ts/mod_meta/meta.plugins.ts +1 -2
  49. package/ts/mod_release/index.ts +4 -3
  50. package/ts/mod_services/classes.servicemanager.ts +8 -14
  51. package/ts/mod_services/index.ts +17 -24
  52. package/ts/mod_services/mod.plugins.ts +1 -2
  53. package/ts/mod_standard/index.ts +2 -4
  54. package/ts/mod_template/index.ts +4 -5
  55. package/ts/mod_template/mod.plugins.ts +1 -2
  56. package/ts/mod_tools/index.ts +4 -10
  57. package/ts/plugins.ts +2 -4
@@ -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 plugins.smartinteract.SmartInteract.getCliConfirmation(
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 interactInstance = new plugins.smartinteract.SmartInteract();
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
- const interactInstance = new plugins.smartinteract.SmartInteract();
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
- const interactInstance = new plugins.smartinteract.SmartInteract();
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 plugins.smartinteract.SmartInteract.getCliConfirmation(
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
- const interactInstance = new plugins.smartinteract.SmartInteract();
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 interactInstance = new plugins.smartinteract.SmartInteract();
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 askValue<string>(interactInstance, {
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 askValue<string>(interactInstance, {
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 askValue<string>(interactInstance, {
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 askValue<string>(interactInstance, {
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 askValue<string>(interactInstance, {
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 askValue<string>(interactInstance, {
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 askValue<string>(interactInstance, {
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 askValue<string>(interactInstance, {
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 askValue<string>(interactInstance, {
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 askValue<boolean>(interactInstance, {
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 askValue<boolean>(interactInstance, {
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 askValue<string>(interactInstance, {
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 askValue<boolean>(interactInstance, {
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 askValue<boolean>(interactInstance, {
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 askValue<string>(interactInstance, {
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 askValue<string>(interactInstance, {
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 askValue<string[]>(interactInstance, {
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 askValue<string>(interactInstance, {
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 askValue<string>(interactInstance, {
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 askValue<string>(interactInstance, {
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 askValue<string>(interactInstance, {
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 askValue<string>(interactInstance, {
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 askValue<string>(interactInstance, {
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 askValue<string>(interactInstance, {
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 askValue<boolean>(interactInstance, {
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 askValue<boolean>(interactInstance, {
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 askValue<string>(interactInstance, {
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 askValue<string>(interactInstance, {
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 plugins.smartinteract.SmartInteract.getCliConfirmation(
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())) {
@@ -3,25 +3,42 @@ import { normalizeNpmRegistryUrl } from "../mod_release/helpers.npmartifact.js";
3
3
 
4
4
  export interface IDeprecationPlan {
5
5
  packageName: string;
6
- replacement: string;
6
+ /** The package that supersedes the deprecated one, or `null` when none exists. */
7
+ replacement: string | null;
7
8
  message: string;
8
9
  registries: string[];
9
10
  }
10
11
 
12
+ export interface IDeprecationPlanOptions {
13
+ packageName: string;
14
+ replacement?: string | null;
15
+ message?: string;
16
+ registries: string[];
17
+ }
18
+
11
19
  export const createDeprecationPlan = (
12
- options: Omit<IDeprecationPlan, "message"> & { message?: string },
20
+ options: IDeprecationPlanOptions,
13
21
  ): IDeprecationPlan => {
14
22
  const namePattern = /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/;
15
23
  if (
16
24
  typeof options.packageName !== "string" ||
17
- typeof options.replacement !== "string" ||
18
- !namePattern.test(options.packageName) ||
19
- !namePattern.test(options.replacement) ||
20
- options.packageName === options.replacement
25
+ !namePattern.test(options.packageName)
26
+ )
27
+ throw new Error("Deprecation requires a valid package name.");
28
+ const replacement = options.replacement ?? null;
29
+ if (
30
+ replacement !== null &&
31
+ (typeof replacement !== "string" ||
32
+ !namePattern.test(replacement) ||
33
+ options.packageName === replacement)
21
34
  )
22
35
  throw new Error(
23
36
  "Deprecation requires distinct valid package and replacement names.",
24
37
  );
38
+ if (replacement === null && options.message == null)
39
+ throw new Error(
40
+ "Deprecation without a replacement requires a message with guidance.",
41
+ );
25
42
  if (!Array.isArray(options.registries))
26
43
  throw new Error("Invalid deprecation registries.");
27
44
  const registries = options.registries.map(normalizeNpmRegistryUrl);
@@ -29,7 +46,7 @@ export const createDeprecationPlan = (
29
46
  throw new Error("Deprecation requires unique explicit registries.");
30
47
  const message =
31
48
  options.message ??
32
- `Use ${options.replacement}. ${options.packageName} is deprecated.`;
49
+ `Use ${replacement}. ${options.packageName} is deprecated.`;
33
50
  if (
34
51
  typeof message !== "string" ||
35
52
  !message.trim() ||
@@ -40,12 +57,20 @@ export const createDeprecationPlan = (
40
57
  }
41
58
  return {
42
59
  packageName: options.packageName,
43
- replacement: options.replacement,
60
+ replacement,
44
61
  registries,
45
62
  message,
46
63
  };
47
64
  };
48
65
 
66
+ /** Human-readable plan lines; `--json` prints the plan object itself. */
67
+ export const describeDeprecationPlan = (plan: IDeprecationPlan): string[] => [
68
+ `package: ${plan.packageName}`,
69
+ `replacement: ${plan.replacement ?? "none"}`,
70
+ `registries: ${plan.registries.join(", ")}`,
71
+ `message: ${plan.message}`,
72
+ ];
73
+
49
74
  interface IPackageMetadata {
50
75
  name: string;
51
76
  versions: Record<string, { deprecated?: string }>;
@@ -66,6 +91,8 @@ const readMetadata = async (
66
91
  headers: { accept: "application/json", "cache-control": "no-cache" },
67
92
  },
68
93
  );
94
+ if (response.status === 404)
95
+ throw new Error(`${packageName} is not published on ${registry}.`);
69
96
  if (!response.ok)
70
97
  throw new Error(
71
98
  `Cannot verify ${packageName} on ${registry} (HTTP ${response.status}).`,
@@ -98,7 +125,10 @@ const isDeprecationComplete = (
98
125
  (version) => version.deprecated === message,
99
126
  );
100
127
 
101
- /** Verify replacements everywhere before changing metadata for any old package. */
128
+ /**
129
+ * Verify the old package (and its replacement, when one is named) on every
130
+ * registry before changing metadata for any of them.
131
+ */
102
132
  export const executeDeprecation = async (
103
133
  planArg: IDeprecationPlan,
104
134
  shell: plugins.smartshell.Smartshell,
@@ -107,20 +137,22 @@ export const executeDeprecation = async (
107
137
  ): Promise<void> => {
108
138
  const plan = createDeprecationPlan(planArg);
109
139
  for (const registry of plan.registries) {
110
- const replacement = await readMetadata(
111
- registry,
112
- plan.replacement,
113
- fetchImplementation,
114
- );
115
- const latestTag = replacement["dist-tags"]?.latest;
116
- const latest =
117
- typeof latestTag === "string"
118
- ? replacement.versions[latestTag]
119
- : undefined;
120
- if (!latest || latest.deprecated)
121
- throw new Error(
122
- `Replacement ${plan.replacement} has no active latest version on ${registry}.`,
140
+ if (plan.replacement !== null) {
141
+ const replacement = await readMetadata(
142
+ registry,
143
+ plan.replacement,
144
+ fetchImplementation,
123
145
  );
146
+ const latestTag = replacement["dist-tags"]?.latest;
147
+ const latest =
148
+ typeof latestTag === "string"
149
+ ? replacement.versions[latestTag]
150
+ : undefined;
151
+ if (!latest || latest.deprecated)
152
+ throw new Error(
153
+ `Replacement ${plan.replacement} has no active latest version on ${registry}.`,
154
+ );
155
+ }
124
156
  await readMetadata(registry, plan.packageName, fetchImplementation);
125
157
  }
126
158
  for (const registry of plan.registries) {
@@ -2,8 +2,10 @@ 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,
8
+ describeDeprecationPlan,
7
9
  executeDeprecation,
8
10
  } from "./helpers.deprecation.js";
9
11
 
@@ -14,17 +16,27 @@ export const run = async (argvArg: any = {}) => {
14
16
  "gitzone deprecate --package <old> --replacement <new> --registries <url,url> [--message <text>] [--plan] [-y]",
15
17
  );
16
18
  console.log(
17
- "Deprecates all versions after verifying the replacement on every registry.",
19
+ 'gitzone deprecate --package <old> --registries <url,url> --message "<old> is no longer maintained; <guidance>" [--plan] [-y]',
20
+ );
21
+ console.log(
22
+ "Deprecates all versions after verifying the package, and the replacement when one is named, on every registry.",
18
23
  );
19
24
  return;
20
25
  }
21
26
  let registryInput = argvArg.registries;
22
27
  let oldPackageName = argvArg.package;
23
28
  let newPackageName = argvArg.replacement;
24
- if (!registryInput || !oldPackageName || !newPackageName) {
29
+ let message = argvArg.message;
30
+ if (
31
+ !registryInput ||
32
+ !oldPackageName ||
33
+ (newPackageName === undefined && message === undefined)
34
+ ) {
25
35
  if (!mode.interactive || argvArg.plan || mode.json)
26
- throw new Error("Specify --package, --replacement, and --registries.");
27
- const smartInteract = new plugins.smartinteract.SmartInteract([
36
+ throw new Error(
37
+ "Specify --package, --registries, and --replacement or --message.",
38
+ );
39
+ const answers = await withPrompts((prompts) => prompts.askAll([
28
40
  {
29
41
  name: `registryUrls`,
30
42
  message: `What are the comma separated registry URLs?`,
@@ -45,23 +57,35 @@ export const run = async (argvArg: any = {}) => {
45
57
  },
46
58
  {
47
59
  name: `newPackageName`,
48
- message: `Whats the name of the NEW package?`,
60
+ message: `Whats the name of the NEW package? (leave empty if there is none)`,
61
+ type: `input`,
62
+ default: ``,
63
+ validate: () => {
64
+ return !process.env.CI;
65
+ },
66
+ },
67
+ ]));
68
+ registryInput = answers.registryUrls;
69
+ oldPackageName = answers.oldPackageName;
70
+ const newPackageAnswer = answers.newPackageName;
71
+ newPackageName = newPackageAnswer === "" ? undefined : newPackageAnswer;
72
+ if (newPackageName === undefined && message === undefined) {
73
+ message = await ask({
74
+ name: `message`,
75
+ message: `What deprecation message guides users of the OLD package?`,
49
76
  type: `input`,
50
77
  default: ``,
51
78
  validate: (stringInput) => {
52
79
  return stringInput !== "" && !process.env.CI;
53
80
  },
54
- },
55
- ]);
56
- const answerBucket = await smartInteract.runQueue();
57
- registryInput = answerBucket.getAnswerFor("registryUrls");
58
- oldPackageName = answerBucket.getAnswerFor("oldPackageName");
59
- newPackageName = answerBucket.getAnswerFor("newPackageName");
81
+ });
82
+ }
60
83
  }
61
84
  if (
62
85
  typeof registryInput !== "string" ||
63
86
  typeof oldPackageName !== "string" ||
64
- typeof newPackageName !== "string"
87
+ (newPackageName !== undefined && typeof newPackageName !== "string") ||
88
+ (message !== undefined && typeof message !== "string")
65
89
  ) {
66
90
  throw new Error("Deprecation arguments must be strings.");
67
91
  }
@@ -69,20 +93,20 @@ export const run = async (argvArg: any = {}) => {
69
93
  packageName: oldPackageName,
70
94
  replacement: newPackageName,
71
95
  registries: registryInput.split(",").map((value) => value.trim()),
72
- message: argvArg.message,
96
+ message,
73
97
  });
74
98
  if (mode.json) {
75
99
  printJson({ ok: true, plan });
76
100
  return;
77
101
  }
78
- console.log(JSON.stringify(plan, null, 2));
102
+ for (const line of describeDeprecationPlan(plan)) console.log(line);
79
103
  if (argvArg.plan) return;
80
104
  if (!mode.yes) {
81
105
  if (!mode.interactive)
82
106
  throw new Error("Deprecation requires -y or interactive confirmation.");
83
107
  if (
84
- !(await plugins.smartinteract.SmartInteract.getCliConfirmation(
85
- `Deprecate every version of ${oldPackageName}?`,
108
+ !(await confirm(
109
+ `Deprecate every version of ${plan.packageName}?`,
86
110
  false,
87
111
  ))
88
112
  )
@@ -90,7 +114,9 @@ export const run = async (argvArg: any = {}) => {
90
114
  }
91
115
  logger.log(
92
116
  "info",
93
- `Deprecating package ${oldPackageName} in favour of ${newPackageName}`,
117
+ plan.replacement === null
118
+ ? `Deprecating package ${plan.packageName} without a replacement`
119
+ : `Deprecating package ${plan.packageName} in favour of ${plan.replacement}`,
94
120
  );
95
121
  const smartshellInstance = new plugins.smartshell.Smartshell({
96
122
  executor: "bash",
@@ -1,6 +1,5 @@
1
1
  export * from '../plugins.js';
2
2
 
3
- import * as smartinteract from '@push.rocks/smartinteract';
4
3
  import * as smartshell from '@push.rocks/smartshell';
5
4
 
6
- export { smartinteract, smartshell };
5
+ export { smartshell };
@@ -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 smartinteraction = new plugins.smartinteract.SmartInteract();
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.value === 'yes';
61
+ return confirmAnswer === 'yes';
62
62
  };
63
63
 
64
64
  if (mode.json) {