@yaoxfly/cli 1.0.4 → 1.0.6
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 +104 -23
- package/bin/add.js +103 -0
- package/bin/create.js +24 -1
- package/bin/delete.js +79 -0
- package/bin/index.js +23 -2
- package/bin/list.js +48 -0
- package/bin/utils.js +18 -6
- package/package.json +2 -2
- package/template.json +7 -2
- package/version.json +1 -1
package/README.md
CHANGED
|
@@ -1,83 +1,164 @@
|
|
|
1
|
+
[English](README.md) | [中文](README-CN.md)
|
|
2
|
+
|
|
1
3
|
# @yaoxfly/cli
|
|
2
|
-
|
|
4
|
+
|
|
5
|
+
Clean and minimalist project scaffolding integrates`vue3` project templates,`vitepress ` project templates, etc., right out of the box.
|
|
6
|
+
|
|
7
|
+
> Compatibility note: The scaffolding uses `Vite` internally by default,`Vite` requires `Node.js` version ` 14.18+ `, `16+`. However, some templates rely on a higher version of `Node` to function properly, so be careful to upgrade your version of 'Node' when your package manager warns you. [node version switch](#node-version-switch)
|
|
3
8
|
|
|
4
9
|
|
|
5
|
-
#
|
|
10
|
+
# Use npx
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
No sense download template, no need to install `@yaoxfly/cli`.
|
|
8
13
|
|
|
9
14
|
```
|
|
10
|
-
npx @yaoxfly/cli@latest create [
|
|
15
|
+
npx @yaoxfly/cli@latest create [Project name]
|
|
11
16
|
|
|
12
17
|
```
|
|
13
18
|
|
|
14
|
-
>
|
|
19
|
+
> If the `npm` image downloads slowly, please switch other image such as `taobao` image, you can use `nrm` management, or other ways, [image switch](#image-switch).
|
|
15
20
|
|
|
16
|
-
# 下载
|
|
17
21
|
|
|
18
|
-
|
|
22
|
+
# Creation project
|
|
23
|
+
|
|
24
|
+
You can also download and then use, the current way can provide more comprehensive features, global download.
|
|
19
25
|
|
|
20
26
|
```
|
|
21
27
|
npm i @yaoxfly/cli -g
|
|
22
28
|
```
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
use
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
yx-cli create [Project name]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
# Add template
|
|
37
|
+
|
|
38
|
+
Add custom templates, such as your own `GitHub` or `Gitee` (code cloud) project address
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
yx-cli add
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
#### Format of the template address
|
|
45
|
+
|
|
46
|
+
You can use the following shorthand
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
GitHub - github:owner/name or owner/name
|
|
50
|
+
GitLab - gitlab:owner/name
|
|
51
|
+
Bitbucket - bitbucket:owner/name
|
|
52
|
+
```
|
|
53
|
+
> 1.The default is `master` branching, but you can specify branching and `tag`, such as `owner/name#my-branch`.
|
|
54
|
+
> 2.You can also specify a custom source, such as ` gitlab:custom.com: owner/name `. Custom source default is `https` or `git@`, you can customize the protocol.
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
#### Direct - direct:url
|
|
58
|
+
|
|
59
|
+
This method skips the above shorthand and passes the full `url`.
|
|
60
|
+
|
|
25
61
|
```
|
|
26
|
-
|
|
62
|
+
direct:https://gitlab.com/flippidippi/download-git-repo-fixture.git
|
|
27
63
|
```
|
|
28
|
-
<a id='mirrorSwitching'></a>
|
|
29
64
|
|
|
30
|
-
|
|
65
|
+
> Gitee(code cloud), private library address can be used in this way.
|
|
31
66
|
|
|
32
|
-
|
|
67
|
+
# Deleting a template
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
yx-cli delete
|
|
71
|
+
```
|
|
33
72
|
|
|
34
|
-
|
|
73
|
+
# Viewing the Template list
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
yx-cli list
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
# image switch
|
|
80
|
+
|
|
81
|
+
## Use nrm
|
|
82
|
+
|
|
83
|
+
Global download
|
|
35
84
|
|
|
36
85
|
```
|
|
37
86
|
npm i nrm@1.0.0 -g
|
|
38
87
|
```
|
|
39
|
-
|
|
88
|
+
>A lower version of `node` and a higher version of `nrm` may not be available.
|
|
40
89
|
|
|
41
|
-
|
|
90
|
+
Viewing the image list
|
|
42
91
|
|
|
43
92
|
```
|
|
44
93
|
nrm ls
|
|
45
94
|
```
|
|
46
95
|
|
|
47
|
-
|
|
96
|
+
Using Taobao image
|
|
97
|
+
|
|
48
98
|
```
|
|
49
99
|
nrm use taobao
|
|
50
100
|
```
|
|
51
101
|
|
|
52
|
-
##
|
|
102
|
+
## Use npm
|
|
53
103
|
|
|
54
|
-
|
|
104
|
+
Set Taobao image
|
|
55
105
|
|
|
56
106
|
```
|
|
57
107
|
npm config set registry https://registry.npmmirror.com/
|
|
58
108
|
```
|
|
59
109
|
|
|
60
|
-
|
|
110
|
+
> `registry.npm.taobao.org`, which was abandoned on May 31, 2022, needs to be replaced with a new `registry.npmmirror.com` source.
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
Check whether the configuration is successful
|
|
114
|
+
|
|
61
115
|
```
|
|
62
116
|
npm config get registry
|
|
63
117
|
```
|
|
64
118
|
|
|
65
|
-
|
|
119
|
+
View the current configuration of npm
|
|
66
120
|
```
|
|
67
121
|
npm config list
|
|
68
122
|
```
|
|
69
123
|
|
|
70
|
-
|
|
124
|
+
Set up an npm image
|
|
71
125
|
```
|
|
72
126
|
npm config set registry https://registry.npmjs.org/
|
|
73
127
|
```
|
|
74
128
|
|
|
75
|
-
##
|
|
76
|
-
|
|
129
|
+
## Use .npmrc
|
|
130
|
+
In the root directory, create `.npmrc` and write the following
|
|
77
131
|
|
|
78
132
|
```
|
|
79
133
|
registry= https://registry.npmmirror.com/
|
|
80
134
|
```
|
|
81
135
|
|
|
82
136
|
|
|
137
|
+
# node version switch
|
|
138
|
+
|
|
139
|
+
#### Use `nvm` to manage your `node` version
|
|
140
|
+
|
|
141
|
+
[nvm download address](https://github.com/coreybutler/nvm-windows/releases)
|
|
83
142
|
|
|
143
|
+
|
|
144
|
+
Download the `vmm-setup. zip` version and install it as prompted.
|
|
145
|
+
|
|
146
|
+
#### To download node
|
|
147
|
+
|
|
148
|
+
This describes only windows systems.
|
|
149
|
+
|
|
150
|
+
When node is installed using the `nvm` command line, `nvm` will not install `npm` when the `node` version is` 8`or higher.
|
|
151
|
+
|
|
152
|
+
Download the corresponding version `zip` file from the [nodejs download website](https://registry.npmmirror.com/binary.html?path=node) and decompress it to the root directory of the `nvm` installation directory. Change the name of the decompressed folder to `v version number`
|
|
153
|
+
For example, the folder name after decompression is changed from `node-v16.13.1-win-x64` to `v16.13.1`.
|
|
154
|
+
|
|
155
|
+
View the downloaded version of `node`
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
nvm list
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Use the corresponding version
|
|
162
|
+
```
|
|
163
|
+
nvm use [Version number]
|
|
164
|
+
```
|
package/bin/add.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
27
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
28
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
29
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
30
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
31
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
32
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.add = void 0;
|
|
40
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
41
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
42
|
+
const fs_1 = __importDefault(require("fs"));
|
|
43
|
+
const log_symbols_1 = __importDefault(require("log-symbols"));
|
|
44
|
+
const utils_1 = require("./utils");
|
|
45
|
+
const add = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
const template = Promise.resolve().then(() => __importStar(require((0, utils_1.resolve)('../template'))));
|
|
47
|
+
let templateObj = yield template;
|
|
48
|
+
templateObj = templateObj.default;
|
|
49
|
+
const question = [
|
|
50
|
+
{
|
|
51
|
+
name: "name",
|
|
52
|
+
type: 'input',
|
|
53
|
+
message: "请输入模板名称",
|
|
54
|
+
validate: (val) => {
|
|
55
|
+
if (val === '') {
|
|
56
|
+
return 'Name is required!';
|
|
57
|
+
}
|
|
58
|
+
else if (templateObj[val]) {
|
|
59
|
+
return 'Template has already existed!';
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "url",
|
|
68
|
+
type: 'input',
|
|
69
|
+
message: "请输入模板地址",
|
|
70
|
+
validate: (val) => {
|
|
71
|
+
if (val === '')
|
|
72
|
+
return 'The url is required!';
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "description",
|
|
78
|
+
type: 'input',
|
|
79
|
+
message: "请输入模板描述",
|
|
80
|
+
validate: (val) => {
|
|
81
|
+
if (val.length >= '70')
|
|
82
|
+
return 'The description is more than 70 characters!';
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
];
|
|
87
|
+
const answers = yield inquirer_1.default.prompt(question);
|
|
88
|
+
const { name, url, description } = answers || {};
|
|
89
|
+
templateObj[name] = {
|
|
90
|
+
url,
|
|
91
|
+
description
|
|
92
|
+
};
|
|
93
|
+
fs_1.default.writeFile((0, utils_1.resolve)('../template.json'), JSON.stringify(templateObj, null, 2), 'utf-8', err => {
|
|
94
|
+
if (err)
|
|
95
|
+
console.log(err);
|
|
96
|
+
console.log('\n');
|
|
97
|
+
console.log(log_symbols_1.default.success, chalk_1.default.green('Added successfully!\n'));
|
|
98
|
+
console.log(chalk_1.default.grey('The latest template list is: \n'));
|
|
99
|
+
console.log(templateObj);
|
|
100
|
+
console.log('\n');
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
exports.add = add;
|
package/bin/create.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
"use strict";
|
|
2
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
4
|
if (k2 === undefined) k2 = k;
|
|
@@ -44,6 +45,7 @@ const download_git_repo_1 = __importDefault(require("download-git-repo"));
|
|
|
44
45
|
const log_symbols_1 = __importDefault(require("log-symbols"));
|
|
45
46
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
46
47
|
const utils_1 = require("./utils");
|
|
48
|
+
const child_process_1 = require("child_process");
|
|
47
49
|
const tips = (param) => {
|
|
48
50
|
const { install, installMode = 'pnpm', projectName } = param || {};
|
|
49
51
|
console.log(log_symbols_1.default.success, chalk_1.default.green('The project is initialized'));
|
|
@@ -52,7 +54,28 @@ const tips = (param) => {
|
|
|
52
54
|
!install && console.log(`\n ${installMode} install`);
|
|
53
55
|
console.log(`\n ${installMode === 'yarn' ? 'yarn dev' : `${installMode} run dev`} `);
|
|
54
56
|
};
|
|
57
|
+
const has = (0, utils_1.hasPackage)();
|
|
58
|
+
const iMode = () => {
|
|
59
|
+
if (has('pnpm'))
|
|
60
|
+
return 'pnpm';
|
|
61
|
+
if (has('yarn'))
|
|
62
|
+
return 'yarn';
|
|
63
|
+
return 'npm';
|
|
64
|
+
};
|
|
55
65
|
const create = (projectName, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
+
if (!has('git')) {
|
|
67
|
+
console.log(chalk_1.default.red("Error, Git is not exsits ,please install git!"));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (has('node')) {
|
|
71
|
+
let nodeVersion = (0, child_process_1.execSync)(`node --version`).toString();
|
|
72
|
+
nodeVersion = nodeVersion.substring(1, nodeVersion.length);
|
|
73
|
+
nodeVersion = parseInt(nodeVersion.split('.').join('').substring(0, 4));
|
|
74
|
+
if (nodeVersion < 1418) {
|
|
75
|
+
console.log(chalk_1.default.red("Error, node version must be at least v14.18.0!"));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
56
79
|
const { force } = options || {};
|
|
57
80
|
if (!force && fs_1.default.existsSync(projectName)) {
|
|
58
81
|
console.log(chalk_1.default.red("Error, In this directory, the project name already exsits !"));
|
|
@@ -92,7 +115,7 @@ const create = (projectName, options) => __awaiter(void 0, void 0, void 0, funct
|
|
|
92
115
|
type: 'list',
|
|
93
116
|
message: '请选择一个安装方式',
|
|
94
117
|
name: 'installMode',
|
|
95
|
-
default:
|
|
118
|
+
default: iMode(),
|
|
96
119
|
choices: ['pnpm', 'npm', 'yarn'],
|
|
97
120
|
when: (answers) => {
|
|
98
121
|
const { install } = answers;
|
package/bin/delete.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
27
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
28
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
29
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
30
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
31
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
32
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.del = void 0;
|
|
40
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
41
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
42
|
+
const fs_1 = __importDefault(require("fs"));
|
|
43
|
+
const log_symbols_1 = __importDefault(require("log-symbols"));
|
|
44
|
+
const utils_1 = require("./utils");
|
|
45
|
+
const del = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
const template = Promise.resolve().then(() => __importStar(require((0, utils_1.resolve)('../template'))));
|
|
47
|
+
let templateObj = yield template;
|
|
48
|
+
templateObj = templateObj.default;
|
|
49
|
+
const question = [
|
|
50
|
+
{
|
|
51
|
+
name: "name",
|
|
52
|
+
message: "请输入要删除的模板名称",
|
|
53
|
+
validate(val) {
|
|
54
|
+
if (val === '') {
|
|
55
|
+
return 'Name is required!';
|
|
56
|
+
}
|
|
57
|
+
else if (!templateObj[val]) {
|
|
58
|
+
return 'Template does not exist!';
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
];
|
|
66
|
+
const answers = yield inquirer_1.default.prompt(question);
|
|
67
|
+
const { name } = answers || {};
|
|
68
|
+
delete templateObj[name];
|
|
69
|
+
fs_1.default.writeFile((0, utils_1.resolve)('../template.json'), JSON.stringify(templateObj, null, 2), 'utf-8', err => {
|
|
70
|
+
if (err)
|
|
71
|
+
console.log(err);
|
|
72
|
+
console.log('\n');
|
|
73
|
+
console.log(log_symbols_1.default.success, chalk_1.default.green('Deleted successfully!\n'));
|
|
74
|
+
console.log(chalk_1.default.grey('The latest template list is: \n'));
|
|
75
|
+
console.log(templateObj);
|
|
76
|
+
console.log('\n');
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
exports.del = del;
|
package/bin/index.js
CHANGED
|
@@ -7,17 +7,38 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
const commander_1 = require("commander");
|
|
8
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
9
|
const create_1 = require("./create");
|
|
10
|
+
const add_1 = require("./add");
|
|
11
|
+
const list_1 = require("./list");
|
|
12
|
+
const delete_1 = require("./delete");
|
|
10
13
|
const program = new commander_1.Command();
|
|
11
14
|
program
|
|
12
15
|
.version(require('../version').version)
|
|
13
16
|
.name('yx-cli');
|
|
14
17
|
program
|
|
15
18
|
.command('create <project-name>')
|
|
16
|
-
.description('
|
|
17
|
-
.option('-f --force', '
|
|
19
|
+
.description('Create a new project')
|
|
20
|
+
.option('-f --force', 'If it exist, overwrite directory')
|
|
18
21
|
.action((projectName, options) => {
|
|
19
22
|
(0, create_1.create)(projectName, options);
|
|
20
23
|
});
|
|
24
|
+
program
|
|
25
|
+
.command('add')
|
|
26
|
+
.description('Add a new template')
|
|
27
|
+
.action(() => {
|
|
28
|
+
(0, add_1.add)();
|
|
29
|
+
});
|
|
30
|
+
program
|
|
31
|
+
.command('list')
|
|
32
|
+
.description('List all the template')
|
|
33
|
+
.action(() => {
|
|
34
|
+
(0, list_1.list)();
|
|
35
|
+
});
|
|
36
|
+
program
|
|
37
|
+
.command('delete')
|
|
38
|
+
.description('Delete a template')
|
|
39
|
+
.action(() => {
|
|
40
|
+
(0, delete_1.del)();
|
|
41
|
+
});
|
|
21
42
|
program.on('--help', () => {
|
|
22
43
|
console.log(`\r\n Run ${chalk_1.default.green(`yx-cli <command> --help`)} to understand the details\r\n `);
|
|
23
44
|
});
|
package/bin/list.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
27
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
28
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
29
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
30
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
31
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
32
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.list = void 0;
|
|
40
|
+
const utils_1 = require("./utils");
|
|
41
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
42
|
+
const list = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
const template = Promise.resolve().then(() => __importStar(require((0, utils_1.resolve)('../template'))));
|
|
44
|
+
const templateObj = yield template;
|
|
45
|
+
console.log(chalk_1.default.grey('The template list is: \n'));
|
|
46
|
+
console.log(templateObj.default);
|
|
47
|
+
});
|
|
48
|
+
exports.list = list;
|
package/bin/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.resolve = exports.shellExec = exports.readFile = void 0;
|
|
6
|
+
exports.hasPackage = exports.resolve = exports.shellExec = exports.readFile = void 0;
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const ora_1 = __importDefault(require("ora"));
|
|
9
9
|
const child_process_1 = require("child_process");
|
|
@@ -16,21 +16,33 @@ exports.readFile = readFile;
|
|
|
16
16
|
const shellExec = (config) => {
|
|
17
17
|
const { directive, cwd, loading, log } = config || {};
|
|
18
18
|
return new Promise((resolve, reject) => {
|
|
19
|
-
console.log(`\n ${log} \n`);
|
|
19
|
+
log && console.log(`\n ${log} \n`);
|
|
20
20
|
const spinner = (0, ora_1.default)(loading);
|
|
21
|
-
spinner.start();
|
|
21
|
+
loading && spinner.start();
|
|
22
22
|
(0, child_process_1.exec)(directive, { cwd }, (error, stdout) => {
|
|
23
23
|
if (error) {
|
|
24
|
-
spinner.fail();
|
|
25
|
-
console.error(error);
|
|
24
|
+
loading && spinner.fail();
|
|
26
25
|
reject(error);
|
|
27
26
|
return;
|
|
28
27
|
}
|
|
29
28
|
resolve(stdout);
|
|
30
|
-
spinner.succeed();
|
|
29
|
+
loading && spinner.succeed();
|
|
31
30
|
});
|
|
32
31
|
});
|
|
33
32
|
};
|
|
34
33
|
exports.shellExec = shellExec;
|
|
35
34
|
const resolve = (...file) => path_1.default.resolve(__dirname, ...file);
|
|
36
35
|
exports.resolve = resolve;
|
|
36
|
+
const hasPackage = () => {
|
|
37
|
+
const fn = (tool) => {
|
|
38
|
+
try {
|
|
39
|
+
(0, child_process_1.execSync)(`${tool} --version`, { stdio: 'ignore' });
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return fn;
|
|
47
|
+
};
|
|
48
|
+
exports.hasPackage = hasPackage;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yaoxfly/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "脚手架工具,开箱即用",
|
|
5
5
|
"main": "bin",
|
|
6
6
|
"private": false,
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@typescript-eslint/eslint-plugin": "^5.40.0",
|
|
41
41
|
"@typescript-eslint/parser": "^5.40.0",
|
|
42
42
|
"eslint": "^8.25.0",
|
|
43
|
-
"typescript": "
|
|
43
|
+
"typescript": "4.8.4"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"chalk": "4.1.2",
|
package/template.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"vue3-simple-frame": {
|
|
3
3
|
"url": "yaoxfly/vue3-simple-frame",
|
|
4
|
-
"description": "[vue3.
|
|
4
|
+
"description": "[vue3.x]、typeScript 、vite3、pinia、eslint、axios、mock、multiple environments"
|
|
5
5
|
},
|
|
6
6
|
"vitepress-template": {
|
|
7
7
|
"url": "yaoxfly/vitepress-template",
|
|
8
|
-
"description": "[vitepress]、typeScript、vue3
|
|
8
|
+
"description": "[vitepress]、typeScript、vue3、Custom Theme"
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
"monorope-component": {
|
|
12
|
+
"url": "yaoxfly/monorope-component",
|
|
13
|
+
"description": "[monorope]、typeScript、vue3、vite、pnpm"
|
|
9
14
|
}
|
|
10
15
|
}
|
package/version.json
CHANGED