@40rty/ams-cli 0.5.10 → 0.5.11
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/commands/doctor.mjs +11 -7
- package/bin/commands/domain.mjs +19 -12
- package/bin/commands/whoami.mjs +1 -1
- package/bin/lib/context.mjs +1 -1
- package/package.json +1 -1
package/bin/commands/doctor.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
// `forty doctor [dev-server-url] [--ask "<question>" | --no-ask]` — the integration's definition of done.
|
|
1
|
+
// `forty doctor [dev-server-url | preview-link] [--ask "<question>" | --no-ask]` — the integration's definition of done.
|
|
2
|
+
// A preview link (`…/?preview=<token>`, what `forty dev` prints) lends its
|
|
3
|
+
// token to the test turn, so a locked space answers it.
|
|
2
4
|
// When 40rty hosts the app (`forty deploy`), the space's own address is
|
|
3
5
|
// checked too: its own site, `https://<space>.40rty.app<route>`.
|
|
4
6
|
//
|
|
@@ -182,7 +184,7 @@ export async function doctor() {
|
|
|
182
184
|
for (const [what, fix] of problems) check(false, what, fix);
|
|
183
185
|
}
|
|
184
186
|
if (devOrigin !== undefined) {
|
|
185
|
-
await routeChecks(check, config, `${devOrigin}/`);
|
|
187
|
+
await routeChecks(check, config, `${new URL(devOrigin).origin}/`);
|
|
186
188
|
} else {
|
|
187
189
|
console.log('- skipped the page and CSP checks: start the dev server with FORTY_AGENTIC=1 and pass its url, e.g. `forty doctor http://localhost:3000`');
|
|
188
190
|
}
|
|
@@ -195,7 +197,7 @@ export async function doctor() {
|
|
|
195
197
|
}
|
|
196
198
|
}
|
|
197
199
|
|
|
198
|
-
if (!flag('no-ask')) await askCheck(config, check);
|
|
200
|
+
if (!flag('no-ask')) await askCheck(config, check, devOrigin === undefined ? null : new URL(devOrigin).searchParams.get('preview'));
|
|
199
201
|
|
|
200
202
|
if (failures.length > 0) {
|
|
201
203
|
console.error(`\n${failures.length} check(s) failed.`);
|
|
@@ -212,13 +214,15 @@ const DEFAULT_QUESTION = 'what do you sell?';
|
|
|
212
214
|
* spacefront uses. Passes when the agent composed a catalog element carrying
|
|
213
215
|
* at least one entity. Skipped with `--no-ask`.
|
|
214
216
|
*/
|
|
215
|
-
async function askCheck(config, check) {
|
|
217
|
+
async function askCheck(config, check, linkToken) {
|
|
216
218
|
const asked = option('ask');
|
|
217
219
|
const question = asked === undefined ? DEFAULT_QUESTION : asked;
|
|
218
220
|
const env = await readDotenv(path.join(cwd, '.env'));
|
|
219
|
-
// The preview credential
|
|
220
|
-
const
|
|
221
|
-
|
|
221
|
+
// The preview credential opens a locked space, and its draft: the link's, else the one `forty dev` wrote.
|
|
222
|
+
const fromEnv = typeof env.FORTY_DEV_TOKEN === 'string' && env.FORTY_DEV_TOKEN !== '' ? env.FORTY_DEV_TOKEN : undefined;
|
|
223
|
+
const token = linkToken !== null && linkToken !== '' ? linkToken : fromEnv;
|
|
224
|
+
const source = token === undefined ? '' : token === fromEnv ? ' (with FORTY_DEV_TOKEN)' : ' (with the preview link\'s token)';
|
|
225
|
+
console.log(`\n- asking "${question}"${source}…`);
|
|
222
226
|
// The organization key fetches the socket ticket a deployment asks a script for.
|
|
223
227
|
const credential = await findCredential(config.apiUrl);
|
|
224
228
|
const turn = await askSpace({ apiUrl: config.apiUrl, slug: config.spaceSlug, token, apiKey: credential === null ? undefined : credential.key, question });
|
package/bin/commands/domain.mjs
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import { fail, positionals, readConfig } from '../lib/context.mjs';
|
|
2
2
|
import { call } from '../lib/credentials.mjs';
|
|
3
3
|
|
|
4
|
-
/**
|
|
4
|
+
/** Where the domain stands, one line, then the DNS records to create while it is not live. */
|
|
5
5
|
function describe(status) {
|
|
6
6
|
const { hostname } = status.domain;
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
9
|
-
const
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
const { edge, routing } = status;
|
|
8
|
+
if (edge.state !== 'ok') return [` ${hostname}: status unavailable (${edge.state === 'error' ? edge.message : edge.reason})`];
|
|
9
|
+
const cert = edge.status.certificate;
|
|
10
|
+
if (cert === 'active' && routing.state === 'pointed') return [` ${hostname}: live`];
|
|
11
|
+
const where =
|
|
12
|
+
!edge.status.attached ? 'provisioning the certificate — run `forty domain` again in a minute'
|
|
13
|
+
: cert === 'failed' ? `certificate failed${edge.status.certificateDetail === null ? '' : ` (${edge.status.certificateDetail})`}`
|
|
14
|
+
: cert !== 'active' ? 'issuing the certificate — waiting on the _acme-challenge record'
|
|
15
|
+
: routing.state === 'elsewhere' ? `certificate ready — DNS still points at ${routing.found.join(', ')}; switch the routing record to cut over`
|
|
16
|
+
: 'certificate ready — waiting for DNS';
|
|
17
|
+
const lines = [` ${hostname}: ${where}. Create:`];
|
|
18
|
+
for (const r of status.records) lines.push(` ${r.type.padEnd(5)} ${r.name.padEnd(40)} ${r.value}`);
|
|
19
|
+
const alt = status.routingAlternative;
|
|
20
|
+
if (alt !== null) lines.push(` (or, instead of the CNAME: ${alt.type} ${alt.name} → ${alt.value})`);
|
|
15
21
|
return lines;
|
|
16
22
|
}
|
|
17
23
|
|
|
@@ -19,7 +25,8 @@ function describe(status) {
|
|
|
19
25
|
* `forty domain add <host>` — serve this repo's space on the customer's own
|
|
20
26
|
* domain (its hosted app or package, as on `<console>/<space>`), and print the
|
|
21
27
|
* DNS records to create. `forty domain` lists the space's domains and what each
|
|
22
|
-
* still needs.
|
|
28
|
+
* still needs. Publish the `_acme-challenge` record first: the certificate issues while the
|
|
29
|
+
* domain still serves from its old host, then the routing record moves with no gap.
|
|
23
30
|
*/
|
|
24
31
|
export async function domain() {
|
|
25
32
|
const [action, host] = positionals();
|
|
@@ -34,9 +41,9 @@ export async function domain() {
|
|
|
34
41
|
if (action !== 'add' || host === undefined) fail('usage: forty domain add <shop.example.com> | forty domain');
|
|
35
42
|
const result = await call(config.apiUrl, 'POST', route, { hostname: host });
|
|
36
43
|
console.log(`${result.domain.hostname} now serves "${config.spaceSlug}"`);
|
|
37
|
-
if (result.attach.state
|
|
44
|
+
if (result.attach.state === 'error' || result.attach.state === 'unconfigured') {
|
|
38
45
|
const why = result.attach.state === 'error' ? result.attach.message : result.attach.reason;
|
|
39
|
-
console.log(` not
|
|
46
|
+
console.log(` certificate not provisioned (${result.attach.state}: ${why}) — tell the 40rty team`);
|
|
40
47
|
}
|
|
41
48
|
for (const line of describe(result)) console.log(line);
|
|
42
49
|
}
|
package/bin/commands/whoami.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { deployment } from '../lib/context.mjs';
|
|
|
5
5
|
import { call } from '../lib/credentials.mjs';
|
|
6
6
|
|
|
7
7
|
/** What a 40rty organization does differently — shared with `forty init`. */
|
|
8
|
-
export const STAFF_NOTICE = '40rty organization: its spaces are 40rty demos. Build the package in the 40RTY-ai/brands repo (packages/<space>, on the shape of packages/
|
|
8
|
+
export const STAFF_NOTICE = '40rty organization: its spaces are 40rty demos. Build the package in the 40RTY-ai/brands repo (packages/<space>, on the shape of packages/ryleeandcru-conversational, which passes the brands lint), open a PR there, and release it by merging (the brands CI publishes) — never from this machine.';
|
|
9
9
|
|
|
10
10
|
export async function whoami() {
|
|
11
11
|
const { apiUrl } = deployment(null);
|
package/bin/lib/context.mjs
CHANGED
|
@@ -7,7 +7,7 @@ export const cwd = process.cwd();
|
|
|
7
7
|
export const CONFIG_FILE = 'forty.config.json';
|
|
8
8
|
|
|
9
9
|
/** The production deployment, used when neither the config nor the environment names another. */
|
|
10
|
-
const PRODUCTION = { apiUrl: 'https://40rty
|
|
10
|
+
const PRODUCTION = { apiUrl: 'https://api.40rty.ai', consoleUrl: 'https://app.40rty.ai' };
|
|
11
11
|
|
|
12
12
|
/** A problem the person can act on — printed without a stack. */
|
|
13
13
|
export class FortyError extends Error {}
|