@nice-move/init 0.3.1 → 0.3.5

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.
@@ -1,6 +1,7 @@
1
+ import { type } from 'os';
2
+
1
3
  import { Text } from 'fs-chain';
2
4
  import ora from 'ora';
3
- import { type } from 'os';
4
5
 
5
6
  import { cyan, green, red } from '../lib/color.mjs';
6
7
  import { download } from '../lib/utils.mjs';
@@ -54,9 +55,10 @@ export async function GitFile() {
54
55
  .then((newText) => {
55
56
  const [match] = oldText.match(regexp) || [];
56
57
 
57
- return `${(match
58
- ? oldText.replace(regexp, newText)
59
- : `${oldText.trim()}\n\n${newText}`
58
+ const io = (
59
+ match
60
+ ? oldText.replace(regexp, newText)
61
+ : `${oldText.trim()}\n\n${newText}`
60
62
  )
61
63
  .replace(
62
64
  /(www\.)?toptal\.com\/developers\/gitignore/g,
@@ -65,7 +67,9 @@ export async function GitFile() {
65
67
  .trim()
66
68
  .split(/\n\n\+/g)
67
69
  .filter((item) => item.trim())
68
- .join('\n\n')}\n`;
70
+ .join('\n\n');
71
+
72
+ return `${io}\n`;
69
73
  })
70
74
  .catch(() => oldText || 'node_modules\n');
71
75
  })
@@ -3,12 +3,14 @@ import { Text } from 'fs-chain';
3
3
  import { cyan } from '../lib/color.mjs';
4
4
  import { getAuthorName, pkgCwd } from '../lib/utils.mjs';
5
5
 
6
- export function License() {
6
+ export async function License() {
7
7
  const { license, author = '' } = pkgCwd();
8
8
 
9
9
  const isMIT = license === 'MIT';
10
10
 
11
11
  if (isMIT || license === 'Unlicense') {
12
+ const holder = await getAuthorName(author);
13
+
12
14
  return new Text()
13
15
  .source(
14
16
  isMIT ? '../../template/mit.tpl' : '../../template/unlicense.tpl',
@@ -18,7 +20,7 @@ export function License() {
18
20
  isMIT
19
21
  ? text
20
22
  .replace('{{year}}', new Date().getFullYear())
21
- .replace('{{holder}}', getAuthorName(author))
23
+ .replace('{{holder}}', holder)
22
24
  : text,
23
25
  )
24
26
  .output('LICENSE')
@@ -6,17 +6,6 @@ import latest from '../lib/latest.mjs';
6
6
 
7
7
  const pkg = 'package.json';
8
8
 
9
- function formatter(data) {
10
- // eslint-disable-next-line import/no-extraneous-dependencies
11
- return import('prettier')
12
- .then(({ default: { format, resolveConfig } }) => ({
13
- options: resolveConfig(pkg),
14
- format,
15
- }))
16
- .then(({ options, format }) => format(data, { ...options, filepath: pkg }))
17
- .catch(() => data);
18
- }
19
-
20
9
  export function Package(info) {
21
10
  return new Json()
22
11
  .config({ pretty: true })
@@ -40,9 +29,6 @@ export function Package(info) {
40
29
  info,
41
30
  ]),
42
31
  )
43
- .onDone(JSON.stringify)
44
- .onDone(formatter)
45
- .onDone(JSON.parse)
46
32
  .output()
47
33
  .logger('Add project info to', cyan(pkg))
48
34
  .catch(console.warn);
@@ -1,5 +1,5 @@
1
1
  import { Text } from 'fs-chain';
2
- import osLocale from 'os-locale';
2
+ import { osLocale } from 'os-locale';
3
3
 
4
4
  import { cyan } from '../lib/color.mjs';
5
5
 
package/lib/latest.mjs CHANGED
@@ -1 +1,20 @@
1
- export default {"ava":"^3.15.0","commitlint":"^12.1.4","eslint":"^7.29.0","eslint-plugin-ava":"^12.0.0","garou":"^0.1.29","prettier":"^2.3.1","stylelint":"^13.13.1","typescript":"^4.3.4","@types/react":"^16.14.8","react":"~16.14.0","react-dom":"~16.14.0","vue":"~2.6.14","eslint-config-base":"^0.5.44","stylelint-config":"^0.5.8","prettier-config":"^0.4.7","commitlint-config":"^0.1.3","cli":"^0.5.26","lts":"^12.22.0 || ^14.17.0"}
1
+ export default {
2
+ ava: '^3.15.0',
3
+ commitlint: '^13.1.0',
4
+ eslint: '^7.32.0',
5
+ 'eslint-plugin-ava': '^12.0.0',
6
+ garou: '^0.1.40',
7
+ prettier: '^2.3.2',
8
+ stylelint: '^13.13.1',
9
+ typescript: '^4.4.3',
10
+ '@types/react': '^16.14.11',
11
+ react: '~16.14.0',
12
+ 'react-dom': '~16.14.0',
13
+ vue: '~2.6.14',
14
+ 'eslint-config-base': '^0.5.62',
15
+ 'stylelint-config': '^0.5.11',
16
+ 'prettier-config': '^0.4.14',
17
+ 'commitlint-config': '^0.2.0',
18
+ cli: '^0.5.29',
19
+ lts: '^12.22.0 || ^14.17.0',
20
+ };
package/lib/utils.mjs CHANGED
@@ -1,10 +1,9 @@
1
- import centra from 'centra';
2
- import execa from 'execa';
3
1
  import { readdirSync } from 'fs';
4
2
  import { createRequire } from 'module';
5
- import { sep } from 'path';
3
+
4
+ import centra from 'centra';
5
+ import execa from 'execa';
6
6
  import stringify from 'stringify-author';
7
- import meta from 'user-meta';
8
7
 
9
8
  export function download(url) {
10
9
  return centra(url)
@@ -50,22 +49,22 @@ export function trim(value) {
50
49
  return value ? value.trim() : undefined;
51
50
  }
52
51
 
53
- export function getAuthorName(author = {}) {
54
- return (typeof author === 'string' ? author : author.name)
55
- ? meta.name
56
- : 'Unknown';
52
+ function getUser() {
53
+ return import('user-meta')
54
+ .then(({ default: meta }) => meta)
55
+ .catch(() => ({}));
57
56
  }
58
57
 
59
- export function dirname(path) {
60
- return path.split(sep).slice(-1)[0].trim();
61
- }
58
+ export async function getAuthor(author) {
59
+ if (author) {
60
+ return author;
61
+ }
62
62
 
63
- export function getAuthor(author = {}) {
64
- const io = meta.name ? stringify(meta) : undefined;
63
+ const meta = await getUser();
65
64
 
66
- if (typeof author === 'string') {
67
- return author || io || 'Unknown';
68
- }
65
+ return meta.name ? stringify(meta) : 'Unknown';
66
+ }
69
67
 
70
- return (author.name ? stringify(author) : io) || 'Unknown';
68
+ export async function getAuthorName(author) {
69
+ return (await getAuthor(author)).name || 'Unknown';
71
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-move/init",
3
- "version": "0.3.1",
3
+ "version": "0.3.5",
4
4
  "description": "Initialize your frontend workspaces",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -40,18 +40,18 @@
40
40
  },
41
41
  "main": "index.mjs",
42
42
  "dependencies": {
43
- "centra": "^2.4.2",
44
- "chalk": "^4.1.1",
43
+ "centra": "^2.5.0",
44
+ "chalk": "^4.1.2",
45
45
  "deepmerge": "^4.2.2",
46
46
  "execa": "^5.1.1",
47
- "fs-chain": "8.0.1",
47
+ "fs-chain": "8.1.0",
48
48
  "is-git-dirty": "^2.0.1",
49
49
  "is-git-repository": "^2.0.0",
50
- "ora": "^5.4.1",
51
- "os-locale": "^5.0.0",
50
+ "ora": "^6.0.1",
51
+ "os-locale": "^6.0.0",
52
52
  "parse-author": "^2.0.0",
53
53
  "prompts": "^2.4.1",
54
- "semver-regex": "^4.0.0",
54
+ "semver-regex": "^3.1.3",
55
55
  "stringify-author": "^0.1.3",
56
56
  "user-meta": "^1.0.0",
57
57
  "validate-npm-package-name": "^3.0.0",
package/prompt/index.mjs CHANGED
@@ -26,7 +26,7 @@ export async function Prompt() {
26
26
  cwd,
27
27
  };
28
28
 
29
- const PackagePrompts = Package(options);
29
+ const PackagePrompts = await Package(options);
30
30
 
31
31
  return prompts(
32
32
  [
@@ -1,12 +1,18 @@
1
+ import { parse as parsePath } from 'path';
2
+
1
3
  import parse from 'parse-author';
2
4
  import semverRegex from 'semver-regex';
3
5
  import validate from 'validate-npm-package-name';
4
6
 
5
- import { dirname, getAuthor, trim } from '../lib/utils.mjs';
7
+ import { getAuthor, trim } from '../lib/utils.mjs';
6
8
 
7
9
  const semver = semverRegex();
8
10
 
9
- export function Package({
11
+ function arrayLength(data) {
12
+ return Array.isArray(data) && data.length > 0;
13
+ }
14
+
15
+ export async function Package({
10
16
  cwd,
11
17
  pkg: {
12
18
  author,
@@ -21,7 +27,7 @@ export function Package({
21
27
  return [
22
28
  {
23
29
  format: trim,
24
- initial: dirname(cwd),
30
+ initial: parsePath(cwd).base,
25
31
  message: 'package.json » name',
26
32
  name: 'name',
27
33
  type: (first) => (first === false || name ? null : 'text'),
@@ -57,7 +63,7 @@ export function Package({
57
63
  ? null
58
64
  : 'text',
59
65
  format: parse,
60
- initial: getAuthor(author),
66
+ initial: await getAuthor(author),
61
67
  message: 'package.json » author',
62
68
  name: 'author',
63
69
  },
@@ -80,9 +86,9 @@ export function Package({
80
86
  format: (value) => (value ? ['packages/*', 'tools/*'] : undefined),
81
87
  type: (first, feedback) =>
82
88
  first === false ||
83
- (workspaces && workspaces.length > 0) ||
84
89
  isPrivate === false ||
85
- feedback.private === false
90
+ feedback.private === false ||
91
+ arrayLength(workspaces ? workspaces.packages : workspaces)
86
92
  ? null
87
93
  : 'toggle',
88
94
  },