juisy 2.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 +211 -0
- package/bin/cli/cli.js +23 -0
- package/bin/cli/cmds/changelog.js +41 -0
- package/bin/cli/cmds/docs/generate-api.js +22 -0
- package/bin/cli/cmds/docs/generate-cli.js +11 -0
- package/bin/cli/cmds/docs/generate-readme.js +11 -0
- package/bin/cli/cmds/docs/index.js +22 -0
- package/bin/cli/cmds/docs/lint.js +42 -0
- package/bin/cli/cmds/eject.js +28 -0
- package/bin/cli/cmds/git-hooks/index.js +20 -0
- package/bin/cli/cmds/git-hooks/reset.js +48 -0
- package/bin/cli/cmds/git-hooks/sync.js +19 -0
- package/bin/cli/cmds/index.js +15 -0
- package/bin/cli/cmds/print-globals.js +28 -0
- package/bin/cli/cmds/release.js +231 -0
- package/bin/cli/cmds/squeeze.js +269 -0
- package/bin/cli/cmds/test.js +33 -0
- package/bin/cli/index.js +9 -0
- package/bin/cli/lib/docs/generate-api-doc.js +78 -0
- package/bin/cli/lib/version/update-version.js +52 -0
- package/bin/scripts/commit-msg.js +32 -0
- package/bin/scripts/pre-commit.js +24 -0
- package/dist/DataExporter.d.ts +67 -0
- package/dist/cli/CLIFactory.d.ts +19 -0
- package/dist/cli/Command.d.ts +44 -0
- package/dist/cli/InterfaceUtils.d.ts +53 -0
- package/dist/cli/OutputUtils.d.ts +123 -0
- package/dist/cli/command-visitors/command-handler-injections.d.ts +10 -0
- package/dist/cli/command-visitors/get-command-meta.d.ts +10 -0
- package/dist/cli/command-visitors/index.d.ts +9 -0
- package/dist/cli/command-visitors/private-command.d.ts +16 -0
- package/dist/cli/create-engine.d.ts +7 -0
- package/dist/cli/extract-usage.d.ts +72 -0
- package/dist/cli/index.d.ts +20 -0
- package/dist/cli/index.js +559 -0
- package/dist/cli/types.d.ts +112 -0
- package/dist/cli/utils.d.ts +19 -0
- package/dist/eject.d.ts +22 -0
- package/dist/get-package-info.d.ts +6 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +244 -0
- package/dist/project-globals.d.ts +63 -0
- package/dist/templater/Templater.d.ts +23 -0
- package/dist/templater/index.d.ts +6 -0
- package/dist/templater/index.js +330 -0
- package/dist/templater/markdown-templater/ReadmeTemplater.d.ts +154 -0
- package/dist/templater/markdown-templater/index.d.ts +25 -0
- package/dist/templater/types.d.ts +10 -0
- package/dist/utils/misc.d.ts +21 -0
- package/package.json +179 -0
- package/src/index.js +507 -0
- package/template/CHANGELOG.md +0 -0
- package/template/bin/cli/cli.js +27 -0
- package/template/bin/cli/cmds/changelog.js +71 -0
- package/template/bin/cli/cmds/docs.js +30 -0
- package/template/bin/cli/cmds/docs_cmds/generate-api.js +75 -0
- package/template/bin/cli/cmds/docs_cmds/generate-readme.js +51 -0
- package/template/bin/cli/cmds/git-hooks.js +30 -0
- package/template/bin/cli/cmds/git_hooks_cmds/reset.js +76 -0
- package/template/bin/cli/cmds/git_hooks_cmds/sync.js +44 -0
- package/template/bin/cli/cmds/release.js +219 -0
- package/template/bin/cli/index.js +7 -0
- package/template/bin/cli/lib/docs/generate-api-doc.js +33 -0
- package/template/bin/cli/lib/release/generate-release-note.js +3 -0
- package/template/bin/cli/lib/version/update-version.js +51 -0
- package/template/bin/scripts/commit-msg.js +42 -0
- package/template/bin/scripts/pre-commit.js +32 -0
- package/template/docs/api/docs.config.js +10 -0
- package/template/docs/readme/config.js +22 -0
- package/template/docs/readme/readme.js +70 -0
- package/template/docs/readme/template.md +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
⚠ IMPORTANT
|
|
3
|
+
This file is generated with **@hperchec/readme-generator**. Don't edit it.
|
|
4
|
+
-->
|
|
5
|
+
|
|
6
|
+
# 🍊 juisy
|
|
7
|
+
|
|
8
|
+
<!-- markdownlint-disable line-length -->
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
[](http://herve-perchec.com/)
|
|
12
|
+
|
|
13
|
+
[](https://gitlab.com/hperchec/juisy/-/releases)
|
|
14
|
+
[](https://gitlab.com/hperchec/juisy/commits/main)
|
|
15
|
+
[](https://www.npmjs.com/package/juisy)
|
|
16
|
+
[](https://www.npmjs.com/package/juisy)
|
|
17
|
+
[](https://gitlab.com/hperchec/juisy/issues)
|
|
18
|
+

|
|
19
|
+
|
|
20
|
+
<!-- markdownlint-enable line-length -->
|
|
21
|
+
|
|
22
|
+
## Table of contents
|
|
23
|
+
|
|
24
|
+
* [What is juisy?](#what-is-juisy)
|
|
25
|
+
* [🚀 Get started](#-get-started)
|
|
26
|
+
* [Features](#features)
|
|
27
|
+
* [Embedded CLI](#embedded-cli)
|
|
28
|
+
* [Project-level global variables](#project-level-global-variables)
|
|
29
|
+
* [🧱 Dependencies](#-dependencies)
|
|
30
|
+
* [📙 Documentation](#-documentation)
|
|
31
|
+
* [API](#api)
|
|
32
|
+
* [Utils](#utils)
|
|
33
|
+
* [✍ Author](#-author)
|
|
34
|
+
* [📄 License](#-license)
|
|
35
|
+
|
|
36
|
+
## What is juisy?
|
|
37
|
+
|
|
38
|
+
* 🔧 [Embedded CLI tool](https://gitlab.com/hperchec/juisy/-/blob/main/documentation/api.md#juisycli--yargs) that uses yargs under the ground
|
|
39
|
+
* 📕 Generate your project documentation and README file with [@hperchec/readme-generator](https://www.npmjs.com/package/@hperchec/readme-generator)
|
|
40
|
+
* 🕵️♂️ Automatic linting with [lint-staged](https://www.npmjs.com/package/lint-staged) at pre-commit git hook
|
|
41
|
+
* 🦾 Respect [Conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) with [commitlint](https://commitlint.js.org/) at commit-msg git hook
|
|
42
|
+
|
|
43
|
+
## 🚀 Get started
|
|
44
|
+
|
|
45
|
+
Install package:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
npm install juisy
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Squeeze!
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
npx juisy squeeze
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
You will get:
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
./
|
|
61
|
+
├─ bin/ # contains CLI
|
|
62
|
+
│ └─ cli/
|
|
63
|
+
│ ├─ cmds/ # commands dir
|
|
64
|
+
│ ├─ lib/ # libraries used by commands
|
|
65
|
+
│ └─ index.js # CLI entry file
|
|
66
|
+
├─ docs/
|
|
67
|
+
│ └─ readme # contains configuration for @hperchec/readme-generator
|
|
68
|
+
└─ ...
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
...and some new scripts in your `package.json` file:
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
"docs", // generate documentation
|
|
75
|
+
"docs:api", // only api
|
|
76
|
+
"docs:readme", // only README file
|
|
77
|
+
"release", // make a release
|
|
78
|
+
"changelog" // generate CHANGELOG file
|
|
79
|
+
"postinstall" // for git hook
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Just use `--help` option to show help:
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
node ./bin/cli --help
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Features
|
|
89
|
+
|
|
90
|
+
### Embedded CLI
|
|
91
|
+
|
|
92
|
+
PRIVATE AND PUBLIC COMMANDS
|
|
93
|
+
Work in progress...
|
|
94
|
+
|
|
95
|
+
### Project-level global variables
|
|
96
|
+
|
|
97
|
+
> > > INSERT MERMAID CHART for file level
|
|
98
|
+
> > > LEVEL 0 : package.json / env ==== hard coded
|
|
99
|
+
> > > LEVEL 1 : globals.config.js
|
|
100
|
+
> > > LEVEL 2 : builder / cli
|
|
101
|
+
> > > LEVEL 4 : Web app ...
|
|
102
|
+
|
|
103
|
+
Assuming you have a `.env` file in the root of your project:
|
|
104
|
+
|
|
105
|
+
```sh
|
|
106
|
+
# .env
|
|
107
|
+
MY_ENV_VAR=foo
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
And the following content in your `globals.config.js` file:
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
// globals.config.js
|
|
114
|
+
import { defineGlobals } from '@hperchec/juisy'
|
|
115
|
+
|
|
116
|
+
export default defineGlobals(
|
|
117
|
+
{
|
|
118
|
+
// The environment variables to auto includes in "ENV" property
|
|
119
|
+
env: { map: [ 'MY_ENV_VAR' ] }
|
|
120
|
+
},
|
|
121
|
+
// Access to all environment variables and package.json info
|
|
122
|
+
({ env, pkg }) => {
|
|
123
|
+
return {
|
|
124
|
+
// Set any variable you want to use globally
|
|
125
|
+
MY_GLOBAL_VARIABLE: 'bar'
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Will result to:
|
|
132
|
+
|
|
133
|
+
```js
|
|
134
|
+
{
|
|
135
|
+
ENV: {
|
|
136
|
+
MY_ENV_VAR: 'foo'
|
|
137
|
+
},
|
|
138
|
+
PACKAGE: {
|
|
139
|
+
NAME: '@hperchec/juisy',
|
|
140
|
+
URL: 'https://www.npmjs.com/package/@hperchec/juisy'
|
|
141
|
+
},
|
|
142
|
+
VERSION: '2.0.0',
|
|
143
|
+
AUTHOR: {
|
|
144
|
+
EMAIL: 'contact@herve-perchec.com',
|
|
145
|
+
NAME: 'Hervé Perchec',
|
|
146
|
+
URL: 'https://gitlab.com/herveperchec'
|
|
147
|
+
},
|
|
148
|
+
REPOSITORY: {
|
|
149
|
+
TYPE: 'git',
|
|
150
|
+
URL: 'git+https://gitlab.com/hperchec/juisy.git'
|
|
151
|
+
},
|
|
152
|
+
ISSUES_URL: 'https://gitlab.com/hperchec/juisy/issues',
|
|
153
|
+
HOMEPAGE: 'https://gitlab.com/hperchec/juisy#readme',
|
|
154
|
+
MY_GLOBAL_VARIABLE: 'bar'
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
You can also print the globals object by running the following command:
|
|
159
|
+
|
|
160
|
+
```sh
|
|
161
|
+
npx juisy print:globals
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## 🧱 Dependencies
|
|
165
|
+
|
|
166
|
+
It will install the following packages as peer dependencies:
|
|
167
|
+
|
|
168
|
+
| name | version |
|
|
169
|
+
| ---------------------------------- | ------- |
|
|
170
|
+
| @commitlint/cli | ^17.7.2 |
|
|
171
|
+
| @commitlint/config-conventional | ^17.7.0 |
|
|
172
|
+
| @github/markdownlint-github | ^0.6.0 |
|
|
173
|
+
| @hperchec/readme-generator | ^3.0.0 |
|
|
174
|
+
| @stylistic/eslint-plugin | ^2 |
|
|
175
|
+
| @typescript-eslint/eslint-plugin | ^8 |
|
|
176
|
+
| chalk | ^4.1.2 |
|
|
177
|
+
| conventional-changelog-cli | ^4.1.0 |
|
|
178
|
+
| eslint | ^9 |
|
|
179
|
+
| execa | ^5.1.1 |
|
|
180
|
+
| lint-staged | ^14.0.1 |
|
|
181
|
+
| markdownlint-cli2 | ^0.12.1 |
|
|
182
|
+
| markdownlint-cli2-formatter-pretty | ^0.0.6 |
|
|
183
|
+
| prompts | ^2.4.2 |
|
|
184
|
+
| simple-git-hooks | ^2.9.0 |
|
|
185
|
+
| yargs | ^17.7.2 |
|
|
186
|
+
|
|
187
|
+
## 📙 Documentation
|
|
188
|
+
|
|
189
|
+
### API
|
|
190
|
+
|
|
191
|
+
> See \[API] documentation]\(https://gitlab.com/hperchec/juisy/-/blob/main/documentation/api.md)
|
|
192
|
+
|
|
193
|
+
### Utils
|
|
194
|
+
|
|
195
|
+
> See [utils documentation](https://gitlab.com/hperchec/juisy/-/blob/main/documentation/utils.md)
|
|
196
|
+
|
|
197
|
+
## ✍ Author
|
|
198
|
+
|
|
199
|
+
[Hervé Perchec](https://gitlab.com/herveperchec)
|
|
200
|
+
|
|
201
|
+
## 📄 License
|
|
202
|
+
|
|
203
|
+
ISC
|
|
204
|
+
|
|
205
|
+
***
|
|
206
|
+
|
|
207
|
+
Made with ❤ by [Hervé Perchec](https://gitlab.com/herveperchec)
|
|
208
|
+
|
|
209
|
+
***
|
|
210
|
+
|
|
211
|
+
*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
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CLIFactory } from '#juisy/cli'
|
|
2
|
+
|
|
3
|
+
import { commands } from './cmds/index.js'
|
|
4
|
+
|
|
5
|
+
const { $style } = CLI.OutputUtils
|
|
6
|
+
|
|
7
|
+
function getBanner () {
|
|
8
|
+
let str = ''
|
|
9
|
+
const title = '@hperchec/juisy'
|
|
10
|
+
const length = title.length - 9 // removes characters generated by $style.bold from length
|
|
11
|
+
str += $style.cyan('-'.repeat(length) + '\n')
|
|
12
|
+
str += $style.cyan(title + '\n')
|
|
13
|
+
str += $style.cyan('-'.repeat(length) + '\n')
|
|
14
|
+
str += $style.italic('Made with') + ' ' + $style.red('❤') + ' ' + $style.italic('by ') + $style.bold('Hervé Perchec <contact@herve-perchec.com>') + '\n'
|
|
15
|
+
return str
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default CLIFactory(cli => cli
|
|
19
|
+
.scriptName('juisy')
|
|
20
|
+
.usage(`${getBanner()}\nUsage: $0 <command> [<options>]`)
|
|
21
|
+
.command(commands)
|
|
22
|
+
.demandCommand(1, ('Command is missing. See help to learn more.').red)
|
|
23
|
+
)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** @type {import('#juisy/cli').Command} */
|
|
2
|
+
export default new CLI.Command({
|
|
3
|
+
command: 'changelog',
|
|
4
|
+
describe: 'Generate CHANGELOG file',
|
|
5
|
+
builder: function (cli) {
|
|
6
|
+
return cli.option('i', {
|
|
7
|
+
alias: 'infile',
|
|
8
|
+
type: 'string',
|
|
9
|
+
describe: 'Same as conventional-changelog option',
|
|
10
|
+
default: 'CHANGELOG.md',
|
|
11
|
+
requiresArg: true
|
|
12
|
+
})
|
|
13
|
+
},
|
|
14
|
+
async handler (argv) {
|
|
15
|
+
// Utils
|
|
16
|
+
const { $style, step, substep, error } = CLI.OutputUtils
|
|
17
|
+
const { run, wait } = CLI.InterfaceUtils
|
|
18
|
+
/**
|
|
19
|
+
* Generate changelog file
|
|
20
|
+
*/
|
|
21
|
+
step('Generating changelog')
|
|
22
|
+
await wait('Generating', async () => {
|
|
23
|
+
try {
|
|
24
|
+
await run(
|
|
25
|
+
'npx',
|
|
26
|
+
[
|
|
27
|
+
'conventional-changelog',
|
|
28
|
+
'-p', 'angular',
|
|
29
|
+
'-i', argv.infile,
|
|
30
|
+
'-s' // same file to output
|
|
31
|
+
],
|
|
32
|
+
{ stdio: 'pipe' }
|
|
33
|
+
)
|
|
34
|
+
} catch (e) {
|
|
35
|
+
error('Unable to generate changelog', e)
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
substep($style.green('✔ Success'), { last: true })
|
|
39
|
+
this.log() // Blank line
|
|
40
|
+
}
|
|
41
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
import generateApiDoc from '../../lib/docs/generate-api-doc.js'
|
|
3
|
+
|
|
4
|
+
/** @type {import('#juisy/cli').Command} */
|
|
5
|
+
export default new CLI.Command({
|
|
6
|
+
command: 'generate:api',
|
|
7
|
+
describe: 'Generate API docs from source code',
|
|
8
|
+
builder (cli) {
|
|
9
|
+
cli
|
|
10
|
+
},
|
|
11
|
+
async handler (argv) {
|
|
12
|
+
let options = {}
|
|
13
|
+
const configPath = path.resolve('./docs/api/docs.config.js')
|
|
14
|
+
|
|
15
|
+
options = require(configPath)
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* If everything is okay generate doc
|
|
19
|
+
*/
|
|
20
|
+
await generateApiDoc(options)
|
|
21
|
+
}
|
|
22
|
+
})
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReadmeTemplater } from '#juisy/templater'
|
|
2
|
+
|
|
3
|
+
/** @type {import('#juisy/cli').Command} */
|
|
4
|
+
export default new CLI.Command({
|
|
5
|
+
command: 'generate:cli',
|
|
6
|
+
describe: 'Generate CLI docs',
|
|
7
|
+
async handler (argv) {
|
|
8
|
+
const templater = new ReadmeTemplater('./docs/cli/config.js')
|
|
9
|
+
await templater.generate()
|
|
10
|
+
}
|
|
11
|
+
})
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReadmeTemplater } from '#juisy/templater'
|
|
2
|
+
|
|
3
|
+
/** @type {import('#juisy/cli').Command} */
|
|
4
|
+
export default new CLI.Command({
|
|
5
|
+
command: 'generate:readme',
|
|
6
|
+
describe: 'Generate README.md',
|
|
7
|
+
async handler (argv) {
|
|
8
|
+
const templater = new ReadmeTemplater('./docs/readme/config.js')
|
|
9
|
+
await templater.generate()
|
|
10
|
+
}
|
|
11
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import generateAPI from './generate-api.js'
|
|
2
|
+
import generateCLI from './generate-cli.js'
|
|
3
|
+
import generateReadme from './generate-readme.js'
|
|
4
|
+
|
|
5
|
+
/** @type {import('#juisy/cli').Command} */
|
|
6
|
+
export default new CLI.Command({
|
|
7
|
+
command: 'docs <command>',
|
|
8
|
+
describe: 'Manage project documentation',
|
|
9
|
+
meta: {
|
|
10
|
+
private: true
|
|
11
|
+
},
|
|
12
|
+
builder (cli) {
|
|
13
|
+
return cli
|
|
14
|
+
.command([
|
|
15
|
+
generateAPI,
|
|
16
|
+
generateCLI,
|
|
17
|
+
generateReadme
|
|
18
|
+
])
|
|
19
|
+
.demandCommand(1, 'Command is missing. See help to learn more.')
|
|
20
|
+
},
|
|
21
|
+
handler (argv) {}
|
|
22
|
+
})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** @type {import('#juisy/cli').Command} */
|
|
2
|
+
export default new CLI.Command({
|
|
3
|
+
command: 'lint',
|
|
4
|
+
describe: 'Lint markdown with markdownlint',
|
|
5
|
+
builder: function (cli) {
|
|
6
|
+
cli.option('c', {
|
|
7
|
+
alias: 'config',
|
|
8
|
+
type: 'string',
|
|
9
|
+
describe: 'Path to custom markdownlint config file (relative to root folder)',
|
|
10
|
+
requiresArg: true
|
|
11
|
+
})
|
|
12
|
+
cli.option('f', {
|
|
13
|
+
alias: 'fix',
|
|
14
|
+
type: 'boolean',
|
|
15
|
+
describe: 'Auto fix by passing --fix option to markdownlint-cli2',
|
|
16
|
+
default: false
|
|
17
|
+
})
|
|
18
|
+
return cli
|
|
19
|
+
},
|
|
20
|
+
async handler (argv) {
|
|
21
|
+
const { abort, run } = CLI.InterfaceUtils
|
|
22
|
+
const configPath = argv.config || './docs/.markdownlint-cli2.cjs' // default relative to root folder
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Call markdownlint command
|
|
26
|
+
*/
|
|
27
|
+
try {
|
|
28
|
+
await run(
|
|
29
|
+
'npx',
|
|
30
|
+
[
|
|
31
|
+
'markdownlint-cli2',
|
|
32
|
+
'--config',
|
|
33
|
+
configPath,
|
|
34
|
+
...(argv.fix ? [ '--fix' ] : [])
|
|
35
|
+
],
|
|
36
|
+
{ stdio: 'inherit' }
|
|
37
|
+
)
|
|
38
|
+
} catch (error) {
|
|
39
|
+
abort(error.exitCode)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { eject } from '#juisy'
|
|
2
|
+
|
|
3
|
+
/** @type {import('#juisy/cli').Command} */
|
|
4
|
+
export default new CLI.Command({
|
|
5
|
+
command: 'eject <identifier>',
|
|
6
|
+
describe: 'Eject file from juisy template to project directory',
|
|
7
|
+
builder (cli) {
|
|
8
|
+
cli.option('f', {
|
|
9
|
+
alias: 'force',
|
|
10
|
+
type: 'boolean',
|
|
11
|
+
default: false,
|
|
12
|
+
describe: 'Overwrites existing files'
|
|
13
|
+
})
|
|
14
|
+
cli.option('l', {
|
|
15
|
+
alias: 'log-level',
|
|
16
|
+
type: 'string',
|
|
17
|
+
default: 'trace',
|
|
18
|
+
describe: 'Can be one of: trace, debug, info, warn, error, silent'
|
|
19
|
+
})
|
|
20
|
+
return cli
|
|
21
|
+
},
|
|
22
|
+
async handler (argv) {
|
|
23
|
+
await eject(argv.identifier, {
|
|
24
|
+
force: argv.force,
|
|
25
|
+
logLevel: argv['log-level']
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import reset from './reset.js'
|
|
2
|
+
import sync from './sync.js'
|
|
3
|
+
|
|
4
|
+
/** @type {import('#juisy/cli').Command} */
|
|
5
|
+
export default new CLI.Command({
|
|
6
|
+
command: 'git-hooks <command>',
|
|
7
|
+
describe: 'Git relative commands',
|
|
8
|
+
meta: {
|
|
9
|
+
private: true
|
|
10
|
+
},
|
|
11
|
+
builder: function (cli) {
|
|
12
|
+
return cli
|
|
13
|
+
.command([
|
|
14
|
+
reset,
|
|
15
|
+
sync
|
|
16
|
+
])
|
|
17
|
+
.demandCommand(1, 'Command is missing. See help to learn more.')
|
|
18
|
+
},
|
|
19
|
+
handler: async function (argv) {}
|
|
20
|
+
})
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import fs from 'fs-extra'
|
|
3
|
+
|
|
4
|
+
/** @type {import('#juisy/cli').Command} */
|
|
5
|
+
export default new CLI.Command({
|
|
6
|
+
command: 'reset',
|
|
7
|
+
describe: 'Reset git hooks',
|
|
8
|
+
builder (cli) {
|
|
9
|
+
return cli
|
|
10
|
+
},
|
|
11
|
+
async handler (argv) {
|
|
12
|
+
// Utils
|
|
13
|
+
const { $style, step, substep } = CLI.OutputUtils
|
|
14
|
+
const { rootDir, run, abort } = CLI.InterfaceUtils
|
|
15
|
+
/**
|
|
16
|
+
* Reset git hooks
|
|
17
|
+
*/
|
|
18
|
+
step('Reset git hooks')
|
|
19
|
+
|
|
20
|
+
// Create temporary empty configuration file
|
|
21
|
+
const tempConfigFilePath = './__TEMP_SIMPLE_GIT_HOOKS_CONFIG__.json' // relative to project root folder
|
|
22
|
+
fs.writeFileSync(path.resolve(rootDir, tempConfigFilePath), '{}')
|
|
23
|
+
|
|
24
|
+
// Run command with empty configuration
|
|
25
|
+
let commandError = false
|
|
26
|
+
try {
|
|
27
|
+
await run('npx', [
|
|
28
|
+
'simple-git-hooks',
|
|
29
|
+
tempConfigFilePath
|
|
30
|
+
], { stdio: 'pipe', cwd: rootDir })
|
|
31
|
+
} catch (e) {
|
|
32
|
+
commandError = e
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Don't forget to always remove temporary file
|
|
36
|
+
fs.unlinkSync(path.resolve(rootDir, tempConfigFilePath))
|
|
37
|
+
|
|
38
|
+
// If error
|
|
39
|
+
if (commandError) {
|
|
40
|
+
substep($style.red('❌ Unable to reset git hooks.'), { last: true })
|
|
41
|
+
abort(1) // Abort with error
|
|
42
|
+
} else {
|
|
43
|
+
// Everything is okay
|
|
44
|
+
substep($style.green('✔ Git hooks successfuly reset'), { last: true })
|
|
45
|
+
this.log() // blank line
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** @type {import('#juisy/cli').Command} */
|
|
2
|
+
export default new CLI.Command({
|
|
3
|
+
command: 'sync',
|
|
4
|
+
describe: 'Sync git hooks',
|
|
5
|
+
builder (cli) {
|
|
6
|
+
return cli
|
|
7
|
+
},
|
|
8
|
+
async handler (argv) {
|
|
9
|
+
// Utils
|
|
10
|
+
const { step} = CLI.OutputUtils
|
|
11
|
+
const { run } = CLI.InterfaceUtils
|
|
12
|
+
/**
|
|
13
|
+
* Sync git hooks
|
|
14
|
+
*/
|
|
15
|
+
step('Sync git hooks')
|
|
16
|
+
|
|
17
|
+
await run('npx', [ 'simple-git-hooks' ])
|
|
18
|
+
}
|
|
19
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import docs from './docs/index.js'
|
|
2
|
+
import eject from './eject.js'
|
|
3
|
+
import gitHooks from './git-hooks/index.js'
|
|
4
|
+
import printGlobals from './print-globals.js'
|
|
5
|
+
import squeeze from './squeeze.js'
|
|
6
|
+
import test from './test.js'
|
|
7
|
+
|
|
8
|
+
export const commands = [
|
|
9
|
+
docs,
|
|
10
|
+
eject,
|
|
11
|
+
gitHooks,
|
|
12
|
+
printGlobals,
|
|
13
|
+
squeeze,
|
|
14
|
+
test
|
|
15
|
+
]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getProjectGlobals, DataExporter } from '#juisy'
|
|
2
|
+
|
|
3
|
+
/** @type {import('#juisy/cli').Command} */
|
|
4
|
+
export default new CLI.Command({
|
|
5
|
+
command: 'print:globals',
|
|
6
|
+
describe: 'Print the computed project globals as JSON',
|
|
7
|
+
meta: {},
|
|
8
|
+
builder (cli) {
|
|
9
|
+
cli.option('f', {
|
|
10
|
+
alias: 'format',
|
|
11
|
+
describe: 'The export format',
|
|
12
|
+
default: 'json',
|
|
13
|
+
choices: [ 'json', 'yaml' ]
|
|
14
|
+
})
|
|
15
|
+
cli.option('t', {
|
|
16
|
+
alias: 'target',
|
|
17
|
+
type: 'string',
|
|
18
|
+
describe: 'The target file exporting project globals (fallback to ./globals.config.js)'
|
|
19
|
+
})
|
|
20
|
+
return cli
|
|
21
|
+
},
|
|
22
|
+
async handler (args) {
|
|
23
|
+
// Use getProjectGlobals API
|
|
24
|
+
const projectGlobals = await getProjectGlobals(args.target)
|
|
25
|
+
// Just console.log the globals as JSON
|
|
26
|
+
this.log(new DataExporter(args.format).exportSync(projectGlobals, { space: 2 }))
|
|
27
|
+
}
|
|
28
|
+
})
|