vibedgames 0.6.3 → 0.8.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.
Files changed (140) hide show
  1. package/README.md +14 -9
  2. package/dist/THIRD_PARTY_NOTICES.txt +383 -0
  3. package/dist/chunk-2QBYTIMH.js +511 -0
  4. package/dist/chunk-6FZPPUQH.js +107 -0
  5. package/dist/chunk-AZGENOOR.js +22 -0
  6. package/dist/chunk-CAKBGDCY.js +47 -0
  7. package/dist/chunk-CU7UY5YJ.js +1108 -0
  8. package/dist/chunk-CZPKN32Z.js +257 -0
  9. package/dist/chunk-FL6IFBUF.js +22 -0
  10. package/dist/chunk-FNYBZNW2.js +165 -0
  11. package/dist/chunk-GUF6ADBF.js +273 -0
  12. package/dist/chunk-H4NBRFBY.js +79 -0
  13. package/dist/chunk-HASKWB6B.js +111 -0
  14. package/dist/chunk-I6O4HIDY.js +1063 -0
  15. package/dist/chunk-IO6OM6WM.js +466 -0
  16. package/dist/chunk-J6PKNPI2.js +26 -0
  17. package/dist/chunk-JT2AU24K.js +759 -0
  18. package/dist/chunk-K5SC6SXO.js +172 -0
  19. package/dist/chunk-MBXCVCC4.js +478 -0
  20. package/dist/chunk-PEUP4MZR.js +59 -0
  21. package/dist/chunk-PQDBCZRT.js +2017 -0
  22. package/dist/chunk-RIGKOLNN.js +1360 -0
  23. package/dist/chunk-RNBUX5VF.js +68 -0
  24. package/dist/chunk-RYFO3ZPO.js +71 -0
  25. package/dist/chunk-RZ4DIJQW.js +68 -0
  26. package/dist/chunk-SAANBZ25.js +118 -0
  27. package/dist/chunk-TMK6V5FV.js +395 -0
  28. package/dist/chunk-TYVYWBY6.js +69 -0
  29. package/dist/chunk-VFFOT7KD.js +2980 -0
  30. package/dist/chunk-W5XP4ZVU.js +159 -0
  31. package/dist/chunk-X4ZABSCN.js +415 -0
  32. package/dist/chunk-XDC7QGOF.js +32 -0
  33. package/dist/chunk-XK5RZQMX.js +1780 -0
  34. package/dist/chunk-Y552BNFZ.js +41 -0
  35. package/dist/chunk-Z4Z24FWO.js +39 -0
  36. package/dist/chunk-ZI6PKVXG.js +64 -0
  37. package/dist/chunk-ZYCSYJWX.js +87 -0
  38. package/dist/index.js +67 -60
  39. package/package.json +13 -16
  40. package/templates/none/_gitignore +3 -0
  41. package/templates/none/index.html +29 -0
  42. package/templates/none/package.json +16 -0
  43. package/templates/none/src/main.ts +16 -0
  44. package/templates/none/tsconfig.json +18 -0
  45. package/templates/none/vite.config.ts +8 -0
  46. package/templates/phaser/_gitignore +3 -0
  47. package/templates/phaser/index.html +24 -0
  48. package/templates/phaser/package.json +19 -0
  49. package/templates/phaser/src/main.ts +16 -0
  50. package/templates/phaser/src/scenes/game-scene.ts +65 -0
  51. package/templates/phaser/tsconfig.json +18 -0
  52. package/templates/phaser/vite.config.ts +8 -0
  53. package/templates/react-r3f/_gitignore +3 -0
  54. package/templates/react-r3f/index.html +24 -0
  55. package/templates/react-r3f/package.json +27 -0
  56. package/templates/react-r3f/src/app.tsx +33 -0
  57. package/templates/react-r3f/src/main.tsx +15 -0
  58. package/templates/react-r3f/tsconfig.json +19 -0
  59. package/templates/react-r3f/vite.config.ts +10 -0
  60. package/templates/threejs/_gitignore +3 -0
  61. package/templates/threejs/index.html +36 -0
  62. package/templates/threejs/package.json +20 -0
  63. package/templates/threejs/src/main.ts +44 -0
  64. package/templates/threejs/tsconfig.json +18 -0
  65. package/templates/threejs/vite.config.ts +8 -0
  66. package/dist/commands/completions.d.ts +0 -7
  67. package/dist/commands/completions.js +0 -145
  68. package/dist/commands/credits.d.ts +0 -10
  69. package/dist/commands/credits.js +0 -136
  70. package/dist/commands/deploy.d.ts +0 -26
  71. package/dist/commands/deploy.js +0 -257
  72. package/dist/commands/factory.d.ts +0 -3
  73. package/dist/commands/factory.js +0 -73
  74. package/dist/commands/fork.d.ts +0 -29
  75. package/dist/commands/fork.js +0 -124
  76. package/dist/commands/generate.d.ts +0 -1
  77. package/dist/commands/generate.js +0 -565
  78. package/dist/commands/init.d.ts +0 -20
  79. package/dist/commands/init.js +0 -105
  80. package/dist/commands/login.d.ts +0 -1
  81. package/dist/commands/login.js +0 -45
  82. package/dist/commands/logout.d.ts +0 -1
  83. package/dist/commands/logout.js +0 -13
  84. package/dist/commands/new.d.ts +0 -26
  85. package/dist/commands/new.js +0 -318
  86. package/dist/commands/playtest-run.d.ts +0 -66
  87. package/dist/commands/playtest-run.js +0 -268
  88. package/dist/commands/playtest.d.ts +0 -76
  89. package/dist/commands/playtest.js +0 -372
  90. package/dist/commands/update.d.ts +0 -13
  91. package/dist/commands/update.js +0 -82
  92. package/dist/commands/whoami.d.ts +0 -10
  93. package/dist/commands/whoami.js +0 -44
  94. package/dist/index.d.ts +0 -2
  95. package/dist/lib/api.d.ts +0 -18
  96. package/dist/lib/api.js +0 -27
  97. package/dist/lib/archive.d.ts +0 -17
  98. package/dist/lib/archive.js +0 -228
  99. package/dist/lib/codex.d.ts +0 -117
  100. package/dist/lib/codex.js +0 -426
  101. package/dist/lib/config-file.d.ts +0 -16
  102. package/dist/lib/config-file.js +0 -54
  103. package/dist/lib/config.d.ts +0 -11
  104. package/dist/lib/config.js +0 -54
  105. package/dist/lib/manifest.d.ts +0 -10
  106. package/dist/lib/manifest.js +0 -91
  107. package/dist/lib/media-args.d.ts +0 -30
  108. package/dist/lib/media-args.js +0 -219
  109. package/dist/lib/media-download.d.ts +0 -37
  110. package/dist/lib/media-download.js +0 -268
  111. package/dist/lib/media-poll.d.ts +0 -18
  112. package/dist/lib/media-poll.js +0 -86
  113. package/dist/lib/media-upload.d.ts +0 -12
  114. package/dist/lib/media-upload.js +0 -52
  115. package/dist/lib/output.d.ts +0 -68
  116. package/dist/lib/output.js +0 -102
  117. package/dist/lib/package-manager.d.ts +0 -25
  118. package/dist/lib/package-manager.js +0 -77
  119. package/dist/lib/playtest/agent.d.ts +0 -192
  120. package/dist/lib/playtest/agent.js +0 -652
  121. package/dist/lib/playtest/browser.d.ts +0 -109
  122. package/dist/lib/playtest/browser.js +0 -219
  123. package/dist/lib/playtest/controls.d.ts +0 -47
  124. package/dist/lib/playtest/controls.js +0 -218
  125. package/dist/lib/playtest/errors.d.ts +0 -9
  126. package/dist/lib/playtest/errors.js +0 -12
  127. package/dist/lib/playtest/keys.d.ts +0 -41
  128. package/dist/lib/playtest/keys.js +0 -157
  129. package/dist/lib/playtest/run.d.ts +0 -195
  130. package/dist/lib/playtest/run.js +0 -409
  131. package/dist/lib/run.d.ts +0 -19
  132. package/dist/lib/run.js +0 -23
  133. package/dist/lib/strict-args.d.ts +0 -27
  134. package/dist/lib/strict-args.js +0 -78
  135. package/dist/lib/types.d.ts +0 -16
  136. package/dist/lib/types.js +0 -10
  137. package/dist/lib/update.d.ts +0 -10
  138. package/dist/lib/update.js +0 -110
  139. package/dist/lib/upload.d.ts +0 -16
  140. package/dist/lib/upload.js +0 -41
@@ -0,0 +1,159 @@
1
+ import { createRequire as __createRequire } from "node:module";
2
+ import { dirname as __pathDirname } from "node:path";
3
+ import { fileURLToPath as __fileURLToPath } from "node:url";
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import {
8
+ extractSource
9
+ } from "./chunk-I6O4HIDY.js";
10
+ import "./chunk-VFFOT7KD.js";
11
+ import {
12
+ SLUG_RE
13
+ } from "./chunk-ZI6PKVXG.js";
14
+ import {
15
+ createClient
16
+ } from "./chunk-PQDBCZRT.js";
17
+ import "./chunk-Z4Z24FWO.js";
18
+ import "./chunk-PEUP4MZR.js";
19
+ import {
20
+ isJsonOutput,
21
+ outputArgs,
22
+ writeStructured
23
+ } from "./chunk-ZYCSYJWX.js";
24
+ import {
25
+ assertKnownFlags
26
+ } from "./chunk-RZ4DIJQW.js";
27
+ import "./chunk-RYFO3ZPO.js";
28
+ import {
29
+ isJsonObject
30
+ } from "./chunk-J6PKNPI2.js";
31
+ import {
32
+ consola
33
+ } from "./chunk-CU7UY5YJ.js";
34
+ import {
35
+ defineCommand
36
+ } from "./chunk-MBXCVCC4.js";
37
+ import "./chunk-CAKBGDCY.js";
38
+
39
+ // src/commands/fork.ts
40
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
41
+ import { tmpdir } from "node:os";
42
+ import path from "node:path";
43
+ var forkArgs = {
44
+ force: {
45
+ default: false,
46
+ description: "Overwrite the target directory if it exists.",
47
+ type: "boolean"
48
+ },
49
+ name: {
50
+ description: "Display name for the fork (defaults to the target slug).",
51
+ type: "string"
52
+ },
53
+ slug: {
54
+ description: "Slug of the project to fork (e.g. bomberman).",
55
+ required: true,
56
+ type: "positional"
57
+ },
58
+ target: {
59
+ description: "New slug + directory for the fork. Defaults to <slug>-fork.",
60
+ required: false,
61
+ type: "positional"
62
+ },
63
+ ...outputArgs
64
+ };
65
+ var rewritePackageName = (dir, slug) => {
66
+ const pkgPath = path.resolve(dir, "package.json");
67
+ if (!existsSync(pkgPath)) {
68
+ return;
69
+ }
70
+ try {
71
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
72
+ if (!isJsonObject(pkg)) {
73
+ throw new Error("package.json is not a JSON object");
74
+ }
75
+ pkg.name = slug;
76
+ delete pkg.repository;
77
+ delete pkg.bugs;
78
+ delete pkg.homepage;
79
+ writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}
80
+ `);
81
+ } catch (error) {
82
+ consola.warn(
83
+ `Could not rewrite package.json name: ${error instanceof Error ? error.message : String(error)}`
84
+ );
85
+ }
86
+ };
87
+ var forkCommand = defineCommand({
88
+ args: forkArgs,
89
+ meta: {
90
+ description: "Fork another project's source so you can build on it. Downloads the source a project shipped with `vg deploy`, extracts it locally, and rewrites it to a new slug.",
91
+ name: "fork"
92
+ },
93
+ run: async ({ args, rawArgs }) => {
94
+ assertKnownFlags(rawArgs, forkArgs);
95
+ const source = args.slug.trim().toLowerCase();
96
+ const target = (args.target ?? `${source}-fork`).trim().toLowerCase();
97
+ if (!SLUG_RE.test(target)) {
98
+ consola.error(`Invalid target slug "${target}". Use lowercase letters, digits, and hyphens.`);
99
+ process.exit(1);
100
+ }
101
+ const dir = path.resolve(process.cwd(), target);
102
+ if (existsSync(dir)) {
103
+ if (!args.force) {
104
+ consola.error(
105
+ `Directory ${dir} already exists. Pass --force to overwrite, or pick another target.`
106
+ );
107
+ process.exit(1);
108
+ }
109
+ rmSync(dir, { force: true, recursive: true });
110
+ }
111
+ const client = createClient();
112
+ if (!isJsonOutput(args) && !args.field) {
113
+ consola.start(`Forking ${source}`);
114
+ }
115
+ let src;
116
+ try {
117
+ src = await client.deploy.getSource({ slug: source });
118
+ } catch (error) {
119
+ consola.error(error instanceof Error ? error.message : String(error));
120
+ process.exit(1);
121
+ }
122
+ const tmp = path.join(tmpdir(), "vibedgames", `fork-${process.pid}.tgz`);
123
+ mkdirSync(path.join(tmpdir(), "vibedgames"), { recursive: true });
124
+ try {
125
+ const res = await fetch(src.url);
126
+ if (!res.ok) {
127
+ throw new Error(`download failed: ${res.status} ${res.statusText}`);
128
+ }
129
+ writeFileSync(tmp, Buffer.from(await res.arrayBuffer()));
130
+ await extractSource(tmp, dir);
131
+ } catch (error) {
132
+ consola.error(error instanceof Error ? error.message : String(error));
133
+ process.exit(1);
134
+ } finally {
135
+ rmSync(tmp, { force: true });
136
+ }
137
+ const name = args.name ?? target.replaceAll("-", " ");
138
+ writeFileSync(
139
+ path.resolve(dir, "vibedgames.json"),
140
+ `${JSON.stringify({ name, slug: target }, null, 2)}
141
+ `
142
+ );
143
+ rewritePackageName(dir, target);
144
+ if (writeStructured({ dir, forkedFrom: source, slug: target }, args)) {
145
+ return;
146
+ }
147
+ consola.success(`Forked ${source} \u2192 ${target}`);
148
+ consola.log(` ${dir}`);
149
+ consola.log("");
150
+ consola.info("Next steps:");
151
+ consola.log(` cd ${target}`);
152
+ consola.log(" npm install");
153
+ consola.log(" npm run dev");
154
+ consola.log(` # then: npm run build && vg deploy ./dist \u2192 ${target}.vibedgames.com`);
155
+ }
156
+ });
157
+ export {
158
+ forkCommand
159
+ };
@@ -0,0 +1,415 @@
1
+ import { createRequire as __createRequire } from "node:module";
2
+ import { dirname as __pathDirname } from "node:path";
3
+ import { fileURLToPath as __fileURLToPath } from "node:url";
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import {
8
+ packSource
9
+ } from "./chunk-I6O4HIDY.js";
10
+ import "./chunk-VFFOT7KD.js";
11
+ import {
12
+ SLUG_RE,
13
+ findProjectRoot,
14
+ projectConfigPath,
15
+ readProjectConfig,
16
+ writeProjectConfig
17
+ } from "./chunk-ZI6PKVXG.js";
18
+ import {
19
+ createClient
20
+ } from "./chunk-PQDBCZRT.js";
21
+ import "./chunk-Z4Z24FWO.js";
22
+ import "./chunk-PEUP4MZR.js";
23
+ import {
24
+ isJsonOutput,
25
+ outputArgs,
26
+ writeStructured
27
+ } from "./chunk-ZYCSYJWX.js";
28
+ import {
29
+ assertKnownFlags
30
+ } from "./chunk-RZ4DIJQW.js";
31
+ import "./chunk-RYFO3ZPO.js";
32
+ import {
33
+ isJsonString
34
+ } from "./chunk-J6PKNPI2.js";
35
+ import {
36
+ consola
37
+ } from "./chunk-CU7UY5YJ.js";
38
+ import {
39
+ defineCommand
40
+ } from "./chunk-MBXCVCC4.js";
41
+ import "./chunk-CAKBGDCY.js";
42
+
43
+ // src/commands/deploy.ts
44
+ import { existsSync, readFileSync as readFileSync3, rmSync } from "node:fs";
45
+ import { tmpdir } from "node:os";
46
+ import path2 from "node:path";
47
+
48
+ // src/lib/manifest.ts
49
+ import { createHash } from "node:crypto";
50
+ import { readFileSync, readdirSync, statSync } from "node:fs";
51
+ import path from "node:path";
52
+ var IGNORED_TOP_LEVEL = /* @__PURE__ */ new Set([
53
+ "node_modules",
54
+ ".git",
55
+ ".turbo",
56
+ ".cache",
57
+ ".DS_Store",
58
+ "vibedgames.json"
59
+ ]);
60
+ var CONTENT_TYPES = new Map(
61
+ Object.entries({
62
+ avif: "image/avif",
63
+ cjs: "application/javascript; charset=utf-8",
64
+ css: "text/css; charset=utf-8",
65
+ gif: "image/gif",
66
+ glb: "model/gltf-binary",
67
+ gltf: "model/gltf+json",
68
+ htm: "text/html; charset=utf-8",
69
+ html: "text/html; charset=utf-8",
70
+ ico: "image/x-icon",
71
+ jpeg: "image/jpeg",
72
+ jpg: "image/jpeg",
73
+ js: "application/javascript; charset=utf-8",
74
+ json: "application/json; charset=utf-8",
75
+ m4a: "audio/mp4",
76
+ map: "application/json; charset=utf-8",
77
+ mjs: "application/javascript; charset=utf-8",
78
+ mp3: "audio/mpeg",
79
+ mp4: "video/mp4",
80
+ ogg: "audio/ogg",
81
+ otf: "font/otf",
82
+ png: "image/png",
83
+ svg: "image/svg+xml",
84
+ ttf: "font/ttf",
85
+ txt: "text/plain; charset=utf-8",
86
+ wasm: "application/wasm",
87
+ wav: "audio/wav",
88
+ webm: "video/webm",
89
+ webp: "image/webp",
90
+ woff: "font/woff",
91
+ woff2: "font/woff2",
92
+ xml: "application/xml"
93
+ })
94
+ );
95
+ var contentTypeForPath = (file) => {
96
+ const ext = file.split(".").pop()?.toLowerCase() ?? "";
97
+ return CONTENT_TYPES.get(ext) ?? "application/octet-stream";
98
+ };
99
+ var shouldIgnore = (relPath) => {
100
+ const top = relPath.split(path.sep)[0] ?? "";
101
+ if (IGNORED_TOP_LEVEL.has(top)) {
102
+ return true;
103
+ }
104
+ if (relPath.split(path.sep).some((seg) => seg.startsWith("."))) {
105
+ return true;
106
+ }
107
+ return false;
108
+ };
109
+ var buildManifest = (rootDir) => {
110
+ const files = [];
111
+ const walk = (dir) => {
112
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
113
+ const abs = path.join(dir, entry.name);
114
+ const rel = path.relative(rootDir, abs);
115
+ if (shouldIgnore(rel)) {
116
+ continue;
117
+ }
118
+ if (entry.isDirectory()) {
119
+ walk(abs);
120
+ continue;
121
+ }
122
+ if (!entry.isFile()) {
123
+ continue;
124
+ }
125
+ const stat = statSync(abs);
126
+ const buf = readFileSync(abs);
127
+ const sha256 = createHash("sha256").update(buf).digest("hex");
128
+ const posixPath = rel.split(path.sep).join("/");
129
+ files.push({
130
+ absolutePath: abs,
131
+ contentType: contentTypeForPath(posixPath),
132
+ path: posixPath,
133
+ sha256,
134
+ size: stat.size
135
+ });
136
+ }
137
+ };
138
+ walk(rootDir);
139
+ return files;
140
+ };
141
+
142
+ // src/lib/upload.ts
143
+ import { readFileSync as readFileSync2 } from "node:fs";
144
+ var uploadAll = async ({
145
+ files,
146
+ uploads,
147
+ concurrency = 6,
148
+ onProgress
149
+ }) => {
150
+ const byPath = new Map(files.map((f) => [f.path, f]));
151
+ let done = 0;
152
+ let cursor = 0;
153
+ const worker = async () => {
154
+ while (true) {
155
+ const idx = cursor;
156
+ cursor += 1;
157
+ if (idx >= uploads.length) {
158
+ return;
159
+ }
160
+ const upload = uploads[idx];
161
+ if (!upload) {
162
+ return;
163
+ }
164
+ const file = byPath.get(upload.path);
165
+ if (!file) {
166
+ throw new Error(`Missing file for upload target: ${upload.path}`);
167
+ }
168
+ const body = readFileSync2(file.absolutePath);
169
+ const res = await fetch(upload.url, {
170
+ body,
171
+ headers: upload.headers,
172
+ method: "PUT"
173
+ });
174
+ if (!res.ok) {
175
+ const text = await res.text().catch(() => "");
176
+ throw new Error(
177
+ `Upload failed for ${upload.path}: ${res.status} ${res.statusText} ${text}`
178
+ );
179
+ }
180
+ done += 1;
181
+ onProgress?.(done, uploads.length);
182
+ }
183
+ };
184
+ const workers = Array.from({ length: Math.min(concurrency, uploads.length) }, () => worker());
185
+ await Promise.all(workers);
186
+ };
187
+
188
+ // src/commands/deploy.ts
189
+ var deployArgs = {
190
+ dir: {
191
+ default: ".",
192
+ description: "Directory to deploy",
193
+ required: false,
194
+ type: "positional"
195
+ },
196
+ slug: {
197
+ description: "Override the slug (bypasses vibedgames.json)",
198
+ required: false,
199
+ type: "string"
200
+ },
201
+ source: {
202
+ default: false,
203
+ description: "Also upload a forkable source archive, letting anyone logged in fork the project.",
204
+ type: "boolean"
205
+ },
206
+ ...outputArgs
207
+ };
208
+ var formatBytes = (n) => {
209
+ if (n < 1024) {
210
+ return `${n} B`;
211
+ }
212
+ if (n < 1024 * 1024) {
213
+ return `${(n / 1024).toFixed(1)} KB`;
214
+ }
215
+ return `${(n / (1024 * 1024)).toFixed(1)} MB`;
216
+ };
217
+ var resolveDeployDir = (dir, say) => {
218
+ if (!existsSync(path2.join(dir, "package.json"))) {
219
+ return dir;
220
+ }
221
+ for (const name of ["dist", "build", "out"]) {
222
+ if (existsSync(path2.join(dir, name, "index.html"))) {
223
+ say(`Project root detected \u2014 deploying its build output ${name}/ instead.`);
224
+ return path2.join(dir, name);
225
+ }
226
+ }
227
+ consola.warn(
228
+ "This looks like an unbuilt project (package.json, no dist/build/out) \u2014 run the build first, or the deployed index.html will reference missing source files."
229
+ );
230
+ return dir;
231
+ };
232
+ var promptForConfig = async (dir, say) => {
233
+ if (!process.stdin.isTTY) {
234
+ consola.error(
235
+ "No slug specified and no vibedgames.json found.\n Pass --slug <name> when running without a TTY (e.g. in CI or from a coding agent).\n Example: vg deploy ./dist --slug my-game"
236
+ );
237
+ process.exit(1);
238
+ }
239
+ const slug = await consola.prompt("Slug (e.g. pong):", { type: "text" });
240
+ if (!isJsonString(slug) || !SLUG_RE.test(slug)) {
241
+ consola.error("Invalid slug. Use lowercase letters, digits, hyphens.");
242
+ process.exit(1);
243
+ }
244
+ const name = await consola.prompt("Name (optional):", { type: "text" });
245
+ const config = {
246
+ name: isJsonString(name) && name.length > 0 ? name : void 0,
247
+ slug
248
+ };
249
+ writeProjectConfig(dir, config);
250
+ say(`Wrote ${projectConfigPath(dir)}`);
251
+ return config;
252
+ };
253
+ var resolveDeployConfig = async (dir, slugOverride, say) => {
254
+ let config = null;
255
+ try {
256
+ config = readProjectConfig(dir);
257
+ } catch (error) {
258
+ consola.error(error instanceof Error ? error.message : String(error));
259
+ process.exit(1);
260
+ }
261
+ if (slugOverride) {
262
+ config = { name: config?.name, slug: slugOverride };
263
+ }
264
+ config ??= await promptForConfig(dir, say);
265
+ if (!SLUG_RE.test(config.slug)) {
266
+ consola.error(`Invalid slug in vibedgames.json: ${config.slug}`);
267
+ process.exit(1);
268
+ }
269
+ return config;
270
+ };
271
+ var packForkableSource = async (dir, slug, say) => {
272
+ const root = findProjectRoot(dir);
273
+ if (!root) {
274
+ consola.warn("No vibedgames.json found above the deploy dir \u2014 skipping source upload.");
275
+ return null;
276
+ }
277
+ try {
278
+ const archive = await packSource(root, path2.join(tmpdir(), "vibedgames"));
279
+ say(
280
+ `Source: ${archive.files.length} files, ${formatBytes(archive.bytes)} \u2014 forkable via \`vg fork ${slug}\``
281
+ );
282
+ return archive;
283
+ } catch (error) {
284
+ consola.error(
285
+ `Source archive failed: ${error instanceof Error ? error.message : String(error)}`
286
+ );
287
+ process.exit(1);
288
+ }
289
+ };
290
+ var uploadSourceArchive = async (archive, upload) => {
291
+ try {
292
+ const res = await fetch(upload.url, {
293
+ body: readFileSync3(archive.path),
294
+ headers: upload.headers,
295
+ method: "PUT"
296
+ });
297
+ if (!res.ok) {
298
+ throw new Error(`source upload failed: ${res.status} ${res.statusText}`);
299
+ }
300
+ } catch (error) {
301
+ rmSync(archive.path, { force: true });
302
+ consola.error(error instanceof Error ? error.message : String(error));
303
+ process.exit(1);
304
+ }
305
+ };
306
+ var finalizeDeployment = async (client, deploymentId) => {
307
+ try {
308
+ return await client.deploy.finalize({ deploymentId });
309
+ } catch (error) {
310
+ consola.error(error instanceof Error ? error.message : String(error));
311
+ process.exit(1);
312
+ }
313
+ };
314
+ var deployCommand = defineCommand({
315
+ args: deployArgs,
316
+ meta: {
317
+ description: "Deploy a game to vibedgames",
318
+ name: "deploy"
319
+ },
320
+ run: async ({ args, rawArgs }) => {
321
+ assertKnownFlags(rawArgs, deployArgs);
322
+ const structured = isJsonOutput(args) || Boolean(args.field);
323
+ const say = structured ? () => {
324
+ } : (message) => consola.info(message);
325
+ const dir = path2.resolve(args.dir);
326
+ if (!existsSync(dir)) {
327
+ consola.error(`Directory does not exist: ${dir}`);
328
+ process.exit(1);
329
+ }
330
+ const deployDir = resolveDeployDir(dir, say);
331
+ const config = await resolveDeployConfig(dir, args.slug, say);
332
+ const manifest = buildManifest(deployDir);
333
+ if (manifest.length === 0) {
334
+ consola.error(`No files found in ${deployDir}`);
335
+ process.exit(1);
336
+ }
337
+ const hasIndex = manifest.some((f) => f.path === "index.html");
338
+ if (!hasIndex) {
339
+ consola.error("Deployment must contain an index.html at the root.");
340
+ process.exit(1);
341
+ }
342
+ const totalBytes = manifest.reduce((acc, f) => acc + f.size, 0);
343
+ say(`Deploying ${config.slug}: ${manifest.length} files, ${formatBytes(totalBytes)}`);
344
+ const sourceArchive = args.source ? await packForkableSource(dir, config.slug, say) : null;
345
+ const client = createClient();
346
+ const started = Date.now();
347
+ let created;
348
+ try {
349
+ created = await client.deploy.create({
350
+ files: manifest.map((f) => ({
351
+ contentType: f.contentType,
352
+ path: f.path,
353
+ sha256: f.sha256,
354
+ size: f.size
355
+ })),
356
+ name: config.name,
357
+ slug: config.slug,
358
+ source: sourceArchive ? { bytes: sourceArchive.bytes, sha256: sourceArchive.sha256 } : void 0
359
+ });
360
+ } catch (error) {
361
+ if (sourceArchive) {
362
+ rmSync(sourceArchive.path, { force: true });
363
+ }
364
+ consola.error(error instanceof Error ? error.message : String(error));
365
+ process.exit(1);
366
+ }
367
+ if (!structured) {
368
+ consola.start(`Uploading ${created.uploads.length} files`);
369
+ }
370
+ try {
371
+ await uploadAll({
372
+ files: manifest,
373
+ onProgress: (done, total) => {
374
+ if (done === total || done % 10 === 0) {
375
+ say(`Uploaded ${done}/${total}`);
376
+ }
377
+ },
378
+ uploads: created.uploads
379
+ });
380
+ } catch (error) {
381
+ if (sourceArchive) {
382
+ rmSync(sourceArchive.path, { force: true });
383
+ }
384
+ consola.error(error instanceof Error ? error.message : String(error));
385
+ process.exit(1);
386
+ }
387
+ if (sourceArchive) {
388
+ if (created.sourceUpload) {
389
+ await uploadSourceArchive(sourceArchive, created.sourceUpload);
390
+ }
391
+ rmSync(sourceArchive.path, { force: true });
392
+ }
393
+ const finalized = await finalizeDeployment(client, created.deploymentId);
394
+ const elapsedMs = Date.now() - started;
395
+ if (writeStructured(
396
+ {
397
+ bytes: totalBytes,
398
+ deployment_id: created.deploymentId,
399
+ elapsed_ms: elapsedMs,
400
+ files: manifest.length,
401
+ slug: config.slug,
402
+ source: sourceArchive ? { bytes: sourceArchive.bytes, files: sourceArchive.files.length } : null,
403
+ url: finalized.url
404
+ },
405
+ args
406
+ )) {
407
+ return;
408
+ }
409
+ consola.success(`Deployed ${config.slug} in ${(elapsedMs / 1e3).toFixed(1)}s`);
410
+ consola.log(` ${finalized.url}`);
411
+ }
412
+ });
413
+ export {
414
+ deployCommand
415
+ };
@@ -0,0 +1,32 @@
1
+ import { createRequire as __createRequire } from "node:module";
2
+ import { dirname as __pathDirname } from "node:path";
3
+ import { fileURLToPath as __fileURLToPath } from "node:url";
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import {
8
+ clearConfig
9
+ } from "./chunk-RYFO3ZPO.js";
10
+ import "./chunk-J6PKNPI2.js";
11
+ import {
12
+ consola
13
+ } from "./chunk-CU7UY5YJ.js";
14
+ import {
15
+ defineCommand
16
+ } from "./chunk-MBXCVCC4.js";
17
+ import "./chunk-CAKBGDCY.js";
18
+
19
+ // src/commands/logout.ts
20
+ var logoutCommand = defineCommand({
21
+ meta: {
22
+ description: "Log out of vibedgames",
23
+ name: "logout"
24
+ },
25
+ run: () => {
26
+ clearConfig();
27
+ consola.success("Logged out");
28
+ }
29
+ });
30
+ export {
31
+ logoutCommand
32
+ };