juisy 2.0.0-beta.0 → 2.0.0-beta.8
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/bin/cli/cli.js +6 -4
- package/bin/cli/cmds/index.js +10 -10
- package/bin/cli/cmds/private/docs/generate-api.js +31 -0
- package/bin/cli/cmds/{docs → private/docs}/index.js +4 -6
- package/bin/cli/cmds/{print-globals.js → public/print-globals.js} +0 -1
- package/bin/cli/index.js +1 -1
- package/bin/scripts/prepare.js +22 -0
- package/dist/DataExporter.d.ts +6 -0
- package/dist/cli/CLIFactory.d.ts +48 -11
- package/dist/cli/Command.d.ts +23 -13
- package/dist/cli/GlobalSettings.schema.json +1 -0
- package/dist/cli/InterfaceUtils.d.ts +8 -2
- package/dist/cli/OutputUtils.d.ts +3 -3
- package/dist/cli/Plugin.d.ts +21 -0
- package/dist/cli/extract-usage.d.ts +7 -1
- package/dist/cli/index.d.ts +18 -6
- package/dist/cli/index.js +1261 -138
- package/dist/cli/plugins/command-handler-injections/augment.d.ts +29 -0
- package/dist/cli/{command-visitors → plugins/command-handler-injections/command-visitors}/command-handler-injections.d.ts +1 -1
- package/dist/cli/plugins/command-handler-injections/index.d.ts +3 -0
- package/dist/cli/plugins/command-meta/augment.d.ts +23 -0
- package/dist/cli/{command-visitors/get-command-meta.d.ts → plugins/command-meta/command-visitors/command-meta.d.ts} +1 -1
- package/dist/cli/plugins/command-meta/index.d.ts +3 -0
- package/dist/cli/plugins/default-command-fallbacks/augment.d.ts +3 -0
- package/dist/cli/plugins/default-command-fallbacks/command-visitors/default-command-fallbacks.d.ts +10 -0
- package/dist/cli/plugins/default-command-fallbacks/index.d.ts +3 -0
- package/dist/cli/plugins/load-env-file/augment.d.ts +9 -0
- package/dist/cli/plugins/load-env-file/index.d.ts +3 -0
- package/dist/cli/plugins/private-commands/augment.d.ts +6 -0
- package/dist/cli/{command-visitors → plugins/private-commands/command-visitors}/private-command.d.ts +1 -1
- package/dist/cli/plugins/private-commands/index.d.ts +3 -0
- package/dist/cli/plugins/register-bump-version-command/cmds/index.d.ts +3 -0
- package/dist/cli/plugins/register-bump-version-command/index.d.ts +3 -0
- package/dist/cli/plugins/register-changelog-command/augment.d.ts +110 -0
- package/dist/cli/plugins/register-changelog-command/cmds/index.d.ts +3 -0
- package/dist/cli/plugins/register-changelog-command/index.d.ts +3 -0
- package/dist/cli/plugins/register-docs-commands/augment.d.ts +18 -0
- package/dist/cli/plugins/register-docs-commands/cmds/generate-api.d.ts +3 -0
- package/dist/cli/plugins/register-docs-commands/cmds/generate-cli.d.ts +3 -0
- package/dist/cli/plugins/register-docs-commands/cmds/generate-readme.d.ts +3 -0
- package/dist/cli/plugins/register-docs-commands/cmds/index.d.ts +3 -0
- package/dist/cli/plugins/register-docs-commands/index.d.ts +3 -0
- package/dist/cli/plugins/register-git-hooks-commands/augment.d.ts +40 -0
- package/dist/cli/plugins/register-git-hooks-commands/cmds/index.d.ts +3 -0
- package/dist/cli/plugins/register-git-hooks-commands/cmds/reset.d.ts +3 -0
- package/dist/cli/plugins/register-git-hooks-commands/cmds/sync.d.ts +3 -0
- package/dist/cli/plugins/register-git-hooks-commands/index.d.ts +3 -0
- package/dist/cli/plugins/register-lint-commands/augment.d.ts +39 -0
- package/dist/cli/plugins/register-lint-commands/cmds/commit.d.ts +3 -0
- package/dist/cli/plugins/register-lint-commands/cmds/default.d.ts +3 -0
- package/dist/cli/plugins/register-lint-commands/cmds/markdown.d.ts +3 -0
- package/dist/cli/plugins/register-lint-commands/cmds/staged.d.ts +3 -0
- package/dist/cli/plugins/register-lint-commands/index.d.ts +3 -0
- package/dist/cli/plugins/register-lint-commands/settings.d.ts +11 -0
- package/dist/cli/plugins/register-lint-commands/types.d.ts +26 -0
- package/dist/cli/plugins/register-release-command/augment.d.ts +9 -0
- package/dist/cli/plugins/register-release-command/cmds/index.d.ts +3 -0
- package/dist/cli/plugins/register-release-command/index.d.ts +3 -0
- package/dist/cli/plugins/register-test-command/cmds/index.d.ts +3 -0
- package/dist/cli/plugins/register-test-command/index.d.ts +3 -0
- package/dist/cli/types.d.ts +73 -44
- package/dist/cli/utils.d.ts +3 -3
- package/dist/eject.d.ts +11 -4
- package/dist/index.d.ts +8 -2
- package/dist/index.js +80 -76
- package/dist/project-globals.d.ts +9 -0
- package/dist/templater/index.d.ts +6 -1
- package/dist/templater/index.js +27 -40
- package/dist/templater/markdown-templater/ReadmeTemplater.d.ts +28 -28
- package/dist/templater/markdown-templater/index.d.ts +3 -0
- package/dist/templater/types.d.ts +6 -0
- package/dist/utils/misc.d.ts +1 -1
- package/package.json +194 -179
- package/README.md +0 -211
- package/bin/cli/cmds/changelog.js +0 -41
- package/bin/cli/cmds/docs/generate-api.js +0 -22
- package/bin/cli/cmds/docs/generate-cli.js +0 -11
- package/bin/cli/cmds/docs/generate-readme.js +0 -11
- package/bin/cli/cmds/eject.js +0 -28
- package/bin/cli/cmds/git-hooks/index.js +0 -20
- package/bin/cli/cmds/git-hooks/reset.js +0 -48
- package/bin/cli/cmds/git-hooks/sync.js +0 -19
- package/bin/cli/cmds/release.js +0 -231
- package/bin/cli/lib/docs/generate-api-doc.js +0 -78
- package/bin/cli/lib/version/update-version.js +0 -52
- package/bin/scripts/commit-msg.js +0 -32
- package/bin/scripts/pre-commit.js +0 -24
- package/dist/cli/command-visitors/index.d.ts +0 -9
- package/src/index.js +0 -507
- package/template/CHANGELOG.md +0 -0
- package/template/bin/cli/cli.js +0 -27
- package/template/bin/cli/cmds/changelog.js +0 -71
- package/template/bin/cli/cmds/docs.js +0 -30
- package/template/bin/cli/cmds/docs_cmds/generate-api.js +0 -75
- package/template/bin/cli/cmds/docs_cmds/generate-readme.js +0 -51
- package/template/bin/cli/cmds/git-hooks.js +0 -30
- package/template/bin/cli/cmds/git_hooks_cmds/reset.js +0 -76
- package/template/bin/cli/cmds/git_hooks_cmds/sync.js +0 -44
- package/template/bin/cli/cmds/release.js +0 -219
- package/template/bin/cli/index.js +0 -7
- package/template/bin/cli/lib/docs/generate-api-doc.js +0 -33
- package/template/bin/cli/lib/release/generate-release-note.js +0 -3
- package/template/bin/cli/lib/version/update-version.js +0 -51
- package/template/bin/scripts/commit-msg.js +0 -42
- package/template/bin/scripts/pre-commit.js +0 -32
- package/template/docs/api/docs.config.js +0 -10
- package/template/docs/readme/config.js +0 -22
- package/template/docs/readme/readme.js +0 -70
- package/template/docs/readme/template.md +0 -53
- /package/bin/cli/cmds/{docs → private/docs}/lint.js +0 -0
- /package/bin/cli/cmds/{test.js → private/test.js} +0 -0
- /package/bin/cli/cmds/{squeeze.js → public/squeeze.js} +0 -0
package/README.md
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
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.*
|
|
@@ -1,41 +0,0 @@
|
|
|
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
|
-
})
|
|
@@ -1,22 +0,0 @@
|
|
|
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
|
-
})
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
})
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
})
|
package/bin/cli/cmds/eject.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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
|
-
})
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
})
|
|
@@ -1,48 +0,0 @@
|
|
|
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
|
-
})
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
})
|
package/bin/cli/cmds/release.js
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const semver = require('semver')
|
|
3
|
-
const juisy = require('../../../src')
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
$style,
|
|
7
|
-
log,
|
|
8
|
-
step,
|
|
9
|
-
substep,
|
|
10
|
-
run,
|
|
11
|
-
error,
|
|
12
|
-
wait,
|
|
13
|
-
confirm,
|
|
14
|
-
prompts
|
|
15
|
-
} = juisy.utils
|
|
16
|
-
|
|
17
|
-
const rootDir = path.resolve(__dirname, '../../../')
|
|
18
|
-
|
|
19
|
-
// Get package.json content
|
|
20
|
-
const packageJson = require(path.resolve(rootDir, './package.json'))
|
|
21
|
-
const updateVersion = require('../lib/version/update-version')
|
|
22
|
-
|
|
23
|
-
// Exports command object
|
|
24
|
-
module.exports = {
|
|
25
|
-
private: true,
|
|
26
|
-
/**
|
|
27
|
-
* Command syntax
|
|
28
|
-
*/
|
|
29
|
-
command: 'release',
|
|
30
|
-
/**
|
|
31
|
-
* Aliases
|
|
32
|
-
*/
|
|
33
|
-
aliases: [],
|
|
34
|
-
/**
|
|
35
|
-
* Command description
|
|
36
|
-
*/
|
|
37
|
-
describe: 'Make a release',
|
|
38
|
-
/**
|
|
39
|
-
* Builder
|
|
40
|
-
* @param {Object} yargs
|
|
41
|
-
* @return {Object}
|
|
42
|
-
*/
|
|
43
|
-
builder: function (yargs) {
|
|
44
|
-
return yargs.option('p', {
|
|
45
|
-
alias: 'preid',
|
|
46
|
-
type: 'string',
|
|
47
|
-
describe: 'Pre-release id',
|
|
48
|
-
requiresArg: true
|
|
49
|
-
})
|
|
50
|
-
},
|
|
51
|
-
/**
|
|
52
|
-
* Handler
|
|
53
|
-
* @param {Object} argv - The argv
|
|
54
|
-
* @return {void}
|
|
55
|
-
*/
|
|
56
|
-
handler: async function (argv) {
|
|
57
|
-
let targetVersion
|
|
58
|
-
const currentVersion = packageJson.version
|
|
59
|
-
const packageName = packageJson.name
|
|
60
|
-
const preId = argv.preid || (semver.prerelease(currentVersion) && semver.prerelease(currentVersion)[0])
|
|
61
|
-
const inc = i => semver.inc(currentVersion, i, preId)
|
|
62
|
-
const versionIncrements = [
|
|
63
|
-
'patch',
|
|
64
|
-
'minor',
|
|
65
|
-
'major',
|
|
66
|
-
...(preId ? [ 'prepatch', 'preminor', 'premajor', 'prerelease' ] : [])
|
|
67
|
-
]
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* First, check if local repository is clean
|
|
71
|
-
*/
|
|
72
|
-
step('Checking changes to commit')
|
|
73
|
-
const { stdout } = await run('git', [ 'diff' ], { stdio: 'pipe', cwd: rootDir })
|
|
74
|
-
if (stdout) {
|
|
75
|
-
error('Please commit your changes before creating a new release!', new Error('There are changes to commit'))
|
|
76
|
-
}
|
|
77
|
-
substep($style.green('✔ Local repository is clean'), { last: true })
|
|
78
|
-
log() // Blank line
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Release prompt
|
|
82
|
-
*/
|
|
83
|
-
step('Setup')
|
|
84
|
-
const { release } = await prompts([
|
|
85
|
-
{
|
|
86
|
-
type: 'select',
|
|
87
|
-
name: 'release',
|
|
88
|
-
message: 'Release type:',
|
|
89
|
-
choices: versionIncrements.map(i => ({ title: `${i} (${inc(i)})`, value: inc(i) })).concat([ { title: 'custom', value: 'custom' } ])
|
|
90
|
-
}
|
|
91
|
-
])
|
|
92
|
-
// If custom release
|
|
93
|
-
if (release === 'custom') {
|
|
94
|
-
const { version: customVersion } = await prompts([
|
|
95
|
-
{
|
|
96
|
-
type: 'text',
|
|
97
|
-
name: 'version',
|
|
98
|
-
message: 'New custom version:',
|
|
99
|
-
initial: currentVersion,
|
|
100
|
-
validate: value => Boolean(semver.valid(value))
|
|
101
|
-
}
|
|
102
|
-
])
|
|
103
|
-
targetVersion = customVersion
|
|
104
|
-
} else {
|
|
105
|
-
targetVersion = release
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Demand confirmation
|
|
110
|
-
*/
|
|
111
|
-
await confirm({ message: `Releasing v${targetVersion}. Confirm?` })
|
|
112
|
-
log() // Blank line
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Run tests
|
|
116
|
-
*/
|
|
117
|
-
// step(`Running tests`)
|
|
118
|
-
// ... here run tests
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Update version in necessary files
|
|
122
|
-
*/
|
|
123
|
-
await updateVersion(targetVersion)
|
|
124
|
-
log() // Blank line
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Generate docs
|
|
128
|
-
*/
|
|
129
|
-
step('Generate docs')
|
|
130
|
-
await wait('API docs', async () => {
|
|
131
|
-
await run('node', [ './bin/cli', 'docs', 'generate:api' ], { stdio: 'pipe', cwd: rootDir })
|
|
132
|
-
})
|
|
133
|
-
substep($style.green('✔ API docs successfuly generated'))
|
|
134
|
-
await wait('CLI docs', async () => {
|
|
135
|
-
await run('node', [ './bin/cli', 'docs', 'generate:cli' ], { stdio: 'pipe', cwd: rootDir })
|
|
136
|
-
})
|
|
137
|
-
substep($style.green('✔ CLI docs successfuly generated'))
|
|
138
|
-
await wait('README', async () => {
|
|
139
|
-
await run('node', [ './bin/cli', 'docs', 'generate:readme' ], { stdio: 'pipe', cwd: rootDir })
|
|
140
|
-
})
|
|
141
|
-
substep($style.green('✔ README successfuly generated'), { last: true })
|
|
142
|
-
// await wait('Linting', async () => {
|
|
143
|
-
// await run('node', [ './bin/cli', 'docs', 'lint', '-c', './docs/.markdownlint-cli2.cjs' ], { stdio: 'pipe', cwd: rootDir })
|
|
144
|
-
// })
|
|
145
|
-
log() // Blank line
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Generate changelog file
|
|
149
|
-
*/
|
|
150
|
-
step('Generating changelog')
|
|
151
|
-
await wait('Generating', async () => {
|
|
152
|
-
await run('node', [ './bin/cli', 'changelog' ], { stdio: 'pipe', cwd: rootDir })
|
|
153
|
-
})
|
|
154
|
-
substep($style.green('✔ Success'), { last: true })
|
|
155
|
-
log() // Blank line
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Confirm changes to commit
|
|
159
|
-
*/
|
|
160
|
-
step('Confirm changes to commit')
|
|
161
|
-
substep($style.yellow('↓ The following changes will be committed:'))
|
|
162
|
-
await run('git', [ 'status', '-s' ], { stdio: 'inherit', cwd: rootDir })
|
|
163
|
-
substep($style.yellow('- The following tag will be created: ') + `v${targetVersion}`, { last: true })
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Demand confirmation
|
|
167
|
-
*/
|
|
168
|
-
await confirm()
|
|
169
|
-
log() // Blank line
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Publish package
|
|
173
|
-
*/
|
|
174
|
-
step(`Publishing ${packageName}`)
|
|
175
|
-
const releaseTag = targetVersion.includes('alpha')
|
|
176
|
-
? 'alpha'
|
|
177
|
-
: targetVersion.includes('beta')
|
|
178
|
-
? 'beta'
|
|
179
|
-
: targetVersion.includes('rc')
|
|
180
|
-
? 'rc'
|
|
181
|
-
: null
|
|
182
|
-
let alreadyPublished = false
|
|
183
|
-
await wait('Publishing', async () => {
|
|
184
|
-
try {
|
|
185
|
-
await run('npm', [ 'publish', ...(releaseTag ? [ '--tag', releaseTag ] : []) ], { stdio: 'pipe', cwd: rootDir })
|
|
186
|
-
} catch (e) {
|
|
187
|
-
if (e.stderr.match(/previously published/)) {
|
|
188
|
-
alreadyPublished = true
|
|
189
|
-
} else {
|
|
190
|
-
error('Unknown error during publishing', e)
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
})
|
|
194
|
-
substep(
|
|
195
|
-
alreadyPublished
|
|
196
|
-
? $style.yellow(`Skipping already published: ${packageName}`)
|
|
197
|
-
: $style.green('✔ Success'),
|
|
198
|
-
{ last: true }
|
|
199
|
-
)
|
|
200
|
-
log() // Blank line
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Push to git
|
|
204
|
-
*/
|
|
205
|
-
step('Pushing changes')
|
|
206
|
-
await wait('Committing', async () => {
|
|
207
|
-
try {
|
|
208
|
-
await run('git', [ 'add', '.' ], { stdio: 'pipe', cwd: rootDir })
|
|
209
|
-
await run('git', [ 'commit', '-m', `chore(release): v${targetVersion}` ], { stdio: 'pipe', cwd: rootDir })
|
|
210
|
-
} catch (e) {
|
|
211
|
-
error('Unable to commit', e)
|
|
212
|
-
}
|
|
213
|
-
})
|
|
214
|
-
substep($style.green('✔ Committed'))
|
|
215
|
-
await wait('Creating tag', async () => {
|
|
216
|
-
try {
|
|
217
|
-
await run('git', [ 'tag', '-a', `v${targetVersion}`, '-m', `v${targetVersion}` ], { stdio: 'pipe', cwd: rootDir })
|
|
218
|
-
} catch (e) {
|
|
219
|
-
error('Unable to create tag', e)
|
|
220
|
-
}
|
|
221
|
-
})
|
|
222
|
-
substep($style.green('✔ Tagged'))
|
|
223
|
-
log() // blank line
|
|
224
|
-
|
|
225
|
-
log($style.green(`✔ Release v${targetVersion} successfuly created`))
|
|
226
|
-
log()
|
|
227
|
-
|
|
228
|
-
log($style.yellow('IMPORTANT: You should now run ') + 'git push origin --follow-tags')
|
|
229
|
-
log()
|
|
230
|
-
}
|
|
231
|
-
}
|