@pantheon-systems/create-p1-starter-kit 0.11.1 → 0.13.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/README.md +3 -3
- package/lib/cli.js +122 -53
- package/lib/cli.test.js +55 -0
- package/lib/copy-template.js +44 -1
- package/lib/copy-template.test.js +75 -0
- package/lib/messages.js +1 -1
- package/package.json +5 -4
- package/template/README.md +82 -0
- package/template/__tests__/auth-route.test.ts +1 -1
- package/template/__tests__/seo-metadata.test.ts +1 -1
- package/template/__tests__/styles-canvas-scope.test.ts +1 -1
- package/template/__tests__/widget-logout.test.ts +114 -0
- package/template/app/[...puckPath]/client.tsx +38 -10
- package/template/app/[...puckPath]/page.tsx +4 -4
- package/template/app/[...puckPath]/widget-logout.ts +36 -0
- package/template/app/p1/(editor)/[[...p1]]/editor-client.tsx +10 -67
- package/template/app/styles.css +6 -2
- package/template/ci-examples/github-actions-sync-puck-registry.yml +15 -7
- package/template/eslint.config.js +63 -0
- package/template/gitignore +43 -0
- package/template/lib/chatbot-flag/ai-generate.ts +1 -1
- package/template/lib/page-seo.ts +1 -1
- package/template/package.json +5 -5
- package/template/scripts/__tests__/sync-puck-registry.test.ts +3 -3
- package/template/scripts/sync-puck-registry.ts +18 -18
- package/template/CHANGELOG.md +0 -76
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
* Syncs this site's Puck component registry (_registry/components/* and the
|
|
3
3
|
* registry index) headlessly, without opening the editor in a browser.
|
|
4
4
|
* Intended to run from CI on push to main or a branch whose name matches a
|
|
5
|
-
*
|
|
5
|
+
* branch on the site, whenever puck.config.tsx or components/puck/** change.
|
|
6
6
|
*
|
|
7
7
|
* Usage: tsx scripts/sync-puck-registry.ts [--dry-run]
|
|
8
8
|
*
|
|
9
9
|
* Required env vars (see validateEnv below for the full fallback contract):
|
|
10
10
|
* CSS_BASE_URL, CSS_SITE_ID, CSS_REGISTRY_API_KEY
|
|
11
11
|
* Optional:
|
|
12
|
-
* CSS_BRANCH_ID —
|
|
12
|
+
* CSS_BRANCH_ID — branch to target (in CI: the pushed git ref's name)
|
|
13
13
|
* CSS_DEFAULT_BRANCH — the repo's default branch name (defaults to "main");
|
|
14
14
|
* when CSS_BRANCH_ID equals it, the site's isMain branch is targeted
|
|
15
15
|
* regardless of naming (see resolveBranchId for the resolution contract)
|
|
16
16
|
*
|
|
17
17
|
* CSS_REGISTRY_API_KEY must be a sat_ site token scoped to write:registry
|
|
18
18
|
* only — do not reuse a read-scoped token (P1_CSS_API_KEY). Because that
|
|
19
|
-
* token has no read access at all, every run
|
|
20
|
-
* descriptor + the registry index
|
|
21
|
-
* see syncComponentRegistryWriteOnly.
|
|
19
|
+
* token has no read access at all, every run posts every component
|
|
20
|
+
* descriptor + the registry index; the backend compares each against stored
|
|
21
|
+
* content and writes only what changed — see syncComponentRegistryWriteOnly.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import { register } from "node:module";
|
|
@@ -43,7 +43,7 @@ export function validateEnv(env: Record<string, string | undefined>): ValidatedE
|
|
|
43
43
|
const siteId = env.CSS_SITE_ID ?? env.NEXT_PUBLIC_CSS_SITE_ID;
|
|
44
44
|
const apiKey = env.CSS_REGISTRY_API_KEY;
|
|
45
45
|
const branchOverride = env.CSS_BRANCH_ID ?? env.NEXT_PUBLIC_CSS_BRANCH_ID;
|
|
46
|
-
// Defaults to "main": the
|
|
46
|
+
// Defaults to "main": the site's main content branch is always literally
|
|
47
47
|
// named "main", so for repos whose default git branch is also "main" this
|
|
48
48
|
// resolves to the same branch it would have matched by name. Repos with a
|
|
49
49
|
// differently-named default branch (master, trunk) must set it explicitly.
|
|
@@ -88,10 +88,10 @@ export function resolveConfigModule(mod: unknown): unknown {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
|
-
* Thrown by resolveBranchId when no
|
|
92
|
-
* other errors so callers (main(), a CI trigger firing on every git
|
|
93
|
-
* can treat "this branch has no
|
|
94
|
-
* than a real sync failure.
|
|
91
|
+
* Thrown by resolveBranchId when no matching branch is found. Distinguished
|
|
92
|
+
* from other errors so callers (main(), a CI trigger firing on every git
|
|
93
|
+
* branch) can treat "this branch has no counterpart on the site" as a benign
|
|
94
|
+
* no-op rather than a real sync failure.
|
|
95
95
|
*/
|
|
96
96
|
export class NoBranchMatchError extends Error {}
|
|
97
97
|
|
|
@@ -133,12 +133,12 @@ export function filterAssetStubbedDescriptors(descriptors: Descriptor[]): {
|
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
135
|
* Resolution contract: an override (in CI, always the pushed git ref's name)
|
|
136
|
-
* matches a
|
|
137
|
-
* default branch name, which always resolves the site's isMain
|
|
138
|
-
* main is always literally named "main", so
|
|
139
|
-
* default branch is "master"/"trunk" would
|
|
140
|
-
* default branch means the main registry,
|
|
141
|
-
*
|
|
136
|
+
* matches a branch on the site by id or name — EXCEPT when it equals the
|
|
137
|
+
* repo's default branch name, which always resolves the site's isMain
|
|
138
|
+
* branch. The site's main branch is always literally named "main", so
|
|
139
|
+
* without that rule a repo whose default branch is "master"/"trunk" would
|
|
140
|
+
* silently skip on every push. The default branch means the main registry,
|
|
141
|
+
* even over a coincidentally-named branch on the site, e.g. "master".
|
|
142
142
|
*/
|
|
143
143
|
export function resolveBranchId(
|
|
144
144
|
branches: Branch[],
|
|
@@ -211,8 +211,8 @@ const isMainModule = import.meta.url === pathToFileURL(process.argv[1] ?? "").hr
|
|
|
211
211
|
if (isMainModule) {
|
|
212
212
|
main().catch((err: unknown) => {
|
|
213
213
|
// A CI trigger firing on every git branch push has no way to know ahead
|
|
214
|
-
// of time which branches have a matching
|
|
215
|
-
// discovered at runtime. Treat "no match" as a benign no-op, not a
|
|
214
|
+
// of time which branches have a matching branch on the site — that has
|
|
215
|
+
// to be discovered at runtime. Treat "no match" as a benign no-op, not a
|
|
216
216
|
// failure, so unrelated feature-branch pushes don't turn CI red.
|
|
217
217
|
if (err instanceof NoBranchMatchError) {
|
|
218
218
|
console.log(`[sync-puck-registry] Skipping: ${err.message}`);
|
package/template/CHANGELOG.md
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
# @pantheon-systems/p1-starter
|
|
2
|
-
|
|
3
|
-
## 1.0.7
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Updated dependencies
|
|
8
|
-
- Updated dependencies
|
|
9
|
-
- Updated dependencies
|
|
10
|
-
- Updated dependencies [3ed945e]
|
|
11
|
-
- Updated dependencies
|
|
12
|
-
- Updated dependencies
|
|
13
|
-
- Updated dependencies
|
|
14
|
-
- Updated dependencies
|
|
15
|
-
- Updated dependencies
|
|
16
|
-
- Updated dependencies
|
|
17
|
-
- Updated dependencies
|
|
18
|
-
- Updated dependencies
|
|
19
|
-
- @pantheon-systems/puck-css@0.8.0
|
|
20
|
-
- @pantheon-systems/p1-next-sdk@0.8.0
|
|
21
|
-
- @pantheon-systems/css-client@0.8.0
|
|
22
|
-
|
|
23
|
-
## 1.0.6
|
|
24
|
-
|
|
25
|
-
### Patch Changes
|
|
26
|
-
|
|
27
|
-
- Updated dependencies [b0254ff]
|
|
28
|
-
- Updated dependencies
|
|
29
|
-
- Updated dependencies [e937842]
|
|
30
|
-
- Updated dependencies [e937842]
|
|
31
|
-
- @pantheon-systems/puck-css@0.7.0
|
|
32
|
-
- @pantheon-systems/css-client@0.7.0
|
|
33
|
-
- @pantheon-systems/p1-next-sdk@0.7.0
|
|
34
|
-
|
|
35
|
-
## 1.0.5
|
|
36
|
-
|
|
37
|
-
### Patch Changes
|
|
38
|
-
|
|
39
|
-
- @pantheon-systems/puck-css@0.6.0
|
|
40
|
-
- @pantheon-systems/p1-next-sdk@0.6.0
|
|
41
|
-
|
|
42
|
-
## 1.0.4
|
|
43
|
-
|
|
44
|
-
### Patch Changes
|
|
45
|
-
|
|
46
|
-
- Updated dependencies [0bc7982]
|
|
47
|
-
- @pantheon-systems/puck-css@0.5.0
|
|
48
|
-
- @pantheon-systems/p1-next-sdk@0.5.0
|
|
49
|
-
|
|
50
|
-
## 1.0.3
|
|
51
|
-
|
|
52
|
-
### Patch Changes
|
|
53
|
-
|
|
54
|
-
- Updated dependencies
|
|
55
|
-
- @pantheon-systems/puck-css@0.4.4
|
|
56
|
-
- @pantheon-systems/p1-next-sdk@0.4.4
|
|
57
|
-
- @pantheon-systems/css-client@0.4.4
|
|
58
|
-
|
|
59
|
-
## 1.0.2
|
|
60
|
-
|
|
61
|
-
### Patch Changes
|
|
62
|
-
|
|
63
|
-
- Updated dependencies
|
|
64
|
-
- @pantheon-systems/puck-css@0.4.3
|
|
65
|
-
- @pantheon-systems/p1-next-sdk@0.4.3
|
|
66
|
-
- @pantheon-systems/css-client@0.4.3
|
|
67
|
-
|
|
68
|
-
## 1.0.1
|
|
69
|
-
|
|
70
|
-
### Patch Changes
|
|
71
|
-
|
|
72
|
-
- Updated dependencies [6650602]
|
|
73
|
-
- Updated dependencies [dc7cfd7]
|
|
74
|
-
- @pantheon-systems/puck-css@0.4.2
|
|
75
|
-
- @pantheon-systems/css-client@0.4.2
|
|
76
|
-
- @pantheon-systems/p1-next-sdk@0.4.2
|