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
|
@@ -0,0 +1,165 @@
|
|
|
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
|
+
defineCommand
|
|
9
|
+
} from "./chunk-MBXCVCC4.js";
|
|
10
|
+
import "./chunk-CAKBGDCY.js";
|
|
11
|
+
|
|
12
|
+
// src/commands/completions.ts
|
|
13
|
+
var SUPPORTED = /* @__PURE__ */ new Set(["bash", "zsh", "fish"]);
|
|
14
|
+
var isShell = (value) => SUPPORTED.has(value);
|
|
15
|
+
var SUBCOMMANDS = [
|
|
16
|
+
"new",
|
|
17
|
+
"init",
|
|
18
|
+
"login",
|
|
19
|
+
"logout",
|
|
20
|
+
"deploy",
|
|
21
|
+
"playtest",
|
|
22
|
+
"factory",
|
|
23
|
+
"fork",
|
|
24
|
+
"generate",
|
|
25
|
+
"credits",
|
|
26
|
+
"config",
|
|
27
|
+
"update",
|
|
28
|
+
"completions",
|
|
29
|
+
"whoami"
|
|
30
|
+
];
|
|
31
|
+
var GENERATE_SUBCOMMANDS = ["run", "status", "models", "schema", "pricing", "docs", "upload"];
|
|
32
|
+
var COMMON_FLAGS = ["--help", "--version"];
|
|
33
|
+
var GENERATE_FLAGS = [
|
|
34
|
+
"--async",
|
|
35
|
+
"--download",
|
|
36
|
+
"--result",
|
|
37
|
+
"--cancel",
|
|
38
|
+
"--logs",
|
|
39
|
+
"--category",
|
|
40
|
+
"--status",
|
|
41
|
+
"--limit",
|
|
42
|
+
"--cursor",
|
|
43
|
+
"--endpoint_id",
|
|
44
|
+
"--expand",
|
|
45
|
+
"--format",
|
|
46
|
+
"--json",
|
|
47
|
+
"--quiet"
|
|
48
|
+
];
|
|
49
|
+
var bashScript = () => `# vg completions for bash. Source this file or write it to a file in your
|
|
50
|
+
# bash completion directory (e.g. /etc/bash_completion.d/vg).
|
|
51
|
+
_vg_completions() {
|
|
52
|
+
local cur prev cmd subcmd
|
|
53
|
+
COMPREPLY=()
|
|
54
|
+
cur="\${COMP_WORDS[COMP_CWORD]}"
|
|
55
|
+
prev="\${COMP_WORDS[COMP_CWORD-1]}"
|
|
56
|
+
cmd="\${COMP_WORDS[1]}"
|
|
57
|
+
subcmd="\${COMP_WORDS[2]}"
|
|
58
|
+
|
|
59
|
+
if [[ $COMP_CWORD -eq 1 ]]; then
|
|
60
|
+
COMPREPLY=( $(compgen -W "${SUBCOMMANDS.join(" ")} ${COMMON_FLAGS.join(" ")}" -- "$cur") )
|
|
61
|
+
return
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
case "$cmd" in
|
|
65
|
+
generate)
|
|
66
|
+
if [[ $COMP_CWORD -eq 2 ]]; then
|
|
67
|
+
COMPREPLY=( $(compgen -W "${GENERATE_SUBCOMMANDS.join(" ")} ${GENERATE_FLAGS.join(" ")} ${COMMON_FLAGS.join(" ")}" -- "$cur") )
|
|
68
|
+
return
|
|
69
|
+
fi
|
|
70
|
+
COMPREPLY=( $(compgen -W "${GENERATE_FLAGS.join(" ")} ${COMMON_FLAGS.join(" ")}" -- "$cur") )
|
|
71
|
+
return
|
|
72
|
+
;;
|
|
73
|
+
*)
|
|
74
|
+
COMPREPLY=( $(compgen -W "${COMMON_FLAGS.join(" ")}" -- "$cur") )
|
|
75
|
+
return
|
|
76
|
+
;;
|
|
77
|
+
esac
|
|
78
|
+
}
|
|
79
|
+
complete -F _vg_completions vg
|
|
80
|
+
`;
|
|
81
|
+
var zshScript = () => `# vg completions for zsh. Source this file or place it on your fpath.
|
|
82
|
+
_vg() {
|
|
83
|
+
local -a subcmds generate_subs generate_flags common_flags
|
|
84
|
+
subcmds=(${SUBCOMMANDS.map((s) => `"${s}"`).join(" ")})
|
|
85
|
+
generate_subs=(${GENERATE_SUBCOMMANDS.map((s) => `"${s}"`).join(" ")})
|
|
86
|
+
generate_flags=(${GENERATE_FLAGS.map((s) => `"${s}"`).join(" ")})
|
|
87
|
+
common_flags=(${COMMON_FLAGS.map((s) => `"${s}"`).join(" ")})
|
|
88
|
+
|
|
89
|
+
if (( CURRENT == 2 )); then
|
|
90
|
+
_values "vg subcommand" "\${subcmds[@]}" "\${common_flags[@]}"
|
|
91
|
+
return
|
|
92
|
+
fi
|
|
93
|
+
case "\${words[2]}" in
|
|
94
|
+
generate)
|
|
95
|
+
if (( CURRENT == 3 )); then
|
|
96
|
+
_values "vg generate subcommand" "\${generate_subs[@]}" "\${generate_flags[@]}" "\${common_flags[@]}"
|
|
97
|
+
return
|
|
98
|
+
fi
|
|
99
|
+
_values "vg generate flag" "\${generate_flags[@]}" "\${common_flags[@]}"
|
|
100
|
+
;;
|
|
101
|
+
*)
|
|
102
|
+
_values "vg flag" "\${common_flags[@]}"
|
|
103
|
+
;;
|
|
104
|
+
esac
|
|
105
|
+
}
|
|
106
|
+
compdef _vg vg
|
|
107
|
+
`;
|
|
108
|
+
var fishFlag = (flag, condition) => {
|
|
109
|
+
const isShort = flag.startsWith("-") && !flag.startsWith("--");
|
|
110
|
+
const name = flag.replace(/^--?/u, "");
|
|
111
|
+
const opt = isShort ? "-s" : "-l";
|
|
112
|
+
return `complete -c vg -n '${condition}' ${opt} '${name}'`;
|
|
113
|
+
};
|
|
114
|
+
var fishScript = () => {
|
|
115
|
+
const generateFlagLines = [...GENERATE_FLAGS, ...COMMON_FLAGS].map(
|
|
116
|
+
(flag) => fishFlag(flag, "__fish_seen_subcommand_from generate")
|
|
117
|
+
);
|
|
118
|
+
const otherSubcommands = SUBCOMMANDS.filter((s) => s !== "generate");
|
|
119
|
+
const otherFlagLines = COMMON_FLAGS.flatMap(
|
|
120
|
+
(flag) => otherSubcommands.map((sub) => fishFlag(flag, `__fish_seen_subcommand_from ${sub}`))
|
|
121
|
+
);
|
|
122
|
+
const topLevelFlagLines = COMMON_FLAGS.map((flag) => fishFlag(flag, "__fish_use_subcommand"));
|
|
123
|
+
return `# vg completions for fish.
|
|
124
|
+
complete -c vg -f
|
|
125
|
+
complete -c vg -n '__fish_use_subcommand' -a '${SUBCOMMANDS.join(" ")}'
|
|
126
|
+
${topLevelFlagLines.join("\n")}
|
|
127
|
+
${GENERATE_SUBCOMMANDS.map(
|
|
128
|
+
(sub) => `complete -c vg -n '__fish_seen_subcommand_from generate' -a '${sub}'`
|
|
129
|
+
).join("\n")}
|
|
130
|
+
${generateFlagLines.join("\n")}
|
|
131
|
+
${otherFlagLines.join("\n")}
|
|
132
|
+
`;
|
|
133
|
+
};
|
|
134
|
+
var completionsCommand = defineCommand({
|
|
135
|
+
args: {
|
|
136
|
+
shell: {
|
|
137
|
+
description: "Shell to generate completions for: bash | zsh | fish",
|
|
138
|
+
required: true,
|
|
139
|
+
type: "positional"
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
meta: {
|
|
143
|
+
description: "Print shell completions for vg. Pipe into your shell's completion dir.",
|
|
144
|
+
name: "completions"
|
|
145
|
+
},
|
|
146
|
+
run: ({ args }) => {
|
|
147
|
+
const shell = String(args.shell ?? "");
|
|
148
|
+
if (!isShell(shell)) {
|
|
149
|
+
process.stderr.write(
|
|
150
|
+
`Unsupported shell "${shell}". Expected: ${[...SUPPORTED].join(", ")}
|
|
151
|
+
`
|
|
152
|
+
);
|
|
153
|
+
process.exit(1);
|
|
154
|
+
}
|
|
155
|
+
const scripts = {
|
|
156
|
+
bash: bashScript,
|
|
157
|
+
fish: fishScript,
|
|
158
|
+
zsh: zshScript
|
|
159
|
+
};
|
|
160
|
+
process.stdout.write(scripts[shell]());
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
export {
|
|
164
|
+
completionsCommand
|
|
165
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
initCommand,
|
|
9
|
+
reportSkills
|
|
10
|
+
} from "./chunk-34AHIMX7.js";
|
|
11
|
+
import "./chunk-2QBYTIMH.js";
|
|
12
|
+
import "./chunk-VFFOT7KD.js";
|
|
13
|
+
import "./chunk-PEUP4MZR.js";
|
|
14
|
+
import "./chunk-RZ4DIJQW.js";
|
|
15
|
+
import "./chunk-CU7UY5YJ.js";
|
|
16
|
+
import "./chunk-J6PKNPI2.js";
|
|
17
|
+
import "./chunk-MBXCVCC4.js";
|
|
18
|
+
import "./chunk-CAKBGDCY.js";
|
|
19
|
+
export {
|
|
20
|
+
initCommand,
|
|
21
|
+
reportSkills
|
|
22
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
authErrorCode,
|
|
9
|
+
createClient
|
|
10
|
+
} from "./chunk-PQDBCZRT.js";
|
|
11
|
+
import "./chunk-Z4Z24FWO.js";
|
|
12
|
+
import "./chunk-PEUP4MZR.js";
|
|
13
|
+
import {
|
|
14
|
+
outputArgs,
|
|
15
|
+
writeStructured
|
|
16
|
+
} from "./chunk-ZYCSYJWX.js";
|
|
17
|
+
import {
|
|
18
|
+
assertKnownFlags
|
|
19
|
+
} from "./chunk-RZ4DIJQW.js";
|
|
20
|
+
import {
|
|
21
|
+
getToken
|
|
22
|
+
} from "./chunk-RYFO3ZPO.js";
|
|
23
|
+
import {
|
|
24
|
+
consola
|
|
25
|
+
} from "./chunk-CU7UY5YJ.js";
|
|
26
|
+
import "./chunk-J6PKNPI2.js";
|
|
27
|
+
import {
|
|
28
|
+
defineCommand
|
|
29
|
+
} from "./chunk-MBXCVCC4.js";
|
|
30
|
+
import "./chunk-CAKBGDCY.js";
|
|
31
|
+
|
|
32
|
+
// src/commands/whoami.ts
|
|
33
|
+
var whoamiArgs = { ...outputArgs };
|
|
34
|
+
var whoamiCommand = defineCommand({
|
|
35
|
+
args: whoamiArgs,
|
|
36
|
+
meta: {
|
|
37
|
+
description: "Show the currently authenticated user",
|
|
38
|
+
name: "whoami"
|
|
39
|
+
},
|
|
40
|
+
run: async ({ args, rawArgs }) => {
|
|
41
|
+
assertKnownFlags(rawArgs, whoamiArgs);
|
|
42
|
+
const token = getToken();
|
|
43
|
+
if (!token) {
|
|
44
|
+
consola.warn("Not logged in. Run `vg login` to authenticate.");
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
const client = createClient();
|
|
48
|
+
try {
|
|
49
|
+
const user = await client.auth.me();
|
|
50
|
+
if (writeStructured({ email: user.email, id: user.id, name: user.name }, args)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
consola.log(`${user.name} (${user.email})`);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
const code = authErrorCode(error);
|
|
56
|
+
if (code === "UNAUTHORIZED" || code === "FORBIDDEN") {
|
|
57
|
+
consola.warn("Not authenticated. Run `vg login`, or check your VG_TOKEN / API key.");
|
|
58
|
+
} else {
|
|
59
|
+
consola.error(
|
|
60
|
+
`Failed to fetch current user: ${error instanceof Error ? error.message : String(error)}`
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
export {
|
|
68
|
+
whoamiCommand
|
|
69
|
+
};
|
|
@@ -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
|
+
consola
|
|
30
|
+
} from "./chunk-CU7UY5YJ.js";
|
|
31
|
+
import {
|
|
32
|
+
isJsonObject
|
|
33
|
+
} from "./chunk-J6PKNPI2.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
|
+
};
|