@nice-move/init 0.3.13 → 0.5.2
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/dist/cli.mjs +2 -0
- package/package.json +15 -12
- package/action/editorconfig.mjs +0 -11
- package/action/git-file.mjs +0 -91
- package/action/license.mjs +0 -31
- package/action/package.mjs +0 -35
- package/action/readme.mjs +0 -22
- package/action/registry.mjs +0 -29
- package/bin/index.mjs +0 -13
- package/index.mjs +0 -41
- package/lib/color.mjs +0 -3
- package/lib/latest.mjs +0 -24
- package/lib/utils.mjs +0 -67
- package/prompt/dependencies.mjs +0 -235
- package/prompt/git-init.mjs +0 -35
- package/prompt/index.mjs +0 -73
- package/prompt/install.mjs +0 -22
- package/prompt/package.mjs +0 -98
- package/template/.editorconfig.tpl +0 -13
- package/template/.gitattributes.tpl +0 -3
- package/template/mit.tpl +0 -21
- package/template/unlicense.tpl +0 -24
package/prompt/git-init.mjs
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { execa } from 'execa';
|
|
2
|
-
|
|
3
|
-
import { green, red } from '../lib/color.mjs';
|
|
4
|
-
|
|
5
|
-
const message = 'Initialize as git repository';
|
|
6
|
-
|
|
7
|
-
function init() {
|
|
8
|
-
return execa('git', ['init']).then(
|
|
9
|
-
(io) => {
|
|
10
|
-
console.log(green('√'), message);
|
|
11
|
-
|
|
12
|
-
return io;
|
|
13
|
-
},
|
|
14
|
-
(error) => {
|
|
15
|
-
console.log(red('×'), message);
|
|
16
|
-
throw error;
|
|
17
|
-
},
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function GitInit({ gitSupported, isGit }) {
|
|
22
|
-
return {
|
|
23
|
-
message,
|
|
24
|
-
name: 'GitInit',
|
|
25
|
-
initial: true,
|
|
26
|
-
type: (first) =>
|
|
27
|
-
first === false || !gitSupported || isGit ? null : 'confirm',
|
|
28
|
-
// eslint-disable-next-line consistent-return
|
|
29
|
-
format(value) {
|
|
30
|
-
if (value === true) {
|
|
31
|
-
return init;
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
}
|
package/prompt/index.mjs
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import isGitDirty from 'is-git-dirty';
|
|
2
|
-
import isGitRepo from 'is-git-repository';
|
|
3
|
-
import prompts from 'prompts';
|
|
4
|
-
import { getPkg } from 'settingz';
|
|
5
|
-
|
|
6
|
-
import { emptyDir, gitSupport } from '../lib/utils.mjs';
|
|
7
|
-
|
|
8
|
-
import { Dependencies } from './dependencies.mjs';
|
|
9
|
-
import { GitInit } from './git-init.mjs';
|
|
10
|
-
import { Install } from './install.mjs';
|
|
11
|
-
import { Package } from './package.mjs';
|
|
12
|
-
|
|
13
|
-
export async function Prompt() {
|
|
14
|
-
const gitSupported = await gitSupport();
|
|
15
|
-
const isGit = gitSupported && isGitRepo();
|
|
16
|
-
const isDirty = isGit ? isGitDirty() : false;
|
|
17
|
-
const isEmpty = emptyDir();
|
|
18
|
-
const pkg = getPkg();
|
|
19
|
-
const cwd = process.cwd();
|
|
20
|
-
|
|
21
|
-
const options = {
|
|
22
|
-
gitSupported,
|
|
23
|
-
isGit,
|
|
24
|
-
isDirty,
|
|
25
|
-
isEmpty,
|
|
26
|
-
pkg,
|
|
27
|
-
cwd,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const PackagePrompts = await Package(options);
|
|
31
|
-
|
|
32
|
-
return prompts(
|
|
33
|
-
[
|
|
34
|
-
{
|
|
35
|
-
active: 'do it',
|
|
36
|
-
inactive: 'cancel',
|
|
37
|
-
message:
|
|
38
|
-
isDirty === true ? 'Repository not clean' : 'Workspace not empty',
|
|
39
|
-
name: 'okay',
|
|
40
|
-
type: () => (isEmpty || isDirty === false ? null : 'toggle'),
|
|
41
|
-
},
|
|
42
|
-
GitInit(options),
|
|
43
|
-
...PackagePrompts,
|
|
44
|
-
Dependencies(options),
|
|
45
|
-
Install(options),
|
|
46
|
-
],
|
|
47
|
-
{
|
|
48
|
-
onCancel() {
|
|
49
|
-
throw new Error('cancel');
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
)
|
|
53
|
-
.then(({ okay, ...rest }) => {
|
|
54
|
-
if (okay === false) {
|
|
55
|
-
throw new Error('cancel');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return Object.entries(rest);
|
|
59
|
-
})
|
|
60
|
-
.then((sets) => {
|
|
61
|
-
const names = PackagePrompts.map(({ name }) => name);
|
|
62
|
-
|
|
63
|
-
const info = Object.fromEntries(
|
|
64
|
-
sets.filter(([key]) => names.includes(key)),
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
const rest = Object.fromEntries(
|
|
68
|
-
sets.filter(([key]) => !names.includes(key)),
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
return { ...rest, info, options };
|
|
72
|
-
});
|
|
73
|
-
}
|
package/prompt/install.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import install from 'yarn-install';
|
|
2
|
-
|
|
3
|
-
import { cyan } from '../lib/color.mjs';
|
|
4
|
-
|
|
5
|
-
const message = `Run ${cyan('npm')} / ${cyan('yarn')} install command`;
|
|
6
|
-
|
|
7
|
-
export function Install() {
|
|
8
|
-
return {
|
|
9
|
-
message,
|
|
10
|
-
name: 'Install',
|
|
11
|
-
type: (first) => (first === false ? null : 'confirm'),
|
|
12
|
-
// eslint-disable-next-line consistent-return
|
|
13
|
-
format(value) {
|
|
14
|
-
if (value === true) {
|
|
15
|
-
return () => {
|
|
16
|
-
console.log('-'.repeat(32));
|
|
17
|
-
install();
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
}
|
package/prompt/package.mjs
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { parse as parsePath } from 'path';
|
|
2
|
-
|
|
3
|
-
import parse from 'parse-author';
|
|
4
|
-
import semverRegex from 'semver-regex';
|
|
5
|
-
import validate from 'validate-npm-package-name';
|
|
6
|
-
|
|
7
|
-
import { getAuthor, trim } from '../lib/utils.mjs';
|
|
8
|
-
|
|
9
|
-
const semver = semverRegex();
|
|
10
|
-
|
|
11
|
-
function arrayLength(data) {
|
|
12
|
-
return Array.isArray(data) && data.length > 0;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export async function Package({
|
|
16
|
-
cwd,
|
|
17
|
-
pkg: {
|
|
18
|
-
author,
|
|
19
|
-
description,
|
|
20
|
-
license,
|
|
21
|
-
name,
|
|
22
|
-
private: isPrivate,
|
|
23
|
-
version,
|
|
24
|
-
workspaces,
|
|
25
|
-
} = {},
|
|
26
|
-
}) {
|
|
27
|
-
return [
|
|
28
|
-
{
|
|
29
|
-
format: trim,
|
|
30
|
-
initial: parsePath(cwd).base,
|
|
31
|
-
message: 'package.json » name',
|
|
32
|
-
name: 'name',
|
|
33
|
-
type: (first) => (first === false || name ? null : 'text'),
|
|
34
|
-
validate: (value) => validate(trim(value) || '').validForNewPackages,
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
format: trim,
|
|
38
|
-
initial: '0.0.0',
|
|
39
|
-
message: 'package.json » version',
|
|
40
|
-
name: 'version',
|
|
41
|
-
type: (first) => (first === false || version ? null : 'text'),
|
|
42
|
-
validate: (value) => semver.test(trim(value) || ''),
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
format: trim,
|
|
46
|
-
message: 'package.json » description',
|
|
47
|
-
name: 'description',
|
|
48
|
-
type: (first) => (first === false || description ? null : 'text'),
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
active: 'MIT',
|
|
52
|
-
format: (value) => (value ? 'MIT' : 'UNLICENSED'),
|
|
53
|
-
inactive: 'UNLICENSED',
|
|
54
|
-
initial: true,
|
|
55
|
-
message: 'package.json » license',
|
|
56
|
-
name: 'license',
|
|
57
|
-
type: (first) => (first === false || license ? null : 'toggle'),
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
type: (first) =>
|
|
61
|
-
first === false ||
|
|
62
|
-
(typeof author === 'string' ? author : author && author.name)
|
|
63
|
-
? null
|
|
64
|
-
: 'text',
|
|
65
|
-
format: parse,
|
|
66
|
-
initial: await getAuthor(author),
|
|
67
|
-
message: 'package.json » author',
|
|
68
|
-
name: 'author',
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
active: 'true',
|
|
72
|
-
inactive: 'false',
|
|
73
|
-
initial: false,
|
|
74
|
-
message: 'package.json » private',
|
|
75
|
-
name: 'private',
|
|
76
|
-
format: (value) => (value === false ? undefined : value),
|
|
77
|
-
type: (first) =>
|
|
78
|
-
first === false || isPrivate !== undefined ? null : 'toggle',
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
active: 'recommend',
|
|
82
|
-
inactive: 'false',
|
|
83
|
-
initial: false,
|
|
84
|
-
message: 'package.json » workspaces',
|
|
85
|
-
name: 'workspaces',
|
|
86
|
-
format: (value) => (value ? ['packages/*', 'tools/*'] : undefined),
|
|
87
|
-
type: (first, feedback) =>
|
|
88
|
-
first === false ||
|
|
89
|
-
isPrivate === false ||
|
|
90
|
-
feedback.private === false ||
|
|
91
|
-
arrayLength(
|
|
92
|
-
workspaces && workspaces.packages ? workspaces.packages : workspaces,
|
|
93
|
-
)
|
|
94
|
-
? null
|
|
95
|
-
: 'toggle',
|
|
96
|
-
},
|
|
97
|
-
];
|
|
98
|
-
}
|
package/template/mit.tpl
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) {{year}} {{holder}}
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/template/unlicense.tpl
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
This is free and unencumbered software released into the public domain.
|
|
2
|
-
|
|
3
|
-
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
-
distribute this software, either in source code form or as a compiled
|
|
5
|
-
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
-
means.
|
|
7
|
-
|
|
8
|
-
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
-
of this software dedicate any and all copyright interest in the
|
|
10
|
-
software to the public domain. We make this dedication for the benefit
|
|
11
|
-
of the public at large and to the detriment of our heirs and
|
|
12
|
-
successors. We intend this dedication to be an overt act of
|
|
13
|
-
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
-
software under copyright law.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
-
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
-
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
-
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
-
|
|
24
|
-
For more information, please refer to <https://unlicense.org/>
|