cmyr-template-cli 1.14.1 → 1.14.3
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/index.js +1 -1
- package/dist/plopfile.js +51 -36
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
|
13
13
|
|
|
14
14
|
const program = new commander.Command('ct')
|
|
15
15
|
.description('草梅项目创建器');
|
|
16
|
-
program.version("1.14.
|
|
16
|
+
program.version("1.14.2" , '-v, --version');
|
|
17
17
|
const args = process.argv.slice(2);
|
|
18
18
|
if (args.length === 0) {
|
|
19
19
|
args.push('create');
|
package/dist/plopfile.js
CHANGED
|
@@ -57,10 +57,21 @@ const NODEJS_URLS = [
|
|
|
57
57
|
'https://nodejs.org/zh-cn/download/',
|
|
58
58
|
'http://nodejs.cn/download/',
|
|
59
59
|
];
|
|
60
|
+
const NODE_INDEX_URL = 'https://cdn.npmmirror.com/binaries/node/index.json';
|
|
60
61
|
const REMOTES = [
|
|
61
62
|
'https://github.com',
|
|
62
63
|
'https://hub.fastgit.xyz',
|
|
63
64
|
'https://download.fastgit.org',
|
|
65
|
+
'https://ghproxy.com/https://github.com',
|
|
66
|
+
'https://gh.ddlc.top/https://github.com',
|
|
67
|
+
'https://gh.flyinbug.top/gh/https://github.com',
|
|
68
|
+
'https://gh.con.sh/https://github.com',
|
|
69
|
+
'https://cors.isteed.cc/github.com',
|
|
70
|
+
'https://ghps.cc/https://github.com',
|
|
71
|
+
'https://download.nuaa.cf',
|
|
72
|
+
'https://kgithub.com',
|
|
73
|
+
'https://github.moeyy.xyz/https://github.com',
|
|
74
|
+
'https://hub.njuu.cf',
|
|
64
75
|
];
|
|
65
76
|
async function createGiteeRepo(data) {
|
|
66
77
|
try {
|
|
@@ -138,16 +149,9 @@ async function getFastGitRepo(repository) {
|
|
|
138
149
|
const loading = ora__default["default"](`正在选择镜像源 - ${repository}`);
|
|
139
150
|
loading.start();
|
|
140
151
|
try {
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
url,
|
|
145
|
-
method: 'HEAD',
|
|
146
|
-
timeout: 15 * 1000,
|
|
147
|
-
});
|
|
148
|
-
}));
|
|
149
|
-
loading.succeed(`成功选择了镜像源 - ${fast.config.url}`);
|
|
150
|
-
return `direct:${fast.config.url}`;
|
|
152
|
+
const fastUrl = await getFastUrl(REMOTES.map((remote) => `${remote}/${repository}/archive/refs/heads/master.zip`));
|
|
153
|
+
loading.succeed(`成功选择了镜像源 - ${fastUrl}`);
|
|
154
|
+
return `direct:${fastUrl}`;
|
|
151
155
|
}
|
|
152
156
|
catch (error) {
|
|
153
157
|
console.error(error);
|
|
@@ -773,40 +777,51 @@ async function getAuthorWebsiteFromGithubAPI(githubUsername) {
|
|
|
773
777
|
return '';
|
|
774
778
|
}
|
|
775
779
|
}
|
|
776
|
-
async function
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
loading.succeed(`成功选择了 Node.js 网址 - ${fast.config.url}`);
|
|
786
|
-
return fast.config.url;
|
|
787
|
-
}
|
|
788
|
-
catch (error) {
|
|
789
|
-
console.error(error);
|
|
790
|
-
loading.fail('选择 Node.js 网址失败!');
|
|
791
|
-
}
|
|
780
|
+
async function getLtsNodeVersionByIndexJson() {
|
|
781
|
+
var _a, _b, _c;
|
|
782
|
+
const resp = await axios__default["default"].get(NODE_INDEX_URL);
|
|
783
|
+
return (_c = (_b = (_a = resp.data) === null || _a === void 0 ? void 0 : _a.find((e) => e.lts)) === null || _b === void 0 ? void 0 : _b.version) === null || _c === void 0 ? void 0 : _c.replace('v', '');
|
|
784
|
+
}
|
|
785
|
+
async function getLtsNodeVersionByHtml(url) {
|
|
786
|
+
var _a, _b;
|
|
787
|
+
const html = (await axios__default["default"].get(url)).data;
|
|
788
|
+
return (_b = (_a = html.match(/<strong>(.*)<\/strong>/)) === null || _a === void 0 ? void 0 : _a[1]) === null || _b === void 0 ? void 0 : _b.trim();
|
|
792
789
|
}
|
|
793
790
|
async function getLtsNodeVersion() {
|
|
794
|
-
var _a
|
|
791
|
+
var _a;
|
|
792
|
+
const loading = ora__default["default"]('正在获取 Node.js lts 版本号');
|
|
793
|
+
loading.start();
|
|
795
794
|
try {
|
|
796
|
-
const
|
|
797
|
-
|
|
798
|
-
|
|
795
|
+
const fastUrl = await getFastUrl([...NODEJS_URLS, NODE_INDEX_URL]);
|
|
796
|
+
loading.succeed(`成功选择了 Node.js 网址 - ${fastUrl}`);
|
|
797
|
+
let version = '';
|
|
798
|
+
if (fastUrl === NODE_INDEX_URL) {
|
|
799
|
+
version = await getLtsNodeVersionByIndexJson();
|
|
799
800
|
}
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
801
|
+
else {
|
|
802
|
+
version = await getLtsNodeVersionByHtml(fastUrl);
|
|
803
|
+
}
|
|
804
|
+
console.log(`获取 Node.js lts 版本号成功,版本号为 ${version}`);
|
|
805
|
+
return (_a = version === null || version === void 0 ? void 0 : version.split('.')) === null || _a === void 0 ? void 0 : _a[0];
|
|
804
806
|
}
|
|
805
807
|
catch (error) {
|
|
806
808
|
console.error(error);
|
|
809
|
+
loading.fail('获取 Node.js lts 版本号失败');
|
|
807
810
|
return '';
|
|
808
811
|
}
|
|
809
812
|
}
|
|
813
|
+
async function getFastUrl(urls) {
|
|
814
|
+
var _a;
|
|
815
|
+
const fast = await Promise.any(urls.map((url) => axios__default["default"]({
|
|
816
|
+
url,
|
|
817
|
+
method: 'HEAD',
|
|
818
|
+
timeout: 15 * 1000,
|
|
819
|
+
headers: {
|
|
820
|
+
'Accept-Encoding': '',
|
|
821
|
+
},
|
|
822
|
+
})));
|
|
823
|
+
return (_a = fast === null || fast === void 0 ? void 0 : fast.config) === null || _a === void 0 ? void 0 : _a.url;
|
|
824
|
+
}
|
|
810
825
|
async function getNpmPackageVersion(name) {
|
|
811
826
|
const version = (await asyncExec(`${PACKAGE_MANAGER} view ${name} version`)) || '';
|
|
812
827
|
return version.trim();
|
|
@@ -867,12 +882,12 @@ async function removeFiles(projectPath, files) {
|
|
|
867
882
|
const newPath = path__default["default"].join(projectPath, file);
|
|
868
883
|
if (await fs__default["default"].pathExists(newPath)) {
|
|
869
884
|
await fs__default["default"].remove(newPath);
|
|
870
|
-
loading.succeed(`文件 ${file} 删除成功!`);
|
|
871
885
|
}
|
|
872
886
|
else {
|
|
873
|
-
|
|
887
|
+
console.log(`文件 ${file} 不存在,已跳过删除`);
|
|
874
888
|
}
|
|
875
889
|
}
|
|
890
|
+
loading.succeed(`文件 ${files.join()} 删除成功!`);
|
|
876
891
|
return true;
|
|
877
892
|
}
|
|
878
893
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cmyr-template-cli",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.3",
|
|
4
4
|
"description": "草梅友仁自制的项目模板创建器",
|
|
5
5
|
"author": "CaoMeiYouRen",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"build:prod": "npm run build && rimraf temp && cross-env NODE_ENV=production ct create"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@rollup/plugin-commonjs": "^
|
|
36
|
-
"@rollup/plugin-json": "^
|
|
37
|
-
"@rollup/plugin-node-resolve": "^
|
|
38
|
-
"@rollup/plugin-replace": "^
|
|
39
|
-
"@rollup/plugin-typescript": "^
|
|
35
|
+
"@rollup/plugin-commonjs": "^23.0.0",
|
|
36
|
+
"@rollup/plugin-json": "^5.0.0",
|
|
37
|
+
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
38
|
+
"@rollup/plugin-replace": "^5.0.0",
|
|
39
|
+
"@rollup/plugin-typescript": "^9.0.1",
|
|
40
40
|
"@semantic-release/changelog": "^6.0.0",
|
|
41
41
|
"@semantic-release/git": "^10.0.0",
|
|
42
42
|
"@types/debug": "^4.1.5",
|