@sandboxsonny/ace-kit 0.4.0 → 0.5.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/CHANGELOG.md +11 -0
- package/README.md +1 -1
- package/dist/astro-integration.d.ts +3 -3
- package/dist/astro-integration.js +7 -4
- package/dist/chunk-N5DIMG3X.js +16 -0
- package/dist/{chunk-O3NAJNUN.js → chunk-WM5NOQE3.js} +7 -7
- package/dist/cli.js +34 -24
- package/dist/react-router-server.js +3 -2
- package/dist/vite.js +2 -1
- package/docs/astro.md +12 -6
- package/docs/command-line.md +4 -4
- package/docs/dev-sites.md +2 -2
- package/docs/react-router.md +7 -5
- package/docs/sections.md +1 -1
- package/docs/typed-content.md +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @sandboxsonny/ace-kit
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 88e17be: CMS Ace is a hosted platform, so a site no longer has to say where it is.
|
|
8
|
+
|
|
9
|
+
- `ACE_API_URL` now defaults to `https://api.ace-cms.co.uk` and `ACE_PREVIEW_ADMIN_ORIGIN` to `https://app.ace-cms.co.uk` (the Astro integration, the React Router adapter and the command line). **If you develop against a CMS on your own machine, set `ACE_API_URL=http://localhost:8080` and `ACE_PREVIEW_ADMIN_ORIGIN=http://localhost:5173` in `.env`**, where before they were the defaults.
|
|
10
|
+
- A site names itself with Astro's own `site` setting (`site: "https://www.example.com"`, or `astro dev --site https://www.example.com`). `ACE_SITE_DOMAIN`, when set, still wins.
|
|
11
|
+
- `ace-kit sync` and `ace-kit generate` take `--site example.com` (a domain or a web address); `--domain` still works.
|
|
12
|
+
- `ace-kit login` and `whoami` need no flags: with no address given they use the hosted CMS Ace.
|
|
13
|
+
|
|
3
14
|
## 0.4.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ const page = await loadPage(cms, { slug: "pages/about", url: new URL(request.url
|
|
|
24
24
|
if (page.kind === "entry") console.log(page.entry.title, page.entry.values);
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
On Astro there is nothing to wire up by hand: add the integration to `astro.config.mjs` (`integrations: [ace()]`), set `
|
|
27
|
+
On Astro there is nothing to wire up by hand: add the integration to `astro.config.mjs` (`integrations: [ace()]`), set your site's domain (`site: "https://www.example.com"` in the Astro config, or `ACE_SITE_DOMAIN`), and read the CMS straight from a page:
|
|
28
28
|
|
|
29
29
|
```astro
|
|
30
30
|
---
|
|
@@ -13,9 +13,9 @@ import { AstroIntegration } from 'astro';
|
|
|
13
13
|
*
|
|
14
14
|
* | Setting | Default | Meaning |
|
|
15
15
|
* | -------------------------- | ----------------------- | -------------------------------------------------------- |
|
|
16
|
-
* | `ACE_API_URL` | `
|
|
17
|
-
* | `ACE_SITE_DOMAIN` | `localhost`
|
|
18
|
-
* | `ACE_PREVIEW_ADMIN_ORIGIN` | `
|
|
16
|
+
* | `ACE_API_URL` | `https://api.ace-cms.co.uk` | where the CMS Ace API lives (set it for a CMS on your machine) |
|
|
17
|
+
* | `ACE_SITE_DOMAIN` | the host of Astro's `site` setting, else `localhost` | the domain this site has in the CMS |
|
|
18
|
+
* | `ACE_PREVIEW_ADMIN_ORIGIN` | `https://app.ace-cms.co.uk` | where the CMS admin app runs (may frame the site) |
|
|
19
19
|
*/
|
|
20
20
|
declare function ace(): AstroIntegration;
|
|
21
21
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { startDevSite, sectionSync } from './chunk-
|
|
1
|
+
import { startDevSite, sectionSync } from './chunk-WM5NOQE3.js';
|
|
2
|
+
import { domainFromSite, hostedAdminOrigin, hostedApiUrl } from './chunk-N5DIMG3X.js';
|
|
2
3
|
import { envField } from 'astro/config';
|
|
3
4
|
import { fileURLToPath } from 'url';
|
|
4
5
|
|
|
@@ -8,10 +9,12 @@ function ace() {
|
|
|
8
9
|
name: "ace-kit",
|
|
9
10
|
hooks: {
|
|
10
11
|
"astro:config:setup": async ({ command, config, logger, updateConfig, addMiddleware }) => {
|
|
12
|
+
const siteDomain = config.site ? domainFromSite(config.site) : "localhost";
|
|
11
13
|
if (command === "dev") {
|
|
12
14
|
devSite = await startDevSite({
|
|
13
15
|
root: fileURLToPath(config.root),
|
|
14
16
|
mode: "development",
|
|
17
|
+
siteDomain,
|
|
15
18
|
log: { info: (text) => logger.info(text), warn: (text) => logger.warn(text) }
|
|
16
19
|
});
|
|
17
20
|
}
|
|
@@ -19,12 +22,12 @@ function ace() {
|
|
|
19
22
|
env: {
|
|
20
23
|
schema: {
|
|
21
24
|
// "secret" only because Astro reads secrets when the server starts, while "public" values are baked into the build.
|
|
22
|
-
ACE_API_URL: envField.string({ context: "server", access: "secret", default:
|
|
23
|
-
ACE_SITE_DOMAIN: envField.string({ context: "server", access: "secret", default:
|
|
25
|
+
ACE_API_URL: envField.string({ context: "server", access: "secret", default: hostedApiUrl }),
|
|
26
|
+
ACE_SITE_DOMAIN: envField.string({ context: "server", access: "secret", default: siteDomain }),
|
|
24
27
|
ACE_PREVIEW_ADMIN_ORIGIN: envField.string({
|
|
25
28
|
context: "server",
|
|
26
29
|
access: "secret",
|
|
27
|
-
default:
|
|
30
|
+
default: hostedAdminOrigin
|
|
28
31
|
})
|
|
29
32
|
}
|
|
30
33
|
},
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/helpers/platform.ts
|
|
2
|
+
var hostedApiUrl = "https://api.ace-cms.co.uk";
|
|
3
|
+
var hostedAdminOrigin = "https://app.ace-cms.co.uk";
|
|
4
|
+
function domainFromSite(site) {
|
|
5
|
+
const trimmed = site.trim();
|
|
6
|
+
if (trimmed.includes("://")) {
|
|
7
|
+
try {
|
|
8
|
+
return new URL(trimmed).hostname.toLowerCase();
|
|
9
|
+
} catch {
|
|
10
|
+
return trimmed.toLowerCase();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return trimmed.replace(/\/.*$/, "").replace(/:\d+$/, "").toLowerCase();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { domainFromSite, hostedAdminOrigin, hostedApiUrl };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hostedApiUrl } from './chunk-N5DIMG3X.js';
|
|
1
2
|
import { loadEnv } from 'vite';
|
|
2
3
|
import { readdir, readFile, mkdir, writeFile, rename } from 'fs/promises';
|
|
3
4
|
import { homedir } from 'os';
|
|
@@ -5,8 +6,6 @@ import { join, relative, dirname } from 'path';
|
|
|
5
6
|
import { spawn } from 'child_process';
|
|
6
7
|
import { fileURLToPath } from 'url';
|
|
7
8
|
|
|
8
|
-
// src/dev-site/start-dev-site.ts
|
|
9
|
-
|
|
10
9
|
// src/auth/login-store.ts
|
|
11
10
|
function normaliseApiUrl(address) {
|
|
12
11
|
let parsed;
|
|
@@ -282,18 +281,19 @@ async function prepareDevSite(options) {
|
|
|
282
281
|
}
|
|
283
282
|
|
|
284
283
|
// src/dev-site/start-dev-site.ts
|
|
285
|
-
var defaultApiUrl = "http://localhost:8080";
|
|
286
284
|
async function startDevSite(options) {
|
|
287
285
|
const { root, mode, log } = options;
|
|
288
286
|
if (mode === "test" || process.env.VITEST) return null;
|
|
289
|
-
const
|
|
287
|
+
const base = options.environment?.variables ?? { ...loadEnv(mode, root, "ACE_"), ...process.env };
|
|
288
|
+
const realDomain = base.ACE_SITE_DOMAIN?.trim() || options.siteDomain?.trim() || "localhost";
|
|
289
|
+
const variables = { ...base, ACE_SITE_DOMAIN: realDomain };
|
|
290
290
|
let apiUrl;
|
|
291
291
|
try {
|
|
292
|
-
apiUrl = normaliseApiUrl(variables.ACE_API_URL ??
|
|
292
|
+
apiUrl = normaliseApiUrl(variables.ACE_API_URL ?? hostedApiUrl);
|
|
293
293
|
} catch {
|
|
294
294
|
return null;
|
|
295
295
|
}
|
|
296
|
-
const environment = options.environment
|
|
296
|
+
const environment = options.environment ? { ...options.environment, variables } : {
|
|
297
297
|
variables,
|
|
298
298
|
store: await chooseLoginStore({ platform: process.platform, variables, run: runCommand }),
|
|
299
299
|
now: Date.now,
|
|
@@ -317,7 +317,7 @@ async function startDevSite(options) {
|
|
|
317
317
|
log.info(
|
|
318
318
|
outcome.created ? `Made you a dev site, "${outcome.site.name}", as a copy of the live site (${outcome.site.domain}). This dev server reads and syncs to it; the live site is not touched.` : `Using your dev site, "${outcome.site.name}" (${outcome.site.domain}). The live site is not touched.`
|
|
319
319
|
);
|
|
320
|
-
const siteDomain =
|
|
320
|
+
const siteDomain = realDomain;
|
|
321
321
|
return {
|
|
322
322
|
domain: outcome.site.domain,
|
|
323
323
|
setPreviewUrl: async (previewUrl) => {
|
package/dist/cli.js
CHANGED
|
@@ -171,7 +171,7 @@ function createLastApiUrl(path) {
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
// src/cli/version.ts
|
|
174
|
-
var aceKitVersion = true ? "0.
|
|
174
|
+
var aceKitVersion = true ? "0.5.0" : "development";
|
|
175
175
|
|
|
176
176
|
// src/cli/environment.ts
|
|
177
177
|
var runCommand = (command, commandArguments, input) => new Promise((resolve2, reject) => {
|
|
@@ -403,15 +403,29 @@ export {};
|
|
|
403
403
|
// src/helpers/package-name.ts
|
|
404
404
|
var packageName = "@sandboxsonny/ace-kit";
|
|
405
405
|
|
|
406
|
+
// src/helpers/platform.ts
|
|
407
|
+
var hostedApiUrl = "https://api.ace-cms.co.uk";
|
|
408
|
+
function domainFromSite(site) {
|
|
409
|
+
const trimmed = site.trim();
|
|
410
|
+
if (trimmed.includes("://")) {
|
|
411
|
+
try {
|
|
412
|
+
return new URL(trimmed).hostname.toLowerCase();
|
|
413
|
+
} catch {
|
|
414
|
+
return trimmed.toLowerCase();
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return trimmed.replace(/\/.*$/, "").replace(/:\d+$/, "").toLowerCase();
|
|
418
|
+
}
|
|
419
|
+
|
|
406
420
|
// src/cli/generate-command.ts
|
|
407
421
|
var generateUsage = `ace-kit generate: write TypeScript types for your CMS Ace content types.
|
|
408
422
|
|
|
409
423
|
Usage:
|
|
410
|
-
ace-kit generate [--
|
|
424
|
+
ace-kit generate [--site <domain>] [--api-url <address>] [--out <file>]
|
|
411
425
|
|
|
412
426
|
Options:
|
|
413
|
-
--
|
|
414
|
-
--
|
|
427
|
+
--site The domain your site has in the CMS, e.g. example.com (or set ACE_SITE_DOMAIN). --domain means the same.
|
|
428
|
+
--api-url Where the CMS Ace API lives (or set ACE_API_URL). Only for a CMS on your own machine.
|
|
415
429
|
--out Where to write the types (default: src/ace-kit.generated.d.ts).
|
|
416
430
|
--help Show this message.
|
|
417
431
|
`;
|
|
@@ -421,6 +435,7 @@ async function generateCommand(commandArguments, environment) {
|
|
|
421
435
|
args: commandArguments,
|
|
422
436
|
options: {
|
|
423
437
|
"api-url": { type: "string" },
|
|
438
|
+
site: { type: "string" },
|
|
424
439
|
domain: { type: "string" },
|
|
425
440
|
out: { type: "string" },
|
|
426
441
|
help: { type: "boolean" }
|
|
@@ -430,14 +445,13 @@ async function generateCommand(commandArguments, environment) {
|
|
|
430
445
|
environment.out(generateUsage);
|
|
431
446
|
return 0;
|
|
432
447
|
}
|
|
433
|
-
const apiUrl = values["api-url"] ?? environment.variables.ACE_API_URL;
|
|
434
|
-
const
|
|
435
|
-
if (!
|
|
436
|
-
environment.error(
|
|
437
|
-
"Give the API address and the site's domain: --api-url and --domain, or ACE_API_URL and ACE_SITE_DOMAIN."
|
|
438
|
-
);
|
|
448
|
+
const apiUrl = values["api-url"] ?? environment.variables.ACE_API_URL ?? hostedApiUrl;
|
|
449
|
+
const given = values.site ?? values.domain ?? environment.variables.ACE_SITE_DOMAIN;
|
|
450
|
+
if (!given) {
|
|
451
|
+
environment.error("Give the site's domain: --site, or ACE_SITE_DOMAIN.");
|
|
439
452
|
return 1;
|
|
440
453
|
}
|
|
454
|
+
const siteDomain = domainFromSite(given);
|
|
441
455
|
const client = createAceClient({
|
|
442
456
|
apiUrl,
|
|
443
457
|
siteDomain,
|
|
@@ -586,13 +600,7 @@ async function resolveLogin(options) {
|
|
|
586
600
|
|
|
587
601
|
// src/cli/api-url.ts
|
|
588
602
|
async function resolveApiUrl(fromOption, environment) {
|
|
589
|
-
const address = fromOption ?? environment.variables.ACE_API_URL ?? await environment.lastApiUrl.read();
|
|
590
|
-
if (!address) {
|
|
591
|
-
environment.error(
|
|
592
|
-
"Give the API address: --api-url, or ACE_API_URL in the environment or a .env file. (Once you have signed in, that address is remembered.)"
|
|
593
|
-
);
|
|
594
|
-
return null;
|
|
595
|
-
}
|
|
603
|
+
const address = fromOption ?? environment.variables.ACE_API_URL ?? await environment.lastApiUrl.read() ?? hostedApiUrl;
|
|
596
604
|
try {
|
|
597
605
|
return normaliseApiUrl(address);
|
|
598
606
|
} catch (error) {
|
|
@@ -1013,7 +1021,7 @@ async function syncSectionTypes(options) {
|
|
|
1013
1021
|
var syncUsage = `ace-kit sync: send the section types your code defines to CMS Ace.
|
|
1014
1022
|
|
|
1015
1023
|
Usage:
|
|
1016
|
-
ace-kit sync [--
|
|
1024
|
+
ace-kit sync [--site <domain>] [--api-url <address>] [--dir <folder>]
|
|
1017
1025
|
|
|
1018
1026
|
It finds every *.schema.ts file in the folder (src by default), checks them, and makes the CMS's section types for your
|
|
1019
1027
|
site match. The dev server does this for you whenever a schema file is saved; run it yourself for a one-off sync, or on a
|
|
@@ -1023,12 +1031,12 @@ Nothing is deleted: a section type, block or field you take out of your code is
|
|
|
1023
1031
|
written in it survives. If any schema file can't be loaded, nothing is synced.
|
|
1024
1032
|
|
|
1025
1033
|
Options:
|
|
1026
|
-
--
|
|
1027
|
-
|
|
1034
|
+
--site The domain your site has in the CMS, e.g. example.com (default: ACE_SITE_DOMAIN, else localhost).
|
|
1035
|
+
(--domain means the same.)
|
|
1036
|
+
--api-url Where the CMS Ace API lives (default: ACE_API_URL, else the hosted CMS Ace). Only for a CMS on your own machine.
|
|
1028
1037
|
--dir The folder to look in (default: src).
|
|
1029
1038
|
--help Show this message.
|
|
1030
1039
|
`;
|
|
1031
|
-
var defaultApiUrl = "http://localhost:8080";
|
|
1032
1040
|
var isSwitchedOff = (value) => ["false", "off", "no", "0"].includes((value ?? "").trim().toLowerCase());
|
|
1033
1041
|
async function syncCommand(commandArguments, environment) {
|
|
1034
1042
|
const { values } = parseArgs3({
|
|
@@ -1036,6 +1044,7 @@ async function syncCommand(commandArguments, environment) {
|
|
|
1036
1044
|
args: commandArguments,
|
|
1037
1045
|
options: {
|
|
1038
1046
|
"api-url": { type: "string" },
|
|
1047
|
+
site: { type: "string" },
|
|
1039
1048
|
domain: { type: "string" },
|
|
1040
1049
|
dir: { type: "string" },
|
|
1041
1050
|
// Set by the dev server, which syncs on its own: it stays quiet when there is nothing to do, and keeps to a
|
|
@@ -1052,12 +1061,13 @@ async function syncCommand(commandArguments, environment) {
|
|
|
1052
1061
|
if (automatic && isSwitchedOff(environment.variables.ACE_SYNC_SECTIONS)) return 0;
|
|
1053
1062
|
let apiUrl;
|
|
1054
1063
|
try {
|
|
1055
|
-
apiUrl = normaliseApiUrl(values["api-url"] ?? environment.variables.ACE_API_URL ??
|
|
1064
|
+
apiUrl = normaliseApiUrl(values["api-url"] ?? environment.variables.ACE_API_URL ?? hostedApiUrl);
|
|
1056
1065
|
} catch (error) {
|
|
1057
1066
|
environment.error(error instanceof Error ? error.message : String(error));
|
|
1058
1067
|
return 1;
|
|
1059
1068
|
}
|
|
1060
|
-
const
|
|
1069
|
+
const given = values.site ?? values.domain ?? environment.variables.ACE_SITE_DOMAIN;
|
|
1070
|
+
const siteDomain = given ? domainFromSite(given) : "localhost";
|
|
1061
1071
|
const aimedAtDevSite = environment.variables.ACE_DEV_SITE_ACTIVE === "1";
|
|
1062
1072
|
if (automatic && !aimedAtDevSite && !isLocalApiUrl(apiUrl) && environment.variables.ACE_SYNC_SECTIONS?.trim().toLowerCase() !== "remote") {
|
|
1063
1073
|
environment.out(
|
|
@@ -1112,7 +1122,7 @@ async function syncCommand(commandArguments, environment) {
|
|
|
1112
1122
|
return automatic ? 0 : 1;
|
|
1113
1123
|
case "site-not-found":
|
|
1114
1124
|
environment.error(
|
|
1115
|
-
`The CMS at ${apiUrl} has no site with the domain "${outcome.domain}" that you can see` + (outcome.available.length > 0 ? ` (your sites: ${outcome.available.join(", ")})` : "") + ". Set ACE_SITE_DOMAIN or pass --
|
|
1125
|
+
`The CMS at ${apiUrl} has no site with the domain "${outcome.domain}" that you can see` + (outcome.available.length > 0 ? ` (your sites: ${outcome.available.join(", ")})` : "") + ". Set ACE_SITE_DOMAIN or pass --site."
|
|
1116
1126
|
);
|
|
1117
1127
|
return 1;
|
|
1118
1128
|
case "forbidden":
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createAceClient, loadMenuLinks, loadPage } from './chunk-XYOW63V6.js';
|
|
2
2
|
import './chunk-M5WR5TCR.js';
|
|
3
|
+
import { hostedAdminOrigin, hostedApiUrl } from './chunk-N5DIMG3X.js';
|
|
3
4
|
import { previewTokenFrom, addFramingPolicy } from './chunk-YLO6IAXF.js';
|
|
4
5
|
import { createReadableStreamFromReadable } from '@react-router/node';
|
|
5
6
|
import { PassThrough } from 'stream';
|
|
@@ -10,9 +11,9 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
10
11
|
// src/react-router/settings.ts
|
|
11
12
|
function getAceSettings() {
|
|
12
13
|
return {
|
|
13
|
-
apiUrl: process.env.ACE_API_URL ??
|
|
14
|
+
apiUrl: process.env.ACE_API_URL ?? hostedApiUrl,
|
|
14
15
|
siteDomain: process.env.ACE_SITE_DOMAIN ?? "localhost",
|
|
15
|
-
previewAdminOrigin: process.env.ACE_PREVIEW_ADMIN_ORIGIN ??
|
|
16
|
+
previewAdminOrigin: process.env.ACE_PREVIEW_ADMIN_ORIGIN ?? hostedAdminOrigin
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
19
|
if (typeof window !== "undefined" && typeof process === "undefined") {
|
package/dist/vite.js
CHANGED
package/docs/astro.md
CHANGED
|
@@ -17,13 +17,19 @@ export default defineConfig({
|
|
|
17
17
|
|
|
18
18
|
The integration declares three settings, adds the middleware that lets the CMS's admin app (and only it) frame the site for [live preview](./live-preview.md), and makes Vite process the kit. The settings are read when the server starts, not baked into the build, so one build runs anywhere:
|
|
19
19
|
|
|
20
|
-
| Setting | Default
|
|
21
|
-
| -------------------------- |
|
|
22
|
-
| `ACE_API_URL` | `
|
|
23
|
-
| `ACE_SITE_DOMAIN` | `localhost`
|
|
24
|
-
| `ACE_PREVIEW_ADMIN_ORIGIN` | `
|
|
20
|
+
| Setting | Default | Meaning |
|
|
21
|
+
| -------------------------- | ---------------------------------------------------- | --------------------------------------------------------- |
|
|
22
|
+
| `ACE_API_URL` | `https://api.ace-cms.co.uk` | where the CMS Ace API lives |
|
|
23
|
+
| `ACE_SITE_DOMAIN` | the host of Astro's `site` setting, else `localhost` | the domain this site has in the CMS (the port is ignored) |
|
|
24
|
+
| `ACE_PREVIEW_ADMIN_ORIGIN` | `https://app.ace-cms.co.uk` | where the CMS admin app runs |
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
CMS Ace is a hosted platform, so a site normally sets none of these except its domain, and it does that with Astro's own `site` setting, which Astro needs for canonical addresses anyway:
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
export default defineConfig({ site: "https://www.example.com", integrations: [ace()] });
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
To try a site without editing the config, `npm run dev -- --site https://www.example.com` does the same. `ACE_SITE_DOMAIN`, when set, wins. Set `ACE_API_URL` and `ACE_PREVIEW_ADMIN_ORIGIN` (in `.env`) only to use a CMS running on your own machine, for example `http://localhost:8080` and `http://localhost:5173`.
|
|
27
33
|
|
|
28
34
|
## Pages
|
|
29
35
|
|
package/docs/command-line.md
CHANGED
|
@@ -10,18 +10,18 @@ npx ace-kit generate # write TypeScript types (see Typed content)
|
|
|
10
10
|
npx ace-kit sync # send your section types to the CMS (see Sections)
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Commands talk to the hosted CMS Ace unless told otherwise. Only for a CMS on your own machine, give `--api-url`, or set `ACE_API_URL` in the environment or a `.env` file in the folder you run it in. Failing both, a command uses the address you last signed in to (kept in a small file beside your logins), and failing that the hosted one, so `ace-kit login` and `ace-kit whoami` need no flags at all. Commands about a site (`sync`, `generate`) take `--site example.com`, or read `ACE_SITE_DOMAIN`.
|
|
14
14
|
|
|
15
15
|
## Signing in
|
|
16
16
|
|
|
17
17
|
```sh
|
|
18
|
-
npx ace-kit login
|
|
18
|
+
npx ace-kit login
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
```
|
|
22
|
-
Signing in to
|
|
22
|
+
Signing in to https://api.ace-cms.co.uk
|
|
23
23
|
|
|
24
|
-
1. Go to
|
|
24
|
+
1. Go to https://app.ace-cms.co.uk/device
|
|
25
25
|
2. Type BCDF-GHJK
|
|
26
26
|
|
|
27
27
|
Check the code on that page matches. Waiting for you to approve it (Ctrl-C to cancel)...
|
package/docs/dev-sites.md
CHANGED
|
@@ -6,7 +6,7 @@ When your site's dev server works against a hosted CMS, it doesn't touch the liv
|
|
|
6
6
|
|
|
7
7
|
On start, the dev server (the Astro integration, or the `ace()` Vite plugin on React Router):
|
|
8
8
|
|
|
9
|
-
1. checks you are signed in (`npx ace-kit login`), and finds the site `ACE_SITE_DOMAIN`
|
|
9
|
+
1. checks you are signed in (`npx ace-kit login`), and finds the site you are working on (Astro's `site` setting, or `ACE_SITE_DOMAIN`);
|
|
10
10
|
2. asks the CMS for your dev site of it, which the CMS makes the first time as a copy of the live site: its content types, section types, menus and the **text** of its entries, with every link between entries pointing at the copy. Images are not copied yet, so image fields start empty;
|
|
11
11
|
3. points the site at it: `ACE_SITE_DOMAIN` becomes the dev site's domain for as long as the dev server runs (your `.env` is not changed), so the site reads its content from the dev site, and section sync goes there;
|
|
12
12
|
4. tells the CMS where the dev server is running, so the live preview in the admin app shows your dev server.
|
|
@@ -23,7 +23,7 @@ Partner accounts and super admins, for sites they own. Ask for a partner account
|
|
|
23
23
|
|
|
24
24
|
## Going to the live site
|
|
25
25
|
|
|
26
|
-
A dev site is never merged into the live site. When your change is ready, deploy your site, then run `npx ace-kit sync` against the live site (
|
|
26
|
+
A dev site is never merged into the live site. When your change is ready, deploy your site, then run `npx ace-kit sync` against the live site (`--site www.example.com`, or `ACE_SITE_DOMAIN`). Deploy first: the live CMS then has the section types the deployed code expects.
|
|
27
27
|
|
|
28
28
|
## Settings
|
|
29
29
|
|
package/docs/react-router.md
CHANGED
|
@@ -26,11 +26,13 @@ export default defineConfig({ plugins: [ace(), reactRouter()] });
|
|
|
26
26
|
|
|
27
27
|
The settings are environment variables, read when the server starts, so one build runs anywhere. Put them in `.env` for development and in the host's environment for production:
|
|
28
28
|
|
|
29
|
-
| Variable | Default
|
|
30
|
-
| -------------------------- |
|
|
31
|
-
| `ACE_API_URL` | `
|
|
32
|
-
| `ACE_SITE_DOMAIN` | `localhost`
|
|
33
|
-
| `ACE_PREVIEW_ADMIN_ORIGIN` | `
|
|
29
|
+
| Variable | Default | Meaning |
|
|
30
|
+
| -------------------------- | --------------------------- | --------------------------------------------------------- |
|
|
31
|
+
| `ACE_API_URL` | `https://api.ace-cms.co.uk` | where the CMS Ace API lives |
|
|
32
|
+
| `ACE_SITE_DOMAIN` | `localhost` | the domain this site has in the CMS (the port is ignored) |
|
|
33
|
+
| `ACE_PREVIEW_ADMIN_ORIGIN` | `https://app.ace-cms.co.uk` | where the CMS admin app runs |
|
|
34
|
+
|
|
35
|
+
CMS Ace is a hosted platform, so a site normally sets only `ACE_SITE_DOMAIN`. Set the other two only to use a CMS on your own machine (`http://localhost:8080` and `http://localhost:5173`).
|
|
34
36
|
|
|
35
37
|
**2. The server entry**, which renders pages and lets the CMS's admin app (and only it) frame the site for [live preview](./live-preview.md):
|
|
36
38
|
|
package/docs/sections.md
CHANGED
|
@@ -87,7 +87,7 @@ While the dev server runs, Ace Kit watches for `*.schema.ts` files (in `src`) an
|
|
|
87
87
|
10:41:07 [ace-kit] Synced 3 section types (faq, gallery, hero) to localhost (http://localhost:8080).
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
-
You don't run anything. You do need to be signed in once: `npx ace-kit login` (see [the command line](./command-line.md)). The sync goes to the site
|
|
90
|
+
You don't run anything. You do need to be signed in once: `npx ace-kit login` (see [the command line](./command-line.md)). The sync goes to the site the dev server is working on, the same one it reads its content from, and only an owner of that site (or a super admin) can sync to it.
|
|
91
91
|
|
|
92
92
|
**Your dev site, not the live one.** Against a _hosted_ CMS the dev server works on a [dev site](./dev-sites.md): your own private copy of the site, made for you the first time, so a half-written field never reaches editors or visitors of the live site. The sync goes there. Against a CMS on your own machine there is no need for one, and the sync goes to the site itself.
|
|
93
93
|
|
package/docs/typed-content.md
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
The kit can write TypeScript types for your site's content types, so `getEntry` and `getEntries` return the right shape and a change in the CMS shows up as a type error in your site.
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
|
-
npx ace-kit generate --
|
|
6
|
+
npx ace-kit generate --site www.example.com
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
or with the settings in the environment:
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
|
|
12
|
+
ACE_SITE_DOMAIN=www.example.com npx ace-kit generate
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
It reads `GET /public/content-types` (no login: it describes field names and kinds, never entries) and writes `src/ace-kit.generated.d.ts` (change it with `--out`). Make sure the file is inside your `tsconfig` `include`. Commit it, and run the command again whenever content types change (a good moment is a CI step, or a `generate` script next to `dev`).
|
|
15
|
+
Add `--api-url http://localhost:8080` (or `ACE_API_URL`) only for a CMS on your own machine. It reads `GET /public/content-types` (no login: it describes field names and kinds, never entries) and writes `src/ace-kit.generated.d.ts` (change it with `--out`). Make sure the file is inside your `tsconfig` `include`. Commit it, and run the command again whenever content types change (a good moment is a CI step, or a `generate` script next to `dev`).
|
|
16
16
|
|
|
17
17
|
```ts
|
|
18
18
|
// ace-kit.generated.d.ts (generated)
|
package/package.json
CHANGED