juisy 2.3.0 β†’ 3.0.0-beta.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.
package/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # Juisy
2
+
3
+ ![presentation](resources/images/presentation-banner.jpg)
4
+
5
+ <!-- markdownlint-disable line-length -->
6
+
7
+ ![author](https://img.shields.io/static/v1?label=\&message=Author:\&color=black)
8
+ [![herve-perchec](http://herve-perchec.com/badge.svg)](http://herve-perchec.com/)
9
+
10
+ [![release](https://img.shields.io/gitlab/v/release/hperchec/juisy?include_prereleases\&logo=gitlab\&sort=semver)](https://gitlab.com/hperchec/juisy/-/releases)
11
+ [![pipeline-status](https://gitlab.com/hperchec/juisy/badges/v3.0.0-beta.1/pipeline.svg)](https://gitlab.com/hperchec/juisy/commits/v3.0.0-beta.1)
12
+ [![package](https://img.shields.io/npm/v/juisy?logo=npm)](https://www.npmjs.com/package/juisy)
13
+ [![downloads](https://img.shields.io/npm/dw/juisy?logo=npm)](https://www.npmjs.com/package/juisy)
14
+ [![issues](https://img.shields.io/gitlab/issues/open/hperchec/juisy?gitlab_url=https%3A%2F%2Fgitlab.com)](https://gitlab.com/hperchec/juisy/issues)
15
+ ![license](https://img.shields.io/gitlab/license/hperchec/juisy?gitlab_url=https%3A%2F%2Fgitlab.com)
16
+
17
+ <!-- markdownlint-enable line-length -->
18
+
19
+ ## Table of contents
20
+
21
+ * [What is juisy?](#what-is-juisy)
22
+ * [❗ Requirements](#-requirements)
23
+ * [πŸš€ Get started](#-get-started)
24
+ * [πŸ“™ Documentation](#-documentation)
25
+ * [🀝 Contribute](#-contribute)
26
+ * [✍ Author](#-author)
27
+ * [πŸ“„ License](#-license)
28
+ * [🧬 Changelog](#-changelog)
29
+
30
+ ## What is juisy?
31
+
32
+ **Juisy** (a play on words for "JS", "easy" and "juicy") is on top of your **JavaScript** (or **TypeScript**) project.
33
+
34
+ It runs on [NodeJS](https://nodejs.org/en) ([ESM](https://nodejs.org/api/esm.html) only) and comes with useful features listed below.
35
+
36
+ * 🧬 Project globals: share project variables to Node and/or runtime environment
37
+ * πŸ“• Generate your project documentation and README file with templaters
38
+ * πŸ•΅οΈβ€β™‚οΈ Lint your code with [ESLint](https://eslint.org/). Automatic linting with [lint-staged](https://www.npmjs.com/package/lint-staged) at pre-commit git hook
39
+ * 🦾 Respect [Conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) with [commitlint](https://commitlint.js.org/) at commit-msg git hook
40
+ * πŸ”§ Use your own **C**ommand **L**ine **I**nterface
41
+ * πŸ“¦ Combine with any of your favorite bundlers like [Vite](https://vite.dev/), [RollUp](https://rollupjs.org/), [ESBuild](https://esbuild.github.io/), [Webpack](https://webpack.js.org/)...
42
+ * and [much more](https://gitlab.com/hperchec/juisy#readme)...
43
+
44
+ ## ❗ Requirements
45
+
46
+ * Node `>=18.20.8`
47
+ * npm `>=10.8.2`
48
+
49
+ ## πŸš€ Get started
50
+
51
+ Create a new project with **Juisy**:
52
+
53
+ ```sh
54
+ npm create juisy
55
+ ```
56
+
57
+ ## πŸ“™ Documentation
58
+
59
+ See [online documentation](https://gitlab.com/hperchec/juisy#readme) to learn more!
60
+
61
+ ## 🀝 Contribute
62
+
63
+ See the [CONTRIBUTING.md](./CONTRIBUTING.md) file.
64
+
65
+ ## ✍ Author
66
+
67
+ [HervΓ© Perchec](https://gitlab.com/herveperchec)
68
+
69
+ ## πŸ“„ License
70
+
71
+ GPL-3.0-only
72
+
73
+ ## 🧬 Changelog
74
+
75
+ See all changes to this project in the [CHANGELOG.md](./CHANGELOG.md) file.
76
+
77
+ ***
78
+
79
+ Made with ❀ by [Hervé Perchec](https://gitlab.com/herveperchec)
80
+
81
+ ***
82
+
83
+ <!-- markdownlint-disable-next-line line-length -->
84
+
85
+ *README.md - this file was auto generated with [juisy](https://www.npmjs.com/package/juisy) README templater. Don't edit it.*
package/bin/cli/cli.js CHANGED
@@ -1,9 +1,10 @@
1
- import { DEFAULT_EXT_CACHE_PATH, loadExtensions } from './lib/index.js'
2
- import mri from 'mri'
3
1
  import { CLIFactory } from '#juisy/cli'
2
+ import bootstrap from '../../dist/bootstrap.js'
4
3
 
5
4
  import { commands } from './cmds/index.js'
6
5
 
6
+ await bootstrap()
7
+
7
8
  const { $style } = CLI.OutputUtils
8
9
 
9
10
  function getBanner () {
@@ -17,23 +18,11 @@ function getBanner () {
17
18
  return str
18
19
  }
19
20
 
20
- // Use `mri` library to parse --ext-cache option
21
- const extCacheOption = mri(CLI.helpers.hideBin(process.argv), {
22
- string: [ 'ext-cache' ]
23
- })['ext-cache']
24
-
25
- await loadExtensions(extCacheOption)
26
-
27
21
  export default await CLIFactory(cli => cli
28
22
  .scriptName('juisy')
29
23
  .usage(`${getBanner()}\nUsage: $0 <command> [<options>]`)
30
24
  .disableDefaultCommand('docs generate:api')
31
25
  .globalCommandVisitorOptions('private-command-visitor', { envKey: '__JUISY_CLI_ENV__' })
32
- .option('ext-cache', {
33
- type: 'string',
34
- describe: `Path to extensions cache file (default: "${DEFAULT_EXT_CACHE_PATH}")`,
35
- requiresArg: true
36
- })
37
26
  .command(commands)
38
27
  // .demandCommand(1, ('Command is missing. See help to learn more.').red)
39
28
  )
@@ -1,15 +1,11 @@
1
1
  // Private commands
2
2
  // ...
3
3
  // Public commands
4
- import AddExtCommand from './public/AddExt.js'
5
- import RemoveExtCommand from './public/RemoveExt.js'
6
4
  import printGlobals from './public/print-globals.js'
7
5
 
8
6
  export const commands = [
9
7
  // Private
10
8
  // ...
11
9
  // Public
12
- AddExtCommand,
13
- RemoveExtCommand,
14
10
  printGlobals
15
11
  ]
package/bin/cli/index.js CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  'use strict'
4
4
 
5
- import './init.js'
6
5
  import cli from './cli.js'
7
6
 
8
7
  const argv = CLI.helpers.hideBin(process.argv)
@@ -9,7 +9,7 @@ import run from 'execa'
9
9
  // Copy env file
10
10
  try {
11
11
  await run('npx', [ 'cpy', '.env.example', '.', '--rename', '.env', '--no-overwrite' ], { stdio: 'inherit' })
12
- } catch (e) {
12
+ } catch (e) { // eslint-disable-line no-unused-vars
13
13
  console.error('βœ– env file already exists. Ignoring step...')
14
14
  console.log() // blank line
15
15
  }
@@ -17,7 +17,8 @@ export type ExportOptions<F extends DataExporterFormat> = F extends 'json' ? Par
17
17
  * @returns The data as JSON string
18
18
  * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
19
19
  */
20
- declare const jsonExporter: (data: any, options?: {
20
+ declare const jsonExporter: (data: any, // eslint-disable-line @typescript-eslint/no-explicit-any
21
+ options?: {
21
22
  replacer?: Parameters<typeof JSON.stringify>[1];
22
23
  space?: Parameters<typeof JSON.stringify>[2];
23
24
  }) => string;
@@ -29,7 +30,8 @@ declare const jsonExporter: (data: any, options?: {
29
30
  * @see https://www.npmjs.com/package/yaml
30
31
  * @see https://eemeli.org/yaml/#yaml
31
32
  */
32
- declare const yamlExporter: (data: any, options?: {
33
+ declare const yamlExporter: (data: any, // eslint-disable-line @typescript-eslint/no-explicit-any
34
+ options?: {
33
35
  replacer?: Parameters<typeof yaml.stringify>[1];
34
36
  exporter?: Parameters<typeof yaml.stringify>[2];
35
37
  }) => string;
@@ -41,7 +43,8 @@ declare const yamlExporter: (data: any, options?: {
41
43
  * @see https://www.npmjs.com/package/json-2-csv
42
44
  * @see https://mrodrig.github.io/json-2-csv/
43
45
  */
44
- declare const csvExporter: (data: any, options: Json2CsvOptions) => string;
46
+ declare const csvExporter: (data: any, // eslint-disable-line @typescript-eslint/no-explicit-any
47
+ options: Json2CsvOptions) => string;
45
48
  /**
46
49
  * XML exporter
47
50
  * @param data - The data object
@@ -50,7 +53,8 @@ declare const csvExporter: (data: any, options: Json2CsvOptions) => string;
50
53
  * @see https://www.npmjs.com/package/jstoxml
51
54
  * @see https://github.com/davidcalhoun/jstoxml
52
55
  */
53
- declare const xmlExporter: (data: any, options: XMLoptions) => string;
56
+ declare const xmlExporter: (data: any, // eslint-disable-line @typescript-eslint/no-explicit-any
57
+ options: XMLoptions) => string;
54
58
  /**
55
59
  * Universal data exporter
56
60
  * @group None
@@ -1 +1,6 @@
1
- export default function bootstrap(importMeta: ImportMeta): Promise<void>;
1
+ /**
2
+ * @internal
3
+ * @privateRemarks
4
+ * Internal usage only
5
+ */
6
+ export default function bootstrap(importMeta?: ImportMeta): Promise<void>;
@@ -0,0 +1,21 @@
1
+ /*!
2
+ * juisy v3.0.0-beta.1
3
+ * Copyright Β© 2022-Present HervΓ© Perchec
4
+ */
5
+
6
+ import { loadExtensions } from './extensions.js';
7
+
8
+ let isAlreadyBootstrapped = false;
9
+ async function bootstrap(importMeta = import.meta) {
10
+ if (!isAlreadyBootstrapped) {
11
+ if (process.env.JUISY_ENABLE_EXTENSIONS === void 0) {
12
+ process.env.JUISY_ENABLE_EXTENSIONS = "true";
13
+ }
14
+ if (process.env.JUISY_ENABLE_EXTENSIONS === "true") {
15
+ await loadExtensions();
16
+ }
17
+ isAlreadyBootstrapped = true;
18
+ }
19
+ }
20
+
21
+ export { bootstrap as default };
@@ -1 +1 @@
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
+ {"$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":{"anyOf":[{"type":"string"},{"type":"boolean","const":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":{"anyOf":[{"type":"object","properties":{"publish":{"type":"boolean","default":true},"publishPath":{"type":"string","default":"."},"publishArgs":{"type":"array","items":{}},"publishPackageManager":{"type":"string","enum":["npm","pnpm","bun"],"default":"npm"},"tag":{"default":null},"stage":{"type":"boolean","default":false},"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}}},{"type":"boolean","const":false}]},"github":{"type":"object","properties":{"release":{"type":"boolean","default":false},"releaseName":{"type":"string","default":"Release ${version}"},"releaseNotes":{"anyOf":[{"type":"string"},{"type":"null"},{"$comment":"() => string | Promise<string>"},{"type":"object","properties":{"commit":{"type":"string"},"excludeMatches":{"type":"array","items":{"type":"string"}}}}],"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":false},"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}}},"quiet":{"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"}}]}}}}}
@@ -15,7 +15,7 @@ export declare class InterfaceUtils {
15
15
  * Get root directory path
16
16
  * @example
17
17
  * const { rootDir } = InterfaceUtils
18
- * console.log(rootDir) // => 'path/to/your/root/dir'
18
+ * console.log(rootDir) // 'path/to/your/root/dir'
19
19
  */
20
20
  static rootDir: string;
21
21
  /**
@@ -38,11 +38,11 @@ export declare class InterfaceUtils {
38
38
  static run(bin: string, args: string[], opts?: ExecaOptions): ExecaResultPromise;
39
39
  /**
40
40
  * Exit process
41
- * @param [code] - Code for process.exit() (default: 0)
41
+ * @param code - Code for process.exit() (default: 0)
42
42
  * @example
43
43
  * const { abort } = InterfaceUtils
44
- * abort() // => exit process with code 0
45
- * abort(1) // => error code
44
+ * abort() // exit process with code 0
45
+ * abort(1) // error code
46
46
  */
47
47
  static abort(code?: number): void;
48
48
  /**
package/dist/cli/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  /*!
2
- * juisy v2.3.0
2
+ * juisy v3.0.0-beta.1
3
3
  * Copyright Β© 2022-Present HervΓ© Perchec
4
4
  */
5
5
 
6
6
  import { hideBin } from 'yargs/helpers';
7
- import deepmerge from 'deepmerge';
8
7
  import { pathToFileURL } from 'node:url';
9
8
  import fs from 'fs-extra';
10
9
  import Yargs from 'yargs/yargs';
11
10
  import { findUpSync } from 'find-up';
12
11
  import { importSingleTs } from 'import-single-ts';
13
- import lodashGet from 'lodash.get';
12
+ import deepMerge from '@juisy/utils/object/deep-merge';
13
+ import get from '@juisy/utils/object/get';
14
14
  import chalk from 'chalk';
15
15
  import indent from 'indent-string';
16
16
  import _stripAnsi from 'strip-ansi';
@@ -20,7 +20,7 @@ import dotenv from '@dotenvx/dotenvx';
20
20
  import semver from 'semver';
21
21
  import fs$1 from 'node:fs';
22
22
  import path from 'node:path';
23
- import kebabcase from 'lodash.kebabcase';
23
+ import kebabcase from '@juisy/utils/string/kebabcase';
24
24
  import { ReadmeTemplater } from 'juisy/templater';
25
25
  import { getPackageInfo } from 'juisy';
26
26
  import { ESLint } from 'eslint';
@@ -55,10 +55,12 @@ class Plugin {
55
55
  * The beforeCreate hook (can be async)
56
56
  */
57
57
  beforeCreate;
58
+ // eslint-disable-line @typescript-eslint/no-explicit-any
58
59
  /**
59
60
  * The created hook (must be sync)
60
61
  */
61
62
  created;
63
+ // eslint-disable-line @typescript-eslint/no-explicit-any
62
64
  }
63
65
 
64
66
  const loading = {
@@ -492,7 +494,7 @@ function isPrivate() {
492
494
  return this._isPrivate;
493
495
  }
494
496
  function getSettings(path) {
495
- return path ? lodashGet(this._settings, path) : this._settings;
497
+ return path ? get(this._settings, path) : this._settings;
496
498
  }
497
499
 
498
500
  const proxify = (target) => {
@@ -540,6 +542,7 @@ const getDefaultCommand = (fullSignature) => {
540
542
  return findCommandIn(fullSignature, defaultCommands);
541
543
  };
542
544
  const resolveSettingsCallbacks = {
545
+ // eslint-disable-line @typescript-eslint/no-unsafe-function-type
543
546
  // ...
544
547
  };
545
548
  function defineSettings(target, settings, options) {
@@ -579,11 +582,11 @@ async function CLIFactory(builder, options) {
579
582
  throw new Error("Unable to find file: " + settingsPath);
580
583
  } else if (configPath) {
581
584
  if (configPath.endsWith(".ts")) {
582
- globalSettings = deepmerge(defaultGlobalSettings, await importSingleTs(configPath).then((mod) => mod.default || mod));
585
+ globalSettings = deepMerge(defaultGlobalSettings, await importSingleTs(configPath).then((mod) => mod.default || mod));
583
586
  } else if (configPath.endsWith(".json")) {
584
- globalSettings = deepmerge(defaultGlobalSettings, JSON.parse(fs.readFileSync(configPath).toString()));
587
+ globalSettings = deepMerge(defaultGlobalSettings, JSON.parse(fs.readFileSync(configPath).toString()));
585
588
  } else {
586
- globalSettings = deepmerge(defaultGlobalSettings, await import(pathToFileURL(configPath).toString()).then((mod) => mod.default || mod));
589
+ globalSettings = deepMerge(defaultGlobalSettings, await import(pathToFileURL(configPath).toString()).then((mod) => mod.default || mod));
587
590
  }
588
591
  } else {
589
592
  globalSettings = defaultGlobalSettings;
@@ -644,7 +647,7 @@ class InterfaceUtils {
644
647
  * Get root directory path
645
648
  * @example
646
649
  * const { rootDir } = InterfaceUtils
647
- * console.log(rootDir) // => 'path/to/your/root/dir'
650
+ * console.log(rootDir) // 'path/to/your/root/dir'
648
651
  */
649
652
  static rootDir = process.cwd();
650
653
  static run(bin, args, opts) {
@@ -674,11 +677,11 @@ class InterfaceUtils {
674
677
  }
675
678
  /**
676
679
  * Exit process
677
- * @param [code] - Code for process.exit() (default: 0)
680
+ * @param code - Code for process.exit() (default: 0)
678
681
  * @example
679
682
  * const { abort } = InterfaceUtils
680
- * abort() // => exit process with code 0
681
- * abort(1) // => error code
683
+ * abort() // exit process with code 0
684
+ * abort(1) // error code
682
685
  */
683
686
  static abort(code = 0) {
684
687
  log($style.yellow("Aborted..."));
@@ -779,7 +782,6 @@ class BumpVersionCommand extends Command {
779
782
  step("Bump version");
780
783
  if (!targetVersion) {
781
784
  const currentVersion = pkg.version;
782
- pkg.name;
783
785
  const preId = argv.preid || semver.prerelease(currentVersion) && semver.prerelease(currentVersion)[0];
784
786
  const inc = (i) => semver.inc(currentVersion, i, preId);
785
787
  const versionIncrements = [
@@ -864,7 +866,7 @@ const changelog = new Command({
864
866
  const { $style, step, substep, error, wait } = OutputUtils;
865
867
  const { run } = InterfaceUtils;
866
868
  step("Generating changelog");
867
- const { onReleaseConfig, ...commandOptions } = this.engine.getSettings("changelog");
869
+ const { ...commandOptions } = this.engine.getSettings("changelog");
868
870
  const flattenOptions = (options) => {
869
871
  const _array = [];
870
872
  for (const key in options) {
@@ -1114,7 +1116,7 @@ function resolveCommitlintSettings(settings = {}) {
1114
1116
  return settings;
1115
1117
  }
1116
1118
  function resolveMarkdownlintSettings(settings = []) {
1117
- let resolved = [];
1119
+ const resolved = [];
1118
1120
  for (const item of settings) {
1119
1121
  if (item.globs && (!(item.globs instanceof Array) || !item.globs.length)) {
1120
1122
  throw new Error('lint.markdown configuration: if provided, "globs" property must be a non-empty array');
@@ -1154,6 +1156,10 @@ const lint = new Command({
1154
1156
  describe: "Provide configuration file path",
1155
1157
  type: "string",
1156
1158
  requiresArg: true
1159
+ }).option("stats", {
1160
+ describe: "Display stats",
1161
+ type: "boolean",
1162
+ default: false
1157
1163
  });
1158
1164
  const lintSettings = cli.getSettings("lint.default");
1159
1165
  if (lintSettings?.config) {
@@ -1166,7 +1172,8 @@ const lint = new Command({
1166
1172
  step("Configuring linter");
1167
1173
  const lintSettings = this.engine.getSettings("lint.default") || {};
1168
1174
  const eslintOptions = {
1169
- fix: !!argv.fix
1175
+ fix: !!argv.fix,
1176
+ stats: !!argv.stats
1170
1177
  };
1171
1178
  if (argv.config) {
1172
1179
  eslintOptions.overrideConfigFile = argv.config;
@@ -1207,7 +1214,7 @@ const lintCommit = new Command({
1207
1214
  return cli;
1208
1215
  },
1209
1216
  async handler(argv) {
1210
- const { abort, run } = InterfaceUtils;
1217
+ const { run } = InterfaceUtils;
1211
1218
  const { $style, step, substep, error } = OutputUtils;
1212
1219
  step("Configuring commitlint");
1213
1220
  const lintSettings = this.engine.getSettings("lint.commit");
@@ -1268,7 +1275,7 @@ const lintMarkdown = new Command({
1268
1275
  return cli;
1269
1276
  },
1270
1277
  async handler(argv) {
1271
- const { abort, run } = InterfaceUtils;
1278
+ const { run } = InterfaceUtils;
1272
1279
  const { $style, step, substep, error } = OutputUtils;
1273
1280
  step("Configuring markdownlint");
1274
1281
  const configs = this.engine.getSettings("lint.markdown") || [];
@@ -1671,7 +1678,7 @@ const visitor$1 = function(commandObject, cli) {
1671
1678
  if (commandObject.meta) {
1672
1679
  const commandMeta = commandObject.meta;
1673
1680
  commandObject.builder = wrapCommandBuilder(commandObject.builder, function(_cli) {
1674
- _cli._meta = deepmerge(_cli._meta, commandMeta);
1681
+ _cli._meta = deepMerge(_cli._meta, commandMeta);
1675
1682
  return _cli;
1676
1683
  });
1677
1684
  }
@@ -1777,6 +1784,7 @@ async function extractUsage(factory, recursive = false, args = [""], locale = "e
1777
1784
  if (recursive) {
1778
1785
  for (const childCommand in doclet.extractedUsage.commands) {
1779
1786
  doclet.children[childCommand] = await extractUsage(
1787
+ // eslint-disable-line @typescript-eslint/no-explicit-any
1780
1788
  factory,
1781
1789
  true,
1782
1790
  [...args.filter((a) => a !== ""), childCommand],
@@ -1,3 +1,4 @@
1
+ export {};
1
2
  declare module '../../types' {
2
3
  /**
3
4
  * @group Types
@@ -17,4 +18,3 @@ declare module '../../types' {
17
18
  meta?: Partial<CommandMeta>;
18
19
  }
19
20
  }
20
- export {};
@@ -1,3 +1,3 @@
1
+ export {};
1
2
  declare module '../../types' {
2
3
  }
3
- export {};
@@ -1,3 +1,4 @@
1
+ export {};
1
2
  declare module '../../types' {
2
3
  interface CLIFactoryOptions {
3
4
  /**
@@ -6,4 +7,3 @@ declare module '../../types' {
6
7
  loadEnv?: boolean;
7
8
  }
8
9
  }
9
- export {};
@@ -90,7 +90,8 @@ export interface CLIEngine extends Argv {
90
90
  getValidationInstance(): any;
91
91
  hasParseCallback(): any;
92
92
  isGlobalContext(): any;
93
- postProcess(argv: any | Promise<any>, populateDoubleDash: boolean, calledFromCommand: boolean, runGlobalMiddleware: boolean): any;
93
+ postProcess(argv: any | Promise<any>, // eslint-disable-line @typescript-eslint/no-explicit-any
94
+ populateDoubleDash: boolean, calledFromCommand: boolean, runGlobalMiddleware: boolean): any;
94
95
  reset(aliases?: any): any;
95
96
  runValidation(aliases: Dictionary<string[]>, positionalMap: Dictionary<string[]>, parseErrors: Error | null, isDefaultCommand?: boolean): (argv: any) => void;
96
97
  runYargsParserAndExecuteCommands(args: string | string[] | null, shortCircuit?: boolean | null, calledFromCommand?: boolean, commandIndex?: number, helpOnly?: boolean): any | Promise<any>;
@@ -0,0 +1,26 @@
1
+ import { CLIFactory as _CLIFactory } from './cli/index.ts';
2
+ /**
3
+ * Juisy extension object
4
+ */
5
+ export interface Extension {
6
+ /**
7
+ * Extends feature of the main juisy bin
8
+ * @param CLIFactory - {@link _CLIFactory CLIFactory}
9
+ */
10
+ juisyBin?: (CLIFactory: typeof _CLIFactory) => void;
11
+ }
12
+ /**
13
+ * Get the extensions locally added to juisy
14
+ * @param pkgJsonPath - The path to package.json file
15
+ * @returns The extension names
16
+ */
17
+ export declare function getExtensions(pkgJsonPath?: string): string[];
18
+ /**
19
+ * Get the loaded extensions
20
+ */
21
+ export declare function getLoadedExtensions(): Record<string, Extension>;
22
+ /**
23
+ * Load the extensions
24
+ * @param pkgJsonPath - The path to extensions cache file
25
+ */
26
+ export declare function loadExtensions(pkgJsonPath?: string): Promise<Record<string, Extension>>;
@@ -0,0 +1,44 @@
1
+ /*!
2
+ * juisy v3.0.0-beta.1
3
+ * Copyright Β© 2022-Present HervΓ© Perchec
4
+ */
5
+
6
+ import path from 'node:path';
7
+ import { pathToFileURL } from 'node:url';
8
+ import fs from 'fs-extra';
9
+ import { CLIFactory } from 'juisy/cli';
10
+
11
+ const loadedExtensions = /* @__PURE__ */ new Map();
12
+ function getExtensions(pkgJsonPath = "./package.json") {
13
+ const absolutePath = path.isAbsolute(pkgJsonPath) ? pkgJsonPath : path.resolve(pkgJsonPath);
14
+ const content = fs.readFileSync(absolutePath, "utf-8");
15
+ const extensionIds = JSON.parse(content).juisy?.extensions || [];
16
+ return extensionIds;
17
+ }
18
+ function getLoadedExtensions() {
19
+ const extensions = {};
20
+ for (const id of loadedExtensions.keys()) {
21
+ extensions[id] = loadedExtensions.get(id);
22
+ }
23
+ return extensions;
24
+ }
25
+ async function loadExtension(id) {
26
+ const modPath = id.startsWith(".") ? path.resolve(id) : id;
27
+ const mod = await (path.isAbsolute(modPath) ? import(pathToFileURL(modPath).toString()) : import(id));
28
+ return mod.extension || mod.default;
29
+ }
30
+ async function loadExtensions(pkgJsonPath = "./package.json") {
31
+ const extensionIds = getExtensions(pkgJsonPath);
32
+ for (const id of extensionIds) {
33
+ if (!loadedExtensions.has(id)) {
34
+ const extension = await loadExtension(id);
35
+ loadedExtensions.set(id, extension);
36
+ if (extension.juisyBin) {
37
+ extension.juisyBin(CLIFactory);
38
+ }
39
+ }
40
+ }
41
+ return getLoadedExtensions();
42
+ }
43
+
44
+ export { getExtensions, getLoadedExtensions, loadExtensions };
package/dist/index.d.ts CHANGED
@@ -4,17 +4,13 @@
4
4
  * @importTarget .
5
5
  * @author HervΓ© Perchec
6
6
  */
7
- import * as utils from './utils/misc';
8
7
  export { DataExporter } from './DataExporter';
9
8
  export { default as eject } from './eject';
10
9
  export { default as getPackageInfo } from './get-package-info';
11
10
  export { defineGlobals, getProjectGlobals } from './project-globals';
12
- /**
13
- * @ignore
14
- */
15
- export { utils };
16
11
  export type * from './DataExporter';
17
12
  export type * from './eject';
13
+ export type * from './extensions';
18
14
  export type * from './project-globals';
19
15
  export type * from './shims/shims';
20
16
  declare const _default: {};