@bitmagic/cli 0.1.48 → 0.1.49
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
CHANGED
|
@@ -209,7 +209,9 @@ specific first:
|
|
|
209
209
|
(`dev`, `upgrade`, `forge`, `generate`, `publish`), and the one thing that outranks a project;
|
|
210
210
|
3. the `environment` field in the project's `bitmagic.json`;
|
|
211
211
|
4. the stored default, written by `bitmagic login`;
|
|
212
|
-
5. `
|
|
212
|
+
5. the environment this CLI's own release line is built for — **`prod` for `@bitmagic/cli`
|
|
213
|
+
(the `latest` tag), `dev` for `@bitmagic/cli@dev`** (any `-dev.N` version, including one run
|
|
214
|
+
from a checkout). A CLI whose version cannot be read falls back to `dev`.
|
|
213
215
|
|
|
214
216
|
Step 3 is what makes a checkout self-describing: `bitmagic init` records which api-server minted
|
|
215
217
|
the project's `gameId` and served the engine pinned beside it, so every later command in that
|
|
@@ -223,10 +225,12 @@ it at startup. A pinned project ignores the stored default, so `bitmagic login`
|
|
|
223
225
|
to the project's environment *without* changing your machine-wide default. `BITMAGIC_API_URL`
|
|
224
226
|
overrides the URL alone, keeping the environment name and its Auth0 tenant.
|
|
225
227
|
|
|
226
|
-
The two published lines are developed against different ones
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
The two published lines are developed against different ones, which is why step 5 asks the CLI
|
|
229
|
+
about itself. `@bitmagic/cli` (the `latest` tag) is the release, built against `prod`;
|
|
230
|
+
`@bitmagic/cli@dev` is the prerelease line, developed against `dev`, where the endpoints it depends
|
|
231
|
+
on exist first. Running a dev build against an environment that has not caught up fails on
|
|
232
|
+
endpoints that are not there yet — so the pairing each line wants is the one it now takes by
|
|
233
|
+
default, and `bitmagic login` needs no `--env` on either.
|
|
230
234
|
|
|
231
235
|
**Inside a project, the pin decides the line**, and nobody should be asked which one they want:
|
|
232
236
|
`dev` and `local` projects take `@bitmagic/cli@dev`, `prod` projects take the plain
|
|
@@ -19,8 +19,27 @@ export interface ResolveEnvironmentOptions {
|
|
|
19
19
|
projectDefault?: string;
|
|
20
20
|
/** The default recorded in the credentials file, if any. */
|
|
21
21
|
storedDefault?: string;
|
|
22
|
+
/**
|
|
23
|
+
* This CLI's own version, which decides the final fallback — see laneDefaultEnvironment.
|
|
24
|
+
* Passed in rather than read here so the precedence chain stays pure and testable; the wiring
|
|
25
|
+
* half below supplies it from `currentCliVersion()`.
|
|
26
|
+
*/
|
|
27
|
+
cliVersion?: string;
|
|
22
28
|
env?: Record<string, string | undefined>;
|
|
23
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* The environment a CLI points at when nothing else says: the one its own release line is built
|
|
32
|
+
* for. `@bitmagic/cli` from `latest` is the release a creator installs to make a real game, so it
|
|
33
|
+
* targets prod; `@bitmagic/cli@dev` carries `-dev.N` and exists to exercise endpoints that land on
|
|
34
|
+
* the dev api-server first, so it targets dev. Requiring `--env prod` on the release line made the
|
|
35
|
+
* common case the one that needed a flag.
|
|
36
|
+
*
|
|
37
|
+
* An unreadable version means dev, not prod. It is the direction whose mistakes are cheap: a dev
|
|
38
|
+
* CLI aimed at prod can publish a real game to bitmagic.ai, while a prod CLI aimed at dev fails
|
|
39
|
+
* visibly at the first authenticated call, because a token minted for one tenant's audience is not
|
|
40
|
+
* accepted by the other.
|
|
41
|
+
*/
|
|
42
|
+
export declare function laneDefaultEnvironment(cliVersion: string): EnvironmentName;
|
|
24
43
|
export interface EnvironmentSelection {
|
|
25
44
|
environment: Environment;
|
|
26
45
|
source: EnvironmentSource;
|
|
@@ -47,6 +66,8 @@ export interface CommandEnvironmentOptions {
|
|
|
47
66
|
cwd?: string;
|
|
48
67
|
/** Test-only credentials-directory override, matching the `baseDir` deps commands already thread. */
|
|
49
68
|
baseDir?: string;
|
|
69
|
+
/** Test-only override for the running CLI's version; production callers omit it. */
|
|
70
|
+
cliVersion?: string;
|
|
50
71
|
env?: Record<string, string | undefined>;
|
|
51
72
|
}
|
|
52
73
|
export declare function selectEnvironmentForCommand(options?: CommandEnvironmentOptions): EnvironmentSelection;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readProjectEnvironment } from '../project/context.js';
|
|
2
2
|
import { CliError } from '../errors.js';
|
|
3
3
|
import { readDefaultEnvironment } from './credentials.js';
|
|
4
|
+
import { currentCliVersion } from '../update/cli-version.js';
|
|
4
5
|
const DEV_AUTH0_DOMAIN = 'bitmagic-v3-staging.us.auth0.com';
|
|
5
6
|
const DEV_AUTH0_AUDIENCE = 'https://api.bitmagic.cloud';
|
|
6
7
|
// Public identifier of the "Bitmagic CLI APP" Auth0 Native application, not a secret — native
|
|
@@ -41,6 +42,23 @@ export const ENVIRONMENT_NAMES = Object.keys(ENVIRONMENTS);
|
|
|
41
42
|
export function isEnvironmentName(value) {
|
|
42
43
|
return Object.prototype.hasOwnProperty.call(ENVIRONMENTS, value);
|
|
43
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* The environment a CLI points at when nothing else says: the one its own release line is built
|
|
47
|
+
* for. `@bitmagic/cli` from `latest` is the release a creator installs to make a real game, so it
|
|
48
|
+
* targets prod; `@bitmagic/cli@dev` carries `-dev.N` and exists to exercise endpoints that land on
|
|
49
|
+
* the dev api-server first, so it targets dev. Requiring `--env prod` on the release line made the
|
|
50
|
+
* common case the one that needed a flag.
|
|
51
|
+
*
|
|
52
|
+
* An unreadable version means dev, not prod. It is the direction whose mistakes are cheap: a dev
|
|
53
|
+
* CLI aimed at prod can publish a real game to bitmagic.ai, while a prod CLI aimed at dev fails
|
|
54
|
+
* visibly at the first authenticated call, because a token minted for one tenant's audience is not
|
|
55
|
+
* accepted by the other.
|
|
56
|
+
*/
|
|
57
|
+
export function laneDefaultEnvironment(cliVersion) {
|
|
58
|
+
if (!cliVersion)
|
|
59
|
+
return 'dev';
|
|
60
|
+
return cliVersion.includes('-') ? 'dev' : 'prod';
|
|
61
|
+
}
|
|
44
62
|
/** Where the bad value came from, and therefore how to tell the user to fix it. */
|
|
45
63
|
function unknownEnvironmentMessage(candidate, source) {
|
|
46
64
|
const valid = `Valid environments: ${ENVIRONMENT_NAMES.join(', ')}.`;
|
|
@@ -79,7 +97,7 @@ export function selectEnvironment(options = {}) {
|
|
|
79
97
|
[validStoredDefault, 'stored'],
|
|
80
98
|
];
|
|
81
99
|
const chosen = candidates.find(([value]) => value !== undefined);
|
|
82
|
-
const candidate = chosen?.[0] ?? '
|
|
100
|
+
const candidate = chosen?.[0] ?? laneDefaultEnvironment(options.cliVersion ?? '');
|
|
83
101
|
const source = chosen?.[1] ?? 'default';
|
|
84
102
|
if (!isEnvironmentName(candidate)) {
|
|
85
103
|
throw new CliError(unknownEnvironmentMessage(candidate, source));
|
|
@@ -106,7 +124,10 @@ export function describeEnvironmentSource(source) {
|
|
|
106
124
|
case 'stored':
|
|
107
125
|
return 'from your last login';
|
|
108
126
|
case 'default':
|
|
109
|
-
|
|
127
|
+
// Named for the reason rather than left as "the default", because the answer now differs
|
|
128
|
+
// between two CLIs a creator may both have installed, and "prod" with no explanation reads
|
|
129
|
+
// like the CLI decided on its own.
|
|
130
|
+
return 'the default for this CLI build';
|
|
110
131
|
}
|
|
111
132
|
}
|
|
112
133
|
export function selectEnvironmentForCommand(options = {}) {
|
|
@@ -114,6 +135,9 @@ export function selectEnvironmentForCommand(options = {}) {
|
|
|
114
135
|
explicit: options.explicit,
|
|
115
136
|
projectDefault: readProjectEnvironment(options.cwd),
|
|
116
137
|
storedDefault: readDefaultEnvironment(options.baseDir),
|
|
138
|
+
// Read here rather than in selectEnvironment: this is the wiring half, and currentCliVersion
|
|
139
|
+
// touches the filesystem. `cliVersion` stays overridable so a test can pin a lane.
|
|
140
|
+
cliVersion: options.cliVersion ?? currentCliVersion(),
|
|
117
141
|
env: options.env,
|
|
118
142
|
});
|
|
119
143
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environments.js","sourceRoot":"","sources":["../../src/config/environments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,s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C,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,QAAQ,CAChB,6CAA6C,WAAW,CAAC,IAAI,iBAAiB;YAC5E,gFAAgF;YAChF,yCAAyC,CAC5C,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitmagic/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.49",
|
|
4
4
|
"description": "Build Bitmagic games from your own agent tool",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"author": "Bitmagic Oy",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"fflate": "^0.8.2",
|
|
24
24
|
"playwright-core": "^1.59.1",
|
|
25
25
|
"tar": "^7.4.3",
|
|
26
|
-
"@bitmagic/
|
|
27
|
-
"@bitmagic/
|
|
28
|
-
"@bitmagic/
|
|
26
|
+
"@bitmagic/world-forger": "0.1.9",
|
|
27
|
+
"@bitmagic/animation-forger": "0.1.4",
|
|
28
|
+
"@bitmagic/asset-core": "0.2.4"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@eslint/js": "^9.38.0",
|