@ones-open/cli 1.4.11-27607.928 → 2.1.1
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/bin/index.es.js +21 -16
- package/bin/types/lib/create.d.ts.map +1 -1
- package/bin/types/lib/env.d.ts.map +1 -1
- package/package.json +4 -3
- package/template/browserslist +3 -3
- package/template/_npmrc +0 -5
package/bin/index.es.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { ONESProjectTemplate, getCliVersionByMetaPath, Version, tryGitInit, renameHiddenTemplateFiles, getNpm, getPackageInNodeModulesDir } from '@ones-open/cli-utils';
|
|
2
3
|
import chalk from 'chalk';
|
|
3
4
|
import { Command, Option } from 'commander';
|
|
4
|
-
import
|
|
5
|
+
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
6
|
+
import { checkIsLegalPluginType, getPluginProjectCreatingTasks } from '@ones-open/cli-plugin';
|
|
5
7
|
import { execa } from 'execa';
|
|
6
8
|
import { pathExists, copy } from 'fs-extra';
|
|
7
9
|
import inquirer from 'inquirer';
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
+
import Listr from 'listr';
|
|
11
|
+
import { isAbsolute, join, basename, dirname } from 'path';
|
|
10
12
|
import { fileURLToPath } from 'url';
|
|
11
13
|
import envinfo from 'envinfo';
|
|
14
|
+
import { cwd } from 'process';
|
|
12
15
|
|
|
13
16
|
/* eslint-disable no-console */
|
|
14
17
|
const defaultConfig = {
|
|
@@ -33,7 +36,7 @@ function isLegalProjectType(projectType) {
|
|
|
33
36
|
return LEGAL_PROJECT_TYPE_SET.has(projectType);
|
|
34
37
|
}
|
|
35
38
|
function isLegalPolicy(policy) {
|
|
36
|
-
return LEGAL_POLICY.
|
|
39
|
+
return _includesInstanceProperty(LEGAL_POLICY).call(LEGAL_POLICY, policy);
|
|
37
40
|
}
|
|
38
41
|
async function getRootPath(currentWorkingDirectory, specificPath) {
|
|
39
42
|
const hasSpecificPath = specificPath && specificPath.length > 0;
|
|
@@ -107,13 +110,12 @@ async function installSubCli({
|
|
|
107
110
|
/**
|
|
108
111
|
* TODO: support different project types
|
|
109
112
|
*/
|
|
110
|
-
|
|
113
|
+
function getExternalTaskByTemplateType(currentWorkingDirectory, projectCreatingParams, options) {
|
|
111
114
|
const {
|
|
112
115
|
template
|
|
113
116
|
} = projectCreatingParams;
|
|
114
117
|
if (template === ONESProjectTemplate.Plugin) {
|
|
115
|
-
|
|
116
|
-
return module.getPluginProjectCreatingTasks({
|
|
118
|
+
return getPluginProjectCreatingTasks({
|
|
117
119
|
currentWorkingDirectory,
|
|
118
120
|
projectCreatingParams,
|
|
119
121
|
options
|
|
@@ -129,6 +131,7 @@ async function createProject(rawProjectName, options) {
|
|
|
129
131
|
useDefaultPreset,
|
|
130
132
|
installLocalDependencies,
|
|
131
133
|
distTag: rawDistTag,
|
|
134
|
+
pluginType,
|
|
132
135
|
policy
|
|
133
136
|
} = options;
|
|
134
137
|
const cliVersion = await getCliVersionByMetaPath(import.meta.url);
|
|
@@ -139,6 +142,9 @@ async function createProject(rawProjectName, options) {
|
|
|
139
142
|
if (!projectType || !isLegalProjectType(projectType)) {
|
|
140
143
|
throw new Error(`Illegal project type: ${projectType}`);
|
|
141
144
|
}
|
|
145
|
+
if (!checkIsLegalPluginType(pluginType)) {
|
|
146
|
+
throw new Error(`Illegal plugin type: ${pluginType}`);
|
|
147
|
+
}
|
|
142
148
|
if (!isLegalPolicy(policy)) {
|
|
143
149
|
throw new Error(`Illegal policy: ${policy}`);
|
|
144
150
|
}
|
|
@@ -198,7 +204,6 @@ async function createProject(rawProjectName, options) {
|
|
|
198
204
|
[key]: value
|
|
199
205
|
};
|
|
200
206
|
});
|
|
201
|
-
const createProject = new EnhancedListr();
|
|
202
207
|
const projectCreatingTasks = [{
|
|
203
208
|
title: 'Git init',
|
|
204
209
|
task: async (ctx, task) => {
|
|
@@ -218,22 +223,22 @@ async function createProject(rawProjectName, options) {
|
|
|
218
223
|
task: () => copyBasicTemplateFiles(projectCreatingParams.template, root)
|
|
219
224
|
}, {
|
|
220
225
|
title: 'Install sub CLI dependencies',
|
|
221
|
-
task:
|
|
226
|
+
task: () => {
|
|
222
227
|
const subCliName = `@ones-open/cli-${projectCreatingParams.template}`;
|
|
223
|
-
|
|
228
|
+
return installSubCli({
|
|
224
229
|
subCliName,
|
|
225
230
|
root,
|
|
226
231
|
installLocalDependencies,
|
|
227
232
|
distTag
|
|
228
233
|
});
|
|
229
|
-
const externalTask = await getExternalTaskByTemplateType(root, projectCreatingParams, {
|
|
230
|
-
...options,
|
|
231
|
-
distTag
|
|
232
|
-
});
|
|
233
|
-
externalTask && createProject.add(externalTask);
|
|
234
234
|
}
|
|
235
235
|
}];
|
|
236
|
-
createProject
|
|
236
|
+
const createProject = new Listr(projectCreatingTasks);
|
|
237
|
+
const externalTask = getExternalTaskByTemplateType(root, projectCreatingParams, {
|
|
238
|
+
...options,
|
|
239
|
+
distTag
|
|
240
|
+
});
|
|
241
|
+
externalTask && createProject.add(externalTask);
|
|
237
242
|
await createProject.run(projectCreatingParams);
|
|
238
243
|
console.log(chalk.bold('\nProject has been created'), `\n${chalk.bold('Project path:')} ${chalk.green(root)}`, `\n${chalk.bold('Project name:')} ${chalk.green(projectCreatingParams.name)}`, `\n${chalk.bold('Project type:')} ${chalk.green(projectCreatingParams.template)}`, `\n${chalk.bold('Project description:')} ${chalk.green(projectCreatingParams.description)}`, `\n${chalk.bold('Project sub CLI:')} ${chalk.green(`@ones-open/cli-${projectCreatingParams.template}`)}`);
|
|
239
244
|
} catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/lib/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/lib/create.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,8BAA8B,EAE/B,MAAM,sBAAsB,CAAA;AAyI7B,iBAAe,aAAa,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,8BAA8B,iBAyJ3F;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/lib/env.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/lib/env.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEjD,QAAA,MAAM,aAAa,EAAE,SAKpB,CAAA;AAED,QAAA,MAAM,cAAc,EAAE,OAGrB,CAAA;AAED,iBAAe,oBAAoB,CACjC,MAAM,GAAE,SAAyB,EACjC,OAAO,GAAE,OAAwB,iBAIlC;AAED,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,oBAAoB,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ones-open/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Command line interface for developers",
|
|
5
5
|
"bin": {
|
|
6
6
|
"ones": "./bin/index.es.js"
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@ones-open/cli-
|
|
43
|
+
"@ones-open/cli-plugin": "^2.1.1",
|
|
44
|
+
"@ones-open/cli-utils": "^2.1.1",
|
|
44
45
|
"chalk": "~5.0.1",
|
|
45
46
|
"commander": "~9.4.0",
|
|
46
47
|
"envinfo": "~7.8.1",
|
|
@@ -55,5 +56,5 @@
|
|
|
55
56
|
"@types/listr": "^0.14.4"
|
|
56
57
|
},
|
|
57
58
|
"type": "module",
|
|
58
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "1e51d94a7a0362a4d26958a4f47b116914e12e5f"
|
|
59
60
|
}
|
package/template/browserslist
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Chrome >=
|
|
1
|
+
Chrome >= 69
|
|
2
2
|
Edge >= 79
|
|
3
|
-
Firefox >=
|
|
4
|
-
Safari >=
|
|
3
|
+
Firefox >= 87
|
|
4
|
+
Safari >= 14
|
package/template/_npmrc
DELETED