vibedgames 0.3.0 → 0.4.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 +45 -12
- package/dist/commands/completions.js +3 -0
- package/dist/commands/credits.d.ts +10 -0
- package/dist/commands/credits.js +137 -0
- package/dist/commands/deploy.d.ts +2 -2
- package/dist/commands/deploy.js +4 -5
- package/dist/commands/fork.d.ts +8 -5
- package/dist/commands/fork.js +5 -10
- package/dist/commands/generate.js +69 -53
- package/dist/commands/init.js +18 -6
- package/dist/commands/new.js +1 -1
- package/dist/commands/playtest.d.ts +29 -0
- package/dist/commands/playtest.js +325 -0
- package/dist/commands/update.d.ts +1 -1
- package/dist/commands/update.js +14 -8
- package/dist/index.js +11 -3
- package/dist/lib/config-file.d.ts +6 -0
- package/dist/lib/config-file.js +6 -0
- package/dist/lib/manifest.js +2 -0
- package/dist/lib/output.d.ts +45 -0
- package/dist/lib/output.js +94 -0
- package/dist/lib/package-manager.d.ts +25 -0
- package/dist/lib/package-manager.js +72 -0
- package/dist/lib/run.d.ts +6 -0
- package/dist/lib/run.js +6 -0
- package/package.json +8 -8
- package/dist/.tsbuildinfo +0 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Work out which package manager installed this CLI, so a self-update uses it.
|
|
3
|
+
*
|
|
4
|
+
* `vg init` and `vg update` both used to shell out to `npm install -g
|
|
5
|
+
* vibedgames` unconditionally. On a machine where the CLI came from pnpm, bun
|
|
6
|
+
* or yarn, that is wrong twice over: npm may not be installed at all, and if it
|
|
7
|
+
* is, it installs a *second* copy into a different global prefix — so the
|
|
8
|
+
* update silently lands somewhere the shell isn't looking and `vg --version`
|
|
9
|
+
* doesn't move.
|
|
10
|
+
*
|
|
11
|
+
* The install path is the evidence. Each manager puts globals somewhere
|
|
12
|
+
* recognisable, so the directory this file was loaded from names the manager
|
|
13
|
+
* that put it there.
|
|
14
|
+
*/
|
|
15
|
+
export type PackageManager = "npm" | "pnpm" | "yarn" | "bun";
|
|
16
|
+
export declare const PKG_NAME = "vibedgames";
|
|
17
|
+
/**
|
|
18
|
+
* `installPath` is where the CLI is installed — normally the directory this
|
|
19
|
+
* module resolves from. Bun's own runtime is a signal in its own right.
|
|
20
|
+
*/
|
|
21
|
+
export declare function detectPackageManager(installPath: string, env?: NodeJS.ProcessEnv): PackageManager;
|
|
22
|
+
/** The argv that installs or upgrades a package globally, per manager. */
|
|
23
|
+
export declare function globalInstallArgs(manager: PackageManager, pkg?: string): string[];
|
|
24
|
+
/** The command a user can copy-paste when the automatic update can't run. */
|
|
25
|
+
export declare function globalInstallCommand(manager: PackageManager, pkg?: string): string;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Work out which package manager installed this CLI, so a self-update uses it.
|
|
3
|
+
*
|
|
4
|
+
* `vg init` and `vg update` both used to shell out to `npm install -g
|
|
5
|
+
* vibedgames` unconditionally. On a machine where the CLI came from pnpm, bun
|
|
6
|
+
* or yarn, that is wrong twice over: npm may not be installed at all, and if it
|
|
7
|
+
* is, it installs a *second* copy into a different global prefix — so the
|
|
8
|
+
* update silently lands somewhere the shell isn't looking and `vg --version`
|
|
9
|
+
* doesn't move.
|
|
10
|
+
*
|
|
11
|
+
* The install path is the evidence. Each manager puts globals somewhere
|
|
12
|
+
* recognisable, so the directory this file was loaded from names the manager
|
|
13
|
+
* that put it there.
|
|
14
|
+
*/
|
|
15
|
+
export const PKG_NAME = "vibedgames";
|
|
16
|
+
/**
|
|
17
|
+
* Global install directory fingerprints, most specific first.
|
|
18
|
+
*
|
|
19
|
+
* The npm entries come last because they are the loosest: `lib/node_modules`
|
|
20
|
+
* is npm's global prefix on unix and `npm\node_modules` is its Windows one,
|
|
21
|
+
* but neither is distinctive enough to check before the managers that have a
|
|
22
|
+
* directory named after them.
|
|
23
|
+
*/
|
|
24
|
+
const SIGNATURES = [
|
|
25
|
+
["bun", /[/\\]\.bun[/\\]/],
|
|
26
|
+
// pnpm's global store, not a project-local `node_modules/.pnpm`.
|
|
27
|
+
["pnpm", /[/\\](?:pnpm[/\\]global|\.pnpm-global|Library[/\\]pnpm)[/\\]/],
|
|
28
|
+
["yarn", /[/\\](?:\.yarn|yarn[/\\]global|\.config[/\\]yarn)[/\\]/],
|
|
29
|
+
["npm", /[/\\]lib[/\\]node_modules[/\\]/],
|
|
30
|
+
["npm", /[/\\]npm[/\\]node_modules[/\\]/],
|
|
31
|
+
];
|
|
32
|
+
/**
|
|
33
|
+
* `npm_config_user_agent` is set by whichever manager is running us — reliable
|
|
34
|
+
* when `vg` was invoked through a script (`pnpm vg …`), absent otherwise.
|
|
35
|
+
*/
|
|
36
|
+
function fromUserAgent(userAgent) {
|
|
37
|
+
if (!userAgent)
|
|
38
|
+
return null;
|
|
39
|
+
const name = userAgent.split("/")[0];
|
|
40
|
+
return name === "npm" || name === "pnpm" || name === "yarn" || name === "bun" ? name : null;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* `installPath` is where the CLI is installed — normally the directory this
|
|
44
|
+
* module resolves from. Bun's own runtime is a signal in its own right.
|
|
45
|
+
*/
|
|
46
|
+
export function detectPackageManager(installPath, env = process.env) {
|
|
47
|
+
for (const [manager, signature] of SIGNATURES) {
|
|
48
|
+
if (signature.test(installPath))
|
|
49
|
+
return manager;
|
|
50
|
+
}
|
|
51
|
+
// Bun reports itself in versions; running under it means `bun add` works.
|
|
52
|
+
if (typeof globalThis.Bun !== "undefined")
|
|
53
|
+
return "bun";
|
|
54
|
+
return fromUserAgent(env.npm_config_user_agent) ?? "npm";
|
|
55
|
+
}
|
|
56
|
+
/** The argv that installs or upgrades a package globally, per manager. */
|
|
57
|
+
export function globalInstallArgs(manager, pkg = PKG_NAME) {
|
|
58
|
+
switch (manager) {
|
|
59
|
+
case "pnpm":
|
|
60
|
+
return ["add", "-g", pkg];
|
|
61
|
+
case "yarn":
|
|
62
|
+
return ["global", "add", pkg];
|
|
63
|
+
case "bun":
|
|
64
|
+
return ["add", "-g", pkg];
|
|
65
|
+
case "npm":
|
|
66
|
+
return ["install", "-g", pkg];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/** The command a user can copy-paste when the automatic update can't run. */
|
|
70
|
+
export function globalInstallCommand(manager, pkg = PKG_NAME) {
|
|
71
|
+
return `${manager} ${globalInstallArgs(manager, pkg).join(" ")}`;
|
|
72
|
+
}
|
package/dist/lib/run.d.ts
CHANGED
|
@@ -2,4 +2,10 @@ export type RunResult = {
|
|
|
2
2
|
code: number;
|
|
3
3
|
output: string;
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* True when the command never started, as opposed to running and failing.
|
|
7
|
+
* `run` turns a spawn error into an exit code, so the message is the only
|
|
8
|
+
* thing that separates "no such binary" from "the binary said no".
|
|
9
|
+
*/
|
|
10
|
+
export declare const isMissingCommand: (result: RunResult) => boolean;
|
|
5
11
|
export declare const run: (cmd: string, args: string[]) => Promise<RunResult>;
|
package/dist/lib/run.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import spawn from "cross-spawn";
|
|
2
|
+
/**
|
|
3
|
+
* True when the command never started, as opposed to running and failing.
|
|
4
|
+
* `run` turns a spawn error into an exit code, so the message is the only
|
|
5
|
+
* thing that separates "no such binary" from "the binary said no".
|
|
6
|
+
*/
|
|
7
|
+
export const isMissingCommand = (result) => result.code !== 0 && /ENOENT|not found|not recognized/i.test(result.output);
|
|
2
8
|
export const run = (cmd, args) => new Promise((resolve) => {
|
|
3
9
|
const chunks = [];
|
|
4
10
|
const child = spawn(cmd, args, { stdio: ["ignore", "pipe", "pipe"] });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vibedgames",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"bin": {
|
|
6
6
|
"vg": "./dist/index.js"
|
|
@@ -14,25 +14,25 @@
|
|
|
14
14
|
"citty": "^0.2.2",
|
|
15
15
|
"consola": "^3.4.2",
|
|
16
16
|
"cross-spawn": "^7.0.6",
|
|
17
|
-
"ignore": "^7.0.
|
|
17
|
+
"ignore": "^7.0.6",
|
|
18
18
|
"superjson": "^2.2.6",
|
|
19
|
-
"tar": "^7.5.
|
|
19
|
+
"tar": "^7.5.22",
|
|
20
20
|
"tiged": "^2.12.8"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@cloudflare/workers-types": "^5.
|
|
24
|
-
"@kyh/tsconfig": "^1.
|
|
23
|
+
"@cloudflare/workers-types": "^5.20260814.1",
|
|
24
|
+
"@kyh/tsconfig": "^1.2.0",
|
|
25
25
|
"@trpc/server": "^11.18.0",
|
|
26
26
|
"@types/cross-spawn": "^6.0.6",
|
|
27
|
-
"@types/node": "^26.
|
|
27
|
+
"@types/node": "^26.2.0",
|
|
28
28
|
"typescript": "^7.0.2",
|
|
29
29
|
"@repo/api": "^0.1.0"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
|
-
"build": "tsc",
|
|
32
|
+
"build": "tsc && chmod +x dist/index.js",
|
|
33
33
|
"dev": "tsc --watch",
|
|
34
34
|
"clean": "rm -rf .turbo dist node_modules",
|
|
35
|
-
"test
|
|
35
|
+
"test": "node --import tsx --test test/*.test.ts",
|
|
36
36
|
"typecheck": "tsc --noEmit"
|
|
37
37
|
}
|
|
38
38
|
}
|