cmyr-template-cli 1.10.2 → 1.10.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 +27 -0
- package/package.json +2 -1
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.10.
|
|
16
|
+
program.version("1.10.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
|
@@ -11,6 +11,7 @@ var child_process = require('child_process');
|
|
|
11
11
|
var colors = require('colors');
|
|
12
12
|
var ejs = require('ejs');
|
|
13
13
|
var core = require('@lint-md/core');
|
|
14
|
+
var JSON5 = require('json5');
|
|
14
15
|
|
|
15
16
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
17
|
|
|
@@ -39,6 +40,7 @@ var download__default = /*#__PURE__*/_interopDefaultLegacy(download);
|
|
|
39
40
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
40
41
|
var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
|
|
41
42
|
var ejs__default = /*#__PURE__*/_interopDefaultLegacy(ejs);
|
|
43
|
+
var JSON5__default = /*#__PURE__*/_interopDefaultLegacy(JSON5);
|
|
42
44
|
|
|
43
45
|
process.env;
|
|
44
46
|
const PACKAGE_MANAGER = 'pnpm';
|
|
@@ -159,6 +161,7 @@ async function init(projectPath, answers) {
|
|
|
159
161
|
await sortProjectJson(projectPath);
|
|
160
162
|
await initDependabot(projectPath, answers);
|
|
161
163
|
await initYarn(projectPath, answers);
|
|
164
|
+
await initTsconfig(projectPath);
|
|
162
165
|
await asyncExec('git add .', {
|
|
163
166
|
cwd: projectPath,
|
|
164
167
|
});
|
|
@@ -228,6 +231,30 @@ async function initYarn(projectPath, answers) {
|
|
|
228
231
|
console.error(error);
|
|
229
232
|
}
|
|
230
233
|
}
|
|
234
|
+
async function initTsconfig(projectPath) {
|
|
235
|
+
var _a;
|
|
236
|
+
try {
|
|
237
|
+
const tsconfigPath = path__default["default"].join(projectPath, 'tsconfig.json');
|
|
238
|
+
if (await fs__default["default"].pathExists(tsconfigPath)) {
|
|
239
|
+
const tsconfigStr = await fs__default["default"].readFile(tsconfigPath, 'utf8');
|
|
240
|
+
const tsconfig = JSON5__default["default"].parse(tsconfigStr);
|
|
241
|
+
if ((_a = tsconfig === null || tsconfig === void 0 ? void 0 : tsconfig.compilerOptions) === null || _a === void 0 ? void 0 : _a.importHelpers) {
|
|
242
|
+
const pkg = await getProjectJson(projectPath);
|
|
243
|
+
const pkgData = {
|
|
244
|
+
dependencies: {
|
|
245
|
+
...pkg.dependencies,
|
|
246
|
+
tslib: `^${await getNpmPackageVersion('tslib')}`,
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
const newPkg = Object.assign({}, pkg, pkgData);
|
|
250
|
+
await saveProjectJson(projectPath, newPkg);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
catch (error) {
|
|
255
|
+
console.error(error);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
231
258
|
async function initProjectJson(projectPath, answers) {
|
|
232
259
|
const loading = ora__default["default"]('正在初始化 package.json ……').start();
|
|
233
260
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cmyr-template-cli",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.3",
|
|
4
4
|
"description": "草梅友仁自制的项目模板创建器",
|
|
5
5
|
"author": "CaoMeiYouRen",
|
|
6
6
|
"license": "MIT",
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"download-git-repo": "^3.0.2",
|
|
77
77
|
"ejs": "^3.1.6",
|
|
78
78
|
"fs-extra": "^10.0.0",
|
|
79
|
+
"json5": "^2.2.1",
|
|
79
80
|
"lodash": "^4.17.20",
|
|
80
81
|
"minimist": "^1.2.5",
|
|
81
82
|
"ora": "^5.4.1",
|