@nice-move/cli 0.5.32 → 0.7.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 +30 -17
- package/cmd/{svgo.cjs → svgo.mjs} +10 -22
- package/index.mjs +4 -3
- package/package.json +6 -6
- package/cmd/init.mjs +0 -11
- package/cmd/lint.mjs +0 -20
package/README.md
CHANGED
|
@@ -21,28 +21,28 @@ npm install @nice-move/cli --save-dev
|
|
|
21
21
|
## Usage
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
|
|
24
|
+
npm exec nice-move <command>
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
## Commands
|
|
28
28
|
|
|
29
|
-
###
|
|
29
|
+
### `lint commit`
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
Lint git commit message.
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
- Run `git init` when workspace not a git project
|
|
35
|
-
- Run a better `npm init` / `yarn init` command when needed
|
|
36
|
-
- Create or overwrite `.gitignore` / `.gitattributes`
|
|
37
|
-
- Create or overwrite `LICENSE` / `.editorconfig`
|
|
38
|
-
- Create `README.md` when it not exists
|
|
39
|
-
- Set registry to China mirror in `.npmrc` / `.yarnrc`
|
|
40
|
-
- Add or reset project dependencies by interactive
|
|
41
|
-
- Run `npm` / `yarn` install command
|
|
33
|
+
Use [commitlint](https://commitlint.js.org/) to enforcing [conventional commits](https://conventionalcommits.org/).
|
|
42
34
|
|
|
43
|
-
|
|
35
|
+
```sh
|
|
36
|
+
#!/bin/sh
|
|
44
37
|
|
|
45
|
-
|
|
38
|
+
# file: .git/hooks/commit-msg
|
|
39
|
+
|
|
40
|
+
npm exec nice-move lint commit
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### `lint staged`
|
|
44
|
+
|
|
45
|
+
Lint and format git staged files.
|
|
46
46
|
|
|
47
47
|
Install `eslint` / `stylelint` / `prettier` / `garou` when needed:
|
|
48
48
|
|
|
@@ -53,7 +53,7 @@ npm install eslint stylelint prettier garou --save-dev
|
|
|
53
53
|
Add configurations:
|
|
54
54
|
|
|
55
55
|
```jsonc
|
|
56
|
-
//
|
|
56
|
+
// file: package.json
|
|
57
57
|
{
|
|
58
58
|
"eslintConfig": {},
|
|
59
59
|
"prettier": {},
|
|
@@ -62,14 +62,27 @@ Add configurations:
|
|
|
62
62
|
}
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+
```sh
|
|
66
|
+
#!/bin/sh
|
|
67
|
+
|
|
68
|
+
# file: .git/hooks/pre-commit
|
|
69
|
+
|
|
70
|
+
npm exec nice-move lint staged
|
|
71
|
+
```
|
|
72
|
+
|
|
65
73
|
Change a few files, then run:
|
|
66
74
|
|
|
67
75
|
```bash
|
|
68
76
|
git add .
|
|
69
|
-
|
|
77
|
+
npm exec nice-move lint staged
|
|
70
78
|
```
|
|
71
79
|
|
|
72
80
|
## Related
|
|
73
81
|
|
|
74
82
|
- [@nice-move/init](../init)
|
|
75
|
-
- [@nice-move/
|
|
83
|
+
- [@nice-move/commitlint-config](../commitlint-config)
|
|
84
|
+
- [@nice-move/eslint-config-base](../eslint-config-base)
|
|
85
|
+
- [@nice-move/eslint-config-react](../eslint-config-react)
|
|
86
|
+
- [@nice-move/eslint-config-vue](../eslint-config-vue)
|
|
87
|
+
- [@nice-move/stylelint-config](../stylelint-config)
|
|
88
|
+
- [@nice-move/prettier-config](../prettier-config)
|
|
@@ -1,32 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
require.resolve(moduleId);
|
|
6
|
-
return true;
|
|
7
|
-
} catch (error) {
|
|
8
|
-
if (
|
|
9
|
-
error.code === 'MODULE_NOT_FOUND' &&
|
|
10
|
-
error.requireStack &&
|
|
11
|
-
error.requireStack[0] === __filename
|
|
12
|
-
) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
throw error;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
3
|
+
import { execa } from 'execa';
|
|
4
|
+
import { isReachable } from 'settingz';
|
|
18
5
|
|
|
19
6
|
// eslint-disable-next-line consistent-return
|
|
20
|
-
|
|
7
|
+
export function svgoCaller() {
|
|
21
8
|
if (
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
isReachable('svgo/package.json') &&
|
|
10
|
+
isReachable('svgo-config/package.json')
|
|
24
11
|
) {
|
|
25
12
|
return {
|
|
26
13
|
command: 'svgo',
|
|
27
14
|
describe: 'Run `svgo` to optimize `*.svg`',
|
|
28
15
|
handler({ _: [_, path = './'] }) {
|
|
29
|
-
const
|
|
16
|
+
const require = createRequire(import.meta.url);
|
|
17
|
+
|
|
30
18
|
execa('svgo', [
|
|
31
19
|
'-r',
|
|
32
20
|
'-q',
|
|
@@ -34,7 +22,7 @@ module.exports = function svgoCaller() {
|
|
|
34
22
|
'--indent',
|
|
35
23
|
'2',
|
|
36
24
|
'--config',
|
|
37
|
-
'
|
|
25
|
+
require.resolve('svgo-config'),
|
|
38
26
|
'-f',
|
|
39
27
|
path,
|
|
40
28
|
])
|
|
@@ -48,4 +36,4 @@ module.exports = function svgoCaller() {
|
|
|
48
36
|
},
|
|
49
37
|
};
|
|
50
38
|
}
|
|
51
|
-
}
|
|
39
|
+
}
|
package/index.mjs
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import { Cheetor } from 'cheetor';
|
|
4
4
|
|
|
5
|
-
import svgoCaller from './cmd/svgo.
|
|
5
|
+
import { svgoCaller } from './cmd/svgo.mjs';
|
|
6
6
|
|
|
7
7
|
process.on('SIGINT', () => {});
|
|
8
8
|
|
|
9
9
|
new Cheetor('./package.json', import.meta.url)
|
|
10
10
|
.website('https://www.npmjs.com/org/nice-move')
|
|
11
|
-
.
|
|
12
|
-
.
|
|
11
|
+
.commandSafe('@nice-move/lint/cmd/commit.mjs')
|
|
12
|
+
.commandSafe('@nice-move/lint/cmd/staged.mjs')
|
|
13
|
+
.commandSafe('@nice-move/lint/cmd/all.mjs')
|
|
13
14
|
.commandSmart(svgoCaller)
|
|
14
15
|
.setup();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nice-move/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Frontend develop helper for frontend development",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
"nice-move": "index.mjs"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@nice-move/
|
|
38
|
-
"@nice-move/lint": "^0.3.4",
|
|
37
|
+
"@nice-move/lint": "^0.4.0",
|
|
39
38
|
"cheetor": "^0.12.2",
|
|
40
|
-
"execa": "^
|
|
39
|
+
"execa": "^6.0.0",
|
|
40
|
+
"settingz": "^0.1.5"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
|
-
"node": "^
|
|
43
|
+
"node": "^14.17.0 || >=16.13.0"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public",
|
|
47
47
|
"registry": "https://registry.npmjs.org/"
|
|
48
48
|
}
|
|
49
|
-
}
|
|
49
|
+
}
|
package/cmd/init.mjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module';
|
|
2
|
-
|
|
3
|
-
const requireJson = createRequire(import.meta.url);
|
|
4
|
-
|
|
5
|
-
const { description } = requireJson('@nice-move/init/package.json');
|
|
6
|
-
|
|
7
|
-
export const command = 'init';
|
|
8
|
-
|
|
9
|
-
export const describe = description;
|
|
10
|
-
|
|
11
|
-
export { init as handler } from '@nice-move/init';
|
package/cmd/lint.mjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module';
|
|
2
|
-
|
|
3
|
-
const requireJson = createRequire(import.meta.url);
|
|
4
|
-
|
|
5
|
-
const { description } = requireJson('@nice-move/lint/package.json');
|
|
6
|
-
|
|
7
|
-
export const command = 'lint';
|
|
8
|
-
|
|
9
|
-
export const describe = description;
|
|
10
|
-
|
|
11
|
-
export const builder = {
|
|
12
|
-
shell: {
|
|
13
|
-
alias: 'x',
|
|
14
|
-
default: false,
|
|
15
|
-
describe: 'skip parsing of tasks for better shell support',
|
|
16
|
-
type: 'boolean',
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export { lint as handler } from '@nice-move/lint';
|