@ryanatkn/gro 0.129.5 → 0.129.7

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 (47) hide show
  1. package/README.md +30 -30
  2. package/dist/config.d.ts +3 -3
  3. package/dist/gen.test.js +1 -1
  4. package/dist/invoke.js +1 -1
  5. package/dist/package.js +2 -2
  6. package/dist/src_json.d.ts +1 -1
  7. package/dist/src_json.js +1 -1
  8. package/package.json +1 -1
  9. package/src/lib/config.ts +3 -3
  10. package/src/lib/gen.test.ts +1 -1
  11. package/src/lib/invoke.ts +1 -1
  12. package/src/lib/package.ts +2 -2
  13. package/src/lib/src_json.ts +1 -1
  14. package/dist/docs/README.gen.md.d.ts +0 -6
  15. package/dist/docs/README.gen.md.d.ts.map +0 -1
  16. package/dist/docs/README.gen.md.js +0 -53
  17. package/dist/docs/README.md +0 -20
  18. package/dist/docs/build.md +0 -41
  19. package/dist/docs/config.md +0 -213
  20. package/dist/docs/deploy.md +0 -32
  21. package/dist/docs/dev.md +0 -40
  22. package/dist/docs/gen.md +0 -269
  23. package/dist/docs/gro_plugin_sveltekit_app.md +0 -113
  24. package/dist/docs/package_json.md +0 -33
  25. package/dist/docs/plugin.md +0 -50
  26. package/dist/docs/publish.md +0 -137
  27. package/dist/docs/task.md +0 -391
  28. package/dist/docs/tasks.gen.md.d.ts +0 -3
  29. package/dist/docs/tasks.gen.md.d.ts.map +0 -1
  30. package/dist/docs/tasks.gen.md.js +0 -66
  31. package/dist/docs/tasks.md +0 -37
  32. package/dist/docs/test.md +0 -52
  33. package/src/lib/docs/README.gen.md.ts +0 -63
  34. package/src/lib/docs/README.md +0 -20
  35. package/src/lib/docs/build.md +0 -41
  36. package/src/lib/docs/config.md +0 -213
  37. package/src/lib/docs/deploy.md +0 -32
  38. package/src/lib/docs/dev.md +0 -40
  39. package/src/lib/docs/gen.md +0 -269
  40. package/src/lib/docs/gro_plugin_sveltekit_app.md +0 -113
  41. package/src/lib/docs/package_json.md +0 -33
  42. package/src/lib/docs/plugin.md +0 -50
  43. package/src/lib/docs/publish.md +0 -137
  44. package/src/lib/docs/task.md +0 -391
  45. package/src/lib/docs/tasks.gen.md.ts +0 -90
  46. package/src/lib/docs/tasks.md +0 -37
  47. package/src/lib/docs/test.md +0 -52
package/dist/docs/dev.md DELETED
@@ -1,40 +0,0 @@
1
- # dev
2
-
3
- Gro is designed to extend [SvelteKit](https://github.com/sveltejs/kit)
4
- with helpful tools. It supports:
5
-
6
- - frontends with SvelteKit and [Vite](https://github.com/vitejs/vite)
7
- - Node libraries
8
- - Node servers
9
-
10
- ## usage
11
-
12
- ```bash
13
- gro dev
14
- gro dev --no-watch # outputs dev artifacts and exits without watch mode
15
- ```
16
-
17
- To configure a project, see [the config docs](config.md).
18
-
19
- ## plugin
20
-
21
- `Plugin`s are objects that customize the behavior of `gro build` and `gro dev`.
22
- See [plugin.md](plugin.md) to learn more.
23
-
24
- ## todo
25
-
26
- - [x] basics
27
- - [ ] add API using esbuild to optionally bundle specific pieces to speed up development
28
- - [ ] livereload CSS (and fix pop-in during dev)
29
- - [ ] HMR
30
- - [ ] probably support Rollup plugins in development, but how?
31
- - [ ] improve loading speed with `cache-control: immutable` and
32
- [import maps](https://github.com/WICG/import-maps/)
33
- (on my machine Firefox is much slower than Chrome
34
- handling a module import waterfall, locally, and http2 didn't help)
35
-
36
- <p align="center">
37
- <a href="https://github.com/ryanatkn/gro">
38
- <img src="static/logo.svg" alt="a pixelated green oak acorn with a glint of sun" width="192" height="192">
39
- </a>
40
- </p>
package/dist/docs/gen.md DELETED
@@ -1,269 +0,0 @@
1
- # gen
2
-
3
- > automated codegen by convention for
4
- > [Gro](https://github.com/ryanatkn/gro)
5
-
6
- ## motivation
7
-
8
- The [`gro gen` task](/src/lib/gen.task.ts) helps us enhance our projects
9
- with convention-based code/data/file generation (codegen) techniques.
10
-
11
- Why? Codegen can produce cool results and unhalting pain.
12
- Used well, codegen can improve performance, flexibility, consistency, and development speed.
13
- As developers, automating our work is a natural thing to do,
14
- and whether or not it's a wise thing to do,
15
- `gro gen` can bring automation deeper into our code authoring workflows.
16
-
17
- By convention, `gro gen` looks through `src/`
18
- for any TypeScript files with `.gen.` in the file name,
19
- and it outputs a file stripped of `.gen.` to the same directory.
20
- The `*.gen.*` origin files export a `gen` function
21
- More flexibility is available when needed
22
- including multiple custom output files.
23
-
24
- `gen` is implemented as [a task](/src/lib/gen.task.ts)
25
- and [a plugin](/src/lib/gro_plugin_gen.ts),
26
- and runs only during development, not for production builds.
27
-
28
- Normally you'll want to commit generated files to git,
29
- but you can always gitignore a specific pattern like `*.ignore.*`
30
- and name the output files accordingly.
31
-
32
- Integrating codegen into our development process
33
- is a simple idea with vast potential.
34
- It lets us have a single source of truth for data
35
- without compromising any of our code's runtime characteristics.
36
- We can generate documentation, types,
37
- `index.ts` files exporting directories,
38
- data for a UI,
39
- validators, tests, fakes,
40
- and more by introspecting our data at buildtime,
41
- which speeds up development
42
- The goal is to leverage automation to increase the power we wield over our code
43
- with a straightforward developer experience.
44
- Ergonomics are key to unlocking codegen's full potential.
45
-
46
- **Be aware** — this is a sharp tool! It should be used sparingly, only when it's a clear win.
47
- It adds a layer of indirection between the code you write and run,
48
- and it's possible to tie yourself into knots with dependencies.
49
- Also, you could introduce security vulnerabilities
50
- if you fail to escape certain inputs,
51
- There's no support for sourcemaps yet, and I have no plans for them.
52
- (I would accept contributions, but I think it's a hard problem to do well,
53
- and I don't know what the payoffs would be)
54
-
55
- > ⚠️ Generated files should never be edited directly,
56
- > because the next time `gro gen` or `gro sync` runs,
57
- > any uncommitted changes will be lost!
58
- > I considered making `gen` only write to files that have no uncommitted changes,
59
- > but that would impede many workflows,
60
- > and I don't want to nudge users towards a habit of always adding an override flag.
61
- > I can see one possible improvement that lets the user
62
- > opt into making gen write only to unchanged files for those workflows that don't mind it,
63
- > so if you would like to see that or something similar,
64
- > please open an issue or [share your thoughts on Discord](https://discord.gg/YU5tyeK72X).
65
-
66
- Inspirations include Lisp macros, the
67
- [Svelte](https://github.com/sveltejs/svelte) compiler,
68
- and [Zig](https://github.com/ziglang/zig)'s comptime.
69
- (but `gro gen` is far more primitive)
70
-
71
- ## usage
72
-
73
- The `gro gen` task looks for any files with `.gen.`
74
- in the file name and tries to call an exported `gen`
75
- function to generate one or more output files,
76
- and then it writes the results to the filesystem.
77
-
78
- ```bash
79
- gro gen # runs codegen for all *.gen.* files in src/
80
- gro gen --check # exits with error code 1 if anything is new or different; no-op to the fs
81
- ```
82
-
83
- > in the following examples,
84
- > but it makes for a better DX
85
-
86
- ### generate arbitrary TypeScript
87
-
88
- Given `src/script.gen.ts`:
89
-
90
- ```ts
91
- import type {Gen} from '@ryanatkn/gro';
92
-
93
- export const gen: Gen = () => {
94
- const message = 'generated';
95
- return `console.log('${message} a ${typeof message}')`;
96
- };
97
- ```
98
-
99
- Outputs `src/script.ts`:
100
-
101
- ```ts
102
- console.log('generated a string');
103
- ```
104
-
105
- ### gen context
106
-
107
- The `Gen` function receives one argument, the `Gen_Context` object:
108
-
109
- ```ts
110
- export interface Gen_Context {
111
- config: Gro_Config;
112
- sveltekit_config: Parsed_Sveltekit_Config;
113
- /**
114
- * Same as `import.meta.url` but in path form.
115
- */
116
- origin_id: Path_Id;
117
- log: Logger;
118
- }
119
- // export const gen: Gen = ({config, origin_id, log}) => {
120
- ```
121
-
122
- ### generate other filetypes
123
-
124
- Files with any extension can be generated without configuration.
125
- If the origin file name ends with the pattern `.gen.*.ts`,
126
- the default output file name is stripped of its trailing `.ts`.
127
-
128
- Given `src/markup.gen.html.ts`:
129
-
130
- ```ts
131
- import type {Gen} from '@ryanatkn/gro';
132
-
133
- export const gen: Gen = () => {
134
- const body = 'hi';
135
- return `
136
- <!DOCTYPE html>
137
- <html>
138
- <body>
139
- ${body}
140
- </body>
141
- </html>
142
- `;
143
- };
144
- ```
145
-
146
- Outputs `src/markup.html`:
147
-
148
- ```html
149
- <!doctype html>
150
- <html>
151
- <body>
152
- hi
153
- </body>
154
- </html>
155
- ```
156
-
157
- ### generate a custom file name or write to a different directory
158
-
159
- The `gen` function can return an object with custom configuration.
160
-
161
- Given `src/somewhere/originalName.gen.ts`:
162
-
163
- ```ts
164
- import type {Gen} from '@ryanatkn/gro';
165
-
166
- export const gen: Gen = () => {
167
- const message = 'output path can be relative and name can be anything';
168
- return {
169
- content: `console.log('${message}')`,
170
- filename: '../elsewhere/otherName.ts',
171
- format: optional_boolean_that_defaults_to_true,
172
- };
173
- };
174
- ```
175
-
176
- Outputs `src/elsewhere/otherName.ts`:
177
-
178
- ```ts
179
- console.log('output path can be relative and name can be anything');
180
- ```
181
-
182
- ### generate multiple custom files
183
-
184
- The `gen` function can also return an array of files.
185
-
186
- Given `src/thing.gen.ts`:
187
-
188
- ```ts
189
- import type {Gen} from '@ryanatkn/gro';
190
-
191
- export const gen: Gen = () => {
192
- const fieldValue = 1;
193
- return [
194
- {
195
- content: `
196
- import {Thing} from './index';
197
- export const isThing = (t: any): t is Thing => t?.field === ${fieldValue};
198
- `,
199
- },
200
- {
201
- content: `export interface Thing { field: ${typeof fieldValue} }`,
202
- filename: 'types.ts',
203
- },
204
- {
205
- content: `{"field": ${fieldValue}}`,
206
- filename: 'data/thing.json',
207
- },
208
- ];
209
- };
210
- ```
211
-
212
- Outputs `src/thing.ts`:
213
-
214
- ```ts
215
- import type {Thing} from './index.js';
216
- export const isThing = (t: any): t is Thing => t?.field === 1;
217
- ```
218
-
219
- and `src/types.ts`:
220
-
221
- ```ts
222
- export interface Thing {
223
- field: number;
224
- }
225
- ```
226
-
227
- and `src/data/thing.json`:
228
-
229
- ```json
230
- {
231
- "field": 1
232
- }
233
- ```
234
-
235
- It's often helpful to check if any generated files are new or have changed.
236
- We don't want to forget to regenerate files before committing or publishing!
237
- The `check` CLI argument can be passed to perform this check
238
- instead of writing the generated files to disk.
239
-
240
- ```bash
241
- gro gen --check # exits with error code 1 if anything is new or different; no-op to the fs
242
- ```
243
-
244
- or in code:
245
-
246
- ```ts
247
- import type {Task} from '@ryanatkn/gro';
248
-
249
- export const task: Task = {
250
- run: async ({args, invoke_task}) => {
251
- // this throws a `Task_Error` if anything is new or different
252
- await invoke_task('gen', {...args, check: true});
253
- },
254
- };
255
- ```
256
-
257
- Gro uses this in [`check.task.ts`](/src/lib/check.task.ts)
258
- which is called during `gro publish`, and it's recommended in CI.
259
- (see [Gro's example `check.yml`](/.github/workflows/check.yml))
260
-
261
- ## todo
262
-
263
- - [x] basic functionality
264
- - [x] format output with Prettier
265
- - [x] [watch mode and build integration](https://github.com/ryanatkn/gro/pull/283),
266
- opt out with `watch: false` for expensive gen use cases
267
- - [ ] change the exported `gen` function to an object with a `summary` and other properties like `watch`
268
- - [ ] support generating non-text files
269
- - [ ] think about how to handle gen file dependency graphs (generated files as inputs to gen files)
@@ -1,113 +0,0 @@
1
- # SvelteKit app plugin
2
-
3
- Gro's [SvelteKit app plugin](/src/lib/gro_plugin_sveltekit_app.ts)
4
- calls `vite dev` and `vite build` with some additional behaviors.
5
-
6
- ```ts
7
- // gro.config.ts
8
- import type {Gro_ConfigCreator} from '@ryanatkn/gro';
9
- import {gro_plugin_sveltekit_app} from '@ryanatkn/gro/gro_plugin_sveltekit_app.js';
10
-
11
- const config: Gro_ConfigCreator = async (cfg) => {
12
- cfg.plugins = async () => [
13
- // this is included in the default config for SvelteKit projects:
14
- gro_plugin_sveltekit_app({
15
- // host_target?: Host_Target;
16
- // well_known_package_json?: boolean | Map_Package_Json;
17
- // well_known_src_json?: boolean | Map_Src_Json;
18
- // well_known_src_files?: boolean | Copy_File_Filter;
19
- }),
20
- ];
21
- return cfg;
22
- };
23
-
24
- export default config;
25
-
26
- // src/lib/gro_plugin_sveltekit_app.ts
27
- export type Host_Target = 'github_pages' | 'static' | 'node';
28
-
29
- export interface Copy_File_Filter {
30
- (file_path: string): boolean | Promise<boolean>;
31
- }
32
-
33
- // src/lib/package_json.ts
34
- export interface Map_Package_Json {
35
- (package_json: Package_Json): Package_Json | null | Promise<Package_Json | null>;
36
- }
37
-
38
- // src/lib/src_json.ts
39
- export interface Map_Src_Json {
40
- (src_json: Src_Json): Src_Json | null | Promise<Src_Json | null>;
41
- }
42
- ```
43
-
44
- ## `host_target`
45
-
46
- When `host_target` is the default value `'github_pages'`,
47
- a `.nojekyll` file is included in the build to tell GitHub Pages not to process it with Jekyll.
48
-
49
- ## `well_known_package_json`
50
-
51
- If your root `package.json` has `"public": true`
52
- (telling Gro it's a [public package](./package_json.md#public-packages)),
53
- by default Gro copies `.well-known/package.json` to `static/` during `vite build`,
54
- so it's included in the SvelteKit build output.
55
- The motivation is to provide conventional package metadata to web users and tools.
56
- (more details below)
57
-
58
- > ⚠️ Outputting `.well-known/package.json` will surprise some users
59
- > and could result in information leaks that compromise privacy or security.
60
- > The feature is enabled only when your root `package.json` has `"public": true`.
61
- > Templates that default to public should prominently warn their users.
62
-
63
- By default the root `package.json` is copied without modifications,
64
- and you can provide your own `well_known_package_json` option to
65
- mutate the `package_json`, return new data, or return `null` to be a no-op.
66
-
67
- > Writing to `.well-known/package.json` is unstandardized behavior that
68
- > extends [Well-known URIs](https://wikipedia.org/wiki/Well-known_URIs) for Node packages
69
- > to provide conventional metadata for deployed websites.
70
- > [Mastodon](<https://en.wikipedia.org/wiki/Mastodon_(social_network)>) uses
71
- > [WebFinger](https://en.wikipedia.org/wiki/WebFinger) which uses `.well-known` for discovery.
72
- > One difference is that SvelteKit outputs static files relative to the configured `base` path,
73
- > so the `.well-known` directory may not be in the root `/`.
74
- > This is useful because it enables websites to provide metadata even when hosted in a namespaced
75
- > path like `username.github.io/projectname/.well-known`.
76
-
77
- Why publish this metadata to the web instead of relying on the git repo as the only source of truth?
78
-
79
- - we want to give all web users and tools access to discoverable package metadata
80
- - metadata is a much lighter dependency than an entire repo
81
- - some repos are deployed to multiple websites with metadata differences
82
- - some repos like monorepos have multiple `package.json` files
83
- - we don't want to force a dependency on git, the bespoke URLs of forge hosts like GitHub,
84
- or any particular toolchains
85
- - the git repo is still the source of truth, but Gro adds a build step for project metadata,
86
- giving devs full control over the published artifacts
87
- instead of coupling metadata directly to a source repo's `package.json`
88
-
89
- ## `well_known_src_json`
90
-
91
- If your root `package.json` has `"public": true`,
92
- by default Gro creates `.well-known/src.json` and `.well-known/src/`
93
- in `static/` during `vite build`,
94
- so they're included in the SvelteKit build output.
95
- More [about public packages](./package_json.md#public-packages).
96
-
97
- This can be customized with `well_known_src_json`.
98
- Setting it to `false` disables the feature, and `true` enables it.
99
- Setting it to a function maps the final `src.json` value - returning `null` disables it.
100
-
101
- The `.well-known/src.json` file contains more details about
102
- the `package.json`'s `exports`, like exported identifier names and types.
103
- It maps each export to a source file in `.well-known/src/`.
104
-
105
- ## `well_known_src_files`
106
-
107
- The contents of your `src/` directory can be included in the output
108
- if you want your app's source code to be available the same as the built files.
109
- This is disabled by default.
110
- If `well_known_src_files` is truthy,
111
- the plugin copies `src/` to `static/.well-known/src/` during `vite build`.
112
- Passing `true` uses the same filter as `exports` in `package.json` by default,
113
- and it also accepts a custom filter function.
@@ -1,33 +0,0 @@
1
- # `package.json`
2
-
3
- Gro extends [`package.json`](https://docs.npmjs.com/cli/v10/configuring-npm/package-json)
4
- with additional functionality.
5
-
6
- ## `public` packages
7
-
8
- Setting `"public": true` in `package.json` opts into
9
- behavior designed for public open source projects:
10
-
11
- - [`gro_plugin_sveltekit_app`](./gro_plugin_sveltekit_app.md)
12
- copies `package.json` from your project root to your
13
- SvelteKit static directory at `.well-known/package.json` during `vite build`,
14
- mapping it with the optional
15
- [`well_known_package_json` option](./gro_plugin_sveltekit_app.md#well_known_package_json).
16
- - `gro_plugin_sveltekit_app` outputs `.well-known/src.json`
17
- using the `exports` property of `package.json` during `vite build`,
18
- containing additional information about the source modules,
19
- mapping it with the optional
20
- [`well_known_src_json` option](./gro_plugin_sveltekit_app.md#well_known_src_json).
21
- - If you define a truthy value for the
22
- [`well_known_src_files` option](./gro_plugin_sveltekit_app.md#well_known_src_files),
23
- `gro_plugin_sveltekit_app` outputs `.well-known/src/` by
24
- copying over `src/` during `vite build`, filtered by `well_known_src_files` if it's a function.
25
- This is costly (usually more than doubling the final output size
26
- of the code files in bytes, not counting images and such),
27
- it slows the build because it copies your entire source tree (sorry to hard drives),
28
- and it exposes your source code the same as the built files.
29
-
30
- > ⚠️ Setting `"public": true` in `package.json` exposes your `package.json`
31
- > and `src.json` metadata with your other built files by default!
32
- > Further opting in with `well_known_src_files` exposes your actual source files.
33
- > If your built files are public, that means these additional files are also public.
@@ -1,50 +0,0 @@
1
- # plugin
2
-
3
- During the [`gro dev`](dev.md) and [`gro build`](build.md) tasks,
4
- Gro uses `Plugin`s to support custom usecases outside of the normal build pipeline.
5
-
6
- In this early implementation of plugins in Gro,
7
- plugins run serially, in the order they are returned from `plugins` in the `gro.config.ts`.
8
- Each step of Gro's build processes - `gro dev` for development and `gro build` for production -
9
- runs a method of each plugin, batched together as `setup -> adapt -> teardown`,
10
- with some behavioral inconsistencies:
11
-
12
- - `adapt` only runs during production aka `gro build`
13
- - `teardown` does not run for `gro dev` in the default `watch` mode,
14
- but it does run with `gro dev --no-watch`
15
- - there should probably be a finalization step that runs `teardown` on uncaught exceptions
16
-
17
- The API needs to be improved for more advanced usecases,
18
- currently it offers little flexibility -
19
- we'll follow the Vite/SvelteKit APIs probably. (`pre` etc)
20
- Maybe let you map the array of each method batch. (is that possible with those?)
21
-
22
- Gro's builtin plugins:
23
-
24
- - [`@ryanatkn/gro_plugin_server`](../gro_plugin_server.ts)
25
- - [`@ryanatkn/gro_plugin_sveltekit_library`](../gro_plugin_sveltekit_library.ts)
26
- - [`@ryanatkn/gro_plugin_sveltekit_app`](../gro_plugin_sveltekit_app.ts)
27
- - [`@ryanatkn/gro_plugin_gen`](../gro_plugin_gen.ts)
28
- (currently disabled, will be replaced with an esbuild plugin)
29
-
30
- Also see [`config.plugin` in the config docs](config.md#plugin)
31
- and usage in [the default config](../gro.config.default.ts).
32
- The default config detects which plugins are included by inspecting the current project.
33
-
34
- The implementation is at [`src/lib/plugin.ts`](../plugin.ts) with more details.
35
-
36
- ```ts
37
- export interface Plugin<T_Plugin_Context extends Plugin_Context = Plugin_Context> {
38
- name: string;
39
- setup?: (ctx: T_Plugin_Context) => void | Promise<void>;
40
- adapt?: (ctx: T_Plugin_Context) => void | Promise<void>;
41
- teardown?: (ctx: T_Plugin_Context) => void | Promise<void>;
42
- }
43
-
44
- export interface Plugin_Context<T_Args = object> extends Task_Context<T_Args> {
45
- dev: boolean;
46
- watch: boolean;
47
- }
48
- ```
49
-
50
- The `adapt` step only runs for production during `gro build`, taking after SvelteKit adapters.
@@ -1,137 +0,0 @@
1
- # publish
2
-
3
- Here's how to publish a new version of a repo with Gro, including for Gro itself.
4
-
5
- ## svelte-package
6
-
7
- Gro uses SvelteKit's [`@sveltejs/package`](https://kit.svelte.dev/docs/packaging)
8
- with the task `gro publish` to publish packages to npm.
9
- Gro's default config enables [`@ryanatkn/gro/gro_plugin_sveltekit_library.js`](../gro_plugin_sveltekit_library.ts)
10
- if it detects `@sveltejs/package` installed as a dependency in the package.json.
11
-
12
- ```bash
13
- # enable `gro publish` to publish to npm:
14
- npm i -D @sveltejs/package # enables `@ryanatkn/gro/gro_plugin_sveltekit_library.js`
15
- gro sync # updates package.json "exports"
16
- git commit -am "..."
17
- # `gro publish` calls `svelte-package`
18
- ```
19
-
20
- ## login to npm
21
-
22
- ```bash
23
- npm whoami # check if you're logged in
24
-
25
- # not logged in?
26
- npm login # and follow the instructions
27
- ```
28
-
29
- > more about [`npm login`](https://docs.npmjs.com/v6/commands/npm-adduser)
30
-
31
- ## using changesets
32
-
33
- The [`gro publish` task](https://github.com/ryanatkn/gro/blob/main/src/lib/publish.task.ts)
34
- integrates with [Changesets](https://github.com/changesets/changesets)
35
- to publish packages to [npm](https://npmjs.com/). Internally the task calls both
36
- [`changeset version`](https://github.com/changesets/changesets/blob/main/packages/README.md#version)
37
- and
38
- [`changeset publish`](https://github.com/changesets/changesets/blob/main/packages/README.md#publish).
39
-
40
- Gro does not include Changesets as a dependency.
41
- Install it globally or local to your repo
42
- (I prefer global, it's not a light dependency):
43
-
44
- ```bash
45
- npm i -g @changesets/cli # install globally
46
- npm i -D @changesets/cli # or install local to your repo
47
- ```
48
-
49
- To [init Changesets](https://github.com/changesets/changesets/blob/main/packages/README.md#init)
50
- in a repo or [add](https://github.com/changesets/changesets/blob/main/packages/README.md#add)
51
- a changeset to an already-inited repo, use `gro changeset`:
52
-
53
- ```bash
54
- gro changeset # inits or adds a changeset
55
- gro changeset --help # view the args docs
56
-
57
- # `gro changeset` is equivalent to:
58
- changeset init # if needed -- prefix with `npx ` if installed only locally
59
- changeset
60
- git add .changeset/$FILE
61
- # TODO include a `git commit` flag or default behavior, maybe `gro changeset "message"`
62
- ```
63
-
64
- After initing, optionally configure and install a custom changelog package
65
- in the `"changelog"` property of the newly created `.changeset/config.json`:
66
-
67
- ```diff
68
- # .changeset/config.json
69
- - "changelog": "@changesets/changelog",
70
- + "changelog": "@changesets/changelog-git",
71
- ```
72
-
73
- ```bash
74
- npm i -D @changesets/changelog-git # a minimal package that requires no GitHub auth
75
- ```
76
-
77
- Gro inits `"access"` based on the package.json `"private": true` value.
78
- To manually configure the `access` property:
79
-
80
- ```diff
81
- # .changeset/config.json
82
- - "access": "public",
83
- + "access": "restricted",
84
- ```
85
-
86
- See [the Changesets docs](https://github.com/changesets/changesets) for more.
87
-
88
- ## GitHub API setup
89
-
90
- Gro currently expects repos to be on GitHub to generate changelogs with Changesets.
91
- (sorry, maybe in the future we'll support other forges)
92
-
93
- Gro modifies the barebones changelog generated by `@changesets/changelog-git`,
94
- doing things like linkifying commit hashes or linking to PRs if they exist.
95
- The difference between Gro's version and `@changesets/changelog-github` is that Gro
96
- doesn't require a token for authorization for public repos,
97
- and Gro makes some different choices for usability.
98
-
99
- Gro calls the GitHub API using the environment variable `GITHUB_TOKEN_SECRET` for authorization,
100
- which is a [GitHub token](https://github.com/settings/tokens)
101
- (with "public access" for public repos, no options selected)
102
- in either `process.env`, a project-local `.env`, or the parent directory at `../.env`
103
- (currently optional to read public repos, but it's recommended regardless,
104
- and you'll need to select options to support private repos).
105
-
106
- You'll get a warning if the token is unavailable, but for light usage you won't hit rate limts.
107
-
108
- ## `gro publish`
109
-
110
- The publish task builds the project, bumps the version, publishes to npm,
111
- commits the changes, and then pushes the commit and tag.
112
-
113
- Ensure `"dist"` is in the `"files"` property of `package.json`:
114
-
115
- ```json
116
- "files": [
117
- "dist"
118
- ],
119
- ```
120
-
121
- Then publish:
122
-
123
- ```bash
124
- gro publish
125
- gro publish --help # view the options
126
- gro publish -- svelte-package -w # forward options
127
- ```
128
-
129
- See [the SvelteKit packaging docs](https://kit.svelte.dev/docs/packaging) for more.
130
-
131
- If `changeset publish` fails during `gro publish`,
132
- the task exits without pushing anything to the remote origin.
133
- It does however create the version commit and tag.
134
- A common failure is not being logged into npm. (see the instructions above)
135
- If the builds are correct but `changeset publish` failed,
136
- and you don't want to undo the version commit and tag,
137
- you can continue manually with `changeset publish` or `npm publish`.