@giteeteam/apps-cli 0.2.11 → 0.2.12
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 +54 -29
- package/package.json +4 -5
package/dist/index.js
CHANGED
|
@@ -10,7 +10,6 @@ var archiver = require('archiver');
|
|
|
10
10
|
var ora = require('ora');
|
|
11
11
|
var yaml = require('yaml');
|
|
12
12
|
var inquirer = require('inquirer');
|
|
13
|
-
var uuid = require('uuid');
|
|
14
13
|
var simpleGit = require('simple-git');
|
|
15
14
|
var chalk = require('chalk');
|
|
16
15
|
var readline = require('readline');
|
|
@@ -31,7 +30,7 @@ var execa__default = /*#__PURE__*/_interopDefaultLegacy(execa);
|
|
|
31
30
|
var child_process__default = /*#__PURE__*/_interopDefaultLegacy(child_process);
|
|
32
31
|
var chokidar__default = /*#__PURE__*/_interopDefaultLegacy(chokidar);
|
|
33
32
|
|
|
34
|
-
var version = "0.2.
|
|
33
|
+
var version = "0.2.12";
|
|
35
34
|
|
|
36
35
|
const packageApp = async ({ outputDir, manifest, copyFiles }) => {
|
|
37
36
|
const { resources } = manifest;
|
|
@@ -273,7 +272,7 @@ var build$1 = async (options) => {
|
|
|
273
272
|
});
|
|
274
273
|
};
|
|
275
274
|
|
|
276
|
-
const init = async (projectPath) => {
|
|
275
|
+
const init$1 = async (projectPath) => {
|
|
277
276
|
const git = simpleGit__default["default"](projectPath);
|
|
278
277
|
await git.init();
|
|
279
278
|
return;
|
|
@@ -354,14 +353,47 @@ const command = {
|
|
|
354
353
|
executeCommand,
|
|
355
354
|
};
|
|
356
355
|
|
|
357
|
-
|
|
356
|
+
// interface PromptResult {
|
|
357
|
+
// [key: string]: string;
|
|
358
|
+
// }
|
|
359
|
+
// const selectTemplate = async (): Promise<TemplateType> => {
|
|
360
|
+
// const prompt = inquirer.createPromptModule();
|
|
361
|
+
// const result: PromptResult = await prompt({
|
|
362
|
+
// type: 'list',
|
|
363
|
+
// name: 'Please select template type',
|
|
364
|
+
// choices: [TemplateType.micro],
|
|
365
|
+
// });
|
|
366
|
+
// return Object.values(result)[0] as TemplateType;
|
|
367
|
+
// };
|
|
368
|
+
const enterAppName = async () => {
|
|
358
369
|
const prompt = inquirer__default["default"].createPromptModule();
|
|
359
370
|
const result = await prompt({
|
|
360
|
-
type: '
|
|
361
|
-
name: '
|
|
362
|
-
|
|
371
|
+
type: 'input',
|
|
372
|
+
name: 'App Name',
|
|
373
|
+
message: 'Please enter an app name',
|
|
374
|
+
validate: (input) => {
|
|
375
|
+
return !!input;
|
|
376
|
+
},
|
|
363
377
|
});
|
|
364
|
-
return
|
|
378
|
+
return result['App Name'];
|
|
379
|
+
};
|
|
380
|
+
const enterAppKey = async () => {
|
|
381
|
+
const prompt = inquirer__default["default"].createPromptModule();
|
|
382
|
+
const result = await prompt({
|
|
383
|
+
type: 'input',
|
|
384
|
+
name: 'App key',
|
|
385
|
+
message: 'Please enter a valid app key',
|
|
386
|
+
validate: (input) => {
|
|
387
|
+
if (!/^[a-z][a-z0-9_]*$/.test(input)) {
|
|
388
|
+
// 需要一个空行来换行输出
|
|
389
|
+
console.log('');
|
|
390
|
+
console.log('only supports letters, numbers, underscores and starts with letters');
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
return true;
|
|
394
|
+
},
|
|
395
|
+
});
|
|
396
|
+
return result['App key'];
|
|
365
397
|
};
|
|
366
398
|
const cloneRepo = async (repoUrl, projectPath) => {
|
|
367
399
|
await execActionWithSpinner({
|
|
@@ -378,14 +410,18 @@ const dependenciesInstall = async (projectPath) => {
|
|
|
378
410
|
}, () => command.executeCommand('yarn', ['install'], projectPath));
|
|
379
411
|
};
|
|
380
412
|
var run$1 = async (options) => {
|
|
381
|
-
const { cwd
|
|
382
|
-
|
|
413
|
+
const { cwd } = options;
|
|
414
|
+
// 选择模板类型 micro or uikit
|
|
415
|
+
// const templateType = await selectTemplate();
|
|
416
|
+
// 暂时写死micro
|
|
417
|
+
const templateType = 'micro';
|
|
418
|
+
const appName = await enterAppName();
|
|
419
|
+
const appKey = await enterAppKey();
|
|
420
|
+
const projectPath = path__default["default"].join(cwd, appKey);
|
|
383
421
|
if (await fse__default["default"].pathExists(projectPath)) {
|
|
384
|
-
console.error(
|
|
422
|
+
console.error(`Project path already exists: ${projectPath}`);
|
|
385
423
|
return;
|
|
386
424
|
}
|
|
387
|
-
// 选择模板类型 micro or uikit
|
|
388
|
-
const templateType = await selectTemplate();
|
|
389
425
|
// 从远程仓库clone模板
|
|
390
426
|
await cloneRepo(templateURL, projectPath);
|
|
391
427
|
// 将指定模板复制到跟目录
|
|
@@ -394,7 +430,6 @@ var run$1 = async (options) => {
|
|
|
394
430
|
await Promise.all(Object.values(TemplateType).map(t => fse__default["default"].remove(path__default["default"].join(projectPath, t))));
|
|
395
431
|
// 删除源远程仓库的git
|
|
396
432
|
await fse__default["default"].remove(path__default["default"].join(projectPath, './.git'));
|
|
397
|
-
const appId = uuid.v4();
|
|
398
433
|
const files = [
|
|
399
434
|
'./manifest.yml',
|
|
400
435
|
'./package.json',
|
|
@@ -402,32 +437,22 @@ var run$1 = async (options) => {
|
|
|
402
437
|
'./public/index.html',
|
|
403
438
|
'./src/App.tsx',
|
|
404
439
|
'./src/index.tsx',
|
|
405
|
-
'./static/micro/package.json',
|
|
406
|
-
'./static/micro/webpack.config.js',
|
|
407
|
-
'./static/micro/public/index.html',
|
|
408
|
-
'./static/micro/src/App.tsx',
|
|
409
|
-
'./static/micro/src/index.tsx',
|
|
410
440
|
];
|
|
411
441
|
// 模板替换
|
|
412
442
|
await Promise.all(files.map(file => rewriteTemplateField(path__default["default"].join(projectPath, file), {
|
|
413
|
-
|
|
414
|
-
|
|
443
|
+
appName,
|
|
444
|
+
appKey,
|
|
415
445
|
})));
|
|
416
446
|
await dependenciesInstall(projectPath);
|
|
417
|
-
await init(projectPath);
|
|
447
|
+
await init$1(projectPath);
|
|
418
448
|
console.log('Project init success!');
|
|
419
449
|
console.log('Project path:' + projectPath);
|
|
420
450
|
};
|
|
421
451
|
|
|
422
|
-
var
|
|
452
|
+
var init = async () => {
|
|
423
453
|
const cwd = process.cwd();
|
|
424
|
-
if (!packageName) {
|
|
425
|
-
console.error('Please input your project name');
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
454
|
await run$1({
|
|
429
455
|
cwd,
|
|
430
|
-
packageName,
|
|
431
456
|
});
|
|
432
457
|
};
|
|
433
458
|
|
|
@@ -571,7 +596,7 @@ program
|
|
|
571
596
|
.option('-i --input [dir]', 'input dir')
|
|
572
597
|
.option('-o --output [dir]', 'output dir')
|
|
573
598
|
.action(build$1);
|
|
574
|
-
program.command('
|
|
599
|
+
program.command('init').action(init);
|
|
575
600
|
program
|
|
576
601
|
.command('dev')
|
|
577
602
|
.option('-i --input [dir]', 'input dir')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@giteeteam/apps-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"description": "Giteeteam Apps cli",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"scripts": {
|
|
27
27
|
"dev": "tsc -w",
|
|
28
28
|
"build": "rimraf dist && rollup -c",
|
|
29
|
-
"prepare": "
|
|
29
|
+
"prepare": "pnpm build",
|
|
30
30
|
"unlink": "yarn unlink",
|
|
31
31
|
"link": "chmod +x ./dist/index.js && yarn link && yarn link '@giteeteam/apps-cli' -g",
|
|
32
|
-
"build-link": "
|
|
32
|
+
"build-link": "pnpm build && yarn run link"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"allowBranch": "master",
|
|
@@ -50,7 +50,6 @@
|
|
|
50
50
|
"inquirer": "^8.2.4",
|
|
51
51
|
"ora": "^5.4.1",
|
|
52
52
|
"simple-git": "^3.7.1",
|
|
53
|
-
"uuid": "^8.3.2",
|
|
54
53
|
"yaml": "^2.1.1"
|
|
55
54
|
},
|
|
56
55
|
"devDependencies": {
|
|
@@ -59,5 +58,5 @@
|
|
|
59
58
|
"@types/inquirer": "^8.2.1",
|
|
60
59
|
"@types/uuid": "^8.3.4"
|
|
61
60
|
},
|
|
62
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "6ab5133ce2217630a7c35225248ef1cba1efa26c"
|
|
63
62
|
}
|