@xrystal/core 3.28.3 → 3.37.3
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/README.md +2331 -21
- package/package.json +66 -24
- package/tsconfig.base.json +15 -0
- package/x/bin/commands/create.mjs +136 -0
- package/x/bin/commands/doctor.mjs +149 -0
- package/x/bin/commands/hooks.mjs +55 -0
- package/x/bin/commands/project.mjs +126 -0
- package/x/bin/commands/release.mjs +66 -0
- package/x/bin/commands/sync-toolchain.mjs +43 -0
- package/x/bin/commands/tmp.mjs +57 -0
- package/x/bin/constants/index.mjs +6 -0
- package/x/bin/helpers/.generated/.generated-from +1 -0
- package/x/bin/helpers/.generated/tmp-schema.mjs +192 -0
- package/x/bin/helpers/banner.mjs +80 -0
- package/x/bin/helpers/build-config.mjs +342 -0
- package/x/bin/helpers/cli-help.mjs +164 -0
- package/x/bin/helpers/cli-identity.mjs +17 -0
- package/x/bin/helpers/create-target.mjs +35 -0
- package/{bin → x/bin}/helpers/index.mjs +44 -1
- package/x/bin/helpers/project-artifacts.mjs +140 -0
- package/x/bin/helpers/project-root.mjs +70 -0
- package/x/bin/helpers/runtime-info.mjs +172 -0
- package/x/bin/helpers/tmp-config.mjs +67 -0
- package/x/bin/helpers/tmp-layout.mjs +281 -0
- package/x/bin/helpers/tmp-schema.mjs +9 -0
- package/x/bin/helpers/toolchain-config.mjs +233 -0
- package/x/bin/main-cli.js +80 -0
- package/x/bin/paths.mjs +14 -0
- package/x/bin/scripts/clean-source-types.mjs +19 -0
- package/x/bin/scripts/fix-dist-imports.mjs +80 -0
- package/x/bin/scripts/install-git-hooks.mjs +86 -0
- package/x/bin/scripts/minify-dist.mjs +50 -0
- package/x/bin/scripts/prepare-npm-publish.mjs +49 -0
- package/x/bin/scripts/release-prepare.mjs +56 -0
- package/x/bin/scripts/tag.mjs +17 -0
- package/x/bin/scripts/unpublish-leaked-versions.mjs +62 -0
- package/x/bin/scripts/verify-npm-pack.mjs +45 -0
- package/x/bin/scripts/verify-version-bump.mjs +27 -0
- package/x/bin/scripts/version-check.mjs +370 -0
- package/x/dist/index.d.ts +3 -0
- package/x/dist/index.js +1 -0
- package/{source → x/dist}/loader/clients/index.d.ts +2 -1
- package/x/dist/loader/clients/index.js +1 -0
- package/{source → x/dist}/loader/configs/index.d.ts +3 -2
- package/x/dist/loader/configs/index.js +1 -0
- package/x/dist/loader/controller/index.d.ts +69 -0
- package/x/dist/loader/controller/index.js +1 -0
- package/x/dist/loader/dto/index.d.ts +39 -0
- package/x/dist/loader/dto/index.js +1 -0
- package/{source → x/dist}/loader/events/index.d.ts +1 -1
- package/x/dist/loader/events/index.js +1 -0
- package/{source → x/dist}/loader/index.d.ts +2 -1
- package/x/dist/loader/index.js +1 -0
- package/{source → x/dist}/loader/kafka/index.d.ts +6 -3
- package/x/dist/loader/kafka/index.js +1 -0
- package/{source → x/dist}/loader/localizations/index.d.ts +4 -3
- package/x/dist/loader/localizations/index.js +1 -0
- package/{source → x/dist}/loader/logger/index.d.ts +10 -7
- package/x/dist/loader/logger/index.js +2 -0
- package/x/dist/loader/service/index.js +1 -0
- package/{source → x/dist}/loader/system/index.d.ts +4 -3
- package/x/dist/loader/system/index.js +1 -0
- package/{source → x/dist}/project/index.d.ts +2 -2
- package/x/dist/project/index.js +1 -0
- package/x/dist/utils/constants/defaults.json +44 -0
- package/x/dist/utils/constants/index.d.ts +27 -0
- package/x/dist/utils/constants/index.js +1 -0
- package/x/dist/utils/helpers/configs/index.js +1 -0
- package/x/dist/utils/helpers/context/controller-store.d.ts +51 -0
- package/x/dist/utils/helpers/context/controller-store.js +1 -0
- package/x/dist/utils/helpers/context/index.d.ts +18 -0
- package/x/dist/utils/helpers/context/index.js +1 -0
- package/{source → x/dist}/utils/helpers/core/index.d.ts +8 -6
- package/x/dist/utils/helpers/core/index.js +1 -0
- package/x/dist/utils/helpers/core/paths.d.ts +2 -0
- package/x/dist/utils/helpers/core/paths.js +1 -0
- package/x/dist/utils/helpers/core/tmp-layout.d.ts +45 -0
- package/x/dist/utils/helpers/core/tmp-layout.js +1 -0
- package/{source → x/dist}/utils/helpers/date/index.d.ts +1 -1
- package/x/dist/utils/helpers/date/index.js +1 -0
- package/x/dist/utils/helpers/dispatch/index.d.ts +9 -0
- package/x/dist/utils/helpers/dispatch/index.js +1 -0
- package/x/dist/utils/helpers/dto/index.d.ts +10 -0
- package/x/dist/utils/helpers/dto/index.js +1 -0
- package/x/dist/utils/helpers/filters/index.js +1 -0
- package/x/dist/utils/helpers/framework/index.d.ts +3 -0
- package/x/dist/utils/helpers/framework/index.js +1 -0
- package/x/dist/utils/helpers/handlers/adapters.d.ts +10 -0
- package/x/dist/utils/helpers/handlers/adapters.js +1 -0
- package/x/dist/utils/helpers/handlers/execute.d.ts +5 -0
- package/x/dist/utils/helpers/handlers/execute.js +1 -0
- package/x/dist/utils/helpers/handlers/index.d.ts +18 -0
- package/x/dist/utils/helpers/handlers/index.js +1 -0
- package/x/dist/utils/helpers/hash/crypto.js +1 -0
- package/x/dist/utils/helpers/id/index.js +1 -0
- package/x/dist/utils/helpers/index.d.ts +26 -0
- package/x/dist/utils/helpers/index.js +1 -0
- package/x/dist/utils/helpers/ip/index.js +1 -0
- package/x/dist/utils/helpers/is/index.js +1 -0
- package/{source → x/dist}/utils/helpers/locales/index.d.ts +1 -0
- package/x/dist/utils/helpers/locales/index.js +1 -0
- package/x/dist/utils/helpers/math/index.js +1 -0
- package/x/dist/utils/helpers/middleware/index.d.ts +19 -0
- package/x/dist/utils/helpers/middleware/index.js +1 -0
- package/x/dist/utils/helpers/objects/index.js +1 -0
- package/x/dist/utils/helpers/path/index.js +1 -0
- package/x/dist/utils/helpers/protocol/index.d.ts +20 -0
- package/x/dist/utils/helpers/protocol/index.js +1 -0
- package/x/dist/utils/helpers/protocol/options.d.ts +6 -0
- package/x/dist/utils/helpers/protocol/options.js +1 -0
- package/x/dist/utils/helpers/regex/checkSpecialRegexControl.js +1 -0
- package/x/dist/utils/helpers/runtime/dto-access.d.ts +3 -0
- package/x/dist/utils/helpers/runtime/dto-access.js +1 -0
- package/x/dist/utils/helpers/runtime/dto-types.d.ts +19 -0
- package/x/dist/utils/helpers/runtime/dto-types.js +1 -0
- package/x/dist/utils/helpers/runtime/index.d.ts +3 -0
- package/x/dist/utils/helpers/runtime/index.js +1 -0
- package/x/dist/utils/helpers/runtime/shutdown.d.ts +3 -0
- package/x/dist/utils/helpers/runtime/shutdown.js +1 -0
- package/x/dist/utils/helpers/state/index.d.ts +59 -0
- package/x/dist/utils/helpers/state/index.js +1 -0
- package/x/dist/utils/helpers/state/props-from-tmp.d.ts +9 -0
- package/x/dist/utils/helpers/state/props-from-tmp.js +1 -0
- package/x/dist/utils/helpers/state/request-key-guard.d.ts +3 -0
- package/x/dist/utils/helpers/state/request-key-guard.js +1 -0
- package/x/dist/utils/helpers/state/scopes.d.ts +21 -0
- package/x/dist/utils/helpers/state/scopes.js +1 -0
- package/x/dist/utils/helpers/string/index.js +1 -0
- package/x/dist/utils/helpers/tests/tmp-schema.test.js +1 -0
- package/{source/utils/models/types/index.js → x/dist/utils/helpers/tests/tmp-watch.test.d.ts} +0 -1
- package/x/dist/utils/helpers/tests/tmp-watch.test.js +1 -0
- package/x/dist/utils/helpers/timer/index.js +1 -0
- package/x/dist/utils/helpers/tmp/index.d.ts +5 -0
- package/x/dist/utils/helpers/tmp/index.js +1 -0
- package/x/dist/utils/helpers/tmp/loader-tmp-sync.d.ts +4 -0
- package/x/dist/utils/helpers/tmp/loader-tmp-sync.js +1 -0
- package/x/dist/utils/helpers/tmp/runtime-tmp.d.ts +9 -0
- package/x/dist/utils/helpers/tmp/runtime-tmp.js +1 -0
- package/x/dist/utils/helpers/tmp/tmp-loader.d.ts +7 -0
- package/x/dist/utils/helpers/tmp/tmp-loader.js +1 -0
- package/x/dist/utils/helpers/tmp/tmp-schema.d.ts +47 -0
- package/x/dist/utils/helpers/tmp/tmp-schema.js +1 -0
- package/x/dist/utils/helpers/tmp/tmp-watch.d.ts +1 -0
- package/x/dist/utils/helpers/tmp/tmp-watch.js +1 -0
- package/x/dist/utils/helpers/validates/index.js +1 -0
- package/x/dist/utils/index.d.ts +3 -0
- package/x/dist/utils/index.js +1 -0
- package/x/dist/utils/models/classes/class.clients.js +1 -0
- package/x/dist/utils/models/classes/class.interfaces.js +1 -0
- package/x/dist/utils/models/classes/class.service-locator.js +1 -0
- package/{source → x/dist}/utils/models/classes/class.tmp-file-loader.d.ts +3 -2
- package/x/dist/utils/models/classes/class.tmp-file-loader.js +1 -0
- package/x/dist/utils/models/classes/class.x.js +1 -0
- package/{source → x/dist}/utils/models/enums/index.d.ts +14 -1
- package/x/dist/utils/models/enums/index.js +1 -0
- package/x/dist/utils/models/index.d.ts +9 -0
- package/x/dist/utils/models/index.js +1 -0
- package/x/dist/utils/models/types/index.d.ts +5 -0
- package/x/dist/utils/models/types/index.js +1 -0
- package/x/dist/utils/package-root.d.ts +2 -0
- package/x/dist/utils/package-root.js +1 -0
- package/x/tmp.yml +48 -17
- package/bin/constants/index.mjs +0 -17
- package/bin/main-cli.js +0 -131
- package/source/index.js +0 -6
- package/source/loader/clients/index.js +0 -18
- package/source/loader/configs/index.js +0 -81
- package/source/loader/controller/index.d.ts +0 -129
- package/source/loader/controller/index.js +0 -327
- package/source/loader/events/index.js +0 -44
- package/source/loader/index.js +0 -10
- package/source/loader/kafka/index.js +0 -122
- package/source/loader/localizations/index.js +0 -40
- package/source/loader/logger/index.js +0 -183
- package/source/loader/service/index.js +0 -7
- package/source/loader/system/index.js +0 -19
- package/source/project/index.js +0 -66
- package/source/utils/constants/index.d.ts +0 -10
- package/source/utils/constants/index.js +0 -11
- package/source/utils/helpers/configs/index.js +0 -1
- package/source/utils/helpers/core/index.js +0 -105
- package/source/utils/helpers/date/index.js +0 -48
- package/source/utils/helpers/filters/index.js +0 -44
- package/source/utils/helpers/hash/crypto.js +0 -22
- package/source/utils/helpers/id/index.js +0 -24
- package/source/utils/helpers/index.d.ts +0 -17
- package/source/utils/helpers/index.js +0 -17
- package/source/utils/helpers/ip/index.js +0 -21
- package/source/utils/helpers/is/index.js +0 -35
- package/source/utils/helpers/locales/index.js +0 -63
- package/source/utils/helpers/math/index.js +0 -14
- package/source/utils/helpers/middlewares/index.d.ts +0 -1
- package/source/utils/helpers/middlewares/index.js +0 -26
- package/source/utils/helpers/objects/index.js +0 -55
- package/source/utils/helpers/path/index.js +0 -4
- package/source/utils/helpers/regex/checkSpecialRegexControl.js +0 -3
- package/source/utils/helpers/string/index.js +0 -9
- package/source/utils/helpers/timer/index.js +0 -5
- package/source/utils/helpers/validates/index.js +0 -20
- package/source/utils/index.d.ts +0 -3
- package/source/utils/index.js +0 -3
- package/source/utils/models/classes/class.clients.js +0 -142
- package/source/utils/models/classes/class.dtos.d.ts +0 -47
- package/source/utils/models/classes/class.dtos.js +0 -36
- package/source/utils/models/classes/class.interfaces.js +0 -10
- package/source/utils/models/classes/class.response.d.ts +0 -17
- package/source/utils/models/classes/class.response.js +0 -35
- package/source/utils/models/classes/class.service-locator.js +0 -16
- package/source/utils/models/classes/class.tmp-file-loader.js +0 -38
- package/source/utils/models/classes/class.x.js +0 -179
- package/source/utils/models/enums/index.js +0 -133
- package/source/utils/models/index.d.ts +0 -11
- package/source/utils/models/index.js +0 -11
- package/source/utils/models/types/index.d.ts +0 -3
- /package/{source → x/dist}/loader/service/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/configs/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/filters/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/hash/crypto.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/id/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/ip/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/is/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/math/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/objects/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/path/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/regex/checkSpecialRegexControl.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/string/index.d.ts +0 -0
- /package/{source/index.d.ts → x/dist/utils/helpers/tests/tmp-schema.test.d.ts} +0 -0
- /package/{source → x/dist}/utils/helpers/timer/index.d.ts +0 -0
- /package/{source → x/dist}/utils/helpers/validates/index.d.ts +0 -0
- /package/{source → x/dist}/utils/models/classes/class.clients.d.ts +0 -0
- /package/{source → x/dist}/utils/models/classes/class.interfaces.d.ts +0 -0
- /package/{source → x/dist}/utils/models/classes/class.service-locator.d.ts +0 -0
- /package/{source → x/dist}/utils/models/classes/class.x.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Yusuf Yasir KAYGUSUZ",
|
|
3
3
|
"name": "@xrystal/core",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.37.3",
|
|
5
5
|
"description": "Project core for xrystal",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public",
|
|
@@ -12,52 +12,94 @@
|
|
|
12
12
|
"url": "git+https://github.com/xdloper/-xrystal-core.git"
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
|
-
"
|
|
16
|
-
"bin",
|
|
17
|
-
"x",
|
|
15
|
+
"x/dist",
|
|
16
|
+
"x/bin",
|
|
17
|
+
"x/tmp.yml",
|
|
18
|
+
"x/assets",
|
|
19
|
+
"tsconfig.base.json",
|
|
18
20
|
"README.md"
|
|
19
21
|
],
|
|
20
|
-
"main": "
|
|
21
|
-
"types": "./index.d.ts",
|
|
22
|
+
"main": "./x/dist/index.js",
|
|
23
|
+
"types": "./x/dist/index.d.ts",
|
|
22
24
|
"exports": {
|
|
25
|
+
"./tsconfig.base.json": "./tsconfig.base.json",
|
|
23
26
|
".": {
|
|
24
|
-
"types": "./
|
|
25
|
-
"default": "./
|
|
27
|
+
"types": "./x/dist/index.d.ts",
|
|
28
|
+
"default": "./x/dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./utils": {
|
|
31
|
+
"types": "./x/dist/utils/index.d.ts",
|
|
32
|
+
"default": "./x/dist/utils/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./loader": {
|
|
35
|
+
"types": "./x/dist/loader/index.d.ts",
|
|
36
|
+
"default": "./x/dist/loader/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./loader/controller": {
|
|
39
|
+
"types": "./x/dist/loader/controller/index.d.ts",
|
|
40
|
+
"default": "./x/dist/loader/controller/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./loader/dto": {
|
|
43
|
+
"types": "./x/dist/loader/dto/index.d.ts",
|
|
44
|
+
"default": "./x/dist/loader/dto/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./project": {
|
|
47
|
+
"types": "./x/dist/project/index.d.ts",
|
|
48
|
+
"default": "./x/dist/project/index.js"
|
|
26
49
|
}
|
|
27
50
|
},
|
|
28
51
|
"type": "module",
|
|
29
52
|
"bin": {
|
|
30
|
-
"
|
|
53
|
+
"xcore": "./x/bin/main-cli.js",
|
|
54
|
+
"xrystal": "./x/bin/main-cli.js",
|
|
55
|
+
"tmp": "./x/bin/main-cli.js"
|
|
31
56
|
},
|
|
32
57
|
"scripts": {
|
|
33
|
-
"dev": "
|
|
34
|
-
"build": "
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
58
|
+
"dev": "node x/bin/main-cli.js dev",
|
|
59
|
+
"build": "node x/bin/main-cli.js build",
|
|
60
|
+
"test": "bun test x/tests",
|
|
61
|
+
"lint": "eslint source",
|
|
62
|
+
"prepublishOnly": "bun run release:prepare",
|
|
63
|
+
"release:prepare": "bun run lint && bun run build && bun test x/tests",
|
|
64
|
+
"build:prod": "bun run release:prepare && node x/bin/scripts/clean-source-types.mjs",
|
|
65
|
+
"build:dev": "node x/bin/main-cli.js dev",
|
|
66
|
+
"start": "node x/bin/main-cli.js start",
|
|
67
|
+
"tag": "node x/bin/scripts/tag.mjs",
|
|
68
|
+
"version:check": "node x/bin/scripts/version-check.mjs",
|
|
69
|
+
"hooks:install": "node x/bin/scripts/install-git-hooks.mjs"
|
|
38
70
|
},
|
|
39
71
|
"dependencies": {
|
|
40
|
-
"
|
|
72
|
+
"@xrystal/dto": "^26.6.28-v1",
|
|
41
73
|
"awilix": "^12.0.5",
|
|
42
|
-
"
|
|
74
|
+
"chalk": "^5.6.2",
|
|
75
|
+
"commander": "^13.0.0",
|
|
43
76
|
"handlebars": "^4.7.8",
|
|
44
|
-
"winston": "^3.19.0",
|
|
45
|
-
"winston-daily-rotate-file": "^5.0.0",
|
|
46
|
-
"winston-mongodb": "^7.0.1",
|
|
47
|
-
"kafkajs": "^2.2.4",
|
|
48
77
|
"i18next": "^25.6.3",
|
|
49
78
|
"i18next-fs-backend": "^2.6.1",
|
|
50
79
|
"i18next-http-middleware": "^3.8.2",
|
|
80
|
+
"kafkajs": "^2.2.4",
|
|
81
|
+
"lodash": "^4.17.23",
|
|
51
82
|
"ora": "^9.0.0",
|
|
83
|
+
"picocolors": "^1.1.1",
|
|
52
84
|
"qs": "^6.14.1",
|
|
53
85
|
"soap": "^1.6.3",
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
86
|
+
"winston": "^3.19.0",
|
|
87
|
+
"winston-daily-rotate-file": "^5.0.0",
|
|
88
|
+
"winston-mongodb": "^7.0.1",
|
|
89
|
+
"yaml": "^2.5.0",
|
|
90
|
+
"zustand": "^5.0.14"
|
|
57
91
|
},
|
|
58
92
|
"devDependencies": {
|
|
93
|
+
"@eslint/js": "^10.0.1",
|
|
94
|
+
"@types/bun": "^1.3.5",
|
|
59
95
|
"@types/lodash": "^4.17.23",
|
|
96
|
+
"@types/qs": "^6.14.0",
|
|
60
97
|
"@types/yaml": "^1.9.7",
|
|
61
|
-
"
|
|
98
|
+
"elysia": "^1.4.19",
|
|
99
|
+
"eslint": "^10.6.0",
|
|
100
|
+
"express": "^5.2.1",
|
|
101
|
+
"tsc-alias": "^1.8.16",
|
|
102
|
+
"typescript": "~5.9.3",
|
|
103
|
+
"typescript-eslint": "^8.62.1"
|
|
62
104
|
}
|
|
63
105
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"baseUrl": ".",
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"forceConsistentCasingInFileNames": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"noImplicitAny": true,
|
|
12
|
+
"noEmitOnError": false,
|
|
13
|
+
"declarationMap": false
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { execSync } from 'node:child_process'
|
|
2
|
+
import fs from 'node:fs'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import chalk from 'chalk'
|
|
5
|
+
import ora from 'ora'
|
|
6
|
+
import yaml from 'yaml'
|
|
7
|
+
|
|
8
|
+
import { Constants } from '../constants/index.mjs'
|
|
9
|
+
import { resolveObjWithHandlebars } from '../helpers/index.mjs'
|
|
10
|
+
import { resolveCreateTarget } from '../helpers/create-target.mjs'
|
|
11
|
+
import {
|
|
12
|
+
ensureTmpFile,
|
|
13
|
+
resolveMainFolderPath,
|
|
14
|
+
} from '../helpers/tmp-layout.mjs'
|
|
15
|
+
import { formatLoaderSummary, summarizeLoaders } from '../helpers/tmp-config.mjs'
|
|
16
|
+
import { formatCreateHelp, formatCreateCommandHelp, LIST_BULLET } from '../helpers/cli-help.mjs'
|
|
17
|
+
import { setupProjectGitHooks } from '../scripts/install-git-hooks.mjs'
|
|
18
|
+
|
|
19
|
+
export function registerCreateCommand(cli, { cliName = 'xcore', runtimeName, packageManager, installCommand, devCommand }) {
|
|
20
|
+
cli
|
|
21
|
+
.command('create <project-name> [target-path]')
|
|
22
|
+
.description('Scaffold new service from GitHub template')
|
|
23
|
+
.option('-f, --force', 'Allow creating in a non-empty directory')
|
|
24
|
+
.action(async (projectName, targetDir, options) => {
|
|
25
|
+
const name = projectName?.trim()
|
|
26
|
+
if (!name) {
|
|
27
|
+
console.error(chalk.red('\n✗ project-name is required\n'))
|
|
28
|
+
console.log(formatCreateHelp({ cliName }))
|
|
29
|
+
process.exit(1)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let targetPath
|
|
33
|
+
let isCurrentDir
|
|
34
|
+
try {
|
|
35
|
+
;({ targetPath, isCurrentDir } = resolveCreateTarget(name, targetDir))
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
38
|
+
process.exit(1)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (fs.existsSync(targetPath)) {
|
|
42
|
+
const entries = fs.readdirSync(targetPath)
|
|
43
|
+
if (entries.length > 0 && !options.force) {
|
|
44
|
+
console.log(chalk.red(`\n✗ Target directory is not empty: ${targetPath}`))
|
|
45
|
+
console.log(chalk.gray(' Use --force to proceed anyway.\n'))
|
|
46
|
+
process.exit(1)
|
|
47
|
+
}
|
|
48
|
+
if (entries.length === 0) fs.rmdirSync(targetPath)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const spinner = ora(`${runtimeName} — cloning template...`).start()
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
if (isCurrentDir) {
|
|
55
|
+
execSync(`git clone --depth 1 ${Constants.templateRepoUri} .`, { cwd: targetPath, stdio: 'ignore' })
|
|
56
|
+
} else {
|
|
57
|
+
fs.mkdirSync(path.dirname(targetPath), { recursive: true })
|
|
58
|
+
execSync(`git clone --depth 1 ${Constants.templateRepoUri} "${targetPath}"`, { stdio: 'ignore' })
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const gitFolder = path.join(targetPath, '.git')
|
|
62
|
+
if (fs.existsSync(gitFolder)) fs.rmSync(gitFolder, { recursive: true, force: true })
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
execSync('git init', { cwd: targetPath, stdio: 'ignore' })
|
|
66
|
+
} catch {
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const tmpResult = ensureTmpFile(targetPath)
|
|
70
|
+
const parsedTmp = yaml.parse(fs.readFileSync(tmpResult.tmpFilePath, 'utf8'))
|
|
71
|
+
const resolvedTmp = resolveObjWithHandlebars(parsedTmp, parsedTmp)
|
|
72
|
+
const mainPath = resolveMainFolderPath(resolvedTmp?.configs)
|
|
73
|
+
const projectMainFolderPath = path.resolve(targetPath, mainPath)
|
|
74
|
+
|
|
75
|
+
if (!fs.existsSync(projectMainFolderPath)) {
|
|
76
|
+
fs.mkdirSync(projectMainFolderPath, { recursive: true })
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
spinner.succeed(chalk.green('Template cloned and git initialized'))
|
|
80
|
+
console.log(chalk.blue(`\n📦 Installing dependencies (${packageManager})...`))
|
|
81
|
+
|
|
82
|
+
execSync(installCommand, { cwd: targetPath, stdio: 'inherit' })
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
const hookResult = setupProjectGitHooks(targetPath, { cliName })
|
|
86
|
+
console.log(
|
|
87
|
+
hookResult.refreshed
|
|
88
|
+
? chalk.yellow(' pre-commit hook refreshed')
|
|
89
|
+
: chalk.green(' pre-commit hook installed'),
|
|
90
|
+
)
|
|
91
|
+
console.log(chalk.gray(` hook: ${hookResult.hookPath}`))
|
|
92
|
+
} catch (hookError) {
|
|
93
|
+
console.log(chalk.yellow(` pre-commit hook skipped: ${hookError.message}`))
|
|
94
|
+
console.log(chalk.gray(` run later: ${cliName} hooks install`))
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
let loaderSummary = null
|
|
98
|
+
try {
|
|
99
|
+
loaderSummary = summarizeLoaders(resolvedTmp)
|
|
100
|
+
} catch {
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
console.log(chalk.green('\n✓ Project ready\n'))
|
|
104
|
+
console.log(chalk.gray(` tmp: ${path.relative(process.cwd(), tmpResult.tmpFilePath) || tmpResult.tmpFilePath}`))
|
|
105
|
+
|
|
106
|
+
if (loaderSummary) {
|
|
107
|
+
console.log(chalk.cyan.bold('\n Loaders & config\n'))
|
|
108
|
+
for (const line of formatLoaderSummary(loaderSummary)) {
|
|
109
|
+
const [key, ...rest] = line.split(': ')
|
|
110
|
+
console.log(` ${LIST_BULLET} ${chalk.white(key)}${rest.length ? chalk.gray(`: ${rest.join(': ')}`) : ''}`)
|
|
111
|
+
}
|
|
112
|
+
console.log('')
|
|
113
|
+
console.log(chalk.dim(' HTTP → dtoMiddleware() + ctr()'))
|
|
114
|
+
console.log(chalk.dim(' WS → realtimeMiddleware() + ctr({ protocol: "ws" })'))
|
|
115
|
+
console.log('')
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const relativePath = path.relative(process.cwd(), targetPath)
|
|
119
|
+
if (relativePath && relativePath !== '.') console.log(chalk.cyan(` cd ${relativePath}`))
|
|
120
|
+
console.log(chalk.cyan(` ${devCommand}\n`))
|
|
121
|
+
} catch (err) {
|
|
122
|
+
spinner.fail(chalk.red('Project creation failed'))
|
|
123
|
+
console.error(chalk.red(`\n${err.message}\n`))
|
|
124
|
+
|
|
125
|
+
if (fs.existsSync(targetPath) && !isCurrentDir) {
|
|
126
|
+
const files = fs.readdirSync(targetPath)
|
|
127
|
+
if (files.length < 5) {
|
|
128
|
+
fs.rmSync(targetPath, { recursive: true, force: true })
|
|
129
|
+
console.log(chalk.yellow(`🧹 Cleaned up ${targetPath}\n`))
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
process.exit(1)
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
|
|
3
|
+
import { printCommandHeader } from '../helpers/banner.mjs'
|
|
4
|
+
import { resolveDistLayout } from '../helpers/project-artifacts.mjs'
|
|
5
|
+
import {
|
|
6
|
+
getInstalledCoreVersion,
|
|
7
|
+
getProjectRoot,
|
|
8
|
+
readCliPackageJson,
|
|
9
|
+
readProjectPackageJson,
|
|
10
|
+
} from '../helpers/project-root.mjs'
|
|
11
|
+
import { listRuntimeInventory, resolveRuntimeInfo } from '../helpers/runtime-info.mjs'
|
|
12
|
+
import { evaluateVersionBump, getLatestTagVersion, getVersionState, VERSION_PATTERN } from '../scripts/version-check.mjs'
|
|
13
|
+
import { auditTsconfigAlignment, resolveToolchainPathsFromProject } from '../helpers/toolchain-config.mjs'
|
|
14
|
+
import { isGitHookInstalled } from '../scripts/install-git-hooks.mjs'
|
|
15
|
+
|
|
16
|
+
function statusValue(value, okLabel = null) {
|
|
17
|
+
if (value == null || value === '') return chalk.gray('—')
|
|
18
|
+
return okLabel ?? value
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function printSection(title) {
|
|
22
|
+
console.log(chalk.bold.cyan(`\n ${title}`))
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function registerDoctorCommand(cli, { cliName = 'xcore' } = {}) {
|
|
26
|
+
cli
|
|
27
|
+
.command('doctor')
|
|
28
|
+
.description('Check runtime, git, and @xrystal/core alignment')
|
|
29
|
+
.action(async () => {
|
|
30
|
+
const root = getProjectRoot()
|
|
31
|
+
const cliPkg = readCliPackageJson()
|
|
32
|
+
const projectPkg = readProjectPackageJson(root)
|
|
33
|
+
const core = getInstalledCoreVersion(root)
|
|
34
|
+
const runtime = resolveRuntimeInfo(root)
|
|
35
|
+
let distLayout = null
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
distLayout = resolveDistLayout(root)
|
|
39
|
+
} catch {
|
|
40
|
+
distLayout = null
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
printCommandHeader({ cliName, command: 'doctor', version: cliPkg.version })
|
|
44
|
+
|
|
45
|
+
const inventory = listRuntimeInventory(runtime)
|
|
46
|
+
|
|
47
|
+
function printRuntimeRow(item) {
|
|
48
|
+
const label = item.label.padEnd(18)
|
|
49
|
+
if (!item.version && !item.path) {
|
|
50
|
+
console.log(` ${label}${chalk.gray('—')}`)
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
const versionText = item.version ? chalk.white(item.version) : chalk.gray('—')
|
|
54
|
+
const activeMark = item.active ? chalk.green(' · active') : ''
|
|
55
|
+
const pathText = item.path ? chalk.gray(` · ${item.path}`) : ''
|
|
56
|
+
console.log(` ${label}${versionText}${activeMark}${pathText}`)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
printSection('Environment')
|
|
60
|
+
console.log(` ${'platform'.padEnd(18)}${chalk.bold(runtime.platform)} ${chalk.gray(`(${runtime.osRelease})`)}`)
|
|
61
|
+
console.log(` ${'CLI host'.padEnd(18)}${chalk.bold(`${runtime.cliHostLabel} ${runtime.cliHostVersion}`)} ${chalk.gray(`(${runtime.cliHost})`)}`)
|
|
62
|
+
console.log(` ${'git'.padEnd(18)}${statusValue(runtime.git, runtime.git ? chalk.gray(runtime.git) : null)}`)
|
|
63
|
+
console.log(` ${'package manager'.padEnd(18)}${chalk.bold(runtime.packageManager)} ${chalk.gray('(lockfile)')}`)
|
|
64
|
+
|
|
65
|
+
printSection('Runtimes (PATH)')
|
|
66
|
+
for (const item of inventory.executables) printRuntimeRow(item)
|
|
67
|
+
|
|
68
|
+
printSection('Node version managers')
|
|
69
|
+
for (const item of inventory.managers) printRuntimeRow(item)
|
|
70
|
+
|
|
71
|
+
printSection('Project')
|
|
72
|
+
console.log(` ${'root'.padEnd(18)}${chalk.bold(root)}`)
|
|
73
|
+
if (distLayout) {
|
|
74
|
+
console.log(` ${'tmp root'.padEnd(18)}${chalk.bold(distLayout.rootFolderPath)} ${chalk.gray('(paths.root)')}`)
|
|
75
|
+
console.log(` ${'source'.padEnd(18)}${chalk.bold(distLayout.layout.mainFolderPath)} ${chalk.gray('(paths.source)')}`)
|
|
76
|
+
console.log(` ${'dist'.padEnd(18)}${chalk.bold(distLayout.distPrefix)} ${chalk.gray('(paths.special.dist)')}`)
|
|
77
|
+
} else {
|
|
78
|
+
console.log(chalk.yellow(' layout: tmp.yml not resolved — run xcore tmp'))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
printSection('CLI (tool)')
|
|
82
|
+
console.log(` ${'@xrystal/core'.padEnd(18)}${chalk.bold(`${cliPkg.name}@${cliPkg.version}`)}`)
|
|
83
|
+
|
|
84
|
+
printSection('Package')
|
|
85
|
+
console.log(` ${'name'.padEnd(18)}${chalk.bold(projectPkg.name)}`)
|
|
86
|
+
console.log(` ${'version'.padEnd(18)}${chalk.bold(projectPkg.version)}`)
|
|
87
|
+
console.log(` ${'semver'.padEnd(18)}${VERSION_PATTERN.test(projectPkg.version) ? chalk.green('valid') : chalk.yellow('check format')}`)
|
|
88
|
+
|
|
89
|
+
if (core.declared) {
|
|
90
|
+
console.log(` ${'dependency'.padEnd(18)}${core.declared}`)
|
|
91
|
+
}
|
|
92
|
+
if (core.installed) {
|
|
93
|
+
const latestHint = core.installed === cliPkg.version ? chalk.green('matches CLI') : chalk.yellow(`CLI is ${cliPkg.version}`)
|
|
94
|
+
console.log(` ${'node_modules'.padEnd(18)}${chalk.bold(core.installed)} ${latestHint}`)
|
|
95
|
+
} else if (!core.isWorkspace) {
|
|
96
|
+
console.log(chalk.yellow(` ${'node_modules'.padEnd(18)}not installed`))
|
|
97
|
+
}
|
|
98
|
+
if (core.installed && core.installed !== cliPkg.version && !core.isWorkspace) {
|
|
99
|
+
console.log('')
|
|
100
|
+
console.log(chalk.bold.red(' ⚠ CLI / node_modules version mismatch'))
|
|
101
|
+
console.log(chalk.yellow(` CLI (this binary): ${cliPkg.version}`))
|
|
102
|
+
console.log(chalk.yellow(` node_modules installed: ${core.installed}`))
|
|
103
|
+
console.log(chalk.gray(` fix: bun add @xrystal/core@${cliPkg.version}`))
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
printSection('Git')
|
|
107
|
+
|
|
108
|
+
try {
|
|
109
|
+
const state = getVersionState('HEAD', root)
|
|
110
|
+
console.log(` ${'branch'.padEnd(18)}${state.branch}`)
|
|
111
|
+
console.log(` ${'HEAD version'.padEnd(18)}${state.committed.version}`)
|
|
112
|
+
console.log(` ${'disk version'.padEnd(18)}${state.disk.version}`)
|
|
113
|
+
console.log(` ${'version match'.padEnd(18)}${state.versionMatch ? chalk.green('yes') : chalk.red('no')}`)
|
|
114
|
+
console.log(` ${'package.json'.padEnd(18)}${state.isPackageJsonClean ? chalk.green('committed') : chalk.yellow('dirty')}`)
|
|
115
|
+
const latestTag = getLatestTagVersion(root)
|
|
116
|
+
console.log(` ${'latest tag'.padEnd(18)}${latestTag ? `v${latestTag}` : chalk.gray('none')}`)
|
|
117
|
+
const evaluation = evaluateVersionBump(state.committed.version, 'HEAD', root)
|
|
118
|
+
if (evaluation.baselineVersion) {
|
|
119
|
+
const bumpText = evaluation.ok
|
|
120
|
+
? chalk.green(`ok (${evaluation.status})`)
|
|
121
|
+
: chalk.red(`must be > ${evaluation.baselineVersion}`)
|
|
122
|
+
console.log(` bump vs ${evaluation.baselineLabel}: ${bumpText}`)
|
|
123
|
+
} else {
|
|
124
|
+
console.log(` ${'bump check'.padEnd(18)}${chalk.green('first release baseline')}`)
|
|
125
|
+
}
|
|
126
|
+
console.log(` ${'working tree'.padEnd(18)}${state.isClean ? chalk.green('clean') : chalk.yellow('dirty')}`)
|
|
127
|
+
const hookOk = isGitHookInstalled(root)
|
|
128
|
+
console.log(` ${'pre-commit hook'.padEnd(18)}${hookOk ? chalk.green('installed') : chalk.yellow('missing')} ${chalk.gray('· xcore hooks install')}`)
|
|
129
|
+
} catch (error) {
|
|
130
|
+
console.log(chalk.yellow(` git: ${error.message}`))
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
printSection('Toolchain')
|
|
134
|
+
const toolchain = resolveToolchainPathsFromProject(root)
|
|
135
|
+
console.log(` ${'source'.padEnd(18)}${chalk.bold(toolchain.mainSourceRel)}`)
|
|
136
|
+
console.log(` ${'outDir'.padEnd(18)}${chalk.bold(toolchain.outDir)}`)
|
|
137
|
+
const tsAudit = auditTsconfigAlignment(root)
|
|
138
|
+
if (tsAudit.missing) {
|
|
139
|
+
console.log(chalk.yellow(` ${'tsconfig'.padEnd(18)}missing · run xcore sync-toolchain`))
|
|
140
|
+
} else if (tsAudit.ok) {
|
|
141
|
+
console.log(chalk.green(` ${'tsconfig'.padEnd(18)}aligned with tmp.yml`))
|
|
142
|
+
} else {
|
|
143
|
+
console.log(chalk.yellow(` ${'tsconfig'.padEnd(18)}drift from tmp.yml`))
|
|
144
|
+
for (const note of tsAudit.notes) console.log(chalk.gray(` · ${note}`))
|
|
145
|
+
}
|
|
146
|
+
console.log(` ${'eslint'.padEnd(18)}${toolchain.eslintFiles.join(', ')}`)
|
|
147
|
+
console.log('')
|
|
148
|
+
})
|
|
149
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
|
|
3
|
+
import { printCommandHeader } from '../helpers/banner.mjs'
|
|
4
|
+
import { readCliPackageJson } from '../helpers/project-root.mjs'
|
|
5
|
+
import { installGitHooks, isGitHookInstalled } from '../scripts/install-git-hooks.mjs'
|
|
6
|
+
import { getProjectRoot } from '../helpers/project-root.mjs'
|
|
7
|
+
|
|
8
|
+
export function registerHooksCommand(cli, { cliName = 'xcore' } = {}) {
|
|
9
|
+
const hooks = cli
|
|
10
|
+
.command('hooks')
|
|
11
|
+
.description('Install git hooks for version bump checks')
|
|
12
|
+
.addHelpText(
|
|
13
|
+
'after',
|
|
14
|
+
`
|
|
15
|
+
${chalk.gray('Examples:')}
|
|
16
|
+
${cliName} hooks install
|
|
17
|
+
${cliName} hooks status
|
|
18
|
+
`,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
hooks
|
|
22
|
+
.command('install')
|
|
23
|
+
.description('Write pre-commit hook to .git/hooks (core repo + services)')
|
|
24
|
+
.action(() => {
|
|
25
|
+
try {
|
|
26
|
+
const root = getProjectRoot()
|
|
27
|
+
printCommandHeader({ cliName, command: 'hooks install', version: readCliPackageJson().version })
|
|
28
|
+
|
|
29
|
+
if (isGitHookInstalled(root)) {
|
|
30
|
+
console.log(chalk.yellow(' pre-commit hook already installed — refreshing'))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const result = installGitHooks(root)
|
|
34
|
+
console.log(chalk.green('\n✓ pre-commit hook installed\n'))
|
|
35
|
+
console.log(chalk.gray(` project: ${result.root}`))
|
|
36
|
+
console.log(chalk.gray(` hook: ${result.hookPath}`))
|
|
37
|
+
console.log(chalk.gray(` checker: ${result.scriptPath}`))
|
|
38
|
+
console.log(chalk.dim('\n Runs on git commit when package.json version changes.\n'))
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
41
|
+
process.exit(1)
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
hooks
|
|
46
|
+
.command('status')
|
|
47
|
+
.description('Show whether @xrystal/core pre-commit hook is installed')
|
|
48
|
+
.action(() => {
|
|
49
|
+
const root = getProjectRoot()
|
|
50
|
+
printCommandHeader({ cliName, command: 'hooks status', version: readCliPackageJson().version })
|
|
51
|
+
const installed = isGitHookInstalled(root)
|
|
52
|
+
console.log(` pre-commit: ${installed ? chalk.green('installed') : chalk.yellow('not installed')}`)
|
|
53
|
+
console.log(chalk.gray(` fix: ${cliName} hooks install\n`))
|
|
54
|
+
})
|
|
55
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { execSync } from 'node:child_process'
|
|
2
|
+
import fs from 'node:fs'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import chalk from 'chalk'
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
isCorePackageName,
|
|
8
|
+
readTmpBuildContext,
|
|
9
|
+
resolveCoreBuildSteps,
|
|
10
|
+
resolveDevEntry,
|
|
11
|
+
resolveDistEntryAbs,
|
|
12
|
+
resolveEnvFiles,
|
|
13
|
+
resolveServiceBuildSteps,
|
|
14
|
+
shouldDelegatePackageBuild,
|
|
15
|
+
summarizeBuildPlan,
|
|
16
|
+
} from '../helpers/build-config.mjs'
|
|
17
|
+
import { getProjectRoot } from '../helpers/project-root.mjs'
|
|
18
|
+
import { printCommandHeader } from '../helpers/banner.mjs'
|
|
19
|
+
import { readCliPackageJson } from '../helpers/project-root.mjs'
|
|
20
|
+
import { ensureTmpFile, relativeFromRoot } from '../helpers/tmp-layout.mjs'
|
|
21
|
+
import { ensureProjectArtifacts } from '../helpers/project-artifacts.mjs'
|
|
22
|
+
|
|
23
|
+
function runInProject(root, command) {
|
|
24
|
+
execSync(command, { cwd: root, stdio: 'inherit', env: process.env })
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function resolveTestTarget(root) {
|
|
28
|
+
const layout = ensureTmpFile(root).layout
|
|
29
|
+
if (fs.existsSync(layout.pathsAbs.tests)) {
|
|
30
|
+
return relativeFromRoot(root, layout.pathsAbs.tests)
|
|
31
|
+
}
|
|
32
|
+
throw new Error(
|
|
33
|
+
`No test directory found (expected ${layout.rootFolderPath}/${layout.paths.tests} from tmp.yml).`,
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function registerProjectCommands(cli, { cliName = 'xcore' } = {}) {
|
|
38
|
+
cli
|
|
39
|
+
.command('dev')
|
|
40
|
+
.description('Watch source/index.ts with dev env files')
|
|
41
|
+
.action(() => {
|
|
42
|
+
const root = getProjectRoot()
|
|
43
|
+
const { layout } = readTmpBuildContext(root)
|
|
44
|
+
const entry = resolveDevEntry(root, layout)
|
|
45
|
+
const envFiles = resolveEnvFiles(layout.pathsAbs.environments, ['.global.env', '.dev.env'])
|
|
46
|
+
const envArgs = envFiles.map((file) => `--env-file=${file}`).join(' ')
|
|
47
|
+
|
|
48
|
+
printCommandHeader({ cliName, command: 'dev', version: readCliPackageJson().version })
|
|
49
|
+
console.log(chalk.gray(` root: ${root}`))
|
|
50
|
+
console.log(chalk.gray(` entry: ${entry} (.ts)\n`))
|
|
51
|
+
runInProject(root, `bun --watch ${envArgs} ${entry}`.trim())
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
cli
|
|
55
|
+
.command('build')
|
|
56
|
+
.description('Bundle to dist/ (Bun + optional tsc)')
|
|
57
|
+
.action(() => {
|
|
58
|
+
const root = getProjectRoot()
|
|
59
|
+
ensureProjectArtifacts(root, { writeToolchain: true, writeManifest: true })
|
|
60
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'))
|
|
61
|
+
|
|
62
|
+
printCommandHeader({ cliName, command: 'build', version: readCliPackageJson().version })
|
|
63
|
+
console.log(chalk.gray(` root: ${root}`))
|
|
64
|
+
|
|
65
|
+
if (shouldDelegatePackageBuild(pkg)) {
|
|
66
|
+
runInProject(root, 'bun run build')
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const { layout, build } = readTmpBuildContext(root)
|
|
71
|
+
const plan = summarizeBuildPlan(root, layout, build)
|
|
72
|
+
const steps = isCorePackageName(pkg.name)
|
|
73
|
+
? resolveCoreBuildSteps(root, plan.distRel, build)
|
|
74
|
+
: resolveServiceBuildSteps(root, layout, build)
|
|
75
|
+
console.log(chalk.gray(` mode: ${isCorePackageName(pkg.name) ? 'core entries' : 'service tsconfig + tmp overrides'}`))
|
|
76
|
+
if (plan.tsconfigRel) {
|
|
77
|
+
console.log(chalk.gray(` tsconfig: ${plan.tsconfigRel}`))
|
|
78
|
+
}
|
|
79
|
+
console.log(chalk.gray(` dist: ${plan.distRel}/ (${plan.distSource})`))
|
|
80
|
+
console.log(chalk.gray(` glob: ${plan.entryGlobs.join(', ')} (${plan.globSource})`))
|
|
81
|
+
if (plan.typecheck) console.log(chalk.gray(' typecheck: tsc --noEmit'))
|
|
82
|
+
if (plan.declarations) console.log(chalk.gray(' declarations: tsc --emitDeclarationOnly'))
|
|
83
|
+
if (plan.sourcemap !== 'false') console.log(chalk.gray(` sourcemap: ${plan.sourcemap}`))
|
|
84
|
+
if (plan.minify && plan.minify !== 'off') console.log(chalk.gray(` minify: ${plan.minify}`))
|
|
85
|
+
console.log('')
|
|
86
|
+
|
|
87
|
+
runInProject(root, steps.join(' && '))
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
cli
|
|
91
|
+
.command('start')
|
|
92
|
+
.alias('start:dist')
|
|
93
|
+
.description('Run dist/index.js with prod env files')
|
|
94
|
+
.action(() => {
|
|
95
|
+
const root = getProjectRoot()
|
|
96
|
+
const { layout, build } = readTmpBuildContext(root)
|
|
97
|
+
const entryAbs = resolveDistEntryAbs(root, layout, build)
|
|
98
|
+
|
|
99
|
+
if (!fs.existsSync(entryAbs)) {
|
|
100
|
+
throw new Error(
|
|
101
|
+
`Build output not found: ${path.relative(root, entryAbs)}. Run ${cliName} build first.`,
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const entry = relativeFromRoot(root, entryAbs)
|
|
106
|
+
const envFiles = resolveEnvFiles(layout.pathsAbs.environments, ['.global.env', '.prod.env'])
|
|
107
|
+
const envArgs = envFiles.map((file) => `--env-file=${file}`).join(' ')
|
|
108
|
+
|
|
109
|
+
printCommandHeader({ cliName, command: 'start', version: readCliPackageJson().version })
|
|
110
|
+
console.log(chalk.gray(` root: ${root}`))
|
|
111
|
+
console.log(chalk.gray(` entry: ${entry} (.js)\n`))
|
|
112
|
+
runInProject(root, `bun ${envArgs} ${entry}`.trim())
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
cli
|
|
116
|
+
.command('test')
|
|
117
|
+
.description('Run tests from tmp.yml paths')
|
|
118
|
+
.action(() => {
|
|
119
|
+
const root = getProjectRoot()
|
|
120
|
+
const target = resolveTestTarget(root)
|
|
121
|
+
|
|
122
|
+
printCommandHeader({ cliName, command: 'test', version: readCliPackageJson().version })
|
|
123
|
+
console.log(chalk.gray(` target: ${target}\n`))
|
|
124
|
+
runInProject(root, `bun test ${target}`)
|
|
125
|
+
})
|
|
126
|
+
}
|