@ryanatkn/gro 0.112.0

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 (222) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +257 -0
  3. package/dist/args.d.ts +59 -0
  4. package/dist/args.js +132 -0
  5. package/dist/args.test.d.ts +1 -0
  6. package/dist/args.test.js +43 -0
  7. package/dist/build.task.d.ts +11 -0
  8. package/dist/build.task.js +24 -0
  9. package/dist/changelog.d.ts +8 -0
  10. package/dist/changelog.js +47 -0
  11. package/dist/changelog.test.d.ts +1 -0
  12. package/dist/changelog.test.js +118 -0
  13. package/dist/changeset.task.d.ts +49 -0
  14. package/dist/changeset.task.js +141 -0
  15. package/dist/check.task.d.ts +47 -0
  16. package/dist/check.task.js +77 -0
  17. package/dist/clean.task.d.ts +26 -0
  18. package/dist/clean.task.js +41 -0
  19. package/dist/clean_fs.d.ts +9 -0
  20. package/dist/clean_fs.js +27 -0
  21. package/dist/cli.d.ts +11 -0
  22. package/dist/cli.js +25 -0
  23. package/dist/commit.task.d.ts +11 -0
  24. package/dist/commit.task.js +22 -0
  25. package/dist/config.d.ts +21 -0
  26. package/dist/config.js +42 -0
  27. package/dist/config.test.d.ts +1 -0
  28. package/dist/config.test.js +8 -0
  29. package/dist/deploy.task.d.ts +47 -0
  30. package/dist/deploy.task.js +198 -0
  31. package/dist/dev.task.d.ts +22 -0
  32. package/dist/dev.task.js +32 -0
  33. package/dist/docs/README.gen.md.d.ts +5 -0
  34. package/dist/docs/README.gen.md.js +53 -0
  35. package/dist/docs/README.md +20 -0
  36. package/dist/docs/build.md +41 -0
  37. package/dist/docs/config.md +162 -0
  38. package/dist/docs/deploy.md +32 -0
  39. package/dist/docs/dev.md +40 -0
  40. package/dist/docs/gen.md +241 -0
  41. package/dist/docs/gro_plugin_sveltekit_frontend.md +97 -0
  42. package/dist/docs/package_json.md +29 -0
  43. package/dist/docs/plugin.md +50 -0
  44. package/dist/docs/publish.md +144 -0
  45. package/dist/docs/task.md +377 -0
  46. package/dist/docs/tasks.gen.md.d.ts +2 -0
  47. package/dist/docs/tasks.gen.md.js +60 -0
  48. package/dist/docs/tasks.md +35 -0
  49. package/dist/docs/test.md +52 -0
  50. package/dist/env.d.ts +10 -0
  51. package/dist/env.js +47 -0
  52. package/dist/esbuild_helpers.d.ts +14 -0
  53. package/dist/esbuild_helpers.js +36 -0
  54. package/dist/esbuild_plugin_external_worker.d.ts +22 -0
  55. package/dist/esbuild_plugin_external_worker.js +49 -0
  56. package/dist/esbuild_plugin_svelte.d.ts +9 -0
  57. package/dist/esbuild_plugin_svelte.js +49 -0
  58. package/dist/esbuild_plugin_sveltekit_local_imports.d.ts +7 -0
  59. package/dist/esbuild_plugin_sveltekit_local_imports.js +30 -0
  60. package/dist/esbuild_plugin_sveltekit_shim_alias.d.ts +6 -0
  61. package/dist/esbuild_plugin_sveltekit_shim_alias.js +16 -0
  62. package/dist/esbuild_plugin_sveltekit_shim_app.d.ts +8 -0
  63. package/dist/esbuild_plugin_sveltekit_shim_app.js +23 -0
  64. package/dist/esbuild_plugin_sveltekit_shim_env.d.ts +10 -0
  65. package/dist/esbuild_plugin_sveltekit_shim_env.js +18 -0
  66. package/dist/format.task.d.ts +11 -0
  67. package/dist/format.task.js +24 -0
  68. package/dist/format_directory.d.ts +2 -0
  69. package/dist/format_directory.js +27 -0
  70. package/dist/format_file.d.ts +8 -0
  71. package/dist/format_file.js +42 -0
  72. package/dist/format_file.test.d.ts +1 -0
  73. package/dist/format_file.test.js +16 -0
  74. package/dist/fs.d.ts +7 -0
  75. package/dist/fs.js +19 -0
  76. package/dist/fs.test.d.ts +1 -0
  77. package/dist/fs.test.js +16 -0
  78. package/dist/gen.d.ts +57 -0
  79. package/dist/gen.js +81 -0
  80. package/dist/gen.task.d.ts +14 -0
  81. package/dist/gen.task.js +103 -0
  82. package/dist/gen.test.d.ts +1 -0
  83. package/dist/gen.test.js +239 -0
  84. package/dist/gen_module.d.ts +46 -0
  85. package/dist/gen_module.js +54 -0
  86. package/dist/gen_module.test.d.ts +1 -0
  87. package/dist/gen_module.test.js +30 -0
  88. package/dist/git.d.ts +76 -0
  89. package/dist/git.js +200 -0
  90. package/dist/git.test.d.ts +1 -0
  91. package/dist/git.test.js +18 -0
  92. package/dist/github.d.ts +35 -0
  93. package/dist/github.js +32 -0
  94. package/dist/gro.config.default.d.ts +12 -0
  95. package/dist/gro.config.default.js +31 -0
  96. package/dist/gro.d.ts +2 -0
  97. package/dist/gro.js +19 -0
  98. package/dist/gro_helpers.d.ts +43 -0
  99. package/dist/gro_helpers.js +79 -0
  100. package/dist/gro_plugin_gen.d.ts +6 -0
  101. package/dist/gro_plugin_gen.js +80 -0
  102. package/dist/gro_plugin_server.d.ts +77 -0
  103. package/dist/gro_plugin_server.js +152 -0
  104. package/dist/gro_plugin_sveltekit_app.d.ts +27 -0
  105. package/dist/gro_plugin_sveltekit_app.js +180 -0
  106. package/dist/gro_plugin_sveltekit_library.d.ts +4 -0
  107. package/dist/gro_plugin_sveltekit_library.js +42 -0
  108. package/dist/hash.d.ts +5 -0
  109. package/dist/hash.js +14 -0
  110. package/dist/hash.test.d.ts +1 -0
  111. package/dist/hash.test.js +25 -0
  112. package/dist/index.d.ts +4 -0
  113. package/dist/index.js +3 -0
  114. package/dist/input_path.d.ts +48 -0
  115. package/dist/input_path.js +161 -0
  116. package/dist/input_path.test.d.ts +1 -0
  117. package/dist/input_path.test.js +106 -0
  118. package/dist/invoke.d.ts +1 -0
  119. package/dist/invoke.js +18 -0
  120. package/dist/invoke_task.d.ts +20 -0
  121. package/dist/invoke_task.js +140 -0
  122. package/dist/lint.task.d.ts +11 -0
  123. package/dist/lint.task.js +29 -0
  124. package/dist/loader.d.ts +4 -0
  125. package/dist/loader.js +153 -0
  126. package/dist/module.d.ts +3 -0
  127. package/dist/module.js +6 -0
  128. package/dist/module.test.d.ts +1 -0
  129. package/dist/module.test.js +41 -0
  130. package/dist/modules.d.ts +60 -0
  131. package/dist/modules.js +103 -0
  132. package/dist/modules.test.d.ts +1 -0
  133. package/dist/modules.test.js +182 -0
  134. package/dist/package.d.ts +939 -0
  135. package/dist/package.gen.d.ts +7 -0
  136. package/dist/package.gen.js +26 -0
  137. package/dist/package.js +887 -0
  138. package/dist/package_json.d.ts +342 -0
  139. package/dist/package_json.js +212 -0
  140. package/dist/package_json.test.d.ts +1 -0
  141. package/dist/package_json.test.js +77 -0
  142. package/dist/path.d.ts +12 -0
  143. package/dist/path.js +8 -0
  144. package/dist/paths.d.ts +60 -0
  145. package/dist/paths.js +128 -0
  146. package/dist/paths.test.d.ts +1 -0
  147. package/dist/paths.test.js +49 -0
  148. package/dist/plugin.d.ts +36 -0
  149. package/dist/plugin.js +80 -0
  150. package/dist/plugin.test.d.ts +1 -0
  151. package/dist/plugin.test.js +54 -0
  152. package/dist/print_task.d.ts +4 -0
  153. package/dist/print_task.js +124 -0
  154. package/dist/publish.task.d.ts +32 -0
  155. package/dist/publish.task.js +125 -0
  156. package/dist/release.task.d.ts +5 -0
  157. package/dist/release.task.js +18 -0
  158. package/dist/resolve_node_specifier.d.ts +8 -0
  159. package/dist/resolve_node_specifier.js +39 -0
  160. package/dist/resolve_node_specifier.test.d.ts +1 -0
  161. package/dist/resolve_node_specifier.test.js +21 -0
  162. package/dist/resolve_specifier.d.ts +15 -0
  163. package/dist/resolve_specifier.js +51 -0
  164. package/dist/resolve_specifier.test.d.ts +1 -0
  165. package/dist/resolve_specifier.test.js +66 -0
  166. package/dist/run.task.d.ts +11 -0
  167. package/dist/run.task.js +31 -0
  168. package/dist/run_gen.d.ts +6 -0
  169. package/dist/run_gen.js +74 -0
  170. package/dist/run_gen.test.d.ts +1 -0
  171. package/dist/run_gen.test.js +182 -0
  172. package/dist/run_task.d.ts +13 -0
  173. package/dist/run_task.js +44 -0
  174. package/dist/run_task.test.d.ts +1 -0
  175. package/dist/run_task.test.js +63 -0
  176. package/dist/search_fs.d.ts +11 -0
  177. package/dist/search_fs.js +22 -0
  178. package/dist/search_fs.test.d.ts +1 -0
  179. package/dist/search_fs.test.js +46 -0
  180. package/dist/src_json.d.ts +256 -0
  181. package/dist/src_json.js +110 -0
  182. package/dist/src_json.test.d.ts +1 -0
  183. package/dist/src_json.test.js +52 -0
  184. package/dist/sveltekit_config.d.ts +36 -0
  185. package/dist/sveltekit_config.js +51 -0
  186. package/dist/sveltekit_shim_app.d.ts +10 -0
  187. package/dist/sveltekit_shim_app.js +31 -0
  188. package/dist/sveltekit_shim_app_environment.d.ts +10 -0
  189. package/dist/sveltekit_shim_app_environment.js +12 -0
  190. package/dist/sveltekit_shim_app_forms.d.ts +5 -0
  191. package/dist/sveltekit_shim_app_forms.js +13 -0
  192. package/dist/sveltekit_shim_app_navigation.d.ts +10 -0
  193. package/dist/sveltekit_shim_app_navigation.js +11 -0
  194. package/dist/sveltekit_shim_app_paths.d.ts +11 -0
  195. package/dist/sveltekit_shim_app_paths.js +6 -0
  196. package/dist/sveltekit_shim_app_stores.d.ts +6 -0
  197. package/dist/sveltekit_shim_app_stores.js +17 -0
  198. package/dist/sveltekit_shim_env.d.ts +4 -0
  199. package/dist/sveltekit_shim_env.js +23 -0
  200. package/dist/sync.task.d.ts +30 -0
  201. package/dist/sync.task.js +45 -0
  202. package/dist/task.d.ts +29 -0
  203. package/dist/task.js +17 -0
  204. package/dist/task.test.d.ts +1 -0
  205. package/dist/task.test.js +22 -0
  206. package/dist/task_module.d.ts +14 -0
  207. package/dist/task_module.js +19 -0
  208. package/dist/task_module.test.d.ts +1 -0
  209. package/dist/task_module.test.js +70 -0
  210. package/dist/test.task.d.ts +20 -0
  211. package/dist/test.task.js +43 -0
  212. package/dist/throttle.d.ts +16 -0
  213. package/dist/throttle.js +59 -0
  214. package/dist/throttle.test.d.ts +1 -0
  215. package/dist/throttle.test.js +49 -0
  216. package/dist/typecheck.task.d.ts +5 -0
  217. package/dist/typecheck.task.js +38 -0
  218. package/dist/upgrade.task.d.ts +14 -0
  219. package/dist/upgrade.task.js +37 -0
  220. package/dist/watch_dir.d.ts +30 -0
  221. package/dist/watch_dir.js +59 -0
  222. package/package.json +422 -0
@@ -0,0 +1,182 @@
1
+ import { suite } from 'uvu';
2
+ import * as assert from 'uvu/assert';
3
+ import { resolve, join } from 'node:path';
4
+ import { Logger } from '@ryanatkn/belt/log.js';
5
+ import { Timings } from '@ryanatkn/belt/timings.js';
6
+ import { run_gen } from './run_gen.js';
7
+ const log = new Logger('test__gen'); // TODO test logger?
8
+ /* test__gen */
9
+ const test__gen = suite('gen');
10
+ test__gen('basic behavior', async () => {
11
+ const source_id_a = resolve('src/foo.gen.ts');
12
+ const source_id_bc = resolve('src/bar/bc');
13
+ let file_a;
14
+ let file_b;
15
+ let file_c1;
16
+ let file_c2;
17
+ const mod_a = {
18
+ type: 'basic',
19
+ id: source_id_a,
20
+ mod: {
21
+ gen: async (ctx) => {
22
+ assert.is(ctx.origin_id, source_id_a);
23
+ if (file_a)
24
+ throw Error('Already generated file_a');
25
+ file_a = {
26
+ filename: 'foo.ts',
27
+ content: 'file_a',
28
+ };
29
+ return file_a.content; // here we return the shorthand version
30
+ },
31
+ },
32
+ };
33
+ const mod_b = {
34
+ type: 'basic',
35
+ id: join(source_id_bc, 'mod_b.gen.ts'),
36
+ mod: {
37
+ gen: async (ctx) => {
38
+ assert.is(ctx.origin_id, mod_b.id);
39
+ if (file_b)
40
+ throw Error('Already generated file_b');
41
+ file_b = {
42
+ filename: 'output_b.ts',
43
+ content: 'file_b',
44
+ };
45
+ return file_b;
46
+ },
47
+ },
48
+ };
49
+ const mod_c = {
50
+ type: 'basic',
51
+ id: join(source_id_bc, 'mod_c.gen.ts'),
52
+ mod: {
53
+ gen: async (ctx) => {
54
+ assert.is(ctx.origin_id, mod_c.id);
55
+ if (file_c1)
56
+ throw Error('Already generated file_c1');
57
+ if (file_c2)
58
+ throw Error('Already generated file_c2');
59
+ file_c1 = {
60
+ filename: 'output_c1.ts',
61
+ content: 'file_c1',
62
+ };
63
+ file_c2 = {
64
+ filename: 'output_c2.ts',
65
+ content: 'file_c2',
66
+ };
67
+ return [file_c1, file_c2];
68
+ },
69
+ },
70
+ };
71
+ const gen_modules_by_input_path = [mod_a, mod_b, mod_c];
72
+ const gen_results = await run_gen(gen_modules_by_input_path, log, new Timings(), async (content, opts) => opts.filepath.endsWith('output_b.ts') ? `${content}/*FORMATTED*/` : content);
73
+ assert.is(gen_results.input_count, 3);
74
+ assert.is(gen_results.output_count, 4);
75
+ assert.is(gen_results.successes.length, 3);
76
+ assert.is(gen_results.failures.length, 0);
77
+ assert.is(gen_results.results.length, 3);
78
+ assert.is(gen_results.results[0], gen_results.successes[0]);
79
+ assert.is(gen_results.results[1], gen_results.successes[1]);
80
+ assert.is(gen_results.results[2], gen_results.successes[2]);
81
+ const result_a = gen_results.results[0];
82
+ assert.ok(result_a?.ok);
83
+ assert.ok(file_a);
84
+ assert.equal(result_a.files, [
85
+ {
86
+ content: file_a.content,
87
+ id: join(mod_a.id, '../', file_a.filename),
88
+ origin_id: mod_a.id,
89
+ format: true,
90
+ },
91
+ ]);
92
+ const result_b = gen_results.results[1];
93
+ assert.ok(result_b?.ok);
94
+ assert.ok(file_b);
95
+ assert.equal(result_b.files, [
96
+ {
97
+ content: `${file_b.content}/*FORMATTED*/`,
98
+ id: join(mod_b.id, '../', file_b.filename),
99
+ origin_id: mod_b.id,
100
+ format: true,
101
+ },
102
+ ]);
103
+ const result_c = gen_results.results[2];
104
+ assert.ok(result_c?.ok);
105
+ assert.ok(file_c1);
106
+ assert.ok(file_c2);
107
+ assert.equal(result_c.files, [
108
+ {
109
+ content: file_c1.content,
110
+ id: join(mod_c.id, '../', file_c1.filename),
111
+ origin_id: mod_c.id,
112
+ format: true,
113
+ },
114
+ {
115
+ content: file_c2.content,
116
+ id: join(mod_c.id, '../', file_c2.filename),
117
+ origin_id: mod_c.id,
118
+ format: true,
119
+ },
120
+ ]);
121
+ });
122
+ test__gen('failing gen function', async () => {
123
+ const source_id_a = resolve('src/foo.gen.ts');
124
+ const source_idB = resolve('src/bar/baz');
125
+ let file_b; // no file_a because it's never generated
126
+ let genError; // this error should be passed through to the result
127
+ // This is the failing gen module.
128
+ // It's ordered first to test that its failure doesn't cascade.
129
+ const mod_a = {
130
+ type: 'basic',
131
+ id: source_id_a,
132
+ mod: {
133
+ gen: async () => {
134
+ genError = Error('This fails for testing');
135
+ throw genError;
136
+ },
137
+ },
138
+ };
139
+ const mod_b = {
140
+ type: 'basic',
141
+ id: join(source_idB, 'mod_b.gen.ts'),
142
+ mod: {
143
+ gen: async (ctx) => {
144
+ assert.is(ctx.origin_id, mod_b.id);
145
+ if (file_b)
146
+ throw Error('Already generated file_b');
147
+ file_b = {
148
+ filename: 'output_b.ts',
149
+ content: 'file_b',
150
+ };
151
+ return file_b;
152
+ },
153
+ },
154
+ };
155
+ const gen_modules_by_input_path = [mod_a, mod_b];
156
+ const gen_results = await run_gen(gen_modules_by_input_path, log, new Timings());
157
+ assert.is(gen_results.input_count, 2);
158
+ assert.is(gen_results.output_count, 1);
159
+ assert.is(gen_results.successes.length, 1);
160
+ assert.is(gen_results.failures.length, 1);
161
+ assert.is(gen_results.results.length, 2);
162
+ assert.is(gen_results.results[0], gen_results.failures[0]);
163
+ assert.is(gen_results.results[1], gen_results.successes[0]);
164
+ const result_a = gen_results.results[0];
165
+ assert.ok(result_a);
166
+ assert.ok(!result_a?.ok);
167
+ assert.ok(result_a.reason);
168
+ assert.ok(result_a.error);
169
+ const result_b = gen_results.results[1];
170
+ assert.ok(result_b?.ok);
171
+ assert.ok(file_b);
172
+ assert.equal(result_b.files, [
173
+ {
174
+ content: file_b.content,
175
+ id: join(mod_b.id, '../', file_b.filename),
176
+ origin_id: mod_b.id,
177
+ format: true,
178
+ },
179
+ ]);
180
+ });
181
+ test__gen.run();
182
+ /* test__gen */
@@ -0,0 +1,13 @@
1
+ import type { Task_Module_Meta } from './task_module.js';
2
+ import { type Args } from './args.js';
3
+ import type { invoke_task as base_invoke_task } from './invoke_task.js';
4
+ import type { Gro_Config } from './config.js';
5
+ export type Run_Task_Result = {
6
+ ok: true;
7
+ output: unknown;
8
+ } | {
9
+ ok: false;
10
+ reason: string;
11
+ error: Error;
12
+ };
13
+ export declare const run_task: (task_meta: Task_Module_Meta, unparsed_args: Args, invoke_task: typeof base_invoke_task, config: Gro_Config, timings: Timings) => Promise<Run_Task_Result>;
@@ -0,0 +1,44 @@
1
+ import { cyan, red } from 'kleur/colors';
2
+ import { print_log_label, System_Logger } from '@ryanatkn/belt/log.js';
3
+ import { parse_args } from './args.js';
4
+ import { print_task_help } from './print_task.js';
5
+ import { Task_Error } from './task.js';
6
+ export const run_task = async (task_meta, unparsed_args, invoke_task, config, timings) => {
7
+ const { task } = task_meta.mod;
8
+ const log = new System_Logger(print_log_label(task_meta.name));
9
+ if (unparsed_args.help) {
10
+ print_task_help(log, task_meta);
11
+ return { ok: true, output: null };
12
+ }
13
+ // Parse and validate args.
14
+ let args = unparsed_args;
15
+ if (task.Args) {
16
+ const parsed = parse_args(unparsed_args, task.Args);
17
+ if (!parsed.success) {
18
+ log.error(red(`Args validation failed:`), '\n', parsed.error.format());
19
+ throw new Task_Error(`Task args failed validation`);
20
+ }
21
+ args = parsed.data;
22
+ }
23
+ // Run the task.
24
+ let output;
25
+ try {
26
+ output = await task.run({
27
+ args,
28
+ config,
29
+ log,
30
+ timings,
31
+ invoke_task: (invoked_task_name, invoked_args = {}, invoked_config) => invoke_task(invoked_task_name, invoked_args, invoked_config || config, timings),
32
+ });
33
+ }
34
+ catch (err) {
35
+ return {
36
+ ok: false,
37
+ reason: red(err?.constructor?.name === 'Task_Error'
38
+ ? err.message
39
+ : `Unexpected error running task ${cyan(task_meta.name)}. If this is unexpected try running \`npm i\` and \`gro clean\`.`),
40
+ error: err,
41
+ };
42
+ }
43
+ return { ok: true, output };
44
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,63 @@
1
+ import { test } from 'uvu';
2
+ import * as assert from 'uvu/assert';
3
+ import { Timings } from '@ryanatkn/belt/timings.js';
4
+ import { run_task } from './run_task.js';
5
+ import { load_config } from './config.js';
6
+ test('passes args and returns output', async () => {
7
+ const args = { a: 1, _: [] };
8
+ const result = await run_task({
9
+ name: 'testTask',
10
+ id: 'foo/testTask',
11
+ mod: {
12
+ task: {
13
+ run: ({ args }) => Promise.resolve(args),
14
+ },
15
+ },
16
+ }, args, () => Promise.resolve(), await load_config(), new Timings());
17
+ assert.ok(result.ok);
18
+ assert.is(result.output, args);
19
+ });
20
+ test('invokes a sub task', async () => {
21
+ const args = { a: 1, _: [] };
22
+ let invoked_task_name;
23
+ let invoked_args;
24
+ const result = await run_task({
25
+ name: 'testTask',
26
+ id: 'foo/testTask',
27
+ mod: {
28
+ task: {
29
+ run: async ({ args, invoke_task }) => {
30
+ await invoke_task('bar/testTask', args);
31
+ return args;
32
+ },
33
+ },
34
+ },
35
+ }, args, async (invoking_task_name, invoking_args) => {
36
+ invoked_task_name = invoking_task_name;
37
+ invoked_args = invoking_args;
38
+ }, await load_config(), new Timings());
39
+ assert.ok(result.ok);
40
+ assert.is(invoked_task_name, 'bar/testTask');
41
+ assert.is(invoked_args, args);
42
+ assert.is(result.output, args);
43
+ });
44
+ test('failing task', async () => {
45
+ let err;
46
+ const result = await run_task({
47
+ name: 'testTask',
48
+ id: 'foo/testTask',
49
+ mod: {
50
+ task: {
51
+ run: async () => {
52
+ err = Error();
53
+ throw err;
54
+ },
55
+ },
56
+ },
57
+ }, { _: [] }, async () => { }, // eslint-disable-line @typescript-eslint/no-empty-function
58
+ await load_config(), new Timings());
59
+ assert.ok(!result.ok);
60
+ assert.ok(result.reason);
61
+ assert.is(result.error, err);
62
+ });
63
+ test.run();
@@ -0,0 +1,11 @@
1
+ import { compare_simple_map_entries } from '@ryanatkn/belt/map.js';
2
+ import type { Path_Stats, Path_Filter } from './path.js';
3
+ export interface Search_Fs_Options {
4
+ filter?: Path_Filter;
5
+ /**
6
+ * Pass `null` to speed things up at the risk of volatile ordering.
7
+ */
8
+ sort?: typeof compare_simple_map_entries | null;
9
+ files_only?: boolean;
10
+ }
11
+ export declare const search_fs: (dir: string, options?: Search_Fs_Options) => Promise<Map<string, Path_Stats>>;
@@ -0,0 +1,22 @@
1
+ import glob from 'tiny-glob';
2
+ import { stat } from 'node:fs/promises';
3
+ import { sort_map, compare_simple_map_entries } from '@ryanatkn/belt/map.js';
4
+ import { strip_end, strip_start } from '@ryanatkn/belt/string.js';
5
+ import { EMPTY_OBJECT } from '@ryanatkn/belt/object.js';
6
+ import { exists } from './fs.js';
7
+ export const search_fs = async (dir, options = EMPTY_OBJECT) => {
8
+ const { filter, sort = compare_simple_map_entries, files_only = true } = options;
9
+ const final_dir = strip_end(dir, '/');
10
+ if (!(await exists(final_dir)))
11
+ return new Map();
12
+ const globbed = await glob(final_dir + '/**/*', { absolute: true, filesOnly: files_only });
13
+ const paths = new Map();
14
+ await Promise.all(globbed.map(async (g) => {
15
+ const path = strip_start(g, final_dir + '/');
16
+ const stats = await stat(g);
17
+ if (!filter || stats.isDirectory() || filter(path, stats)) {
18
+ paths.set(path, stats);
19
+ }
20
+ }));
21
+ return sort ? sort_map(paths, sort) : paths;
22
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,46 @@
1
+ import { suite } from 'uvu';
2
+ import * as assert from 'uvu/assert';
3
+ import { search_fs } from './search_fs.js';
4
+ import { paths } from './paths.js';
5
+ /* test__search_fs */
6
+ const test__search_fs = suite('search_fs');
7
+ test__search_fs('basic behavior', async () => {
8
+ const ignored_path = 'test1.foo.ts';
9
+ let has_ignored_path = false;
10
+ const result = await search_fs('./src/fixtures', {
11
+ filter: (path) => {
12
+ if (!has_ignored_path)
13
+ has_ignored_path = path.endsWith(ignored_path);
14
+ return !path.endsWith(ignored_path);
15
+ },
16
+ sort: (a, b) => -a[0].localeCompare(b[0]),
17
+ });
18
+ assert.ok(has_ignored_path); // makes sure the test isn't wrong
19
+ assert.equal(Array.from(result.keys()), [
20
+ 'test2.foo.ts',
21
+ 'test_ts.ts',
22
+ 'test_task_module.task_fixture.ts',
23
+ 'test_js.js',
24
+ 'test_invalid_task_module.ts',
25
+ 'test_file.other.ext',
26
+ 'test_failing_task_module.ts',
27
+ 'some_test_side_effect.ts',
28
+ 'some_test_json.json',
29
+ 'some_test_exports3.ts',
30
+ 'some_test_exports2.ts',
31
+ 'some_test_exports.ts',
32
+ 'modules/some_test_ts.ts',
33
+ 'modules/Some_Test_Svelte.svelte',
34
+ 'modules/some_test_json.json',
35
+ 'modules/some_test_css.css',
36
+ 'changelog_example.md',
37
+ 'changelog_cache.json',
38
+ 'baz2/test2.baz.ts',
39
+ 'baz1/test1.baz.ts',
40
+ 'bar2/test2.bar.ts',
41
+ 'bar1/test1.bar.ts',
42
+ ].map((f) => paths.source + 'fixtures/' + f));
43
+ });
44
+ // TODO more tests
45
+ test__search_fs.run();
46
+ /* test__search_fs */
@@ -0,0 +1,256 @@
1
+ import { z } from 'zod';
2
+ import { type Package_Json, type Package_Json_Exports } from './package_json.js';
3
+ export declare const Src_Module_Declaration: z.ZodObject<{
4
+ name: z.ZodString;
5
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
6
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
7
+ name: z.ZodString;
8
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
9
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
10
+ name: z.ZodString;
11
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
12
+ }, z.ZodTypeAny, "passthrough">>;
13
+ export type Src_Module_Declaration = z.infer<typeof Src_Module_Declaration>;
14
+ export declare const Src_Module: z.ZodObject<{
15
+ path: z.ZodString;
16
+ declarations: z.ZodArray<z.ZodObject<{
17
+ name: z.ZodString;
18
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
19
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
20
+ name: z.ZodString;
21
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
22
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
23
+ name: z.ZodString;
24
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
25
+ }, z.ZodTypeAny, "passthrough">>, "many">;
26
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
27
+ path: z.ZodString;
28
+ declarations: z.ZodArray<z.ZodObject<{
29
+ name: z.ZodString;
30
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
31
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
32
+ name: z.ZodString;
33
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
34
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
35
+ name: z.ZodString;
36
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
37
+ }, z.ZodTypeAny, "passthrough">>, "many">;
38
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
39
+ path: z.ZodString;
40
+ declarations: z.ZodArray<z.ZodObject<{
41
+ name: z.ZodString;
42
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
43
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
44
+ name: z.ZodString;
45
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
46
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
47
+ name: z.ZodString;
48
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
49
+ }, z.ZodTypeAny, "passthrough">>, "many">;
50
+ }, z.ZodTypeAny, "passthrough">>;
51
+ export type Src_Module = z.infer<typeof Src_Module>;
52
+ export declare const Src_Modules: z.ZodRecord<z.ZodString, z.ZodObject<{
53
+ path: z.ZodString;
54
+ declarations: z.ZodArray<z.ZodObject<{
55
+ name: z.ZodString;
56
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
57
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
58
+ name: z.ZodString;
59
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
60
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
61
+ name: z.ZodString;
62
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
63
+ }, z.ZodTypeAny, "passthrough">>, "many">;
64
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
65
+ path: z.ZodString;
66
+ declarations: z.ZodArray<z.ZodObject<{
67
+ name: z.ZodString;
68
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
69
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
70
+ name: z.ZodString;
71
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
72
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
73
+ name: z.ZodString;
74
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
75
+ }, z.ZodTypeAny, "passthrough">>, "many">;
76
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
77
+ path: z.ZodString;
78
+ declarations: z.ZodArray<z.ZodObject<{
79
+ name: z.ZodString;
80
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
81
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
82
+ name: z.ZodString;
83
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
84
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
85
+ name: z.ZodString;
86
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
87
+ }, z.ZodTypeAny, "passthrough">>, "many">;
88
+ }, z.ZodTypeAny, "passthrough">>>;
89
+ export type Src_Modules = z.infer<typeof Src_Modules>;
90
+ /**
91
+ * @see https://github.com/ryanatkn/gro/blob/main/src/lib/docs/gro_plugin_sveltekit_app.md#well-known-src
92
+ */
93
+ export declare const Src_Json: z.ZodIntersection<z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodObject<{
94
+ name: z.ZodString;
95
+ version: z.ZodString;
96
+ modules: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodObject<{
97
+ path: z.ZodString;
98
+ declarations: z.ZodArray<z.ZodObject<{
99
+ name: z.ZodString;
100
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
101
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
102
+ name: z.ZodString;
103
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
104
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
105
+ name: z.ZodString;
106
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
107
+ }, z.ZodTypeAny, "passthrough">>, "many">;
108
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
109
+ path: z.ZodString;
110
+ declarations: z.ZodArray<z.ZodObject<{
111
+ name: z.ZodString;
112
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
113
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
114
+ name: z.ZodString;
115
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
116
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
117
+ name: z.ZodString;
118
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
119
+ }, z.ZodTypeAny, "passthrough">>, "many">;
120
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
121
+ path: z.ZodString;
122
+ declarations: z.ZodArray<z.ZodObject<{
123
+ name: z.ZodString;
124
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
125
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
126
+ name: z.ZodString;
127
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
128
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
129
+ name: z.ZodString;
130
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
131
+ }, z.ZodTypeAny, "passthrough">>, "many">;
132
+ }, z.ZodTypeAny, "passthrough">>>, any, Record<string, z.objectInputType<{
133
+ path: z.ZodString;
134
+ declarations: z.ZodArray<z.ZodObject<{
135
+ name: z.ZodString;
136
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
137
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
138
+ name: z.ZodString;
139
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
140
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
141
+ name: z.ZodString;
142
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
143
+ }, z.ZodTypeAny, "passthrough">>, "many">;
144
+ }, z.ZodTypeAny, "passthrough">>>>;
145
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
146
+ name: z.ZodString;
147
+ version: z.ZodString;
148
+ modules: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodObject<{
149
+ path: z.ZodString;
150
+ declarations: z.ZodArray<z.ZodObject<{
151
+ name: z.ZodString;
152
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
153
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
154
+ name: z.ZodString;
155
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
156
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
157
+ name: z.ZodString;
158
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
159
+ }, z.ZodTypeAny, "passthrough">>, "many">;
160
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
161
+ path: z.ZodString;
162
+ declarations: z.ZodArray<z.ZodObject<{
163
+ name: z.ZodString;
164
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
165
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
166
+ name: z.ZodString;
167
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
168
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
169
+ name: z.ZodString;
170
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
171
+ }, z.ZodTypeAny, "passthrough">>, "many">;
172
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
173
+ path: z.ZodString;
174
+ declarations: z.ZodArray<z.ZodObject<{
175
+ name: z.ZodString;
176
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
177
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
178
+ name: z.ZodString;
179
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
180
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
181
+ name: z.ZodString;
182
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
183
+ }, z.ZodTypeAny, "passthrough">>, "many">;
184
+ }, z.ZodTypeAny, "passthrough">>>, any, Record<string, z.objectInputType<{
185
+ path: z.ZodString;
186
+ declarations: z.ZodArray<z.ZodObject<{
187
+ name: z.ZodString;
188
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
189
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
190
+ name: z.ZodString;
191
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
192
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
193
+ name: z.ZodString;
194
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
195
+ }, z.ZodTypeAny, "passthrough">>, "many">;
196
+ }, z.ZodTypeAny, "passthrough">>>>;
197
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
198
+ name: z.ZodString;
199
+ version: z.ZodString;
200
+ modules: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodObject<{
201
+ path: z.ZodString;
202
+ declarations: z.ZodArray<z.ZodObject<{
203
+ name: z.ZodString;
204
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
205
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
206
+ name: z.ZodString;
207
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
208
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
209
+ name: z.ZodString;
210
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
211
+ }, z.ZodTypeAny, "passthrough">>, "many">;
212
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
213
+ path: z.ZodString;
214
+ declarations: z.ZodArray<z.ZodObject<{
215
+ name: z.ZodString;
216
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
217
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
218
+ name: z.ZodString;
219
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
220
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
221
+ name: z.ZodString;
222
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
223
+ }, z.ZodTypeAny, "passthrough">>, "many">;
224
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
225
+ path: z.ZodString;
226
+ declarations: z.ZodArray<z.ZodObject<{
227
+ name: z.ZodString;
228
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
229
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
230
+ name: z.ZodString;
231
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
232
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
233
+ name: z.ZodString;
234
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
235
+ }, z.ZodTypeAny, "passthrough">>, "many">;
236
+ }, z.ZodTypeAny, "passthrough">>>, any, Record<string, z.objectInputType<{
237
+ path: z.ZodString;
238
+ declarations: z.ZodArray<z.ZodObject<{
239
+ name: z.ZodString;
240
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
241
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
242
+ name: z.ZodString;
243
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
244
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
245
+ name: z.ZodString;
246
+ kind: z.ZodNullable<z.ZodEnum<["type", "function", "variable", "class"]>>;
247
+ }, z.ZodTypeAny, "passthrough">>, "many">;
248
+ }, z.ZodTypeAny, "passthrough">>>>;
249
+ }, z.ZodTypeAny, "passthrough">>>;
250
+ export type Src_Json = z.infer<typeof Src_Json>;
251
+ export interface Map_Src_Json {
252
+ (src_json: Src_Json): Src_Json | null | Promise<Src_Json | null>;
253
+ }
254
+ export declare const create_src_json: (package_json: Package_Json, log?: any, lib_path?: string) => Promise<Src_Json>;
255
+ export declare const serialize_src_json: (src_json: Src_Json) => string;
256
+ export declare const to_src_modules: (exports: Package_Json_Exports | undefined, log?: any, lib_path?: string) => Promise<Src_Modules | undefined>;