vibedgames 0.8.1 → 0.9.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 (40) hide show
  1. package/README.md +14 -6
  2. package/dist/THIRD_PARTY_NOTICES.txt +58 -6
  3. package/dist/{chunk-FNYBZNW2.js → chunk-25BAMW5X.js} +3 -1
  4. package/dist/{chunk-GCX5KQ6A.js → chunk-2VUUMXAQ.js} +2 -2
  5. package/dist/{chunk-7MKUR7Y3.js → chunk-355VG7EO.js} +13 -12
  6. package/dist/{chunk-I6O4HIDY.js → chunk-3HUWAJQH.js} +76 -61
  7. package/dist/{chunk-2QBYTIMH.js → chunk-5535KDYI.js} +1 -1
  8. package/dist/chunk-56OY4TEP.js +20125 -0
  9. package/dist/{chunk-PHEDW6C7.js → chunk-6EWHKL7Z.js} +13 -5
  10. package/dist/{chunk-6FZPPUQH.js → chunk-7CXMMC5S.js} +1 -1
  11. package/dist/{chunk-QJZ72MSY.js → chunk-7QZSDU52.js} +5 -5
  12. package/dist/{chunk-MGIASPED.js → chunk-AXTLPJ2F.js} +5 -5
  13. package/dist/{chunk-RAUJA3OY.js → chunk-BMTHAVMS.js} +5 -5
  14. package/dist/{chunk-CU7UY5YJ.js → chunk-D2RF35HJ.js} +1 -1
  15. package/dist/chunk-FC233UKH.js +170 -0
  16. package/dist/{chunk-CAKBGDCY.js → chunk-GKDUYJ7R.js} +5 -0
  17. package/dist/{chunk-HCMTSR7E.js → chunk-H3IPLBXQ.js} +8 -7
  18. package/dist/{chunk-QGEITHUP.js → chunk-HNRVSBRK.js} +5 -5
  19. package/dist/chunk-K2U7L4RU.js +183 -0
  20. package/dist/{chunk-PQDBCZRT.js → chunk-KZBZNTM4.js} +203 -153
  21. package/dist/{chunk-QIVCBUYD.js → chunk-LXS3NJYD.js} +7 -6
  22. package/dist/{chunk-HKA5LBYW.js → chunk-LY2GQ32S.js} +9 -8
  23. package/dist/{chunk-2GL2WJZX.js → chunk-NDHXM4PL.js} +4 -4
  24. package/dist/{chunk-PM5UOIKR.js → chunk-OD2MNYXD.js} +16 -16
  25. package/dist/{chunk-JT2AU24K.js → chunk-QARXJGI5.js} +1 -1
  26. package/dist/{chunk-RYFO3ZPO.js → chunk-RXHTGX7C.js} +9 -2
  27. package/dist/chunk-ST5FC2W3.js +95 -0
  28. package/dist/{chunk-AYJQVZXY.js → chunk-TBQ5BU3Q.js} +4 -4
  29. package/dist/{chunk-N3XAUFKH.js → chunk-UFR6G6BL.js} +38 -63
  30. package/dist/{chunk-4BGCA3W7.js → chunk-US6QZICZ.js} +8 -8
  31. package/dist/{chunk-TLRL6FHW.js → chunk-UXCWSWWX.js} +7 -7
  32. package/dist/chunk-UZM6OSW5.js +113 -0
  33. package/dist/{chunk-NC5XCGYU.js → chunk-WSRIF6K4.js} +4 -4
  34. package/dist/chunk-X75Y7LUW.js +126 -0
  35. package/dist/chunk-Z5TFZQ5U.js +2478 -0
  36. package/dist/{chunk-C2IRIRAA.js → chunk-ZCYWDKYP.js} +2 -2
  37. package/dist/index.js +30 -19
  38. package/package.json +6 -5
  39. package/dist/chunk-MJQSHP3Y.js +0 -415
  40. package/dist/chunk-MYFLYNPO.js +0 -68
@@ -6,10 +6,10 @@ var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
7
  import {
8
8
  run
9
- } from "./chunk-AYJQVZXY.js";
9
+ } from "./chunk-TBQ5BU3Q.js";
10
10
  import {
11
11
  consola
12
- } from "./chunk-CU7UY5YJ.js";
12
+ } from "./chunk-D2RF35HJ.js";
13
13
  import {
14
14
  isJsonObject,
15
15
  isJsonString
package/dist/index.js CHANGED
@@ -14,9 +14,17 @@ import {
14
14
  defineCommand,
15
15
  runMain
16
16
  } from "./chunk-MBXCVCC4.js";
17
- import "./chunk-CAKBGDCY.js";
17
+ import "./chunk-GKDUYJ7R.js";
18
18
 
19
19
  // src/index.ts
20
+ for (const stream of [process.stdout, process.stderr]) {
21
+ stream.on("error", (error) => {
22
+ if (error.code === "EPIPE") {
23
+ process.exit(0);
24
+ }
25
+ throw error;
26
+ });
27
+ }
20
28
  var lazy = (load, key) => async () => {
21
29
  const module = await load();
22
30
  return module[key];
@@ -30,17 +38,19 @@ var main = defineCommand({
30
38
  // Each command is imported when it runs, so a call loads that command's code
31
39
  // and dependencies alone. `vg --help` loads them all, for their descriptions.
32
40
  subCommands: {
33
- completions: lazy(() => import("./chunk-FNYBZNW2.js"), "completionsCommand"),
34
- config: lazy(() => import("./chunk-2GL2WJZX.js"), "configCommand"),
35
- credits: lazy(() => import("./chunk-QIVCBUYD.js"), "creditsCommand"),
36
- deploy: lazy(() => import("./chunk-MJQSHP3Y.js"), "deployCommand"),
37
- factory: lazy(() => import("./chunk-QJZ72MSY.js"), "factoryCommand"),
38
- fork: lazy(() => import("./chunk-HKA5LBYW.js"), "forkCommand"),
39
- generate: lazy(() => import("./chunk-N3XAUFKH.js"), "generateCommand"),
40
- init: lazy(() => import("./chunk-MGIASPED.js"), "initCommand"),
41
- login: lazy(() => import("./chunk-MYFLYNPO.js"), "loginCommand"),
42
- logout: lazy(() => import("./chunk-PHEDW6C7.js"), "logoutCommand"),
43
- new: lazy(() => import("./chunk-QGEITHUP.js"), "newCommand"),
41
+ completions: lazy(() => import("./chunk-25BAMW5X.js"), "completionsCommand"),
42
+ config: lazy(() => import("./chunk-NDHXM4PL.js"), "configCommand"),
43
+ credits: lazy(() => import("./chunk-LXS3NJYD.js"), "creditsCommand"),
44
+ deploy: lazy(() => import("./chunk-56OY4TEP.js"), "deployCommand"),
45
+ deployments: lazy(() => import("./chunk-FC233UKH.js"), "deploymentsCommand"),
46
+ distribute: lazy(() => import("./chunk-Z5TFZQ5U.js"), "distributeCommand"),
47
+ factory: lazy(() => import("./chunk-7QZSDU52.js"), "factoryCommand"),
48
+ fork: lazy(() => import("./chunk-LY2GQ32S.js"), "forkCommand"),
49
+ generate: lazy(() => import("./chunk-UFR6G6BL.js"), "generateCommand"),
50
+ init: lazy(() => import("./chunk-AXTLPJ2F.js"), "initCommand"),
51
+ login: lazy(() => import("./chunk-ST5FC2W3.js"), "loginCommand"),
52
+ logout: lazy(() => import("./chunk-6EWHKL7Z.js"), "logoutCommand"),
53
+ new: lazy(() => import("./chunk-HNRVSBRK.js"), "newCommand"),
44
54
  // `run` is the one `vg playtest` verb that is ours rather than
45
55
  // agent-browser's: the model-driven playtest. index.ts routes every other
46
56
  // `vg playtest …` straight to the binary below. Only the meta is reused:
@@ -48,29 +58,30 @@ var main = defineCommand({
48
58
  // passthrough here would forward `run …` to agent-browser once the
49
59
  // playtest had finished and turn every passing run into an exit 1.
50
60
  playtest: async () => {
51
- const { playtestCommand } = await import("./chunk-TLRL6FHW.js");
61
+ const { playtestCommand } = await import("./chunk-UXCWSWWX.js");
52
62
  return defineCommand({
53
63
  meta: playtestCommand.meta,
54
64
  subCommands: {
55
- run: lazy(() => import("./chunk-7MKUR7Y3.js"), "playtestRunCommand")
65
+ run: lazy(() => import("./chunk-355VG7EO.js"), "playtestRunCommand")
56
66
  }
57
67
  });
58
68
  },
59
- update: lazy(() => import("./chunk-PM5UOIKR.js"), "updateCommand"),
60
- whoami: lazy(() => import("./chunk-HCMTSR7E.js"), "whoamiCommand")
69
+ skills: lazy(() => import("./chunk-UZM6OSW5.js"), "skillsCommand"),
70
+ update: lazy(() => import("./chunk-OD2MNYXD.js"), "updateCommand"),
71
+ whoami: lazy(() => import("./chunk-H3IPLBXQ.js"), "whoamiCommand")
61
72
  }
62
73
  });
63
74
  var subcommand = process.argv.at(2);
64
75
  if (subcommand && !["update", "init", "completions"].includes(subcommand)) {
65
- const { maybeScheduleAutoUpdate } = await import("./chunk-NC5XCGYU.js");
76
+ const { maybeScheduleAutoUpdate } = await import("./chunk-WSRIF6K4.js");
66
77
  maybeScheduleAutoUpdate();
67
78
  }
68
79
  if (subcommand === "factory") {
69
- const { runFactory } = await import("./chunk-QJZ72MSY.js");
80
+ const { runFactory } = await import("./chunk-7QZSDU52.js");
70
81
  runFactory(process.argv.slice(3));
71
82
  }
72
83
  if (subcommand === "playtest" && process.argv.at(3) !== "run") {
73
- const { runPlaytest } = await import("./chunk-TLRL6FHW.js");
84
+ const { runPlaytest } = await import("./chunk-UXCWSWWX.js");
74
85
  runPlaytest(process.argv.slice(3));
75
86
  }
76
87
  await runMain(main);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibedgames",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "private": false,
5
5
  "bin": {
6
6
  "vg": "./dist/index.js"
@@ -11,16 +11,17 @@
11
11
  ],
12
12
  "type": "module",
13
13
  "devDependencies": {
14
- "@kyh/tsconfig": "^1.2.0",
15
- "@orpc/client": "2.0.0-beta.42",
14
+ "@kyh/tsconfig": "^1.3.0",
15
+ "@orpc/client": "2.0.0-beta.45",
16
16
  "@repo/contract": "^0.1.0",
17
17
  "@types/cross-spawn": "^6.0.6",
18
- "@types/node": "^26.6.4",
18
+ "@types/node": "^26.6.5",
19
19
  "citty": "^0.2.2",
20
20
  "consola": "^3.4.2",
21
21
  "cross-spawn": "^7.0.6",
22
22
  "esbuild": "^0.28.2",
23
- "ignore": "^7.0.12",
23
+ "fflate": "^0.8.3",
24
+ "ignore": "^7.0.14",
24
25
  "tar": "^7.5.22",
25
26
  "typescript": "^7.0.2"
26
27
  },
@@ -1,415 +0,0 @@
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
- consola
34
- } from "./chunk-CU7UY5YJ.js";
35
- import {
36
- isJsonString
37
- } from "./chunk-J6PKNPI2.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
- };
@@ -1,68 +0,0 @@
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
- createPublicClient
9
- } from "./chunk-PQDBCZRT.js";
10
- import "./chunk-Z4Z24FWO.js";
11
- import "./chunk-PEUP4MZR.js";
12
- import {
13
- getBaseUrl,
14
- saveConfig
15
- } from "./chunk-RYFO3ZPO.js";
16
- import {
17
- consola
18
- } from "./chunk-CU7UY5YJ.js";
19
- import "./chunk-J6PKNPI2.js";
20
- import {
21
- defineCommand
22
- } from "./chunk-MBXCVCC4.js";
23
- import "./chunk-CAKBGDCY.js";
24
-
25
- // src/commands/login.ts
26
- import { exec } from "node:child_process";
27
- import { setTimeout as sleep } from "node:timers/promises";
28
- var POLL_INTERVAL_MS = 2e3;
29
- var MAX_POLLS = 150;
30
- var openBrowser = (url) => {
31
- const openers = { darwin: "open", win32: "start" };
32
- const cmd = openers[process.platform] ?? "xdg-open";
33
- exec(`${cmd} "${url}"`);
34
- };
35
- var loginCommand = defineCommand({
36
- meta: {
37
- description: "Authenticate with vibedgames",
38
- name: "login"
39
- },
40
- run: async () => {
41
- const baseUrl = getBaseUrl();
42
- const client = createPublicClient(baseUrl);
43
- const { code } = await client.auth.cliInit();
44
- consola.box(`Code: ${code}`);
45
- consola.info("Opening browser to complete authentication...");
46
- const authUrl = `${baseUrl}/auth/cli?code=${code}`;
47
- openBrowser(authUrl);
48
- consola.start("Waiting for confirmation...");
49
- for (let i = 0; i < MAX_POLLS; i += 1) {
50
- await sleep(POLL_INTERVAL_MS);
51
- const result = await client.auth.cliPoll({ code });
52
- if (result.status === "confirmed") {
53
- saveConfig({ baseUrl, token: result.token });
54
- consola.success("Logged in successfully");
55
- return;
56
- }
57
- if (result.status === "expired") {
58
- consola.error("Code expired. Run `vg login` to try again.");
59
- process.exit(1);
60
- }
61
- }
62
- consola.error("Timed out waiting for confirmation.");
63
- process.exit(1);
64
- }
65
- });
66
- export {
67
- loginCommand
68
- };