imooc-cli-dev-gd 1.0.0

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.
Files changed (63) hide show
  1. package/LICENSE.md +0 -0
  2. package/commands/init/README.md +11 -0
  3. package/commands/init/__tests__/init.test.js +7 -0
  4. package/commands/init/lib/getProjectTemplate.js +7 -0
  5. package/commands/init/lib/index.js +423 -0
  6. package/commands/init/package.json +41 -0
  7. package/commands/publish/README.md +11 -0
  8. package/commands/publish/__tests__/publish.test.js +7 -0
  9. package/commands/publish/lib/index.js +67 -0
  10. package/commands/publish/package.json +32 -0
  11. package/core/cli/README.md +11 -0
  12. package/core/cli/__tests__/core.test.js +7 -0
  13. package/core/cli/bin/index.js +9 -0
  14. package/core/cli/lib/const.js +5 -0
  15. package/core/cli/lib/index.js +151 -0
  16. package/core/cli/package.json +41 -0
  17. package/core/exec/README.md +11 -0
  18. package/core/exec/__tests__/exec.test.js +7 -0
  19. package/core/exec/lib/index.js +89 -0
  20. package/core/exec/package.json +31 -0
  21. package/lerna.json +9 -0
  22. package/models/cloudbuild/README.md +11 -0
  23. package/models/cloudbuild/__tests__/cloudbuild.test.js +7 -0
  24. package/models/cloudbuild/lib/index.js +99 -0
  25. package/models/cloudbuild/package.json +28 -0
  26. package/models/command/README.md +11 -0
  27. package/models/command/__tests__/Command.test.js +7 -0
  28. package/models/command/lib/index.js +56 -0
  29. package/models/command/package.json +31 -0
  30. package/models/git/README.md +11 -0
  31. package/models/git/__tests__/git.test.js +7 -0
  32. package/models/git/lib/GitServer.js +60 -0
  33. package/models/git/lib/Gitee.js +59 -0
  34. package/models/git/lib/GiteeRequest.js +50 -0
  35. package/models/git/lib/Github.js +63 -0
  36. package/models/git/lib/GithubRequest.js +53 -0
  37. package/models/git/lib/index.js +512 -0
  38. package/models/git/package.json +35 -0
  39. package/models/package/README.md +11 -0
  40. package/models/package/__tests__/package.test.js +7 -0
  41. package/models/package/lib/index.js +121 -0
  42. package/models/package/package.json +35 -0
  43. package/package.json +14 -0
  44. package/utils/format-path/README.md +11 -0
  45. package/utils/format-path/__tests__/format-path.test.js +7 -0
  46. package/utils/format-path/lib/index.js +15 -0
  47. package/utils/format-path/package.json +26 -0
  48. package/utils/get-npm-info/README.md +11 -0
  49. package/utils/get-npm-info/__tests__/get-npm-info.test.js +7 -0
  50. package/utils/get-npm-info/lib/index.js +65 -0
  51. package/utils/get-npm-info/package.json +28 -0
  52. package/utils/log/README.md +11 -0
  53. package/utils/log/__tests__/log.test.js +7 -0
  54. package/utils/log/lib/index.js +10 -0
  55. package/utils/log/package.json +32 -0
  56. package/utils/request/README.md +11 -0
  57. package/utils/request/__tests__/request.test.js +7 -0
  58. package/utils/request/lib/index.js +22 -0
  59. package/utils/request/package.json +29 -0
  60. package/utils/utils/README.md +11 -0
  61. package/utils/utils/__tests__/utils.test.js +7 -0
  62. package/utils/utils/lib/index.js +77 -0
  63. package/utils/utils/package.json +26 -0
package/LICENSE.md ADDED
File without changes
@@ -0,0 +1,11 @@
1
+ # `@imooc-cli-dev-gd/init`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ const init = require('@imooc-cli-dev-gd/init');
9
+
10
+ // TODO: DEMONSTRATE API
11
+ ```
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ const init = require('..');
4
+
5
+ describe('@imooc-cli-dev-gd/init', () => {
6
+ it('needs tests');
7
+ });
@@ -0,0 +1,7 @@
1
+ const request = require('@imooc-cli-dev-gd/request');
2
+
3
+ module.exports = function() {
4
+ return request({
5
+ url: '/project/template',
6
+ });
7
+ };
@@ -0,0 +1,423 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const inquirer = require('inquirer');
6
+ const fse = require('fs-extra');
7
+ const glob = require('glob');
8
+ const ejs = require('ejs');
9
+ const semver = require('semver');
10
+ const userHome = require('user-home');
11
+ const Command = require('@imooc-cli-dev-gd/command');
12
+ const Package = require('@imooc-cli-dev-gd/package');
13
+ const log = require('@imooc-cli-dev-gd/log');
14
+ const { spinnerStart, sleep, execAsync } = require('@imooc-cli-dev-gd/utils');
15
+
16
+ const getProjectTemplate = require('./getProjectTemplate');
17
+
18
+ const TYPE_PROJECT = 'project';
19
+ const TYPE_COMPONENT = 'component';
20
+
21
+ const TEMPLATE_TYPE_NORMAL = 'normal';
22
+ const TEMPLATE_TYPE_CUSTOM = 'custom';
23
+
24
+ const WHITE_COMMAND = ['npm', 'cnpm'];
25
+
26
+ class InitCommand extends Command {
27
+ init() {
28
+ this.projectName = this._argv[0] || '';
29
+ this.force = !!this._cmd.force;
30
+ log.verbose('projectName', this.projectName);
31
+ log.verbose('force', this.force);
32
+ }
33
+
34
+ async exec() {
35
+ try {
36
+ // 1. 准备阶段
37
+ const projectInfo = await this.prepare();
38
+ if (projectInfo) {
39
+ // 2. 下载模板
40
+ log.verbose('projectInfo', projectInfo);
41
+ this.projectInfo = projectInfo;
42
+ await this.downloadTemplate();
43
+ // 3. 安装模板
44
+ await this.installTemplate();
45
+ }
46
+ } catch (e) {
47
+ log.error(e.message);
48
+ if (process.env.LOG_LEVEL === 'verbose') {
49
+ console.log(e);
50
+ }
51
+ }
52
+ }
53
+
54
+ async installTemplate() {
55
+ log.verbose('templateInfo', this.templateInfo);
56
+ if (this.templateInfo) {
57
+ if (!this.templateInfo.type) {
58
+ this.templateInfo.type = TEMPLATE_TYPE_NORMAL;
59
+ }
60
+ if (this.templateInfo.type === TEMPLATE_TYPE_NORMAL) {
61
+ // 标准安装
62
+ await this.installNormalTemplate();
63
+ } else if (this.templateInfo.type === TEMPLATE_TYPE_CUSTOM) {
64
+ // 自定义安装
65
+ await this.installCustomTemplate();
66
+ } else {
67
+ throw new Error('无法识别项目模板类型!');
68
+ }
69
+ } else {
70
+ throw new Error('项目模板信息不存在!');
71
+ }
72
+ }
73
+
74
+ checkCommand(cmd) {
75
+ if (WHITE_COMMAND.includes(cmd)) {
76
+ return cmd;
77
+ }
78
+ return null;
79
+ }
80
+
81
+ async execCommand(command, errMsg) {
82
+ let ret;
83
+ if (command) {
84
+ const cmdArray = command.split(' ');
85
+ const cmd = this.checkCommand(cmdArray[0]);
86
+ if (!cmd) {
87
+ throw new Error('命令不存在!命令:' + command);
88
+ }
89
+ const args = cmdArray.slice(1);
90
+ ret = await execAsync(cmd, args, {
91
+ stdio: 'inherit',
92
+ cwd: process.cwd(),
93
+ });
94
+ }
95
+ if (ret !== 0) {
96
+ throw new Error(errMsg);
97
+ }
98
+ return ret;
99
+ }
100
+
101
+ async ejsRender(options) {
102
+ const dir = process.cwd();
103
+ const projectInfo = this.projectInfo;
104
+ return new Promise((resolve, reject) => {
105
+ glob('**', {
106
+ cwd: dir,
107
+ ignore: options.ignore || '',
108
+ nodir: true,
109
+ }, function(err, files) {
110
+ if (err) {
111
+ reject(err);
112
+ }
113
+ Promise.all(files.map(file => {
114
+ const filePath = path.join(dir, file);
115
+ return new Promise((resolve1, reject1) => {
116
+ ejs.renderFile(filePath, projectInfo, {}, (err, result) => {
117
+ if (err) {
118
+ reject1(err);
119
+ } else {
120
+ fse.writeFileSync(filePath, result);
121
+ resolve1(result);
122
+ }
123
+ });
124
+ });
125
+ })).then(() => {
126
+ resolve();
127
+ }).catch(err => {
128
+ reject(err);
129
+ });
130
+ });
131
+ });
132
+ }
133
+
134
+ async installNormalTemplate() {
135
+ log.verbose('templateNpm', this.templateNpm);
136
+ // 拷贝模板代码至当前目录
137
+ let spinner = spinnerStart('正在安装模板...');
138
+ await sleep();
139
+ try {
140
+ const templatePath = path.resolve(this.templateNpm.cacheFilePath, 'template');
141
+ const targetPath = process.cwd();
142
+ fse.ensureDirSync(templatePath);
143
+ fse.ensureDirSync(targetPath);
144
+ fse.copySync(templatePath, targetPath);
145
+ } catch (e) {
146
+ throw e;
147
+ } finally {
148
+ spinner.stop(true);
149
+ log.success('模板安装成功');
150
+ }
151
+ const templateIgnore = this.templateInfo.ignore || [];
152
+ const ignore = ['**/node_modules/**', ...templateIgnore];
153
+ await this.ejsRender({ ignore });
154
+ const { installCommand, startCommand } = this.templateInfo;
155
+ // 依赖安装
156
+ await this.execCommand(installCommand, '依赖安装失败!');
157
+ // 启动命令执行
158
+ await this.execCommand(startCommand, '启动执行命令失败!');
159
+ }
160
+
161
+ async installCustomTemplate() {
162
+ // 查询自定义模板的入口文件
163
+ if (await this.templateNpm.exists()) {
164
+ const rootFile = this.templateNpm.getRootFilePath();
165
+ if (fs.existsSync(rootFile)) {
166
+ log.notice('开始执行自定义模板');
167
+ const templatePath = path.resolve(this.templateNpm.cacheFilePath, 'template');
168
+ const options = {
169
+ templateInfo: this.templateInfo,
170
+ projectInfo: this.projectInfo,
171
+ sourcePath: templatePath,
172
+ targetPath: process.cwd(),
173
+ };
174
+ const code = `require('${rootFile}')(${JSON.stringify(options)})`;
175
+ log.verbose('code', code);
176
+ await execAsync('node', ['-e', code], { stdio: 'inherit', cwd: process.cwd() });
177
+ log.success('自定义模板安装成功');
178
+ } else {
179
+ throw new Error('自定义模板入口文件不存在!');
180
+ }
181
+ }
182
+ }
183
+
184
+ async downloadTemplate() {
185
+ const { projectTemplate } = this.projectInfo;
186
+ const templateInfo = this.template.find(item => item.npmName === projectTemplate);
187
+ const targetPath = path.resolve(userHome, '.imooc-cli-dev', 'template');
188
+ const storeDir = path.resolve(userHome, '.imooc-cli-dev', 'template', 'node_modules');
189
+ const { npmName, version } = templateInfo;
190
+ this.templateInfo = templateInfo;
191
+ const templateNpm = new Package({
192
+ targetPath,
193
+ storeDir,
194
+ packageName: npmName,
195
+ packageVersion: version,
196
+ });
197
+ if (!await templateNpm.exists()) {
198
+ const spinner = spinnerStart('正在下载模板...');
199
+ await sleep();
200
+ try {
201
+ await templateNpm.install();
202
+ } catch (e) {
203
+ throw e;
204
+ } finally {
205
+ spinner.stop(true);
206
+ if (await templateNpm.exists()) {
207
+ log.success('下载模板成功');
208
+ this.templateNpm = templateNpm;
209
+ }
210
+ }
211
+ } else {
212
+ const spinner = spinnerStart('正在更新模板...');
213
+ await sleep();
214
+ try {
215
+ await templateNpm.update();
216
+ } catch (e) {
217
+ throw e;
218
+ } finally {
219
+ spinner.stop(true);
220
+ if (await templateNpm.exists()) {
221
+ log.success('更新模板成功');
222
+ this.templateNpm = templateNpm;
223
+ }
224
+ }
225
+ }
226
+ }
227
+
228
+ async prepare() {
229
+ // 0. 判断项目模板是否存在
230
+ const template = await getProjectTemplate();
231
+ if (!template || template.length === 0) {
232
+ throw new Error('项目模板不存在');
233
+ }
234
+ this.template = template;
235
+ // 1. 判断当前目录是否为空
236
+ const localPath = process.cwd();
237
+ if (!this.isDirEmpty(localPath)) {
238
+ let ifContinue = false;
239
+ if (!this.force) {
240
+ // 询问是否继续创建
241
+ ifContinue = (await inquirer.prompt({
242
+ type: 'confirm',
243
+ name: 'ifContinue',
244
+ default: false,
245
+ message: '当前文件夹不为空,是否继续创建项目?',
246
+ })).ifContinue;
247
+ if (!ifContinue) {
248
+ return;
249
+ }
250
+ }
251
+ // 2. 是否启动强制更新
252
+ if (ifContinue || this.force) {
253
+ // 给用户做二次确认
254
+ const { confirmDelete } = await inquirer.prompt({
255
+ type: 'confirm',
256
+ name: 'confirmDelete',
257
+ default: false,
258
+ message: '是否确认清空当前目录下的文件?',
259
+ });
260
+ if (confirmDelete) {
261
+ // 清空当前目录
262
+ fse.emptyDirSync(localPath);
263
+ }
264
+ }
265
+ }
266
+ return this.getProjectInfo();
267
+ }
268
+
269
+ async getProjectInfo() {
270
+ function isValidName(v) {
271
+ return /^[a-zA-Z]+([-][a-zA-Z][a-zA-Z0-9]*|[_][a-zA-Z][a-zA-Z0-9]*|[a-zA-Z0-9])*$/.test(v);
272
+ }
273
+
274
+ let projectInfo = {};
275
+ let isProjectNameValid = false;
276
+ if (isValidName(this.projectName)) {
277
+ isProjectNameValid = true;
278
+ projectInfo.projectName = this.projectName;
279
+ }
280
+ // 1. 选择创建项目或组件
281
+ const { type } = await inquirer.prompt({
282
+ type: 'list',
283
+ name: 'type',
284
+ message: '请选择初始化类型',
285
+ default: TYPE_PROJECT,
286
+ choices: [{
287
+ name: '项目',
288
+ value: TYPE_PROJECT,
289
+ }, {
290
+ name: '组件',
291
+ value: TYPE_COMPONENT,
292
+ }],
293
+ });
294
+ log.verbose('type', type);
295
+ this.template = this.template.filter(template =>
296
+ template.tag.includes(type));
297
+ const title = type === TYPE_PROJECT ? '项目' : '组件';
298
+ const projectNamePrompt = {
299
+ type: 'input',
300
+ name: 'projectName',
301
+ message: `请输入${title}名称`,
302
+ default: '',
303
+ validate: function(v) {
304
+ const done = this.async();
305
+ setTimeout(function() {
306
+ // 1.首字符必须为英文字符
307
+ // 2.尾字符必须为英文或数字,不能为字符
308
+ // 3.字符仅允许"-_"
309
+ if (!isValidName(v)) {
310
+ done(`请输入合法的${title}名称`);
311
+ return;
312
+ }
313
+ done(null, true);
314
+ }, 0);
315
+ },
316
+ filter: function(v) {
317
+ return v;
318
+ },
319
+ };
320
+ const projectPrompt = [];
321
+ if (!isProjectNameValid) {
322
+ projectPrompt.push(projectNamePrompt);
323
+ }
324
+ projectPrompt.push({
325
+ type: 'input',
326
+ name: 'projectVersion',
327
+ message: `请输入${title}版本号`,
328
+ default: '1.0.0',
329
+ validate: function(v) {
330
+ const done = this.async();
331
+ setTimeout(function() {
332
+ if (!(!!semver.valid(v))) {
333
+ done('请输入合法的版本号');
334
+ return;
335
+ }
336
+ done(null, true);
337
+ }, 0);
338
+ },
339
+ filter: function(v) {
340
+ if (!!semver.valid(v)) {
341
+ return semver.valid(v);
342
+ } else {
343
+ return v;
344
+ }
345
+ },
346
+ },
347
+ {
348
+ type: 'list',
349
+ name: 'projectTemplate',
350
+ message: `请选择${title}模板`,
351
+ choices: this.createTemplateChoice(),
352
+ });
353
+ if (type === TYPE_PROJECT) {
354
+ // 2. 获取项目的基本信息
355
+ const project = await inquirer.prompt(projectPrompt);
356
+ projectInfo = {
357
+ ...projectInfo,
358
+ type,
359
+ ...project,
360
+ };
361
+ } else if (type === TYPE_COMPONENT) {
362
+ const descriptionPrompt = {
363
+ type: 'input',
364
+ name: 'componentDescription',
365
+ message: '请输入组件描述信息',
366
+ default: '',
367
+ validate: function(v) {
368
+ const done = this.async();
369
+ setTimeout(function() {
370
+ if (!v) {
371
+ done('请输入组件描述信息');
372
+ return;
373
+ }
374
+ done(null, true);
375
+ }, 0);
376
+ },
377
+ };
378
+ projectPrompt.push(descriptionPrompt);
379
+ // 2. 获取组件的基本信息
380
+ const component = await inquirer.prompt(projectPrompt);
381
+ projectInfo = {
382
+ ...projectInfo,
383
+ type,
384
+ ...component,
385
+ };
386
+ }
387
+ // 生成classname
388
+ if (projectInfo.projectName) {
389
+ projectInfo.name = projectInfo.projectName;
390
+ projectInfo.className = require('kebab-case')(projectInfo.projectName).replace(/^-/, '');
391
+ }
392
+ if (projectInfo.projectVersion) {
393
+ projectInfo.version = projectInfo.projectVersion;
394
+ }
395
+ if (projectInfo.componentDescription) {
396
+ projectInfo.description = projectInfo.componentDescription;
397
+ }
398
+ return projectInfo;
399
+ }
400
+
401
+ isDirEmpty(localPath) {
402
+ let fileList = fs.readdirSync(localPath);
403
+ // 文件过滤的逻辑
404
+ fileList = fileList.filter(file => (
405
+ !file.startsWith('.') && ['node_modules'].indexOf(file) < 0
406
+ ));
407
+ return !fileList || fileList.length <= 0;
408
+ }
409
+
410
+ createTemplateChoice() {
411
+ return this.template.map(item => ({
412
+ value: item.npmName,
413
+ name: item.name,
414
+ }));
415
+ }
416
+ }
417
+
418
+ function init(argv) {
419
+ return new InitCommand(argv);
420
+ }
421
+
422
+ module.exports = init;
423
+ module.exports.InitCommand = InitCommand;
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@imooc-cli-dev-gd/init",
3
+ "version": "1.0.0",
4
+ "description": "imooc-cli-dev init",
5
+ "author": "sam <247765564@qq.com>",
6
+ "homepage": "",
7
+ "license": "ISC",
8
+ "main": "lib/index.js",
9
+ "directories": {
10
+ "lib": "lib",
11
+ "test": "__tests__"
12
+ },
13
+ "files": [
14
+ "lib"
15
+ ],
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://git.imooc.com/class-110/imooc-cli-dev.git"
22
+ },
23
+ "scripts": {
24
+ "test": "echo \"Error: run tests from root\" && exit 1"
25
+ },
26
+ "dependencies": {
27
+ "@imooc-cli-dev-gd/command": "file:../../models/command",
28
+ "@imooc-cli-dev-gd/log": "file:../../utils/log",
29
+ "@imooc-cli-dev-gd/package": "file:../../models/package",
30
+ "@imooc-cli-dev-gd/request": "file:../../utils/request",
31
+ "@imooc-cli-dev-gd/utils": "file:../../utils/utils",
32
+ "ejs": "^3.1.5",
33
+ "fs-extra": "^9.0.1",
34
+ "glob": "^7.1.6",
35
+ "inquirer": "^7.3.3",
36
+ "kebab-case": "^1.0.0",
37
+ "semver": "^7.3.4",
38
+ "spinner": "^0.3.4",
39
+ "user-home": "^2.0.0"
40
+ }
41
+ }
@@ -0,0 +1,11 @@
1
+ # `@imooc-cli-dev-gd/publish`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ const publish = require('@imooc-cli-dev-gd/publish');
9
+
10
+ // TODO: DEMONSTRATE API
11
+ ```
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ const publish = require('..');
4
+
5
+ describe('@imooc-cli-dev-gd/publish', () => {
6
+ it('needs tests');
7
+ });
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const fs = require('fs');
5
+ const fse = require('fs-extra');
6
+ const Command = require('@imooc-cli-dev-gd/command');
7
+ const log = require('@imooc-cli-dev-gd/log');
8
+ const Git = require('@imooc-cli-dev-gd/git');
9
+
10
+ class PublishCommand extends Command {
11
+ init() {
12
+ // 处理参数
13
+ log.verbose('publish', this._argv, this._cmd);
14
+ this.options = {
15
+ refreshServer: this._cmd.refreshServer,
16
+ refreshToken: this._cmd.refreshToken,
17
+ refreshOwner: this._cmd.refreshOwner,
18
+ buildCmd: this._cmd.buildCmd,
19
+ };
20
+ }
21
+
22
+ async exec() {
23
+ try {
24
+ const startTime = new Date().getTime();
25
+ // 1.初始化检查
26
+ this.prepare();
27
+ // 2.Git Flow自动化
28
+ const git = new Git(this.projectInfo, this.options);
29
+ await git.prepare(); // 自动化提交准备和代码仓库初始化
30
+ await git.commit(); // 代码自动化提交
31
+ await git.publish(); // 代码云构建+云发布
32
+ // 3.云构建和云发布
33
+ const endTime = new Date().getTime();
34
+ log.info('本次发布耗时:', Math.floor((endTime - startTime) / 1000) + '秒');
35
+ } catch (e) {
36
+ log.error(e.message);
37
+ if (process.env.LOG_LEVEL === 'verbose') {
38
+ console.log(e);
39
+ }
40
+ }
41
+ }
42
+
43
+ prepare() {
44
+ // 1.确认项目是否为npm项目
45
+ const projectPath = process.cwd();
46
+ const pkgPath = path.resolve(projectPath, 'package.json');
47
+ log.verbose('package.json', pkgPath);
48
+ if (!fs.existsSync(pkgPath)) {
49
+ throw new Error('package.json不存在!');
50
+ }
51
+ // 2.确认是否包含name、version、build命令
52
+ const pkg = fse.readJsonSync(pkgPath);
53
+ const { name, version, scripts } = pkg;
54
+ log.verbose('package.json', name, version, scripts);
55
+ if (!name || !version || !scripts || !scripts.build) {
56
+ throw new Error('package.json信息不全,请检查是否存在name、version和scripts(需提供build命令)!');
57
+ }
58
+ this.projectInfo = { name, version, dir: projectPath };
59
+ }
60
+ }
61
+
62
+ function init(argv) {
63
+ return new PublishCommand(argv);
64
+ }
65
+
66
+ module.exports = init;
67
+ module.exports.PublishCommand = PublishCommand;
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@imooc-cli-dev-gd/publish",
3
+ "version": "1.0.0",
4
+ "description": "> TODO: description",
5
+ "author": "sam <247765564@qq.com>",
6
+ "homepage": "",
7
+ "license": "ISC",
8
+ "main": "lib/index.js",
9
+ "directories": {
10
+ "lib": "lib",
11
+ "test": "__tests__"
12
+ },
13
+ "files": [
14
+ "lib"
15
+ ],
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://git.imooc.com/class-110/imooc-cli-dev.git"
22
+ },
23
+ "scripts": {
24
+ "test": "echo \"Error: run tests from root\" && exit 1"
25
+ },
26
+ "dependencies": {
27
+ "@imooc-cli-dev-gd/command": "file:../../models/command",
28
+ "@imooc-cli-dev-gd/log": "file:../../utils/log",
29
+ "@imooc-cli-dev-gd/git": "file:../../models/git",
30
+ "fs-extra": "^10.0.0"
31
+ }
32
+ }
@@ -0,0 +1,11 @@
1
+ # `core`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ const core = require('core');
9
+
10
+ // TODO: DEMONSTRATE API
11
+ ```
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ const core = require('..');
4
+
5
+ describe('core', () => {
6
+ it('needs tests');
7
+ });
@@ -0,0 +1,9 @@
1
+ #! /usr/bin/env node
2
+
3
+ const importLocal = require('import-local');
4
+
5
+ if (importLocal(__filename)) {
6
+ require('npmlog').info('cli', '正在使用 imooc-cli 本地版本');
7
+ } else {
8
+ require('../lib')(process.argv.slice(2));
9
+ }
@@ -0,0 +1,5 @@
1
+ const DEFAULT_CLI_HOME = '.imooc-cli-dev';
2
+
3
+ module.exports = {
4
+ DEFAULT_CLI_HOME,
5
+ };