vibedgames 0.6.3 → 0.7.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/README.md +14 -9
- package/dist/THIRD_PARTY_NOTICES.txt +383 -0
- package/dist/chunk-2GL2WJZX.js +172 -0
- package/dist/chunk-2QBYTIMH.js +511 -0
- package/dist/chunk-34AHIMX7.js +466 -0
- package/dist/chunk-6FZPPUQH.js +107 -0
- package/dist/chunk-BVVYDSFJ.js +99 -0
- package/dist/chunk-CAKBGDCY.js +47 -0
- package/dist/chunk-CBKOPVU6.js +1780 -0
- package/dist/chunk-CU7UY5YJ.js +1108 -0
- package/dist/chunk-CZPKN32Z.js +257 -0
- package/dist/chunk-DHEXGWJY.js +111 -0
- package/dist/chunk-FL6IFBUF.js +22 -0
- package/dist/chunk-FLUXEHMU.js +1360 -0
- package/dist/chunk-FNYBZNW2.js +165 -0
- package/dist/chunk-G5FRIFA3.js +22 -0
- package/dist/chunk-HCMTSR7E.js +69 -0
- package/dist/chunk-HKA5LBYW.js +159 -0
- package/dist/chunk-I6O4HIDY.js +1063 -0
- package/dist/chunk-J6PKNPI2.js +26 -0
- package/dist/chunk-JT2AU24K.js +759 -0
- package/dist/chunk-MBXCVCC4.js +478 -0
- package/dist/chunk-MJQSHP3Y.js +415 -0
- package/dist/chunk-MYFLYNPO.js +68 -0
- package/dist/chunk-PEUP4MZR.js +59 -0
- package/dist/chunk-PHEDW6C7.js +32 -0
- package/dist/chunk-PQDBCZRT.js +2017 -0
- package/dist/chunk-QGEITHUP.js +395 -0
- package/dist/chunk-QIVCBUYD.js +273 -0
- package/dist/chunk-RYFO3ZPO.js +71 -0
- package/dist/chunk-RZ4DIJQW.js +68 -0
- package/dist/chunk-SAANBZ25.js +118 -0
- package/dist/chunk-VFFOT7KD.js +2980 -0
- package/dist/chunk-Y552BNFZ.js +41 -0
- package/dist/chunk-Z4Z24FWO.js +39 -0
- package/dist/chunk-ZI6PKVXG.js +64 -0
- package/dist/chunk-ZYCSYJWX.js +87 -0
- package/dist/index.js +67 -60
- package/package.json +13 -16
- package/templates/none/_gitignore +3 -0
- package/templates/none/index.html +29 -0
- package/templates/none/package.json +16 -0
- package/templates/none/src/main.ts +16 -0
- package/templates/none/tsconfig.json +18 -0
- package/templates/none/vite.config.ts +8 -0
- package/templates/phaser/_gitignore +3 -0
- package/templates/phaser/index.html +24 -0
- package/templates/phaser/package.json +19 -0
- package/templates/phaser/src/main.ts +16 -0
- package/templates/phaser/src/scenes/game-scene.ts +65 -0
- package/templates/phaser/tsconfig.json +18 -0
- package/templates/phaser/vite.config.ts +8 -0
- package/templates/react-r3f/_gitignore +3 -0
- package/templates/react-r3f/index.html +24 -0
- package/templates/react-r3f/package.json +27 -0
- package/templates/react-r3f/src/app.tsx +33 -0
- package/templates/react-r3f/src/main.tsx +15 -0
- package/templates/react-r3f/tsconfig.json +19 -0
- package/templates/react-r3f/vite.config.ts +10 -0
- package/templates/threejs/_gitignore +3 -0
- package/templates/threejs/index.html +36 -0
- package/templates/threejs/package.json +20 -0
- package/templates/threejs/src/main.ts +44 -0
- package/templates/threejs/tsconfig.json +18 -0
- package/templates/threejs/vite.config.ts +8 -0
- package/dist/commands/completions.d.ts +0 -7
- package/dist/commands/completions.js +0 -145
- package/dist/commands/credits.d.ts +0 -10
- package/dist/commands/credits.js +0 -136
- package/dist/commands/deploy.d.ts +0 -26
- package/dist/commands/deploy.js +0 -257
- package/dist/commands/factory.d.ts +0 -3
- package/dist/commands/factory.js +0 -73
- package/dist/commands/fork.d.ts +0 -29
- package/dist/commands/fork.js +0 -124
- package/dist/commands/generate.d.ts +0 -1
- package/dist/commands/generate.js +0 -565
- package/dist/commands/init.d.ts +0 -20
- package/dist/commands/init.js +0 -105
- package/dist/commands/login.d.ts +0 -1
- package/dist/commands/login.js +0 -45
- package/dist/commands/logout.d.ts +0 -1
- package/dist/commands/logout.js +0 -13
- package/dist/commands/new.d.ts +0 -26
- package/dist/commands/new.js +0 -318
- package/dist/commands/playtest-run.d.ts +0 -66
- package/dist/commands/playtest-run.js +0 -268
- package/dist/commands/playtest.d.ts +0 -76
- package/dist/commands/playtest.js +0 -372
- package/dist/commands/update.d.ts +0 -13
- package/dist/commands/update.js +0 -82
- package/dist/commands/whoami.d.ts +0 -10
- package/dist/commands/whoami.js +0 -44
- package/dist/index.d.ts +0 -2
- package/dist/lib/api.d.ts +0 -18
- package/dist/lib/api.js +0 -27
- package/dist/lib/archive.d.ts +0 -17
- package/dist/lib/archive.js +0 -228
- package/dist/lib/codex.d.ts +0 -117
- package/dist/lib/codex.js +0 -426
- package/dist/lib/config-file.d.ts +0 -16
- package/dist/lib/config-file.js +0 -54
- package/dist/lib/config.d.ts +0 -11
- package/dist/lib/config.js +0 -54
- package/dist/lib/manifest.d.ts +0 -10
- package/dist/lib/manifest.js +0 -91
- package/dist/lib/media-args.d.ts +0 -30
- package/dist/lib/media-args.js +0 -219
- package/dist/lib/media-download.d.ts +0 -37
- package/dist/lib/media-download.js +0 -268
- package/dist/lib/media-poll.d.ts +0 -18
- package/dist/lib/media-poll.js +0 -86
- package/dist/lib/media-upload.d.ts +0 -12
- package/dist/lib/media-upload.js +0 -52
- package/dist/lib/output.d.ts +0 -68
- package/dist/lib/output.js +0 -102
- package/dist/lib/package-manager.d.ts +0 -25
- package/dist/lib/package-manager.js +0 -77
- package/dist/lib/playtest/agent.d.ts +0 -192
- package/dist/lib/playtest/agent.js +0 -652
- package/dist/lib/playtest/browser.d.ts +0 -109
- package/dist/lib/playtest/browser.js +0 -219
- package/dist/lib/playtest/controls.d.ts +0 -47
- package/dist/lib/playtest/controls.js +0 -218
- package/dist/lib/playtest/errors.d.ts +0 -9
- package/dist/lib/playtest/errors.js +0 -12
- package/dist/lib/playtest/keys.d.ts +0 -41
- package/dist/lib/playtest/keys.js +0 -157
- package/dist/lib/playtest/run.d.ts +0 -195
- package/dist/lib/playtest/run.js +0 -409
- package/dist/lib/run.d.ts +0 -19
- package/dist/lib/run.js +0 -23
- package/dist/lib/strict-args.d.ts +0 -27
- package/dist/lib/strict-args.js +0 -78
- package/dist/lib/types.d.ts +0 -16
- package/dist/lib/types.js +0 -10
- package/dist/lib/update.d.ts +0 -10
- package/dist/lib/update.js +0 -110
- package/dist/lib/upload.d.ts +0 -16
- package/dist/lib/upload.js +0 -41
package/dist/commands/deploy.js
DELETED
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, rmSync } from "node:fs";
|
|
2
|
-
import { tmpdir } from "node:os";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { defineCommand } from "citty";
|
|
5
|
-
import { consola } from "consola";
|
|
6
|
-
import { createClient } from "../lib/api.js";
|
|
7
|
-
import { packSource } from "../lib/archive.js";
|
|
8
|
-
import { findProjectRoot, projectConfigPath, readProjectConfig, writeProjectConfig, SLUG_RE, } from "../lib/config-file.js";
|
|
9
|
-
import { buildManifest } from "../lib/manifest.js";
|
|
10
|
-
import { isJsonOutput, outputArgs, writeStructured } from "../lib/output.js";
|
|
11
|
-
import { assertKnownFlags } from "../lib/strict-args.js";
|
|
12
|
-
import { isJsonString } from "../lib/types.js";
|
|
13
|
-
import { uploadAll } from "../lib/upload.js";
|
|
14
|
-
const deployArgs = {
|
|
15
|
-
dir: {
|
|
16
|
-
default: ".",
|
|
17
|
-
description: "Directory to deploy",
|
|
18
|
-
required: false,
|
|
19
|
-
type: "positional",
|
|
20
|
-
},
|
|
21
|
-
slug: {
|
|
22
|
-
description: "Override the slug (bypasses vibedgames.json)",
|
|
23
|
-
required: false,
|
|
24
|
-
type: "string",
|
|
25
|
-
},
|
|
26
|
-
source: {
|
|
27
|
-
default: false,
|
|
28
|
-
description: "Also upload a forkable source archive, letting anyone logged in fork the project.",
|
|
29
|
-
type: "boolean",
|
|
30
|
-
},
|
|
31
|
-
...outputArgs,
|
|
32
|
-
};
|
|
33
|
-
const formatBytes = (n) => {
|
|
34
|
-
if (n < 1024) {
|
|
35
|
-
return `${n} B`;
|
|
36
|
-
}
|
|
37
|
-
if (n < 1024 * 1024) {
|
|
38
|
-
return `${(n / 1024).toFixed(1)} KB`;
|
|
39
|
-
}
|
|
40
|
-
return `${(n / (1024 * 1024)).toFixed(1)} MB`;
|
|
41
|
-
};
|
|
42
|
-
/** Build-tool projects (package.json present): the root index.html is the
|
|
43
|
-
* source template, the playable game lives in the build output. Deploying the
|
|
44
|
-
* root uploads the whole source tree — wrong content and usually over the file
|
|
45
|
-
* caps — so prefer a build directory when one exists. Checked in popularity
|
|
46
|
-
* order: Vite/Rollup/Parcel → CRA/Preact → Next export/esbuild. */
|
|
47
|
-
const resolveDeployDir = (dir, say) => {
|
|
48
|
-
if (!existsSync(path.join(dir, "package.json"))) {
|
|
49
|
-
return dir;
|
|
50
|
-
}
|
|
51
|
-
for (const name of ["dist", "build", "out"]) {
|
|
52
|
-
if (existsSync(path.join(dir, name, "index.html"))) {
|
|
53
|
-
say(`Project root detected — deploying its build output ${name}/ instead.`);
|
|
54
|
-
return path.join(dir, name);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
consola.warn("This looks like an unbuilt project (package.json, no dist/build/out) — " +
|
|
58
|
-
"run the build first, or the deployed index.html will reference missing source files.");
|
|
59
|
-
return dir;
|
|
60
|
-
};
|
|
61
|
-
const promptForConfig = async (dir, say) => {
|
|
62
|
-
if (!process.stdin.isTTY) {
|
|
63
|
-
consola.error("No slug specified and no vibedgames.json found.\n" +
|
|
64
|
-
" Pass --slug <name> when running without a TTY (e.g. in CI or from a coding agent).\n" +
|
|
65
|
-
" Example: vg deploy ./dist --slug my-game");
|
|
66
|
-
process.exit(1);
|
|
67
|
-
}
|
|
68
|
-
// isJsonString: consola.prompt is typed to resolve a string but can resolve a
|
|
69
|
-
// cancel sentinel at runtime, and a symbol would throw inside RegExp.test.
|
|
70
|
-
const slug = await consola.prompt("Slug (e.g. pong):", { type: "text" });
|
|
71
|
-
if (!isJsonString(slug) || !SLUG_RE.test(slug)) {
|
|
72
|
-
consola.error("Invalid slug. Use lowercase letters, digits, hyphens.");
|
|
73
|
-
process.exit(1);
|
|
74
|
-
}
|
|
75
|
-
const name = await consola.prompt("Name (optional):", { type: "text" });
|
|
76
|
-
const config = {
|
|
77
|
-
name: isJsonString(name) && name.length > 0 ? name : undefined,
|
|
78
|
-
slug,
|
|
79
|
-
};
|
|
80
|
-
writeProjectConfig(dir, config);
|
|
81
|
-
say(`Wrote ${projectConfigPath(dir)}`);
|
|
82
|
-
return config;
|
|
83
|
-
};
|
|
84
|
-
const resolveDeployConfig = async (dir, slugOverride, say) => {
|
|
85
|
-
let config = null;
|
|
86
|
-
try {
|
|
87
|
-
config = readProjectConfig(dir);
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
consola.error(error instanceof Error ? error.message : String(error));
|
|
91
|
-
process.exit(1);
|
|
92
|
-
}
|
|
93
|
-
if (slugOverride) {
|
|
94
|
-
config = { name: config?.name, slug: slugOverride };
|
|
95
|
-
}
|
|
96
|
-
config ??= await promptForConfig(dir, say);
|
|
97
|
-
if (!SLUG_RE.test(config.slug)) {
|
|
98
|
-
consola.error(`Invalid slug in vibedgames.json: ${config.slug}`);
|
|
99
|
-
process.exit(1);
|
|
100
|
-
}
|
|
101
|
-
return config;
|
|
102
|
-
};
|
|
103
|
-
const packForkableSource = async (dir, slug, say) => {
|
|
104
|
-
const root = findProjectRoot(dir);
|
|
105
|
-
if (!root) {
|
|
106
|
-
consola.warn("No vibedgames.json found above the deploy dir — skipping source upload.");
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
try {
|
|
110
|
-
const archive = await packSource(root, path.join(tmpdir(), "vibedgames"));
|
|
111
|
-
say(`Source: ${archive.files.length} files, ${formatBytes(archive.bytes)} — forkable via \`vg fork ${slug}\``);
|
|
112
|
-
return archive;
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
consola.error(`Source archive failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
116
|
-
process.exit(1);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
const uploadSourceArchive = async (archive, upload) => {
|
|
120
|
-
try {
|
|
121
|
-
const res = await fetch(upload.url, {
|
|
122
|
-
body: readFileSync(archive.path),
|
|
123
|
-
headers: upload.headers,
|
|
124
|
-
method: "PUT",
|
|
125
|
-
});
|
|
126
|
-
if (!res.ok) {
|
|
127
|
-
throw new Error(`source upload failed: ${res.status} ${res.statusText}`);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
catch (error) {
|
|
131
|
-
rmSync(archive.path, { force: true });
|
|
132
|
-
consola.error(error instanceof Error ? error.message : String(error));
|
|
133
|
-
process.exit(1);
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
const finalizeDeployment = async (client, deploymentId) => {
|
|
137
|
-
try {
|
|
138
|
-
return await client.deploy.finalize({ deploymentId });
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
consola.error(error instanceof Error ? error.message : String(error));
|
|
142
|
-
process.exit(1);
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
export const deployCommand = defineCommand({
|
|
146
|
-
args: deployArgs,
|
|
147
|
-
meta: {
|
|
148
|
-
description: "Deploy a game to vibedgames",
|
|
149
|
-
name: "deploy",
|
|
150
|
-
},
|
|
151
|
-
run: async ({ args, rawArgs }) => {
|
|
152
|
-
assertKnownFlags(rawArgs, deployArgs);
|
|
153
|
-
// Progress narration shares stdout with the payload, so it has to go quiet
|
|
154
|
-
// whenever stdout is the result rather than a story about it.
|
|
155
|
-
const structured = isJsonOutput(args) || Boolean(args.field);
|
|
156
|
-
const say = structured
|
|
157
|
-
? () => {
|
|
158
|
-
/* empty */
|
|
159
|
-
}
|
|
160
|
-
: (message) => consola.info(message);
|
|
161
|
-
const dir = path.resolve(args.dir);
|
|
162
|
-
if (!existsSync(dir)) {
|
|
163
|
-
consola.error(`Directory does not exist: ${dir}`);
|
|
164
|
-
process.exit(1);
|
|
165
|
-
}
|
|
166
|
-
const deployDir = resolveDeployDir(dir, say);
|
|
167
|
-
const config = await resolveDeployConfig(dir, args.slug, say);
|
|
168
|
-
// ---- Walk files ---------------------------------------------------------
|
|
169
|
-
const manifest = buildManifest(deployDir);
|
|
170
|
-
if (manifest.length === 0) {
|
|
171
|
-
consola.error(`No files found in ${deployDir}`);
|
|
172
|
-
process.exit(1);
|
|
173
|
-
}
|
|
174
|
-
const hasIndex = manifest.some((f) => f.path === "index.html");
|
|
175
|
-
if (!hasIndex) {
|
|
176
|
-
consola.error("Deployment must contain an index.html at the root.");
|
|
177
|
-
process.exit(1);
|
|
178
|
-
}
|
|
179
|
-
const totalBytes = manifest.reduce((acc, f) => acc + f.size, 0);
|
|
180
|
-
say(`Deploying ${config.slug}: ${manifest.length} files, ${formatBytes(totalBytes)}`);
|
|
181
|
-
// ---- Pack forkable source (opt-in: source is a publish, --source) -------
|
|
182
|
-
const sourceArchive = args.source ? await packForkableSource(dir, config.slug, say) : null;
|
|
183
|
-
// ---- Create deployment --------------------------------------------------
|
|
184
|
-
const client = createClient();
|
|
185
|
-
const started = Date.now();
|
|
186
|
-
let created;
|
|
187
|
-
try {
|
|
188
|
-
created = await client.deploy.create({
|
|
189
|
-
files: manifest.map((f) => ({
|
|
190
|
-
contentType: f.contentType,
|
|
191
|
-
path: f.path,
|
|
192
|
-
sha256: f.sha256,
|
|
193
|
-
size: f.size,
|
|
194
|
-
})),
|
|
195
|
-
name: config.name,
|
|
196
|
-
slug: config.slug,
|
|
197
|
-
source: sourceArchive
|
|
198
|
-
? { bytes: sourceArchive.bytes, sha256: sourceArchive.sha256 }
|
|
199
|
-
: undefined,
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
catch (error) {
|
|
203
|
-
if (sourceArchive) {
|
|
204
|
-
rmSync(sourceArchive.path, { force: true });
|
|
205
|
-
}
|
|
206
|
-
consola.error(error instanceof Error ? error.message : String(error));
|
|
207
|
-
process.exit(1);
|
|
208
|
-
}
|
|
209
|
-
// ---- Upload to R2 -------------------------------------------------------
|
|
210
|
-
if (!structured) {
|
|
211
|
-
consola.start(`Uploading ${created.uploads.length} files`);
|
|
212
|
-
}
|
|
213
|
-
try {
|
|
214
|
-
await uploadAll({
|
|
215
|
-
files: manifest,
|
|
216
|
-
onProgress: (done, total) => {
|
|
217
|
-
if (done === total || done % 10 === 0) {
|
|
218
|
-
say(`Uploaded ${done}/${total}`);
|
|
219
|
-
}
|
|
220
|
-
},
|
|
221
|
-
uploads: created.uploads,
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
catch (error) {
|
|
225
|
-
if (sourceArchive) {
|
|
226
|
-
rmSync(sourceArchive.path, { force: true });
|
|
227
|
-
}
|
|
228
|
-
consola.error(error instanceof Error ? error.message : String(error));
|
|
229
|
-
process.exit(1);
|
|
230
|
-
}
|
|
231
|
-
// ---- Upload source archive (best-effort companion to the bundle) -------
|
|
232
|
-
if (sourceArchive) {
|
|
233
|
-
if (created.sourceUpload) {
|
|
234
|
-
await uploadSourceArchive(sourceArchive, created.sourceUpload);
|
|
235
|
-
}
|
|
236
|
-
rmSync(sourceArchive.path, { force: true });
|
|
237
|
-
}
|
|
238
|
-
// ---- Finalize -----------------------------------------------------------
|
|
239
|
-
const finalized = await finalizeDeployment(client, created.deploymentId);
|
|
240
|
-
const elapsedMs = Date.now() - started;
|
|
241
|
-
if (writeStructured({
|
|
242
|
-
bytes: totalBytes,
|
|
243
|
-
deployment_id: created.deploymentId,
|
|
244
|
-
elapsed_ms: elapsedMs,
|
|
245
|
-
files: manifest.length,
|
|
246
|
-
slug: config.slug,
|
|
247
|
-
source: sourceArchive
|
|
248
|
-
? { bytes: sourceArchive.bytes, files: sourceArchive.files.length }
|
|
249
|
-
: null,
|
|
250
|
-
url: finalized.url,
|
|
251
|
-
}, args)) {
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
consola.success(`Deployed ${config.slug} in ${(elapsedMs / 1000).toFixed(1)}s`);
|
|
255
|
-
consola.log(` ${finalized.url}`);
|
|
256
|
-
},
|
|
257
|
-
});
|
package/dist/commands/factory.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from "node:child_process";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { defineCommand } from "citty";
|
|
5
|
-
import { consola } from "consola";
|
|
6
|
-
/**
|
|
7
|
-
* `vg factory` — the autonomous game factory, shipped as an optional plugin.
|
|
8
|
-
* The vg CLI carries none of it: the factory lives in a per-platform npm
|
|
9
|
-
* package (a bun-compiled standalone binary) that gets installed globally on
|
|
10
|
-
* first use, then every invocation just execs it with the args passed
|
|
11
|
-
* through. index.ts routes `vg factory …` here BEFORE citty parses anything,
|
|
12
|
-
* so even `--help`/`--version` reach the binary untouched; the citty command
|
|
13
|
-
* below exists only so `vg --help` lists the subcommand.
|
|
14
|
-
*/
|
|
15
|
-
const PKG = `@vibedgames/factory-${process.platform}-${process.arch}`;
|
|
16
|
-
const BIN = process.platform === "win32" ? "vg-factory.exe" : "vg-factory";
|
|
17
|
-
const npmGlobalRoot = () => {
|
|
18
|
-
try {
|
|
19
|
-
const res = spawnSync("npm", ["root", "-g"], { encoding: "utf-8", timeout: 30_000 });
|
|
20
|
-
if (res.status !== 0 || res.error !== undefined) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
const root = res.stdout.trim();
|
|
24
|
-
return root || null;
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
/** The installed factory binary, or null. VG_FACTORY_BIN overrides (dev). */
|
|
31
|
-
const findBinary = () => {
|
|
32
|
-
const override = process.env.VG_FACTORY_BIN;
|
|
33
|
-
if (override) {
|
|
34
|
-
return existsSync(override) ? override : null;
|
|
35
|
-
}
|
|
36
|
-
const root = npmGlobalRoot();
|
|
37
|
-
if (!root) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
const bin = path.join(root, PKG, "bin", BIN);
|
|
41
|
-
return existsSync(bin) ? bin : null;
|
|
42
|
-
};
|
|
43
|
-
/** Resolve (installing on first use) and exec the factory. Never returns. */
|
|
44
|
-
export const runFactory = (args) => {
|
|
45
|
-
let bin = findBinary();
|
|
46
|
-
if (!bin) {
|
|
47
|
-
consola.start(`Installing the factory (${PKG})…`);
|
|
48
|
-
const install = spawnSync("npm", ["install", "-g", PKG], { stdio: "inherit" });
|
|
49
|
-
if (install.status !== 0 || install.error !== undefined) {
|
|
50
|
-
consola.error(`Couldn't install the factory. Try manually: npm install -g ${PKG}`);
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
bin = findBinary();
|
|
54
|
-
if (!bin) {
|
|
55
|
-
consola.error(`Installed ${PKG} but couldn't find its binary under npm's global root. Check \`npm root -g\`.`);
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
58
|
-
consola.success("Factory installed.");
|
|
59
|
-
}
|
|
60
|
-
const result = spawnSync(bin, args, { stdio: "inherit" });
|
|
61
|
-
process.exit(result.status ?? 1);
|
|
62
|
-
};
|
|
63
|
-
export const factoryCommand = defineCommand({
|
|
64
|
-
meta: {
|
|
65
|
-
description: "Run the vibedgames factory — an autonomous agent that builds a browser game and evolves it like a studio (optional plugin; installs on first use). All arguments are passed through: `vg factory` opens the dashboard, `vg factory start <slug>` resumes a game.",
|
|
66
|
-
name: "factory",
|
|
67
|
-
},
|
|
68
|
-
run: ({ rawArgs }) => {
|
|
69
|
-
// Normally unreachable (index.ts routes `vg factory` before citty), but
|
|
70
|
-
// keeps the command functional if invoked programmatically.
|
|
71
|
-
runFactory(rawArgs);
|
|
72
|
-
},
|
|
73
|
-
});
|
package/dist/commands/fork.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export declare const forkCommand: import("citty").CommandDef<{
|
|
2
|
-
readonly field: {
|
|
3
|
-
readonly description: "Print a single value from the JSON result, e.g. --field request_id or --field images[0].url. Prints scalars bare for shell capture.";
|
|
4
|
-
readonly type: "string";
|
|
5
|
-
};
|
|
6
|
-
readonly json: {
|
|
7
|
-
readonly description: "Print structured JSON to stdout.";
|
|
8
|
-
readonly type: "boolean";
|
|
9
|
-
};
|
|
10
|
-
readonly force: {
|
|
11
|
-
readonly default: false;
|
|
12
|
-
readonly description: "Overwrite the target directory if it exists.";
|
|
13
|
-
readonly type: "boolean";
|
|
14
|
-
};
|
|
15
|
-
readonly name: {
|
|
16
|
-
readonly description: "Display name for the fork (defaults to the target slug).";
|
|
17
|
-
readonly type: "string";
|
|
18
|
-
};
|
|
19
|
-
readonly slug: {
|
|
20
|
-
readonly description: "Slug of the project to fork (e.g. bomberman).";
|
|
21
|
-
readonly required: true;
|
|
22
|
-
readonly type: "positional";
|
|
23
|
-
};
|
|
24
|
-
readonly target: {
|
|
25
|
-
readonly description: "New slug + directory for the fork. Defaults to <slug>-fork.";
|
|
26
|
-
readonly required: false;
|
|
27
|
-
readonly type: "positional";
|
|
28
|
-
};
|
|
29
|
-
}>;
|
package/dist/commands/fork.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { tmpdir } from "node:os";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { defineCommand } from "citty";
|
|
5
|
-
import { consola } from "consola";
|
|
6
|
-
import { createClient } from "../lib/api.js";
|
|
7
|
-
import { extractSource } from "../lib/archive.js";
|
|
8
|
-
import { SLUG_RE } from "../lib/config-file.js";
|
|
9
|
-
import { isJsonOutput, outputArgs, writeStructured } from "../lib/output.js";
|
|
10
|
-
import { assertKnownFlags } from "../lib/strict-args.js";
|
|
11
|
-
import { isJsonObject } from "../lib/types.js";
|
|
12
|
-
const forkArgs = {
|
|
13
|
-
force: {
|
|
14
|
-
default: false,
|
|
15
|
-
description: "Overwrite the target directory if it exists.",
|
|
16
|
-
type: "boolean",
|
|
17
|
-
},
|
|
18
|
-
name: {
|
|
19
|
-
description: "Display name for the fork (defaults to the target slug).",
|
|
20
|
-
type: "string",
|
|
21
|
-
},
|
|
22
|
-
slug: {
|
|
23
|
-
description: "Slug of the project to fork (e.g. bomberman).",
|
|
24
|
-
required: true,
|
|
25
|
-
type: "positional",
|
|
26
|
-
},
|
|
27
|
-
target: {
|
|
28
|
-
description: "New slug + directory for the fork. Defaults to <slug>-fork.",
|
|
29
|
-
required: false,
|
|
30
|
-
type: "positional",
|
|
31
|
-
},
|
|
32
|
-
...outputArgs,
|
|
33
|
-
};
|
|
34
|
-
const rewritePackageName = (dir, slug) => {
|
|
35
|
-
const pkgPath = path.resolve(dir, "package.json");
|
|
36
|
-
if (!existsSync(pkgPath)) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
try {
|
|
40
|
-
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
41
|
-
if (!isJsonObject(pkg)) {
|
|
42
|
-
throw new Error("package.json is not a JSON object");
|
|
43
|
-
}
|
|
44
|
-
pkg.name = slug;
|
|
45
|
-
delete pkg.repository;
|
|
46
|
-
delete pkg.bugs;
|
|
47
|
-
delete pkg.homepage;
|
|
48
|
-
writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
consola.warn(`Could not rewrite package.json name: ${error instanceof Error ? error.message : String(error)}`);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
export const forkCommand = defineCommand({
|
|
55
|
-
args: forkArgs,
|
|
56
|
-
meta: {
|
|
57
|
-
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.",
|
|
58
|
-
name: "fork",
|
|
59
|
-
},
|
|
60
|
-
run: async ({ args, rawArgs }) => {
|
|
61
|
-
assertKnownFlags(rawArgs, forkArgs);
|
|
62
|
-
const source = args.slug.trim().toLowerCase();
|
|
63
|
-
const target = (args.target ?? `${source}-fork`).trim().toLowerCase();
|
|
64
|
-
if (!SLUG_RE.test(target)) {
|
|
65
|
-
consola.error(`Invalid target slug "${target}". Use lowercase letters, digits, and hyphens.`);
|
|
66
|
-
process.exit(1);
|
|
67
|
-
}
|
|
68
|
-
const dir = path.resolve(process.cwd(), target);
|
|
69
|
-
if (existsSync(dir)) {
|
|
70
|
-
if (!args.force) {
|
|
71
|
-
consola.error(`Directory ${dir} already exists. Pass --force to overwrite, or pick another target.`);
|
|
72
|
-
process.exit(1);
|
|
73
|
-
}
|
|
74
|
-
// --force means replace, not merge — clear stale files first so the fork
|
|
75
|
-
// isn't a dirty mix of the archive and whatever was already there.
|
|
76
|
-
rmSync(dir, { force: true, recursive: true });
|
|
77
|
-
}
|
|
78
|
-
const client = createClient();
|
|
79
|
-
// ---- Resolve + download source -----------------------------------------
|
|
80
|
-
if (!isJsonOutput(args) && !args.field) {
|
|
81
|
-
consola.start(`Forking ${source}`);
|
|
82
|
-
}
|
|
83
|
-
let src;
|
|
84
|
-
try {
|
|
85
|
-
src = await client.deploy.getSource({ slug: source });
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
consola.error(error instanceof Error ? error.message : String(error));
|
|
89
|
-
process.exit(1);
|
|
90
|
-
}
|
|
91
|
-
const tmp = path.join(tmpdir(), "vibedgames", `fork-${process.pid}.tgz`);
|
|
92
|
-
mkdirSync(path.join(tmpdir(), "vibedgames"), { recursive: true });
|
|
93
|
-
try {
|
|
94
|
-
const res = await fetch(src.url);
|
|
95
|
-
if (!res.ok) {
|
|
96
|
-
throw new Error(`download failed: ${res.status} ${res.statusText}`);
|
|
97
|
-
}
|
|
98
|
-
writeFileSync(tmp, Buffer.from(await res.arrayBuffer()));
|
|
99
|
-
await extractSource(tmp, dir);
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
consola.error(error instanceof Error ? error.message : String(error));
|
|
103
|
-
process.exit(1);
|
|
104
|
-
}
|
|
105
|
-
finally {
|
|
106
|
-
rmSync(tmp, { force: true });
|
|
107
|
-
}
|
|
108
|
-
// ---- Re-slug the fork (clean slate — no provenance recorded) ------------
|
|
109
|
-
const name = args.name ?? target.replaceAll("-", " ");
|
|
110
|
-
writeFileSync(path.resolve(dir, "vibedgames.json"), `${JSON.stringify({ name, slug: target }, null, 2)}\n`);
|
|
111
|
-
rewritePackageName(dir, target);
|
|
112
|
-
if (writeStructured({ dir, forkedFrom: source, slug: target }, args)) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
consola.success(`Forked ${source} → ${target}`);
|
|
116
|
-
consola.log(` ${dir}`);
|
|
117
|
-
consola.log("");
|
|
118
|
-
consola.info("Next steps:");
|
|
119
|
-
consola.log(` cd ${target}`);
|
|
120
|
-
consola.log(" npm install");
|
|
121
|
-
consola.log(" npm run dev");
|
|
122
|
-
consola.log(` # then: npm run build && vg deploy ./dist → ${target}.vibedgames.com`);
|
|
123
|
-
},
|
|
124
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const generateCommand: import("citty").CommandDef<import("citty").ArgsDef>;
|