@ryanatkn/gro 0.129.6 → 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.
- package/README.md +30 -30
- package/dist/config.d.ts +3 -3
- package/dist/gen.test.js +1 -1
- package/dist/invoke.js +1 -1
- package/dist/package.js +2 -2
- package/dist/src_json.d.ts +1 -1
- package/dist/src_json.js +1 -1
- package/package.json +1 -1
- package/src/lib/config.ts +3 -3
- package/src/lib/gen.test.ts +1 -1
- package/src/lib/invoke.ts +1 -1
- package/src/lib/package.ts +2 -2
- package/src/lib/src_json.ts +1 -1
- package/dist/docs/README.gen.md.d.ts +0 -6
- package/dist/docs/README.gen.md.d.ts.map +0 -1
- package/dist/docs/README.gen.md.js +0 -53
- package/dist/docs/README.md +0 -20
- package/dist/docs/build.md +0 -41
- package/dist/docs/config.md +0 -213
- package/dist/docs/deploy.md +0 -32
- package/dist/docs/dev.md +0 -40
- package/dist/docs/gen.md +0 -269
- package/dist/docs/gro_plugin_sveltekit_app.md +0 -113
- package/dist/docs/package_json.md +0 -33
- package/dist/docs/plugin.md +0 -50
- package/dist/docs/publish.md +0 -137
- package/dist/docs/task.md +0 -391
- package/dist/docs/tasks.gen.md.d.ts +0 -3
- package/dist/docs/tasks.gen.md.d.ts.map +0 -1
- package/dist/docs/tasks.gen.md.js +0 -66
- package/dist/docs/tasks.md +0 -37
- package/dist/docs/test.md +0 -52
- package/src/lib/docs/README.gen.md.ts +0 -63
- package/src/lib/docs/README.md +0 -20
- package/src/lib/docs/build.md +0 -41
- package/src/lib/docs/config.md +0 -213
- package/src/lib/docs/deploy.md +0 -32
- package/src/lib/docs/dev.md +0 -40
- package/src/lib/docs/gen.md +0 -269
- package/src/lib/docs/gro_plugin_sveltekit_app.md +0 -113
- package/src/lib/docs/package_json.md +0 -33
- package/src/lib/docs/plugin.md +0 -50
- package/src/lib/docs/publish.md +0 -137
- package/src/lib/docs/task.md +0 -391
- package/src/lib/docs/tasks.gen.md.ts +0 -90
- package/src/lib/docs/tasks.md +0 -37
- package/src/lib/docs/test.md +0 -52
|
@@ -1,90 +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 {log_error_reasons} from '../task_logging.js';
|
|
8
|
-
import {find_tasks, load_tasks, Task_Error} from '../task.js';
|
|
9
|
-
|
|
10
|
-
// This is the first simple implementation of Gro's automated docs.
|
|
11
|
-
// It combines Gro's gen and task systems
|
|
12
|
-
// to generate a markdown file with a summary of all of Gro's tasks.
|
|
13
|
-
// Other projects that use Gro should be able to import this module
|
|
14
|
-
// or other otherwise get frictionless access to this specific use case,
|
|
15
|
-
// and they should be able to extend or customize it to any degree.
|
|
16
|
-
|
|
17
|
-
// TODO display more info about each task, including a summary and params
|
|
18
|
-
// TODO needs some cleanup and better APIs - paths are confusing and verbose!
|
|
19
|
-
// TODO add backlinks to every document that links to this one
|
|
20
|
-
|
|
21
|
-
export const gen: Gen = async ({origin_id, log, config}) => {
|
|
22
|
-
const found = find_tasks(['.'], [paths.lib], config);
|
|
23
|
-
if (!found.ok) {
|
|
24
|
-
log_error_reasons(log, found.reasons);
|
|
25
|
-
throw new Task_Error(`Failed to generate task docs: ${found.type}`);
|
|
26
|
-
}
|
|
27
|
-
const found_tasks = found.value;
|
|
28
|
-
|
|
29
|
-
const loaded = await load_tasks(found_tasks);
|
|
30
|
-
if (!loaded.ok) {
|
|
31
|
-
log_error_reasons(log, loaded.reasons);
|
|
32
|
-
throw new Task_Error(`Failed to generate task docs: ${loaded.type}`);
|
|
33
|
-
}
|
|
34
|
-
const loaded_tasks = loaded.value;
|
|
35
|
-
const tasks = loaded_tasks.modules;
|
|
36
|
-
|
|
37
|
-
const root_path = parse_path_segments(paths.root).at(-1);
|
|
38
|
-
|
|
39
|
-
const origin_dir = dirname(origin_id);
|
|
40
|
-
const origin_base = basename(origin_id);
|
|
41
|
-
|
|
42
|
-
const base_dir = paths.source;
|
|
43
|
-
const relative_path = strip_start(origin_id, base_dir);
|
|
44
|
-
const relative_dir = dirname(relative_path);
|
|
45
|
-
|
|
46
|
-
// TODO should this be passed in the context, like `defaultOutputFileName`?
|
|
47
|
-
const output_file_name = to_output_file_name(origin_base);
|
|
48
|
-
|
|
49
|
-
// TODO this is GitHub-specific
|
|
50
|
-
const root_link = `[${root_path}](/../..)`;
|
|
51
|
-
|
|
52
|
-
// TODO do we want to use absolute paths instead of relative paths,
|
|
53
|
-
// because GitHub works with them and it simplifies the code?
|
|
54
|
-
const path_parts = parse_path_parts(relative_dir).map(
|
|
55
|
-
(relative_path_part) =>
|
|
56
|
-
`[${parse_path_segments(relative_path_part).at(-1)}](${
|
|
57
|
-
relative(origin_dir, base_path_to_path_id(relative_path_part)) || './'
|
|
58
|
-
})`,
|
|
59
|
-
);
|
|
60
|
-
const breadcrumbs =
|
|
61
|
-
'> <sub>' + [root_link, ...path_parts, output_file_name].join(' / ') + '</sub>';
|
|
62
|
-
|
|
63
|
-
// TODO render the footer with the origin_id
|
|
64
|
-
return `# tasks
|
|
65
|
-
|
|
66
|
-
${breadcrumbs}
|
|
67
|
-
|
|
68
|
-
What is a \`Task\`? See [\`task.md\`](./task.md).
|
|
69
|
-
|
|
70
|
-
## all tasks
|
|
71
|
-
|
|
72
|
-
${tasks.reduce(
|
|
73
|
-
(taskList, task) =>
|
|
74
|
-
taskList +
|
|
75
|
-
`- [${task.name}](${relative(origin_dir, task.id)})${
|
|
76
|
-
task.mod.task.summary ? ` - ${task.mod.task.summary}` : ''
|
|
77
|
-
}\n`,
|
|
78
|
-
'',
|
|
79
|
-
)}
|
|
80
|
-
## usage
|
|
81
|
-
|
|
82
|
-
\`\`\`bash
|
|
83
|
-
$ gro some/name
|
|
84
|
-
\`\`\`
|
|
85
|
-
|
|
86
|
-
${breadcrumbs}
|
|
87
|
-
|
|
88
|
-
> <sub>generated by [${origin_base}](${origin_base})</sub>
|
|
89
|
-
`;
|
|
90
|
-
};
|
package/src/lib/docs/tasks.md
DELETED
|
@@ -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/src/lib/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.
|