@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.
@@ -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) || [];
@@ -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, pkgCwd } from '../lib/utils.mjs';
5
+ import { getAuthorName } from '../lib/utils.mjs';
5
6
 
6
7
  export async function License() {
7
- const { license, author = '' } = pkgCwd();
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 } = pkgCwd();
7
+ const { name, description } = getPkg();
8
8
 
9
9
  new Text()
10
10
  .source('README.md')
@@ -19,6 +19,7 @@ export async function Registry() {
19
19
  ) {
20
20
  return text;
21
21
  }
22
+
22
23
  return `registry = https://mirrors.tencent.com/npm/\r${text}`;
23
24
  })
24
25
  .output()
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.15.0',
3
- commitlint: '^13.2.1',
4
- eslint: '^7.32.0',
5
- 'eslint-plugin-ava': '^13.1.0',
6
- garou: '^0.2.4',
7
- prettier: '^2.4.1',
8
- stylelint: '^14.0.1',
9
- typescript: '^4.4.4',
10
- '@bring-it/cli': '^0.5.5',
11
- '@playwright/test': '^1.16.2',
12
- '@types/react': '^16.14.20',
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: '~2.2.17',
16
+ tailwindcss: '~3.0.19',
18
17
  vue: '~2.6.14',
19
- 'eslint-config-base': '^0.5.66',
20
- 'stylelint-config': '^0.6.2',
21
- 'prettier-config': '^0.5.1',
22
- 'commitlint-config': '^0.2.2',
23
- cli: '^0.5.31',
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
- return (await getAuthor(author)).name || 'Unknown';
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.9",
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": "^4.1.2",
44
+ "chalk": "^5.0.0",
45
45
  "deepmerge": "^4.2.2",
46
- "execa": "^5.1.1",
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.1",
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",
@@ -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
- ['#!/bin/sh', '', 'npx --no-install commitlint -e', ''].join('\n'),
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
- commitlint: latest.commitlint,
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: { tailwindcss: latest.postcss } }
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 = {} } = pkgCwd();
211
+ const { dependencies = {}, devDependencies = {} } = getPkg();
214
212
 
215
213
  return {
216
214
  instructions: false,
@@ -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, pkgCwd } from '../lib/utils.mjs';
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 = pkgCwd();
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) => {