@git.zone/cli 8.2.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 (53) 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/index.js +9 -10
  9. package/dist_ts/mod_deprecate/mod.plugins.d.ts +1 -2
  10. package/dist_ts/mod_deprecate/mod.plugins.js +2 -3
  11. package/dist_ts/mod_docker/index.js +4 -4
  12. package/dist_ts/mod_format/formatters/smartconfig.formatter.js +10 -16
  13. package/dist_ts/mod_format/index.js +6 -6
  14. package/dist_ts/mod_format/mod.plugins.d.ts +1 -2
  15. package/dist_ts/mod_format/mod.plugins.js +2 -3
  16. package/dist_ts/mod_meta/meta.classes.meta.js +5 -4
  17. package/dist_ts/mod_meta/meta.plugins.d.ts +1 -2
  18. package/dist_ts/mod_meta/meta.plugins.js +2 -3
  19. package/dist_ts/mod_release/index.js +5 -4
  20. package/dist_ts/mod_services/classes.servicemanager.js +9 -13
  21. package/dist_ts/mod_services/index.js +10 -17
  22. package/dist_ts/mod_services/mod.plugins.d.ts +1 -2
  23. package/dist_ts/mod_services/mod.plugins.js +2 -3
  24. package/dist_ts/mod_standard/index.js +3 -4
  25. package/dist_ts/mod_template/index.js +5 -6
  26. package/dist_ts/mod_template/mod.plugins.d.ts +1 -2
  27. package/dist_ts/mod_template/mod.plugins.js +2 -3
  28. package/dist_ts/mod_tools/index.js +5 -10
  29. package/dist_ts/plugins.d.ts +2 -3
  30. package/dist_ts/plugins.js +3 -4
  31. package/package.json +3 -4
  32. package/ts/00_commitinfo_data.ts +1 -1
  33. package/ts/helpers.prompts.ts +70 -0
  34. package/ts/mod_commit/index.ts +37 -48
  35. package/ts/mod_commit/mod.plugins.ts +1 -2
  36. package/ts/mod_config/index.ts +44 -63
  37. package/ts/mod_deprecate/index.ts +8 -9
  38. package/ts/mod_deprecate/mod.plugins.ts +1 -2
  39. package/ts/mod_docker/index.ts +3 -3
  40. package/ts/mod_format/formatters/smartconfig.formatter.ts +15 -22
  41. package/ts/mod_format/index.ts +9 -5
  42. package/ts/mod_format/mod.plugins.ts +0 -2
  43. package/ts/mod_meta/meta.classes.meta.ts +7 -3
  44. package/ts/mod_meta/meta.plugins.ts +1 -2
  45. package/ts/mod_release/index.ts +4 -3
  46. package/ts/mod_services/classes.servicemanager.ts +8 -14
  47. package/ts/mod_services/index.ts +17 -24
  48. package/ts/mod_services/mod.plugins.ts +1 -2
  49. package/ts/mod_standard/index.ts +2 -4
  50. package/ts/mod_template/index.ts +4 -5
  51. package/ts/mod_template/mod.plugins.ts +1 -2
  52. package/ts/mod_tools/index.ts +4 -10
  53. package/ts/plugins.ts +2 -4
@@ -39,6 +39,7 @@ import {
39
39
  type TServiceMigrationScope,
40
40
  } from '../../ts_migration/index.js';
41
41
  import { logger } from '../gitzone.logging.js';
42
+ import { answerDefaultsWithoutTerminal, ask } from '../helpers.prompts.js';
42
43
  import {
43
44
  readSmartconfigFile,
44
45
  setCliConfigValueInData,
@@ -755,8 +756,7 @@ export class ServiceManager {
755
756
  // Check if services array exists
756
757
  if (persistedServices.length === 0) {
757
758
  // Prompt user to select services
758
- const smartinteract = new plugins.smartinteract.SmartInteract();
759
- const response = await smartinteract.askQuestion({
759
+ const enabledServices = await ask<string>({
760
760
  name: 'services',
761
761
  type: 'checkbox',
762
762
  message: 'Which services do you want to enable for this project?',
@@ -766,9 +766,7 @@ export class ServiceManager {
766
766
  { name: 'Elasticsearch', value: 'elasticsearch' }
767
767
  ],
768
768
  default: ['mongodb', 'objectstorage', 'elasticsearch']
769
- });
770
-
771
- const enabledServices = response.value || ['mongodb', 'objectstorage', 'elasticsearch'];
769
+ }, answerDefaultsWithoutTerminal);
772
770
  this.enabledServices = enabledServices;
773
771
 
774
772
  // Save to .smartconfig.json
@@ -3042,8 +3040,7 @@ export class ServiceManager {
3042
3040
 
3043
3041
  const currentServices = this.enabledServices || ['mongodb', 'objectstorage', 'elasticsearch'];
3044
3042
 
3045
- const smartinteract = new plugins.smartinteract.SmartInteract();
3046
- const response = await smartinteract.askQuestion({
3043
+ const enabledServices = await ask<string>({
3047
3044
  name: 'services',
3048
3045
  type: 'checkbox',
3049
3046
  message: 'Which services do you want to enable?',
@@ -3053,9 +3050,7 @@ export class ServiceManager {
3053
3050
  { name: 'Elasticsearch', value: 'elasticsearch' }
3054
3051
  ],
3055
3052
  default: currentServices
3056
- });
3057
-
3058
- const enabledServices = response.value || ['mongodb', 'objectstorage', 'elasticsearch'];
3053
+ }, answerDefaultsWithoutTerminal);
3059
3054
  this.enabledServices = enabledServices;
3060
3055
 
3061
3056
  // Save to .smartconfig.json
@@ -3073,15 +3068,14 @@ export class ServiceManager {
3073
3068
 
3074
3069
  // Ask if user wants to restart services after releasing the reconfiguration
3075
3070
  // locks; startAll acquires the same locks one service at a time.
3076
- const smartinteract = new plugins.smartinteract.SmartInteract();
3077
- const response = await smartinteract.askQuestion({
3071
+ const restart = await ask({
3078
3072
  name: 'restart',
3079
3073
  type: 'confirm',
3080
3074
  message: 'Do you want to start services with new ports?',
3081
3075
  default: true
3082
- });
3076
+ }, answerDefaultsWithoutTerminal);
3083
3077
 
3084
- if (response.value) {
3078
+ if (restart) {
3085
3079
  console.log();
3086
3080
  await this.startAll();
3087
3081
  await this.registerWithGlobalRegistry();
@@ -17,6 +17,11 @@ import {
17
17
  type IServicePrunePlan,
18
18
  } from "./classes.servicepruner.js";
19
19
  import { logger } from "../gitzone.logging.js";
20
+ import {
21
+ answerDefaultsWithoutTerminal,
22
+ ask,
23
+ confirm,
24
+ } from "../helpers.prompts.js";
20
25
  import type { ICliMode } from "../helpers.climode.js";
21
26
  import {
22
27
  getCliMode,
@@ -569,14 +574,8 @@ async function handleMigrate(
569
574
  "`services migrate` stops and replaces the legacy database container. Re-run with --yes to confirm non-interactively.",
570
575
  );
571
576
  }
572
- const smartinteraction = new plugins.smartinteract.SmartInteract();
573
- const confirmAnswer = await smartinteraction.askQuestion({
574
- name: "confirm",
575
- type: "confirm",
576
- message: "Migrate now?",
577
- default: false,
578
- });
579
- if (!confirmAnswer.value) {
577
+ const migrateNow = await confirm("Migrate now?", false);
578
+ if (!migrateNow) {
580
579
  logger.log("note", "Cancelled");
581
580
  return;
582
581
  }
@@ -595,11 +594,7 @@ async function handleRemove(serviceManager: ServiceManager, mode: ICliMode) {
595
594
  "`services remove` needs confirmation. Re-run with --yes to remove containers non-interactively.",
596
595
  );
597
596
  }
598
- const shouldContinue =
599
- await plugins.smartinteract.SmartInteract.getCliConfirmation(
600
- "Continue?",
601
- false,
602
- );
597
+ const shouldContinue = await confirm("Continue?", false);
603
598
  if (!shouldContinue) {
604
599
  logger.log("note", "Cancelled");
605
600
  return;
@@ -622,14 +617,13 @@ async function handleClean(serviceManager: ServiceManager, mode: ICliMode) {
622
617
  "`services clean` destroys data and needs explicit intent. Re-run with --yes to confirm non-interactively.",
623
618
  );
624
619
  }
625
- const smartinteraction = new plugins.smartinteract.SmartInteract();
626
- const confirmAnswer = await smartinteraction.askQuestion({
620
+ const confirmAnswer = await ask({
627
621
  name: "confirm",
628
622
  type: "input",
629
623
  message: 'Type "yes" to confirm:',
630
624
  default: "no",
631
625
  });
632
- if (confirmAnswer.value !== "yes") {
626
+ if (confirmAnswer !== "yes") {
633
627
  logger.log("note", "Cancelled");
634
628
  return;
635
629
  }
@@ -731,14 +725,13 @@ async function handlePrune(argvArg: any, mode: ICliMode) {
731
725
  "`services prune --apply` would delete data directories. Re-run with --yes to confirm non-interactively.",
732
726
  );
733
727
  }
734
- const smartinteraction = new plugins.smartinteract.SmartInteract();
735
- const confirmAnswer = await smartinteraction.askQuestion({
728
+ const confirmAnswer = await ask({
736
729
  name: "confirm",
737
730
  type: "input",
738
731
  message: `Type "yes" to permanently delete ${plan.dataDirsToRemove.length} data directory/ies:`,
739
732
  default: "no",
740
733
  });
741
- return confirmAnswer.value === "yes";
734
+ return confirmAnswer === "yes";
742
735
  };
743
736
 
744
737
  if (mode.json) {
@@ -1232,11 +1225,11 @@ async function handleGlobalStop(globalRegistry: GlobalRegistry) {
1232
1225
  }
1233
1226
 
1234
1227
  console.log();
1235
- const shouldContinue =
1236
- await plugins.smartinteract.SmartInteract.getCliConfirmation(
1237
- "Stop all containers?",
1238
- false,
1239
- );
1228
+ const shouldContinue = await confirm(
1229
+ "Stop all containers?",
1230
+ false,
1231
+ answerDefaultsWithoutTerminal,
1232
+ );
1240
1233
 
1241
1234
  if (!shouldContinue) {
1242
1235
  logger.log("note", "Cancelled");
@@ -2,11 +2,10 @@ export * from '../plugins.js';
2
2
 
3
3
  import * as smartshell from '@push.rocks/smartshell';
4
4
  import * as smartfile from '@push.rocks/smartfile';
5
- import * as smartinteract from '@push.rocks/smartinteract';
6
5
  import * as smartnetwork from '@push.rocks/smartnetwork';
7
6
  import * as smartdelay from '@push.rocks/smartdelay';
8
7
 
9
8
  // @lossless.org scope
10
9
  import * as nosqldb from '@lossless.org/client/nosqldb';
11
10
 
12
- export { smartshell, smartfile, smartinteract, smartnetwork, smartdelay, nosqldb };
11
+ export { smartshell, smartfile, smartnetwork, smartdelay, nosqldb };
@@ -5,6 +5,7 @@ import * as plugins from "./mod.plugins.js";
5
5
  import * as paths from "../paths.js";
6
6
  import type { ICliMode } from "../helpers.climode.js";
7
7
  import { getCliMode, printJson } from "../helpers.climode.js";
8
+ import { ask } from "../helpers.prompts.js";
8
9
 
9
10
  import { logger } from "../gitzone.logging.js";
10
11
 
@@ -67,8 +68,7 @@ export let run = async (argvArg: any = {}) => {
67
68
  );
68
69
  console.log("");
69
70
 
70
- const interactInstance = new plugins.smartinteract.SmartInteract();
71
- const response = await interactInstance.askQuestion({
71
+ const action = await ask({
72
72
  type: "list",
73
73
  name: "action",
74
74
  message: "What would you like to do?",
@@ -86,8 +86,6 @@ export let run = async (argvArg: any = {}) => {
86
86
  ],
87
87
  });
88
88
 
89
- const action = (response as any).value;
90
-
91
89
  switch (action) {
92
90
  case "commit": {
93
91
  const modCommit = await import("../mod_commit/index.js");
@@ -2,6 +2,7 @@ import * as plugins from './mod.plugins.js';
2
2
  import * as paths from '../paths.js';
3
3
 
4
4
  import { logger } from '../gitzone.logging.js';
5
+ import { answerDefaultsWithoutTerminal, ask, stringChoices } from '../helpers.prompts.js';
5
6
 
6
7
  export const getTemplatePath = (templateNameArg: string) => {
7
8
  return plugins.path.join(paths.templatesDir, templateNameArg);
@@ -30,16 +31,14 @@ export const run = async (argvArg: any) => {
30
31
  let chosenTemplate: string = argvArg._[1];
31
32
 
32
33
  if (!chosenTemplate) {
33
- const smartinteract = new plugins.smartinteract.SmartInteract();
34
- const answerBucket = await smartinteract.askQuestion({
34
+ chosenTemplate = await ask({
35
35
  type: 'list',
36
36
  default: 'npm',
37
37
  message:
38
38
  'What template do you want to scaffold? (Only showing mpost common options)',
39
39
  name: 'templateName',
40
- choices: ['npm', 'service', 'wcc', 'website'],
41
- });
42
- chosenTemplate = answerBucket.value;
40
+ choices: stringChoices(['npm', 'service', 'wcc', 'website']),
41
+ }, answerDefaultsWithoutTerminal);
43
42
  }
44
43
 
45
44
  if (await isTemplate(chosenTemplate)) {
@@ -1,7 +1,6 @@
1
1
  export * from '../plugins.js';
2
2
 
3
3
  import * as smartfile from '@push.rocks/smartfile';
4
- import * as smartinteract from '@push.rocks/smartinteract';
5
4
  import * as smartscaf from '@push.rocks/smartscaf';
6
5
 
7
- export { smartfile, smartinteract, smartscaf };
6
+ export { smartfile, smartscaf };
@@ -2,6 +2,7 @@ import * as plugins from "./mod.plugins.js";
2
2
  import { commitinfo } from "../00_commitinfo_data.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
  PackageManagerUtil,
7
8
  type IInstalledPackage,
@@ -177,14 +178,12 @@ async function runUpdate(argvArg: any, mode: ICliMode): Promise<void> {
177
178
 
178
179
  let shouldUpdate = mode.yes;
179
180
  if (!shouldUpdate) {
180
- const interactInstance = new plugins.smartinteract.SmartInteract();
181
- const answer = await interactInstance.askQuestion({
181
+ shouldUpdate = await ask({
182
182
  type: "confirm",
183
183
  name: "confirmUpdate",
184
184
  message: "Do you want to update, migrate, and cleanup these tools?",
185
185
  default: true,
186
186
  });
187
- shouldUpdate = answer.value === true;
188
187
  }
189
188
 
190
189
  if (!shouldUpdate) {
@@ -279,16 +278,13 @@ async function runInstall(argvArg: any, mode: ICliMode): Promise<void> {
279
278
  });
280
279
  }
281
280
 
282
- const interactInstance = new plugins.smartinteract.SmartInteract();
283
- const answer = await interactInstance.askQuestion({
281
+ selectedPackages = await ask({
284
282
  type: "checkbox",
285
283
  name: "packages",
286
284
  message: "Select packages to install:",
287
285
  default: missingPackages,
288
286
  choices: choicesWithVersions,
289
287
  });
290
-
291
- selectedPackages = answer.value as string[];
292
288
  if (selectedPackages.length === 0) {
293
289
  console.log("No packages selected. Nothing to install.");
294
290
  return;
@@ -322,14 +318,12 @@ async function handleSelfUpdate(
322
318
 
323
319
  let shouldUpdate = mode.yes;
324
320
  if (!shouldUpdate) {
325
- const interactInstance = new plugins.smartinteract.SmartInteract();
326
- const answer = await interactInstance.askQuestion({
321
+ shouldUpdate = await ask({
327
322
  type: "confirm",
328
323
  name: "confirmSelfUpdate",
329
324
  message: "Do you want to update gitzone itself first?",
330
325
  default: true,
331
326
  });
332
- shouldUpdate = answer.value === true;
333
327
  }
334
328
 
335
329
  if (!shouldUpdate) {
package/ts/plugins.ts CHANGED
@@ -10,7 +10,7 @@ import * as fsSync from 'node:fs';
10
10
  import * as childProcess from 'node:child_process';
11
11
  import * as tty from 'node:tty';
12
12
  import * as projectinfo from '@push.rocks/projectinfo';
13
- import * as smartcli from '@push.rocks/smartcli';
13
+ import * as smartconsole from '@push.rocks/smartconsole';
14
14
  import * as smartpath from '@push.rocks/smartpath';
15
15
  import * as smartpromise from '@push.rocks/smartpromise';
16
16
  import * as smartupdate from '@push.rocks/smartupdate';
@@ -18,7 +18,6 @@ import * as smartshell from '@push.rocks/smartshell';
18
18
  import * as smartnetwork from '@push.rocks/smartnetwork';
19
19
  import * as smartfile from '@push.rocks/smartfile';
20
20
  import { SmartFs, SmartFsProviderNode } from '@push.rocks/smartfs';
21
- import * as smartinteract from '@push.rocks/smartinteract';
22
21
  import * as smartdelay from '@push.rocks/smartdelay';
23
22
 
24
23
  // @lossless.org scope
@@ -62,14 +61,13 @@ export {
62
61
  childProcess,
63
62
  tty,
64
63
  projectinfo,
65
- smartcli,
64
+ smartconsole,
66
65
  smartpath,
67
66
  smartpromise,
68
67
  smartupdate,
69
68
  smartshell,
70
69
  smartnetwork,
71
70
  smartfile,
72
- smartinteract,
73
71
  smartdelay,
74
72
  objectstorage,
75
73
  s3,