@evitcastudio/kit 2.3.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bundle/cli/cli.js +62 -6
- package/lib/bundle/cli/kit-game-templates/multi/_gitignore +180 -0
- package/lib/bundle/cli/kit-game-templates/multi/resource.json +1 -0
- package/lib/bundle/cli/kit-game-templates/single/_gitignore +180 -0
- package/lib/bundle/cli/kit-game-templates/single/resource.json +1 -0
- package/lib/cli/init.d.ts.map +1 -1
- package/lib/cli/init.js +47 -3
- package/package.json +1 -1
package/lib/bundle/cli/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/*!
|
|
4
|
-
* @evitcastudio/kit@
|
|
5
|
-
* Compiled Fri, 20 Mar 2026
|
|
4
|
+
* @evitcastudio/kit@3.0.0 git+https://github.com/EvitcaStudio/Kit.git
|
|
5
|
+
* Compiled Fri, 20 Mar 2026 18:35:48 UTC
|
|
6
6
|
* Copyright (c) 2026 Jared Bates, Evitca Studio, "doubleactii"
|
|
7
7
|
*
|
|
8
8
|
* @evitcastudio/kit is licensed under the MIT License.
|
|
@@ -3512,6 +3512,25 @@ var Gt = (e = "", r) => {
|
|
|
3512
3512
|
${t("gray", x2)} ` : "";
|
|
3513
3513
|
s.write(`${i}${e}
|
|
3514
3514
|
|
|
3515
|
+
`);
|
|
3516
|
+
};
|
|
3517
|
+
var jt = (e) => t("dim", e);
|
|
3518
|
+
var kt2 = (e, r, s) => {
|
|
3519
|
+
const i = { hard: true, trim: false }, a = J2(e, r, i).split(`
|
|
3520
|
+
`), o = a.reduce((n, c) => Math.max(D2(c), n), 0), u = a.map(s).reduce((n, c) => Math.max(D2(c), n), 0), l = r - (u - o);
|
|
3521
|
+
return J2(e, l, i);
|
|
3522
|
+
};
|
|
3523
|
+
var Vt2 = (e = "", r = "", s) => {
|
|
3524
|
+
const i = s?.output ?? N2.stdout, a = s?.withGuide ?? _.withGuide, o = s?.format ?? jt, u = ["", ...kt2(e, rt(i) - 6, o).split(`
|
|
3525
|
+
`).map(o), ""], l = D2(r), n = Math.max(u.reduce((g, E) => {
|
|
3526
|
+
const $ = D2(E);
|
|
3527
|
+
return $ > g ? $ : g;
|
|
3528
|
+
}, 0), l) + 2, c = u.map((g) => `${t("gray", h)} ${g}${" ".repeat(n - D2(g))}${t("gray", h)}`).join(`
|
|
3529
|
+
`), p = a ? `${t("gray", h)}
|
|
3530
|
+
` : "", f = a ? We : ge;
|
|
3531
|
+
i.write(`${p}${t("green", V)} ${t("reset", r)} ${t("gray", se.repeat(Math.max(n - l - 1, 1)) + pe)}
|
|
3532
|
+
${c}
|
|
3533
|
+
${t("gray", f + se.repeat(n + 2) + me)}
|
|
3515
3534
|
`);
|
|
3516
3535
|
};
|
|
3517
3536
|
var Kt = (e) => t("magenta", e);
|
|
@@ -3653,11 +3672,12 @@ ${l}
|
|
|
3653
3672
|
import fs2 from "node:fs";
|
|
3654
3673
|
import path from "node:path";
|
|
3655
3674
|
import { fileURLToPath } from "node:url";
|
|
3656
|
-
import { spawnSync } from "node:child_process";
|
|
3675
|
+
import { spawnSync, execSync } from "node:child_process";
|
|
3676
|
+
import os2 from "node:os";
|
|
3657
3677
|
// package.json
|
|
3658
3678
|
var package_default = {
|
|
3659
3679
|
name: "@evitcastudio/kit",
|
|
3660
|
-
version: "
|
|
3680
|
+
version: "3.0.0",
|
|
3661
3681
|
author: "doubleactii 56242467+doubleactii@users.noreply.github.com (https://evitcastudio.com)",
|
|
3662
3682
|
main: "./lib/index.js",
|
|
3663
3683
|
types: "./lib/index.d.ts",
|
|
@@ -3742,6 +3762,20 @@ function getGitUser() {
|
|
|
3742
3762
|
return "Author";
|
|
3743
3763
|
}
|
|
3744
3764
|
}
|
|
3765
|
+
function checkBun() {
|
|
3766
|
+
const result = spawnSync("bun", ["--version"], { stdio: "ignore", shell: true });
|
|
3767
|
+
return !result.error && result.status === 0;
|
|
3768
|
+
}
|
|
3769
|
+
function installBun() {
|
|
3770
|
+
const isWindows = os2.platform() === "win32";
|
|
3771
|
+
const command = isWindows ? 'powershell -c "irm bun.sh/install.ps1 | iex"' : "curl -fsSL https://bun.sh/install | bash";
|
|
3772
|
+
try {
|
|
3773
|
+
execSync(command, { stdio: "inherit" });
|
|
3774
|
+
return true;
|
|
3775
|
+
} catch {
|
|
3776
|
+
return false;
|
|
3777
|
+
}
|
|
3778
|
+
}
|
|
3745
3779
|
function copyTemplate(pSrc, pDest, pProjectName, pVersion, pAuthor) {
|
|
3746
3780
|
if (!fs2.existsSync(pDest)) {
|
|
3747
3781
|
fs2.mkdirSync(pDest, { recursive: true });
|
|
@@ -3749,7 +3783,8 @@ function copyTemplate(pSrc, pDest, pProjectName, pVersion, pAuthor) {
|
|
|
3749
3783
|
const files = fs2.readdirSync(pSrc);
|
|
3750
3784
|
for (const file of files) {
|
|
3751
3785
|
const srcPath = path.join(pSrc, file);
|
|
3752
|
-
const
|
|
3786
|
+
const destFile = file === "_gitignore" ? ".gitignore" : file;
|
|
3787
|
+
const destPath = path.join(pDest, destFile);
|
|
3753
3788
|
const stats = fs2.statSync(srcPath);
|
|
3754
3789
|
if (stats.isDirectory()) {
|
|
3755
3790
|
if (file === ".git")
|
|
@@ -3758,7 +3793,7 @@ function copyTemplate(pSrc, pDest, pProjectName, pVersion, pAuthor) {
|
|
|
3758
3793
|
} else {
|
|
3759
3794
|
const ext = path.extname(file).toLowerCase();
|
|
3760
3795
|
const textExtensions = [".ts", ".js", ".json", ".html", ".css", ".md", ".txt"];
|
|
3761
|
-
if (textExtensions.includes(ext)
|
|
3796
|
+
if (textExtensions.includes(ext)) {
|
|
3762
3797
|
let content = fs2.readFileSync(srcPath, "utf8");
|
|
3763
3798
|
content = content.replace(/{{PROJECT_NAME}}/g, pProjectName);
|
|
3764
3799
|
content = content.replace(/{{VERSION}}/g, pVersion);
|
|
@@ -3772,6 +3807,27 @@ function copyTemplate(pSrc, pDest, pProjectName, pVersion, pAuthor) {
|
|
|
3772
3807
|
}
|
|
3773
3808
|
async function processInit(pOptions) {
|
|
3774
3809
|
Wt2(source_default.cyan(`Kit CLI v${package_default.version}`));
|
|
3810
|
+
if (!checkBun()) {
|
|
3811
|
+
Vt2(`Kit requires the Bun runtime to build and run projects.
|
|
3812
|
+
You can download it manually at ${source_default.cyan("https://bun.sh/")}`, "Bun Not Found");
|
|
3813
|
+
const install = await Rt({
|
|
3814
|
+
message: "Would you like to install Bun automatically now?",
|
|
3815
|
+
initialValue: true
|
|
3816
|
+
});
|
|
3817
|
+
if (Ct(install) || !install) {
|
|
3818
|
+
Nt(`Please install Bun manually to use Kit: ${source_default.cyan("https://bun.sh/")}
|
|
3819
|
+
Note: Kit projects cannot build or run without Bun.`);
|
|
3820
|
+
process.exit(1);
|
|
3821
|
+
}
|
|
3822
|
+
const sInstall = be();
|
|
3823
|
+
sInstall.start("Installing Bun...");
|
|
3824
|
+
const success = installBun();
|
|
3825
|
+
if (!success) {
|
|
3826
|
+
sInstall.stop(source_default.red("Automatic installation failed."));
|
|
3827
|
+
Vt2(`Please install Bun manually: ${source_default.cyan("https://bun.sh/")}`, "Manual Installation Required");
|
|
3828
|
+
process.exit(1);
|
|
3829
|
+
}
|
|
3830
|
+
}
|
|
3775
3831
|
let projectName = pOptions.projectName;
|
|
3776
3832
|
let gameType = "single";
|
|
3777
3833
|
if (!pOptions.single && !pOptions.multi && !projectName) {
|
|
@@ -0,0 +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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
package/lib/cli/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":"AASA;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAyFD;;;GAGG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CA6JtE"}
|
package/lib/cli/init.js
CHANGED
|
@@ -3,7 +3,8 @@ import chalk from 'chalk';
|
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
|
-
import { spawnSync } from 'node:child_process';
|
|
6
|
+
import { spawnSync, execSync } from 'node:child_process';
|
|
7
|
+
import os from 'node:os';
|
|
7
8
|
import packageJSON from '../../package.json';
|
|
8
9
|
/**
|
|
9
10
|
* Gets the git user name and email from the local system.
|
|
@@ -22,6 +23,27 @@ function getGitUser() {
|
|
|
22
23
|
return 'Author';
|
|
23
24
|
}
|
|
24
25
|
}
|
|
26
|
+
function checkBun() {
|
|
27
|
+
const result = spawnSync('bun', ['--version'], { stdio: 'ignore', shell: true });
|
|
28
|
+
return !result.error && result.status === 0;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Installs Bun using the official installation scripts.
|
|
32
|
+
* @returns True if the installation was successful.
|
|
33
|
+
*/
|
|
34
|
+
function installBun() {
|
|
35
|
+
const isWindows = os.platform() === 'win32';
|
|
36
|
+
const command = isWindows
|
|
37
|
+
? 'powershell -c "irm bun.sh/install.ps1 | iex"'
|
|
38
|
+
: 'curl -fsSL https://bun.sh/install | bash';
|
|
39
|
+
try {
|
|
40
|
+
execSync(command, { stdio: 'inherit' });
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
25
47
|
/**
|
|
26
48
|
* Recursively copy template files and replace placeholders.
|
|
27
49
|
* @param pSrc - Source template directory.
|
|
@@ -37,7 +59,9 @@ function copyTemplate(pSrc, pDest, pProjectName, pVersion, pAuthor) {
|
|
|
37
59
|
const files = fs.readdirSync(pSrc);
|
|
38
60
|
for (const file of files) {
|
|
39
61
|
const srcPath = path.join(pSrc, file);
|
|
40
|
-
|
|
62
|
+
// Rename _gitignore back to .gitignore in the destination
|
|
63
|
+
const destFile = file === '_gitignore' ? '.gitignore' : file;
|
|
64
|
+
const destPath = path.join(pDest, destFile);
|
|
41
65
|
const stats = fs.statSync(srcPath);
|
|
42
66
|
if (stats.isDirectory()) {
|
|
43
67
|
if (file === '.git')
|
|
@@ -47,7 +71,7 @@ function copyTemplate(pSrc, pDest, pProjectName, pVersion, pAuthor) {
|
|
|
47
71
|
else {
|
|
48
72
|
const ext = path.extname(file).toLowerCase();
|
|
49
73
|
const textExtensions = ['.ts', '.js', '.json', '.html', '.css', '.md', '.txt'];
|
|
50
|
-
if (textExtensions.includes(ext)
|
|
74
|
+
if (textExtensions.includes(ext)) {
|
|
51
75
|
let content = fs.readFileSync(srcPath, 'utf8');
|
|
52
76
|
// Replace placeholders
|
|
53
77
|
content = content.replace(/{{PROJECT_NAME}}/g, pProjectName);
|
|
@@ -68,6 +92,26 @@ function copyTemplate(pSrc, pDest, pProjectName, pVersion, pAuthor) {
|
|
|
68
92
|
*/
|
|
69
93
|
export async function processInit(pOptions) {
|
|
70
94
|
intro(chalk.cyan(`Kit CLI v${packageJSON.version}`));
|
|
95
|
+
// Environment Check
|
|
96
|
+
if (!checkBun()) {
|
|
97
|
+
note(`Kit requires the Bun runtime to build and run projects.\nYou can download it manually at ${chalk.cyan('https://bun.sh/')}`, 'Bun Not Found');
|
|
98
|
+
const install = await confirm({
|
|
99
|
+
message: 'Would you like to install Bun automatically now?',
|
|
100
|
+
initialValue: true,
|
|
101
|
+
});
|
|
102
|
+
if (isCancel(install) || !install) {
|
|
103
|
+
cancel(`Please install Bun manually to use Kit: ${chalk.cyan('https://bun.sh/')}\nNote: Kit projects cannot build or run without Bun.`);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
const sInstall = spinner();
|
|
107
|
+
sInstall.start('Installing Bun...');
|
|
108
|
+
const success = installBun();
|
|
109
|
+
if (!success) {
|
|
110
|
+
sInstall.stop(chalk.red('Automatic installation failed.'));
|
|
111
|
+
note(`Please install Bun manually: ${chalk.cyan('https://bun.sh/')}`, 'Manual Installation Required');
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
71
115
|
let projectName = pOptions.projectName;
|
|
72
116
|
let gameType = 'single';
|
|
73
117
|
// Interactive Walkthrough
|