@bitmagic/cli 0.1.38 → 0.1.39
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 +32 -7
- package/dist/auth/subscribe-flow.d.ts +59 -0
- package/dist/auth/subscribe-flow.js +102 -0
- package/dist/auth/subscribe-flow.js.map +1 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/login.js +27 -7
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/subscribe.d.ts +14 -0
- package/dist/commands/subscribe.js +60 -0
- package/dist/commands/subscribe.js.map +1 -0
- package/dist/commands/whoami.d.ts +10 -14
- package/dist/commands/whoami.js +17 -12
- package/dist/commands/whoami.js.map +1 -1
- package/dist/http/client.d.ts +10 -0
- package/dist/http/client.js +38 -3
- package/dist/http/client.js.map +1 -1
- package/dist/scaffold/project-files.js +4 -2
- package/dist/scaffold/project-files.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,14 +7,38 @@ web project or per-session pod required.
|
|
|
7
7
|
|
|
8
8
|
## Who can use it
|
|
9
9
|
|
|
10
|
-
The CLI requires an **active Bitmagic Pro subscription
|
|
11
|
-
|
|
12
|
-
immediately and prints how you were admitted, so you find out at login rather than three commands
|
|
13
|
-
later; `bitmagic whoami` shows it again at any time.
|
|
10
|
+
The CLI requires an **active Bitmagic Pro subscription**. There is no other way in — an Auth0 role
|
|
11
|
+
used to work and no longer does.
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
You do not have to go and find a signup page: `bitmagic login` checks as soon as you have
|
|
14
|
+
authenticated and, if you are not subscribed, opens Stripe Checkout in the browser you are already
|
|
15
|
+
in and waits for it to complete.
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
$ bitmagic login
|
|
19
|
+
Open: https://…/activate?user_code=KLMN-PQRS
|
|
20
|
+
Code: KLMN-PQRS
|
|
21
|
+
Waiting for approval…
|
|
22
|
+
Logged in to dev as you@example.com.
|
|
23
|
+
|
|
24
|
+
The Bitmagic CLI needs a Bitmagic Pro subscription.
|
|
25
|
+
Pro gives you a weekly and a 5-hour spark allowance that refill on their own,
|
|
26
|
+
and pays for generating assets, cover art and worlds.
|
|
27
|
+
|
|
28
|
+
Opening checkout in your browser:
|
|
29
|
+
https://checkout.stripe.com/c/pay/cs_…
|
|
30
|
+
|
|
31
|
+
Waiting for your subscription… (Ctrl-C is safe — run `bitmagic subscribe` to resume)
|
|
32
|
+
|
|
33
|
+
Bitmagic Pro is active. You are ready — try `bitmagic init`.
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Ctrl-C at any point is safe; your login is already stored. `bitmagic subscribe` picks up where you
|
|
37
|
+
left off, and `bitmagic whoami` says whether Pro is active and when it renews.
|
|
38
|
+
|
|
39
|
+
The spark allowance refills on a rolling basis — a weekly budget and a 5-hour one — and is what pays
|
|
40
|
+
for `bitmagic generate`, `cover` and `forge`. When an allowance runs out, generation falls back to
|
|
41
|
+
your purchased spark balance. `bitmagic usage` shows where it went.
|
|
18
42
|
|
|
19
43
|
## Install
|
|
20
44
|
|
|
@@ -46,6 +70,7 @@ browser reloads itself on every change and the assets panel shows each generatio
|
|
|
46
70
|
| Command | What it does |
|
|
47
71
|
|---|---|
|
|
48
72
|
| `bitmagic login [--env <env>]` | Device-code auth against Auth0; stores credentials per environment. |
|
|
73
|
+
| `bitmagic subscribe [--no-wait]` | Start the Bitmagic Pro subscription the CLI requires; opens checkout and waits for it. |
|
|
49
74
|
| `bitmagic usage [--days N]` | Where this account's sparks went, and what Pro allowance is left. |
|
|
50
75
|
| `bitmagic logout [--env <env>]` | Remove stored credentials for an environment. |
|
|
51
76
|
| `bitmagic whoami [--env <env>]` | Show the identity the CLI is authenticated as. |
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { openInBrowser } from '../open-browser.js';
|
|
2
|
+
import type { Environment } from '../config/environments.js';
|
|
3
|
+
import type { Output } from '../output.js';
|
|
4
|
+
/** How long to wait for the webhook to land the subscription before giving up. */
|
|
5
|
+
export declare const SUBSCRIBE_POLL_TIMEOUT_MS: number;
|
|
6
|
+
export declare const SUBSCRIBE_POLL_INTERVAL_MS = 3000;
|
|
7
|
+
export interface WhoamiResponse {
|
|
8
|
+
userId: string;
|
|
9
|
+
roles: string[];
|
|
10
|
+
/** Whether the caller currently holds an entitled subscription. */
|
|
11
|
+
pro: boolean;
|
|
12
|
+
/** Period end of any subscription row, including a lapsed one. */
|
|
13
|
+
proUntil: string | null;
|
|
14
|
+
/** Set when the subscription is live but will not renew. Optional: older api-servers omit it. */
|
|
15
|
+
cancelAtPeriodEnd?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* PURE. One line describing where the caller's subscription stands.
|
|
19
|
+
*
|
|
20
|
+
* Covers the case a status boolean cannot: a subscription that is live TODAY
|
|
21
|
+
* but set not to renew. Finding that out when a command is refused mid-work is
|
|
22
|
+
* the worst possible moment, so every command that greets the creator says it.
|
|
23
|
+
*/
|
|
24
|
+
export declare function describeProStatus(me: WhoamiResponse): string;
|
|
25
|
+
export interface SubscribeDeps {
|
|
26
|
+
fetch: typeof globalThis.fetch;
|
|
27
|
+
sleep: (ms: number) => Promise<void>;
|
|
28
|
+
now: () => number;
|
|
29
|
+
openInBrowser: typeof openInBrowser;
|
|
30
|
+
}
|
|
31
|
+
export declare const defaultSubscribeDeps: SubscribeDeps;
|
|
32
|
+
export declare function fetchWhoami(environment: Environment, token: string, deps: SubscribeDeps): Promise<WhoamiResponse>;
|
|
33
|
+
export interface SubscribeOptions {
|
|
34
|
+
/**
|
|
35
|
+
* Do not launch a browser — print the URL instead. Set under `--json`: an
|
|
36
|
+
* agent tool's machine spawning a window unasked is surprising, and the URL
|
|
37
|
+
* is the actionable thing there. `BITMAGIC_NO_OPEN` is honoured separately,
|
|
38
|
+
* inside openInBrowser.
|
|
39
|
+
*/
|
|
40
|
+
noOpen?: boolean;
|
|
41
|
+
/** Skip the wait entirely and return as soon as checkout is open. */
|
|
42
|
+
noWait?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface SubscribeResult {
|
|
45
|
+
/** True when the subscription was confirmed active before we returned. */
|
|
46
|
+
pro: boolean;
|
|
47
|
+
/** The checkout URL, when one was created (absent if already subscribed). */
|
|
48
|
+
checkoutUrl?: string;
|
|
49
|
+
/** Why we stopped waiting, when we did not confirm. */
|
|
50
|
+
reason?: 'timeout' | 'not-waited';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Explain that Pro is required, open checkout, and wait for it to land.
|
|
54
|
+
*
|
|
55
|
+
* Returns rather than throwing when the creator does not finish: abandoning
|
|
56
|
+
* checkout is a decision, not an error, and the credentials from a successful
|
|
57
|
+
* login are still worth keeping.
|
|
58
|
+
*/
|
|
59
|
+
export declare function runSubscribeFlow(environment: Environment, token: string, output: Output, options?: SubscribeOptions, deps?: SubscribeDeps): Promise<SubscribeResult>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Getting a logged-in creator from "no subscription" to "ready to work".
|
|
3
|
+
*
|
|
4
|
+
* The Bitmagic CLI requires an active Bitmagic Pro subscription, so for a new
|
|
5
|
+
* creator the very first command would otherwise be a 403. Rather than print an
|
|
6
|
+
* error and a URL to retype, the CLI creates the Stripe Checkout session itself
|
|
7
|
+
* and opens it: `bitmagic login` flows straight from the device-code approval
|
|
8
|
+
* into paying, in the same browser, and then confirms.
|
|
9
|
+
*
|
|
10
|
+
* Two api-server routes make this possible, and both live OUTSIDE the CLI's
|
|
11
|
+
* entitlement gate for exactly this reason (see cli-onboarding-routes.ts):
|
|
12
|
+
* `GET /whoami` answers whether the caller is entitled, and
|
|
13
|
+
* `POST /pro/checkout` mints a checkout URL for the caller's own account.
|
|
14
|
+
*
|
|
15
|
+
* Shared by `login` and by `subscribe`, so a creator who abandoned checkout
|
|
16
|
+
* gets an identical second run rather than a different-looking recovery path.
|
|
17
|
+
*/
|
|
18
|
+
import { apiGet, apiPost } from '../http/client.js';
|
|
19
|
+
import { openInBrowser } from '../open-browser.js';
|
|
20
|
+
/** How long to wait for the webhook to land the subscription before giving up. */
|
|
21
|
+
export const SUBSCRIBE_POLL_TIMEOUT_MS = 15 * 60_000;
|
|
22
|
+
export const SUBSCRIBE_POLL_INTERVAL_MS = 3_000;
|
|
23
|
+
/**
|
|
24
|
+
* PURE. One line describing where the caller's subscription stands.
|
|
25
|
+
*
|
|
26
|
+
* Covers the case a status boolean cannot: a subscription that is live TODAY
|
|
27
|
+
* but set not to renew. Finding that out when a command is refused mid-work is
|
|
28
|
+
* the worst possible moment, so every command that greets the creator says it.
|
|
29
|
+
*/
|
|
30
|
+
export function describeProStatus(me) {
|
|
31
|
+
const day = (iso) => iso.slice(0, 10);
|
|
32
|
+
if (me.pro) {
|
|
33
|
+
if (!me.proUntil)
|
|
34
|
+
return 'Bitmagic Pro is active.';
|
|
35
|
+
return me.cancelAtPeriodEnd === true
|
|
36
|
+
? `Bitmagic Pro is active until ${day(me.proUntil)} and will NOT renew — \`bitmagic subscribe\` to keep it.`
|
|
37
|
+
: `Bitmagic Pro is active. Renews ${day(me.proUntil)}.`;
|
|
38
|
+
}
|
|
39
|
+
return me.proUntil
|
|
40
|
+
? `Bitmagic Pro ended on ${day(me.proUntil)}.`
|
|
41
|
+
: 'No Bitmagic Pro subscription.';
|
|
42
|
+
}
|
|
43
|
+
export const defaultSubscribeDeps = {
|
|
44
|
+
fetch: globalThis.fetch,
|
|
45
|
+
sleep: (ms) => new Promise((r) => setTimeout(r, ms)),
|
|
46
|
+
now: () => Date.now(),
|
|
47
|
+
openInBrowser,
|
|
48
|
+
};
|
|
49
|
+
export function fetchWhoami(environment, token, deps) {
|
|
50
|
+
return apiGet(environment, '/api/cli/v1/whoami', token, { fetch: deps.fetch });
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Explain that Pro is required, open checkout, and wait for it to land.
|
|
54
|
+
*
|
|
55
|
+
* Returns rather than throwing when the creator does not finish: abandoning
|
|
56
|
+
* checkout is a decision, not an error, and the credentials from a successful
|
|
57
|
+
* login are still worth keeping.
|
|
58
|
+
*/
|
|
59
|
+
export async function runSubscribeFlow(environment, token, output, options = {}, deps = defaultSubscribeDeps) {
|
|
60
|
+
const checkout = await apiPost(environment, '/api/cli/v1/pro/checkout', token, {}, {
|
|
61
|
+
fetch: deps.fetch,
|
|
62
|
+
});
|
|
63
|
+
output.info('');
|
|
64
|
+
output.info('The Bitmagic CLI needs a Bitmagic Pro subscription.');
|
|
65
|
+
output.info('Pro gives you a weekly and a 5-hour spark allowance that refill on their own,');
|
|
66
|
+
output.info('and pays for generating assets, cover art and worlds.');
|
|
67
|
+
output.info('');
|
|
68
|
+
// Always print the URL, opened or not: a printed URL works on a machine with
|
|
69
|
+
// no browser, in a container, and in a log an agent reads back later.
|
|
70
|
+
const opened = options.noOpen === true
|
|
71
|
+
? false
|
|
72
|
+
: deps.openInBrowser(checkout.url, { log: (m) => output.info(m) });
|
|
73
|
+
output.info(opened ? `Opening checkout in your browser:\n ${checkout.url}` : `Subscribe at:\n ${checkout.url}`);
|
|
74
|
+
if (options.noWait === true) {
|
|
75
|
+
return { pro: false, checkoutUrl: checkout.url, reason: 'not-waited' };
|
|
76
|
+
}
|
|
77
|
+
output.info('');
|
|
78
|
+
output.info('Waiting for your subscription… (Ctrl-C is safe — run `bitmagic subscribe` to resume)');
|
|
79
|
+
const deadline = deps.now() + SUBSCRIBE_POLL_TIMEOUT_MS;
|
|
80
|
+
while (deps.now() < deadline) {
|
|
81
|
+
await deps.sleep(SUBSCRIBE_POLL_INTERVAL_MS);
|
|
82
|
+
// A transient failure mid-poll must not end the flow — the creator may
|
|
83
|
+
// still be typing their card in. Only a definitive "yes" stops the loop.
|
|
84
|
+
let me = null;
|
|
85
|
+
try {
|
|
86
|
+
me = await fetchWhoami(environment, token, deps);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (me.pro) {
|
|
92
|
+
output.info('');
|
|
93
|
+
output.info('Bitmagic Pro is active. You are ready — try `bitmagic init`.');
|
|
94
|
+
return { pro: true, checkoutUrl: checkout.url };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
output.info('');
|
|
98
|
+
output.info('Still waiting on Stripe. Run `bitmagic usage` once it completes, or');
|
|
99
|
+
output.info('`bitmagic subscribe` to start again.');
|
|
100
|
+
return { pro: false, checkoutUrl: checkout.url, reason: 'timeout' };
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=subscribe-flow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscribe-flow.js","sourceRoot":"","sources":["../../src/auth/subscribe-flow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAInD,kFAAkF;AAClF,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,MAAM,CAAC;AACrD,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAahD;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAkB;IAClD,MAAM,GAAG,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC9C,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC;QACX,IAAI,CAAC,EAAE,CAAC,QAAQ;YAAE,OAAO,yBAAyB,CAAC;QACnD,OAAO,EAAE,CAAC,iBAAiB,KAAK,IAAI;YAClC,CAAC,CAAC,gCAAgC,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,0DAA0D;YAC5G,CAAC,CAAC,kCAAkC,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,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,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC;QAClD,CAAC;IACH,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChB,MAAM,CAAC,IAAI,CAAC,qEAAqE,CAAC,CAAC;IACnF,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;IACpD,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AACtE,CAAC"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -38,6 +38,20 @@ declare const rawCommands: {
|
|
|
38
38
|
readonly description: "Print the result as JSON on stdout; all progress goes to stderr.";
|
|
39
39
|
};
|
|
40
40
|
}>;
|
|
41
|
+
subscribe: CommandDef<{
|
|
42
|
+
readonly env: {
|
|
43
|
+
readonly type: "string";
|
|
44
|
+
readonly description: "Environment to subscribe in (dev, prod, local).";
|
|
45
|
+
};
|
|
46
|
+
readonly 'no-wait': {
|
|
47
|
+
readonly type: "boolean";
|
|
48
|
+
readonly description: "Open checkout and exit instead of waiting for it to complete.";
|
|
49
|
+
};
|
|
50
|
+
readonly json: {
|
|
51
|
+
readonly type: "boolean";
|
|
52
|
+
readonly description: "Print the result as JSON on stdout; all progress goes to stderr.";
|
|
53
|
+
};
|
|
54
|
+
}>;
|
|
41
55
|
usage: CommandDef<{
|
|
42
56
|
readonly days: {
|
|
43
57
|
readonly type: "string";
|
package/dist/cli.js
CHANGED
|
@@ -5,6 +5,7 @@ import { loginCommand } from './commands/login.js';
|
|
|
5
5
|
import { logoutCommand } from './commands/logout.js';
|
|
6
6
|
import { whoamiCommand } from './commands/whoami.js';
|
|
7
7
|
import { usageCommand } from './commands/usage.js';
|
|
8
|
+
import { subscribeCommand } from './commands/subscribe.js';
|
|
8
9
|
import { initCommand } from './commands/init.js';
|
|
9
10
|
import { upgradeCommand } from './commands/upgrade.js';
|
|
10
11
|
import { checkCommand } from './commands/check.js';
|
|
@@ -100,6 +101,7 @@ const rawCommands = {
|
|
|
100
101
|
login: loginCommand,
|
|
101
102
|
logout: logoutCommand,
|
|
102
103
|
whoami: whoamiCommand,
|
|
104
|
+
subscribe: subscribeCommand,
|
|
103
105
|
usage: usageCommand,
|
|
104
106
|
init: initCommand,
|
|
105
107
|
upgrade: upgradeCommand,
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,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D,WAAW;CACZ,CAAC,CAAC"}
|
package/dist/commands/login.js
CHANGED
|
@@ -2,7 +2,7 @@ import { defineCommand } from 'citty';
|
|
|
2
2
|
import { resolveEnvironment, resolveAuth0ClientId } from '../config/environments.js';
|
|
3
3
|
import { writeCredentials, writeDefaultEnvironment, readDefaultEnvironment } from '../config/credentials.js';
|
|
4
4
|
import { requestDeviceCode, pollForToken } from '../auth/device-flow.js';
|
|
5
|
-
import {
|
|
5
|
+
import { fetchWhoami, runSubscribeFlow, defaultSubscribeDeps, describeProStatus } from '../auth/subscribe-flow.js';
|
|
6
6
|
import { createOutput } from '../output.js';
|
|
7
7
|
const deps = {
|
|
8
8
|
fetch: globalThis.fetch,
|
|
@@ -35,18 +35,38 @@ export const loginCommand = defineCommand({
|
|
|
35
35
|
writeCredentials(environment.name, credentials);
|
|
36
36
|
writeDefaultEnvironment(environment.name);
|
|
37
37
|
// Prove the login rather than assuming it: a token Auth0 accepted is not the same as an
|
|
38
|
-
// account api-server admits to the CLI
|
|
39
|
-
|
|
38
|
+
// account api-server admits to the CLI, which requires an active Bitmagic Pro subscription.
|
|
39
|
+
// whoami sits OUTSIDE that gate precisely so this answer exists for someone who has not
|
|
40
|
+
// subscribed yet — otherwise the first thing a new creator would meet is a 403.
|
|
41
|
+
const me = await fetchWhoami(environment, credentials.accessToken, defaultSubscribeDeps);
|
|
40
42
|
output.info(`Logged in to ${environment.name} as ${me.userId}.`);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
if (me.pro) {
|
|
44
|
+
// Says "renews on X" — or warns when it will not, which is the only
|
|
45
|
+
// chance to mention that before a command is refused mid-work.
|
|
46
|
+
output.info(describeProStatus(me));
|
|
47
|
+
output.result({
|
|
48
|
+
ok: true, environment: environment.name, userId: me.userId, roles: me.roles,
|
|
49
|
+
pro: true, proUntil: me.proUntil, cancelAtPeriodEnd: me.cancelAtPeriodEnd ?? false,
|
|
50
|
+
});
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// A returning creator whose subscription lapsed should be told so, not
|
|
54
|
+
// greeted as though they had never subscribed.
|
|
55
|
+
if (me.proUntil)
|
|
56
|
+
output.info(describeProStatus(me));
|
|
57
|
+
// Not subscribed: carry straight on into checkout rather than ending on an
|
|
58
|
+
// error the creator has to decode. They are already in a browser — they
|
|
59
|
+
// just approved a device code in one.
|
|
60
|
+
const subscribed = await runSubscribeFlow(environment, credentials.accessToken, output, {
|
|
61
|
+
noOpen: args.json === true,
|
|
62
|
+
});
|
|
44
63
|
output.result({
|
|
45
64
|
ok: true,
|
|
46
65
|
environment: environment.name,
|
|
47
66
|
userId: me.userId,
|
|
48
67
|
roles: me.roles,
|
|
49
|
-
|
|
68
|
+
pro: subscribed.pro,
|
|
69
|
+
...(subscribed.checkoutUrl ? { checkoutUrl: subscribed.checkoutUrl } : {}),
|
|
50
70
|
});
|
|
51
71
|
},
|
|
52
72
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC7G,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC7G,OAAO,E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,GAAG,MAAM,gBAAgB,CAAC,WAAW,EAAE,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE;YACtF,MAAM,EAAE,IAAI,CAAC,IAAI,KAAK,IAAI;SAC3B,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC;YACZ,EAAE,EAAE,IAAI;YACR,WAAW,EAAE,WAAW,CAAC,IAAI;YAC7B,MAAM,EAAE,EAAE,CAAC,MAAM;YACjB,KAAK,EAAE,EAAE,CAAC,KAAK;YACf,GAAG,EAAE,UAAU,CAAC,GAAG;YACnB,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC3E,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const subscribeCommand: import("citty").CommandDef<{
|
|
2
|
+
readonly env: {
|
|
3
|
+
readonly type: "string";
|
|
4
|
+
readonly description: "Environment to subscribe in (dev, prod, local).";
|
|
5
|
+
};
|
|
6
|
+
readonly 'no-wait': {
|
|
7
|
+
readonly type: "boolean";
|
|
8
|
+
readonly description: "Open checkout and exit instead of waiting for it to complete.";
|
|
9
|
+
};
|
|
10
|
+
readonly json: {
|
|
11
|
+
readonly type: "boolean";
|
|
12
|
+
readonly description: "Print the result as JSON on stdout; all progress goes to stderr.";
|
|
13
|
+
};
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { defineCommand } from 'citty';
|
|
2
|
+
import { resolveEnvironment, resolveAuth0ClientId } from '../config/environments.js';
|
|
3
|
+
import { readDefaultEnvironment } from '../config/credentials.js';
|
|
4
|
+
import { getAccessToken } from '../auth/session.js';
|
|
5
|
+
import { fetchWhoami, runSubscribeFlow, defaultSubscribeDeps } from '../auth/subscribe-flow.js';
|
|
6
|
+
import { createOutput } from '../output.js';
|
|
7
|
+
/**
|
|
8
|
+
* `bitmagic subscribe` — start (or finish) a Bitmagic Pro subscription.
|
|
9
|
+
*
|
|
10
|
+
* `login` already runs this flow for a creator who has not subscribed, so this
|
|
11
|
+
* command exists for the second attempt: someone who closed the checkout tab,
|
|
12
|
+
* whose card was declined, or whose subscription has since lapsed. Same code
|
|
13
|
+
* path, so the recovery looks exactly like the first run rather than being a
|
|
14
|
+
* differently-worded special case.
|
|
15
|
+
*/
|
|
16
|
+
const deviceFlowDeps = { fetch: globalThis.fetch, sleep: (ms) => new Promise((r) => setTimeout(r, ms)) };
|
|
17
|
+
export const subscribeCommand = defineCommand({
|
|
18
|
+
meta: { name: 'subscribe', description: 'Start a Bitmagic Pro subscription, which the CLI requires.' },
|
|
19
|
+
args: {
|
|
20
|
+
env: { type: 'string', description: 'Environment to subscribe in (dev, prod, local).' },
|
|
21
|
+
'no-wait': { type: 'boolean', description: 'Open checkout and exit instead of waiting for it to complete.' },
|
|
22
|
+
json: {
|
|
23
|
+
type: 'boolean',
|
|
24
|
+
description: 'Print the result as JSON on stdout; all progress goes to stderr.',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
async run({ args }) {
|
|
28
|
+
const output = createOutput(args.json === true);
|
|
29
|
+
const environment = resolveEnvironment({
|
|
30
|
+
explicit: args.env,
|
|
31
|
+
storedDefault: readDefaultEnvironment(),
|
|
32
|
+
});
|
|
33
|
+
const clientId = resolveAuth0ClientId(environment);
|
|
34
|
+
const token = await getAccessToken(environment, clientId, deviceFlowDeps);
|
|
35
|
+
const me = await fetchWhoami(environment, token, defaultSubscribeDeps);
|
|
36
|
+
if (me.pro) {
|
|
37
|
+
// Nothing to sell. Say when it renews rather than "already subscribed",
|
|
38
|
+
// which is the question behind the question.
|
|
39
|
+
const until = me.proUntil ? ` Renews ${me.proUntil.slice(0, 10)}.` : '';
|
|
40
|
+
output.info(`Bitmagic Pro is already active for ${me.userId}.${until}`);
|
|
41
|
+
output.result({ ok: true, pro: true, userId: me.userId, proUntil: me.proUntil ?? null });
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (me.proUntil) {
|
|
45
|
+
output.info(`Your previous Bitmagic Pro subscription ended on ${me.proUntil.slice(0, 10)}.`);
|
|
46
|
+
}
|
|
47
|
+
const result = await runSubscribeFlow(environment, token, output, {
|
|
48
|
+
noOpen: args.json === true,
|
|
49
|
+
noWait: args['no-wait'] === true,
|
|
50
|
+
});
|
|
51
|
+
output.result({
|
|
52
|
+
ok: true,
|
|
53
|
+
pro: result.pro,
|
|
54
|
+
userId: me.userId,
|
|
55
|
+
...(result.checkoutUrl ? { checkoutUrl: result.checkoutUrl } : {}),
|
|
56
|
+
...(result.reason ? { reason: result.reason } : {}),
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=subscribe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscribe.js","sourceRoot":"","sources":["../../src/commands/subscribe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;;;;;GAQG;AACH,MAAM,cAAc,GAAG,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAO,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;AAEvH,MAAM,CAAC,MAAM,gBAAgB,G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M,EAAE,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC,CAAC;YACzF,OAAO;QACT,CAAC;QAED,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC;YAChB,MAAM,CAAC,IAAI,CAAC,oDAAoD,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;QAC/F,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE;YAChE,MAAM,EAAE,IAAI,CAAC,IAAI,KAAK,IAAI;YAC1B,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI;SACjC,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC;YACZ,EAAE,EAAE,IAAI;YACR,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,MAAM,EAAE,EAAE,CAAC,MAAM;YACjB,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAClE,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACpD,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
access?: string;
|
|
12
|
-
pro?: boolean;
|
|
13
|
-
proUntil?: string | null;
|
|
14
|
-
}
|
|
1
|
+
import { type WhoamiResponse } from '../auth/subscribe-flow.js';
|
|
2
|
+
export type { WhoamiResponse };
|
|
3
|
+
/**
|
|
4
|
+
* `bitmagic whoami` — who the CLI is authenticated as, and whether that account
|
|
5
|
+
* may use it.
|
|
6
|
+
*
|
|
7
|
+
* The endpoint behind this sits outside the CLI's entitlement gate, so it
|
|
8
|
+
* answers for an unsubscribed creator too — that is the whole point: "why is
|
|
9
|
+
* this refusing me" needs an answer that is not itself refused.
|
|
10
|
+
*/
|
|
15
11
|
export declare function runWhoami(explicitEnv?: string): Promise<WhoamiResponse>;
|
|
16
12
|
export declare const whoamiCommand: import("citty").CommandDef<{
|
|
17
13
|
readonly env: {
|
package/dist/commands/whoami.js
CHANGED
|
@@ -2,19 +2,24 @@ import { defineCommand } from 'citty';
|
|
|
2
2
|
import { resolveEnvironment, resolveAuth0ClientId } from '../config/environments.js';
|
|
3
3
|
import { readDefaultEnvironment } from '../config/credentials.js';
|
|
4
4
|
import { getAccessToken } from '../auth/session.js';
|
|
5
|
-
import {
|
|
5
|
+
import { fetchWhoami, defaultSubscribeDeps, describeProStatus } from '../auth/subscribe-flow.js';
|
|
6
6
|
import { createOutput } from '../output.js';
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* `bitmagic whoami` — who the CLI is authenticated as, and whether that account
|
|
9
|
+
* may use it.
|
|
10
|
+
*
|
|
11
|
+
* The endpoint behind this sits outside the CLI's entitlement gate, so it
|
|
12
|
+
* answers for an unsubscribed creator too — that is the whole point: "why is
|
|
13
|
+
* this refusing me" needs an answer that is not itself refused.
|
|
14
|
+
*/
|
|
8
15
|
export async function runWhoami(explicitEnv) {
|
|
9
16
|
const environment = resolveEnvironment({
|
|
10
17
|
explicit: explicitEnv,
|
|
11
18
|
storedDefault: readDefaultEnvironment(),
|
|
12
19
|
});
|
|
13
20
|
const clientId = resolveAuth0ClientId(environment);
|
|
14
|
-
const token = await getAccessToken(environment, clientId,
|
|
15
|
-
return
|
|
16
|
-
fetch: globalThis.fetch,
|
|
17
|
-
});
|
|
21
|
+
const token = await getAccessToken(environment, clientId, defaultSubscribeDeps);
|
|
22
|
+
return fetchWhoami(environment, token, defaultSubscribeDeps);
|
|
18
23
|
}
|
|
19
24
|
export const whoamiCommand = defineCommand({
|
|
20
25
|
meta: { name: 'whoami', description: 'Show the identity the CLI is authenticated as.' },
|
|
@@ -30,16 +35,16 @@ export const whoamiCommand = defineCommand({
|
|
|
30
35
|
const me = await runWhoami(args.env);
|
|
31
36
|
output.info(`user: ${me.userId}`);
|
|
32
37
|
output.info(`roles: ${me.roles.length > 0 ? me.roles.join(', ') : '(none)'}`);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
output.info(`
|
|
36
|
-
}
|
|
38
|
+
output.info(`pro: ${describeProStatus(me)}`);
|
|
39
|
+
if (!me.pro)
|
|
40
|
+
output.info(' Run `bitmagic subscribe` to use the CLI.');
|
|
37
41
|
output.result({
|
|
38
42
|
ok: true,
|
|
39
43
|
userId: me.userId,
|
|
40
44
|
roles: me.roles,
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
pro: me.pro,
|
|
46
|
+
proUntil: me.proUntil,
|
|
47
|
+
cancelAtPeriodEnd: me.cancelAtPeriodEnd ?? false,
|
|
43
48
|
});
|
|
44
49
|
},
|
|
45
50
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB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;QACnC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QAE9E,MAAM,CAAC,IAAI,CAAC,UAAU,iBAAiB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,EAAE,CAAC,GAAG;YAAE,MAAM,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;QAE5E,MAAM,CAAC,MAAM,CAAC;YACZ,EAAE,EAAE,IAAI;YACR,MAAM,EAAE,EAAE,CAAC,MAAM;YACjB,KAAK,EAAE,EAAE,CAAC,KAAK;YACf,GAAG,EAAE,EAAE,CAAC,GAAG;YACX,QAAQ,EAAE,EAAE,CAAC,QAAQ;YACrB,iBAAiB,EAAE,EAAE,CAAC,iBAAiB,IAAI,KAAK;SACjD,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC"}
|
package/dist/http/client.d.ts
CHANGED
|
@@ -2,5 +2,15 @@ import type { Environment } from '../config/environments.js';
|
|
|
2
2
|
export interface ApiDeps {
|
|
3
3
|
fetch: typeof globalThis.fetch;
|
|
4
4
|
}
|
|
5
|
+
type FetchResponse = Awaited<ReturnType<typeof globalThis.fetch>>;
|
|
6
|
+
/**
|
|
7
|
+
* PURE-ish: turn a 403 into the sentence that actually helps.
|
|
8
|
+
*
|
|
9
|
+
* Falls back to the generic wording whenever the body is missing, unparseable
|
|
10
|
+
* or from an older api-server — a CLI that throws while explaining a refusal
|
|
11
|
+
* would be worse than one that explains it vaguely.
|
|
12
|
+
*/
|
|
13
|
+
export declare function proRefusalMessage(response: FetchResponse): Promise<string>;
|
|
5
14
|
export declare function apiGet<T>(environment: Environment, path: string, accessToken: string, deps: ApiDeps): Promise<T>;
|
|
6
15
|
export declare function apiPost<T>(environment: Environment, path: string, accessToken: string, body: unknown, deps: ApiDeps): Promise<T>;
|
|
16
|
+
export {};
|
package/dist/http/client.js
CHANGED
|
@@ -1,4 +1,33 @@
|
|
|
1
1
|
import { CliError } from '../errors.js';
|
|
2
|
+
/** '2026-08-03T00:00:00.000Z' -> '2026-08-03'; anything unparseable is dropped. */
|
|
3
|
+
function refusalDate(iso) {
|
|
4
|
+
if (typeof iso !== 'string' || iso.length < 10)
|
|
5
|
+
return null;
|
|
6
|
+
return Number.isNaN(new Date(iso).getTime()) ? null : iso.slice(0, 10);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* PURE-ish: turn a 403 into the sentence that actually helps.
|
|
10
|
+
*
|
|
11
|
+
* Falls back to the generic wording whenever the body is missing, unparseable
|
|
12
|
+
* or from an older api-server — a CLI that throws while explaining a refusal
|
|
13
|
+
* would be worse than one that explains it vaguely.
|
|
14
|
+
*/
|
|
15
|
+
export async function proRefusalMessage(response) {
|
|
16
|
+
let body = {};
|
|
17
|
+
try {
|
|
18
|
+
body = (await response.json());
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// Keep the generic message.
|
|
22
|
+
}
|
|
23
|
+
if (body.code === 'pro_expired') {
|
|
24
|
+
const ended = refusalDate(body.proUntil);
|
|
25
|
+
return (`Your Bitmagic Pro subscription ${ended ? `ended on ${ended}` : 'has ended'}. ` +
|
|
26
|
+
'Run `bitmagic subscribe` to start it again — your games and projects are untouched.');
|
|
27
|
+
}
|
|
28
|
+
return ('The Bitmagic CLI requires an active Bitmagic Pro subscription. ' +
|
|
29
|
+
'Run `bitmagic subscribe` to start one.');
|
|
30
|
+
}
|
|
2
31
|
/**
|
|
3
32
|
* Shared status handling for every api-server call: the transport-failure/error-status split,
|
|
4
33
|
* and the 401/403/503/other mapping. `apiGet` and `apiPost` differ only in the fetch `init` they
|
|
@@ -21,9 +50,15 @@ async function request(environment, path, accessToken, deps, init) {
|
|
|
21
50
|
throw new CliError('Your session has expired. Run `bitmagic login`.');
|
|
22
51
|
}
|
|
23
52
|
if (response.status === 403) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
53
|
+
// The gate is Bitmagic Pro and nothing else, and `subscribe` is a command
|
|
54
|
+
// that finishes the job — so name it rather than describing a web page the
|
|
55
|
+
// creator would have to go find.
|
|
56
|
+
//
|
|
57
|
+
// Read the body: api-server distinguishes a lapsed subscription from one
|
|
58
|
+
// that never existed, and telling a returning customer to "start one"
|
|
59
|
+
// reads as though their year of paying never happened — it sends them
|
|
60
|
+
// hunting for a problem with their account instead of renewing.
|
|
61
|
+
throw new CliError(await proRefusalMessage(response));
|
|
27
62
|
}
|
|
28
63
|
if (response.status === 503) {
|
|
29
64
|
throw new CliError(`api-server reported this feature is unavailable in the "${environment.name}" environment.`);
|
package/dist/http/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/http/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/http/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAmBxC,mFAAmF;AACnF,SAAS,WAAW,CAAC,GAA8B;IACjD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,GAAG,EAAE;QAAE,OAAO,IAAI,CAAC;IAC5D,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACzE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,QAAuB;IAC7D,IAAI,IAAI,GAAmB,EAAE,CAAC;IAC9B,IAAI,CAAC;QACH,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zE,sEAAsE;QACtE,sEAAsE;QACtE,gEAAgE;QAChE,MAAM,IAAI,QAAQ,CAAC,MAAM,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxD,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC5B,MAAM,IAAI,QAAQ,CAChB,2DAA2D,WAAW,CAAC,IAAI,gBAAgB,CAC5F,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,QAAQ,CAAC,4BAA4B,QAAQ,CAAC,MAAM,QAAQ,IAAI,GAAG,CAAC,CAAC;AACjF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,WAAwB,EACxB,IAAY,EACZ,WAAmB,EACnB,IAAa;IAEb,OAAO,OAAO,CAAI,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE;QACtD,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,WAAW,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE;KAChF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,WAAwB,EACxB,IAAY,EACZ,WAAmB,EACnB,IAAa,EACb,IAAa;IAEb,OAAO,OAAO,CAAI,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE;QACtD,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,WAAW,EAAE;YACtC,MAAM,EAAE,kBAAkB;YAC1B,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1125,7 +1125,8 @@ running before you start implementing rather than after.
|
|
|
1125
1125
|
- **Not logged in** — run \`bitmagic login\`.
|
|
1126
1126
|
- **Does not own the game** — \`bitmagic.json\`'s \`gameId\` points at someone else's game; nothing
|
|
1127
1127
|
was generated and \`world.json\` is untouched.
|
|
1128
|
-
- **Insufficient balance** — the message names what was required.
|
|
1128
|
+
- **Insufficient balance** — the message names what was required. That is the Pro allowance plus
|
|
1129
|
+
any purchased sparks; \`bitmagic usage\` shows which is short and when the allowance resets.
|
|
1129
1130
|
|
|
1130
1131
|
Every failure before the asset arrives leaves \`world.json\` unchanged, and the command says so
|
|
1131
1132
|
explicitly. You never need to guess whether a failed generation half-applied.
|
|
@@ -1186,7 +1187,8 @@ request needs several generations, tell the human before starting, not after.
|
|
|
1186
1187
|
## When it refuses
|
|
1187
1188
|
|
|
1188
1189
|
- **Not logged in** — run \`bitmagic login\`.
|
|
1189
|
-
- **Not entitled** — the CLI needs an active Bitmagic Pro subscription
|
|
1190
|
+
- **Not entitled** — the CLI needs an active Bitmagic Pro subscription. \`bitmagic subscribe\`
|
|
1191
|
+
starts one.
|
|
1190
1192
|
|
|
1191
1193
|
## What it does not show
|
|
1192
1194
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-files.js","sourceRoot":"","sources":["../../src/scaffold/project-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEjF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,2BAA2B,EAAE,SAAS;IACtC,2BAA2B,EAAE,SAAS;IACtC,kBAAkB,EAAE,QAAQ;IAC5B,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,kCAAkC,EAAE,QAAQ;IAC5C,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,UAAU;IACjB,4FAA4F;IAC5F,6FAA6F;IAC7F,4CAA4C;CACZ,CAAC;AAEnC,MAAM,CAAC,MAAM,gBAAgB,GAA2B;IACtD,aAAa,EAAE,UAAU;IACzB,cAAc,EAAE,UAAU;IAC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