juisy 2.3.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.
- package/README.md +85 -0
- package/bin/cli/cli.js +3 -14
- package/bin/cli/cmds/index.js +0 -4
- package/bin/cli/index.js +0 -1
- package/bin/scripts/prepare.js +22 -22
- package/dist/DataExporter.d.ts +8 -4
- package/dist/bootstrap.d.ts +6 -1
- package/dist/bootstrap.js +21 -0
- package/dist/cli/GlobalSettings.schema.json +1 -1
- package/dist/cli/InterfaceUtils.d.ts +4 -4
- package/dist/cli/index.js +19 -11
- package/dist/cli/plugins/command-meta/augment.d.ts +1 -1
- package/dist/cli/plugins/default-command-fallbacks/augment.d.ts +1 -1
- package/dist/cli/plugins/load-env-file/augment.d.ts +1 -1
- package/dist/cli/types.d.ts +2 -1
- package/dist/extensions.d.ts +26 -0
- package/dist/extensions.js +44 -0
- package/dist/index.d.ts +1 -5
- package/dist/index.js +18 -279
- package/dist/project-globals.d.ts +4 -2
- package/dist/templater/index.js +2 -2
- package/dist/templater/markdown-templater/ReadmeTemplater.d.ts +4 -2
- package/package.json +17 -17
- package/bin/cli/cmds/public/AddExt.js +0 -49
- package/bin/cli/cmds/public/RemoveExt.js +0 -49
- package/bin/cli/init.js +0 -1
- package/bin/cli/lib/index.js +0 -71
- package/dist/utils/misc.d.ts +0 -145
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Juisy
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
<!-- markdownlint-disable line-length -->
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
[](http://herve-perchec.com/)
|
|
9
|
+
|
|
10
|
+
[](https://gitlab.com/hperchec/juisy/-/releases)
|
|
11
|
+
[](https://gitlab.com/hperchec/juisy/commits/v3.0.0-beta.0)
|
|
12
|
+
[](https://www.npmjs.com/package/juisy)
|
|
13
|
+
[](https://www.npmjs.com/package/juisy)
|
|
14
|
+
[](https://gitlab.com/hperchec/juisy/issues)
|
|
15
|
+

|
|
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
|
)
|
package/bin/cli/cmds/index.js
CHANGED
|
@@ -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
package/bin/scripts/prepare.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import run from 'execa'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Prepare script
|
|
5
|
-
*/
|
|
6
|
-
;(async function () {
|
|
7
|
-
console.log('Prepare packages/juisy')
|
|
8
|
-
|
|
9
|
-
// Copy env file
|
|
10
|
-
try {
|
|
11
|
-
await run('npx', [ 'cpy', '.env.example', '.', '--rename', '.env', '--no-overwrite' ], { stdio: 'inherit' })
|
|
12
|
-
} catch (e) {
|
|
13
|
-
console.error('β env file already exists. Ignoring step...')
|
|
14
|
-
console.log() // blank line
|
|
15
|
-
}
|
|
16
|
-
// Build juisy because we depend on CLI tools
|
|
17
|
-
await run('pnpm', [ 'build' ], { stdio: 'inherit' })
|
|
18
|
-
|
|
19
|
-
// Everything is okay
|
|
20
|
-
console.log('β Prepare script passed')
|
|
21
|
-
console.log() // blank line
|
|
22
|
-
})()
|
|
1
|
+
import run from 'execa'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Prepare script
|
|
5
|
+
*/
|
|
6
|
+
;(async function () {
|
|
7
|
+
console.log('Prepare packages/juisy')
|
|
8
|
+
|
|
9
|
+
// Copy env file
|
|
10
|
+
try {
|
|
11
|
+
await run('npx', [ 'cpy', '.env.example', '.', '--rename', '.env', '--no-overwrite' ], { stdio: 'inherit' })
|
|
12
|
+
} catch (e) { // eslint-disable-line no-unused-vars
|
|
13
|
+
console.error('β env file already exists. Ignoring step...')
|
|
14
|
+
console.log() // blank line
|
|
15
|
+
}
|
|
16
|
+
// Build juisy because we depend on CLI tools
|
|
17
|
+
await run('pnpm', [ 'build' ], { stdio: 'inherit' })
|
|
18
|
+
|
|
19
|
+
// Everything is okay
|
|
20
|
+
console.log('β Prepare script passed')
|
|
21
|
+
console.log() // blank line
|
|
22
|
+
})()
|
package/dist/DataExporter.d.ts
CHANGED
|
@@ -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,
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
package/dist/bootstrap.d.ts
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* juisy v3.0.0-beta.0
|
|
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","
|
|
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":{"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"}}]}}}}}
|
|
@@ -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) //
|
|
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
|
|
41
|
+
* @param code - Code for process.exit() (default: 0)
|
|
42
42
|
* @example
|
|
43
43
|
* const { abort } = InterfaceUtils
|
|
44
|
-
* abort() //
|
|
45
|
-
* abort(1) //
|
|
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,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* juisy
|
|
2
|
+
* juisy v3.0.0-beta.0
|
|
3
3
|
* Copyright Β© 2022-Present HervΓ© Perchec
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -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 = {
|
|
@@ -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) {
|
|
@@ -644,7 +647,7 @@ class InterfaceUtils {
|
|
|
644
647
|
* Get root directory path
|
|
645
648
|
* @example
|
|
646
649
|
* const { rootDir } = InterfaceUtils
|
|
647
|
-
* console.log(rootDir) //
|
|
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
|
|
680
|
+
* @param code - Code for process.exit() (default: 0)
|
|
678
681
|
* @example
|
|
679
682
|
* const { abort } = InterfaceUtils
|
|
680
|
-
* abort() //
|
|
681
|
-
* abort(1) //
|
|
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 {
|
|
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
|
-
|
|
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 {
|
|
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 {
|
|
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") || [];
|
|
@@ -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],
|
package/dist/cli/types.d.ts
CHANGED
|
@@ -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>,
|
|
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.0
|
|
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: {};
|