@nice-move/init 0.3.9 → 0.3.13
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/action/git-file.mjs +2 -0
- package/action/license.mjs +3 -2
- package/action/readme.mjs +2 -2
- package/action/registry.mjs +1 -0
- package/bin/index.mjs +0 -0
- package/index.mjs +1 -1
- package/lib/latest.mjs +17 -18
- package/lib/utils.mjs +8 -11
- package/package.json +5 -4
- package/prompt/dependencies.mjs +13 -15
- package/prompt/git-init.mjs +2 -1
- package/prompt/index.mjs +4 -2
package/action/git-file.mjs
CHANGED
|
@@ -28,6 +28,7 @@ function getPlatform(context) {
|
|
|
28
28
|
]),
|
|
29
29
|
].sort();
|
|
30
30
|
}
|
|
31
|
+
|
|
31
32
|
throw new Error('fail');
|
|
32
33
|
} catch {
|
|
33
34
|
return Types[type()];
|
|
@@ -51,6 +52,7 @@ export async function GitFile() {
|
|
|
51
52
|
.onFail()
|
|
52
53
|
.onDone((oldText = '') => {
|
|
53
54
|
const platform = getPlatform(oldText);
|
|
55
|
+
|
|
54
56
|
return download(`https://gitignore.io/api/node,${platform}`)
|
|
55
57
|
.then((newText) => {
|
|
56
58
|
const [match] = oldText.match(regexp) || [];
|
package/action/license.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Text } from 'fs-chain';
|
|
2
|
+
import { getPkg } from 'settingz';
|
|
2
3
|
|
|
3
4
|
import { cyan } from '../lib/color.mjs';
|
|
4
|
-
import { getAuthorName
|
|
5
|
+
import { getAuthorName } from '../lib/utils.mjs';
|
|
5
6
|
|
|
6
7
|
export async function License() {
|
|
7
|
-
const { license, author = '' } =
|
|
8
|
+
const { license, author = '' } = getPkg();
|
|
8
9
|
|
|
9
10
|
const isMIT = license === 'MIT';
|
|
10
11
|
|
package/action/readme.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Text } from 'fs-chain';
|
|
2
|
+
import { getPkg } from 'settingz';
|
|
2
3
|
|
|
3
4
|
import { cyan } from '../lib/color.mjs';
|
|
4
|
-
import { pkgCwd } from '../lib/utils.mjs';
|
|
5
5
|
|
|
6
6
|
export async function Readme() {
|
|
7
|
-
const { name, description } =
|
|
7
|
+
const { name, description } = getPkg();
|
|
8
8
|
|
|
9
9
|
new Text()
|
|
10
10
|
.source('README.md')
|
package/action/registry.mjs
CHANGED
package/bin/index.mjs
CHANGED
|
File without changes
|
package/index.mjs
CHANGED
|
@@ -30,8 +30,8 @@ export async function init() {
|
|
|
30
30
|
].filter((func) => typeof func === 'function');
|
|
31
31
|
|
|
32
32
|
for (const action of actions) {
|
|
33
|
-
// eslint-disable-next-line no-await-in-loop
|
|
34
33
|
const io = await action();
|
|
34
|
+
|
|
35
35
|
if (io && io.catch) {
|
|
36
36
|
io.catch((error) => {
|
|
37
37
|
console.warn(error.message);
|
package/lib/latest.mjs
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
ava: '^
|
|
3
|
-
|
|
4
|
-
eslint: '^
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
'@
|
|
11
|
-
'@
|
|
12
|
-
|
|
13
|
-
postcss: '^8.3.11',
|
|
2
|
+
ava: '^4.0.1',
|
|
3
|
+
eslint: '^8.8.0',
|
|
4
|
+
'eslint-plugin-ava': '^13.2.0',
|
|
5
|
+
garou: '^0.3.11',
|
|
6
|
+
prettier: '^2.5.1',
|
|
7
|
+
stylelint: '^14.3.0',
|
|
8
|
+
typescript: '^4.5.5',
|
|
9
|
+
'@bring-it/cli': '^0.5.6',
|
|
10
|
+
'@playwright/test': '^1.18.1',
|
|
11
|
+
'@types/react': '^16.14.23',
|
|
12
|
+
postcss: '^8.4.6',
|
|
14
13
|
react: '~16.14.0',
|
|
15
14
|
'react-dom': '~16.14.0',
|
|
16
15
|
rustywind: '^0.12.2',
|
|
17
|
-
tailwindcss: '~
|
|
16
|
+
tailwindcss: '~3.0.19',
|
|
18
17
|
vue: '~2.6.14',
|
|
19
|
-
'eslint-config-base': '^0.
|
|
20
|
-
'stylelint-config': '^0.6.
|
|
21
|
-
'prettier-config': '^0.5.
|
|
22
|
-
'commitlint-config': '^0.
|
|
23
|
-
cli: '^0.
|
|
18
|
+
'eslint-config-base': '^0.6.1',
|
|
19
|
+
'stylelint-config': '^0.6.14',
|
|
20
|
+
'prettier-config': '^0.5.2',
|
|
21
|
+
'commitlint-config': '^0.5.0',
|
|
22
|
+
cli: '^0.7.0',
|
|
24
23
|
lts: '^12.22.0 || ^14.17.0 || >=16.13.0',
|
|
25
24
|
};
|
package/lib/utils.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { readdirSync } from 'fs';
|
|
2
|
-
import { createRequire } from 'module';
|
|
3
2
|
|
|
4
3
|
import centra from 'centra';
|
|
5
|
-
import execa from 'execa';
|
|
4
|
+
import { execa } from 'execa';
|
|
6
5
|
import stringify from 'stringify-author';
|
|
7
6
|
|
|
8
7
|
export function download(url) {
|
|
@@ -13,13 +12,16 @@ export function download(url) {
|
|
|
13
12
|
if (response.statusCode === 301) {
|
|
14
13
|
return download(response.headers.location);
|
|
15
14
|
}
|
|
15
|
+
|
|
16
16
|
return response.text();
|
|
17
17
|
})
|
|
18
18
|
.then((response) => {
|
|
19
19
|
const data = response.trim();
|
|
20
|
+
|
|
20
21
|
if (data) {
|
|
21
22
|
return data;
|
|
22
23
|
}
|
|
24
|
+
|
|
23
25
|
throw new Error('template download fail');
|
|
24
26
|
});
|
|
25
27
|
}
|
|
@@ -27,20 +29,13 @@ export function download(url) {
|
|
|
27
29
|
export async function gitSupport() {
|
|
28
30
|
try {
|
|
29
31
|
const { stdout } = await execa('git', ['--version']);
|
|
32
|
+
|
|
30
33
|
return Boolean(stdout);
|
|
31
34
|
} catch {
|
|
32
35
|
return false;
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
export function pkgCwd() {
|
|
37
|
-
try {
|
|
38
|
-
return createRequire(`${process.cwd()}/`)('./package.json');
|
|
39
|
-
} catch {
|
|
40
|
-
return {};
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
39
|
export function emptyDir() {
|
|
45
40
|
return readdirSync(process.cwd()).length === 0;
|
|
46
41
|
}
|
|
@@ -66,5 +61,7 @@ export async function getAuthor(author) {
|
|
|
66
61
|
}
|
|
67
62
|
|
|
68
63
|
export async function getAuthorName(author) {
|
|
69
|
-
|
|
64
|
+
const info = await getAuthor(author);
|
|
65
|
+
|
|
66
|
+
return info.name || 'Unknown';
|
|
70
67
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nice-move/init",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.13",
|
|
4
4
|
"description": "Initialize your frontend workspaces",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -41,17 +41,18 @@
|
|
|
41
41
|
"main": "index.mjs",
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"centra": "^2.5.0",
|
|
44
|
-
"chalk": "^
|
|
44
|
+
"chalk": "^5.0.0",
|
|
45
45
|
"deepmerge": "^4.2.2",
|
|
46
|
-
"execa": "^
|
|
46
|
+
"execa": "^6.0.0",
|
|
47
47
|
"fs-chain": "^8.1.1",
|
|
48
48
|
"is-git-dirty": "^2.0.1",
|
|
49
49
|
"is-git-repository": "^2.0.0",
|
|
50
50
|
"ora": "^6.0.1",
|
|
51
|
-
"os-locale": "^6.0.
|
|
51
|
+
"os-locale": "^6.0.2",
|
|
52
52
|
"parse-author": "^2.0.0",
|
|
53
53
|
"prompts": "^2.4.2",
|
|
54
54
|
"semver-regex": "^4.0.2",
|
|
55
|
+
"settingz": "^0.1.5",
|
|
55
56
|
"stringify-author": "^0.1.3",
|
|
56
57
|
"user-meta": "^1.0.0",
|
|
57
58
|
"validate-npm-package-name": "^3.0.0",
|
package/prompt/dependencies.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import deepmerge from 'deepmerge';
|
|
2
2
|
import { Json, Text } from 'fs-chain';
|
|
3
|
+
import { getPkg } from 'settingz';
|
|
3
4
|
|
|
4
5
|
import latest from '../lib/latest.mjs';
|
|
5
|
-
import { pkgCwd } from '../lib/utils.mjs';
|
|
6
6
|
|
|
7
7
|
function checkEslint({ vue, react }) {
|
|
8
8
|
const type =
|
|
@@ -49,7 +49,7 @@ function action(isGit, wanted = {}) {
|
|
|
49
49
|
const useLint = eslint || stylelint || prettier || garou;
|
|
50
50
|
|
|
51
51
|
const prepublishOnly = [
|
|
52
|
-
useLint ? 'npm run lint' : undefined,
|
|
52
|
+
useLint ? 'npm run lint:staged' : undefined,
|
|
53
53
|
ava ? 'npm test' : undefined,
|
|
54
54
|
].filter(Boolean);
|
|
55
55
|
|
|
@@ -62,7 +62,12 @@ function action(isGit, wanted = {}) {
|
|
|
62
62
|
if (commitlint) {
|
|
63
63
|
await new Text()
|
|
64
64
|
.onDone(() =>
|
|
65
|
-
[
|
|
65
|
+
[
|
|
66
|
+
'#!/bin/sh',
|
|
67
|
+
'',
|
|
68
|
+
'npx --no-install nice-move lint commit',
|
|
69
|
+
'',
|
|
70
|
+
].join('\n'),
|
|
66
71
|
)
|
|
67
72
|
.output('.githooks/commit-msg');
|
|
68
73
|
}
|
|
@@ -91,24 +96,17 @@ function action(isGit, wanted = {}) {
|
|
|
91
96
|
},
|
|
92
97
|
}
|
|
93
98
|
: undefined,
|
|
94
|
-
commitlint
|
|
99
|
+
useLint || commitlint
|
|
95
100
|
? {
|
|
96
|
-
commitlint: {
|
|
97
|
-
extends: '@nice-move/commitlint-config',
|
|
98
|
-
},
|
|
99
101
|
devDependencies: {
|
|
100
|
-
|
|
101
|
-
'@nice-move/commitlint-config': latest['commitlint-config'],
|
|
102
|
+
'@nice-move/cli': latest.cli,
|
|
102
103
|
},
|
|
103
104
|
}
|
|
104
105
|
: undefined,
|
|
105
106
|
useLint
|
|
106
107
|
? {
|
|
107
|
-
devDependencies: {
|
|
108
|
-
'@nice-move/cli': latest.cli,
|
|
109
|
-
},
|
|
110
108
|
scripts: {
|
|
111
|
-
lint: 'nice-move lint',
|
|
109
|
+
'lint:staged': 'nice-move lint staged',
|
|
112
110
|
},
|
|
113
111
|
}
|
|
114
112
|
: undefined,
|
|
@@ -168,7 +166,7 @@ function action(isGit, wanted = {}) {
|
|
|
168
166
|
? { devDependencies: { tailwindcss: latest.rustywind } }
|
|
169
167
|
: undefined,
|
|
170
168
|
postcss
|
|
171
|
-
? { devDependencies: {
|
|
169
|
+
? { devDependencies: { postcss: latest.postcss } }
|
|
172
170
|
: undefined,
|
|
173
171
|
playwright
|
|
174
172
|
? {
|
|
@@ -210,7 +208,7 @@ export function Dependencies() {
|
|
|
210
208
|
'tailwindcss',
|
|
211
209
|
];
|
|
212
210
|
|
|
213
|
-
const { dependencies = {}, devDependencies = {} } =
|
|
211
|
+
const { dependencies = {}, devDependencies = {} } = getPkg();
|
|
214
212
|
|
|
215
213
|
return {
|
|
216
214
|
instructions: false,
|
package/prompt/git-init.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import execa from 'execa';
|
|
1
|
+
import { execa } from 'execa';
|
|
2
2
|
|
|
3
3
|
import { green, red } from '../lib/color.mjs';
|
|
4
4
|
|
|
@@ -8,6 +8,7 @@ function init() {
|
|
|
8
8
|
return execa('git', ['init']).then(
|
|
9
9
|
(io) => {
|
|
10
10
|
console.log(green('√'), message);
|
|
11
|
+
|
|
11
12
|
return io;
|
|
12
13
|
},
|
|
13
14
|
(error) => {
|
package/prompt/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import isGitDirty from 'is-git-dirty';
|
|
2
2
|
import isGitRepo from 'is-git-repository';
|
|
3
3
|
import prompts from 'prompts';
|
|
4
|
+
import { getPkg } from 'settingz';
|
|
4
5
|
|
|
5
|
-
import { emptyDir, gitSupport
|
|
6
|
+
import { emptyDir, gitSupport } from '../lib/utils.mjs';
|
|
6
7
|
|
|
7
8
|
import { Dependencies } from './dependencies.mjs';
|
|
8
9
|
import { GitInit } from './git-init.mjs';
|
|
@@ -14,7 +15,7 @@ export async function Prompt() {
|
|
|
14
15
|
const isGit = gitSupported && isGitRepo();
|
|
15
16
|
const isDirty = isGit ? isGitDirty() : false;
|
|
16
17
|
const isEmpty = emptyDir();
|
|
17
|
-
const pkg =
|
|
18
|
+
const pkg = getPkg();
|
|
18
19
|
const cwd = process.cwd();
|
|
19
20
|
|
|
20
21
|
const options = {
|
|
@@ -53,6 +54,7 @@ export async function Prompt() {
|
|
|
53
54
|
if (okay === false) {
|
|
54
55
|
throw new Error('cancel');
|
|
55
56
|
}
|
|
57
|
+
|
|
56
58
|
return Object.entries(rest);
|
|
57
59
|
})
|
|
58
60
|
.then((sets) => {
|