@canonical/summon-application 0.29.0-experimental.0 → 0.30.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/LICENSE +166 -0
- package/README.md +75 -13
- package/dist/esm/application/react/index.js +347 -0
- package/dist/esm/application/react/index.js.map +1 -0
- package/dist/esm/application/react/templates/.browserslistrc +2 -0
- package/dist/esm/application/react/templates/.storybook/main.ts.ejs +10 -0
- package/{src → dist/esm}/application/react/templates/README.md.ejs +54 -0
- package/dist/esm/application/react/templates/biome.json.ejs +6 -0
- package/dist/esm/application/react/templates/gitignore +25 -0
- package/{src → dist/esm}/application/react/templates/package.json.ejs +36 -2
- package/dist/esm/application/react/templates/patches/react-relay@18.2.0.patch +52 -0
- package/dist/esm/application/react/templates/patches/relay-runtime-network@0.1.0.patch +46 -0
- package/dist/esm/application/react/templates/relay.config.json +8 -0
- package/{src/application/react/templates/src/client/entry.tsx → dist/esm/application/react/templates/src/client/entry.tsx.ejs} +23 -0
- package/dist/esm/application/react/templates/src/domains/catalog/CatalogPage.tsx +50 -0
- package/dist/esm/application/react/templates/src/domains/catalog/ErrorBoundary.tests.tsx +56 -0
- package/dist/esm/application/react/templates/src/domains/catalog/ErrorBoundary.tsx +37 -0
- package/dist/esm/application/react/templates/src/domains/catalog/ProductCard.tsx +49 -0
- package/dist/esm/application/react/templates/src/domains/catalog/ProductList.stories.tsx +103 -0
- package/dist/esm/application/react/templates/src/domains/catalog/ProductList.tests.tsx +80 -0
- package/dist/esm/application/react/templates/src/domains/catalog/ProductList.tsx +59 -0
- package/dist/esm/application/react/templates/src/domains/catalog/routes.ts +11 -0
- package/dist/esm/application/react/templates/src/lib/ClientOnly/ClientOnly.tests.tsx +35 -0
- package/dist/esm/application/react/templates/src/lib/ClientOnly/ClientOnly.tsx +31 -0
- package/dist/esm/application/react/templates/src/lib/ClientOnly/index.ts +1 -0
- package/{src → dist/esm}/application/react/templates/src/lib/Navigation/Navigation.tsx.ejs +3 -0
- package/{src/application/react/templates/src/lib/index.ts → dist/esm/application/react/templates/src/lib/index.ts.ejs} +3 -0
- package/dist/esm/application/react/templates/src/relay/__generated__/ProductCard_product.graphql.ts +82 -0
- package/dist/esm/application/react/templates/src/relay/__generated__/ProductListQuery.graphql.ts +272 -0
- package/dist/esm/application/react/templates/src/relay/environment.tests.ts +87 -0
- package/dist/esm/application/react/templates/src/relay/environment.ts +119 -0
- package/dist/esm/application/react/templates/src/relay/schema.graphql +111 -0
- package/dist/esm/application/react/templates/src/relay/schema.tests.ts +137 -0
- package/dist/esm/application/react/templates/src/relay/schema.ts +205 -0
- package/{src → dist/esm}/application/react/templates/src/routes.tsx.ejs +10 -0
- package/{src/application/react/templates/src/server/entry.tsx → dist/esm/application/react/templates/src/server/entry.tsx.ejs} +36 -0
- package/{src → dist/esm}/application/react/templates/src/sitemap/getSitemapItems.ts.ejs +3 -0
- package/{src/application/react/templates/tsconfig.json → dist/esm/application/react/templates/tsconfig.json.ejs} +3 -0
- package/dist/esm/application/react/templates/vite.config.ts.ejs +92 -0
- package/dist/esm/application/react/templates/vitest.setup.ts.ejs +22 -0
- package/dist/esm/domain/index.js +89 -0
- package/dist/esm/domain/index.js.map +1 -0
- package/{src/index.ts → dist/esm/index.js} +6 -8
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/route/index.js +115 -0
- package/dist/esm/route/index.js.map +1 -0
- package/dist/esm/route/insertRoute.js +178 -0
- package/dist/esm/route/insertRoute.js.map +1 -0
- package/dist/esm/shared/casing.js +15 -0
- package/dist/esm/shared/casing.js.map +1 -0
- package/dist/esm/shared/packageManager.js +38 -0
- package/dist/esm/shared/packageManager.js.map +1 -0
- package/dist/esm/shared/versions.js +88 -0
- package/dist/esm/shared/versions.js.map +1 -0
- package/dist/esm/wrapper/index.js +72 -0
- package/dist/esm/wrapper/index.js.map +1 -0
- package/dist/types/application/react/index.d.ts +12 -0
- package/dist/types/application/react/index.d.ts.map +1 -0
- package/dist/types/domain/index.d.ts +7 -0
- package/dist/types/domain/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/route/index.d.ts +7 -0
- package/dist/types/route/index.d.ts.map +1 -0
- package/dist/types/route/insertRoute.d.ts +34 -0
- package/dist/types/route/insertRoute.d.ts.map +1 -0
- package/{src/shared/casing.ts → dist/types/shared/casing.d.ts} +2 -7
- package/dist/types/shared/casing.d.ts.map +1 -0
- package/dist/types/shared/packageManager.d.ts +19 -0
- package/dist/types/shared/packageManager.d.ts.map +1 -0
- package/dist/types/shared/versions.d.ts +15 -0
- package/dist/types/shared/versions.d.ts.map +1 -0
- package/dist/types/wrapper/index.d.ts +7 -0
- package/dist/types/wrapper/index.d.ts.map +1 -0
- package/package.json +17 -15
- package/src/application/react/index.ts +0 -294
- package/src/application/react/templates/.storybook/main.ts +0 -5
- package/src/application/react/templates/biome.json.ejs +0 -6
- package/src/application/react/templates/vite.config.ts +0 -45
- package/src/application/react/templates/vitest.setup.ts +0 -9
- package/src/domain/index.ts +0 -119
- package/src/index.test.ts +0 -398
- package/src/route/index.ts +0 -154
- package/src/route/insertRoute.test.ts +0 -98
- package/src/route/insertRoute.ts +0 -236
- package/src/shared/versions.ts +0 -48
- package/src/wrapper/index.ts +0 -100
- /package/{src → dist/esm}/application/react/templates/.storybook/decorators/index.ts +0 -0
- /package/{src → dist/esm}/application/react/templates/.storybook/decorators/withRouter.tsx +0 -0
- /package/{src → dist/esm}/application/react/templates/.storybook/preview.ts +0 -0
- /package/{src → dist/esm}/application/react/templates/index.html.ejs +0 -0
- /package/{src → dist/esm}/application/react/templates/public/.gitkeep +0 -0
- /package/{src → dist/esm}/application/react/templates/public/robots.txt +0 -0
- /package/{src → dist/esm}/application/react/templates/src/assets/.gitkeep +0 -0
- /package/{src → dist/esm}/application/react/templates/src/domains/account/AccountPage.tsx +0 -0
- /package/{src → dist/esm}/application/react/templates/src/domains/account/LoginPage.tsx +0 -0
- /package/{src → dist/esm}/application/react/templates/src/domains/account/routes.ts +0 -0
- /package/{src → dist/esm}/application/react/templates/src/domains/contact/ContactPage.tsx +0 -0
- /package/{src → dist/esm}/application/react/templates/src/domains/contact/routes.ts +0 -0
- /package/{src → dist/esm}/application/react/templates/src/domains/marketing/GuidePage.tsx +0 -0
- /package/{src → dist/esm}/application/react/templates/src/domains/marketing/HomePage.tsx +0 -0
- /package/{src → dist/esm}/application/react/templates/src/domains/marketing/routes.ts +0 -0
- /package/{src → dist/esm}/application/react/templates/src/lib/ExampleComponent/ExampleComponent.stories.tsx +0 -0
- /package/{src → dist/esm}/application/react/templates/src/lib/ExampleComponent/ExampleComponent.tests.tsx +0 -0
- /package/{src → dist/esm}/application/react/templates/src/lib/ExampleComponent/ExampleComponent.tsx +0 -0
- /package/{src → dist/esm}/application/react/templates/src/lib/ExampleComponent/index.ts +0 -0
- /package/{src → dist/esm}/application/react/templates/src/lib/ExampleComponent/styles.css +0 -0
- /package/{src → dist/esm}/application/react/templates/src/lib/ExampleComponent/types.ts +0 -0
- /package/{src → dist/esm}/application/react/templates/src/lib/LazyComponent/LazyComponent.stories.tsx +0 -0
- /package/{src → dist/esm}/application/react/templates/src/lib/LazyComponent/LazyComponent.tsx +0 -0
- /package/{src → dist/esm}/application/react/templates/src/lib/LazyComponent/index.ts +0 -0
- /package/{src → dist/esm}/application/react/templates/src/lib/Navigation/index.ts +0 -0
- /package/{src → dist/esm}/application/react/templates/src/lib/ThemeSelector/ThemeSelector.tsx +0 -0
- /package/{src → dist/esm}/application/react/templates/src/lib/ThemeSelector/index.ts +0 -0
- /package/{src → dist/esm}/application/react/templates/src/server/preview.bun.ts +0 -0
- /package/{src → dist/esm}/application/react/templates/src/server/preview.express.ts +0 -0
- /package/{src → dist/esm}/application/react/templates/src/server/renderer.tsx +0 -0
- /package/{src → dist/esm}/application/react/templates/src/server/server.bun.ts +0 -0
- /package/{src → dist/esm}/application/react/templates/src/server/server.express.ts +0 -0
- /package/{src → dist/esm}/application/react/templates/src/sitemap/renderer.ts +0 -0
- /package/{src → dist/esm}/application/react/templates/src/styles/app.css +0 -0
- /package/{src → dist/esm}/application/react/templates/src/styles/index.css.ejs +0 -0
- /package/{src → dist/esm}/application/react/templates/src/vite-env.d.ts +0 -0
- /package/{src → dist/esm}/application/react/templates/test/e2e/serverHarness.ts +0 -0
- /package/{src → dist/esm}/application/react/templates/test/e2e/servers.e2e.ts +0 -0
- /package/{src → dist/esm}/application/react/templates/vitest.config.ts +0 -0
- /package/{src → dist/esm}/application/react/templates/vitest.e2e.config.ts +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
|
166
|
+
|
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ Scaffolds a complete React application with SSR, routing, Storybook, and two sta
|
|
|
11
11
|
```bash
|
|
12
12
|
summon application/react my-app
|
|
13
13
|
summon application/react --forms my-app
|
|
14
|
+
summon application/react --relay my-app
|
|
14
15
|
```
|
|
15
16
|
|
|
16
17
|
Produces:
|
|
@@ -23,6 +24,7 @@ my-app/
|
|
|
23
24
|
│ └── decorators/
|
|
24
25
|
│ ├── withRouter.tsx # Hash-based router decorator
|
|
25
26
|
│ └── index.ts
|
|
27
|
+
├── patches/ # bun dependency patches (--relay only)
|
|
26
28
|
├── src/
|
|
27
29
|
│ ├── client/entry.tsx # Client hydration
|
|
28
30
|
│ ├── server/
|
|
@@ -33,24 +35,73 @@ my-app/
|
|
|
33
35
|
│ ├── domains/
|
|
34
36
|
│ │ ├── marketing/ # HomePage, GuidePage, routes
|
|
35
37
|
│ │ ├── account/ # AccountPage, LoginPage, routes
|
|
36
|
-
│ │
|
|
38
|
+
│ │ ├── contact/ # ContactPage, routes (--forms only)
|
|
39
|
+
│ │ └── catalog/ # CatalogPage, ProductList, ProductCard (--relay only)
|
|
37
40
|
│ ├── lib/
|
|
38
41
|
│ │ ├── Navigation/
|
|
39
42
|
│ │ ├── ThemeSelector/
|
|
40
43
|
│ │ ├── ExampleComponent/
|
|
41
|
-
│ │
|
|
44
|
+
│ │ ├── LazyComponent/
|
|
45
|
+
│ │ └── ClientOnly/ # SSR query guard (--relay only)
|
|
46
|
+
│ ├── relay/ # Environment factory, mock schema, __generated__ (--relay only)
|
|
42
47
|
│ ├── styles/
|
|
43
48
|
│ ├── routes.tsx
|
|
44
49
|
│ └── vite-env.d.ts
|
|
45
50
|
├── biome.json
|
|
46
51
|
├── index.html
|
|
47
52
|
├── package.json
|
|
53
|
+
├── relay.config.json # (--relay only)
|
|
48
54
|
├── tsconfig.json
|
|
49
55
|
└── vite.config.ts
|
|
50
56
|
```
|
|
51
57
|
|
|
52
58
|
The `--forms` flag adds the contact domain with form components and wires `contactRoutes` into `routes.tsx`.
|
|
53
59
|
|
|
60
|
+
#### `--relay`: Relay (GraphQL) data layer
|
|
61
|
+
|
|
62
|
+
The `--relay` flag (off by default) mirrors the boilerplate's Relay data layer:
|
|
63
|
+
|
|
64
|
+
- **`src/relay/`** — a `createEnvironment` factory built on
|
|
65
|
+
`relay-runtime-network`'s middleware pipeline: by default a local executor
|
|
66
|
+
resolves every operation in-process against the executable mock catalog
|
|
67
|
+
schema (`schema.graphql` + `schema.ts`), so the app runs with zero backend;
|
|
68
|
+
setting `VITE_GRAPHQL_URL` (or passing `graphqlUrl`) switches to posting
|
|
69
|
+
operations to a real endpoint. The relay-compiler artifacts in
|
|
70
|
+
`src/relay/__generated__/` are committed — deterministic outputs of the
|
|
71
|
+
committed schema — and regenerated with `bun run relay` (or `relay:watch`)
|
|
72
|
+
after any schema or `graphql` tag edit.
|
|
73
|
+
- **`src/domains/catalog/`** — an example domain wiring `useLazyLoadQuery`
|
|
74
|
+
(`ProductList`) and a colocated `useFragment` (`ProductCard`) behind the
|
|
75
|
+
canonical Suspense + `ErrorBoundary` pairing, with Storybook stories mocked
|
|
76
|
+
via `@canonical/storybook-addon-relay` (`parameters.relay` mock resolvers +
|
|
77
|
+
play tests) and component tests against both the local schema and
|
|
78
|
+
`relay-test-utils`.
|
|
79
|
+
- **`src/lib/ClientOnly/`** — keeps queries off the server render path until
|
|
80
|
+
SSR data serialization/hydration is supported: the server streams the
|
|
81
|
+
fallback and the browser fetches after hydration. It is emitted only with
|
|
82
|
+
`--relay` because the catalog page is its only consumer today.
|
|
83
|
+
- **`patches/` + `"patchedDependencies"`** — a generated app is standalone and
|
|
84
|
+
cannot inherit the monorepo's `patches/`, so the two bun patches ship with
|
|
85
|
+
the scaffold: `react-relay@18.2.0` (cjs-module-lexer export hints so named
|
|
86
|
+
imports survive Node SSR externalisation) and `relay-runtime-network@0.1.0`
|
|
87
|
+
(fixes its broken package `imports` map — temporary until the fixed
|
|
88
|
+
upstream release lands, advl/lit-relay#32, after which the patch and its
|
|
89
|
+
`patchedDependencies` entry can be dropped).
|
|
90
|
+
- **Wiring** — `RelayEnvironmentProvider` in both entries (one environment
|
|
91
|
+
per browser session on the client, a fresh one per request on the server),
|
|
92
|
+
`vite-plugin-relay-lite` in `vite.config.ts` (`codegen: false`; artifacts
|
|
93
|
+
are committed), the `relay` / `relay:watch` scripts, catalog route, nav
|
|
94
|
+
link, and sitemap entries, and the relay addon via `extraAddons` in
|
|
95
|
+
`.storybook/main.ts`.
|
|
96
|
+
|
|
97
|
+
**Known caveats — not yet on npm.** `@canonical/storybook-addon-relay` and
|
|
98
|
+
the fixed `relay-runtime-network` release have not been published yet. A
|
|
99
|
+
scaffolded app's install currently fails to resolve
|
|
100
|
+
`@canonical/storybook-addon-relay` (404 from the registry), and the
|
|
101
|
+
`relay-runtime-network` patch remains necessary until the fixed upstream
|
|
102
|
+
release lands. The scaffold encodes the intended end state; a `--relay` app's
|
|
103
|
+
install will only fully resolve once those packages publish.
|
|
104
|
+
|
|
54
105
|
### `summon domain <name>`
|
|
55
106
|
|
|
56
107
|
Creates a domain folder under `src/domains/` with a `MainPage` and a `routes.ts` barrel.
|
|
@@ -145,12 +196,23 @@ src/
|
|
|
145
196
|
│ │ ├── AccountPage.tsx
|
|
146
197
|
│ │ ├── LoginPage.tsx
|
|
147
198
|
│ │ └── routes.ts
|
|
148
|
-
│
|
|
149
|
-
│
|
|
199
|
+
│ ├── contact/ # When --forms is enabled
|
|
200
|
+
│ │ ├── ContactPage.tsx
|
|
201
|
+
│ │ └── routes.ts
|
|
202
|
+
│ └── catalog/ # When --relay is enabled
|
|
203
|
+
│ ├── CatalogPage.tsx
|
|
204
|
+
│ ├── ProductList.tsx
|
|
205
|
+
│ ├── ProductCard.tsx
|
|
206
|
+
│ ├── ErrorBoundary.tsx
|
|
150
207
|
│ └── routes.ts
|
|
151
208
|
├── lib/ # Shared components
|
|
152
209
|
│ ├── Navigation/
|
|
153
210
|
│ └── SidebarLayout/
|
|
211
|
+
├── relay/ # When --relay is enabled
|
|
212
|
+
│ ├── environment.ts # Environment factory (local executor / HTTP)
|
|
213
|
+
│ ├── schema.graphql # Mock SDL (relay-compiler validates against it)
|
|
214
|
+
│ ├── schema.ts # Executable mock schema (graphql-js)
|
|
215
|
+
│ └── __generated__/ # Committed relay-compiler artifacts
|
|
154
216
|
├── styles/ # CSS
|
|
155
217
|
└── routes.tsx # Root route map, middleware, type registration
|
|
156
218
|
```
|
|
@@ -244,15 +306,15 @@ This enables typed `<Link to="invoices">`, `router.navigate("invoices")`, and `r
|
|
|
244
306
|
|
|
245
307
|
Design decisions about the generated output that are not yet settled:
|
|
246
308
|
|
|
247
|
-
- **Pinned pragma version is
|
|
248
|
-
workspace packages (`react-ds-global`, `router-core`, `styles`, …) at
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
309
|
+
- **Pinned pragma version is fetched at summon time.** Generated apps pin the pragma
|
|
310
|
+
workspace packages (`react-ds-global`, `router-core`, `styles`, …) at `^<latest>`, where
|
|
311
|
+
`<latest>` is queried from the npm registry when the app is scaffolded
|
|
312
|
+
(`resolvePragmaVersion` in `src/shared/versions.ts`, via `npm view`). If the registry is
|
|
313
|
+
unreachable it falls back to `^<installed generator version>` — safe because
|
|
314
|
+
`@canonical/summon-application` is released in lockstep with those packages. Note
|
|
315
|
+
`@canonical/design-tokens` is versioned separately and is *not* covered here (it arrives
|
|
316
|
+
transitively via `@canonical/styles`). **Open:** whether to cache the lookup or let users
|
|
317
|
+
pin explicitly for reproducible offline scaffolding.
|
|
256
318
|
|
|
257
319
|
- **Two static-asset folders (`src/assets/` + `public/`).** The generated app ships both,
|
|
258
320
|
and `.storybook/main.ts` lists `staticDirs: ["../src/assets", "../public"]` to match the
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { template, withHelpers } from "@canonical/summon-core";
|
|
4
|
+
import { copyFile, exec, exists, flatMap, info, pure, sequence_, warn, when, } from "@canonical/task";
|
|
5
|
+
import { pickPackageManager } from "../../shared/packageManager.js";
|
|
6
|
+
import { resolvePragmaVersion } from "../../shared/versions.js";
|
|
7
|
+
const prompts = [
|
|
8
|
+
{
|
|
9
|
+
name: "appPath",
|
|
10
|
+
type: "text",
|
|
11
|
+
message: "Application directory name:",
|
|
12
|
+
default: "my-app",
|
|
13
|
+
positional: true,
|
|
14
|
+
group: "Application",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: "ssr",
|
|
18
|
+
type: "confirm",
|
|
19
|
+
message: "Include SSR?",
|
|
20
|
+
default: true,
|
|
21
|
+
group: "Application",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "router",
|
|
25
|
+
type: "confirm",
|
|
26
|
+
message: "Include router?",
|
|
27
|
+
default: true,
|
|
28
|
+
group: "Application",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: "forms",
|
|
32
|
+
type: "confirm",
|
|
33
|
+
message: "Include form components?",
|
|
34
|
+
default: true,
|
|
35
|
+
group: "Application",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "relay",
|
|
39
|
+
type: "confirm",
|
|
40
|
+
message: "Include a Relay (GraphQL) data layer with a local mock schema?",
|
|
41
|
+
default: false,
|
|
42
|
+
group: "Application",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "runInstall",
|
|
46
|
+
type: "confirm",
|
|
47
|
+
message: "Install dependencies now?",
|
|
48
|
+
default: true,
|
|
49
|
+
group: "Application",
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
53
|
+
const templatesDir = path.join(__dirname, "templates");
|
|
54
|
+
/** Resolve a path inside the templates directory. */
|
|
55
|
+
const src = (templatePath) => path.join(templatesDir, templatePath);
|
|
56
|
+
export const generator = {
|
|
57
|
+
meta: {
|
|
58
|
+
name: "application/react",
|
|
59
|
+
displayName: "@canonical/summon-application:application/react",
|
|
60
|
+
description: "Scaffold a complete React application with SSR and routing",
|
|
61
|
+
version: "0.1.0",
|
|
62
|
+
help: `Creates a full React application with:
|
|
63
|
+
- Vite build + dev server
|
|
64
|
+
- Server-side rendering (Express + Bun dev servers)
|
|
65
|
+
- Routing with @canonical/router-core
|
|
66
|
+
- Head management with @canonical/react-head
|
|
67
|
+
- Two domains (marketing + account) with pages
|
|
68
|
+
- Contact domain with form components (when --forms is enabled)
|
|
69
|
+
- Relay (GraphQL) data layer with a local mock schema, catalog example
|
|
70
|
+
domain, and Storybook mocking (when --relay is enabled)
|
|
71
|
+
- Navigation, ThemeSelector, ExampleComponent
|
|
72
|
+
- Storybook with router decorator
|
|
73
|
+
- Biome + TypeScript configuration
|
|
74
|
+
|
|
75
|
+
Requires both --ssr and --router flags.`,
|
|
76
|
+
examples: [
|
|
77
|
+
"summon application/react my-app",
|
|
78
|
+
"summon application/react --forms my-app",
|
|
79
|
+
"summon application/react --relay my-app",
|
|
80
|
+
"summon application/react --ssr --router --forms --relay my-app",
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
prompts,
|
|
84
|
+
generate: (answers) => {
|
|
85
|
+
if (!answers.ssr || !answers.router) {
|
|
86
|
+
throw new Error("The application/react generator requires both --ssr and --router. " +
|
|
87
|
+
"Standalone SPA mode is not supported.");
|
|
88
|
+
}
|
|
89
|
+
// The app path is a directory path, not a route path — keep it as given
|
|
90
|
+
// (absolute or relative), only trimming surrounding whitespace and any
|
|
91
|
+
// trailing slash.
|
|
92
|
+
const appPath = (answers.appPath || "my-app").trim().replace(/\/+$/, "") || "my-app";
|
|
93
|
+
// The package name is the final path segment. For "." / "" / "/" (scaffold
|
|
94
|
+
// into the current dir) basename gives "."/"" — resolve against the real
|
|
95
|
+
// directory so the name is the actual folder name. Then slugify to an
|
|
96
|
+
// npm-safe form (lowercase, safe chars).
|
|
97
|
+
const rawName = path.basename(path.resolve(appPath));
|
|
98
|
+
const name = rawName
|
|
99
|
+
.toLowerCase()
|
|
100
|
+
.replace(/[^a-z0-9._-]+/g, "-")
|
|
101
|
+
.replace(/^[._-]+|[._-]+$/g, "");
|
|
102
|
+
if (!name) {
|
|
103
|
+
throw new Error(`Could not derive a valid application name from path "${appPath}". ` +
|
|
104
|
+
"Pass an explicit directory name (lowercase letters/digits).");
|
|
105
|
+
}
|
|
106
|
+
const dest = (...segments) => path.join(appPath, ...segments);
|
|
107
|
+
const copy = (filePath) => copyFile(src(filePath), dest(filePath));
|
|
108
|
+
// Resolve the @canonical/* version range first (latest from npm, with an
|
|
109
|
+
// offline fallback), then build the rest of the pipeline with it baked into
|
|
110
|
+
// the template vars.
|
|
111
|
+
return flatMap(resolvePragmaVersion(), (pragmaVersion) => {
|
|
112
|
+
const vars = withHelpers({
|
|
113
|
+
name,
|
|
114
|
+
forms: answers.forms,
|
|
115
|
+
relay: answers.relay,
|
|
116
|
+
pragmaVersion,
|
|
117
|
+
});
|
|
118
|
+
// Detect an available package manager for both the (optional) install
|
|
119
|
+
// step and the closing message, so the suggested commands reflect what's
|
|
120
|
+
// actually on the machine.
|
|
121
|
+
const pm = pickPackageManager();
|
|
122
|
+
// Build the install task only when a package manager was actually found —
|
|
123
|
+
// this narrows `pm` to non-null, so the install command never invents a
|
|
124
|
+
// manager. `null` when we won't (or can't) install.
|
|
125
|
+
const installTask = answers.runInstall && pm !== null
|
|
126
|
+
? sequence_([
|
|
127
|
+
info(`Installing dependencies with ${pm}...`),
|
|
128
|
+
exec(pm, ["install"], appPath),
|
|
129
|
+
])
|
|
130
|
+
: null;
|
|
131
|
+
// The closing command only names a package manager we actually found; if
|
|
132
|
+
// none was detected we don't invent one (previously this suggested `bun`
|
|
133
|
+
// even on a machine without bun), and instead point the user at the
|
|
134
|
+
// package-manager step.
|
|
135
|
+
const finalMessage = installTask
|
|
136
|
+
? `Application "${appPath}" created. Run \`cd ${appPath} && ${pm} run dev\` to start.`
|
|
137
|
+
: pm
|
|
138
|
+
? `Application "${appPath}" created. Run \`cd ${appPath} && ${pm} install && ${pm} run dev\` to start.`
|
|
139
|
+
: `Application "${appPath}" created. Install a package manager (bun, pnpm, npm, or yarn), then run \`cd ${appPath} && <pm> install && <pm> run dev\` to start.`;
|
|
140
|
+
return sequence_([
|
|
141
|
+
// Warn (don't block) if the destination already exists — scaffolding
|
|
142
|
+
// will overwrite files in place.
|
|
143
|
+
flatMap(exists(appPath), (present) => when(present, warn(`"${appPath}" already exists — existing files may be overwritten.`))),
|
|
144
|
+
info(`Scaffolding React application in "${appPath}"...`),
|
|
145
|
+
// EJS templates (files needing interpolation)
|
|
146
|
+
template({
|
|
147
|
+
source: src("package.json.ejs"),
|
|
148
|
+
dest: dest("package.json"),
|
|
149
|
+
vars,
|
|
150
|
+
}),
|
|
151
|
+
template({
|
|
152
|
+
source: src("README.md.ejs"),
|
|
153
|
+
dest: dest("README.md"),
|
|
154
|
+
vars,
|
|
155
|
+
}),
|
|
156
|
+
template({
|
|
157
|
+
source: src("biome.json.ejs"),
|
|
158
|
+
dest: dest("biome.json"),
|
|
159
|
+
vars,
|
|
160
|
+
}),
|
|
161
|
+
// Root config
|
|
162
|
+
// tsconfig (EJS — #relay path alias only when --relay)
|
|
163
|
+
template({
|
|
164
|
+
source: src("tsconfig.json.ejs"),
|
|
165
|
+
dest: dest("tsconfig.json"),
|
|
166
|
+
vars,
|
|
167
|
+
}),
|
|
168
|
+
// vite config (EJS — vite-plugin-relay-lite only when --relay)
|
|
169
|
+
template({
|
|
170
|
+
source: src("vite.config.ts.ejs"),
|
|
171
|
+
dest: dest("vite.config.ts"),
|
|
172
|
+
vars,
|
|
173
|
+
}),
|
|
174
|
+
copy("vitest.config.ts"),
|
|
175
|
+
// vitest setup (EJS — relay-test-utils' jest→vi alias only when --relay)
|
|
176
|
+
template({
|
|
177
|
+
source: src("vitest.setup.ts.ejs"),
|
|
178
|
+
dest: dest("vitest.setup.ts"),
|
|
179
|
+
vars,
|
|
180
|
+
}),
|
|
181
|
+
copy("vitest.e2e.config.ts"),
|
|
182
|
+
// Relay compiler config (validates queries against the mock SDL)
|
|
183
|
+
when(answers.relay, copy("relay.config.json")),
|
|
184
|
+
// index.html (EJS — <title> uses the app name)
|
|
185
|
+
template({
|
|
186
|
+
source: src("index.html.ejs"),
|
|
187
|
+
dest: dest("index.html"),
|
|
188
|
+
vars,
|
|
189
|
+
}),
|
|
190
|
+
// The template is stored as `gitignore` (no leading dot): npm strips a
|
|
191
|
+
// literal `.gitignore` from published tarballs, so we ship it dotless and
|
|
192
|
+
// restore the dot at write time.
|
|
193
|
+
copyFile(src("gitignore"), dest(".gitignore")),
|
|
194
|
+
// The app's browser floor, read by vite.config.ts to derive Lightning
|
|
195
|
+
// CSS targets. Unlike `.gitignore` above, npm does not strip
|
|
196
|
+
// `.browserslistrc` from tarballs, so the template keeps its dot.
|
|
197
|
+
copy(".browserslistrc"),
|
|
198
|
+
// E2e tests (the 2×3 server matrix + its spawn/teardown harness)
|
|
199
|
+
copy("test/e2e/serverHarness.ts"),
|
|
200
|
+
copy("test/e2e/servers.e2e.ts"),
|
|
201
|
+
// Styles
|
|
202
|
+
// styles (EJS — form stylesheet imported only when --forms)
|
|
203
|
+
template({
|
|
204
|
+
source: src("src/styles/index.css.ejs"),
|
|
205
|
+
dest: dest("src/styles/index.css"),
|
|
206
|
+
vars,
|
|
207
|
+
}),
|
|
208
|
+
copy("src/styles/app.css"),
|
|
209
|
+
// Client (EJS — RelayEnvironmentProvider only when --relay)
|
|
210
|
+
template({
|
|
211
|
+
source: src("src/client/entry.tsx.ejs"),
|
|
212
|
+
dest: dest("src/client/entry.tsx"),
|
|
213
|
+
vars,
|
|
214
|
+
}),
|
|
215
|
+
// Server — dev (Vite + HMR) and preview (compiled) servers each route
|
|
216
|
+
// between the app + sitemap renderers; the renderers stay routing-agnostic.
|
|
217
|
+
// Server entry (EJS — a per-request RelayEnvironmentProvider only when --relay)
|
|
218
|
+
template({
|
|
219
|
+
source: src("src/server/entry.tsx.ejs"),
|
|
220
|
+
dest: dest("src/server/entry.tsx"),
|
|
221
|
+
vars,
|
|
222
|
+
}),
|
|
223
|
+
copy("src/server/renderer.tsx"),
|
|
224
|
+
copy("src/server/server.express.ts"),
|
|
225
|
+
copy("src/server/server.bun.ts"),
|
|
226
|
+
copy("src/server/preview.express.ts"),
|
|
227
|
+
copy("src/server/preview.bun.ts"),
|
|
228
|
+
// Sitemap (rendered route at /sitemap.xml)
|
|
229
|
+
copy("src/sitemap/renderer.ts"),
|
|
230
|
+
// sitemap getters (EJS — /contact entry only when --forms, /catalog
|
|
231
|
+
// entry only when --relay)
|
|
232
|
+
template({
|
|
233
|
+
source: src("src/sitemap/getSitemapItems.ts.ejs"),
|
|
234
|
+
dest: dest("src/sitemap/getSitemapItems.ts"),
|
|
235
|
+
vars,
|
|
236
|
+
}),
|
|
237
|
+
// Domain: marketing
|
|
238
|
+
copy("src/domains/marketing/HomePage.tsx"),
|
|
239
|
+
copy("src/domains/marketing/GuidePage.tsx"),
|
|
240
|
+
copy("src/domains/marketing/routes.ts"),
|
|
241
|
+
// Domain: account
|
|
242
|
+
copy("src/domains/account/AccountPage.tsx"),
|
|
243
|
+
copy("src/domains/account/LoginPage.tsx"),
|
|
244
|
+
copy("src/domains/account/routes.ts"),
|
|
245
|
+
// Domain: contact (when --forms is enabled)
|
|
246
|
+
when(answers.forms, copy("src/domains/contact/ContactPage.tsx")),
|
|
247
|
+
when(answers.forms, copy("src/domains/contact/routes.ts")),
|
|
248
|
+
// Relay data layer (when --relay is enabled): environment factory +
|
|
249
|
+
// executable mock schema, the catalog example domain, and the
|
|
250
|
+
// ClientOnly SSR guard (whose only consumer today is the catalog page).
|
|
251
|
+
when(answers.relay, copy("src/relay/schema.graphql")),
|
|
252
|
+
when(answers.relay, copy("src/relay/schema.ts")),
|
|
253
|
+
when(answers.relay, copy("src/relay/schema.tests.ts")),
|
|
254
|
+
when(answers.relay, copy("src/relay/environment.ts")),
|
|
255
|
+
when(answers.relay, copy("src/relay/environment.tests.ts")),
|
|
256
|
+
// Committed relay-compiler artifacts — deterministic outputs of the
|
|
257
|
+
// committed schema + the catalog queries; `bun run relay` regenerates
|
|
258
|
+
// them in the scaffolded app after any schema or graphql-tag edit.
|
|
259
|
+
when(answers.relay, copy("src/relay/__generated__/ProductCard_product.graphql.ts")),
|
|
260
|
+
when(answers.relay, copy("src/relay/__generated__/ProductListQuery.graphql.ts")),
|
|
261
|
+
// Domain: catalog (when --relay is enabled)
|
|
262
|
+
when(answers.relay, copy("src/domains/catalog/CatalogPage.tsx")),
|
|
263
|
+
when(answers.relay, copy("src/domains/catalog/ProductList.tsx")),
|
|
264
|
+
when(answers.relay, copy("src/domains/catalog/ProductList.stories.tsx")),
|
|
265
|
+
when(answers.relay, copy("src/domains/catalog/ProductList.tests.tsx")),
|
|
266
|
+
when(answers.relay, copy("src/domains/catalog/ProductCard.tsx")),
|
|
267
|
+
when(answers.relay, copy("src/domains/catalog/ErrorBoundary.tsx")),
|
|
268
|
+
when(answers.relay, copy("src/domains/catalog/ErrorBoundary.tests.tsx")),
|
|
269
|
+
when(answers.relay, copy("src/domains/catalog/routes.ts")),
|
|
270
|
+
// Standalone dependency patches (when --relay is enabled): a generated
|
|
271
|
+
// app cannot inherit the monorepo's patches/, so they ship with the
|
|
272
|
+
// scaffold and are applied via "patchedDependencies" in package.json.
|
|
273
|
+
// react-relay: cjs-module-lexer export hints so named imports survive
|
|
274
|
+
// Node SSR externalisation.
|
|
275
|
+
when(answers.relay, copy("patches/react-relay@18.2.0.patch")),
|
|
276
|
+
// relay-runtime-network: fixes the broken package `imports` map.
|
|
277
|
+
// Temporary until the fixed upstream release lands (advl/lit-relay#32);
|
|
278
|
+
// then this patch and its patchedDependencies entry can be dropped.
|
|
279
|
+
when(answers.relay, copy("patches/relay-runtime-network@0.1.0.patch")),
|
|
280
|
+
// Routes (EJS — conditionally includes contact + catalog domains)
|
|
281
|
+
template({
|
|
282
|
+
source: src("src/routes.tsx.ejs"),
|
|
283
|
+
dest: dest("src/routes.tsx"),
|
|
284
|
+
vars,
|
|
285
|
+
}),
|
|
286
|
+
// Lib: Navigation (EJS — contact link only when --forms, catalog
|
|
287
|
+
// link only when --relay)
|
|
288
|
+
template({
|
|
289
|
+
source: src("src/lib/Navigation/Navigation.tsx.ejs"),
|
|
290
|
+
dest: dest("src/lib/Navigation/Navigation.tsx"),
|
|
291
|
+
vars,
|
|
292
|
+
}),
|
|
293
|
+
copy("src/lib/Navigation/index.ts"),
|
|
294
|
+
// Lib: ThemeSelector
|
|
295
|
+
copy("src/lib/ThemeSelector/ThemeSelector.tsx"),
|
|
296
|
+
copy("src/lib/ThemeSelector/index.ts"),
|
|
297
|
+
// Lib: ExampleComponent
|
|
298
|
+
copy("src/lib/ExampleComponent/ExampleComponent.tsx"),
|
|
299
|
+
copy("src/lib/ExampleComponent/ExampleComponent.stories.tsx"),
|
|
300
|
+
copy("src/lib/ExampleComponent/ExampleComponent.tests.tsx"),
|
|
301
|
+
copy("src/lib/ExampleComponent/index.ts"),
|
|
302
|
+
copy("src/lib/ExampleComponent/types.ts"),
|
|
303
|
+
copy("src/lib/ExampleComponent/styles.css"),
|
|
304
|
+
// Lib: LazyComponent
|
|
305
|
+
copy("src/lib/LazyComponent/LazyComponent.tsx"),
|
|
306
|
+
copy("src/lib/LazyComponent/LazyComponent.stories.tsx"),
|
|
307
|
+
copy("src/lib/LazyComponent/index.ts"),
|
|
308
|
+
// Lib: ClientOnly (when --relay is enabled — the catalog page is its
|
|
309
|
+
// only consumer, keeping Relay queries off the server render until
|
|
310
|
+
// SSR data serialization/hydration is supported)
|
|
311
|
+
when(answers.relay, copy("src/lib/ClientOnly/ClientOnly.tsx")),
|
|
312
|
+
when(answers.relay, copy("src/lib/ClientOnly/ClientOnly.tests.tsx")),
|
|
313
|
+
when(answers.relay, copy("src/lib/ClientOnly/index.ts")),
|
|
314
|
+
// Lib barrel (EJS — ClientOnly export only when --relay)
|
|
315
|
+
template({
|
|
316
|
+
source: src("src/lib/index.ts.ejs"),
|
|
317
|
+
dest: dest("src/lib/index.ts"),
|
|
318
|
+
vars,
|
|
319
|
+
}),
|
|
320
|
+
// Vite types
|
|
321
|
+
copy("src/vite-env.d.ts"),
|
|
322
|
+
// Storybook
|
|
323
|
+
// main config (EJS — the relay mocking addon only when --relay)
|
|
324
|
+
template({
|
|
325
|
+
source: src(".storybook/main.ts.ejs"),
|
|
326
|
+
dest: dest(".storybook/main.ts"),
|
|
327
|
+
vars,
|
|
328
|
+
}),
|
|
329
|
+
copy(".storybook/preview.ts"),
|
|
330
|
+
copy(".storybook/decorators/withRouter.tsx"),
|
|
331
|
+
copy(".storybook/decorators/index.ts"),
|
|
332
|
+
// Static asset dirs (kept by placeholder; both wired into Storybook staticDirs)
|
|
333
|
+
copy("src/assets/.gitkeep"),
|
|
334
|
+
copy("public/.gitkeep"),
|
|
335
|
+
copy("public/robots.txt"),
|
|
336
|
+
// Install dependencies with the detected package manager, or a no-op
|
|
337
|
+
// when none was found / the user declined. Built above where `pm` is
|
|
338
|
+
// narrowed to non-null, so the install command never invents a manager;
|
|
339
|
+
// the scaffold completes and the closing message says what to run.
|
|
340
|
+
installTask ?? pure(undefined),
|
|
341
|
+
info(finalMessage),
|
|
342
|
+
]);
|
|
343
|
+
});
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
export default generator;
|
|
347
|
+
//# sourceMappingURL=index.js.map
|