create-grist-widget 0.3.6 → 0.3.9

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.
Files changed (34) hide show
  1. package/README.md +79 -7
  2. package/bin/create-grist-widget.mjs +485 -90
  3. package/examples/attachment-gallery/WidgetApp.tsx +202 -0
  4. package/examples/bulk-mark-done/WidgetApp.tsx +43 -0
  5. package/examples/declared-columns/WidgetApp.tsx +42 -0
  6. package/examples/form-edit/WidgetApp.tsx +225 -0
  7. package/examples/hello-world/WidgetApp.tsx +15 -0
  8. package/examples/mark-done/WidgetApp.tsx +44 -0
  9. package/examples/reads-demo/WidgetApp.tsx +69 -0
  10. package/examples/rest-fetch/WidgetApp.tsx +49 -0
  11. package/examples/safe-parse/WidgetApp.tsx +61 -0
  12. package/examples/schema-migration/WidgetApp.tsx +67 -0
  13. package/examples/schema-preview/WidgetApp.tsx +26 -0
  14. package/examples/slice-hooks/WidgetApp.tsx +47 -0
  15. package/examples/spreadsheet-grid/GristDataSheetGrid.tsx +376 -0
  16. package/examples/spreadsheet-grid/GristRdgGrid.tsx +189 -0
  17. package/examples/spreadsheet-grid/GristSchemaToolbar.tsx +293 -0
  18. package/examples/spreadsheet-grid/WidgetApp.tsx +133 -0
  19. package/examples/spreadsheet-grid/grist-rdg-choice-column.tsx +616 -0
  20. package/examples/spreadsheet-grid/grist-rdg-columns.ts +397 -0
  21. package/examples/task-board/WidgetApp.tsx +229 -0
  22. package/examples/theme-demo/WidgetApp.tsx +26 -0
  23. package/examples/widget-options/WidgetApp.tsx +34 -0
  24. package/examples/writes-demo/WidgetApp.tsx +75 -0
  25. package/manifest.json +304 -0
  26. package/package.json +14 -2
  27. package/src/git-gate.mjs +30 -0
  28. package/template/.github/workflows/deploy.yml +7 -3
  29. package/template/README.md +3 -2
  30. package/template/scripts/deploy.mjs +128 -18
  31. package/ui-source/ShadcnDataSheetGrid.css +117 -0
  32. package/ui-source/ShadcnDataSheetGrid.tsx +46 -0
  33. package/ui-source/badge.tsx +49 -0
  34. package/vendor/compose-example.mjs +252 -0
package/README.md CHANGED
@@ -6,13 +6,82 @@ Scaffold a new [Grist](https://www.getgrist.com/) custom widget, preconfigured w
6
6
  ```bash
7
7
  npm create grist-widget my-widget
8
8
  cd my-widget
9
- pnpm install
10
9
  pnpm dev
11
10
  ```
12
11
 
13
- The template ships embedded in this package — nothing is fetched from GitHub at
14
- scaffold time. See [Getting started](https://gristwidgets.com/docs/sdk/guide/getting-started)
15
- for the full walkthrough (dev loop, deploying, embedding in Grist).
12
+ The template — plus every starting example and the logic that composes them — ships
13
+ embedded in this package. Nothing is fetched from GitHub or npm at scaffold time; the SDK
14
+ install right after is the only network access any of these commands make. See
15
+ [Getting started](https://gristwidgets.com/docs/sdk/guide/getting-started) for the full
16
+ walkthrough (dev loop, deploying, embedding in Grist).
17
+
18
+ By default the scaffold starts blank (a two-field editor) and installs its own
19
+ dependencies automatically, detecting whichever package manager you invoked this with. Add
20
+ `--example <id>` to start from a real widget instead — `create-grist-widget list` shows
21
+ what's available — or just run `npm create grist-widget` with no name for an interactive
22
+ prompt that asks for both.
23
+
24
+ ## The four commands
25
+
26
+ | Command | What it does |
27
+ | --- | --- |
28
+ | `create <name> [--example <id>]` | Scaffold a new widget into `./<name>` (the command above, or run explicitly) |
29
+ | `init [--example <id>]` | Scaffold into the **current** directory instead of a new one — for an already-cloned or agent-initialized repo |
30
+ | `use <example-id>` | Swap the current project's widget for a different example |
31
+ | `list [--json]` | Print the available starting examples |
32
+
33
+ Common flags for `create`/`init`: `--yes` skips interactive prompts and uses
34
+ flags/defaults only; `--no-install` skips the automatic dependency install;
35
+ `--pm <name>` picks a specific package manager instead of auto-detecting one.
36
+ `init` additionally takes `--name <name>` (default: the current directory's
37
+ name) and `--force` (overwrite files that already exist and differ from the
38
+ template — see below).
39
+
40
+ ### `init` — starting from an already-initialized directory
41
+
42
+ `create` refuses a non-empty target directory; `init` is the fix for the case that comes
43
+ up constantly with cloud coding agents, which typically start from an already-cloned or
44
+ already-`git init`'d repo rather than an empty one:
45
+
46
+ ```bash
47
+ mkdir my-widget && cd my-widget
48
+ git init # or: this is already a fresh GitHub Pages / template clone
49
+ npx create-grist-widget init --example form-edit
50
+ ```
51
+
52
+ Files that already exist and are identical to the template are left untouched; the four
53
+ identity-bearing files (`package.json`, `README.md`, `index.html`, `src/App.tsx`) get the
54
+ usual name/title substitution even if present. Anything else that already exists **and**
55
+ differs from the template's own copy stops the run with a list of the conflicting paths —
56
+ pass `--force` to overwrite anyway. If `.git` already exists, `init` never auto-commits;
57
+ review and commit the result yourself. If it doesn't, `init` sets up `main` + `dev` and an
58
+ initial commit exactly like `create` does.
59
+
60
+ ### `use` — swapping to a different example later
61
+
62
+ Changed your mind about which example to start from, or want to compare two? `use` swaps
63
+ `src/App.tsx` (and any example-specific files) for a different one, in place:
64
+
65
+ ```bash
66
+ create-grist-widget use task-board
67
+ ```
68
+
69
+ It only ever touches `src/**` — never `main.tsx`, `vite.config.ts`, or the deploy
70
+ workflow — and it requires a clean git working tree first (`git status --porcelain`
71
+ empty), so the swap is always a single reviewable, revertible diff. Commit or stash first
72
+ if you have uncommitted changes; `use` refuses to run otherwise.
73
+
74
+ ### `list` — what's available
75
+
76
+ ```bash
77
+ create-grist-widget list # id / title / description, one per line
78
+ create-grist-widget list --json # the same, as JSON
79
+ ```
80
+
81
+ > **Note:** `create`, `init`, `use`, and `list` are themselves valid widget names — a bare
82
+ > `create-grist-widget list` runs the `list` command, not "scaffold a widget named list."
83
+ > Use the explicit form (`create-grist-widget create list`) for a widget with one of these
84
+ > names.
16
85
 
17
86
  ## Using Claude Code?
18
87
 
@@ -80,9 +149,12 @@ simplest way to get from zero to a deployed widget:
80
149
 
81
150
  > ⚠️ **Merging without a version bump publishes nothing.** The release
82
151
  > build skips whenever the version already has a published `v<version>/`
83
- > directory, which is always true if you forgot to bump it. The PR merges
84
- > cleanly and CI runs "successfully," but `/latest/` doesn't change. Bump
85
- > the version *before* merging.
152
+ > directory, which is always true if you forgot to bump it. Bump the
153
+ > version *before* merging. After your first release, the deploy workflow
154
+ > catches the common case of this and fails the run loudly instead of
155
+ > silently reporting success — but only when it can tell the previous
156
+ > commit had the exact same version; it's a backstop, not a substitute
157
+ > for bumping it yourself.
86
158
 
87
159
  Keep committing to the same `dev` branch afterward — it's the permanent
88
160
  working/preview branch, not a one-off branch to delete per change.