@ryanatkn/gro 0.129.6 → 0.129.8

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/task.md DELETED
@@ -1,391 +0,0 @@
1
- # task
2
-
3
- > task runner for
4
- > [Gro](https://github.com/ryanatkn/gro)
5
-
6
- ## contents
7
-
8
- - [what](#what)
9
- - [usage](#usage)
10
- - [why?](#why)
11
-
12
- ## what
13
-
14
- A Gro `Task` is just an object with a `run` function and some optional metadata.
15
- Gro prefers conventions and code over configuration,
16
- and its task runner leverages the filesystem as the API
17
- and defers composition to the user in regular TypeScript modules.
18
-
19
- > Tasks are a special Gro construct.
20
- > If you want to simply execute regular TypeScript files,
21
- > use the `gro run` task, which works like the normal `node` CLI
22
- > but uses the Gro loader to support `.ts`.
23
-
24
- - tasks are defined by naming files with the `.task.ts` and `.task.js` suffixes
25
- - tasks can be run from the CLI via a name (`gro foo`),
26
- which uses Gro's task resolution (see more below),
27
- or via paths that are absolute (`gro /path/to/foo`) or explicitly relative (`gro ./foo`)
28
- - Gro automatically discovers all `*.task.ts|js` files
29
- in its configurable directory, so creating a new task
30
- is as simple as [creating a new file](#define-a-task), no config needed
31
- (defaults to `src/lib`, see the config option [`task_root_dirs`](./config.md#task_root_dirs))
32
- - to view [the available tasks](https://github.com/ryanatkn/gro/blob/main/src/lib/docs/tasks.md)
33
- run `gro` with no arguments
34
- - task definitions are just objects with an async `run` function and some optional properties,
35
- so composing tasks is explicit in your code, just like any other module
36
- (but there's also the helper `invoke_task`, see more below)
37
- - the task object's `run` function has access to CLI args
38
- - tasks optionally use [zod](https://github.com/colinhacks/zod) schemas
39
- for `args` types, runtime parsing with helpful validation errors,
40
- and generated help docs (`gro foo --help`), with DRY co-located definitions
41
- - it's easy to call into or override any of Gro's builtin tasks,
42
- like [`gro test`](/src/lib/test.task.ts) and [`gro gen`](/src/lib/gen.task.ts) -
43
- your own versions with the same name take precedence, and you can invoke the base
44
- tasks using the `gro/` prefix, e.g. `gro gro/test`
45
- (tasks are also copy-paste friendly! just update the imports)
46
- - it's fast because it imports only the modules imported by your invoked tasks, not every task's
47
-
48
- The task runner's purpose is to provide an ergonomic interface
49
- between the CLI, build tools, and app code.
50
- As a developer, it's nice to be able to reuse TypeScript modules in every context.
51
-
52
- ## usage
53
-
54
- ### show all available tasks
55
-
56
- ```bash
57
- # This looks through `src/lib` in both the current working directory and Gro's source
58
- # for all files matching `*.task.ts|js` and logs them out with their args docs.
59
- $ gro
60
- ```
61
-
62
- The [config](./config.md) option [task_root_dirs](./config.md#task_root_dirs)
63
- tells Gro where to search for tasks.
64
-
65
- > Currently, only the first directory specified in `task_root_dirs` that's found on the filesystem
66
- > will be used to automatically discover tasks, like when running `gro` without args.
67
- > Please open an issue if you would like to see Gro be able to discover
68
- > tasks in more than one directory - it will take some reworking of internals
69
- > but it seems like the right design.
70
-
71
- ### show tasks in a directory
72
-
73
- ```bash
74
- # Logs all `*.task.ts|js` files in `src/lib/some/dir` and `gro/src/lib/some/dir`.
75
- # If no tasks are found, it displays an error.
76
- $ gro some/dir
77
- ```
78
-
79
- > To learn more about the Gro CLI path conventions,
80
- > see [the `input_paths` comments](../input_path.ts)
81
-
82
- ### run a task
83
-
84
- ```bash
85
- # This runs `src/lib/some/file.task.ts`,
86
- # or if it doesn't exist, `gro/src/lib/some/file.task.ts`.
87
- # If neither exists, it displays an error.
88
- $ gro some/file arg1 arg2 --arg3 example
89
-
90
- # This runs `gro/src/lib/some/file.task.ts` directly
91
- # without checking the current working directory,
92
- # and displays an error if it doesn't exist.
93
- $ gro gro/some/file
94
- ```
95
-
96
- ### define a task
97
-
98
- ```ts
99
- // src/lib/some/file.task.ts
100
- import type {Task} from '@ryanatkn/gro';
101
-
102
- export const task: Task = {
103
- run: async ({log, args}) => {
104
- log.info('CLI args', args); // => {_: ['arg1', 'arg2'], arg3: 'example'}
105
- await whatever();
106
- },
107
- };
108
- ```
109
-
110
- The minimum:
111
-
112
- ```ts
113
- // src/lib/some/minimal.task.ts
114
- export const task = {
115
- run: () => console.log('a minimal example'),
116
- };
117
- ```
118
-
119
- Minimum with [`Args`](#task-args):
120
-
121
- ```ts
122
- // src/lib/some/withargs.task.ts
123
- import type {Task} from '@ryanatkn/gro';
124
- import {z} from 'zod';
125
-
126
- export const Args = z
127
- .object({
128
- arg: z.number({description: 'example number arg'}).default(2),
129
- })
130
- .strict();
131
- export type Args = z.infer<typeof Args>;
132
-
133
- export const task: Task = {
134
- Args,
135
- run: async ({args}) => {
136
- args.arg; // `number` that defaults to `2`
137
- },
138
- };
139
- ```
140
-
141
- ### type `Task`
142
-
143
- ```ts
144
- import type {Task} from '@ryanatkn/gro';
145
-
146
- export interface Task<
147
- T_Args = Args, // same as `z.infer<typeof Args>`
148
- T_Args_Schema extends z.ZodType = z.ZodType,
149
- T_Return = unknown,
150
- > {
151
- run: (ctx: Task_Context<T_Args>) => Promise<T_Return>;
152
- summary?: string;
153
- Args?: T_Args_Schema;
154
- }
155
- ```
156
-
157
- ### type `Task_Context`
158
-
159
- ```ts
160
- import type {Task_Context} from '@ryanatkn/gro';
161
-
162
- export interface Task_Context<T_Args = object> {
163
- args: T_Args;
164
- config: Gro_Config;
165
- sveltekit_config: Parsed_Sveltekit_Config;
166
- log: Logger;
167
- timings: Timings;
168
- invoke_task: (task_name: string, args?: Args, config?: Gro_Config) => Promise<void>;
169
- }
170
- ```
171
-
172
- ### run a task inside another task with `invoke_task`
173
-
174
- Because Gro tasks are just functions,
175
- you can directly import them from within other tasks and run them.
176
- However, we recommend using the `invoke_task` helper
177
- for its ergonomics and automatic logging and diagnostics.
178
-
179
- The `invoke_task` helper uses Gro's task resolution rules
180
- to allow user code to override builtin tasks.
181
- For example, Gro's `check.task.ts` calls `invoke_task('test')`
182
- so that it calls your `src/lib/test.task.ts` if it exists
183
- and falls back to `gro/src/lib/test.task.ts` if not.
184
-
185
- It's less important to use `invoke_task` over explicit imports in user code
186
- because you don't need to rely on the task override rules to get desired behavior,
187
- but the logging and diagnostics it provides are nice to have.
188
-
189
- ```bash
190
- gro some/file
191
- ```
192
-
193
- ```ts
194
- // src/lib/some/file.task.ts
195
- import type {Task} from '@ryanatkn/gro';
196
-
197
- export const task: Task = {
198
- run: async ({args, invoke_task}) => {
199
- // runs `src/lib/some/file.task.ts`, automatically forwarding `args`
200
- await invoke_task('some/file');
201
- // as documented above, the following is similar but lacks nice features:
202
- // await (await import('./some/file.task.js')).run(ctx);
203
-
204
- // runs `src/lib/other/file.task.ts` and falls back to `gro/src/other/file.task.ts`,
205
- // forwarding both custom args and a different event emitter (warning: spaghetti)
206
- await invoke_task(
207
- 'other/file',
208
- {...args, optionally: 'extended'},
209
- optionalEventEmitterForSubtree,
210
- optionalDevFlagForSubtree,
211
- optionalFsForSubtree,
212
- );
213
-
214
- // runs `gro/src/lib/other/file.task.ts` directly, bypassing any local version
215
- await invoke_task('gro/other/file');
216
- },
217
- };
218
- ```
219
-
220
- ### hook into one of [Gro's builtin tasks](../docs/tasks.md)
221
-
222
- ```bash
223
- # This normally loads Gro's version of the test task at `gro/src/lib/test.task.ts`,
224
- # but projects can define `src/lib/test.task.ts` to extend or replace it.
225
- $ gro test
226
- ```
227
-
228
- ```ts
229
- // src/lib/test.task.ts
230
- import type {Task} from '@ryanatkn/gro';
231
-
232
- export const task: Task = {
233
- run: async ({args, invoke_task}) => {
234
- await doSomethingFirst();
235
- // As discussed in the `invoke_task` section above,
236
- // it's possible to `import {task as groBuiltinTestTask} from '@ryanatkn/gro/test.task.js'`
237
- // and then call `groBuiltinTestTask.run` directly,
238
- // but that loses some important benefits.
239
- // Still, the task is available to import if you want it for any reason!
240
- await invoke_task('gro/test', {...args, optionally: 'extended'}, newEventEmitterForSubtree);
241
- await emailEveryoneWithTestResults();
242
- },
243
- };
244
- ```
245
-
246
- Note that when hooking into [Gro's builtin tasks](../docs/tasks.md),
247
- like `test.task.ts` above, you don't have to call its version.
248
- You can copy/paste an existing task and customize it,
249
- rewrite a task from scratch, compose them together, or whatever is needed for each project.
250
-
251
- ### task `Args`
252
-
253
- The **`Args` property** of each `Task` (not the task context **`args` param** described above!)
254
- is an optional [zod](https://github.com/colinhacks/zod) schema.
255
- Using zod has some benefits:
256
-
257
- - automatically print helpful text on the CLI with `gro` and `gro taskname --help`
258
- - automated args parsing/validation using the schema with initialized defaults
259
- - type safety using args in tasks
260
- - concise source of truth
261
-
262
- ```ts
263
- // src/lib/dosomething.task.ts
264
- import type {Task} from '@ryanatkn/gro';
265
- import type {z} from 'zod';
266
-
267
- export const Args = z
268
- .object({
269
- _: z.array(z.string(), {description: 'rest args'}).default([]),
270
- yepyep: z.string({description: 'helpful info'}).default('ya'),
271
- okcool: z.number({description: 'that prints to the CLI'}).default(1234),
272
- maybee: z.boolean({description: 'and optional args work too'}),
273
- })
274
- .strict();
275
- export type Args = z.infer<typeof Args>;
276
-
277
- export const task: Task<Args> = {
278
- Args,
279
- run: async ({args}) => {
280
- args._; // string[]
281
- args.yepyep; // string
282
- args.okcool; // number
283
- args.maybee; // boolean | undefined
284
- },
285
- };
286
- ```
287
-
288
- Running `gro dosomething --help` prints the schema information in a friendly format.
289
-
290
- ### task args forwarding
291
-
292
- Some builtin Gro tasks call external commands like
293
- [`svelte-kit`](https://github.com/sveltejs/kit),
294
- [`vite`](https://github.com/vitejs/vite),
295
- [`uvu`](https://github.com/lukeed/uvu),
296
- [`tsc`](https://github.com/microsoft/typescript),
297
- and [`prettier`](https://github.com/prettier/prettier).
298
- Gro supports generic agnostic args forwarding to these tasks via the `--` pattern:
299
- for example, to forward args to `svelte-kit` and `uvu`, no matter which task invokes them,
300
- use `gro taskname --taskname-arg -- uvu --arg1 neat --arg2 22 -- svelte-kit --arg3`.
301
-
302
- Any number of sections separated by `--` may be defined, and the first arg
303
- that appears after each `--` is assumed to be the CLI command.
304
- If `gro taskname` or its invoked tasks don't call `uvu` or `svelte-kit`,
305
- the `--` args will be ignored.
306
-
307
- There's one special case for task args forwarding: running Gro tasks.
308
- If `gro` is the command following a `--`, e.g. the second `gro` of
309
- `gro taskname -- gro taskname2 --a --b`,
310
- then `--a` and `--b` will be forwarded to `taskname2`.
311
- Forwarded args to Gro tasks override direct args, including args to `invoke_task`,
312
- so `gro taskname --a 1 -- gro taskname --a 2` will invoke `taskname` with `{a: 2}`.
313
-
314
- The `invoke_task` helper in the task context forwards the CLI args for the specified task.
315
- CLI args take precedence over args passed directly to `invoke_task`.
316
- This may not always be the desired behavior, but it gives the user more control,
317
- because you can't change args in code you don't control.
318
-
319
- ### throwing errors
320
-
321
- If a task encounters an error, normally it should throw rather than exiting the process.
322
- This defers control to the caller, like your own parent tasks.
323
-
324
- Often, errors that tasks encounter do not need a stack trace,
325
- and we don't want the added noise to be logged.
326
- To suppress logging the stack trace for an error,
327
- throw a `Task_Error`.
328
-
329
- ```ts
330
- import {Task, Task_Error} from '@ryanatkn/gro';
331
-
332
- export const task: Task = {
333
- run: async () => {
334
- if (someErrorCondition) {
335
- throw new Task_Error('We hit a known error - ignore the stack trace!');
336
- }
337
- },
338
- };
339
- ```
340
-
341
- ## why?
342
-
343
- Gro usage on the command line (`gro <task_name_or_directory> [...flags]`)
344
- looks a lot like using `node`.
345
- What makes Gro different?
346
-
347
- - The `*.task.ts` file name convention signals to Gro that your application
348
- contains task modules that conform to some interface.
349
- This allows them to be discoverable by convention,
350
- so running `gro` displays them all without any config, and it puts generic handles on them,
351
- enabling various verbs (e.g. `run`) and
352
- structured metadata (e.g. `summary` and args schemas for docs and validation).
353
- - Tasks aren't just a script on the filesystem, they can be composed and inspected in code.
354
- Task modules do not have any side effects when imported,
355
- while Node scripts just execute when imported -
356
- their primary purpose is to cause side effects, and they're limited to the filesystem API.
357
- This is useful in many cases - for example `gro taskname --help`
358
- inspects the args schema and other metadata to print help to the console,
359
- and `gro` prints the `summary` property of each task it discovers.
360
- There's lots more to explore here, like task composition
361
- and improved DX with new capabilities.
362
- - Tasks support CLI args that are validated and typesafe
363
- via colocated Zod schemas with minimal boilerplate.
364
- - Tasks are forwarded CLI args when called via `invoke_task` in other tasks,
365
- so running `gro foo -- gro bar --a b` passes `{a: 'b'}` automatically to the `bar` task.
366
- - Module resolution differs and leverages discoverability:
367
- - When a task name is given to Gro,
368
- it first searches `src/lib/` in the current working directory and
369
- falls back to searching the Gro directory.
370
- This allows your code and CLI commands to compose Gro's builtin tasks
371
- or override them without changing how you invoke them.
372
- Gro reserves no special behavior for its own commands -
373
- `gro test`, `gro gen`, and all the rest are just tasks that all follow the same rules.
374
- (see its task at [`src/lib/test.task.ts`](/src/lib/test.task.ts)).
375
- - When a directory is given to Gro,
376
- it prints all of the tasks found inside it,
377
- both relative to the current working directory and Gro's directory.
378
- So when you run `gro` by itself,
379
- it prints all tasks available both in your project and Gro.
380
- - The trailing `.task.ts` in the file path provided to `gro` is optional,
381
- so for example, `gro foo/bar` is the same as `gro foo/bar.task.ts`, a nice convenience.
382
-
383
- ## :turtle:<sub>:turtle:</sub><sub><sub>:turtle:</sub></sub>
384
-
385
- Gro's task runner has many inspirations:
386
-
387
- - [mgutz/task](https://github.com/mgutz/task)
388
- - [Gulp](https://github.com/gulpjs/gulp)
389
- - [@mgutz](https://github.com/mgutz)' [Projmate](https://github.com/projmate/projmate-core)
390
- - [Grunt](https://github.com/gruntjs/grunt)
391
- - [npm scripts](https://docs.npmjs.com/v8/using-npm/scripts)
@@ -1,3 +0,0 @@
1
- import { type Gen } from '../gen.js';
2
- export declare const gen: Gen;
3
- //# sourceMappingURL=tasks.gen.md.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tasks.gen.md.d.ts","sourceRoot":"","sources":["../../../../src/lib/docs/tasks.gen.md.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,GAAG,EAAsB,MAAM,WAAW,CAAC;AAgBxD,eAAO,MAAM,GAAG,EAAE,GAqEjB,CAAC"}
@@ -1,66 +0,0 @@
1
- import { dirname, relative, basename } from 'node:path';
2
- import { parse_path_parts, parse_path_segments } from '@ryanatkn/belt/path.js';
3
- import { strip_start } from '@ryanatkn/belt/string.js';
4
- import { to_output_file_name } from '../gen.js';
5
- import { paths, base_path_to_path_id } from '../paths.js';
6
- import { log_error_reasons } from '../task_logging.js';
7
- import { find_tasks, load_tasks, Task_Error } from '../task.js';
8
- // This is the first simple implementation of Gro's automated docs.
9
- // It combines Gro's gen and task systems
10
- // to generate a markdown file with a summary of all of Gro's tasks.
11
- // Other projects that use Gro should be able to import this module
12
- // or other otherwise get frictionless access to this specific use case,
13
- // and they should be able to extend or customize it to any degree.
14
- // TODO display more info about each task, including a summary and params
15
- // TODO needs some cleanup and better APIs - paths are confusing and verbose!
16
- // TODO add backlinks to every document that links to this one
17
- export const gen = async ({ origin_id, log, config }) => {
18
- const found = find_tasks(['.'], [paths.lib], config);
19
- if (!found.ok) {
20
- log_error_reasons(log, found.reasons);
21
- throw new Task_Error(`Failed to generate task docs: ${found.type}`);
22
- }
23
- const found_tasks = found.value;
24
- const loaded = await load_tasks(found_tasks);
25
- if (!loaded.ok) {
26
- log_error_reasons(log, loaded.reasons);
27
- throw new Task_Error(`Failed to generate task docs: ${loaded.type}`);
28
- }
29
- const loaded_tasks = loaded.value;
30
- const tasks = loaded_tasks.modules;
31
- const root_path = parse_path_segments(paths.root).at(-1);
32
- const origin_dir = dirname(origin_id);
33
- const origin_base = basename(origin_id);
34
- const base_dir = paths.source;
35
- const relative_path = strip_start(origin_id, base_dir);
36
- const relative_dir = dirname(relative_path);
37
- // TODO should this be passed in the context, like `defaultOutputFileName`?
38
- const output_file_name = to_output_file_name(origin_base);
39
- // TODO this is GitHub-specific
40
- const root_link = `[${root_path}](/../..)`;
41
- // TODO do we want to use absolute paths instead of relative paths,
42
- // because GitHub works with them and it simplifies the code?
43
- const path_parts = parse_path_parts(relative_dir).map((relative_path_part) => `[${parse_path_segments(relative_path_part).at(-1)}](${relative(origin_dir, base_path_to_path_id(relative_path_part)) || './'})`);
44
- const breadcrumbs = '> <sub>' + [root_link, ...path_parts, output_file_name].join(' / ') + '</sub>';
45
- // TODO render the footer with the origin_id
46
- return `# tasks
47
-
48
- ${breadcrumbs}
49
-
50
- What is a \`Task\`? See [\`task.md\`](./task.md).
51
-
52
- ## all tasks
53
-
54
- ${tasks.reduce((taskList, task) => taskList +
55
- `- [${task.name}](${relative(origin_dir, task.id)})${task.mod.task.summary ? ` - ${task.mod.task.summary}` : ''}\n`, '')}
56
- ## usage
57
-
58
- \`\`\`bash
59
- $ gro some/name
60
- \`\`\`
61
-
62
- ${breadcrumbs}
63
-
64
- > <sub>generated by [${origin_base}](${origin_base})</sub>
65
- `;
66
- };
@@ -1,37 +0,0 @@
1
- # tasks
2
-
3
- > <sub>[gro](/../..) / [lib](..) / [docs](./) / tasks.md</sub>
4
-
5
- What is a `Task`? See [`task.md`](./task.md).
6
-
7
- ## all tasks
8
-
9
- - [build](../build.task.ts) - build the project
10
- - [changeset](../changeset.task.ts) - call changeset with gro patterns
11
- - [check](../check.task.ts) - check that everything is ready to commit
12
- - [clean](../clean.task.ts) - remove temporary dev and build files, and optionally prune git branches
13
- - [commit](../commit.task.ts) - commit and push to a new branch
14
- - [deploy](../deploy.task.ts) - deploy to a branch
15
- - [dev](../dev.task.ts) - start SvelteKit and other dev plugins
16
- - [format](../format.task.ts) - format source files
17
- - [gen](../gen.task.ts) - run code generation scripts
18
- - [lint](../lint.task.ts) - run eslint
19
- - [publish](../publish.task.ts) - bump version, publish to npm, and git push
20
- - [reinstall](../reinstall.task.ts) - refreshes package-lock.json with the latest and cleanest deps
21
- - [release](../release.task.ts) - publish and deploy
22
- - [resolve](../resolve.task.ts) - diagnostic that logs resolved filesystem info for the given input paths
23
- - [run](../run.task.ts) - execute a file with the loader, like `node` but works for TypeScript
24
- - [sync](../sync.task.ts) - run `gro gen`, update `package.json`, and optionally `npm i` to sync up
25
- - [test](../test.task.ts) - run tests with uvu
26
- - [typecheck](../typecheck.task.ts) - run tsc on the project without emitting any files
27
- - [upgrade](../upgrade.task.ts) - upgrade deps
28
-
29
- ## usage
30
-
31
- ```bash
32
- $ gro some/name
33
- ```
34
-
35
- > <sub>[gro](/../..) / [lib](..) / [docs](./) / tasks.md</sub>
36
-
37
- > <sub>generated by [tasks.gen.md.ts](tasks.gen.md.ts)</sub>
package/dist/docs/test.md DELETED
@@ -1,52 +0,0 @@
1
- # test
2
-
3
- Gro integrates [`uvu`](https://github.com/lukeed/uvu) for tests:
4
-
5
- ```bash
6
- gro test # run all tests with Gro's default `*.test.ts` pattern
7
- gro test thing.test somedir test/a.+b # run tests matching regexp patterns
8
- ```
9
-
10
- > Running `gro test [...args]` calls `uvu`'s `parse` and `run` helpers
11
- > inside Gro's normal [task context](/src/lib/docs/task.md) instead of using the `uvu` CLI.
12
- > Gro typically defers to a tool's CLI, so it can transparently forward args without wrapping,
13
- > but in this case `uvu` doesn't support [loaders](https://nodejs.org/api/esm.html#loaders)
14
- > for running TypeScript files directly.
15
- > `uvu` does support require hooks, but Gro prefers the loader API.
16
-
17
- Like other tasks, use `--help` to see the args info:
18
-
19
- ```bash
20
- gro test --help
21
- ```
22
-
23
- outputs:
24
-
25
- ```
26
- gro test: run tests
27
- [...args] string[] ["\\.test\\.ts$"] file patterns to test
28
- bail boolean false the bail option to uvu run, exit immediately on failure
29
- cwd string undefined the cwd option to uvu parse
30
- ignore string | string[] undefined the ignore option to uvu parse
31
- ```
32
-
33
- [`gro test`](/src/lib/test.task.ts) runs all `*.test.ts`
34
- files in your project by default using the regexp `"\\.test\\.ts$"`.
35
- So to add a new test, create a new file:
36
-
37
- ```ts
38
- // by convention, create `src/lib/thing.ts`
39
- // to test `src/lib/thing.test.ts`
40
- import {test} from 'uvu';
41
- import * as assert from 'uvu/assert';
42
-
43
- import {thing} from '$lib/thing.js';
44
-
45
- test('the thing', async () => {
46
- assert.equal(thing, {expected: true});
47
- });
48
-
49
- test.run();
50
- ```
51
-
52
- See [the `uvu` docs](https://github.com/lukeed/uvu) for more.
@@ -1,63 +0,0 @@
1
- import {dirname, relative, basename} from 'node:path';
2
- import {parse_path_parts, parse_path_segments} from '@ryanatkn/belt/path.js';
3
- import {strip_start} from '@ryanatkn/belt/string.js';
4
-
5
- import {type Gen, to_output_file_name} from '../gen.js';
6
- import {paths, base_path_to_path_id} from '../paths.js';
7
- import {search_fs} from '../search_fs.js';
8
-
9
- // TODO look at `tasks.gen.md.ts` to refactor and generalize
10
- // TODO show nested structure, not a flat list
11
- // TODO work with file types beyond markdown
12
-
13
- /**
14
- * Renders a simple index of a possibly nested directory of files.
15
- */
16
- export const gen: Gen = ({origin_id}) => {
17
- // TODO need to get this from project config or something
18
- const root_path = parse_path_segments(paths.root).at(-1);
19
-
20
- const origin_dir = dirname(origin_id);
21
- const origin_base = basename(origin_id);
22
-
23
- const base_dir = paths.source;
24
- const relative_path = strip_start(origin_id, base_dir);
25
- const relative_dir = dirname(relative_path);
26
-
27
- // TODO should this be passed in the context, like `defaultOutputFileName`?
28
- const output_file_name = to_output_file_name(origin_base);
29
-
30
- // TODO this is GitHub-specific
31
- const root_link = `[${root_path}](/../..)`;
32
- const doc_files = search_fs(origin_dir);
33
- const doc_paths: string[] = [];
34
- for (const {path} of doc_files) {
35
- if (path === output_file_name || !path.endsWith('.md')) {
36
- continue;
37
- }
38
- doc_paths.push(path);
39
- }
40
-
41
- // TODO do we want to use absolute paths instead of relative paths,
42
- // because GitHub works with them and it simplifies the code?
43
- const is_index_file = output_file_name === 'README.md';
44
- const path_parts = parse_path_parts(relative_dir).map((relative_path_part) => {
45
- const segment = parse_path_segments(relative_path_part).at(-1);
46
- return is_index_file && relative_path_part === relative_dir
47
- ? segment
48
- : `[${segment}](${relative(origin_dir, base_path_to_path_id(relative_path_part)) || './'})`;
49
- });
50
- const breadcrumbs =
51
- '> <sub>' + [root_link, ...path_parts, output_file_name].join(' / ') + '</sub>';
52
-
53
- // TODO render the footer with the origin_id
54
- return `# docs
55
-
56
- ${breadcrumbs}
57
-
58
- ${doc_paths.reduce((docList, doc) => docList + `- [${basename(doc, '.md')}](${doc})\n`, '')}
59
- ${breadcrumbs}
60
-
61
- > <sub>generated by [${origin_base}](${origin_base})</sub>
62
- `;
63
- };
@@ -1,20 +0,0 @@
1
- # docs
2
-
3
- > <sub>[gro](/../..) / [lib](..) / docs / README.md</sub>
4
-
5
- - [build](build.md)
6
- - [config](config.md)
7
- - [deploy](deploy.md)
8
- - [dev](dev.md)
9
- - [gen](gen.md)
10
- - [gro_plugin_sveltekit_app](gro_plugin_sveltekit_app.md)
11
- - [package_json](package_json.md)
12
- - [plugin](plugin.md)
13
- - [publish](publish.md)
14
- - [task](task.md)
15
- - [tasks](tasks.md)
16
- - [test](test.md)
17
-
18
- > <sub>[gro](/../..) / [lib](..) / docs / README.md</sub>
19
-
20
- > <sub>generated by [README.gen.md.ts](README.gen.md.ts)</sub>
@@ -1,41 +0,0 @@
1
- # build
2
-
3
- > these docs are for production builds, for development see [dev.md](dev.md)
4
-
5
- ## usage
6
-
7
- The `gro build` task produces outputs for production:
8
-
9
- ```bash
10
- gro build
11
- ```
12
-
13
- This runs the configured Gro plugins, `setup -> adapt -> teardown`, in production mode.
14
-
15
- If your project has a SvelteKit frontend,
16
- [the default plugin](../gro_plugin_sveltekit_app.ts) calls `vite build`,
17
- forwarding any [`-- vite [...]` args](https://vitejs.dev/config/):
18
-
19
- ```bash
20
- gro build -- vite --config my-config.js
21
- ```
22
-
23
- ## plugins
24
-
25
- `Plugin`s are objects that customize the behavior of `gro build` and `gro dev`.
26
- They try to defer to underlying tools as much as possible, and exist to glue everything together.
27
- For example, the library plugin internally uses
28
- [`svelte-package`](https://kit.svelte.dev/docs/packaging).
29
- See [plugin.md](plugin.md) to learn more.
30
-
31
- ## deploying and publishing
32
-
33
- Now that we can produce builds, how do we share them with the world?
34
-
35
- The [`gro deploy`](deploy.md) task outputs builds to a branch,
36
- like for static publishing to GitHub pages.
37
-
38
- The [`gro publish`](publish.md) task publishes packages to npm.
39
-
40
- Both of these tasks call `gro build` internally,
41
- and you can always run it manually if you're curious.