@ones-open/cli 0.50.0 → 1.0.1-10001.1957
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/LICENSE +201 -674
- package/bin/ones.js +4 -0
- package/dist/index.cjs +1589 -0
- package/dist/index.js +1588 -0
- package/dist/types/actions/build/index.d.ts +4 -0
- package/dist/types/actions/build/index.d.ts.map +1 -0
- package/dist/types/actions/build/normalize.d.ts +6 -0
- package/dist/types/actions/build/normalize.d.ts.map +1 -0
- package/dist/types/actions/build/regexp.d.ts +2 -0
- package/dist/types/actions/build/regexp.d.ts.map +1 -0
- package/dist/types/actions/dev/enums.d.ts +6 -0
- package/dist/types/actions/dev/enums.d.ts.map +1 -0
- package/dist/types/actions/dev/index.d.ts +4 -0
- package/dist/types/actions/dev/index.d.ts.map +1 -0
- package/dist/types/actions/dev/normalize.d.ts +6 -0
- package/dist/types/actions/dev/normalize.d.ts.map +1 -0
- package/dist/types/actions/dev/types.d.ts +10 -0
- package/dist/types/actions/dev/types.d.ts.map +1 -0
- package/dist/types/actions/disable/index.d.ts +4 -0
- package/dist/types/actions/disable/index.d.ts.map +1 -0
- package/dist/types/actions/disable/normalize.d.ts +6 -0
- package/dist/types/actions/disable/normalize.d.ts.map +1 -0
- package/dist/types/actions/enable/index.d.ts +4 -0
- package/dist/types/actions/enable/index.d.ts.map +1 -0
- package/dist/types/actions/enable/normalize.d.ts +6 -0
- package/dist/types/actions/enable/normalize.d.ts.map +1 -0
- package/dist/types/actions/index.d.ts +15 -0
- package/dist/types/actions/index.d.ts.map +1 -0
- package/dist/types/actions/install/index.d.ts +5 -0
- package/dist/types/actions/install/index.d.ts.map +1 -0
- package/dist/types/actions/install/install.d.ts +3 -0
- package/dist/types/actions/install/install.d.ts.map +1 -0
- package/dist/types/actions/install/normalize.d.ts +6 -0
- package/dist/types/actions/install/normalize.d.ts.map +1 -0
- package/dist/types/actions/legacy/index.d.ts +4 -0
- package/dist/types/actions/legacy/index.d.ts.map +1 -0
- package/dist/types/actions/legacy/normalize.d.ts +6 -0
- package/dist/types/actions/legacy/normalize.d.ts.map +1 -0
- package/dist/types/actions/login/consts.d.ts +2 -0
- package/dist/types/actions/login/consts.d.ts.map +1 -0
- package/dist/types/actions/login/index.d.ts +4 -0
- package/dist/types/actions/login/index.d.ts.map +1 -0
- package/dist/types/actions/login/normalize.d.ts +6 -0
- package/dist/types/actions/login/normalize.d.ts.map +1 -0
- package/dist/types/actions/login/regexp.d.ts +2 -0
- package/dist/types/actions/login/regexp.d.ts.map +1 -0
- package/dist/types/actions/logout/index.d.ts +4 -0
- package/dist/types/actions/logout/index.d.ts.map +1 -0
- package/dist/types/actions/logout/normalize.d.ts +6 -0
- package/dist/types/actions/logout/normalize.d.ts.map +1 -0
- package/dist/types/actions/tunnel/consts.d.ts +6 -0
- package/dist/types/actions/tunnel/consts.d.ts.map +1 -0
- package/dist/types/actions/tunnel/index.d.ts +7 -0
- package/dist/types/actions/tunnel/index.d.ts.map +1 -0
- package/dist/types/actions/tunnel/normalize.d.ts +6 -0
- package/dist/types/actions/tunnel/normalize.d.ts.map +1 -0
- package/dist/types/actions/tunnel/regexp.d.ts +2 -0
- package/dist/types/actions/tunnel/regexp.d.ts.map +1 -0
- package/dist/types/actions/tunnel/tunnel-client.d.ts +25 -0
- package/dist/types/actions/tunnel/tunnel-client.d.ts.map +1 -0
- package/dist/types/actions/tunnel/tunnel.d.ts +3 -0
- package/dist/types/actions/tunnel/tunnel.d.ts.map +1 -0
- package/dist/types/actions/tunnel/types.d.ts +33 -0
- package/dist/types/actions/tunnel/types.d.ts.map +1 -0
- package/dist/types/actions/tunnel/utils.d.ts +7 -0
- package/dist/types/actions/tunnel/utils.d.ts.map +1 -0
- package/dist/types/actions/uninstall/index.d.ts +4 -0
- package/dist/types/actions/uninstall/index.d.ts.map +1 -0
- package/dist/types/actions/uninstall/normalize.d.ts +6 -0
- package/dist/types/actions/uninstall/normalize.d.ts.map +1 -0
- package/dist/types/actions/whoami/index.d.ts +4 -0
- package/dist/types/actions/whoami/index.d.ts.map +1 -0
- package/dist/types/actions/whoami/normalize.d.ts +6 -0
- package/dist/types/actions/whoami/normalize.d.ts.map +1 -0
- package/dist/types/cli/index.d.ts +2 -0
- package/dist/types/cli/index.d.ts.map +1 -0
- package/dist/types/command/app/index.d.ts +4 -0
- package/dist/types/command/app/index.d.ts.map +1 -0
- package/dist/types/command/build/index.d.ts +9 -0
- package/dist/types/command/build/index.d.ts.map +1 -0
- package/dist/types/command/dev/index.d.ts +10 -0
- package/dist/types/command/dev/index.d.ts.map +1 -0
- package/dist/types/command/disable/index.d.ts +8 -0
- package/dist/types/command/disable/index.d.ts.map +1 -0
- package/dist/types/command/enable/index.d.ts +8 -0
- package/dist/types/command/enable/index.d.ts.map +1 -0
- package/dist/types/command/index.d.ts +16 -0
- package/dist/types/command/index.d.ts.map +1 -0
- package/dist/types/command/install/index.d.ts +8 -0
- package/dist/types/command/install/index.d.ts.map +1 -0
- package/dist/types/command/legacy/index.d.ts +8 -0
- package/dist/types/command/legacy/index.d.ts.map +1 -0
- package/dist/types/command/login/index.d.ts +8 -0
- package/dist/types/command/login/index.d.ts.map +1 -0
- package/dist/types/command/logout/index.d.ts +8 -0
- package/dist/types/command/logout/index.d.ts.map +1 -0
- package/dist/types/command/tunnel/index.d.ts +8 -0
- package/dist/types/command/tunnel/index.d.ts.map +1 -0
- package/dist/types/command/uninstall/index.d.ts +8 -0
- package/dist/types/command/uninstall/index.d.ts.map +1 -0
- package/dist/types/command/whoami/index.d.ts +8 -0
- package/dist/types/command/whoami/index.d.ts.map +1 -0
- package/dist/types/common/base/index.d.ts +5 -0
- package/dist/types/common/base/index.d.ts.map +1 -0
- package/dist/types/common/base/utils.d.ts +7 -0
- package/dist/types/common/base/utils.d.ts.map +1 -0
- package/dist/types/common/command/index.d.ts +6 -0
- package/dist/types/common/command/index.d.ts.map +1 -0
- package/dist/types/common/command/types.d.ts +2 -0
- package/dist/types/common/command/types.d.ts.map +1 -0
- package/dist/types/common/command/utils.d.ts +2 -0
- package/dist/types/common/command/utils.d.ts.map +1 -0
- package/dist/types/common/config/index.d.ts +6 -0
- package/dist/types/common/config/index.d.ts.map +1 -0
- package/dist/types/common/config/types.d.ts +8 -0
- package/dist/types/common/config/types.d.ts.map +1 -0
- package/dist/types/common/config/utils.d.ts +3 -0
- package/dist/types/common/config/utils.d.ts.map +1 -0
- package/dist/types/common/context/index.d.ts +6 -0
- package/dist/types/common/context/index.d.ts.map +1 -0
- package/dist/types/common/context/types.d.ts +2 -0
- package/dist/types/common/context/types.d.ts.map +1 -0
- package/dist/types/common/context/utils.d.ts +2 -0
- package/dist/types/common/context/utils.d.ts.map +1 -0
- package/dist/types/common/error/enums.d.ts +19 -0
- package/dist/types/common/error/enums.d.ts.map +1 -0
- package/dist/types/common/error/index.d.ts +7 -0
- package/dist/types/common/error/index.d.ts.map +1 -0
- package/dist/types/common/error/types.d.ts +2 -0
- package/dist/types/common/error/types.d.ts.map +1 -0
- package/dist/types/common/error/utils.d.ts +2 -0
- package/dist/types/common/error/utils.d.ts.map +1 -0
- package/dist/types/common/locales/en/index.d.ts +34 -0
- package/dist/types/common/locales/en/index.d.ts.map +1 -0
- package/dist/types/common/locales/index.d.ts +6 -0
- package/dist/types/common/locales/index.d.ts.map +1 -0
- package/dist/types/common/locales/types.d.ts +4 -0
- package/dist/types/common/locales/types.d.ts.map +1 -0
- package/dist/types/common/locales/utils.d.ts +6 -0
- package/dist/types/common/locales/utils.d.ts.map +1 -0
- package/dist/types/common/package/index.d.ts +7 -0
- package/dist/types/common/package/index.d.ts.map +1 -0
- package/dist/types/common/package/schema.d.ts +3 -0
- package/dist/types/common/package/schema.d.ts.map +1 -0
- package/dist/types/common/package/types.d.ts +2 -0
- package/dist/types/common/package/types.d.ts.map +1 -0
- package/dist/types/common/package/utils.d.ts +14 -0
- package/dist/types/common/package/utils.d.ts.map +1 -0
- package/dist/types/common/public/consts.d.ts +2 -0
- package/dist/types/common/public/consts.d.ts.map +1 -0
- package/dist/types/common/public/index.d.ts +6 -0
- package/dist/types/common/public/index.d.ts.map +1 -0
- package/dist/types/common/public/utils.d.ts +2 -0
- package/dist/types/common/public/utils.d.ts.map +1 -0
- package/dist/types/common/request/consts.d.ts +13 -0
- package/dist/types/common/request/consts.d.ts.map +1 -0
- package/dist/types/common/request/fetch.d.ts +12 -0
- package/dist/types/common/request/fetch.d.ts.map +1 -0
- package/dist/types/common/request/index.d.ts +8 -0
- package/dist/types/common/request/index.d.ts.map +1 -0
- package/dist/types/common/request/types.d.ts +92 -0
- package/dist/types/common/request/types.d.ts.map +1 -0
- package/dist/types/common/request/utils.d.ts +8 -0
- package/dist/types/common/request/utils.d.ts.map +1 -0
- package/dist/types/common/store/index.d.ts +6 -0
- package/dist/types/common/store/index.d.ts.map +1 -0
- package/dist/types/common/store/schema.d.ts +25 -0
- package/dist/types/common/store/schema.d.ts.map +1 -0
- package/dist/types/common/store/utils.d.ts +13 -0
- package/dist/types/common/store/utils.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +57 -38
- package/public/callback.html +65 -0
- package/public/logo.svg +4 -0
- package/bin/index.es.js +0 -261
- package/bin/types/index.d.ts +0 -2
- package/bin/types/index.d.ts.map +0 -1
- package/bin/types/lib/create.d.ts +0 -4
- package/bin/types/lib/create.d.ts.map +0 -1
- package/bin/types/lib/env.d.ts +0 -6
- package/bin/types/lib/env.d.ts.map +0 -1
- package/template/_prettierignore +0 -13
- package/template/_prettierrc +0 -6
- package/template/browserslist +0 -4
- package/template/package.json +0 -5
package/index.d.ts
ADDED
package/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ones-open/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.1-10001.1957+e5e51129",
|
|
4
|
+
"description": "",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "pnpm clean && pnpm run tsc && vite build",
|
|
18
|
+
"clean": "rm -rf ./dist",
|
|
19
|
+
"test": "tsc --noEmit --emitDeclarationOnly false",
|
|
20
|
+
"tsc": "tsc && tsc-alias"
|
|
7
21
|
},
|
|
8
|
-
"files": [
|
|
9
|
-
"bin",
|
|
10
|
-
"template"
|
|
11
|
-
],
|
|
12
|
-
"main": "./bin/index.es.js",
|
|
13
22
|
"engines": {
|
|
14
23
|
"node": ">=16.13.0"
|
|
15
24
|
},
|
|
@@ -17,44 +26,54 @@
|
|
|
17
26
|
"ones"
|
|
18
27
|
],
|
|
19
28
|
"author": {
|
|
20
|
-
"name": "
|
|
21
|
-
"email": "
|
|
22
|
-
"url": "https://www.yuque.com/htmlin"
|
|
29
|
+
"name": "lixinliang",
|
|
30
|
+
"email": "lixinliang@ones.cn"
|
|
23
31
|
},
|
|
24
|
-
"
|
|
32
|
+
"maintainers": [
|
|
25
33
|
{
|
|
26
|
-
"name": "
|
|
27
|
-
"email": "laijiehui@ones.ai",
|
|
28
|
-
"url": "https://github.com/luckyJeffy"
|
|
34
|
+
"name": "ones"
|
|
29
35
|
}
|
|
30
36
|
],
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
+
"files": [
|
|
38
|
+
"bin",
|
|
39
|
+
"dist",
|
|
40
|
+
"index.d.ts",
|
|
41
|
+
"index.js",
|
|
42
|
+
"public",
|
|
43
|
+
"template"
|
|
44
|
+
],
|
|
45
|
+
"bin": {
|
|
46
|
+
"ones": "./bin/ones.js"
|
|
37
47
|
},
|
|
38
|
-
"license": "
|
|
48
|
+
"license": "Apache-2.0",
|
|
39
49
|
"publishConfig": {
|
|
50
|
+
"registry": "https://registry.npmjs.org",
|
|
40
51
|
"access": "public"
|
|
41
52
|
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/archiver": "^7.0.0",
|
|
55
|
+
"@types/fs-extra": "^11.0.4",
|
|
56
|
+
"@types/lodash-es": "^4.17.12"
|
|
57
|
+
},
|
|
42
58
|
"dependencies": {
|
|
43
|
-
"@
|
|
44
|
-
"
|
|
45
|
-
"
|
|
59
|
+
"@babel/runtime-corejs3": "~7.26.10",
|
|
60
|
+
"archiver": "^7.0.1",
|
|
61
|
+
"axios": "1.13.2",
|
|
62
|
+
"chalk": "^5.0.1",
|
|
46
63
|
"commander": "~9.4.0",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
64
|
+
"cosmiconfig": "^8.3.6",
|
|
65
|
+
"create-ones-app": "1.0.1-10001.1957+e5e51129",
|
|
66
|
+
"env-paths": "3.0.0",
|
|
67
|
+
"execa": "^6.1.0",
|
|
68
|
+
"fs-extra": "^11.3.0",
|
|
69
|
+
"get-port": "^7.1.0",
|
|
70
|
+
"lodash-es": "^4.17.21",
|
|
71
|
+
"open": "^11.0.0",
|
|
72
|
+
"ora": "^9.1.0",
|
|
73
|
+
"type-fest": "4.41.0",
|
|
74
|
+
"uuid": "^13.0.0",
|
|
75
|
+
"ws": "^8.18.3",
|
|
76
|
+
"zod": "^3.22.2"
|
|
52
77
|
},
|
|
53
|
-
"
|
|
54
|
-
"@types/envinfo": "^7.8.1",
|
|
55
|
-
"@types/inquirer": "^8.2.1",
|
|
56
|
-
"@types/listr": "^0.14.4"
|
|
57
|
-
},
|
|
58
|
-
"type": "module",
|
|
59
|
-
"gitHead": "3f0a9d4e2dbd8e34f90a09c9614107a7b62d9460"
|
|
78
|
+
"gitHead": "e5e51129d48f958f3601bad876aad064946c29a9"
|
|
60
79
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta
|
|
6
|
+
name="viewport"
|
|
7
|
+
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
|
|
8
|
+
/>
|
|
9
|
+
<title>ONES Open Platform</title>
|
|
10
|
+
<style type="text/css">
|
|
11
|
+
.app-loading {
|
|
12
|
+
animation-duration: 0.5s;
|
|
13
|
+
animation-timing-function: ease-in-out;
|
|
14
|
+
animation-fill-mode: both;
|
|
15
|
+
display: inline-block;
|
|
16
|
+
width: 32px;
|
|
17
|
+
height: 32px;
|
|
18
|
+
margin: auto;
|
|
19
|
+
position: absolute;
|
|
20
|
+
top: 0;
|
|
21
|
+
left: 0;
|
|
22
|
+
bottom: 0;
|
|
23
|
+
right: 0;
|
|
24
|
+
vertical-align: middle;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.app-loading-inner {
|
|
28
|
+
width: 100%;
|
|
29
|
+
height: 100%;
|
|
30
|
+
display: inline-block;
|
|
31
|
+
box-sizing: border-box;
|
|
32
|
+
border: solid 2px transparent;
|
|
33
|
+
border-top-color: #0064ff;
|
|
34
|
+
border-left-color: #0064ff;
|
|
35
|
+
border-radius: 50%;
|
|
36
|
+
animation: nprogress-spinner 400ms linear infinite;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@keyframes nprogress-spinner {
|
|
40
|
+
0% {
|
|
41
|
+
transform: rotate(0deg);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
100% {
|
|
45
|
+
transform: rotate(360deg);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
</style>
|
|
49
|
+
</head>
|
|
50
|
+
<body>
|
|
51
|
+
<div id="app-loading" class="app-loading">
|
|
52
|
+
<div class="app-loading-inner"></div>
|
|
53
|
+
</div>
|
|
54
|
+
<script>
|
|
55
|
+
;(function () {
|
|
56
|
+
const searchParams = new URLSearchParams(window.location.search)
|
|
57
|
+
const url = searchParams.get('redirect_url')
|
|
58
|
+
searchParams.delete('redirect_url')
|
|
59
|
+
if (url) {
|
|
60
|
+
window.open(`${url}?${searchParams}`, '_self')
|
|
61
|
+
}
|
|
62
|
+
})()
|
|
63
|
+
</script>
|
|
64
|
+
</body>
|
|
65
|
+
</html>
|
package/public/logo.svg
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect width="16" height="16" rx="2" fill="#0064FF"/>
|
|
3
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.43816 2.66672C6.82458 2.66672 6.31279 3.17606 6.31279 3.82228V4.4445C6.31279 4.68996 6.11381 4.88894 5.86835 4.88894H3.55556V6.70091H4.56017C5.68056 6.70091 6.57443 7.62426 6.57443 8.74535C6.57443 9.83706 5.70842 10.8718 4.56017 10.8718H3.55556V12.4445H10.6667V10.4274C10.6667 10.1819 10.8657 9.98296 11.1111 9.98296H12.208C12.7937 9.98296 13.3333 9.42095 13.3333 8.74535C13.3333 8.09914 12.8215 7.5898 12.208 7.5898H11.1111C10.8657 7.5898 10.6667 7.39081 10.6667 7.14535V4.88894H9.00797C8.76251 4.88894 8.56353 4.68996 8.56353 4.4445V3.82228C8.56353 3.17606 8.05174 2.66672 7.43816 2.66672ZM5.4239 3.82228C5.4239 2.70118 6.31778 1.77783 7.43816 1.77783C8.55854 1.77783 9.45242 2.70118 9.45242 3.82228V4.00005H11.1111C11.3566 4.00005 11.5556 4.19904 11.5556 4.4445V6.70091H12.208C13.3284 6.70091 14.2222 7.62426 14.2222 8.74535C14.2222 9.83706 13.3562 10.8718 12.208 10.8718H11.5556V12.8889C11.5556 13.1344 11.3566 13.3334 11.1111 13.3334H3.11112C2.86566 13.3334 2.66667 13.1344 2.66667 12.8889V10.4274C2.66667 10.1819 2.86566 9.98296 3.11112 9.98296H4.56017C5.14589 9.98296 5.68554 9.42095 5.68554 8.74535C5.68554 8.09914 5.17375 7.5898 4.56017 7.5898H3.11112C2.86566 7.5898 2.66667 7.39081 2.66667 7.14535V4.4445C2.66667 4.32662 2.7135 4.21358 2.79685 4.13023C2.8802 4.04688 2.99324 4.00005 3.11112 4.00005H5.4239V3.82228Z" fill="white"/>
|
|
4
|
+
</svg>
|
package/bin/index.es.js
DELETED
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { ONESProjectTemplate, getCliVersionByMetaPath, Version, tryGitInit, renameHiddenTemplateFiles, getNpm, getPackageInNodeModulesDir } from '@ones-open/cli-utils';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import { Command, Option } from 'commander';
|
|
5
|
-
import _includesInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/includes';
|
|
6
|
-
import { checkIsLegalPluginType, getPluginProjectCreatingTasks } from '@ones-open/cli-plugin';
|
|
7
|
-
import { execa } from 'execa';
|
|
8
|
-
import { pathExists, copy } from 'fs-extra';
|
|
9
|
-
import inquirer from 'inquirer';
|
|
10
|
-
import Listr from 'listr';
|
|
11
|
-
import { isAbsolute, join, basename, dirname } from 'path';
|
|
12
|
-
import { fileURLToPath } from 'url';
|
|
13
|
-
import envinfo from 'envinfo';
|
|
14
|
-
import { cwd } from 'process';
|
|
15
|
-
|
|
16
|
-
/* eslint-disable no-console */
|
|
17
|
-
const defaultConfig = {
|
|
18
|
-
System: ['OS', 'CPU', 'Memory', 'Shell'],
|
|
19
|
-
Binaries: ['Node', 'npm'],
|
|
20
|
-
npmPackages: ['@ones-open/cli-utils', '@ones-open/cli-plugin', '@ones-open/cli-monorepo'],
|
|
21
|
-
npmGlobalPackages: ['@ones-open/cli']
|
|
22
|
-
};
|
|
23
|
-
const defaultOptions = {
|
|
24
|
-
duplicates: true,
|
|
25
|
-
showNotFound: true
|
|
26
|
-
};
|
|
27
|
-
async function printEnvironmentInfo(config = defaultConfig, options = defaultOptions) {
|
|
28
|
-
const info = await envinfo.run(config, options);
|
|
29
|
-
console.log(chalk.bold('\nEnvironment Info:'), info);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const LEGAL_PROJECT_TYPE = Object.values(ONESProjectTemplate);
|
|
33
|
-
const LEGAL_PROJECT_TYPE_SET = new Set(LEGAL_PROJECT_TYPE);
|
|
34
|
-
const LEGAL_POLICY = ['simple', 'standard'];
|
|
35
|
-
function isLegalProjectType(projectType) {
|
|
36
|
-
return LEGAL_PROJECT_TYPE_SET.has(projectType);
|
|
37
|
-
}
|
|
38
|
-
function isLegalPolicy(policy) {
|
|
39
|
-
return _includesInstanceProperty(LEGAL_POLICY).call(LEGAL_POLICY, policy);
|
|
40
|
-
}
|
|
41
|
-
async function getRootPath(currentWorkingDirectory, specificPath) {
|
|
42
|
-
const hasSpecificPath = specificPath && specificPath.length > 0;
|
|
43
|
-
if (hasSpecificPath) {
|
|
44
|
-
// we had to check if the path is absolute or not
|
|
45
|
-
const isAbsolutePath = isAbsolute(specificPath);
|
|
46
|
-
const root = isAbsolutePath ? specificPath : join(currentWorkingDirectory, specificPath);
|
|
47
|
-
const isPathExists = await pathExists(root);
|
|
48
|
-
if (!isPathExists) {
|
|
49
|
-
throw new Error('The specific path does not exist on the file system');
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
hasSpecificPath,
|
|
53
|
-
root,
|
|
54
|
-
projectName: basename(root)
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
hasSpecificPath,
|
|
59
|
-
root: currentWorkingDirectory,
|
|
60
|
-
projectName: basename(currentWorkingDirectory)
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Copy the project basic template files
|
|
66
|
-
*
|
|
67
|
-
* We need to consider the path of current file path after complication.
|
|
68
|
-
* When we compute the path on the file system.
|
|
69
|
-
*
|
|
70
|
-
* e.g:
|
|
71
|
-
*
|
|
72
|
-
* Current file in `/Users/user/ones/cli/src/bin/index.ts`
|
|
73
|
-
* Then the location of current file after complication is `/Users/user/ones/cli/bin/index.js`
|
|
74
|
-
*/
|
|
75
|
-
async function copyBasicTemplateFiles(projectType, projectPath) {
|
|
76
|
-
const currentFilePath = fileURLToPath(import.meta.url);
|
|
77
|
-
const currentFileDir = dirname(currentFilePath);
|
|
78
|
-
const templatePath = join(currentFileDir, '../template');
|
|
79
|
-
if (projectType === ONESProjectTemplate.Monorepo) {
|
|
80
|
-
await copy(templatePath, projectPath);
|
|
81
|
-
await renameHiddenTemplateFiles(projectPath);
|
|
82
|
-
} else {
|
|
83
|
-
// Only copy the package.json for the plugin project creating
|
|
84
|
-
const basicTemplatePackageJsonPath = join(templatePath, 'package.json');
|
|
85
|
-
const packageJsonPath = join(projectPath, 'package.json');
|
|
86
|
-
await copy(basicTemplatePackageJsonPath, packageJsonPath);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
async function installSubCli({
|
|
90
|
-
root,
|
|
91
|
-
subCliName,
|
|
92
|
-
installLocalDependencies,
|
|
93
|
-
distTag
|
|
94
|
-
}) {
|
|
95
|
-
const cliNameWithVersionSuffix = `${subCliName}@${distTag}`;
|
|
96
|
-
const installCommand = getNpm();
|
|
97
|
-
const installArgs = installLocalDependencies ? ['link', subCliName, '--save-dev', '--no-optional'] : ['install', cliNameWithVersionSuffix, '--save-dev', '--no-optional'];
|
|
98
|
-
await execa(installCommand, installArgs, {
|
|
99
|
-
cwd: root,
|
|
100
|
-
stdio: 'ignore'
|
|
101
|
-
});
|
|
102
|
-
const subCliPath = getPackageInNodeModulesDir(root, subCliName);
|
|
103
|
-
const subCliPackageJsonPath = join(subCliPath, 'package.json');
|
|
104
|
-
const isSubCliInstalled = await pathExists(subCliPackageJsonPath);
|
|
105
|
-
if (!isSubCliInstalled) {
|
|
106
|
-
throw new Error(`${subCliName} does not exist in node_modules`);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* TODO: support different project types
|
|
112
|
-
*/
|
|
113
|
-
function getExternalTaskByTemplateType(currentWorkingDirectory, projectCreatingParams, options) {
|
|
114
|
-
const {
|
|
115
|
-
template
|
|
116
|
-
} = projectCreatingParams;
|
|
117
|
-
if (template === ONESProjectTemplate.Plugin) {
|
|
118
|
-
return getPluginProjectCreatingTasks({
|
|
119
|
-
currentWorkingDirectory,
|
|
120
|
-
projectCreatingParams,
|
|
121
|
-
options
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
return undefined;
|
|
125
|
-
}
|
|
126
|
-
async function createProject(rawProjectName, options) {
|
|
127
|
-
try {
|
|
128
|
-
const {
|
|
129
|
-
projectType,
|
|
130
|
-
specificPath,
|
|
131
|
-
useDefaultPreset,
|
|
132
|
-
installLocalDependencies,
|
|
133
|
-
distTag: rawDistTag,
|
|
134
|
-
pluginType,
|
|
135
|
-
policy
|
|
136
|
-
} = options;
|
|
137
|
-
const cliVersion = await getCliVersionByMetaPath(import.meta.url);
|
|
138
|
-
if (!cliVersion) throw new Error('Get sub cli version failed.');
|
|
139
|
-
const distTag = rawDistTag ? rawDistTag :
|
|
140
|
-
// Get ONES CLI major version to match correct dependencies version
|
|
141
|
-
new Version(cliVersion).major;
|
|
142
|
-
if (!projectType || !isLegalProjectType(projectType)) {
|
|
143
|
-
throw new Error(`Illegal project type: ${projectType}`);
|
|
144
|
-
}
|
|
145
|
-
if (!checkIsLegalPluginType(pluginType)) {
|
|
146
|
-
throw new Error(`Illegal plugin type: ${pluginType}`);
|
|
147
|
-
}
|
|
148
|
-
if (!isLegalPolicy(policy)) {
|
|
149
|
-
throw new Error(`Illegal policy: ${policy}`);
|
|
150
|
-
}
|
|
151
|
-
const {
|
|
152
|
-
root,
|
|
153
|
-
projectName
|
|
154
|
-
} = await getRootPath(cwd(), specificPath);
|
|
155
|
-
const defaultProjectName = rawProjectName || projectName;
|
|
156
|
-
let projectCreatingParams = {
|
|
157
|
-
template: ONESProjectTemplate.Plugin,
|
|
158
|
-
name: defaultProjectName,
|
|
159
|
-
description: '',
|
|
160
|
-
appID: ''
|
|
161
|
-
};
|
|
162
|
-
const prompts = [{
|
|
163
|
-
type: 'list',
|
|
164
|
-
name: 'template',
|
|
165
|
-
message: 'Choose a template:',
|
|
166
|
-
choices: LEGAL_PROJECT_TYPE,
|
|
167
|
-
default: projectCreatingParams.template,
|
|
168
|
-
// Temporary hide the monorepo template type until we support it
|
|
169
|
-
when: false
|
|
170
|
-
// when: !projectType || !templates.includes(projectType),
|
|
171
|
-
}, {
|
|
172
|
-
type: 'input',
|
|
173
|
-
name: 'appID',
|
|
174
|
-
message: 'Project app ID(Refer to https://developer.ones.com/docs/guide/developer-license to learn how to get the appID.):',
|
|
175
|
-
validate: rawInput => {
|
|
176
|
-
const input = rawInput.trim();
|
|
177
|
-
if (input.length === 0) return 'Project app ID is required and cannot be empty';
|
|
178
|
-
return true;
|
|
179
|
-
}
|
|
180
|
-
}, {
|
|
181
|
-
type: 'input',
|
|
182
|
-
name: 'name',
|
|
183
|
-
message: 'Project name:',
|
|
184
|
-
default: defaultProjectName,
|
|
185
|
-
validate: rawInput => {
|
|
186
|
-
const input = rawInput.trim();
|
|
187
|
-
if (input.length === 0) return 'Project name is required and cannot be empty';
|
|
188
|
-
return true;
|
|
189
|
-
},
|
|
190
|
-
when: !useDefaultPreset
|
|
191
|
-
}, {
|
|
192
|
-
type: 'input',
|
|
193
|
-
name: 'description',
|
|
194
|
-
message: 'Project description:',
|
|
195
|
-
when: !useDefaultPreset
|
|
196
|
-
}];
|
|
197
|
-
|
|
198
|
-
// display interactive prompts
|
|
199
|
-
const answers = await inquirer.prompt(prompts);
|
|
200
|
-
Object.entries(answers).forEach(([key, value]) => {
|
|
201
|
-
if (!value) return;
|
|
202
|
-
projectCreatingParams = {
|
|
203
|
-
...projectCreatingParams,
|
|
204
|
-
[key]: value
|
|
205
|
-
};
|
|
206
|
-
});
|
|
207
|
-
const projectCreatingTasks = [{
|
|
208
|
-
title: 'Git init',
|
|
209
|
-
task: async (ctx, task) => {
|
|
210
|
-
try {
|
|
211
|
-
await tryGitInit(root);
|
|
212
|
-
} catch (error) {
|
|
213
|
-
if (error instanceof Error) {
|
|
214
|
-
const {
|
|
215
|
-
message
|
|
216
|
-
} = error;
|
|
217
|
-
task.skip(message);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}, {
|
|
222
|
-
title: 'Copy basic template files',
|
|
223
|
-
task: () => copyBasicTemplateFiles(projectCreatingParams.template, root)
|
|
224
|
-
}, {
|
|
225
|
-
title: 'Install sub CLI dependencies',
|
|
226
|
-
task: () => {
|
|
227
|
-
const subCliName = `@ones-open/cli-${projectCreatingParams.template}`;
|
|
228
|
-
return installSubCli({
|
|
229
|
-
subCliName,
|
|
230
|
-
root,
|
|
231
|
-
installLocalDependencies,
|
|
232
|
-
distTag
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
}];
|
|
236
|
-
const createProject = new Listr(projectCreatingTasks);
|
|
237
|
-
const externalTask = getExternalTaskByTemplateType(root, projectCreatingParams, {
|
|
238
|
-
...options,
|
|
239
|
-
distTag
|
|
240
|
-
});
|
|
241
|
-
externalTask && createProject.add(externalTask);
|
|
242
|
-
await createProject.run(projectCreatingParams);
|
|
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}`)}`);
|
|
244
|
-
} catch (error) {
|
|
245
|
-
console.error(chalk.red(error));
|
|
246
|
-
await printEnvironmentInfo();
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
const cliVersion = (await getCliVersionByMetaPath(import.meta.url)) || 'unknown';
|
|
251
|
-
const ones = new Command('ones');
|
|
252
|
-
const gray = chalk.gray;
|
|
253
|
-
ones.version(cliVersion, '-v, --version', 'output the current version');
|
|
254
|
-
ones.command('create [project-name]').description(`create project from preset project template by type
|
|
255
|
-
${gray(`
|
|
256
|
-
Tip: if you leave the [project-name] blank and
|
|
257
|
-
1. not specified the specific path, then will use current folder name as default project name
|
|
258
|
-
2. the specific path is also specified, then will use the folder name as default project name
|
|
259
|
-
`)}`).option('-d, --use-default-preset', 'skip prompts and use default preset').option('-s, --specific-path <path>', 'create at a specific path, it will automatically detect relative or absolute path').option('--plugin-type [type]', 'support type: team, organization', 'team').option('--policy <policy>', 'support policy: simple, standard', 'simple').addOption(new Option('-t, --project-type <type>', 'the type of project template, support: monorepo, plugin').default('plugin').hideHelp(true)).addOption(new Option('--install-local-dependencies', 'development only, install local dependencies after create project').hideHelp(true)).addOption(new Option('--dist-tag <tag>', 'specify the dist tag of sub CLI dependencies, default: latest').hideHelp(true)).addOption(new Option('--ones-version <onesVersion>', 'specify the version of ONES')).action(createProject);
|
|
260
|
-
ones.command('envinfo').description('print environment info').action(printEnvironmentInfo);
|
|
261
|
-
ones.parse();
|
package/bin/types/index.d.ts
DELETED
package/bin/types/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/bin/types/lib/env.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { RunConfig, Options } from 'envinfo';
|
|
2
|
-
declare const defaultConfig: RunConfig;
|
|
3
|
-
declare const defaultOptions: Options;
|
|
4
|
-
declare function printEnvironmentInfo(config?: RunConfig, options?: Options): Promise<void>;
|
|
5
|
-
export { defaultConfig, defaultOptions, printEnvironmentInfo };
|
|
6
|
-
//# sourceMappingURL=env.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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/template/_prettierignore
DELETED
package/template/_prettierrc
DELETED
package/template/browserslist
DELETED