juisy 2.2.0 → 3.0.0-beta.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.
Files changed (59) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +85 -0
  3. package/bin/cli/cli.js +3 -0
  4. package/bin/cli/cmds/index.js +2 -4
  5. package/bin/scripts/prepare.js +22 -22
  6. package/dist/DataExporter.d.ts +9 -4
  7. package/dist/bootstrap.d.ts +6 -0
  8. package/dist/bootstrap.js +21 -0
  9. package/dist/cli/CLIFactory.d.ts +1 -0
  10. package/dist/cli/Command.d.ts +23 -2
  11. package/dist/cli/GlobalSettings.schema.json +1 -1
  12. package/dist/cli/InterfaceUtils.d.ts +14 -12
  13. package/dist/cli/OutputUtils.d.ts +30 -16
  14. package/dist/cli/Plugin.d.ts +9 -0
  15. package/dist/cli/extract-usage.d.ts +8 -0
  16. package/dist/cli/index.d.ts +1 -0
  17. package/dist/cli/index.js +210 -122
  18. package/dist/cli/plugins/command-meta/augment.d.ts +1 -4
  19. package/dist/cli/plugins/command-meta/index.d.ts +4 -0
  20. package/dist/cli/plugins/default-command-fallbacks/augment.d.ts +1 -1
  21. package/dist/cli/plugins/default-command-fallbacks/command-visitors/default-command-fallbacks.d.ts +1 -1
  22. package/dist/cli/plugins/default-command-fallbacks/index.d.ts +4 -0
  23. package/dist/cli/plugins/load-env-file/augment.d.ts +1 -1
  24. package/dist/cli/plugins/load-env-file/index.d.ts +4 -0
  25. package/dist/cli/plugins/private-commands/augment.d.ts +8 -0
  26. package/dist/cli/plugins/private-commands/command-visitors/private-command.d.ts +7 -3
  27. package/dist/cli/plugins/private-commands/index.d.ts +4 -0
  28. package/dist/cli/plugins/register-bump-version-command/index.d.ts +4 -0
  29. package/dist/cli/plugins/register-changelog-command/index.d.ts +4 -0
  30. package/dist/cli/plugins/register-docs-commands/index.d.ts +4 -0
  31. package/dist/cli/plugins/register-git-hooks-commands/index.d.ts +4 -0
  32. package/dist/cli/plugins/register-lint-commands/index.d.ts +4 -0
  33. package/dist/cli/plugins/register-lint-commands/settings.d.ts +2 -0
  34. package/dist/cli/plugins/register-lint-commands/types.d.ts +5 -9
  35. package/dist/cli/plugins/register-release-command/index.d.ts +4 -0
  36. package/dist/cli/plugins/register-test-command/index.d.ts +4 -0
  37. package/dist/cli/types.d.ts +9 -1
  38. package/dist/cli/utils.d.ts +3 -4
  39. package/dist/eject.d.ts +1 -0
  40. package/dist/extensions.d.ts +26 -0
  41. package/dist/extensions.js +44 -0
  42. package/dist/get-package-info.d.ts +1 -0
  43. package/dist/index.d.ts +5 -5
  44. package/dist/index.js +23 -128
  45. package/dist/project-globals.d.ts +6 -2
  46. package/dist/shims/shims.d.ts +1440 -0
  47. package/dist/templater/index.d.ts +4 -1
  48. package/dist/templater/index.js +43 -24
  49. package/dist/templater/markdown-templater/ReadmeTemplater.d.ts +12 -12
  50. package/dist/templater/markdown-templater/index.d.ts +10 -1
  51. package/package.json +43 -49
  52. package/bin/cli/cmds/private/docs/generate-api.js +0 -31
  53. package/bin/cli/cmds/private/docs/index.js +0 -20
  54. package/bin/cli/cmds/private/test.js +0 -33
  55. package/dist/utils/misc.d.ts +0 -84
  56. package/dist/vite/plugins/inject-css-variables/index.d.ts +0 -23
  57. package/dist/vite/plugins/inject-css-variables/index.js +0 -60
  58. package/dist/vite/plugins/inject-project-globals/index.d.ts +0 -19
  59. package/dist/vite/plugins/inject-project-globals/index.js +0 -58
package/dist/cli/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v2.2.0
2
+ * juisy v3.0.0-beta.0
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -27,6 +27,11 @@ import { ESLint } from 'eslint';
27
27
  import yargsParser from 'yargs-parser';
28
28
 
29
29
  class Plugin {
30
+ /**
31
+ * Creates a Plugin instance
32
+ * @param name - The unique name
33
+ * @param pluginObject - The plugin object
34
+ */
30
35
  constructor(name, pluginObject) {
31
36
  this.name = name;
32
37
  if (pluginObject.beforeCreate) {
@@ -50,10 +55,12 @@ class Plugin {
50
55
  * The beforeCreate hook (can be async)
51
56
  */
52
57
  beforeCreate;
58
+ // eslint-disable-line @typescript-eslint/no-explicit-any
53
59
  /**
54
60
  * The created hook (must be sync)
55
61
  */
56
62
  created;
63
+ // eslint-disable-line @typescript-eslint/no-explicit-any
57
64
  }
58
65
 
59
66
  const loading = {
@@ -93,13 +100,31 @@ class OutputUtils {
93
100
  index: 0
94
101
  // 0 by default
95
102
  };
103
+ /**
104
+ * The logger instance
105
+ * @ignore
106
+ */
107
+ static _loggerInstance = console;
96
108
  /**
97
109
  * Use `chalk` package to style output in console/stdout
98
110
  * @example
99
- * const { $style } = OutputUtils
100
- * console.log($style.green('Green text!')) // => '[32mGreen text![0m'
111
+ * const { $style, log } = OutputUtils
112
+ * log($style.green('Green text!')) // => '[32mGreen text![0m'
101
113
  */
102
114
  static $style = chalk;
115
+ /**
116
+ * Set logger instance
117
+ * @param loggerInstance - The logger instance to set
118
+ */
119
+ static setLoggerInstance(loggerInstance) {
120
+ this._loggerInstance = loggerInstance;
121
+ }
122
+ /**
123
+ * Get the logger instance
124
+ */
125
+ static getLoggerInstance() {
126
+ return this._loggerInstance;
127
+ }
103
128
  /**
104
129
  * Format a message for console output
105
130
  * @param msg - The message to format
@@ -128,12 +153,11 @@ class OutputUtils {
128
153
  return formatted;
129
154
  }
130
155
  /**
156
+ * Log message in console
131
157
  * @param msg - The message
132
158
  * @param options - (Optional) Options object
133
159
  * @param options.indent - How many repeat indent (see `indent-string` package)
134
160
  * @param options.indentChar - Indent character(s). If `options.indent` not provided, will be repeated only 1 time
135
- * @description
136
- * Log message in console
137
161
  * @example
138
162
  * const { log } = OutputUtils
139
163
  * log() // => blank line
@@ -141,7 +165,7 @@ class OutputUtils {
141
165
  * log('To do:', { indent: 2 }) // => ' To do:'
142
166
  */
143
167
  static log(msg, options = {}) {
144
- const loggerInstance = options.loggerInstance || console;
168
+ const loggerInstance = options.loggerInstance || OutputUtils.getLoggerInstance();
145
169
  if (msg) {
146
170
  loggerInstance.log(OutputUtils.formatOutputMessage(msg, options));
147
171
  } else {
@@ -159,12 +183,11 @@ class OutputUtils {
159
183
  OutputUtils.log(OutputUtils.$style.yellow(`⚠ Warning: ${msg}`));
160
184
  }
161
185
  /**
186
+ * Display error message. Throws `err` if provided.
162
187
  * @param msg - The message to display
163
188
  * @param err - If provided, throw the error
164
- * @description
165
- * Display error message. Throws `err` if provided.
166
189
  * @example
167
- * const { error } = require('@hperchec/juisy').utils
190
+ * const { error } = OutputUtils
168
191
  * error('No configuration file') // => '[31m⨉ ERROR: No configuration file[0m'
169
192
  * error('No configuration file', error) // => Log and throws error
170
193
  */
@@ -181,6 +204,7 @@ class OutputUtils {
181
204
  * @param options - Options object
182
205
  * @param options.index - Custom index. If `null`, no index prepended to string
183
206
  * @example
207
+ * const { step } = OutputUtils
184
208
  * step('Important step') // => '● 1 - Important step'
185
209
  * step('Very important step') // => '● 2 - Very important step'
186
210
  */
@@ -197,7 +221,7 @@ class OutputUtils {
197
221
  * @param options - Options object
198
222
  * @param options.last - Defines if it is the last substep
199
223
  * @example
200
- * const { substep } = require('@hperchec/juisy').utils
224
+ * const { substep } = OutputUtils
201
225
  * substep('Awesome substep') // => '├ Awesome substep'
202
226
  * substep('Last substep', { last: true }) // => '└ Last substep'
203
227
  */
@@ -205,13 +229,11 @@ class OutputUtils {
205
229
  OutputUtils.log(msg, { indentChar: options.last ? "└ " : "├ " });
206
230
  }
207
231
  /**
208
- * @param {string} message - Message to display
209
- * @param {Function} fct - The function to execute
210
- * @returns {Promise<void>}
211
- * @description
212
232
  * Wait function: display loading during 'fct' execution
233
+ * @param message - Message to display
234
+ * @param fct - The function to execute
213
235
  * @example
214
- * const { wait } = require('@hperchec/juisy').utils
236
+ * const { wait } = OutputUtils
215
237
  * await wait('Waiting', async () => {
216
238
  * // Do async logic
217
239
  * })
@@ -231,7 +253,7 @@ class OutputUtils {
231
253
  class Command {
232
254
  /**
233
255
  * Creates a Command instance from object (CommandObject)
234
- * @param {CommandObject} commandObject - The command definition object
256
+ * @param commandObject - The command definition object
235
257
  */
236
258
  constructor(commandObject) {
237
259
  if (commandObject) {
@@ -240,10 +262,8 @@ class Command {
240
262
  this.describe = commandObject.describe;
241
263
  this.deprecated = commandObject.deprecated;
242
264
  this.meta = commandObject.meta;
243
- if (commandObject.builder)
244
- this.builder = commandObject.builder;
245
- if (commandObject.handler)
246
- this.handler = commandObject.handler;
265
+ if (commandObject.builder) this.builder = commandObject.builder;
266
+ if (commandObject.handler) this.handler = commandObject.handler;
247
267
  this.middlewares = commandObject.middlewares;
248
268
  }
249
269
  }
@@ -301,6 +321,12 @@ class Command {
301
321
  getProcessArgv() {
302
322
  return hideBin(process.argv);
303
323
  }
324
+ /**
325
+ * Get the command signature as string
326
+ */
327
+ getSignature() {
328
+ return this.constructor.getSignature(this);
329
+ }
304
330
  /**
305
331
  * Get Command instance as plain object
306
332
  * @returns The command definition object to pass to yargs
@@ -329,10 +355,32 @@ class Command {
329
355
  /**
330
356
  * Static properties
331
357
  */
358
+ /**
359
+ * The CLI engine
360
+ * @ignore
361
+ */
362
+ static _engine;
332
363
  /**
333
364
  * The CLI engine. Will be set by createEngine method
334
365
  */
335
- static engine;
366
+ static get engine() {
367
+ return this._engine;
368
+ }
369
+ /**
370
+ * Set the CLI engine
371
+ * @param engine - The CLI engine
372
+ */
373
+ static setEngine(engine) {
374
+ this._engine = engine;
375
+ OutputUtils.setLoggerInstance(this._engine.getInternalMethods().getLoggerInstance());
376
+ }
377
+ /**
378
+ * Get the command signature as string
379
+ * @param cmdObj - Can be an instance of Command or a command object
380
+ */
381
+ static getSignature(cmdObj) {
382
+ return cmdObj.command ? Array.isArray(cmdObj.command) ? cmdObj.command.join(" ") : cmdObj.command : "";
383
+ }
336
384
  }
337
385
 
338
386
  function createEngine(yargs) {
@@ -357,7 +405,10 @@ function createEngine(yargs) {
357
405
  xargs.enableGlobalCommandVisitors = enableGlobalCommandVisitors;
358
406
  xargs.isPrivate = isPrivate;
359
407
  xargs.getSettings = getSettings;
360
- Command.engine = xargs.strict().help();
408
+ Command.setEngine(
409
+ xargs.strict().help()
410
+ // Enable help
411
+ );
361
412
  return Command.engine;
362
413
  }
363
414
  function command(...args) {
@@ -383,8 +434,7 @@ function command(...args) {
383
434
  const cmdsArray = [];
384
435
  for (const commandModule of args[0]) {
385
436
  const visited = visit((isClass(commandModule) ? new commandModule() : commandModule).toObject());
386
- if (visited)
387
- cmdsArray.push(visited);
437
+ if (visited) cmdsArray.push(visited);
388
438
  }
389
439
  return self.originalCommand(cmdsArray);
390
440
  } else {
@@ -448,18 +498,21 @@ function getSettings(path) {
448
498
  }
449
499
 
450
500
  const proxify = (target) => {
451
- const tmp = new Proxy(target instanceof Array ? [] : {}, {
452
- // Overwrite Object type getter to 'observe'
453
- get: (obj, prop) => {
454
- if (prop in obj) {
455
- if (resolveSettingsCallbacks[prop]) {
456
- return resolveSettingsCallbacks[prop](obj[prop]);
501
+ const tmp = new Proxy(
502
+ target instanceof Array ? [] : {},
503
+ {
504
+ // Overwrite Object type getter to 'observe'
505
+ get: (obj, prop) => {
506
+ if (prop in obj) {
507
+ if (resolveSettingsCallbacks[prop]) {
508
+ return resolveSettingsCallbacks[prop](obj[prop]);
509
+ }
510
+ return obj[prop];
457
511
  }
458
- return obj[prop];
512
+ return void 0;
459
513
  }
460
- return void 0;
461
514
  }
462
- });
515
+ );
463
516
  for (const property in target) {
464
517
  tmp[property] = target[property];
465
518
  }
@@ -480,8 +533,7 @@ const findCommandIn = (fullSignature, commands) => {
480
533
  } else {
481
534
  if (command.children?.length) {
482
535
  const found = findCommandIn(fullSignature, command.children);
483
- if (found)
484
- return found;
536
+ if (found) return found;
485
537
  }
486
538
  }
487
539
  }
@@ -490,6 +542,7 @@ const getDefaultCommand = (fullSignature) => {
490
542
  return findCommandIn(fullSignature, defaultCommands);
491
543
  };
492
544
  const resolveSettingsCallbacks = {
545
+ // eslint-disable-line @typescript-eslint/no-unsafe-function-type
493
546
  // ...
494
547
  };
495
548
  function defineSettings(target, settings, options) {
@@ -512,17 +565,19 @@ async function CLIFactory(builder, options) {
512
565
  if (options?.settingsPath) {
513
566
  settingsPath = options.settingsPath;
514
567
  }
515
- const configPath = findUpSync(settingsPath ? [settingsPath] : [
516
- "dev.config.ts",
517
- "dev.config.js",
518
- "dev.config.json",
519
- "cli.config.ts",
520
- "cli.config.js",
521
- "cli.config.json",
522
- ".clirc.ts",
523
- ".clirc.js",
524
- ".clirc.json"
525
- ]);
568
+ const configPath = findUpSync(
569
+ settingsPath ? [settingsPath] : [
570
+ "dev.config.ts",
571
+ "dev.config.js",
572
+ "dev.config.json",
573
+ "cli.config.ts",
574
+ "cli.config.js",
575
+ "cli.config.json",
576
+ ".clirc.ts",
577
+ ".clirc.js",
578
+ ".clirc.json"
579
+ ]
580
+ );
526
581
  if (settingsPath && !configPath) {
527
582
  throw new Error("Unable to find file: " + settingsPath);
528
583
  } else if (configPath) {
@@ -592,7 +647,7 @@ class InterfaceUtils {
592
647
  * Get root directory path
593
648
  * @example
594
649
  * const { rootDir } = InterfaceUtils
595
- * console.log(rootDir) // => 'path/to/your/root/dir'
650
+ * console.log(rootDir) // 'path/to/your/root/dir'
596
651
  */
597
652
  static rootDir = process.cwd();
598
653
  static run(bin, args, opts) {
@@ -621,26 +676,23 @@ class InterfaceUtils {
621
676
  return callExeca();
622
677
  }
623
678
  /**
624
- * @param {number} [code] - Code for process.exit() (default: 0)
625
- * @returns {void}
626
- * @description
627
679
  * Exit process
680
+ * @param code - Code for process.exit() (default: 0)
628
681
  * @example
629
682
  * const { abort } = InterfaceUtils
630
- * abort() // => exit process with code 0
631
- * abort(1) // => error code
683
+ * abort() // exit process with code 0
684
+ * abort(1) // error code
632
685
  */
633
686
  static abort(code = 0) {
634
687
  log($style.yellow("Aborted..."));
635
688
  process.exit(code);
636
689
  }
637
690
  /**
691
+ * Demand confirmation with prompts native util. If not confirmed, it will automatically abort the script.
638
692
  * @param question - A prompt question object
639
693
  * @param options - A prompt options object
640
- * @returns {Promise<boolean>} - True if confirmed
641
- * @description
642
- * Demand confirmation with prompts native util. If not confirmed, it will automatically abort the script.
643
694
  * @example
695
+ * const { confirm } = InterfaceUtils
644
696
  * confirm({ message: 'Confirm to continue' }) // Deny it will abort the script
645
697
  */
646
698
  static async confirm(question, options = {}) {
@@ -723,12 +775,13 @@ class BumpVersionCommand extends Command {
723
775
  const { $style, step, substep, error } = OutputUtils;
724
776
  const { confirm, prompts, abort } = InterfaceUtils;
725
777
  const packageJsonPath = argv.file ? path.isAbsolute(argv.file) ? argv.file : path.join(process.cwd(), argv.file) : path.resolve(process.cwd(), "package.json");
726
- const pkg = JSON.parse(fs$1.readFileSync(packageJsonPath, "utf-8"));
778
+ const pkg = JSON.parse(
779
+ fs$1.readFileSync(packageJsonPath, "utf-8")
780
+ );
727
781
  let targetVersion = argv.targetVersion;
728
782
  step("Bump version");
729
783
  if (!targetVersion) {
730
784
  const currentVersion = pkg.version;
731
- pkg.name;
732
785
  const preId = argv.preid || semver.prerelease(currentVersion) && semver.prerelease(currentVersion)[0];
733
786
  const inc = (i) => semver.inc(currentVersion, i, preId);
734
787
  const versionIncrements = [
@@ -759,14 +812,17 @@ class BumpVersionCommand extends Command {
759
812
  } else {
760
813
  targetVersion = release;
761
814
  }
762
- await confirm({
763
- type: "confirm",
764
- name: "yes",
765
- message: `Releasing v${targetVersion}. Confirm?`,
766
- initial: true
767
- }, {
768
- onCancel: () => abort()
769
- });
815
+ await confirm(
816
+ {
817
+ type: "confirm",
818
+ name: "yes",
819
+ message: `Releasing v${targetVersion}. Confirm?`,
820
+ initial: true
821
+ },
822
+ {
823
+ onCancel: () => abort()
824
+ }
825
+ );
770
826
  }
771
827
  let commandError = false;
772
828
  try {
@@ -810,7 +866,7 @@ const changelog = new Command({
810
866
  const { $style, step, substep, error, wait } = OutputUtils;
811
867
  const { run } = InterfaceUtils;
812
868
  step("Generating changelog");
813
- const { onReleaseConfig, ...commandOptions } = this.engine.getSettings("changelog");
869
+ const { ...commandOptions } = this.engine.getSettings("changelog");
814
870
  const flattenOptions = (options) => {
815
871
  const _array = [];
816
872
  for (const key in options) {
@@ -825,10 +881,14 @@ const changelog = new Command({
825
881
  };
826
882
  await wait("Generating", async () => {
827
883
  try {
828
- await run("npx", [
829
- "conventional-changelog",
830
- ...flattenOptions(commandOptions)
831
- ], { stdio: "inherit" });
884
+ await run(
885
+ "npx",
886
+ [
887
+ "conventional-changelog",
888
+ ...flattenOptions(commandOptions)
889
+ ],
890
+ { stdio: "inherit" }
891
+ );
832
892
  } catch (e) {
833
893
  error("Unable to generate changelog", e);
834
894
  }
@@ -1056,35 +1116,14 @@ function resolveCommitlintSettings(settings = {}) {
1056
1116
  return settings;
1057
1117
  }
1058
1118
  function resolveMarkdownlintSettings(settings = []) {
1059
- const normalizeRootConfig = (config = {}) => {
1060
- return {
1061
- config: {},
1062
- ...config
1063
- };
1064
- };
1065
- const normalizeConfig = (config = {}) => {
1066
- return {
1067
- config: {},
1068
- ...config,
1069
- globs: config.globs
1070
- };
1071
- };
1072
- let resolved = [];
1073
- let rootConfig = {
1074
- config: {}
1075
- };
1076
- const globScopedConfigs = [];
1119
+ const resolved = [];
1077
1120
  for (const item of settings) {
1078
- if (!item.globs && typeof rootConfig.config !== "string") {
1079
- rootConfig = deepmerge(rootConfig, item);
1080
- } else if (!(item.globs instanceof Array) || !item.globs.length) {
1121
+ if (item.globs && (!(item.globs instanceof Array) || !item.globs.length)) {
1081
1122
  throw new Error('lint.markdown configuration: if provided, "globs" property must be a non-empty array');
1082
1123
  } else {
1083
- globScopedConfigs.push(item);
1124
+ resolved.push(item);
1084
1125
  }
1085
1126
  }
1086
- resolved.push(normalizeRootConfig(rootConfig));
1087
- resolved.push(...globScopedConfigs.map(normalizeConfig));
1088
1127
  return resolved;
1089
1128
  }
1090
1129
  function resolveLintStagedSettings(settings = {}) {
@@ -1117,6 +1156,10 @@ const lint = new Command({
1117
1156
  describe: "Provide configuration file path",
1118
1157
  type: "string",
1119
1158
  requiresArg: true
1159
+ }).option("stats", {
1160
+ describe: "Display stats",
1161
+ type: "boolean",
1162
+ default: false
1120
1163
  });
1121
1164
  const lintSettings = cli.getSettings("lint.default");
1122
1165
  if (lintSettings?.config) {
@@ -1129,7 +1172,8 @@ const lint = new Command({
1129
1172
  step("Configuring linter");
1130
1173
  const lintSettings = this.engine.getSettings("lint.default") || {};
1131
1174
  const eslintOptions = {
1132
- fix: !!argv.fix
1175
+ fix: !!argv.fix,
1176
+ stats: !!argv.stats
1133
1177
  };
1134
1178
  if (argv.config) {
1135
1179
  eslintOptions.overrideConfigFile = argv.config;
@@ -1170,7 +1214,7 @@ const lintCommit = new Command({
1170
1214
  return cli;
1171
1215
  },
1172
1216
  async handler(argv) {
1173
- const { abort, run } = InterfaceUtils;
1217
+ const { run } = InterfaceUtils;
1174
1218
  const { $style, step, substep, error } = OutputUtils;
1175
1219
  step("Configuring commitlint");
1176
1220
  const lintSettings = this.engine.getSettings("lint.commit");
@@ -1195,7 +1239,11 @@ const lintCommit = new Command({
1195
1239
  }
1196
1240
  let commandError;
1197
1241
  try {
1198
- await run("npx", ["commitlint", ...commitLintCmdArgs], { stdio: "pipe" });
1242
+ await run(
1243
+ "npx",
1244
+ ["commitlint", ...commitLintCmdArgs],
1245
+ { stdio: "pipe" }
1246
+ );
1199
1247
  } catch (e) {
1200
1248
  commandError = e;
1201
1249
  }
@@ -1227,19 +1275,16 @@ const lintMarkdown = new Command({
1227
1275
  return cli;
1228
1276
  },
1229
1277
  async handler(argv) {
1230
- const { abort, run } = InterfaceUtils;
1278
+ const { run } = InterfaceUtils;
1231
1279
  const { $style, step, substep, error } = OutputUtils;
1232
1280
  step("Configuring markdownlint");
1233
1281
  const configs = this.engine.getSettings("lint.markdown") || [];
1234
- const rootConfig = configs.splice(configs.findIndex((config) => !config.globs), 1);
1235
1282
  let commandError;
1236
1283
  for (const item of configs) {
1237
1284
  let tempConfig;
1238
1285
  const mdLintCmdArgs = [...item.globs];
1239
1286
  const tempConfigFilePath = "__TEMP_MARKDOWNLINT_CONFIG__.markdownlint-cli2.jsonc";
1240
- if (!item.config) {
1241
- tempConfig = rootConfig;
1242
- } else {
1287
+ if (item.config) {
1243
1288
  tempConfig = item.config;
1244
1289
  }
1245
1290
  if (typeof tempConfig === "string") {
@@ -1252,7 +1297,11 @@ const lintMarkdown = new Command({
1252
1297
  mdLintCmdArgs.push("--fix");
1253
1298
  }
1254
1299
  try {
1255
- await run("npx", ["markdownlint-cli2", ...mdLintCmdArgs], { stdio: "pipe" });
1300
+ await run(
1301
+ "npx",
1302
+ ["markdownlint-cli2", ...mdLintCmdArgs],
1303
+ { stdio: "pipe" }
1304
+ );
1256
1305
  } catch (e) {
1257
1306
  commandError = e;
1258
1307
  if (fs$1.existsSync(path.resolve(tempConfigFilePath))) {
@@ -1260,6 +1309,9 @@ const lintMarkdown = new Command({
1260
1309
  }
1261
1310
  break;
1262
1311
  }
1312
+ if (fs$1.existsSync(path.resolve(tempConfigFilePath))) {
1313
+ fs$1.unlinkSync(path.resolve(tempConfigFilePath));
1314
+ }
1263
1315
  }
1264
1316
  if (commandError) {
1265
1317
  substep($style.red("❌ An error has occured."), { last: true });
@@ -1339,22 +1391,26 @@ const lintStaged = new Command({
1339
1391
 
1340
1392
  const RegisterLintCommands = new Plugin("built-in:register-lint-commands", {
1341
1393
  beforeCreate({ defineDefaultCommand, defineSettings, builder, factoryOptions }) {
1342
- defineSettings("lint", {
1343
- default: {
1344
- config: "eslint.config.js"
1345
- },
1346
- commit: {
1347
- // ...
1394
+ defineSettings(
1395
+ "lint",
1396
+ {
1397
+ default: {
1398
+ config: "eslint.config.js"
1399
+ },
1400
+ commit: {
1401
+ // ...
1402
+ },
1403
+ markdown: [],
1404
+ staged: {
1405
+ "*.{js,cjs,ts}": [
1406
+ "eslint --fix"
1407
+ ]
1408
+ }
1348
1409
  },
1349
- markdown: [],
1350
- staged: {
1351
- "*.{js,cjs,ts}": [
1352
- "eslint --fix"
1353
- ]
1410
+ {
1411
+ resolve: resolveSettings
1354
1412
  }
1355
- }, {
1356
- resolve: resolveSettings
1357
- });
1413
+ );
1358
1414
  defineDefaultCommand({
1359
1415
  fullSignature: "lint",
1360
1416
  commandObject: lint,
@@ -1458,7 +1514,12 @@ const release = new Command({
1458
1514
  releaseItCmdArgs.push("--config", releaseSettings.config);
1459
1515
  } else {
1460
1516
  const changelogSettings = this.engine.getSettings("changelog");
1461
- const { onReleaseConfig, preset, infile, context } = changelogSettings;
1517
+ const {
1518
+ onReleaseConfig,
1519
+ preset,
1520
+ infile,
1521
+ context
1522
+ } = changelogSettings;
1462
1523
  const releaseItChangelogConfig = {
1463
1524
  infile: onReleaseConfig.infile || infile,
1464
1525
  header: onReleaseConfig.header,
@@ -1547,6 +1608,7 @@ const RegisterReleaseCommand = new Plugin("built-in:register-release-command", {
1547
1608
  git: {
1548
1609
  commitMessage: "chore(release): v${version}",
1549
1610
  requireBranch: "main",
1611
+ tagName: "v${version}",
1550
1612
  tagAnnotation: "v${version}"
1551
1613
  }
1552
1614
  });
@@ -1633,9 +1695,23 @@ const CommandMeta = new Plugin("built-in:command-meta", {
1633
1695
  }
1634
1696
  });
1635
1697
 
1698
+ const visitorsCache = [];
1636
1699
  const visitor = function(commandObject, engine, options2) {
1637
1700
  const { metaProp, envKey } = options2;
1638
- if (commandObject.meta?.[metaProp]) {
1701
+ let isMadePrivate = !!commandObject.meta?.[metaProp];
1702
+ for (const localVisitor of visitorsCache) {
1703
+ const result = localVisitor(commandObject);
1704
+ if (result !== void 0) {
1705
+ isMadePrivate = result;
1706
+ }
1707
+ }
1708
+ if (!commandObject.meta) commandObject.meta = {};
1709
+ if (isMadePrivate) {
1710
+ commandObject.meta[metaProp] = true;
1711
+ } else {
1712
+ commandObject.meta[metaProp] = false;
1713
+ }
1714
+ if (commandObject.meta[metaProp]) {
1639
1715
  if (process.env[envKey] === "private") {
1640
1716
  commandObject.builder = wrapCommandBuilder(commandObject.builder, function(cli) {
1641
1717
  cli._isPrivate = true;
@@ -1652,8 +1728,15 @@ const options = {
1652
1728
  envKey: "CLI_ENV"
1653
1729
  };
1654
1730
 
1731
+ function makeCommandPrivate(visitor) {
1732
+ visitorsCache.push(visitor);
1733
+ return this;
1734
+ }
1655
1735
  const PrivateCommands = new Plugin("built-in:private-commands", {
1656
1736
  created({ engine, builder, factoryOptions }) {
1737
+ Object.defineProperty(engine.constructor.prototype, "makeCommandPrivate", {
1738
+ value: makeCommandPrivate
1739
+ });
1657
1740
  engine.globalCommandVisitor("private-command-visitor", visitor, options);
1658
1741
  }
1659
1742
  });
@@ -1671,8 +1754,7 @@ async function extractUsage(factory, recursive = false, args = [""], locale = "e
1671
1754
  children: recursive ? {} : void 0
1672
1755
  };
1673
1756
  const parseCallback = function(err, argv, output) {
1674
- if (err)
1675
- throw err;
1757
+ if (err) throw err;
1676
1758
  const self = this;
1677
1759
  doclet.args = argv._;
1678
1760
  doclet.command = argv._[argv._.length - 1];
@@ -1701,7 +1783,13 @@ async function extractUsage(factory, recursive = false, args = [""], locale = "e
1701
1783
  await innerYargs.parseAsync(args, { help: true }, parseCallback);
1702
1784
  if (recursive) {
1703
1785
  for (const childCommand in doclet.extractedUsage.commands) {
1704
- doclet.children[childCommand] = await extractUsage(factory, true, [...args.filter((a) => a !== ""), childCommand], locale);
1786
+ doclet.children[childCommand] = await extractUsage(
1787
+ // eslint-disable-line @typescript-eslint/no-explicit-any
1788
+ factory,
1789
+ true,
1790
+ [...args.filter((a) => a !== ""), childCommand],
1791
+ locale
1792
+ );
1705
1793
  }
1706
1794
  }
1707
1795
  return doclet;
@@ -1,3 +1,4 @@
1
+ export {};
1
2
  declare module '../../types' {
2
3
  /**
3
4
  * @group Types
@@ -13,11 +14,7 @@ declare module '../../types' {
13
14
  */
14
15
  getMeta: () => this['_meta'];
15
16
  }
16
- /**
17
- * @group Types
18
- */
19
17
  interface CommandObject {
20
18
  meta?: Partial<CommandMeta>;
21
19
  }
22
20
  }
23
- export {};
@@ -1,3 +1,7 @@
1
1
  import { Plugin } from '../../Plugin';
2
+ /**
3
+ * Built-in plugin: 'built-in:command-meta'
4
+ * @group None
5
+ */
2
6
  declare const _default: Plugin;
3
7
  export default _default;
@@ -1,3 +1,3 @@
1
+ export {};
1
2
  declare module '../../types' {
2
3
  }
3
- export {};