@wildshard/cli 0.0.0-stage → 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/bin/route.mjs +24 -0
- package/bin/wildshard.mjs +13 -0
- package/package.json +35 -3
- package/README.md +0 -3
package/bin/route.mjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// SDK-SPLIT SP10: which program a `wildshard` invocation runs. Kept apart from the bin so tests can import it.
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { dirname, resolve } from 'node:path';
|
|
5
|
+
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
/** @param {string} name @param {string} file @returns {string} `file` inside the installed package `name`. */
|
|
8
|
+
export const inPackage = (name, file) => resolve(dirname(require.resolve(`${name}/package.json`)), file);
|
|
9
|
+
|
|
10
|
+
/** @param {readonly string[]} args @returns {string | undefined} build's compiled bin, when this `build` is its to run. */
|
|
11
|
+
export function buildBin(args) {
|
|
12
|
+
const [command, operand] = args;
|
|
13
|
+
if (command !== 'build' || operand === undefined || operand.startsWith('-')) return undefined;
|
|
14
|
+
if (args.some(arg => arg === '--help' || arg === '-h' || arg === '--behaviour-only' || arg.startsWith('--input-receipt='))) return undefined;
|
|
15
|
+
// `build <folder>` of a built shard file folder (SA3) is dev's: it writes the shard file, no generators run.
|
|
16
|
+
if (existsSync(resolve(operand, 'shard.json')) && !existsSync(resolve(operand, 'shard.config.ts'))) return undefined;
|
|
17
|
+
const script = inPackage('@wildshard/build', 'dist/build.mjs');
|
|
18
|
+
return existsSync(script) ? script : undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** @param {readonly string[]} args @returns {string} the script this invocation runs. */
|
|
22
|
+
export function route(args) {
|
|
23
|
+
return buildBin(args) ?? inPackage('@wildshard/dev', 'bin/wildshard.mjs');
|
|
24
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// `wildshard` (SDK-SPLIT SP10, D4, Q34): the one command an author installs. It only dispatches (bin/route.mjs).
|
|
3
|
+
// - `build <source>` runs @wildshard/build's compiled bin (dist/build.mjs, from its prepack) straight away: no dev, no
|
|
4
|
+
// engine, no vite. A built folder (`build <folder>` with a shard.json), recorded builds (`--input-receipt`) and
|
|
5
|
+
// `--behaviour-only` stay on dev's CLI, which owns them; so does a checkout whose build is not compiled yet.
|
|
6
|
+
// - Every other verb, help and `--version` load dev's CLI (packages/dev/bin/wildshard.mjs) only when they run.
|
|
7
|
+
import { pathToFileURL } from 'node:url';
|
|
8
|
+
import { buildBin, inPackage } from './route.mjs';
|
|
9
|
+
|
|
10
|
+
const build = buildBin(process.argv.slice(2));
|
|
11
|
+
// Build's bin reads its operands from argv[2]; dev's bin reads the verb from argv[2] as before.
|
|
12
|
+
if (build !== undefined) process.argv.splice(1, 2, build);
|
|
13
|
+
await import(pathToFileURL(build ?? inPackage('@wildshard/dev', 'bin/wildshard.mjs')).href);
|
package/package.json
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildshard/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "The `wildshard` command (SDK-SPLIT SP10): one install brings build, upload and dev (the local game and the engine). `build` runs @wildshard/build's compiled bin and never loads the engine; every other verb loads dev's CLI lazily.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/project-wildshard/sharddev.git",
|
|
9
|
+
"directory": "packages/cli"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=24.18.0"
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"wildshard": "./bin/wildshard.mjs"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"bin"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@wildshard/dev": "0.4.0",
|
|
23
|
+
"@wildshard/upload": "0.4.0",
|
|
24
|
+
"@wildshard/build": "0.4.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@wildshard/sdk": "0.4.0"
|
|
28
|
+
},
|
|
29
|
+
"exports": {
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"test": "node --test 'test/*.test.mjs'"
|
|
37
|
+
}
|
|
6
38
|
}
|
package/README.md
DELETED