unisolution-create-app 1.0.2 → 1.0.4
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/{bin/index.js → index.js} +163 -156
- package/dist/package-BYI6NkyP.js +58 -0
- package/package.json +4 -4
- package/bin/index.js +0 -102
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var require$$0$2 = require('events');
|
|
5
|
+
var require$$1$2 = require('child_process');
|
|
6
|
+
var require$$1$1 = require('path');
|
|
7
|
+
var require$$0$3 = require('fs');
|
|
8
|
+
var require$$4$1 = require('process');
|
|
9
|
+
var require$$0$4 = require('os');
|
|
10
|
+
var require$$1$3 = require('tty');
|
|
11
|
+
var require$$0$5 = require('stream');
|
|
12
|
+
var require$$0$6 = require('readline');
|
|
13
|
+
var require$$0$7 = require('assert');
|
|
14
|
+
var require$$0$8 = require('buffer');
|
|
15
|
+
var require$$0$9 = require('util');
|
|
16
|
+
var require$$1$4 = require('string_decoder');
|
|
17
|
+
var require$$2$1 = require('crypto');
|
|
18
|
+
var require$$0$a = require('constants');
|
|
17
19
|
|
|
18
20
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
19
21
|
|
|
@@ -21,9 +23,7 @@ function getDefaultExportFromCjs (x) {
|
|
|
21
23
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
var commander = {exports: {}};
|
|
26
|
+
var commander$1 = {exports: {}};
|
|
27
27
|
|
|
28
28
|
var argument = {};
|
|
29
29
|
|
|
@@ -3352,7 +3352,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3352
3352
|
var hasRequiredCommander;
|
|
3353
3353
|
|
|
3354
3354
|
function requireCommander () {
|
|
3355
|
-
if (hasRequiredCommander) return commander.exports;
|
|
3355
|
+
if (hasRequiredCommander) return commander$1.exports;
|
|
3356
3356
|
hasRequiredCommander = 1;
|
|
3357
3357
|
(function (module, exports) {
|
|
3358
3358
|
const { Argument } = requireArgument();
|
|
@@ -3382,9 +3382,27 @@ function requireCommander () {
|
|
|
3382
3382
|
exports.InvalidArgumentError = InvalidArgumentError;
|
|
3383
3383
|
exports.InvalidOptionArgumentError = InvalidArgumentError; // Deprecated
|
|
3384
3384
|
exports.Option = Option;
|
|
3385
|
-
} (commander, commander.exports));
|
|
3386
|
-
return commander.exports;
|
|
3387
|
-
}
|
|
3385
|
+
} (commander$1, commander$1.exports));
|
|
3386
|
+
return commander$1.exports;
|
|
3387
|
+
}
|
|
3388
|
+
|
|
3389
|
+
var commanderExports = requireCommander();
|
|
3390
|
+
var commander = /*@__PURE__*/getDefaultExportFromCjs(commanderExports);
|
|
3391
|
+
|
|
3392
|
+
// wrapper to provide named exports for ESM.
|
|
3393
|
+
const {
|
|
3394
|
+
program,
|
|
3395
|
+
createCommand,
|
|
3396
|
+
createArgument,
|
|
3397
|
+
createOption,
|
|
3398
|
+
CommanderError,
|
|
3399
|
+
InvalidArgumentError,
|
|
3400
|
+
InvalidOptionArgumentError, // deprecated old name
|
|
3401
|
+
Command,
|
|
3402
|
+
Argument,
|
|
3403
|
+
Option,
|
|
3404
|
+
Help
|
|
3405
|
+
} = commander;
|
|
3388
3406
|
|
|
3389
3407
|
var figlet = {exports: {}};
|
|
3390
3408
|
|
|
@@ -4998,7 +5016,9 @@ function requireNodeFiglet () {
|
|
|
4998
5016
|
return nodeFiglet;
|
|
4999
5017
|
}
|
|
5000
5018
|
|
|
5001
|
-
|
|
5019
|
+
requireNodeFiglet();
|
|
5020
|
+
|
|
5021
|
+
var inquirer$1 = {exports: {}};
|
|
5002
5022
|
|
|
5003
5023
|
var ansiStyles = {exports: {}};
|
|
5004
5024
|
|
|
@@ -25095,7 +25115,7 @@ function requireWrapAnsi () {
|
|
|
25095
25115
|
return wrapAnsi_1;
|
|
25096
25116
|
}
|
|
25097
25117
|
|
|
25098
|
-
var ora$
|
|
25118
|
+
var ora$2 = {exports: {}};
|
|
25099
25119
|
|
|
25100
25120
|
var dots = {
|
|
25101
25121
|
interval: 80,
|
|
@@ -26090,7 +26110,6 @@ var bouncingBar = {
|
|
|
26090
26110
|
"[= ]",
|
|
26091
26111
|
"[== ]",
|
|
26092
26112
|
"[=== ]",
|
|
26093
|
-
"[====]",
|
|
26094
26113
|
"[ ===]",
|
|
26095
26114
|
"[ ==]",
|
|
26096
26115
|
"[ =]",
|
|
@@ -30996,7 +31015,7 @@ function requireBl () {
|
|
|
30996
31015
|
var hasRequiredOra$1;
|
|
30997
31016
|
|
|
30998
31017
|
function requireOra$1 () {
|
|
30999
|
-
if (hasRequiredOra$1) return ora$
|
|
31018
|
+
if (hasRequiredOra$1) return ora$2.exports;
|
|
31000
31019
|
hasRequiredOra$1 = 1;
|
|
31001
31020
|
const readline = require$$0$6;
|
|
31002
31021
|
const chalk = requireSource();
|
|
@@ -31382,9 +31401,9 @@ function requireOra$1 () {
|
|
|
31382
31401
|
return new Ora(options);
|
|
31383
31402
|
};
|
|
31384
31403
|
|
|
31385
|
-
ora$
|
|
31404
|
+
ora$2.exports = oraFactory;
|
|
31386
31405
|
|
|
31387
|
-
ora$
|
|
31406
|
+
ora$2.exports.promise = (action, options) => {
|
|
31388
31407
|
// eslint-disable-next-line promise/prefer-await-to-then
|
|
31389
31408
|
if (typeof action.then !== 'function') {
|
|
31390
31409
|
throw new TypeError('Parameter `action` must be a Promise');
|
|
@@ -31404,7 +31423,7 @@ function requireOra$1 () {
|
|
|
31404
31423
|
|
|
31405
31424
|
return spinner;
|
|
31406
31425
|
};
|
|
31407
|
-
return ora$
|
|
31426
|
+
return ora$2.exports;
|
|
31408
31427
|
}
|
|
31409
31428
|
|
|
31410
31429
|
var screenManager;
|
|
@@ -45210,7 +45229,7 @@ var require$$6 = [
|
|
|
45210
45229
|
]
|
|
45211
45230
|
];
|
|
45212
45231
|
|
|
45213
|
-
var require$$7
|
|
45232
|
+
var require$$7 = [
|
|
45214
45233
|
[
|
|
45215
45234
|
"8740",
|
|
45216
45235
|
"䏰䰲䘃䖦䕸𧉧䵷䖳𧲱䳢𧳅㮕䜶䝄䱇䱀𤊿𣘗𧍒𦺋𧃒䱗𪍑䝏䗚䲅𧱬䴇䪤䚡𦬣爥𥩔𡩣𣸆𣽡晍囻"
|
|
@@ -45888,7 +45907,7 @@ function requireDbcsData () {
|
|
|
45888
45907
|
'big5': 'big5hkscs',
|
|
45889
45908
|
'big5hkscs': {
|
|
45890
45909
|
type: '_dbcs',
|
|
45891
|
-
table: function() { return require$$6.concat(require$$7
|
|
45910
|
+
table: function() { return require$$6.concat(require$$7) },
|
|
45892
45911
|
encodeSkipVals: [0xa2cc],
|
|
45893
45912
|
},
|
|
45894
45913
|
|
|
@@ -47598,7 +47617,7 @@ function requireEditor () {
|
|
|
47598
47617
|
var hasRequiredInquirer;
|
|
47599
47618
|
|
|
47600
47619
|
function requireInquirer () {
|
|
47601
|
-
if (hasRequiredInquirer) return inquirer.exports;
|
|
47620
|
+
if (hasRequiredInquirer) return inquirer$1.exports;
|
|
47602
47621
|
hasRequiredInquirer = 1;
|
|
47603
47622
|
(function (module) {
|
|
47604
47623
|
/**
|
|
@@ -47693,11 +47712,14 @@ function requireInquirer () {
|
|
|
47693
47712
|
inquirer.restoreDefaultPrompts = function () {
|
|
47694
47713
|
inquirer.prompt.restoreDefaultPrompts();
|
|
47695
47714
|
};
|
|
47696
|
-
} (inquirer));
|
|
47697
|
-
return inquirer.exports;
|
|
47715
|
+
} (inquirer$1));
|
|
47716
|
+
return inquirer$1.exports;
|
|
47698
47717
|
}
|
|
47699
47718
|
|
|
47700
|
-
var
|
|
47719
|
+
var inquirerExports = requireInquirer();
|
|
47720
|
+
var inquirer = /*@__PURE__*/getDefaultExportFromCjs(inquirerExports);
|
|
47721
|
+
|
|
47722
|
+
var fs$1 = {};
|
|
47701
47723
|
|
|
47702
47724
|
var universalify = {};
|
|
47703
47725
|
|
|
@@ -47712,8 +47734,11 @@ function requireUniversalify () {
|
|
|
47712
47734
|
if (typeof args[args.length - 1] === 'function') fn.apply(this, args);
|
|
47713
47735
|
else {
|
|
47714
47736
|
return new Promise((resolve, reject) => {
|
|
47715
|
-
|
|
47716
|
-
|
|
47737
|
+
fn.call(
|
|
47738
|
+
this,
|
|
47739
|
+
...args,
|
|
47740
|
+
(err, res) => (err != null) ? reject(err) : resolve(res)
|
|
47741
|
+
);
|
|
47717
47742
|
})
|
|
47718
47743
|
}
|
|
47719
47744
|
}, 'name', { value: fn.name })
|
|
@@ -47723,10 +47748,7 @@ function requireUniversalify () {
|
|
|
47723
47748
|
return Object.defineProperty(function (...args) {
|
|
47724
47749
|
const cb = args[args.length - 1];
|
|
47725
47750
|
if (typeof cb !== 'function') return fn.apply(this, args)
|
|
47726
|
-
else
|
|
47727
|
-
args.pop();
|
|
47728
|
-
fn.apply(this, args).then(r => cb(null, r), cb);
|
|
47729
|
-
}
|
|
47751
|
+
else fn.apply(this, args.slice(0, -1)).then(r => cb(null, r), cb);
|
|
47730
47752
|
}, 'name', { value: fn.name })
|
|
47731
47753
|
};
|
|
47732
47754
|
return universalify;
|
|
@@ -48714,7 +48736,7 @@ function requireGracefulFs () {
|
|
|
48714
48736
|
var hasRequiredFs;
|
|
48715
48737
|
|
|
48716
48738
|
function requireFs () {
|
|
48717
|
-
if (hasRequiredFs) return fs;
|
|
48739
|
+
if (hasRequiredFs) return fs$1;
|
|
48718
48740
|
hasRequiredFs = 1;
|
|
48719
48741
|
(function (exports) {
|
|
48720
48742
|
// This is adapted from https://github.com/normalize/mz
|
|
@@ -48862,8 +48884,8 @@ function requireFs () {
|
|
|
48862
48884
|
'Warning', 'fs-extra-WARN0003'
|
|
48863
48885
|
);
|
|
48864
48886
|
}
|
|
48865
|
-
} (fs));
|
|
48866
|
-
return fs;
|
|
48887
|
+
} (fs$1));
|
|
48888
|
+
return fs$1;
|
|
48867
48889
|
}
|
|
48868
48890
|
|
|
48869
48891
|
var makeDir = {};
|
|
@@ -50449,6 +50471,9 @@ function requireLib () {
|
|
|
50449
50471
|
return lib;
|
|
50450
50472
|
}
|
|
50451
50473
|
|
|
50474
|
+
var libExports = /*@__PURE__*/ requireLib();
|
|
50475
|
+
var fs = /*@__PURE__*/getDefaultExportFromCjs(libExports);
|
|
50476
|
+
|
|
50452
50477
|
var util = {};
|
|
50453
50478
|
|
|
50454
50479
|
var hasRequiredUtil;
|
|
@@ -50526,15 +50551,15 @@ function requireImpl () {
|
|
|
50526
50551
|
return impl;
|
|
50527
50552
|
}
|
|
50528
50553
|
|
|
50529
|
-
var gitClone;
|
|
50554
|
+
var gitClone$1;
|
|
50530
50555
|
var hasRequiredGitClone;
|
|
50531
50556
|
|
|
50532
50557
|
function requireGitClone () {
|
|
50533
|
-
if (hasRequiredGitClone) return gitClone;
|
|
50558
|
+
if (hasRequiredGitClone) return gitClone$1;
|
|
50534
50559
|
hasRequiredGitClone = 1;
|
|
50535
50560
|
const impl = requireImpl();
|
|
50536
50561
|
|
|
50537
|
-
gitClone = function(repo, targetPath, opts, cb) {
|
|
50562
|
+
gitClone$1 = function(repo, targetPath, opts, cb) {
|
|
50538
50563
|
if (typeof opts === 'function') {
|
|
50539
50564
|
cb = opts;
|
|
50540
50565
|
opts = null;
|
|
@@ -50545,15 +50570,18 @@ function requireGitClone () {
|
|
|
50545
50570
|
|
|
50546
50571
|
impl(repo, targetPath, opts, cb, cb);
|
|
50547
50572
|
};
|
|
50548
|
-
return gitClone;
|
|
50573
|
+
return gitClone$1;
|
|
50549
50574
|
}
|
|
50550
50575
|
|
|
50551
|
-
var
|
|
50576
|
+
var gitCloneExports = requireGitClone();
|
|
50577
|
+
var gitClone = /*@__PURE__*/getDefaultExportFromCjs(gitCloneExports);
|
|
50578
|
+
|
|
50579
|
+
var ora$1 = {exports: {}};
|
|
50552
50580
|
|
|
50553
50581
|
var hasRequiredOra;
|
|
50554
50582
|
|
|
50555
50583
|
function requireOra () {
|
|
50556
|
-
if (hasRequiredOra) return ora.exports;
|
|
50584
|
+
if (hasRequiredOra) return ora$1.exports;
|
|
50557
50585
|
hasRequiredOra = 1;
|
|
50558
50586
|
const readline = require$$0$6;
|
|
50559
50587
|
const chalk = requireSource();
|
|
@@ -50891,9 +50919,9 @@ function requireOra () {
|
|
|
50891
50919
|
return new Ora(options);
|
|
50892
50920
|
};
|
|
50893
50921
|
|
|
50894
|
-
ora.exports = oraFactory;
|
|
50922
|
+
ora$1.exports = oraFactory;
|
|
50895
50923
|
|
|
50896
|
-
ora.exports.promise = (action, options) => {
|
|
50924
|
+
ora$1.exports.promise = (action, options) => {
|
|
50897
50925
|
// eslint-disable-next-line promise/prefer-await-to-then
|
|
50898
50926
|
if (typeof action.then !== 'function') {
|
|
50899
50927
|
throw new TypeError('Parameter `action` must be a Promise');
|
|
@@ -50913,118 +50941,97 @@ function requireOra () {
|
|
|
50913
50941
|
|
|
50914
50942
|
return spinner;
|
|
50915
50943
|
};
|
|
50916
|
-
return ora.exports;
|
|
50944
|
+
return ora$1.exports;
|
|
50917
50945
|
}
|
|
50918
50946
|
|
|
50919
|
-
var
|
|
50920
|
-
var
|
|
50921
|
-
version: version};
|
|
50922
|
-
|
|
50923
|
-
var hasRequiredBin;
|
|
50947
|
+
var oraExports = requireOra();
|
|
50948
|
+
var ora = /*@__PURE__*/getDefaultExportFromCjs(oraExports);
|
|
50924
50949
|
|
|
50925
|
-
|
|
50926
|
-
|
|
50927
|
-
hasRequiredBin = 1;
|
|
50928
|
-
const { program } = requireCommander();
|
|
50929
|
-
requireNodeFiglet();
|
|
50930
|
-
const inquirer = requireInquirer();
|
|
50950
|
+
// 首航提示
|
|
50951
|
+
program.name('runcli').usage('<command> [options]');
|
|
50931
50952
|
|
|
50932
|
-
|
|
50933
|
-
|
|
50934
|
-
const gitClone = requireGitClone();
|
|
50935
|
-
const ora = requireOra();
|
|
50936
|
-
// 首航提示
|
|
50937
|
-
program.name('runcli').usage('<command> [options]');
|
|
50953
|
+
// 版本
|
|
50954
|
+
program.version(`${Promise.resolve().then(function () { return require('./package-BYI6NkyP.js'); })['version']}`);
|
|
50938
50955
|
|
|
50939
|
-
|
|
50940
|
-
|
|
50956
|
+
// 命令
|
|
50957
|
+
program
|
|
50958
|
+
.command('create <app-name>')
|
|
50959
|
+
.description('create a new project')
|
|
50960
|
+
.action(projectName => {
|
|
50961
|
+
createProject(projectName);
|
|
50962
|
+
});
|
|
50941
50963
|
|
|
50942
|
-
|
|
50943
|
-
|
|
50944
|
-
|
|
50945
|
-
.description('create a new project')
|
|
50946
|
-
.action(projectName => {
|
|
50947
|
-
createProject(projectName);
|
|
50948
|
-
});
|
|
50964
|
+
// program.on('--help', function () {
|
|
50965
|
+
// console.log('')
|
|
50966
|
+
// });
|
|
50949
50967
|
|
|
50950
|
-
|
|
50951
|
-
// console.log('')
|
|
50952
|
-
// });
|
|
50968
|
+
program.parse(process.argv);
|
|
50953
50969
|
|
|
50954
|
-
|
|
50970
|
+
const projectList = {
|
|
50971
|
+
'react': '',
|
|
50972
|
+
'react-ts': 'https://gitee.com/unisolution_cn_lhj/reactdemo.git'
|
|
50973
|
+
};
|
|
50955
50974
|
|
|
50956
|
-
|
|
50957
|
-
|
|
50958
|
-
|
|
50959
|
-
|
|
50975
|
+
async function createProject (projectName) {
|
|
50976
|
+
// 创建一个名字为projectName的文件夹,将模板代码放在文件夹下面
|
|
50977
|
+
// 判断有没有 name 的文件夹
|
|
50978
|
+
const currentFolder = process.cwd();
|
|
50979
|
+
const fullPath = require$$1$1.join(currentFolder, projectName);
|
|
50980
|
+
const isExist = fs.existsSync(fullPath);
|
|
50960
50981
|
|
|
50961
|
-
|
|
50962
|
-
|
|
50963
|
-
|
|
50964
|
-
|
|
50965
|
-
|
|
50966
|
-
|
|
50982
|
+
if (isExist) {
|
|
50983
|
+
const answers = await inquirer.prompt([
|
|
50984
|
+
{
|
|
50985
|
+
type: 'confirm',
|
|
50986
|
+
name: 'overWrite',
|
|
50987
|
+
message: `${projectName}已经存在,是否要覆盖?`
|
|
50988
|
+
}
|
|
50989
|
+
]);
|
|
50990
|
+
const { overWrite } = answers;
|
|
50991
|
+
if (overWrite) {
|
|
50992
|
+
fs.remove(fullPath);
|
|
50993
|
+
generateNewProject(fullPath);
|
|
50994
|
+
} else return;
|
|
50995
|
+
} else {
|
|
50996
|
+
generateNewProject(fullPath);
|
|
50997
|
+
}
|
|
50998
|
+
}
|
|
50967
50999
|
|
|
50968
|
-
|
|
50969
|
-
|
|
50970
|
-
|
|
50971
|
-
|
|
50972
|
-
|
|
50973
|
-
|
|
50974
|
-
|
|
50975
|
-
|
|
50976
|
-
|
|
50977
|
-
|
|
50978
|
-
|
|
50979
|
-
|
|
50980
|
-
|
|
50981
|
-
|
|
50982
|
-
|
|
50983
|
-
|
|
50984
|
-
|
|
50985
|
-
|
|
50986
|
-
|
|
50987
|
-
|
|
50988
|
-
|
|
50989
|
-
|
|
50990
|
-
|
|
50991
|
-
|
|
50992
|
-
|
|
50993
|
-
|
|
50994
|
-
|
|
50995
|
-
|
|
50996
|
-
|
|
50997
|
-
|
|
50998
|
-
|
|
50999
|
-
|
|
51000
|
-
|
|
51001
|
-
|
|
51002
|
-
|
|
51003
|
-
|
|
51004
|
-
|
|
51005
|
-
|
|
51006
|
-
const address = projectList[type];
|
|
51007
|
-
// 拿到仓库的地址?
|
|
51008
|
-
const loading = ora('正在生成模板...').start();
|
|
51009
|
-
gitClone(address, projectPath, {
|
|
51010
|
-
checkout: 'master'
|
|
51011
|
-
}, function (err) {
|
|
51012
|
-
if (err) {
|
|
51013
|
-
loading.fail('生成失败,请检查网络问题重试');
|
|
51014
|
-
} else {
|
|
51015
|
-
loading.succeed('创建完毕');
|
|
51016
|
-
}
|
|
51017
|
-
});
|
|
51018
|
-
}
|
|
51019
|
-
if (type === 'react') {
|
|
51020
|
-
console.log('不选ts你是怎么想的');
|
|
51021
|
-
console.log('重新创建去吧');
|
|
51022
|
-
}
|
|
51023
|
-
}
|
|
51024
|
-
return bin;
|
|
51025
|
-
}
|
|
51026
|
-
|
|
51027
|
-
var binExports = requireBin();
|
|
51028
|
-
var index = /*@__PURE__*/getDefaultExportFromCjs(binExports);
|
|
51029
|
-
|
|
51030
|
-
export { index as default };
|
|
51000
|
+
async function generateNewProject (projectPath) {
|
|
51001
|
+
const answers = await inquirer.prompt([
|
|
51002
|
+
{
|
|
51003
|
+
type: 'list',
|
|
51004
|
+
name: 'type',
|
|
51005
|
+
message: `请选择模板`,
|
|
51006
|
+
choices: [
|
|
51007
|
+
{
|
|
51008
|
+
name: 'react',
|
|
51009
|
+
value: 'react'
|
|
51010
|
+
},
|
|
51011
|
+
{
|
|
51012
|
+
name: 'react-ts',
|
|
51013
|
+
value: 'react-ts'
|
|
51014
|
+
}
|
|
51015
|
+
]
|
|
51016
|
+
}
|
|
51017
|
+
]);
|
|
51018
|
+
const { type } = answers;
|
|
51019
|
+
if (type === 'react-ts') {
|
|
51020
|
+
const address = projectList[type];
|
|
51021
|
+
// 拿到仓库的地址?
|
|
51022
|
+
const loading = ora('正在生成模板...').start();
|
|
51023
|
+
gitClone(address, projectPath, {
|
|
51024
|
+
checkout: 'master'
|
|
51025
|
+
}, function (err) {
|
|
51026
|
+
if (err) {
|
|
51027
|
+
loading.fail('生成失败,请检查网络问题重试');
|
|
51028
|
+
} else {
|
|
51029
|
+
loading.succeed('创建完毕');
|
|
51030
|
+
}
|
|
51031
|
+
});
|
|
51032
|
+
}
|
|
51033
|
+
if (type === 'react') {
|
|
51034
|
+
console.log('不选ts你是怎么想的');
|
|
51035
|
+
console.log('重新创建去吧');
|
|
51036
|
+
}
|
|
51037
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var name = "unisolution-create-app";
|
|
4
|
+
var version = "1.0.3";
|
|
5
|
+
var description = "";
|
|
6
|
+
var bin = "/dist/bin/index.js";
|
|
7
|
+
var type = "module";
|
|
8
|
+
var scripts = {
|
|
9
|
+
build: "rollup -c"
|
|
10
|
+
};
|
|
11
|
+
var files = [
|
|
12
|
+
"dist",
|
|
13
|
+
"package.json"
|
|
14
|
+
];
|
|
15
|
+
var author = "";
|
|
16
|
+
var license = "ISC";
|
|
17
|
+
var dependencies = {
|
|
18
|
+
chalk: "^4.1.2",
|
|
19
|
+
commander: "^10.0.1",
|
|
20
|
+
figlet: "^1.6.0",
|
|
21
|
+
"fs-extra": "^11.1.1",
|
|
22
|
+
"git-clone": "^0.2.0",
|
|
23
|
+
inquirer: "^8.0.0",
|
|
24
|
+
ora: "5.0.0"
|
|
25
|
+
};
|
|
26
|
+
var devDependencies = {
|
|
27
|
+
"@rollup/plugin-commonjs": "^28.0.3",
|
|
28
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
29
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
30
|
+
rollup: "^4.37.0",
|
|
31
|
+
"rollup-plugin-delete": "^3.0.1"
|
|
32
|
+
};
|
|
33
|
+
var _package = {
|
|
34
|
+
name: name,
|
|
35
|
+
version: version,
|
|
36
|
+
description: description,
|
|
37
|
+
bin: bin,
|
|
38
|
+
type: type,
|
|
39
|
+
scripts: scripts,
|
|
40
|
+
files: files,
|
|
41
|
+
author: author,
|
|
42
|
+
license: license,
|
|
43
|
+
dependencies: dependencies,
|
|
44
|
+
devDependencies: devDependencies
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
exports.author = author;
|
|
48
|
+
exports.bin = bin;
|
|
49
|
+
exports.default = _package;
|
|
50
|
+
exports.dependencies = dependencies;
|
|
51
|
+
exports.description = description;
|
|
52
|
+
exports.devDependencies = devDependencies;
|
|
53
|
+
exports.files = files;
|
|
54
|
+
exports.license = license;
|
|
55
|
+
exports.name = name;
|
|
56
|
+
exports.scripts = scripts;
|
|
57
|
+
exports.type = type;
|
|
58
|
+
exports.version = version;
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unisolution-create-app",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "",
|
|
5
|
-
"
|
|
6
|
-
"bin": "/bin/index.js",
|
|
5
|
+
"bin": "/dist/bin/index.js",
|
|
7
6
|
"type": "module",
|
|
8
7
|
"scripts": {
|
|
9
8
|
"build": "rollup -c"
|
|
10
9
|
},
|
|
11
10
|
"files": [
|
|
12
|
-
"dist"
|
|
11
|
+
"dist",
|
|
12
|
+
"package.json"
|
|
13
13
|
],
|
|
14
14
|
"author": "",
|
|
15
15
|
"license": "ISC",
|
package/bin/index.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { program } = require('commander')
|
|
4
|
-
const figlet = require('figlet')
|
|
5
|
-
const inquirer = require('inquirer')
|
|
6
|
-
|
|
7
|
-
const fs = require('fs-extra')
|
|
8
|
-
const path = require('path')
|
|
9
|
-
const gitClone = require('git-clone');
|
|
10
|
-
const ora = require('ora');
|
|
11
|
-
// 首航提示
|
|
12
|
-
program.name('runcli').usage('<command> [options]')
|
|
13
|
-
|
|
14
|
-
// 版本
|
|
15
|
-
program.version(`${require('../package.json')['version']}`)
|
|
16
|
-
|
|
17
|
-
// 命令
|
|
18
|
-
program
|
|
19
|
-
.command('create <app-name>')
|
|
20
|
-
.description('create a new project')
|
|
21
|
-
.action(projectName => {
|
|
22
|
-
createProject(projectName)
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
// program.on('--help', function () {
|
|
26
|
-
// console.log('')
|
|
27
|
-
// });
|
|
28
|
-
|
|
29
|
-
program.parse(process.argv);
|
|
30
|
-
|
|
31
|
-
function log (obj) {
|
|
32
|
-
console.log(JSON.stringify(obj))
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const projectList = {
|
|
36
|
-
'react': '',
|
|
37
|
-
'react-ts': 'https://gitee.com/unisolution_cn_lhj/reactdemo.git'
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function createProject (projectName) {
|
|
41
|
-
// 创建一个名字为projectName的文件夹,将模板代码放在文件夹下面
|
|
42
|
-
// 判断有没有 name 的文件夹
|
|
43
|
-
const currentFolder = process.cwd();
|
|
44
|
-
const fullPath = path.join(currentFolder, projectName);
|
|
45
|
-
const isExist = fs.existsSync(fullPath)
|
|
46
|
-
|
|
47
|
-
if (isExist) {
|
|
48
|
-
const answers = await inquirer.prompt([
|
|
49
|
-
{
|
|
50
|
-
type: 'confirm',
|
|
51
|
-
name: 'overWrite',
|
|
52
|
-
message: `${projectName}已经存在,是否要覆盖?`
|
|
53
|
-
}
|
|
54
|
-
])
|
|
55
|
-
const { overWrite } = answers;
|
|
56
|
-
if (overWrite) {
|
|
57
|
-
fs.remove(fullPath)
|
|
58
|
-
generateNewProject(fullPath)
|
|
59
|
-
} else return;
|
|
60
|
-
} else {
|
|
61
|
-
generateNewProject(fullPath)
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
async function generateNewProject (projectPath) {
|
|
66
|
-
const answers = await inquirer.prompt([
|
|
67
|
-
{
|
|
68
|
-
type: 'list',
|
|
69
|
-
name: 'type',
|
|
70
|
-
message: `请选择模板`,
|
|
71
|
-
choices: [
|
|
72
|
-
{
|
|
73
|
-
name: 'react',
|
|
74
|
-
value: 'react'
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
name: 'react-ts',
|
|
78
|
-
value: 'react-ts'
|
|
79
|
-
}
|
|
80
|
-
]
|
|
81
|
-
}
|
|
82
|
-
])
|
|
83
|
-
const { type } = answers;
|
|
84
|
-
if (type === 'react-ts') {
|
|
85
|
-
const address = projectList[type];
|
|
86
|
-
// 拿到仓库的地址?
|
|
87
|
-
const loading = ora('正在生成模板...').start();
|
|
88
|
-
gitClone(address, projectPath, {
|
|
89
|
-
checkout: 'master'
|
|
90
|
-
}, function (err) {
|
|
91
|
-
if (err) {
|
|
92
|
-
loading.fail('生成失败,请检查网络问题重试')
|
|
93
|
-
} else {
|
|
94
|
-
loading.succeed('创建完毕')
|
|
95
|
-
}
|
|
96
|
-
})
|
|
97
|
-
}
|
|
98
|
-
if (type === 'react') {
|
|
99
|
-
console.log('不选ts你是怎么想的');
|
|
100
|
-
console.log('重新创建去吧');
|
|
101
|
-
}
|
|
102
|
-
}
|