@viglet/create-shio-app 2026.3.2
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 +201 -0
- package/README.md +98 -0
- package/package.json +59 -0
- package/src/emit-guard.mjs +98 -0
- package/src/emit.mjs +292 -0
- package/src/index.mjs +88 -0
- package/src/published.mjs +67 -0
- package/src/scaffold.mjs +185 -0
- package/template/.env.example +15 -0
- package/template/README.md +108 -0
- package/template/app/[...slug]/page.tsx +110 -0
- package/template/app/api/preview/route.ts +65 -0
- package/template/app/api/revalidate/route.ts +96 -0
- package/template/app/layout.tsx +25 -0
- package/template/app/page.tsx +72 -0
- package/template/gitignore +26 -0
- package/template/lib/shio.ts +70 -0
- package/template/next-env.d.ts +5 -0
- package/template/next.config.mjs +12 -0
- package/template/package.json +25 -0
- package/template/tsconfig.json +21 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# @viglet/create-shio-app
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@viglet/create-shio-app)
|
|
4
|
+
[](https://github.com/openviglet/shio/blob/HEAD/LICENSE)
|
|
5
|
+
[](https://shio.viglet.org/)
|
|
6
|
+
|
|
7
|
+
Scaffold a **Next.js (App Router)** site wired to the Content Delivery API of
|
|
8
|
+
**[Viglet Shio](https://shio.viglet.org/)**, the open source **headless CMS built
|
|
9
|
+
for coding agents**.
|
|
10
|
+
|
|
11
|
+
The flagship "JS dev, zero Java" starter — a JavaScript/TypeScript developer
|
|
12
|
+
builds a full site against Shio without ever touching the Java backend.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
Interactive:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm create @viglet/shio-app@latest
|
|
20
|
+
# or
|
|
21
|
+
npx @viglet/create-shio-app
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Non-interactive (CI / scripted):
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npx @viglet/create-shio-app my-site \
|
|
28
|
+
--url https://cms.example.com \
|
|
29
|
+
--site <site-id> \
|
|
30
|
+
--token <cda-token> \
|
|
31
|
+
--yes
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
| Flag | Maps to |
|
|
35
|
+
|---|---|
|
|
36
|
+
| `--url` | `SHIO_URL` |
|
|
37
|
+
| `--site` | `SHIO_SITE_ID` |
|
|
38
|
+
| `--token` | `SHIO_CDA_TOKEN` |
|
|
39
|
+
| `--yes`, `-y` | skip prompts (use defaults / flags) |
|
|
40
|
+
|
|
41
|
+
## What you get
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
my-site/
|
|
45
|
+
app/
|
|
46
|
+
layout.tsx
|
|
47
|
+
page.tsx # lists published posts (shio.query)
|
|
48
|
+
[...slug]/page.tsx # CDA path → post (shio.getPostByUrl) + SSG/ISR
|
|
49
|
+
lib/shio.ts # shared @viglet/shio-client instance
|
|
50
|
+
next.config.mjs
|
|
51
|
+
tsconfig.json
|
|
52
|
+
.env.local # filled from your answers/flags
|
|
53
|
+
.env.example
|
|
54
|
+
.gitignore
|
|
55
|
+
README.md
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The generated project depends on [`@viglet/shio-client`](https://www.npmjs.com/package/@viglet/shio-client)
|
|
59
|
+
and talks only to the stable CDA contract (`/api/v2/cda/**`).
|
|
60
|
+
|
|
61
|
+
## Next steps
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npx @viglet/shio types # generate a .d.ts so post.attrs.* autocompletes
|
|
65
|
+
npx @viglet/shio dev # types + dev server + model watch
|
|
66
|
+
npx @viglet/shio pull --content # the whole site as Markdown on disk
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Driving the CMS from [Claude Code](https://claude.com/claude-code)? Add the MCP
|
|
70
|
+
server and the agent gets the same surface:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
claude mcp add shio -- npx -y @viglet/shio mcp
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Develop this generator
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npm test # node:test — scaffolds into a temp dir and asserts the output
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Related packages
|
|
83
|
+
|
|
84
|
+
| Package | For |
|
|
85
|
+
|---|---|
|
|
86
|
+
| [`@viglet/shio`](https://www.npmjs.com/package/@viglet/shio) | The Shio CLI — content as files, type generation, and the MCP bridge |
|
|
87
|
+
| [`@viglet/shio-client`](https://www.npmjs.com/package/@viglet/shio-client) | Zero-dependency Content Delivery API client (what the scaffold uses) |
|
|
88
|
+
| [`@viglet/shio-react-sdk`](https://www.npmjs.com/package/@viglet/shio-react-sdk) | React hooks and render components |
|
|
89
|
+
| [`@viglet/shio-sections`](https://www.npmjs.com/package/@viglet/shio-sections) | The page-section vocabulary |
|
|
90
|
+
| [`@viglet/shio-model`](https://www.npmjs.com/package/@viglet/shio-model) | Author the content model as typed code |
|
|
91
|
+
| [`@viglet/shio-editor-cors`](https://www.npmjs.com/package/@viglet/shio-editor-cors) | Inline visual editing with the Universal Editor |
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
Apache-2.0 — [Viglet Shio](https://shio.viglet.org/) ·
|
|
96
|
+
[github.com/openviglet/shio](https://github.com/openviglet/shio) ·
|
|
97
|
+
[docs.viglet.org/shio](https://docs.viglet.org/shio/) ·
|
|
98
|
+
part of the [Viglet](https://www.viglet.org) open source family.
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@viglet/create-shio-app",
|
|
3
|
+
"version": "2026.3.2",
|
|
4
|
+
"description": "Scaffold a Next.js (App Router) site wired to the Shio CMS Content Delivery API. The flagship 'JS dev, zero Java' starter.",
|
|
5
|
+
"homepage": "https://shio.viglet.org/",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/openviglet/shio.git",
|
|
9
|
+
"directory": "create-shio-app"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/openviglet/shio/issues"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"bin": {
|
|
16
|
+
"create-shio-app": "src/index.mjs"
|
|
17
|
+
},
|
|
18
|
+
"exports": {
|
|
19
|
+
"./scaffold": "./src/scaffold.mjs",
|
|
20
|
+
"./published": "./src/published.mjs",
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"src",
|
|
25
|
+
"template"
|
|
26
|
+
],
|
|
27
|
+
"keywords": [
|
|
28
|
+
"shio",
|
|
29
|
+
"viglet",
|
|
30
|
+
"cms",
|
|
31
|
+
"headless-cms",
|
|
32
|
+
"content-management-system",
|
|
33
|
+
"agent",
|
|
34
|
+
"ai",
|
|
35
|
+
"mcp",
|
|
36
|
+
"model-context-protocol",
|
|
37
|
+
"claude-code",
|
|
38
|
+
"nextjs",
|
|
39
|
+
"starter",
|
|
40
|
+
"create",
|
|
41
|
+
"scaffold",
|
|
42
|
+
"react",
|
|
43
|
+
"headless"
|
|
44
|
+
],
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=26",
|
|
47
|
+
"npm": ">=11"
|
|
48
|
+
},
|
|
49
|
+
"author": {
|
|
50
|
+
"name": "Viglet Team",
|
|
51
|
+
"url": "https://www.viglet.org"
|
|
52
|
+
},
|
|
53
|
+
"license": "Apache-2.0",
|
|
54
|
+
"scripts": {
|
|
55
|
+
"emit": "node src/emit.mjs",
|
|
56
|
+
"test": "node --test \"test/*.test.mjs\"",
|
|
57
|
+
"emit:check": "node scripts/emit-guard.mjs"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a release's re-emit is allowed to change (SH218).
|
|
3
|
+
*
|
|
4
|
+
* <h2>Why a release needs a guard the suite already provides</h2>
|
|
5
|
+
*
|
|
6
|
+
* <p>`publish-js-sdk.yml` bumps every publishable package, re-runs `emit` and commits the result.
|
|
7
|
+
* That step exists because without it the generated trees keep the old dependency range and
|
|
8
|
+
* `emit.test.mjs` turns the **next** push red — a release's side effect reported against whoever
|
|
9
|
+
* pushed after it, where the obvious reading of a red build ("what did I break?") is wrong.</p>
|
|
10
|
+
*
|
|
11
|
+
* <p>The drift test cannot do this job. It runs on a push and answers "the tree matches its
|
|
12
|
+
* source"; the release runs `emit` and then *commits whatever came out*, so the one thing nobody
|
|
13
|
+
* checks is whether that output was the output anybody expected. A job that regenerates content
|
|
14
|
+
* into `shio-app/src/main/resources/` and commits it unread is a job that can land anything.</p>
|
|
15
|
+
*
|
|
16
|
+
* <h2>The rule, and why it is about files rather than about lines</h2>
|
|
17
|
+
*
|
|
18
|
+
* <p>A release changes <b>versions</b>. It does not add or remove files: a package that gains or
|
|
19
|
+
* loses one during a release is either an overlay somebody edited without running `emit`, or a
|
|
20
|
+
* generator that broke — and in both cases the release is the worst possible place for it to land,
|
|
21
|
+
* because a release commit is the one nobody reviews.</p>
|
|
22
|
+
*
|
|
23
|
+
* <p>So: <b>an addition or a deletion under the generated trees fails the release; a modification
|
|
24
|
+
* is expected and reported.</b> Deliberately not "every changed line must be a semver range" —
|
|
25
|
+
* that reads the diff's *text*, and a rule that has to parse a diff to decide whether a release is
|
|
26
|
+
* sound is a rule that will one day be wrong about a quoted string. The file-level question is the
|
|
27
|
+
* one with a clean answer, and it is the one that catches the case that matters.</p>
|
|
28
|
+
*
|
|
29
|
+
* @module
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/** Where the generated trees live, relative to the repository root. */
|
|
33
|
+
export const GENERATED = "shio-app/src/main/resources/blueprints/";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Splits `git status --porcelain` into what a release may and may not have produced.
|
|
37
|
+
*
|
|
38
|
+
* <p>Porcelain v1, whose first two columns are the index and worktree status. Only paths under
|
|
39
|
+
* {@link GENERATED} are considered: the same command reports the bumped `package.json` files,
|
|
40
|
+
* which are exactly what the release is *for*.</p>
|
|
41
|
+
*
|
|
42
|
+
* @param {string} porcelain raw `git status --porcelain` output
|
|
43
|
+
*/
|
|
44
|
+
export function classify(porcelain) {
|
|
45
|
+
const added = [];
|
|
46
|
+
const deleted = [];
|
|
47
|
+
const modified = [];
|
|
48
|
+
for (const line of String(porcelain ?? "").split("\n")) {
|
|
49
|
+
if (line.length < 4) continue;
|
|
50
|
+
const status = line.slice(0, 2);
|
|
51
|
+
// A rename is reported as `R old -> new`; the arrow form would otherwise be read as one
|
|
52
|
+
// path with an arrow in it, and a renamed generated file is exactly the surprise this catches.
|
|
53
|
+
const path = line.slice(3).replace(/^"|"$/g, "").split(" -> ").pop();
|
|
54
|
+
if (!path.startsWith(GENERATED)) continue;
|
|
55
|
+
if (status.includes("?") || status.includes("A") || status.includes("R")) added.push(path);
|
|
56
|
+
else if (status.includes("D")) deleted.push(path);
|
|
57
|
+
else modified.push(path);
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
added: added.sort(),
|
|
61
|
+
deleted: deleted.sort(),
|
|
62
|
+
modified: modified.sort(),
|
|
63
|
+
surprising: added.length + deleted.length,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* What the release prints, and the exit code it should carry.
|
|
69
|
+
*
|
|
70
|
+
* <p>The modified list is printed on success too. A release that says nothing about what it
|
|
71
|
+
* regenerated is one whose commit nobody can read afterwards, and "it changed six files" is the
|
|
72
|
+
* cheapest possible proof that the step ran at all (P9).</p>
|
|
73
|
+
*/
|
|
74
|
+
export function describe(result) {
|
|
75
|
+
const lines = [];
|
|
76
|
+
if (result.surprising === 0) {
|
|
77
|
+
lines.push(`emit: ${result.modified.length} generated file(s) changed, all modifications.`);
|
|
78
|
+
for (const path of result.modified) lines.push(` M ${path}`);
|
|
79
|
+
return { ok: true, text: `${lines.join("\n")}\n` };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
lines.push(
|
|
83
|
+
`emit: the release regenerated ${result.surprising} file(s) it was not supposed to.`,
|
|
84
|
+
"",
|
|
85
|
+
"A release changes versions. It does not add or remove generated files — one that does is",
|
|
86
|
+
"either an overlay somebody edited without running `emit`, or a generator that broke. Either",
|
|
87
|
+
"way a release commit is the worst place for it to land, because it is the one nobody reads.",
|
|
88
|
+
"",
|
|
89
|
+
);
|
|
90
|
+
for (const path of result.added) lines.push(` + ${path}`);
|
|
91
|
+
for (const path of result.deleted) lines.push(` - ${path}`);
|
|
92
|
+
lines.push(
|
|
93
|
+
"",
|
|
94
|
+
"Fix: run `pnpm -C create-shio-app run emit` on a branch, review what it produces, and commit",
|
|
95
|
+
"that as its own change. Then re-run the release.",
|
|
96
|
+
);
|
|
97
|
+
return { ok: false, text: `${lines.join("\n")}\n` };
|
|
98
|
+
}
|