juisy 2.0.0-beta.13 → 2.0.0-beta.15

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.
@@ -1 +1 @@
1
- {"$schema":"http://json-schema.org/draft-07/schema#","$ref":"#/definitions/GlobalSettings","definitions":{"GlobalSettings":{"type":"object","properties":{"release":{"$ref":"#/definitions/UserProvidedConfigSetting%3CReleaseIt.Config%3E","description":"Release configuration"}}},"UserProvidedConfigSetting<ReleaseIt.Config>":{"anyOf":[{"type":"object","properties":{"config":{"type":"string","description":"The configuration file path"}},"required":["config"]},{"type":"object","properties":{}}],"description":"Provide a configuration object or an object with only \"config\" property","examples":[{"config":"path/to/config/file"}]}}}
1
+ {"$schema":"http://json-schema.org/draft-07/schema#","$ref":"#/definitions/GlobalSettings","definitions":{"GlobalSettings":{"type":"object","properties":{"release":{"$ref":"#/definitions/UserProvidedConfigSetting%3CConfig%3E","description":"Release configuration"}}},"UserProvidedConfigSetting<Config>":{"anyOf":[{"type":"object","properties":{"config":{"type":"string","description":"The configuration file path"}},"required":["config"]},{"type":"object","properties":{"hooks":{"$ref":"#/definitions/Hooks"},"plugins":{"type":"object","additionalProperties":{"type":"object"}},"git":{"type":"object","properties":{"changelog":{"type":"string","default":"git log --pretty=format:\"* %s (%h)\" ${from}...${to}"},"requireCleanWorkingDir":{"type":"boolean","default":true},"requireBranch":{"type":"boolean","enum":[false],"default":false},"requireUpstream":{"type":"boolean","default":true},"requireCommits":{"type":"boolean","default":false},"requireCommitsFail":{"type":"boolean","default":true},"commitsPath":{"type":"string","default":""},"addUntrackedFiles":{"type":"boolean","default":false},"commit":{"type":"boolean","default":true},"commitMessage":{"type":"string","default":"Release ${version}"},"commitArgs":{"type":"array","items":{}},"tag":{"type":"boolean","default":true},"tagExclude":{"default":null},"tagName":{"default":null},"tagMatch":{"default":null},"getLatestTagFromAllRefs":{"type":"boolean","default":false},"tagAnnotation":{"type":"string","default":"Release ${version}"},"tagArgs":{"type":"array","items":{}},"push":{"type":"boolean","default":true},"pushArgs":{"type":"array","items":{"type":"string"},"default":["--follow-tags"]},"pushRepo":{"type":"string","default":""}}},"npm":{"type":"object","properties":{"publish":{"type":"boolean","default":true},"publishPath":{"type":"string","default":"."},"publishArgs":{"type":"array","items":{}},"tag":{"default":null},"otp":{"default":null},"ignoreVersion":{"type":"boolean","default":false},"allowSameVersion":{"type":"boolean","default":false},"versionArgs":{"type":"array","items":{}},"skipChecks":{"type":"boolean","default":false},"timeout":{"type":"number","default":10}}},"github":{"type":"object","properties":{"release":{"type":"boolean","default":false},"releaseName":{"type":"string","default":"Release ${version}"},"releaseNotes":{"default":null},"autoGenerate":{"type":"boolean","default":false},"preRelease":{"type":"boolean","default":false},"draft":{"type":"boolean","default":false},"tokenRef":{"type":"string","default":"GITHUB_TOKEN"},"assets":{"default":null},"host":{"default":null},"timeout":{"type":"number","default":0},"proxy":{"default":null},"makeLatest":{"anyOf":[{"type":"boolean"},{"type":"string","const":"legacy"}],"default":"true\n'legacy' - Github determines the latest release based on the release creation date and higher semantic version.\nSee https://docs.github.com/en/rest/releases/releases?apiVersion=latest#create-a-release"},"discussionCategoryName":{"type":["boolean","string"],"default":false},"skipChecks":{"type":"boolean","default":false},"web":{"type":"boolean","default":false},"comments":{"type":"object","properties":{"submit":{"type":"boolean","default":false},"issue":{"type":"string","default":":rocket?: _This issue has been resolved in v${version}. See [${releaseName}](${releaseUrl}) for release notes._"},"pr":{"type":"string","default":":rocket?: _This pull request is included in v${version}. See [${releaseName}](${releaseUrl}) for release notes._"}}}}},"gitlab":{"type":"object","properties":{"release":{"type":"boolean","default":false},"releaseName":{"type":"string","default":"Release ${version}"},"releaseNotes":{"default":null},"milestones":{"type":"array","items":{}},"tokenRef":{"type":"string","default":"GITLAB_TOKEN"},"tokenHeader":{"type":"string","default":"Private-Token"},"certificateAuthorityFile":{"default":null},"secure":{"type":"boolean","default":null},"assets":{"default":null},"useIdsForUrls":{"type":"boolean","default":false},"useGenericPackageRepositoryForAssets":{"type":"boolean","default":false},"genericPackageRepositoryName":{"type":"string","default":"release-it"},"origin":{"default":null},"skipChecks":{"type":"boolean","default":false}}}}}],"description":"Provide a configuration object or an object with only \"config\" property","examples":[{"config":"path/to/config/file"}]},"Hooks":{"type":"object","properties":{"before:init":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"before:bump":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"before:release":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"after:init":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"after:bump":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"after:release":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"before:version:init":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"before:version:bump":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"before:version:release":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"after:version:init":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"after:version:bump":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"after:version:release":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"before:git:init":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"before:git:bump":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"before:git:release":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"after:git:init":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"after:git:bump":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"after:git:release":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"before:npm:init":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"before:npm:bump":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"before:npm:release":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"after:npm:init":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"after:npm:bump":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"after:npm:release":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"before:github:init":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"before:github:bump":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"before:github:release":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"after:github:init":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"after:github:bump":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"after:github:release":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"before:gitlab:init":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"before:gitlab:bump":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"before:gitlab:release":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"after:gitlab:init":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"after:gitlab:bump":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"after:gitlab:release":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]}}}}}
@@ -1,4 +1,4 @@
1
- import { ExecaError } from 'execa';
1
+ import { ResultPromise as ExecaResultPromise, ExecaError, Options as ExecaOptions } from 'execa';
2
2
  import { default as _prompts } from 'prompts';
3
3
  /**
4
4
  * Command execution error thrown by execa
@@ -9,45 +9,49 @@ export declare class InterfaceUtils {
9
9
  /**
10
10
  * Get root directory path
11
11
  * @example
12
- * import { CLIUtils: { rootDir } } from '@hperchec/juisy'
12
+ * const { rootDir } = InterfaceUtils
13
13
  * console.log(rootDir) // => 'path/to/your/root/dir'
14
14
  */
15
15
  static rootDir: string;
16
16
  /**
17
- * @param {string} bin - Command
18
- * @param {string[]} args - Same as execa second arg
19
- * @param {object} [opts] - Options
20
- * @returns {Promise<object>} The `execa` Promise
17
+ * @param bin - Command
18
+ * @param args - Same as execa second arg
19
+ * @param opts - Options
20
+ * @returns The `execa` Promise
21
21
  * @throws {RunError}
22
22
  * @description
23
23
  * Run command (child_process). See also `execa` package documentation
24
24
  * @example
25
- * const { run } = require('@hperchec/juisy').utils
25
+ * const { run } = InterfaceUtils
26
+ * await run('npm run test')
27
+ * // With options
28
+ * await run('npm run test', { stdio: 'inherit' })
29
+ * // Old way
26
30
  * await run('npm', [ 'run', 'test' ], { stdio: 'inherit' })
27
31
  */
28
- static run(bin: string, args: string[], opts?: {}): import('execa').ExecaChildProcess<string>;
32
+ static run(command: string, opts?: ExecaOptions): ExecaResultPromise;
33
+ static run(bin: string, args: string[], opts?: ExecaOptions): ExecaResultPromise;
29
34
  /**
30
- * @alias utils.abort
31
35
  * @param {number} [code] - Code for process.exit() (default: 0)
32
36
  * @returns {void}
33
37
  * @description
34
38
  * Exit process
35
39
  * @example
36
- * const { abort } = require('@hperchec/juisy').utils
40
+ * const { abort } = InterfaceUtils
37
41
  * abort() // => exit process with code 0
38
42
  * abort(1) // => error code
39
43
  */
40
44
  static abort(code?: number): void;
41
45
  /**
42
- * @alias utils.confirm
43
- * @param {prompts.PromptObject} question - A prompt question object (see https://gitlab.com/hperchec/juisy/-/blob/main/documentation/utils.md#utilspromptsargs-object)
46
+ * @param question - A prompt question object
47
+ * @param options - A prompt options object
44
48
  * @returns {Promise<boolean>} - True if confirmed
45
49
  * @description
46
50
  * Demand confirmation with prompts native util. If not confirmed, it will automatically abort the script.
47
51
  * @example
48
52
  * confirm({ message: 'Confirm to continue' }) // Deny it will abort the script
49
53
  */
50
- static confirm(question: _prompts.PromptObject): Promise<true | undefined>;
54
+ static confirm(question: _prompts.PromptObject, options?: _prompts.Options): Promise<true | undefined>;
51
55
  /**
52
56
  * See `prompts` package documentation
53
57
  * @example
@@ -1,4 +1,3 @@
1
- import { default as chalk } from 'chalk';
2
1
  import { default as indent } from 'indent-string';
3
2
  import { default as _stripAnsi } from 'strip-ansi';
4
3
  export declare class OutputUtils {
@@ -13,17 +12,7 @@ export declare class OutputUtils {
13
12
  * const { $style } = OutputUtils
14
13
  * console.log($style.green('Green text!')) // => '[32mGreen text![0m'
15
14
  */
16
- static $style: chalk.Chalk & chalk.ChalkFunction & {
17
- supportsColor: chalk.ColorSupport | false;
18
- Level: chalk.Level;
19
- Color: ("black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "grey" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright") | ("bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "bgGray" | "bgGrey" | "bgBlackBright" | "bgRedBright" | "bgGreenBright" | "bgYellowBright" | "bgBlueBright" | "bgMagentaBright" | "bgCyanBright" | "bgWhiteBright");
20
- ForegroundColor: "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "grey" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright";
21
- BackgroundColor: "bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "bgGray" | "bgGrey" | "bgBlackBright" | "bgRedBright" | "bgGreenBright" | "bgYellowBright" | "bgBlueBright" | "bgMagentaBright" | "bgCyanBright" | "bgWhiteBright";
22
- Modifiers: "bold" | "hidden" | "reset" | "dim" | "italic" | "underline" | "inverse" | "strikethrough" | "visible";
23
- stderr: chalk.Chalk & {
24
- supportsColor: chalk.ColorSupport | false;
25
- };
26
- };
15
+ static $style: import('chalk').ChalkInstance;
27
16
  /**
28
17
  * Format a message for console output
29
18
  * @param msg - The message to format
package/dist/cli/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v2.0.0-beta.13
2
+ * juisy v2.0.0-beta.15
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -18,12 +18,12 @@ import indent from 'indent-string';
18
18
  import _stripAnsi from 'strip-ansi';
19
19
  import dotenv from '@dotenvx/dotenvx';
20
20
  import semver from 'semver';
21
- import { getPackageInfo } from 'juisy';
21
+ import fs$1 from 'node:fs';
22
+ import path from 'node:path';
22
23
  import kebabcase from 'lodash.kebabcase';
23
24
  import { ReadmeTemplater } from 'juisy/templater';
24
- import path from 'node:path';
25
+ import { getPackageInfo } from 'juisy';
25
26
  import { ESLint } from 'eslint';
26
- import fs$1 from 'node:fs';
27
27
  import yargsParser from 'yargs-parser';
28
28
 
29
29
  class Plugin {
@@ -530,33 +530,42 @@ class InterfaceUtils {
530
530
  /**
531
531
  * Get root directory path
532
532
  * @example
533
- * import { CLIUtils: { rootDir } } from '@hperchec/juisy'
533
+ * const { rootDir } = InterfaceUtils
534
534
  * console.log(rootDir) // => 'path/to/your/root/dir'
535
535
  */
536
536
  static rootDir = process.cwd();
537
- /**
538
- * @param {string} bin - Command
539
- * @param {string[]} args - Same as execa second arg
540
- * @param {object} [opts] - Options
541
- * @returns {Promise<object>} The `execa` Promise
542
- * @throws {RunError}
543
- * @description
544
- * Run command (child_process). See also `execa` package documentation
545
- * @example
546
- * const { run } = require('@hperchec/juisy').utils
547
- * await run('npm', [ 'run', 'test' ], { stdio: 'inherit' })
548
- */
549
- static run(bin, args, opts = {}) {
550
- return execa(bin, args, { stdio: "inherit", cwd: InterfaceUtils.rootDir, ...opts });
537
+ static run(bin, args, opts) {
538
+ let execaOptions = {
539
+ stdio: "inherit",
540
+ cwd: InterfaceUtils.rootDir
541
+ };
542
+ let callExeca = () => execa`${bin}`;
543
+ if (args) {
544
+ if (args instanceof Array) {
545
+ execaOptions = {
546
+ ...execaOptions,
547
+ ...opts || {}
548
+ };
549
+ callExeca = () => execa(bin, args, execaOptions);
550
+ } else if (typeof args === "object") {
551
+ execaOptions = {
552
+ ...execaOptions,
553
+ ...args
554
+ };
555
+ callExeca = () => execa(execaOptions)`${bin}`;
556
+ } else {
557
+ throw new Error("Second argument must be either an array of arguments or an object of options");
558
+ }
559
+ }
560
+ return callExeca();
551
561
  }
552
562
  /**
553
- * @alias utils.abort
554
563
  * @param {number} [code] - Code for process.exit() (default: 0)
555
564
  * @returns {void}
556
565
  * @description
557
566
  * Exit process
558
567
  * @example
559
- * const { abort } = require('@hperchec/juisy').utils
568
+ * const { abort } = InterfaceUtils
560
569
  * abort() // => exit process with code 0
561
570
  * abort(1) // => error code
562
571
  */
@@ -565,15 +574,15 @@ class InterfaceUtils {
565
574
  process.exit(code);
566
575
  }
567
576
  /**
568
- * @alias utils.confirm
569
- * @param {prompts.PromptObject} question - A prompt question object (see https://gitlab.com/hperchec/juisy/-/blob/main/documentation/utils.md#utilspromptsargs-object)
577
+ * @param question - A prompt question object
578
+ * @param options - A prompt options object
570
579
  * @returns {Promise<boolean>} - True if confirmed
571
580
  * @description
572
581
  * Demand confirmation with prompts native util. If not confirmed, it will automatically abort the script.
573
582
  * @example
574
583
  * confirm({ message: 'Confirm to continue' }) // Deny it will abort the script
575
584
  */
576
- static async confirm(question) {
585
+ static async confirm(question, options = {}) {
577
586
  if (!question) {
578
587
  question = {
579
588
  type: "confirm",
@@ -588,7 +597,7 @@ class InterfaceUtils {
588
597
  type: "confirm",
589
598
  name: "yes"
590
599
  }
591
- ]);
600
+ ], options);
592
601
  if (!yes) {
593
602
  InterfaceUtils.abort();
594
603
  } else {
@@ -619,78 +628,89 @@ const LoadEnvFile = new Plugin("built-in:load-env-file", {
619
628
  });
620
629
 
621
630
  const bumpVersion = new Command({
622
- command: "bump-version",
631
+ command: "bump-version [targetVersion]",
623
632
  describe: "Bump version in package.json file",
624
633
  meta: {
625
634
  private: true
626
635
  },
627
636
  builder: function(cli) {
637
+ cli.positional("targetVersion", {
638
+ describe: "The target version to set manually",
639
+ type: "string"
640
+ });
628
641
  cli.option("p", {
629
642
  alias: "preid",
630
643
  type: "string",
631
644
  describe: "Pre-release id",
632
645
  requiresArg: true
633
646
  });
647
+ cli.option("f", {
648
+ alias: "file",
649
+ type: "string",
650
+ describe: "Path to package.json file",
651
+ requiresArg: true
652
+ });
653
+ cli.option("indent", {
654
+ type: "number",
655
+ describe: "Number of indent spaces used by JSON.stringify. Default: 2",
656
+ default: 2,
657
+ requiresArg: true
658
+ });
634
659
  return cli;
635
660
  },
636
661
  async handler(argv) {
637
662
  const { $style, step, substep, error } = OutputUtils;
638
- const { run, prompts, abort } = InterfaceUtils;
639
- const packageJson = getPackageInfo();
640
- let targetVersion;
641
- const currentVersion = packageJson.version;
642
- packageJson.name;
643
- const preId = argv.preid || semver.prerelease(currentVersion) && semver.prerelease(currentVersion)[0];
644
- const inc = (i) => semver.inc(currentVersion, i, preId);
645
- const versionIncrements = [
646
- "patch",
647
- "minor",
648
- "major",
649
- ...preId ? ["prepatch", "preminor", "premajor", "prerelease"] : []
650
- ];
663
+ const { confirm, prompts, abort } = InterfaceUtils;
664
+ const packageJsonPath = argv.file ? path.isAbsolute(argv.file) ? argv.file : path.join(process.cwd(), argv.file) : path.resolve(process.cwd(), "package.json");
665
+ const pkg = JSON.parse(fs$1.readFileSync(packageJsonPath, "utf-8"));
666
+ let targetVersion = argv.targetVersion;
651
667
  step("Bump version");
652
- const { release } = await prompts([
653
- {
654
- type: "select",
655
- name: "release",
656
- message: "Release type:",
657
- choices: versionIncrements.map((i) => ({ title: `${i} (${inc(i)})`, value: inc(i) })).concat([{ title: "custom", value: "custom" }])
658
- }
659
- ]);
660
- if (release === "custom") {
661
- const { version: customVersion } = await prompts([
668
+ if (!targetVersion) {
669
+ const currentVersion = pkg.version;
670
+ pkg.name;
671
+ const preId = argv.preid || semver.prerelease(currentVersion) && semver.prerelease(currentVersion)[0];
672
+ const inc = (i) => semver.inc(currentVersion, i, preId);
673
+ const versionIncrements = [
674
+ "patch",
675
+ "minor",
676
+ "major",
677
+ ...preId ? ["prepatch", "preminor", "premajor", "prerelease"] : []
678
+ ];
679
+ const { release } = await prompts([
662
680
  {
663
- type: "text",
664
- name: "version",
665
- message: "New custom version:",
666
- initial: currentVersion,
667
- validate: (value) => Boolean(semver.valid(value))
681
+ type: "select",
682
+ name: "release",
683
+ message: "Release type:",
684
+ choices: versionIncrements.map((i) => ({ title: `${i} (${inc(i)})`, value: inc(i) })).concat([{ title: "custom", value: "custom" }])
668
685
  }
669
- ]);
670
- targetVersion = customVersion;
671
- } else {
672
- targetVersion = release;
673
- }
674
- const { yes } = await prompts([
675
- {
686
+ ], { onCancel: () => abort() });
687
+ if (release === "custom") {
688
+ const { version: customVersion } = await prompts([
689
+ {
690
+ type: "text",
691
+ name: "version",
692
+ message: "New custom version:",
693
+ initial: currentVersion,
694
+ validate: (value) => Boolean(semver.valid(value))
695
+ }
696
+ ], { onCancel: () => abort() });
697
+ targetVersion = customVersion;
698
+ } else {
699
+ targetVersion = release;
700
+ }
701
+ await confirm({
676
702
  type: "confirm",
677
703
  name: "yes",
678
704
  message: `Releasing v${targetVersion}. Confirm?`,
679
705
  initial: true
680
- }
681
- ]);
682
- if (!yes) {
683
- abort();
684
- return;
706
+ }, {
707
+ onCancel: () => abort()
708
+ });
685
709
  }
686
- this.log();
687
710
  let commandError = false;
688
711
  try {
689
- await run("npm", [
690
- "--no-git-tag-version",
691
- "version",
692
- targetVersion
693
- ], { stdio: "inherit" });
712
+ pkg.version = targetVersion;
713
+ fs$1.writeFileSync(packageJsonPath, JSON.stringify(pkg, null, argv.indent) + "\n");
694
714
  } catch (e) {
695
715
  commandError = e;
696
716
  }
@@ -699,7 +719,8 @@ const bumpVersion = new Command({
699
719
  error("An error has occured.", commandError);
700
720
  abort(1);
701
721
  } else {
702
- substep($style.green("✔ Version successfuly bumped"), { last: true });
722
+ substep($style.green("✔ Version successfuly bumped"));
723
+ substep($style.cyan("New version: " + targetVersion), { last: true });
703
724
  this.log();
704
725
  }
705
726
  }
@@ -1310,6 +1331,9 @@ const release = new Command({
1310
1331
  describe: 'Increment "major", "minor", "patch", or "pre*" version; or specify version',
1311
1332
  default: "patch",
1312
1333
  requiresArg: true
1334
+ }).option("preRelease", {
1335
+ type: "string",
1336
+ describe: "Same as release-it --preRelease option. See: https://github.com/release-it/release-it/blob/main/docs/pre-releases.md"
1313
1337
  }).option("ci", {
1314
1338
  type: "boolean",
1315
1339
  describe: "No prompts, no user interaction; activated automatically in CI environments"
@@ -1406,6 +1430,10 @@ const release = new Command({
1406
1430
  releaseItCmdArgs.push(argv.increment);
1407
1431
  }
1408
1432
  }
1433
+ if (argv.preRelease !== void 0) {
1434
+ releaseItCmdArgs.push("--preRelease");
1435
+ releaseItCmdArgs.push(argv.preRelease);
1436
+ }
1409
1437
  if (argv.ci) {
1410
1438
  releaseItCmdArgs.push("--ci");
1411
1439
  }
@@ -1,9 +1,9 @@
1
- import { default as ReleaseIt } from 'release-it';
1
+ import { Config as ReleaseItConfig } from 'release-it';
2
2
  declare module '../../types' {
3
3
  interface GlobalSettings {
4
4
  /**
5
5
  * Release configuration
6
6
  */
7
- release?: UserProvidedConfigSetting<ReleaseIt.Config>;
7
+ release?: UserProvidedConfigSetting<ReleaseItConfig>;
8
8
  }
9
9
  }
package/dist/eject.d.ts CHANGED
@@ -7,6 +7,7 @@ export type EjectOptions = {
7
7
  targetDir?: string;
8
8
  logLevel?: LogLevelDesc;
9
9
  ignoreFiles?: string[];
10
+ templateData?: Record<string, any> | ((identifier: string) => Record<string, any> | Promise<Record<string, any>>);
10
11
  processor?: (content: string, identifier: string) => string | Promise<string>;
11
12
  onError?: (identifier: string, fromPath: string, toPath: string, err: Error) => void | Promise<void>;
12
13
  onSuccess?: (identifier: string, fromPath: string, toPath: string) => void | Promise<void>;
@@ -17,6 +18,7 @@ export type EjectOptions = {
17
18
  * @param options - The options object
18
19
  * @param options.force - If true, the target files will be overwritten
19
20
  * @param options.targetDir - The target directory absolute path
21
+ * @param options.templateData - The template data object
20
22
  * @param options.processor - The template file content processor function.
21
23
  * Takes content as unique argument and must return string or a Promise that resolves a string
22
24
  * @param options.onError - The callback if an error occurs
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v2.0.0-beta.13
2
+ * juisy v2.0.0-beta.15
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -123,6 +123,7 @@ async function isFile(filePath) {
123
123
  async function ejectFile(from, to, identifier = null, options) {
124
124
  identifier = identifier || path.basename(from);
125
125
  const force = options?.force || false;
126
+ const templateData = options?.templateData;
126
127
  const processor = options?.processor || (async (str, _identifier) => str);
127
128
  const onError = options?.onError || (async (_identifier, fromPath, toPath, err) => {
128
129
  throw err;
@@ -134,7 +135,7 @@ async function ejectFile(from, to, identifier = null, options) {
134
135
  const write = await fs.exists(to) ? force : true;
135
136
  if (write) {
136
137
  const template = await fs.readFile(from, { encoding: "utf8" });
137
- const content = await templater.render(template);
138
+ const content = await templater.render(template, typeof templateData === "function" ? await templateData(identifier) : templateData);
138
139
  const processedContent = await processor(content, identifier);
139
140
  await fs.ensureFile(to);
140
141
  await fs.writeFile(to, processedContent);
@@ -160,6 +161,8 @@ async function eject(templateDir, identifier, options) {
160
161
  if (await isFile(fullPath)) {
161
162
  if (!ignoreFiles.includes(identifier)) {
162
163
  await ejectFile(fullPath, path.resolve(targetDir, identifier), identifier, {
164
+ force: options?.force,
165
+ templateData: options?.templateData,
163
166
  processor: options?.processor,
164
167
  onSuccess: options?.onSuccess,
165
168
  onError: options?.onError
@@ -171,6 +174,8 @@ async function eject(templateDir, identifier, options) {
171
174
  const fullTemplateFilePath = path.resolve(templateDir, fileRelativePath);
172
175
  if (!ignoreFiles.includes(fileRelativePath)) {
173
176
  await ejectFile(fullTemplateFilePath, path.resolve(targetDir, fileRelativePath), fileRelativePath, {
177
+ force: options?.force,
178
+ templateData: options?.templateData,
174
179
  processor: options?.processor,
175
180
  onSuccess: options?.onSuccess,
176
181
  onError: options?.onError
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v2.0.0-beta.13
2
+ * juisy v2.0.0-beta.15
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v2.0.0-beta.13
2
+ * juisy v2.0.0-beta.15
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * juisy v2.0.0-beta.13
2
+ * juisy v2.0.0-beta.15
3
3
  * Copyright © 2022-Present Hervé Perchec
4
4
  */
5
5
 
package/package.json CHANGED
@@ -1,204 +1,212 @@
1
- {
2
- "name": "juisy",
3
- "version": "2.0.0-beta.13",
4
- "description": "Make you JavaScript (and/or TypeScript) project juicy!",
5
- "type": "module",
6
- "files": [
7
- "bin",
8
- "dist"
9
- ],
10
- "engines": {
11
- "node": "^18.0.0 || ^20.0.0 || >=22.0.0"
12
- },
13
- "imports": {
14
- "#juisy": {
15
- "types": "./dist/index.d.ts",
16
- "import": "./dist/index.js"
17
- },
18
- "#juisy/cli": {
19
- "types": "./dist/cli/index.d.ts",
20
- "import": "./dist/cli/index.js"
21
- },
22
- "#juisy/templater": {
23
- "types": "./dist/templater/index.d.ts",
24
- "import": "./dist/templater/index.js"
25
- }
26
- },
27
- "exports": {
28
- ".": {
29
- "types": "./dist/index.d.ts",
30
- "import": "./dist/index.js"
31
- },
32
- "./cli": {
33
- "types": "./dist/cli/index.d.ts",
34
- "import": "./dist/cli/index.js"
35
- },
36
- "./templater": {
37
- "types": "./dist/templater/index.d.ts",
38
- "import": "./dist/templater/index.js"
39
- },
40
- "./vite-plugin-inject-css-variables": {
41
- "types": "./dist/vite/plugins/inject-css-variables/index.d.ts",
42
- "import": "./dist/vite/plugins/inject-css-variables/index.js"
43
- },
44
- "./vite-plugin-inject-project-globals": {
45
- "types": "./dist/vite/plugins/inject-project-globals/index.d.ts",
46
- "import": "./dist/vite/plugins/inject-project-globals/index.js"
47
- }
48
- },
49
- "publishConfig": {
50
- "access": "public"
51
- },
52
- "scripts": {
53
- "build": "vite build",
54
- "audit": "ncu && npm audit",
55
- "audit:fix": "ncu --interactive",
56
- "docs": "npm run docs:cli && npm run docs:api",
57
- "docs:api": "node ./bin/cli docs generate:api",
58
- "docs:cli": "npm run docs:cli:private && npm run docs:cli:public",
59
- "docs:cli:private": "node ./bin/cli docs generate:cli -c ./docs/cli/private/config.js",
60
- "docs:cli:public": "node ./bin/cli docs generate:cli -c ./docs/cli/public/config.js",
61
- "example:reset": "git checkout --no-overlay -- example && cd example && git clean -fdX",
62
- "example:test": "npm run example:reset && cd example && npm install -D juisy@file:../ && npx juisy squeeze && npm run docs:readme",
63
- "print:globals": "node --no-warnings ./bin/cli print:globals",
64
- "release": "release-it --no-increment",
65
- "test": "node ./bin/cli test",
66
- "test:dev": "npm test -- --watch",
67
- "test:ui": "npm test -- --ui"
68
- },
69
- "repository": {
70
- "type": "git",
71
- "url": "git+https://gitlab.com/hperchec/juisy.git"
72
- },
73
- "keywords": [
74
- "js",
75
- "build",
76
- "release",
77
- "changelog",
78
- "bin",
79
- "cmd",
80
- "easy"
81
- ],
82
- "author": {
83
- "name": "Hervé Perchec",
84
- "email": "contact@herve-perchec.com",
85
- "url": "https://gitlab.com/herveperchec"
86
- },
87
- "license": "GPL-3.0-only",
88
- "bugs": {
89
- "url": "https://gitlab.com/hperchec/juisy/issues"
90
- },
91
- "homepage": "https://hperchec.gitlab.io/juisy",
92
- "bin": {
93
- "juisy": "./bin/cli/index.js"
94
- },
95
- "peerDependencies": {
96
- "@commitlint/cli": "^19.6.1",
97
- "@commitlint/config-conventional": "^19.6.0",
98
- "@github/markdownlint-github": "^0.6.3",
99
- "@release-it/bumper": "6.0.1",
100
- "@release-it/conventional-changelog": "^9.0.4",
101
- "@stylistic/eslint-plugin": "^2",
102
- "@typescript-eslint/eslint-plugin": "^8",
103
- "chalk": "^4.1.2",
104
- "conventional-changelog-cli": "^5.0.0",
105
- "eslint": "^9",
106
- "lint-staged": "^14.0.1",
107
- "markdownlint-cli2": "^0.12.0",
108
- "markdownlint-cli2-formatter-pretty": "^0.0.7",
109
- "prompts": "^2.4.2",
110
- "release-it": "^17.11.0",
111
- "simple-git-hooks": "^2.9.0",
112
- "yargs": "^17.7.2"
113
- },
114
- "peerDependenciesMeta": {
115
- "@release-it/bumper": {
116
- "optional": true
117
- },
118
- "@release-it/conventional-changelog": {
119
- "optional": true
120
- }
121
- },
122
- "devDependencies": {
123
- "@babel/eslint-parser": "^7.25.9",
124
- "@conventional-changelog/git-client": "^1.0.1",
125
- "@rollup/plugin-typescript": "^12.1.2",
126
- "@stylistic/eslint-plugin": "^2.12.1",
127
- "@types/conventional-changelog": "^3.1.5",
128
- "@types/conventional-changelog-config-spec": "^2.1.5",
129
- "@types/ejs": "^3.1.5",
130
- "@types/fs-extra": "^11.0.4",
131
- "@types/lint-staged": "^13.3.0",
132
- "@types/lodash.get": "^4.4.9",
133
- "@types/lodash.kebabcase": "^4.1.9",
134
- "@types/lodash.merge": "^4.6.9",
135
- "@types/lodash.set": "^4.3.9",
136
- "@types/node": "^22.10.2",
137
- "@types/prompts": "^2.4.9",
138
- "@types/semver": "^7.5.8",
139
- "@types/yargs": "^17.0.33",
140
- "@types/yargs-parser": "^21.0.3",
141
- "@typescript-eslint/eslint-plugin": "^8.18.1",
142
- "@vitest/coverage-v8": "^2.1.8",
143
- "@vitest/ui": "^2.1.8",
144
- "cpy-cli": "^5.0.0",
145
- "eslint": "^9.17.0",
146
- "happy-dom": "^15.11.7",
147
- "json-schema-to-ts": "^3.1.1",
148
- "lint-staged": "^14.0.1",
149
- "npm-check-updates": "^17.1.12",
150
- "quicktype": "^23.0.170",
151
- "typedoc": "^0.28.1",
152
- "typedoc-plugin-frontmatter": "^1.3.0",
153
- "typedoc-plugin-markdown": "^4.5.2",
154
- "typedoc-vitepress-theme": "^1.1.2",
155
- "typescript": "^5.7.2",
156
- "vite": "^5.4.11",
157
- "vite-plugin-dts": "^4.3.0",
158
- "vite-plugin-generate-file": "^0.2.0",
159
- "vitest": "^2.1.8"
160
- },
161
- "dependencies": {
162
- "@commitlint/types": "^19.8.0",
163
- "@dotenvx/dotenvx": "^1.31.0",
164
- "ascii-tree": "^0.3.0",
165
- "chalk": "^4.1.2",
166
- "conventional-recommended-bump": "^10.0.0",
167
- "deepmerge": "^4.3.1",
168
- "ejs": "^3.1.10",
169
- "execa": "^8",
170
- "find-up": "^7.0.0",
171
- "fs-extra": "^11.2.0",
172
- "github-slugger": "^2.0.0",
173
- "glob": "^11.0.0",
174
- "handlebars": "^4.7.8",
175
- "import-single-ts": "^1.2.0",
176
- "indent-string": "^5.0.0",
177
- "json-2-csv": "^5.5.7",
178
- "jstoxml": "^5.0.2",
179
- "lodash.get": "^4.4.2",
180
- "lodash.kebabcase": "^4.1.1",
181
- "lodash.merge": "^4.6.2",
182
- "lodash.set": "^4.3.2",
183
- "loglevel": "^1.9.2",
184
- "markdown-table": "^3.0.4",
185
- "markdown-toc": "^1.2.0",
186
- "markdown-utils": "^1.0.0",
187
- "package-json-type": "^1.0.3",
188
- "pkg-dir": "^8.0.0",
189
- "prompts": "^2.4.2",
190
- "remark": "^15.0.1",
191
- "remark-frontmatter": "^5.0.0",
192
- "remark-toc": "^9.0.0",
193
- "semver": "^7.7.1",
194
- "simple-git-hooks": "^2.9.0",
195
- "strip-ansi": "^7.1.0",
196
- "ts-json-schema-generator": "^2.3.0",
197
- "yaml": "^2.6.1",
198
- "yargs": "^17.7.2",
199
- "yargs-parser": "^21.1.1"
200
- },
201
- "release-it": {
202
- "git": false
203
- }
204
- }
1
+ {
2
+ "name": "juisy",
3
+ "version": "2.0.0-beta.15",
4
+ "description": "Make you JavaScript (and/or TypeScript) project juicy!",
5
+ "type": "module",
6
+ "files": [
7
+ "bin",
8
+ "dist"
9
+ ],
10
+ "engines": {
11
+ "node": "^18.0.0 || ^20.0.0 || >=22.0.0"
12
+ },
13
+ "imports": {
14
+ "#juisy": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ },
18
+ "#juisy/cli": {
19
+ "types": "./dist/cli/index.d.ts",
20
+ "import": "./dist/cli/index.js"
21
+ },
22
+ "#juisy/templater": {
23
+ "types": "./dist/templater/index.d.ts",
24
+ "import": "./dist/templater/index.js"
25
+ }
26
+ },
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.js"
31
+ },
32
+ "./cli": {
33
+ "types": "./dist/cli/index.d.ts",
34
+ "import": "./dist/cli/index.js"
35
+ },
36
+ "./templater": {
37
+ "types": "./dist/templater/index.d.ts",
38
+ "import": "./dist/templater/index.js"
39
+ },
40
+ "./vite-plugin-inject-css-variables": {
41
+ "types": "./dist/vite/plugins/inject-css-variables/index.d.ts",
42
+ "import": "./dist/vite/plugins/inject-css-variables/index.js"
43
+ },
44
+ "./vite-plugin-inject-project-globals": {
45
+ "types": "./dist/vite/plugins/inject-project-globals/index.d.ts",
46
+ "import": "./dist/vite/plugins/inject-project-globals/index.js"
47
+ }
48
+ },
49
+ "publishConfig": {
50
+ "access": "public"
51
+ },
52
+ "scripts": {
53
+ "build": "vite build",
54
+ "audit": "ncu && npm audit",
55
+ "audit:fix": "ncu --interactive",
56
+ "docs": "npm run docs:cli && npm run docs:api",
57
+ "docs:api": "node ./bin/cli docs generate:api",
58
+ "docs:cli": "npm run docs:cli:private && npm run docs:cli:public",
59
+ "docs:cli:private": "node ./bin/cli docs generate:cli -c ./docs/cli/private/config.js",
60
+ "docs:cli:public": "node ./bin/cli docs generate:cli -c ./docs/cli/public/config.js",
61
+ "example:reset": "git checkout --no-overlay -- example && cd example && git clean -fdX",
62
+ "example:test": "npm run example:reset && cd example && npm install -D juisy@file:../ && npx juisy squeeze && npm run docs:readme",
63
+ "print:globals": "node --no-warnings ./bin/cli print:globals",
64
+ "release": "release-it --no-increment",
65
+ "test": "node ./bin/cli test",
66
+ "test:dev": "npm test -- --watch",
67
+ "test:ui": "npm test -- --ui"
68
+ },
69
+ "repository": {
70
+ "type": "git",
71
+ "url": "git+https://gitlab.com/hperchec/juisy.git"
72
+ },
73
+ "keywords": [
74
+ "js",
75
+ "build",
76
+ "release",
77
+ "changelog",
78
+ "bin",
79
+ "cmd",
80
+ "easy"
81
+ ],
82
+ "author": {
83
+ "name": "Hervé Perchec",
84
+ "email": "contact@herve-perchec.com",
85
+ "url": "https://gitlab.com/herveperchec"
86
+ },
87
+ "license": "GPL-3.0-only",
88
+ "bugs": {
89
+ "url": "https://gitlab.com/hperchec/juisy/issues"
90
+ },
91
+ "homepage": "https://hperchec.gitlab.io/juisy",
92
+ "bin": {
93
+ "juisy": "./bin/cli/index.js"
94
+ },
95
+ "peerDependencies": {
96
+ "@commitlint/cli": "^19.6.1",
97
+ "@commitlint/config-conventional": "^19.6.0",
98
+ "@github/markdownlint-github": "^0.6.3",
99
+ "@release-it/bumper": "6.0.1",
100
+ "@release-it/conventional-changelog": "^9.0.4",
101
+ "@stylistic/eslint-plugin": "^2",
102
+ "@typescript-eslint/eslint-plugin": "^8",
103
+ "chalk": "^5.4.1",
104
+ "conventional-changelog-cli": "^5.0.0",
105
+ "eslint": "^9",
106
+ "globals": "^15",
107
+ "lint-staged": "^14.0.1",
108
+ "markdownlint-cli2": "^0.12.0",
109
+ "markdownlint-cli2-formatter-pretty": "^0.0.7",
110
+ "prompts": "^2.4.2",
111
+ "release-it": "^17.11.0",
112
+ "simple-git-hooks": "^2.9.0",
113
+ "yargs": "^17.7.2"
114
+ },
115
+ "peerDependenciesMeta": {
116
+ "@release-it/bumper": {
117
+ "optional": true
118
+ },
119
+ "@release-it/conventional-changelog": {
120
+ "optional": true
121
+ }
122
+ },
123
+ "devDependencies": {
124
+ "@babel/eslint-parser": "^7.25.9",
125
+ "@conventional-changelog/git-client": "^1.0.1",
126
+ "@rollup/plugin-typescript": "^12.1.2",
127
+ "@stylistic/eslint-plugin": "^2.12.1",
128
+ "@types/conventional-changelog": "^3.1.5",
129
+ "@types/conventional-changelog-config-spec": "^2.1.5",
130
+ "@types/ejs": "^3.1.5",
131
+ "@types/fs-extra": "^11.0.4",
132
+ "@types/lint-staged": "^13.3.0",
133
+ "@types/lodash.get": "^4.4.9",
134
+ "@types/lodash.kebabcase": "^4.1.9",
135
+ "@types/lodash.merge": "^4.6.9",
136
+ "@types/lodash.set": "^4.3.9",
137
+ "@types/node": "^22.10.2",
138
+ "@types/prompts": "^2.4.9",
139
+ "@types/semver": "^7.5.8",
140
+ "@types/yargs": "^17.0.33",
141
+ "@types/yargs-parser": "^21.0.3",
142
+ "@typescript-eslint/eslint-plugin": "^8.18.1",
143
+ "@vitest/coverage-v8": "^2.1.8",
144
+ "@vitest/ui": "^2.1.8",
145
+ "cpy-cli": "^5.0.0",
146
+ "eslint": "^9.17.0",
147
+ "happy-dom": "^15.11.7",
148
+ "json-schema-to-ts": "^3.1.1",
149
+ "lint-staged": "^14.0.1",
150
+ "npm-check-updates": "^17.1.12",
151
+ "quicktype": "^23.0.170",
152
+ "typedoc": "^0.28.1",
153
+ "typedoc-plugin-frontmatter": "^1.3.0",
154
+ "typedoc-plugin-markdown": "^4.5.2",
155
+ "typedoc-vitepress-theme": "^1.1.2",
156
+ "typescript": "^5.7.2",
157
+ "vite": "^5.4.11",
158
+ "vite-plugin-dts": "^4.3.0",
159
+ "vite-plugin-generate-file": "^0.2.0",
160
+ "vitest": "^2.1.8"
161
+ },
162
+ "dependencies": {
163
+ "@commitlint/types": "^19.8.0",
164
+ "@dotenvx/dotenvx": "^1.31.0",
165
+ "ascii-tree": "^0.3.0",
166
+ "chalk": "^5.4.1",
167
+ "conventional-recommended-bump": "^10.0.0",
168
+ "deepmerge": "^4.3.1",
169
+ "ejs": "^3.1.10",
170
+ "execa": "^9.5.2",
171
+ "find-up": "^7.0.0",
172
+ "fs-extra": "^11.2.0",
173
+ "github-slugger": "^2.0.0",
174
+ "glob": "^11.0.0",
175
+ "handlebars": "^4.7.8",
176
+ "import-single-ts": "^1.2.0",
177
+ "indent-string": "^5.0.0",
178
+ "json-2-csv": "^5.5.7",
179
+ "jstoxml": "^5.0.2",
180
+ "lodash.get": "^4.4.2",
181
+ "lodash.kebabcase": "^4.1.1",
182
+ "lodash.merge": "^4.6.2",
183
+ "lodash.set": "^4.3.2",
184
+ "loglevel": "^1.9.2",
185
+ "markdown-table": "^3.0.4",
186
+ "markdown-toc": "^1.2.0",
187
+ "markdown-utils": "^1.0.0",
188
+ "package-json-type": "^1.0.3",
189
+ "pkg-dir": "^8.0.0",
190
+ "prompts": "^2.4.2",
191
+ "remark": "^15.0.1",
192
+ "remark-frontmatter": "^5.0.0",
193
+ "remark-toc": "^9.0.0",
194
+ "semver": "^7.7.1",
195
+ "simple-git-hooks": "^2.9.0",
196
+ "strip-ansi": "^7.1.0",
197
+ "ts-json-schema-generator": "^2.3.0",
198
+ "yaml": "^2.6.1",
199
+ "yargs": "^17.7.2",
200
+ "yargs-parser": "^21.1.1"
201
+ },
202
+ "release-it": {
203
+ "git": false
204
+ },
205
+ "overrides": {
206
+ "simple-git-hooks": {
207
+ "scripts": {
208
+ "postinstall": ""
209
+ }
210
+ }
211
+ }
212
+ }