@canonical/summon-application 0.30.0 → 0.32.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 +15 -7
- package/dist/esm/application/react/index.js +31 -5
- package/dist/esm/application/react/index.js.map +1 -1
- package/dist/esm/application/react/templates/README.md.ejs +18 -5
- package/dist/esm/application/react/templates/package.json.ejs +9 -8
- package/dist/esm/application/react/templates/patches/{react-relay@18.2.0.patch → react-relay@21.0.1.patch} +5 -4
- package/dist/esm/application/react/templates/patches/relay-runtime@21.0.1.patch +26 -0
- package/dist/esm/application/react/templates/src/relay/__generated__/ProductCard_product.graphql.ts +1 -2
- package/dist/esm/application/react/templates/src/relay/__generated__/ProductListQuery.graphql.ts +14 -15
- package/dist/esm/application/react/templates/vite.config.ts.ejs +10 -6
- package/dist/esm/shared/workspace.js +128 -0
- package/dist/esm/shared/workspace.js.map +1 -0
- package/dist/types/application/react/index.d.ts.map +1 -1
- package/dist/types/shared/workspace.d.ts +12 -0
- package/dist/types/shared/workspace.d.ts.map +1 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -80,13 +80,21 @@ The `--relay` flag (off by default) mirrors the boilerplate's Relay data layer:
|
|
|
80
80
|
SSR data serialization/hydration is supported: the server streams the
|
|
81
81
|
fallback and the browser fetches after hydration. It is emitted only with
|
|
82
82
|
`--relay` because the catalog page is its only consumer today.
|
|
83
|
-
- **`patches/` + `"patchedDependencies"`** —
|
|
84
|
-
|
|
85
|
-
the
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
`
|
|
83
|
+
- **`patches/` + `"patchedDependencies"`** — emitted only for STANDALONE
|
|
84
|
+
apps. bun resolves `patchedDependencies` paths from the workspace root, so
|
|
85
|
+
when the target path is inside a bun workspace (detected by walking up for
|
|
86
|
+
a `package.json` whose `workspaces` globs cover the app) the workspace root
|
|
87
|
+
owns patching and the scaffold emits neither the `patches/` directory nor
|
|
88
|
+
the `patchedDependencies` block — an app-local block there would abort
|
|
89
|
+
`bun install` with "Couldn't find patch file". A standalone app cannot
|
|
90
|
+
inherit anyone's `patches/`, so three bun patches ship with the scaffold:
|
|
91
|
+
`react-relay@21.0.1` (cjs-module-lexer export hints so named imports
|
|
92
|
+
survive Node SSR externalisation), `relay-runtime@21.0.1` (real runtime
|
|
93
|
+
bindings for type-only names the compiler artifacts import as values —
|
|
94
|
+
`ConcreteRequest`, `ReaderFragment`, `FragmentRefs`), and
|
|
95
|
+
`relay-runtime-network@0.1.0` (fixes its broken package `imports` map —
|
|
96
|
+
temporary until the fixed upstream release lands, advl/lit-relay#32, after
|
|
97
|
+
which the patch and its `patchedDependencies` entry can be dropped).
|
|
90
98
|
- **Wiring** — `RelayEnvironmentProvider` in both entries (one environment
|
|
91
99
|
per browser session on the client, a fresh one per request on the server),
|
|
92
100
|
`vite-plugin-relay-lite` in `vite.config.ts` (`codegen: false`; artifacts
|
|
@@ -4,6 +4,7 @@ import { template, withHelpers } from "@canonical/summon-core";
|
|
|
4
4
|
import { copyFile, exec, exists, flatMap, info, pure, sequence_, warn, when, } from "@canonical/task";
|
|
5
5
|
import { pickPackageManager } from "../../shared/packageManager.js";
|
|
6
6
|
import { resolvePragmaVersion } from "../../shared/versions.js";
|
|
7
|
+
import { findEnclosingWorkspaceRoot } from "../../shared/workspace.js";
|
|
7
8
|
const prompts = [
|
|
8
9
|
{
|
|
9
10
|
name: "appPath",
|
|
@@ -105,6 +106,14 @@ Requires both --ssr and --router flags.`,
|
|
|
105
106
|
}
|
|
106
107
|
const dest = (...segments) => path.join(appPath, ...segments);
|
|
107
108
|
const copy = (filePath) => copyFile(src(filePath), dest(filePath));
|
|
109
|
+
// Whether the app lands inside a bun workspace decides who owns dependency
|
|
110
|
+
// patching: bun resolves `patchedDependencies` paths from the WORKSPACE
|
|
111
|
+
// ROOT, so an app-local block inside a workspace aborts `bun install`
|
|
112
|
+
// ("Couldn't find patch file") and leaves the workspace unlinked. Inside a
|
|
113
|
+
// workspace the root owns patching and the scaffold emits no patches;
|
|
114
|
+
// standalone apps get their own patches/ + patchedDependencies.
|
|
115
|
+
const workspaceRoot = findEnclosingWorkspaceRoot(path.resolve(appPath));
|
|
116
|
+
const standalone = workspaceRoot === null;
|
|
108
117
|
// Resolve the @canonical/* version range first (latest from npm, with an
|
|
109
118
|
// offline fallback), then build the rest of the pipeline with it baked into
|
|
110
119
|
// the template vars.
|
|
@@ -113,6 +122,7 @@ Requires both --ssr and --router flags.`,
|
|
|
113
122
|
name,
|
|
114
123
|
forms: answers.forms,
|
|
115
124
|
relay: answers.relay,
|
|
125
|
+
standalone,
|
|
116
126
|
pragmaVersion,
|
|
117
127
|
});
|
|
118
128
|
// Detect an available package manager for both the (optional) install
|
|
@@ -267,16 +277,32 @@ Requires both --ssr and --router flags.`,
|
|
|
267
277
|
when(answers.relay, copy("src/domains/catalog/ErrorBoundary.tsx")),
|
|
268
278
|
when(answers.relay, copy("src/domains/catalog/ErrorBoundary.tests.tsx")),
|
|
269
279
|
when(answers.relay, copy("src/domains/catalog/routes.ts")),
|
|
270
|
-
// Standalone dependency patches (when --relay is enabled): a
|
|
271
|
-
// app cannot inherit
|
|
272
|
-
// scaffold and are applied via "patchedDependencies" in
|
|
280
|
+
// Standalone dependency patches (when --relay is enabled): a
|
|
281
|
+
// standalone app cannot inherit a workspace's patches/, so they ship
|
|
282
|
+
// with the scaffold and are applied via "patchedDependencies" in
|
|
283
|
+
// package.json. Inside a bun workspace the WORKSPACE ROOT owns
|
|
284
|
+
// patching — bun resolves patch paths from the root, so an app-local
|
|
285
|
+
// block would abort `bun install` ("Couldn't find patch file") —
|
|
286
|
+
// hence neither patches/ nor patchedDependencies are emitted there.
|
|
287
|
+
when(answers.relay && !standalone, info(`Scaffolding into the bun workspace at "${workspaceRoot}" — ` +
|
|
288
|
+
"dependency patches are owned by the workspace root, so no " +
|
|
289
|
+
"app-local patches/ or patchedDependencies were emitted. " +
|
|
290
|
+
"Ensure the workspace root patches react-relay, relay-runtime " +
|
|
291
|
+
"and relay-runtime-network (see the app README).")),
|
|
273
292
|
// react-relay: cjs-module-lexer export hints so named imports survive
|
|
274
293
|
// Node SSR externalisation.
|
|
275
|
-
when(answers.relay, copy("patches/react-relay@
|
|
294
|
+
when(answers.relay && standalone, copy("patches/react-relay@21.0.1.patch")),
|
|
295
|
+
// relay-runtime: real `module.exports.X = undefined;` assignments for
|
|
296
|
+
// type-only names (ConcreteRequest, ReaderFragment, FragmentRefs…)
|
|
297
|
+
// that relay-compiler's TypeScript artifacts import as values —
|
|
298
|
+
// strict ESM-CJS interop (Node ESM, Vite's SSR module runner, Bun)
|
|
299
|
+
// rejects them otherwise. Real assignments, not a dead-branch lexer
|
|
300
|
+
// hint: Bun's interop reflects the actual runtime exports object.
|
|
301
|
+
when(answers.relay && standalone, copy("patches/relay-runtime@21.0.1.patch")),
|
|
276
302
|
// relay-runtime-network: fixes the broken package `imports` map.
|
|
277
303
|
// Temporary until the fixed upstream release lands (advl/lit-relay#32);
|
|
278
304
|
// then this patch and its patchedDependencies entry can be dropped.
|
|
279
|
-
when(answers.relay, copy("patches/relay-runtime-network@0.1.0.patch")),
|
|
305
|
+
when(answers.relay && standalone, copy("patches/relay-runtime-network@0.1.0.patch")),
|
|
280
306
|
// Routes (EJS — conditionally includes contact + catalog domains)
|
|
281
307
|
template({
|
|
282
308
|
source: src("src/routes.tsx.ejs"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/application/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAKzC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EACL,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,IAAI,GACL,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/application/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAKzC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EACL,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,IAAI,GACL,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAWvE,MAAM,OAAO,GAAuB;IAClC;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,6BAA6B;QACtC,OAAO,EAAE,QAAQ;QACjB,UAAU,EAAE,IAAI;QAChB,KAAK,EAAE,aAAa;KACrB;IACD;QACE,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,cAAc;QACvB,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,aAAa;KACrB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,iBAAiB;QAC1B,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,aAAa;KACrB;IACD;QACE,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,0BAA0B;QACnC,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,aAAa;KACrB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EAAqE;gBACrE,qEAAqE;gBACrE,wEAAwE;gBACxE,mEAAmE;gBACnE,WAAW,IAAI,IAAI,CAAC,SAAS,CAAC;gBAE9B,IAAI,CAAC,YAAY,CAAC;aACnB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -121,14 +121,27 @@ yet, so the catalog page wraps its query subtree in `ClientOnly`
|
|
|
121
121
|
(`src/lib/ClientOnly/`): the server streams the fallback and the browser
|
|
122
122
|
fetches after hydration.
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
<% if (standalone) { -%>
|
|
125
|
+
**Patched dependencies.** `patches/` carries three package patches applied via
|
|
125
126
|
`patchedDependencies` in `package.json` (a bun feature — with another package
|
|
126
|
-
manager, apply the equivalent mechanism): `react-relay@
|
|
127
|
-
cjs-module-lexer export hint so named imports survive Node SSR,
|
|
128
|
-
`relay-runtime
|
|
129
|
-
|
|
127
|
+
manager, apply the equivalent mechanism): `react-relay@21.0.1` needs a
|
|
128
|
+
cjs-module-lexer export hint so named imports survive Node SSR,
|
|
129
|
+
`relay-runtime@21.0.1` needs real runtime bindings for type-only names its
|
|
130
|
+
compiler artifacts import as values (`ConcreteRequest`, `ReaderFragment`,
|
|
131
|
+
`FragmentRefs`), and `relay-runtime-network@0.1.0` ships a broken `imports`
|
|
132
|
+
map. The last patch is temporary until the fixed upstream release lands
|
|
130
133
|
([advl/lit-relay#32](https://github.com/advl/lit-relay/pull/32)); drop it and
|
|
131
134
|
its `patchedDependencies` entry once a fixed version is published.
|
|
135
|
+
<% } else { -%>
|
|
136
|
+
**Patched dependencies.** This app was scaffolded inside a bun workspace, so
|
|
137
|
+
dependency patching is owned by the workspace root — bun resolves
|
|
138
|
+
`patchedDependencies` paths from the root, which is why the scaffold emitted
|
|
139
|
+
no app-local `patches/` directory or `patchedDependencies` block. The root's
|
|
140
|
+
`patches/` must carry the `react-relay@21.0.1`, `relay-runtime@21.0.1` and
|
|
141
|
+
`relay-runtime-network@0.1.0` patches (named imports under Node SSR, runtime
|
|
142
|
+
bindings for type-only artifact imports, and a broken `imports` map,
|
|
143
|
+
respectively).
|
|
144
|
+
<% } -%>
|
|
132
145
|
|
|
133
146
|
**Not yet on npm.** `@canonical/storybook-addon-relay` and the fixed
|
|
134
147
|
`relay-runtime-network` release have not been published yet, so a fresh
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
<% } -%>
|
|
61
61
|
"react": "^19.2.4",
|
|
62
62
|
"react-dom": "^19.2.4"<% if (relay) { %>,
|
|
63
|
-
"react-relay": "^
|
|
64
|
-
"relay-runtime": "^
|
|
63
|
+
"react-relay": "^21.0.1",
|
|
64
|
+
"relay-runtime": "^21.0.1",
|
|
65
65
|
"relay-runtime-network": "^0.1.0"<% } %>
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
@@ -77,8 +77,8 @@
|
|
|
77
77
|
"@types/react-dom": "^19.2.3",
|
|
78
78
|
<% if (relay) { -%>
|
|
79
79
|
"@types/react-relay": "^18.2.1",
|
|
80
|
-
"@types/relay-runtime": "^
|
|
81
|
-
"@types/relay-test-utils": "^
|
|
80
|
+
"@types/relay-runtime": "^20.1.1",
|
|
81
|
+
"@types/relay-test-utils": "^19.0.0",
|
|
82
82
|
<% } -%>
|
|
83
83
|
"@vitejs/plugin-react": "^6.0.0",
|
|
84
84
|
"@vitest/coverage-v8": "^4.0.18",
|
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
"jsdom": "^28.1.0",
|
|
88
88
|
"lightningcss": "^1.32.0",
|
|
89
89
|
<% if (relay) { -%>
|
|
90
|
-
"relay-compiler": "^
|
|
91
|
-
"relay-test-utils": "^
|
|
90
|
+
"relay-compiler": "^21.0.1",
|
|
91
|
+
"relay-test-utils": "^21.0.1",
|
|
92
92
|
<% } -%>
|
|
93
93
|
"storybook": "^10.3.1",
|
|
94
94
|
"tsx": "^4.19.0",
|
|
@@ -98,9 +98,10 @@
|
|
|
98
98
|
"vite-plugin-relay-lite": "^0.12.0",
|
|
99
99
|
<% } -%>
|
|
100
100
|
"vitest": "^4.0.18"
|
|
101
|
-
}<% if (relay) { %>,
|
|
101
|
+
}<% if (relay && standalone) { %>,
|
|
102
102
|
"patchedDependencies": {
|
|
103
|
-
"react-relay@
|
|
103
|
+
"react-relay@21.0.1": "patches/react-relay@21.0.1.patch",
|
|
104
|
+
"relay-runtime@21.0.1": "patches/relay-runtime@21.0.1.patch",
|
|
104
105
|
"relay-runtime-network@0.1.0": "patches/relay-runtime-network@0.1.0.patch"
|
|
105
106
|
}<% } %>
|
|
106
107
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
diff --git a/index.js b/index.js
|
|
2
|
-
index
|
|
2
|
+
index fec955baf6b7659b1365c9f6be3696ae30bd59a4..9976682e603b4680352f4d84c28467b703a07122 100644
|
|
3
3
|
--- a/index.js
|
|
4
4
|
+++ b/index.js
|
|
5
|
-
@@ -8,3 +8,
|
|
5
|
+
@@ -8,3 +8,48 @@
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
module.exports = require('./lib/index.js');
|
|
9
9
|
+
|
|
10
10
|
+// Patch (pragma): cjs-module-lexer cannot statically detect the exports of
|
|
@@ -42,10 +42,11 @@ index 5fe5bc4a2adf6210e2dc5f84cc33382f47953384..407b9665ffa3b703f8fb2bfffa843a86
|
|
|
42
42
|
+ useEntryPointLoader: null,
|
|
43
43
|
+ useQueryLoader: null,
|
|
44
44
|
+ useMutation: null,
|
|
45
|
+
+ useMutationAction_EXPERIMENTAL: null,
|
|
45
46
|
+ usePaginationFragment: null,
|
|
46
47
|
+ usePreloadedQuery: null,
|
|
47
48
|
+ useRefetchableFragment: null,
|
|
48
|
-
+
|
|
49
|
+
+ usePrefetchableForwardPaginationFragment: null,
|
|
49
50
|
+ useRelayEnvironment: null,
|
|
50
51
|
+ useSubscribeToInvalidationState: null,
|
|
51
52
|
+ useSubscription: null,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
diff --git a/node_modules/relay-runtime/.bun-tag-be2ff370f245fe53 b/.bun-tag-be2ff370f245fe53
|
|
2
|
+
new file mode 100644
|
|
3
|
+
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
|
|
4
|
+
diff --git a/index.js b/index.js
|
|
5
|
+
index fec955baf6b7659b1365c9f6be3696ae30bd59a4..4dfe28979fe0d055148e3ec15931bec20c30d8ae 100644
|
|
6
|
+
--- a/index.js
|
|
7
|
+
+++ b/index.js
|
|
8
|
+
@@ -8,3 +8,18 @@
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
module.exports = require('./lib/index.js');
|
|
12
|
+
+
|
|
13
|
+
+// Patch (pragma): relay-compiler's TypeScript artifacts emit value imports for
|
|
14
|
+
+// names that exist only as types (`import { ConcreteRequest } from
|
|
15
|
+
+// 'relay-runtime'`), which fail strict ESM-CJS interop checks (Node ESM and
|
|
16
|
+
+// Vite's dev SSR module runner) because the names are not runtime exports.
|
|
17
|
+
+// Real `module.exports.X =` assignments — not a dead-branch lexer hint — are
|
|
18
|
+
+// required: Node's cjs-module-lexer detects them statically, and Bun's interop
|
|
19
|
+
+// reflects the runtime exports object, which a never-executed hint would not
|
|
20
|
+
+// touch. The bindings stay undefined, which is fine for names only ever used
|
|
21
|
+
+// in erased type positions.
|
|
22
|
+
+module.exports.ConcreteRequest = undefined;
|
|
23
|
+
+module.exports.ReaderFragment = undefined;
|
|
24
|
+
+module.exports.ReaderInlineDataFragment = undefined;
|
|
25
|
+
+module.exports.FragmentRefs = undefined;
|
|
26
|
+
+module.exports.ConcreteUpdatableQuery = undefined;
|
package/dist/esm/application/react/templates/src/relay/__generated__/ProductListQuery.graphql.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @generated SignedSource<<
|
|
2
|
+
* @generated SignedSource<<4a78ea6f25a5f5f01866f23299cb1067>>
|
|
3
3
|
* @lightSyntaxTransform
|
|
4
|
-
* @nogrep
|
|
5
4
|
*/
|
|
6
5
|
|
|
7
6
|
/* tslint:disable */
|
|
@@ -102,7 +101,7 @@ v5 = {
|
|
|
102
101
|
};
|
|
103
102
|
return {
|
|
104
103
|
"fragment": {
|
|
105
|
-
"argumentDefinitions": (v0
|
|
104
|
+
"argumentDefinitions": (v0/*:: as any*/),
|
|
106
105
|
"kind": "Fragment",
|
|
107
106
|
"metadata": null,
|
|
108
107
|
"name": "ProductListQuery",
|
|
@@ -115,17 +114,17 @@ return {
|
|
|
115
114
|
"name": "viewer",
|
|
116
115
|
"plural": false,
|
|
117
116
|
"selections": [
|
|
118
|
-
(v1
|
|
117
|
+
(v1/*:: as any*/),
|
|
119
118
|
{
|
|
120
119
|
"alias": null,
|
|
121
|
-
"args": (v2
|
|
120
|
+
"args": (v2/*:: as any*/),
|
|
122
121
|
"concreteType": "ProductConnection",
|
|
123
122
|
"kind": "LinkedField",
|
|
124
123
|
"name": "products",
|
|
125
124
|
"plural": false,
|
|
126
125
|
"selections": [
|
|
127
|
-
(v3
|
|
128
|
-
(v4
|
|
126
|
+
(v3/*:: as any*/),
|
|
127
|
+
(v4/*:: as any*/),
|
|
129
128
|
{
|
|
130
129
|
"alias": null,
|
|
131
130
|
"args": null,
|
|
@@ -142,7 +141,7 @@ return {
|
|
|
142
141
|
"name": "node",
|
|
143
142
|
"plural": false,
|
|
144
143
|
"selections": [
|
|
145
|
-
(v5
|
|
144
|
+
(v5/*:: as any*/),
|
|
146
145
|
{
|
|
147
146
|
"args": null,
|
|
148
147
|
"kind": "FragmentSpread",
|
|
@@ -166,7 +165,7 @@ return {
|
|
|
166
165
|
},
|
|
167
166
|
"kind": "Request",
|
|
168
167
|
"operation": {
|
|
169
|
-
"argumentDefinitions": (v0
|
|
168
|
+
"argumentDefinitions": (v0/*:: as any*/),
|
|
170
169
|
"kind": "Operation",
|
|
171
170
|
"name": "ProductListQuery",
|
|
172
171
|
"selections": [
|
|
@@ -178,17 +177,17 @@ return {
|
|
|
178
177
|
"name": "viewer",
|
|
179
178
|
"plural": false,
|
|
180
179
|
"selections": [
|
|
181
|
-
(v1
|
|
180
|
+
(v1/*:: as any*/),
|
|
182
181
|
{
|
|
183
182
|
"alias": null,
|
|
184
|
-
"args": (v2
|
|
183
|
+
"args": (v2/*:: as any*/),
|
|
185
184
|
"concreteType": "ProductConnection",
|
|
186
185
|
"kind": "LinkedField",
|
|
187
186
|
"name": "products",
|
|
188
187
|
"plural": false,
|
|
189
188
|
"selections": [
|
|
190
|
-
(v3
|
|
191
|
-
(v4
|
|
189
|
+
(v3/*:: as any*/),
|
|
190
|
+
(v4/*:: as any*/),
|
|
192
191
|
{
|
|
193
192
|
"alias": null,
|
|
194
193
|
"args": null,
|
|
@@ -205,8 +204,8 @@ return {
|
|
|
205
204
|
"name": "node",
|
|
206
205
|
"plural": false,
|
|
207
206
|
"selections": [
|
|
208
|
-
(v5
|
|
209
|
-
(v1
|
|
207
|
+
(v5/*:: as any*/),
|
|
208
|
+
(v1/*:: as any*/),
|
|
210
209
|
{
|
|
211
210
|
"alias": null,
|
|
212
211
|
"args": null,
|
|
@@ -80,12 +80,16 @@ export default defineConfig(({ mode }) => ({
|
|
|
80
80
|
<% if (relay) { -%>
|
|
81
81
|
//
|
|
82
82
|
// The Relay packages (react-relay, relay-runtime, relay-runtime-network,
|
|
83
|
-
// graphql) stay externalised like react itself.
|
|
84
|
-
// made that possible and are fixed via `patchedDependencies` (
|
|
85
|
-
// patches/
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
//
|
|
83
|
+
// graphql) stay externalised like react itself. Three packaging defects
|
|
84
|
+
// made that possible and are fixed via `patchedDependencies` (app-local
|
|
85
|
+
// patches/ for a standalone app; the workspace root's patches/ when the
|
|
86
|
+
// app lives inside a bun workspace): react-relay's CJS exports are member
|
|
87
|
+
// expressions cjs-module-lexer cannot detect (breaking named imports
|
|
88
|
+
// under Node SSR and Vite's dev module runner), relay-runtime lacks
|
|
89
|
+
// runtime bindings for type-only names its compiler artifacts import as
|
|
90
|
+
// values (ConcreteRequest, ReaderFragment, FragmentRefs), and
|
|
91
|
+
// relay-runtime-network@0.1.0 ships an `imports` map pointing at its
|
|
92
|
+
// unpublished src/ directory.
|
|
89
93
|
<% } -%>
|
|
90
94
|
noExternal: [/^@canonical\//],
|
|
91
95
|
},
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Detect whether a directory would be claimed as a member of an enclosing bun
|
|
5
|
+
* workspace, walking up from the directory and matching each ancestor's
|
|
6
|
+
* `workspaces` globs against the relative path.
|
|
7
|
+
*
|
|
8
|
+
* Why this matters for scaffolding: bun resolves `patchedDependencies` paths
|
|
9
|
+
* from the WORKSPACE ROOT, not from the member package. An app-local
|
|
10
|
+
* `patchedDependencies` block inside a workspace makes `bun install` abort
|
|
11
|
+
* ("Couldn't find patch file") and leaves the entire workspace's node_modules
|
|
12
|
+
* unlinked — so the generator must emit patches only for standalone apps.
|
|
13
|
+
*
|
|
14
|
+
* Semantics mirror bun/npm workspace resolution:
|
|
15
|
+
* - The nearest ancestor whose `workspaces` globs cover the directory wins.
|
|
16
|
+
* - Ancestor package.json files without a matching `workspaces` field do not
|
|
17
|
+
* stop the walk (an intermediate plain package does not detach the app from
|
|
18
|
+
* an outer workspace root for patch resolution).
|
|
19
|
+
* - The directory itself is never its own enclosing root — an app that IS a
|
|
20
|
+
* workspace root resolves patches from itself, which is the standalone case.
|
|
21
|
+
* - Both the array form (`"workspaces": [...]`) and the object form
|
|
22
|
+
* (`"workspaces": { "packages": [...] }`) are accepted.
|
|
23
|
+
* - Globs support `*`/`?` within a path segment and `**` across segments —
|
|
24
|
+
* the subset bun and npm document for workspace member patterns. Negation
|
|
25
|
+
* patterns are not interpreted.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Read the `workspaces` member globs from a package.json, accepting both the
|
|
29
|
+
* array form (`"workspaces": [...]`) and the object form
|
|
30
|
+
* (`"workspaces": { "packages": [...] }`). Returns `null` when the file is
|
|
31
|
+
* unreadable, is not valid JSON, or declares no workspaces — a malformed
|
|
32
|
+
* manifest somewhere up the tree must not break scaffolding. The parsed JSON
|
|
33
|
+
* is validated structurally rather than trusted via a cast.
|
|
34
|
+
*
|
|
35
|
+
* @note Impure — reads the filesystem.
|
|
36
|
+
*/
|
|
37
|
+
function readWorkspaceGlobs(manifestPath) {
|
|
38
|
+
let manifest;
|
|
39
|
+
try {
|
|
40
|
+
manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
if (typeof manifest !== "object" || manifest === null)
|
|
46
|
+
return null;
|
|
47
|
+
const workspaces = manifest.workspaces;
|
|
48
|
+
const globs = Array.isArray(workspaces)
|
|
49
|
+
? workspaces
|
|
50
|
+
: typeof workspaces === "object" && workspaces !== null
|
|
51
|
+
? workspaces.packages
|
|
52
|
+
: undefined;
|
|
53
|
+
if (!Array.isArray(globs))
|
|
54
|
+
return null;
|
|
55
|
+
const patterns = globs.filter((glob) => typeof glob === "string" && glob.length > 0);
|
|
56
|
+
return patterns.length > 0 ? patterns : null;
|
|
57
|
+
}
|
|
58
|
+
/** Escape a literal glob segment for regex use, keeping `*`/`?` wildcards. */
|
|
59
|
+
function compileGlobSegment(segment) {
|
|
60
|
+
return segment
|
|
61
|
+
.replace(/[.+^${}()|[\]\\]/g, "\\$&")
|
|
62
|
+
.replace(/\*/g, "[^/]*")
|
|
63
|
+
.replace(/\?/g, "[^/]");
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Compile one workspace glob to a regular expression over a `/`-separated
|
|
67
|
+
* relative path: `**` matches zero or more whole segments, `*` and `?` match
|
|
68
|
+
* within one segment.
|
|
69
|
+
*/
|
|
70
|
+
function compileWorkspaceGlob(glob) {
|
|
71
|
+
const segments = glob.split("/");
|
|
72
|
+
let pattern = "";
|
|
73
|
+
segments.forEach((segment, index) => {
|
|
74
|
+
const isLast = index === segments.length - 1;
|
|
75
|
+
if (segment === "**") {
|
|
76
|
+
// Globstar: zero or more whole segments. In the middle it contributes
|
|
77
|
+
// `segment/` repetitions; at the end it swallows any remaining depth
|
|
78
|
+
// (including none — `apps/**` covers `apps` itself).
|
|
79
|
+
pattern = isLast
|
|
80
|
+
? pattern === ""
|
|
81
|
+
? ".*"
|
|
82
|
+
: `${pattern.replace(/\/$/, "")}(?:/.*)?`
|
|
83
|
+
: `${pattern}(?:[^/]+/)*`;
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
pattern += compileGlobSegment(segment);
|
|
87
|
+
if (!isLast)
|
|
88
|
+
pattern += "/";
|
|
89
|
+
});
|
|
90
|
+
return new RegExp(`^${pattern}$`);
|
|
91
|
+
}
|
|
92
|
+
/** Whether any workspace glob covers the given `/`-separated relative path. */
|
|
93
|
+
function coversRelativePath(globs, relativePath) {
|
|
94
|
+
return globs.some((glob) => compileWorkspaceGlob(glob).test(relativePath));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Find the nearest ancestor directory whose package.json `workspaces` globs
|
|
98
|
+
* cover `appDirectory` — i.e. the bun workspace root that would claim the app
|
|
99
|
+
* as a member and own its dependency patching. Returns `null` when no
|
|
100
|
+
* enclosing workspace covers the path (the standalone case).
|
|
101
|
+
*
|
|
102
|
+
* The app directory does not need to exist yet; only ancestors are probed.
|
|
103
|
+
*
|
|
104
|
+
* @note Impure — walks the filesystem upward from the app directory.
|
|
105
|
+
*/
|
|
106
|
+
export function findEnclosingWorkspaceRoot(appDirectory) {
|
|
107
|
+
const target = path.resolve(appDirectory);
|
|
108
|
+
let current = path.dirname(target);
|
|
109
|
+
while (true) {
|
|
110
|
+
const manifestPath = path.join(current, "package.json");
|
|
111
|
+
if (existsSync(manifestPath)) {
|
|
112
|
+
const globs = readWorkspaceGlobs(manifestPath);
|
|
113
|
+
if (globs !== null) {
|
|
114
|
+
const relativePath = path
|
|
115
|
+
.relative(current, target)
|
|
116
|
+
.split(path.sep)
|
|
117
|
+
.join("/");
|
|
118
|
+
if (coversRelativePath(globs, relativePath))
|
|
119
|
+
return current;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const parent = path.dirname(current);
|
|
123
|
+
if (parent === current)
|
|
124
|
+
return null;
|
|
125
|
+
current = parent;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../../src/shared/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;;;;;;;;GASG;AACH,SAAS,kBAAkB,CAAC,YAAoB;IAC9C,IAAI,QAAiB,CAAC;IACtB,IAAI,CAAC;QACH,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACnE,MAAM,UAAU,GAAa,QAAqC,CAAC,UAAU,CAAC;IAC9E,MAAM,KAAK,GAAY,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;QAC9C,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,IAAI;YACrD,CAAC,CAAE,UAAqC,CAAC,QAAQ;YACjD,CAAC,CAAC,SAAS,CAAC;IAChB,IAAI,CA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
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/application/react/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,mBAAmB,EAEpB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/application/react/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,mBAAmB,EAEpB,MAAM,wBAAwB,CAAC;AAiBhC,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAsDD,eAAO,MAAM,SAAS,EAAE,mBAAmB,CAAC,uBAAuB,CAoYlE,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find the nearest ancestor directory whose package.json `workspaces` globs
|
|
3
|
+
* cover `appDirectory` — i.e. the bun workspace root that would claim the app
|
|
4
|
+
* as a member and own its dependency patching. Returns `null` when no
|
|
5
|
+
* enclosing workspace covers the path (the standalone case).
|
|
6
|
+
*
|
|
7
|
+
* The app directory does not need to exist yet; only ancestors are probed.
|
|
8
|
+
*
|
|
9
|
+
* @note Impure — walks the filesystem upward from the app directory.
|
|
10
|
+
*/
|
|
11
|
+
export declare function findEnclosingWorkspaceRoot(appDirectory: string): string | null;
|
|
12
|
+
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../src/shared/workspace.ts"],"names":[],"mappings":"AAsGA;;;;;;;;;GASG;AACH,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,MAAM,GACnB,MAAM,GAAG,IAAI,CAmBf"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/summon-application",
|
|
3
3
|
"description": "Summon generators for application scaffolding: domain, route, and wrapper",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.32.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
7
7
|
"module": "dist/esm/index.js",
|
|
@@ -36,17 +36,17 @@
|
|
|
36
36
|
"test": "vitest run"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@canonical/summon-core": "^0.
|
|
40
|
-
"@canonical/task": "^0.
|
|
41
|
-
"@canonical/utils": "^0.
|
|
39
|
+
"@canonical/summon-core": "^0.32.0",
|
|
40
|
+
"@canonical/task": "^0.32.0",
|
|
41
|
+
"@canonical/utils": "^0.32.0",
|
|
42
42
|
"typescript": "^5.9.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@biomejs/biome": "2.4.9",
|
|
46
|
-
"@canonical/biome-config": "^0.
|
|
47
|
-
"@canonical/webarchitect": "^0.
|
|
46
|
+
"@canonical/biome-config": "^0.32.0",
|
|
47
|
+
"@canonical/webarchitect": "^0.32.0",
|
|
48
48
|
"@types/node": "^24.12.0",
|
|
49
49
|
"vitest": "^4.0.18"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "5b279d8150e3988c68c6c2a741046bcd425624ca"
|
|
52
52
|
}
|