@nice-move/cli 0.6.0 → 0.7.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 CHANGED
@@ -21,14 +21,28 @@ npm install @nice-move/cli --save-dev
21
21
  ## Usage
22
22
 
23
23
  ```bash
24
- npx --no-install nice-move <command>
24
+ npm exec nice-move <command>
25
25
  ```
26
26
 
27
27
  ## Commands
28
28
 
29
- ### lint
29
+ ### `lint commit`
30
30
 
31
- Lint and format everything.
31
+ Lint git commit message.
32
+
33
+ Use [commitlint](https://commitlint.js.org/) to enforcing [conventional commits](https://conventionalcommits.org/).
34
+
35
+ ```sh
36
+ #!/bin/sh
37
+
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.
32
46
 
33
47
  Install `eslint` / `stylelint` / `prettier` / `garou` when needed:
34
48
 
@@ -39,7 +53,7 @@ npm install eslint stylelint prettier garou --save-dev
39
53
  Add configurations:
40
54
 
41
55
  ```jsonc
42
- // example: package.json
56
+ // file: package.json
43
57
  {
44
58
  "eslintConfig": {},
45
59
  "prettier": {},
@@ -48,14 +62,27 @@ Add configurations:
48
62
  }
49
63
  ```
50
64
 
65
+ ```sh
66
+ #!/bin/sh
67
+
68
+ # file: .git/hooks/pre-commit
69
+
70
+ npm exec nice-move lint staged
71
+ ```
72
+
51
73
  Change a few files, then run:
52
74
 
53
75
  ```bash
54
76
  git add .
55
- npx --no-install nice-move lint
77
+ npm exec nice-move lint staged
56
78
  ```
57
79
 
58
80
  ## Related
59
81
 
60
82
  - [@nice-move/init](../init)
61
- - [@nice-move/lint](../lint)
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,9 +1,10 @@
1
- 'use strict';
1
+ import { createRequire } from 'module';
2
2
 
3
- const { isReachable } = require('settingz');
3
+ import { execa } from 'execa';
4
+ import { isReachable } from 'settingz';
4
5
 
5
6
  // eslint-disable-next-line consistent-return
6
- module.exports = function svgoCaller() {
7
+ export function svgoCaller() {
7
8
  if (
8
9
  isReachable('svgo/package.json') &&
9
10
  isReachable('svgo-config/package.json')
@@ -12,7 +13,8 @@ module.exports = function svgoCaller() {
12
13
  command: 'svgo',
13
14
  describe: 'Run `svgo` to optimize `*.svg`',
14
15
  handler({ _: [_, path = './'] }) {
15
- const execa = require('execa');
16
+ const require = createRequire(import.meta.url);
17
+
16
18
  execa('svgo', [
17
19
  '-r',
18
20
  '-q',
@@ -20,7 +22,7 @@ module.exports = function svgoCaller() {
20
22
  '--indent',
21
23
  '2',
22
24
  '--config',
23
- 'node_modules/svgo-config/config.json',
25
+ require.resolve('svgo-config'),
24
26
  '-f',
25
27
  path,
26
28
  ])
@@ -34,4 +36,4 @@ module.exports = function svgoCaller() {
34
36
  },
35
37
  };
36
38
  }
37
- };
39
+ }
package/index.mjs CHANGED
@@ -2,12 +2,14 @@
2
2
 
3
3
  import { Cheetor } from 'cheetor';
4
4
 
5
- import svgoCaller from './cmd/svgo.cjs';
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
- .commandFrom('../cmd/lint.mjs')
11
+ .commandSafe('@nice-move/lint/cmd/commit.mjs')
12
+ .commandSafe('@nice-move/lint/cmd/staged.mjs')
13
+ .commandSafe('@nice-move/lint/cmd/all.mjs')
12
14
  .commandSmart(svgoCaller)
13
15
  .setup();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-move/cli",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "description": "Frontend develop helper for frontend development",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -34,13 +34,13 @@
34
34
  "nice-move": "index.mjs"
35
35
  },
36
36
  "dependencies": {
37
- "@nice-move/lint": "^0.3.4",
38
- "cheetor": "^0.12.2",
39
- "execa": "^5.1.1",
40
- "settingz": "^0.1.0"
37
+ "@nice-move/lint": "^0.4.1",
38
+ "cheetor": "^0.12.5",
39
+ "execa": "^6.1.0",
40
+ "settingz": "^0.1.7"
41
41
  },
42
42
  "engines": {
43
- "node": "^12.22.0 || ^14.17.0 || >=16.13.0"
43
+ "node": "^14.17.0 || >=16.13.0"
44
44
  },
45
45
  "publishConfig": {
46
46
  "access": "public",
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';