@evitcastudio/kit 3.1.1 → 3.2.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.
- package/LICENSE +21 -21
- package/README.md +224 -123
- package/lib/bundle/cli/cli.js +379 -56
- package/lib/bundle/cli/kit-game-templates/multi/_gitignore +180 -180
- package/lib/bundle/cli/kit-game-templates/multi/package.json +3 -3
- package/lib/bundle/cli/kit-game-templates/multi/resource.json +1 -0
- package/lib/bundle/cli/kit-game-templates/multi/src/client/packets/s-packets.ts +4 -4
- package/lib/bundle/cli/kit-game-templates/multi/src/server/packets/c-packets.ts +4 -4
- package/lib/bundle/cli/kit-game-templates/single/_gitignore +180 -180
- package/lib/bundle/cli/kit-game-templates/single/package.json +3 -3
- package/lib/bundle/cli/kit-game-templates/single/resource.json +1 -0
- package/lib/cli/app-bundler.d.ts +29 -0
- package/lib/cli/app-bundler.d.ts.map +1 -0
- package/lib/cli/app-bundler.js +230 -0
- package/lib/cli/create.d.ts +11 -0
- package/lib/cli/create.d.ts.map +1 -0
- package/lib/cli/create.js +88 -0
- package/lib/cli/doctor.d.ts +9 -0
- package/lib/cli/doctor.d.ts.map +1 -0
- package/lib/cli/doctor.js +179 -0
- package/lib/cli/host.d.ts +49 -0
- package/lib/cli/host.d.ts.map +1 -0
- package/lib/cli/host.js +127 -0
- package/lib/cli/init.d.ts +2 -0
- package/lib/cli/init.d.ts.map +1 -1
- package/lib/cli/init.js +42 -15
- package/lib/cli/main.d.ts +22 -1
- package/lib/cli/main.d.ts.map +1 -1
- package/lib/cli/main.js +28 -1
- package/lib/cli/resource-builder.d.ts +1 -1
- package/lib/cli/resource-builder.d.ts.map +1 -1
- package/lib/cli/resource-builder.js +139 -19
- package/lib/cli/types.d.ts +12 -6
- package/lib/cli/types.d.ts.map +1 -1
- package/lib/types/vylo.d.ts +3848 -3848
- package/lib/vendor/vyi/index.js +26 -26
- package/package.json +73 -73
- package/lib/bundle/cli/kit-game-templates/multi/bun-build.ts +0 -109
- package/lib/bundle/cli/kit-game-templates/single/bun-build.ts +0 -33
- package/lib/bundle/cli/kit-game-templates/single/bun-serve.ts +0 -28
|
@@ -1,180 +1,180 @@
|
|
|
1
|
-
dist/
|
|
2
|
-
lib/
|
|
3
|
-
**/resource.json
|
|
4
|
-
tests/temp/
|
|
5
|
-
|
|
6
|
-
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
|
|
7
|
-
|
|
8
|
-
# Logs
|
|
9
|
-
|
|
10
|
-
logs
|
|
11
|
-
_.log
|
|
12
|
-
npm-debug.log_
|
|
13
|
-
yarn-debug.log*
|
|
14
|
-
yarn-error.log*
|
|
15
|
-
lerna-debug.log*
|
|
16
|
-
.pnpm-debug.log*
|
|
17
|
-
|
|
18
|
-
# Caches
|
|
19
|
-
|
|
20
|
-
.cache
|
|
21
|
-
|
|
22
|
-
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
23
|
-
|
|
24
|
-
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
|
25
|
-
|
|
26
|
-
# Runtime data
|
|
27
|
-
|
|
28
|
-
pids
|
|
29
|
-
_.pid
|
|
30
|
-
_.seed
|
|
31
|
-
*.pid.lock
|
|
32
|
-
|
|
33
|
-
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
34
|
-
|
|
35
|
-
lib-cov
|
|
36
|
-
|
|
37
|
-
# Coverage directory used by tools like istanbul
|
|
38
|
-
|
|
39
|
-
coverage
|
|
40
|
-
*.lcov
|
|
41
|
-
|
|
42
|
-
# nyc test coverage
|
|
43
|
-
|
|
44
|
-
.nyc_output
|
|
45
|
-
|
|
46
|
-
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
47
|
-
|
|
48
|
-
.grunt
|
|
49
|
-
|
|
50
|
-
# Bower dependency directory (https://bower.io/)
|
|
51
|
-
|
|
52
|
-
bower_components
|
|
53
|
-
|
|
54
|
-
# node-waf configuration
|
|
55
|
-
|
|
56
|
-
.lock-wscript
|
|
57
|
-
|
|
58
|
-
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
59
|
-
|
|
60
|
-
build/Release
|
|
61
|
-
|
|
62
|
-
# Dependency directories
|
|
63
|
-
|
|
64
|
-
node_modules/
|
|
65
|
-
jspm_packages/
|
|
66
|
-
|
|
67
|
-
# Snowpack dependency directory (https://snowpack.dev/)
|
|
68
|
-
|
|
69
|
-
web_modules/
|
|
70
|
-
|
|
71
|
-
# TypeScript cache
|
|
72
|
-
|
|
73
|
-
*.tsbuildinfo
|
|
74
|
-
|
|
75
|
-
# Optional npm cache directory
|
|
76
|
-
|
|
77
|
-
.npm
|
|
78
|
-
|
|
79
|
-
# Optional eslint cache
|
|
80
|
-
|
|
81
|
-
.eslintcache
|
|
82
|
-
|
|
83
|
-
# Optional stylelint cache
|
|
84
|
-
|
|
85
|
-
.stylelintcache
|
|
86
|
-
|
|
87
|
-
# Microbundle cache
|
|
88
|
-
|
|
89
|
-
.rpt2_cache/
|
|
90
|
-
.rts2_cache_cjs/
|
|
91
|
-
.rts2_cache_es/
|
|
92
|
-
.rts2_cache_umd/
|
|
93
|
-
|
|
94
|
-
# Optional REPL history
|
|
95
|
-
|
|
96
|
-
.node_repl_history
|
|
97
|
-
|
|
98
|
-
# Output of 'npm pack'
|
|
99
|
-
|
|
100
|
-
*.tgz
|
|
101
|
-
|
|
102
|
-
# Yarn Integrity file
|
|
103
|
-
|
|
104
|
-
.yarn-integrity
|
|
105
|
-
|
|
106
|
-
# dotenv environment variable files
|
|
107
|
-
|
|
108
|
-
.env
|
|
109
|
-
.env.development.local
|
|
110
|
-
.env.test.local
|
|
111
|
-
.env.production.local
|
|
112
|
-
.env.local
|
|
113
|
-
|
|
114
|
-
# parcel-bundler cache (https://parceljs.org/)
|
|
115
|
-
|
|
116
|
-
.parcel-cache
|
|
117
|
-
|
|
118
|
-
# Next.js build output
|
|
119
|
-
|
|
120
|
-
.next
|
|
121
|
-
out
|
|
122
|
-
|
|
123
|
-
# Nuxt.js build / generate output
|
|
124
|
-
|
|
125
|
-
.nuxt
|
|
126
|
-
dist
|
|
127
|
-
|
|
128
|
-
# Gatsby files
|
|
129
|
-
|
|
130
|
-
# Comment in the public line in if your project uses Gatsby and not Next.js
|
|
131
|
-
|
|
132
|
-
# https://nextjs.org/blog/next-9-1#public-directory-support
|
|
133
|
-
|
|
134
|
-
# public
|
|
135
|
-
|
|
136
|
-
# vuepress build output
|
|
137
|
-
|
|
138
|
-
.vuepress/dist
|
|
139
|
-
|
|
140
|
-
# vuepress v2.x temp and cache directory
|
|
141
|
-
|
|
142
|
-
.temp
|
|
143
|
-
|
|
144
|
-
# Docusaurus cache and generated files
|
|
145
|
-
|
|
146
|
-
.docusaurus
|
|
147
|
-
|
|
148
|
-
# Serverless directories
|
|
149
|
-
|
|
150
|
-
.serverless/
|
|
151
|
-
|
|
152
|
-
# FuseBox cache
|
|
153
|
-
|
|
154
|
-
.fusebox/
|
|
155
|
-
|
|
156
|
-
# DynamoDB Local files
|
|
157
|
-
|
|
158
|
-
.dynamodb/
|
|
159
|
-
|
|
160
|
-
# TernJS port file
|
|
161
|
-
|
|
162
|
-
.tern-port
|
|
163
|
-
|
|
164
|
-
# Stores VSCode versions used for testing VSCode extensions
|
|
165
|
-
|
|
166
|
-
.vscode-test
|
|
167
|
-
|
|
168
|
-
# yarn v2
|
|
169
|
-
|
|
170
|
-
.yarn/cache
|
|
171
|
-
.yarn/unplugged
|
|
172
|
-
.yarn/build-state.yml
|
|
173
|
-
.yarn/install-state.gz
|
|
174
|
-
.pnp.*
|
|
175
|
-
|
|
176
|
-
# IntelliJ based IDEs
|
|
177
|
-
.idea
|
|
178
|
-
|
|
179
|
-
# Finder (MacOS) folder config
|
|
180
|
-
.DS_Store
|
|
1
|
+
dist/
|
|
2
|
+
lib/
|
|
3
|
+
**/resource.json
|
|
4
|
+
tests/temp/
|
|
5
|
+
|
|
6
|
+
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
|
|
7
|
+
|
|
8
|
+
# Logs
|
|
9
|
+
|
|
10
|
+
logs
|
|
11
|
+
_.log
|
|
12
|
+
npm-debug.log_
|
|
13
|
+
yarn-debug.log*
|
|
14
|
+
yarn-error.log*
|
|
15
|
+
lerna-debug.log*
|
|
16
|
+
.pnpm-debug.log*
|
|
17
|
+
|
|
18
|
+
# Caches
|
|
19
|
+
|
|
20
|
+
.cache
|
|
21
|
+
|
|
22
|
+
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
23
|
+
|
|
24
|
+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
|
25
|
+
|
|
26
|
+
# Runtime data
|
|
27
|
+
|
|
28
|
+
pids
|
|
29
|
+
_.pid
|
|
30
|
+
_.seed
|
|
31
|
+
*.pid.lock
|
|
32
|
+
|
|
33
|
+
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
34
|
+
|
|
35
|
+
lib-cov
|
|
36
|
+
|
|
37
|
+
# Coverage directory used by tools like istanbul
|
|
38
|
+
|
|
39
|
+
coverage
|
|
40
|
+
*.lcov
|
|
41
|
+
|
|
42
|
+
# nyc test coverage
|
|
43
|
+
|
|
44
|
+
.nyc_output
|
|
45
|
+
|
|
46
|
+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
47
|
+
|
|
48
|
+
.grunt
|
|
49
|
+
|
|
50
|
+
# Bower dependency directory (https://bower.io/)
|
|
51
|
+
|
|
52
|
+
bower_components
|
|
53
|
+
|
|
54
|
+
# node-waf configuration
|
|
55
|
+
|
|
56
|
+
.lock-wscript
|
|
57
|
+
|
|
58
|
+
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
59
|
+
|
|
60
|
+
build/Release
|
|
61
|
+
|
|
62
|
+
# Dependency directories
|
|
63
|
+
|
|
64
|
+
node_modules/
|
|
65
|
+
jspm_packages/
|
|
66
|
+
|
|
67
|
+
# Snowpack dependency directory (https://snowpack.dev/)
|
|
68
|
+
|
|
69
|
+
web_modules/
|
|
70
|
+
|
|
71
|
+
# TypeScript cache
|
|
72
|
+
|
|
73
|
+
*.tsbuildinfo
|
|
74
|
+
|
|
75
|
+
# Optional npm cache directory
|
|
76
|
+
|
|
77
|
+
.npm
|
|
78
|
+
|
|
79
|
+
# Optional eslint cache
|
|
80
|
+
|
|
81
|
+
.eslintcache
|
|
82
|
+
|
|
83
|
+
# Optional stylelint cache
|
|
84
|
+
|
|
85
|
+
.stylelintcache
|
|
86
|
+
|
|
87
|
+
# Microbundle cache
|
|
88
|
+
|
|
89
|
+
.rpt2_cache/
|
|
90
|
+
.rts2_cache_cjs/
|
|
91
|
+
.rts2_cache_es/
|
|
92
|
+
.rts2_cache_umd/
|
|
93
|
+
|
|
94
|
+
# Optional REPL history
|
|
95
|
+
|
|
96
|
+
.node_repl_history
|
|
97
|
+
|
|
98
|
+
# Output of 'npm pack'
|
|
99
|
+
|
|
100
|
+
*.tgz
|
|
101
|
+
|
|
102
|
+
# Yarn Integrity file
|
|
103
|
+
|
|
104
|
+
.yarn-integrity
|
|
105
|
+
|
|
106
|
+
# dotenv environment variable files
|
|
107
|
+
|
|
108
|
+
.env
|
|
109
|
+
.env.development.local
|
|
110
|
+
.env.test.local
|
|
111
|
+
.env.production.local
|
|
112
|
+
.env.local
|
|
113
|
+
|
|
114
|
+
# parcel-bundler cache (https://parceljs.org/)
|
|
115
|
+
|
|
116
|
+
.parcel-cache
|
|
117
|
+
|
|
118
|
+
# Next.js build output
|
|
119
|
+
|
|
120
|
+
.next
|
|
121
|
+
out
|
|
122
|
+
|
|
123
|
+
# Nuxt.js build / generate output
|
|
124
|
+
|
|
125
|
+
.nuxt
|
|
126
|
+
dist
|
|
127
|
+
|
|
128
|
+
# Gatsby files
|
|
129
|
+
|
|
130
|
+
# Comment in the public line in if your project uses Gatsby and not Next.js
|
|
131
|
+
|
|
132
|
+
# https://nextjs.org/blog/next-9-1#public-directory-support
|
|
133
|
+
|
|
134
|
+
# public
|
|
135
|
+
|
|
136
|
+
# vuepress build output
|
|
137
|
+
|
|
138
|
+
.vuepress/dist
|
|
139
|
+
|
|
140
|
+
# vuepress v2.x temp and cache directory
|
|
141
|
+
|
|
142
|
+
.temp
|
|
143
|
+
|
|
144
|
+
# Docusaurus cache and generated files
|
|
145
|
+
|
|
146
|
+
.docusaurus
|
|
147
|
+
|
|
148
|
+
# Serverless directories
|
|
149
|
+
|
|
150
|
+
.serverless/
|
|
151
|
+
|
|
152
|
+
# FuseBox cache
|
|
153
|
+
|
|
154
|
+
.fusebox/
|
|
155
|
+
|
|
156
|
+
# DynamoDB Local files
|
|
157
|
+
|
|
158
|
+
.dynamodb/
|
|
159
|
+
|
|
160
|
+
# TernJS port file
|
|
161
|
+
|
|
162
|
+
.tern-port
|
|
163
|
+
|
|
164
|
+
# Stores VSCode versions used for testing VSCode extensions
|
|
165
|
+
|
|
166
|
+
.vscode-test
|
|
167
|
+
|
|
168
|
+
# yarn v2
|
|
169
|
+
|
|
170
|
+
.yarn/cache
|
|
171
|
+
.yarn/unplugged
|
|
172
|
+
.yarn/build-state.yml
|
|
173
|
+
.yarn/install-state.gz
|
|
174
|
+
.pnp.*
|
|
175
|
+
|
|
176
|
+
# IntelliJ based IDEs
|
|
177
|
+
.idea
|
|
178
|
+
|
|
179
|
+
# Finder (MacOS) folder config
|
|
180
|
+
.DS_Store
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
"bun": ">=1.1.0"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"build": "kit build
|
|
13
|
-
"
|
|
12
|
+
"build": "kit build",
|
|
13
|
+
"watch": "kit build --watch",
|
|
14
|
+
"host": "kit host -b"
|
|
14
15
|
},
|
|
15
16
|
"keywords": [],
|
|
16
17
|
"dependencies": {
|
|
17
18
|
"@evitcastudio/kit": "latest"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
|
-
"@evitcastudio/copy-bun-plugin": "^1.0.4",
|
|
21
21
|
"@types/bun": "latest"
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type ProjectArchitecture = 'single' | 'multi' | 'none';
|
|
2
|
+
export interface BundleAppOptions {
|
|
3
|
+
minify?: boolean;
|
|
4
|
+
obfuscate?: boolean;
|
|
5
|
+
sourcemap?: 'none' | 'linked' | 'inline' | 'external';
|
|
6
|
+
prod?: boolean;
|
|
7
|
+
verbose?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface AppBundleResult {
|
|
10
|
+
architecture: ProjectArchitecture;
|
|
11
|
+
clientBuildTime?: number;
|
|
12
|
+
serverBuildTime?: number;
|
|
13
|
+
success: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Detects the project architecture based on existing entrypoints in the source directory.
|
|
17
|
+
* @param pSrcDir - Path to the project's source directory.
|
|
18
|
+
* @returns The detected project architecture.
|
|
19
|
+
*/
|
|
20
|
+
export declare function detectArchitecture(pSrcDir: string): ProjectArchitecture;
|
|
21
|
+
/**
|
|
22
|
+
* Builds the application game code and static assets for singleplayer or multiplayer architectures.
|
|
23
|
+
* @param pProjectRoot - The project root directory.
|
|
24
|
+
* @param pOutDir - The destination output directory.
|
|
25
|
+
* @param pOptions - Build and bundling options.
|
|
26
|
+
* @returns The build result including build times and architecture.
|
|
27
|
+
*/
|
|
28
|
+
export declare function bundleApp(pProjectRoot: string, pOutDir: string, pOptions?: BundleAppOptions): Promise<AppBundleResult>;
|
|
29
|
+
//# sourceMappingURL=app-bundler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-bundler.d.ts","sourceRoot":"","sources":["../../src/cli/app-bundler.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAE9D,MAAM,WAAW,gBAAgB;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;IACtD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC5B,YAAY,EAAE,mBAAmB,CAAC;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,mBAAmB,CAYvE;AAsDD;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAE,gBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CA6KhI"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { promises as fs, existsSync } from 'node:fs';
|
|
2
|
+
import { join, dirname, extname } from 'node:path';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import Bun from 'bun';
|
|
5
|
+
/**
|
|
6
|
+
* Detects the project architecture based on existing entrypoints in the source directory.
|
|
7
|
+
* @param pSrcDir - Path to the project's source directory.
|
|
8
|
+
* @returns The detected project architecture.
|
|
9
|
+
*/
|
|
10
|
+
export function detectArchitecture(pSrcDir) {
|
|
11
|
+
const hasClientEntry = existsSync(join(pSrcDir, 'client', 'index.ts'));
|
|
12
|
+
const hasServerEntry = existsSync(join(pSrcDir, 'server', 'index.ts'));
|
|
13
|
+
const hasSingleEntry = existsSync(join(pSrcDir, 'index.ts'));
|
|
14
|
+
if (hasClientEntry || hasServerEntry) {
|
|
15
|
+
return 'multi';
|
|
16
|
+
}
|
|
17
|
+
if (hasSingleEntry) {
|
|
18
|
+
return 'single';
|
|
19
|
+
}
|
|
20
|
+
return 'none';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Recursively copies a directory to the destination.
|
|
24
|
+
* @param pSourceDir - Directory to copy from.
|
|
25
|
+
* @param pDestDir - Directory to copy to.
|
|
26
|
+
*/
|
|
27
|
+
async function copyDirectoryRecursive(pSourceDir, pDestDir) {
|
|
28
|
+
if (!existsSync(pSourceDir))
|
|
29
|
+
return;
|
|
30
|
+
const entries = await fs.readdir(pSourceDir, { withFileTypes: true });
|
|
31
|
+
await fs.mkdir(pDestDir, { recursive: true });
|
|
32
|
+
for (const entry of entries) {
|
|
33
|
+
const srcPath = join(pSourceDir, entry.name);
|
|
34
|
+
const destPath = join(pDestDir, entry.name);
|
|
35
|
+
if (entry.isDirectory()) {
|
|
36
|
+
await copyDirectoryRecursive(srcPath, destPath);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
await fs.copyFile(srcPath, destPath);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Copies static web assets (.html, .css, .ico) from source to destination.
|
|
45
|
+
* @param pSourceDir - Source directory to search.
|
|
46
|
+
* @param pDestDir - Output destination directory.
|
|
47
|
+
* @param pBaseDir - Base directory to preserve relative paths from.
|
|
48
|
+
*/
|
|
49
|
+
async function copyStaticWebFiles(pSourceDir, pDestDir, pBaseDir) {
|
|
50
|
+
if (!existsSync(pSourceDir))
|
|
51
|
+
return;
|
|
52
|
+
const entries = await fs.readdir(pSourceDir, { withFileTypes: true });
|
|
53
|
+
for (const entry of entries) {
|
|
54
|
+
const fullPath = join(pSourceDir, entry.name);
|
|
55
|
+
if (entry.isDirectory()) {
|
|
56
|
+
if (entry.name === 'vendor' || entry.name === 'resources' || entry.name === 'node_modules') {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
await copyStaticWebFiles(fullPath, pDestDir, pBaseDir);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const ext = extname(entry.name).toLowerCase();
|
|
63
|
+
if (['.html', '.css', '.ico'].includes(ext)) {
|
|
64
|
+
const relativePath = fullPath.slice(pBaseDir.length).replace(/^[/\\]+/, '');
|
|
65
|
+
const targetPath = join(pDestDir, relativePath);
|
|
66
|
+
await fs.mkdir(dirname(targetPath), { recursive: true });
|
|
67
|
+
await fs.copyFile(fullPath, targetPath);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Builds the application game code and static assets for singleplayer or multiplayer architectures.
|
|
74
|
+
* @param pProjectRoot - The project root directory.
|
|
75
|
+
* @param pOutDir - The destination output directory.
|
|
76
|
+
* @param pOptions - Build and bundling options.
|
|
77
|
+
* @returns The build result including build times and architecture.
|
|
78
|
+
*/
|
|
79
|
+
export async function bundleApp(pProjectRoot, pOutDir, pOptions = {}) {
|
|
80
|
+
const srcDir = join(pProjectRoot, 'src');
|
|
81
|
+
const architecture = detectArchitecture(srcDir);
|
|
82
|
+
const isVerbose = Boolean(pOptions.verbose);
|
|
83
|
+
if (architecture === 'none') {
|
|
84
|
+
if (isVerbose) {
|
|
85
|
+
console.log(chalk.yellow('[Kit CLI] No application entrypoint detected (src/index.ts or src/client/index.ts). Skipping code bundle.'));
|
|
86
|
+
}
|
|
87
|
+
return { architecture: 'none', success: true };
|
|
88
|
+
}
|
|
89
|
+
const isProd = Boolean(pOptions.prod);
|
|
90
|
+
const shouldMinify = isProd || Boolean(pOptions.minify);
|
|
91
|
+
const shouldObfuscate = isProd || Boolean(pOptions.obfuscate);
|
|
92
|
+
const sourcemapMode = pOptions.sourcemap ?? (isProd ? 'none' : 'linked');
|
|
93
|
+
// Read package.json banner if available
|
|
94
|
+
let banner = '';
|
|
95
|
+
const pkgPath = join(pProjectRoot, 'package.json');
|
|
96
|
+
if (existsSync(pkgPath)) {
|
|
97
|
+
try {
|
|
98
|
+
const pkg = JSON.parse(await fs.readFile(pkgPath, 'utf8'));
|
|
99
|
+
banner = [
|
|
100
|
+
'/*!',
|
|
101
|
+
` * ${pkg.name || 'game'}@${pkg.version || '1.0.0'}`,
|
|
102
|
+
` * Compiled ${new Date().toUTCString().replace(/GMT/g, 'UTC')}`,
|
|
103
|
+
' *',
|
|
104
|
+
` * ${pkg.name || 'game'} is privately licensed. All rights reserved.`,
|
|
105
|
+
` * Author: ${pkg.author ?? 'Unnamed'}`,
|
|
106
|
+
' */',
|
|
107
|
+
].join('\n');
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
// Ignored
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
if (architecture === 'single') {
|
|
115
|
+
const startStamp = Date.now();
|
|
116
|
+
const clientResult = await Bun.build({
|
|
117
|
+
entrypoints: [join(srcDir, 'index.ts')],
|
|
118
|
+
naming: 'index.js',
|
|
119
|
+
outdir: pOutDir,
|
|
120
|
+
target: 'browser',
|
|
121
|
+
banner,
|
|
122
|
+
sourcemap: sourcemapMode,
|
|
123
|
+
minify: shouldMinify ? {
|
|
124
|
+
identifiers: shouldObfuscate,
|
|
125
|
+
syntax: true,
|
|
126
|
+
whitespace: true
|
|
127
|
+
} : false
|
|
128
|
+
});
|
|
129
|
+
if (!clientResult.success) {
|
|
130
|
+
console.error(clientResult.logs);
|
|
131
|
+
throw new AggregateError(clientResult.logs, 'Client build failed');
|
|
132
|
+
}
|
|
133
|
+
await copyStaticWebFiles(srcDir, pOutDir, srcDir);
|
|
134
|
+
const rootFavicon = join(pProjectRoot, 'favicon.ico');
|
|
135
|
+
if (existsSync(rootFavicon)) {
|
|
136
|
+
await fs.copyFile(rootFavicon, join(pOutDir, 'favicon.ico'));
|
|
137
|
+
}
|
|
138
|
+
const vendorDir = join(srcDir, 'vendor');
|
|
139
|
+
if (existsSync(vendorDir)) {
|
|
140
|
+
await copyDirectoryRecursive(vendorDir, join(pOutDir, 'vendor'));
|
|
141
|
+
}
|
|
142
|
+
const elapsed = Date.now() - startStamp;
|
|
143
|
+
if (isVerbose) {
|
|
144
|
+
console.log(chalk.hex('#ffa552')(`[Kit CLI] Singleplayer Client Build took: ${elapsed}ms`));
|
|
145
|
+
}
|
|
146
|
+
return { architecture: 'single', clientBuildTime: elapsed, success: true };
|
|
147
|
+
}
|
|
148
|
+
if (architecture === 'multi') {
|
|
149
|
+
const clientEntry = join(srcDir, 'client', 'index.ts');
|
|
150
|
+
const serverEntry = join(srcDir, 'server', 'index.ts');
|
|
151
|
+
let clientElapsed = 0;
|
|
152
|
+
let serverElapsed = 0;
|
|
153
|
+
if (existsSync(clientEntry)) {
|
|
154
|
+
const clientStart = Date.now();
|
|
155
|
+
const clientResult = await Bun.build({
|
|
156
|
+
entrypoints: [clientEntry],
|
|
157
|
+
naming: 'index.js',
|
|
158
|
+
outdir: pOutDir,
|
|
159
|
+
target: 'browser',
|
|
160
|
+
banner,
|
|
161
|
+
sourcemap: sourcemapMode,
|
|
162
|
+
minify: shouldMinify ? {
|
|
163
|
+
identifiers: shouldObfuscate,
|
|
164
|
+
syntax: true,
|
|
165
|
+
whitespace: true
|
|
166
|
+
} : false
|
|
167
|
+
});
|
|
168
|
+
if (!clientResult.success) {
|
|
169
|
+
console.error(clientResult.logs);
|
|
170
|
+
throw new AggregateError(clientResult.logs, 'Multiplayer client build failed');
|
|
171
|
+
}
|
|
172
|
+
const clientSrc = join(srcDir, 'client');
|
|
173
|
+
await copyStaticWebFiles(clientSrc, pOutDir, clientSrc);
|
|
174
|
+
const clientVendor = join(clientSrc, 'vendor');
|
|
175
|
+
if (existsSync(clientVendor)) {
|
|
176
|
+
await copyDirectoryRecursive(clientVendor, join(pOutDir, 'vendor'));
|
|
177
|
+
}
|
|
178
|
+
clientElapsed = Date.now() - clientStart;
|
|
179
|
+
}
|
|
180
|
+
if (existsSync(serverEntry)) {
|
|
181
|
+
const serverStart = Date.now();
|
|
182
|
+
const serverResult = await Bun.build({
|
|
183
|
+
entrypoints: [serverEntry],
|
|
184
|
+
naming: 'server.js',
|
|
185
|
+
outdir: pOutDir,
|
|
186
|
+
target: 'node',
|
|
187
|
+
banner,
|
|
188
|
+
sourcemap: sourcemapMode,
|
|
189
|
+
minify: shouldMinify ? {
|
|
190
|
+
identifiers: shouldObfuscate,
|
|
191
|
+
syntax: true,
|
|
192
|
+
whitespace: true
|
|
193
|
+
} : false
|
|
194
|
+
});
|
|
195
|
+
if (!serverResult.success) {
|
|
196
|
+
console.error(serverResult.logs);
|
|
197
|
+
throw new AggregateError(serverResult.logs, 'Multiplayer server build failed');
|
|
198
|
+
}
|
|
199
|
+
const settingsFile = join(srcDir, 'server', 'settings.json');
|
|
200
|
+
if (existsSync(settingsFile)) {
|
|
201
|
+
await fs.copyFile(settingsFile, join(pOutDir, 'settings.json'));
|
|
202
|
+
}
|
|
203
|
+
serverElapsed = Date.now() - serverStart;
|
|
204
|
+
}
|
|
205
|
+
const rootFavicon = join(pProjectRoot, 'favicon.ico');
|
|
206
|
+
if (existsSync(rootFavicon)) {
|
|
207
|
+
await fs.copyFile(rootFavicon, join(pOutDir, 'favicon.ico'));
|
|
208
|
+
}
|
|
209
|
+
if (isVerbose) {
|
|
210
|
+
if (clientElapsed) {
|
|
211
|
+
console.log(chalk.hex('#ffa552')(`[Kit CLI] Multiplayer Client Build took: ${clientElapsed}ms`));
|
|
212
|
+
}
|
|
213
|
+
if (serverElapsed) {
|
|
214
|
+
console.log(chalk.hex('#ffa552')(`[Kit CLI] Multiplayer Server Build took: ${serverElapsed}ms`));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
architecture: 'multi',
|
|
219
|
+
clientBuildTime: clientElapsed,
|
|
220
|
+
serverBuildTime: serverElapsed,
|
|
221
|
+
success: true
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
return { architecture: 'none', success: true };
|
|
225
|
+
}
|
|
226
|
+
catch (pError) {
|
|
227
|
+
console.error(chalk.hex('#c42847')(`[Kit CLI Build Error] ${pError}`));
|
|
228
|
+
return { architecture, success: false };
|
|
229
|
+
}
|
|
230
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface CreateOptions {
|
|
2
|
+
type: string;
|
|
3
|
+
name: string;
|
|
4
|
+
verbose?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Handles creation of new boilerplate elements in a Kit project.
|
|
8
|
+
* @param pOptions - Creation configuration options.
|
|
9
|
+
*/
|
|
10
|
+
export declare function processCreate(pOptions: CreateOptions): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/cli/create.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAkDD;;;GAGG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CA0C1E"}
|