create-grist-widget 0.2.16 → 0.2.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-grist-widget",
3
- "version": "0.2.16",
3
+ "version": "0.2.18",
4
4
  "description": "Scaffold a new Grist custom widget from the grist-widget-sdk Vite template",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -91,13 +91,16 @@ automatically.
91
91
  > it doesn't run any of the CLI's own setup (renaming `package.json`,
92
92
  > titles, etc.), and it won't reset `package.json`'s `version` back to a
93
93
  > fresh `0.0.1` for you. Do both by hand before your first real release.
94
- > Also **never manually seed/copy `gh-pages` content** from another repo
95
- > (e.g. to get Pages showing something immediately) — each `v<version>/`
96
- > is only recognized as a genuine prior release if it carries a
94
+ > If you also checked **"Include all branches"** (to get `gh-pages`/Pages
95
+ > already set up, no manual Settings step), your first real release
96
+ > automatically clears out every leftover `v<version>/` it finds — a
97
+ > `v<version>/` only counts as a genuine prior release once it carries a
97
98
  > `showcase-meta.json` naming *this* repo (written by this pipeline's own
98
- > `place` step); anything else is treated as unpublished and safely
99
- > rebuilt over, but it's simpler to just let the workflow create
100
- > `gh-pages` itself (it does, as an orphan branch, on its first real run).
99
+ > `place` step), so on a repo with no genuine releases yet, everything
100
+ > else is provably inherited noise and gets safely wiped on your first
101
+ > push to `main`. That cleanup only ever runs before your *first* genuine
102
+ > release — once one exists, it's permanently a no-op, so it's still safest
103
+ > to never manually re-seed `gh-pages` again after that point.
101
104
 
102
105
  **One-time setup** (the workflow can't do this part for you):
103
106
 
@@ -177,6 +177,29 @@ function replaceDir(dest, srcDist) {
177
177
  cpSync(srcDist, dest, { recursive: true })
178
178
  }
179
179
 
180
+ /**
181
+ * If this repo has never genuinely published a release before (no
182
+ * v<version>/ directory whose showcase-meta.json matches this repo), any
183
+ * v<version>/ directories present are provably inherited noise -- e.g. from
184
+ * copying this template repo including its gh-pages branch (GitHub's "Use
185
+ * this template" -> "Include all branches"). Safe to clear them all before
186
+ * placing this repo's actual first release: there is no ambiguity, since a
187
+ * repo with zero genuine releases can't have any of its own history to lose.
188
+ * Never touches dev/, latest/, or site-root files. Once a genuine release
189
+ * exists for this repo, buildVersionsManifest is non-empty and this is
190
+ * permanently a no-op.
191
+ */
192
+ export function cleanupForeignVersionsIfFirstRelease(siteDir, repo) {
193
+ if (buildVersionsManifest(siteDir, repo).length > 0) return { cleaned: [] }
194
+ const cleaned = []
195
+ for (const name of existsSync(siteDir) ? readdirSync(siteDir) : []) {
196
+ if (!/^v\d+\.\d+\.\d+/.test(name)) continue
197
+ rmSync(join(siteDir, name), { recursive: true, force: true })
198
+ cleaned.push(name)
199
+ }
200
+ return { cleaned }
201
+ }
202
+
180
203
  /** Place a freshly built dist into the gh-pages tree. */
181
204
  export function placeTarget({ siteDir, channel, version, distDir, sha, ref, repo }) {
182
205
  if (!existsSync(distDir)) throw new Error(`dist not found: ${distDir}`)
@@ -202,6 +225,7 @@ export function placeTarget({ siteDir, channel, version, distDir, sha, ref, repo
202
225
  // exactly like latest/ reusing it: the asset URLs it references (under
203
226
  // v<version>/assets/) already exist from the versionDir placement above,
204
227
  // so nothing 404s.
228
+ cleanupForeignVersionsIfFirstRelease(siteDir, repo)
205
229
  const versionDir = join(siteDir, `v${version}`)
206
230
  replaceDir(versionDir, distDir)
207
231
  writeFileSync(
@@ -63,6 +63,28 @@ function CreateRepoButton() {
63
63
  )
64
64
  }
65
65
 
66
+ // The fastest path: GitHub's own "generate from template" flow, with
67
+ // history included so gh-pages/Pages content comes along -- no
68
+ // create-grist-widget CLI, no local install. See the template README's
69
+ // "Used GitHub's 'Use this template' button instead of `npm create
70
+ // grist-widget`?" note for what this trades away (package.json rename,
71
+ // version reset) in exchange for zero local setup.
72
+ function CopyStarterRepoButton() {
73
+ return (
74
+ <div className="mt-2 ml-5">
75
+ <Button asChild>
76
+ <a
77
+ href="https://github.com/arthurblanchon/grist-widget-template/generate"
78
+ target="_blank"
79
+ rel="noreferrer"
80
+ >
81
+ Copy starter repo
82
+ </a>
83
+ </Button>
84
+ </div>
85
+ )
86
+ }
87
+
66
88
  export function TemplateLanding() {
67
89
  const { versions, error } = useVersions()
68
90
 
@@ -84,7 +106,63 @@ export function TemplateLanding() {
84
106
 
85
107
  <div className="mb-10 rounded-lg border p-4">
86
108
  <h2 className="mb-3 font-heading text-base font-semibold">
87
- Get started
109
+ Quickstart
110
+ </h2>
111
+ <ol className="list-inside list-decimal space-y-3 text-sm text-muted-foreground">
112
+ <li>
113
+ Copy this starter repo. On the next page, check{" "}
114
+ <strong className="text-foreground">Include all branches</strong>{" "}
115
+ so GitHub Pages comes already configured — no manual Settings
116
+ step.
117
+ <CopyStarterRepoButton />
118
+ </li>
119
+ <li>
120
+ Your new widget starts deploying on its first push. Ask your AI
121
+ coding agent for two URLs: the{" "}
122
+ <strong className="text-foreground">dev</strong> build (auto-reloads
123
+ as you iterate) and the{" "}
124
+ <strong className="text-foreground">latest</strong> build (ready to
125
+ paste into a production Grist document).
126
+ </li>
127
+ </ol>
128
+ <div className="mt-4 rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-xs text-muted-foreground">
129
+ <strong className="text-foreground">
130
+ If your AI can't see the new widget repo,
131
+ </strong>{" "}
132
+ check its GitHub App has been granted access to it:{" "}
133
+ <a
134
+ href="https://github.com/apps/claude"
135
+ target="_blank"
136
+ rel="noreferrer"
137
+ className="underline underline-offset-4 hover:text-foreground"
138
+ >
139
+ Claude
140
+ </a>
141
+ ,{" "}
142
+ <a
143
+ href="https://github.com/apps/chatgpt-codex-connector"
144
+ target="_blank"
145
+ rel="noreferrer"
146
+ className="underline underline-offset-4 hover:text-foreground"
147
+ >
148
+ Codex
149
+ </a>
150
+ , or{" "}
151
+ <a
152
+ href="https://github.com/apps/cursor"
153
+ target="_blank"
154
+ rel="noreferrer"
155
+ className="underline underline-offset-4 hover:text-foreground"
156
+ >
157
+ Cursor
158
+ </a>
159
+ .
160
+ </div>
161
+ </div>
162
+
163
+ <div className="mb-10 rounded-lg border p-4">
164
+ <h2 className="mb-3 font-heading text-base font-semibold">
165
+ Prefer the CLI?
88
166
  </h2>
89
167
  <Tabs defaultValue="claude-code">
90
168
  <TabsList className="mb-4">