@ryanatkn/gro 0.176.0 → 0.177.1

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 (211) hide show
  1. package/dist/args.d.ts +5 -5
  2. package/dist/args.d.ts.map +1 -1
  3. package/dist/build.task.d.ts.map +1 -1
  4. package/dist/build.task.js +2 -2
  5. package/dist/build_cache.d.ts +12 -12
  6. package/dist/build_cache.d.ts.map +1 -1
  7. package/dist/build_cache.js +4 -4
  8. package/dist/changelog.d.ts +2 -2
  9. package/dist/changelog.d.ts.map +1 -1
  10. package/dist/changelog.js +1 -1
  11. package/dist/changeset.task.d.ts.map +1 -1
  12. package/dist/changeset.task.js +9 -9
  13. package/dist/changeset_helpers.d.ts +4 -4
  14. package/dist/changeset_helpers.d.ts.map +1 -1
  15. package/dist/changeset_helpers.js +2 -2
  16. package/dist/check.task.d.ts.map +1 -1
  17. package/dist/check.task.js +3 -3
  18. package/dist/clean.task.js +2 -2
  19. package/dist/cli.d.ts +6 -6
  20. package/dist/cli.d.ts.map +1 -1
  21. package/dist/commit.task.js +2 -2
  22. package/dist/deploy.task.d.ts.map +1 -1
  23. package/dist/deploy.task.js +13 -13
  24. package/dist/dev.task.d.ts +2 -2
  25. package/dist/dev.task.d.ts.map +1 -1
  26. package/dist/disknode.d.ts +4 -4
  27. package/dist/disknode.d.ts.map +1 -1
  28. package/dist/esbuild_helpers.d.ts +2 -2
  29. package/dist/esbuild_helpers.d.ts.map +1 -1
  30. package/dist/esbuild_plugin_external_worker.d.ts +5 -5
  31. package/dist/esbuild_plugin_external_worker.d.ts.map +1 -1
  32. package/dist/esbuild_plugin_svelte.d.ts +4 -4
  33. package/dist/esbuild_plugin_svelte.d.ts.map +1 -1
  34. package/dist/esbuild_plugin_sveltekit_shim_alias.d.ts +2 -2
  35. package/dist/esbuild_plugin_sveltekit_shim_alias.d.ts.map +1 -1
  36. package/dist/esbuild_plugin_sveltekit_shim_app.d.ts +5 -5
  37. package/dist/esbuild_plugin_sveltekit_shim_app.d.ts.map +1 -1
  38. package/dist/esbuild_plugin_sveltekit_shim_env.d.ts +2 -2
  39. package/dist/esbuild_plugin_sveltekit_shim_env.d.ts.map +1 -1
  40. package/dist/filer.d.ts +15 -15
  41. package/dist/filer.d.ts.map +1 -1
  42. package/dist/filer.js +2 -2
  43. package/dist/format.task.d.ts.map +1 -1
  44. package/dist/format.task.js +2 -2
  45. package/dist/format_directory.d.ts +2 -2
  46. package/dist/format_directory.d.ts.map +1 -1
  47. package/dist/gen.d.ts +73 -73
  48. package/dist/gen.d.ts.map +1 -1
  49. package/dist/gen.js +1 -1
  50. package/dist/gen.task.d.ts.map +1 -1
  51. package/dist/gen.task.js +8 -8
  52. package/dist/gen_helpers.d.ts +4 -4
  53. package/dist/gen_helpers.d.ts.map +1 -1
  54. package/dist/gen_helpers.js +1 -1
  55. package/dist/github.d.ts +4 -4
  56. package/dist/github.d.ts.map +1 -1
  57. package/dist/github.js +3 -3
  58. package/dist/gro.config.default.d.ts +2 -2
  59. package/dist/gro.config.default.d.ts.map +1 -1
  60. package/dist/gro_config.d.ts +25 -25
  61. package/dist/gro_config.d.ts.map +1 -1
  62. package/dist/gro_config.js +2 -2
  63. package/dist/gro_helpers.d.ts +2 -2
  64. package/dist/gro_helpers.d.ts.map +1 -1
  65. package/dist/gro_plugin_gen.d.ts +3 -3
  66. package/dist/gro_plugin_gen.d.ts.map +1 -1
  67. package/dist/gro_plugin_gen.js +2 -2
  68. package/dist/gro_plugin_server.d.ts +7 -7
  69. package/dist/gro_plugin_server.d.ts.map +1 -1
  70. package/dist/gro_plugin_sveltekit_app.d.ts +10 -10
  71. package/dist/gro_plugin_sveltekit_app.d.ts.map +1 -1
  72. package/dist/gro_plugin_sveltekit_app.js +2 -2
  73. package/dist/gro_plugin_sveltekit_library.d.ts +4 -4
  74. package/dist/gro_plugin_sveltekit_library.d.ts.map +1 -1
  75. package/dist/gro_plugin_sveltekit_library.js +2 -2
  76. package/dist/index.d.ts +3 -3
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +1 -1
  79. package/dist/input_path.d.ts +30 -30
  80. package/dist/input_path.d.ts.map +1 -1
  81. package/dist/input_path.js +2 -2
  82. package/dist/invoke.js +1 -1
  83. package/dist/invoke_task.d.ts +3 -3
  84. package/dist/invoke_task.d.ts.map +1 -1
  85. package/dist/invoke_task.js +4 -4
  86. package/dist/lint.task.d.ts.map +1 -1
  87. package/dist/lint.task.js +2 -2
  88. package/dist/modules.d.ts +20 -20
  89. package/dist/modules.d.ts.map +1 -1
  90. package/dist/modules.js +2 -2
  91. package/dist/package_json.d.ts +16 -16
  92. package/dist/package_json.d.ts.map +1 -1
  93. package/dist/package_json.js +6 -6
  94. package/dist/parse_exports.d.ts +7 -7
  95. package/dist/parse_exports.d.ts.map +1 -1
  96. package/dist/parse_exports.js +3 -3
  97. package/dist/parse_exports_context.d.ts +3 -3
  98. package/dist/parse_exports_context.d.ts.map +1 -1
  99. package/dist/parse_exports_context.js +1 -1
  100. package/dist/parse_imports.d.ts +3 -3
  101. package/dist/parse_imports.d.ts.map +1 -1
  102. package/dist/parse_imports.js +2 -2
  103. package/dist/paths.d.ts +6 -6
  104. package/dist/paths.d.ts.map +1 -1
  105. package/dist/plugin.d.ts +13 -13
  106. package/dist/plugin.d.ts.map +1 -1
  107. package/dist/plugin.js +1 -1
  108. package/dist/publish.task.d.ts.map +1 -1
  109. package/dist/publish.task.js +12 -12
  110. package/dist/reinstall.task.d.ts.map +1 -1
  111. package/dist/reinstall.task.js +4 -4
  112. package/dist/resolve_specifier.d.ts +4 -4
  113. package/dist/resolve_specifier.d.ts.map +1 -1
  114. package/dist/run.task.d.ts.map +1 -1
  115. package/dist/run.task.js +9 -6
  116. package/dist/run_gen.d.ts +4 -4
  117. package/dist/run_gen.d.ts.map +1 -1
  118. package/dist/run_task.d.ts +4 -4
  119. package/dist/run_task.d.ts.map +1 -1
  120. package/dist/run_task.js +3 -3
  121. package/dist/search_fs.d.ts +6 -6
  122. package/dist/search_fs.d.ts.map +1 -1
  123. package/dist/src_json.d.ts +6 -6
  124. package/dist/src_json.d.ts.map +1 -1
  125. package/dist/src_json.js +3 -3
  126. package/dist/svelte_config.d.ts +3 -3
  127. package/dist/svelte_config.d.ts.map +1 -1
  128. package/dist/sveltekit_helpers.d.ts +5 -5
  129. package/dist/sveltekit_helpers.d.ts.map +1 -1
  130. package/dist/sveltekit_helpers.js +5 -5
  131. package/dist/sveltekit_shim_app.d.ts +2 -2
  132. package/dist/sveltekit_shim_app.d.ts.map +1 -1
  133. package/dist/sync.task.d.ts.map +1 -1
  134. package/dist/sync.task.js +2 -2
  135. package/dist/task.d.ts +54 -54
  136. package/dist/task.d.ts.map +1 -1
  137. package/dist/task.js +3 -3
  138. package/dist/task_logging.d.ts +3 -3
  139. package/dist/task_logging.d.ts.map +1 -1
  140. package/dist/test.task.d.ts.map +1 -1
  141. package/dist/test.task.js +4 -4
  142. package/dist/typecheck.task.d.ts.map +1 -1
  143. package/dist/typecheck.task.js +4 -4
  144. package/dist/upgrade.task.d.ts.map +1 -1
  145. package/dist/upgrade.task.js +5 -5
  146. package/dist/watch_dir.d.ts +10 -10
  147. package/dist/watch_dir.d.ts.map +1 -1
  148. package/package.json +3 -3
  149. package/src/lib/args.ts +9 -9
  150. package/src/lib/build.task.ts +2 -2
  151. package/src/lib/build_cache.ts +18 -18
  152. package/src/lib/changelog.ts +10 -10
  153. package/src/lib/changeset.task.ts +16 -16
  154. package/src/lib/changeset_helpers.ts +4 -4
  155. package/src/lib/check.task.ts +3 -3
  156. package/src/lib/clean.task.ts +2 -2
  157. package/src/lib/cli.ts +7 -7
  158. package/src/lib/commit.task.ts +2 -2
  159. package/src/lib/deploy.task.ts +15 -15
  160. package/src/lib/dev.task.ts +2 -2
  161. package/src/lib/disknode.ts +4 -4
  162. package/src/lib/esbuild_helpers.ts +2 -2
  163. package/src/lib/esbuild_plugin_external_worker.ts +7 -7
  164. package/src/lib/esbuild_plugin_svelte.ts +4 -4
  165. package/src/lib/esbuild_plugin_sveltekit_shim_alias.ts +2 -2
  166. package/src/lib/esbuild_plugin_sveltekit_shim_app.ts +5 -5
  167. package/src/lib/esbuild_plugin_sveltekit_shim_env.ts +2 -2
  168. package/src/lib/filer.ts +35 -35
  169. package/src/lib/format.task.ts +2 -2
  170. package/src/lib/format_directory.ts +2 -2
  171. package/src/lib/gen.task.ts +19 -19
  172. package/src/lib/gen.ts +85 -85
  173. package/src/lib/gen_helpers.ts +17 -17
  174. package/src/lib/github.ts +6 -6
  175. package/src/lib/gro.config.default.ts +2 -2
  176. package/src/lib/gro_config.ts +28 -28
  177. package/src/lib/gro_helpers.ts +2 -2
  178. package/src/lib/gro_plugin_gen.ts +5 -5
  179. package/src/lib/gro_plugin_server.ts +8 -8
  180. package/src/lib/gro_plugin_sveltekit_app.ts +15 -15
  181. package/src/lib/gro_plugin_sveltekit_library.ts +6 -6
  182. package/src/lib/index.ts +3 -3
  183. package/src/lib/input_path.ts +56 -56
  184. package/src/lib/invoke.ts +2 -2
  185. package/src/lib/invoke_task.ts +7 -7
  186. package/src/lib/lint.task.ts +2 -2
  187. package/src/lib/modules.ts +31 -31
  188. package/src/lib/package_json.ts +27 -27
  189. package/src/lib/parse_exports.ts +15 -15
  190. package/src/lib/parse_exports_context.ts +9 -9
  191. package/src/lib/parse_imports.ts +6 -6
  192. package/src/lib/paths.ts +6 -6
  193. package/src/lib/plugin.ts +17 -17
  194. package/src/lib/publish.task.ts +13 -13
  195. package/src/lib/reinstall.task.ts +4 -4
  196. package/src/lib/resolve_specifier.ts +5 -5
  197. package/src/lib/run.task.ts +10 -6
  198. package/src/lib/run_gen.ts +14 -14
  199. package/src/lib/run_task.ts +8 -8
  200. package/src/lib/search_fs.ts +13 -13
  201. package/src/lib/src_json.ts +13 -13
  202. package/src/lib/svelte_config.ts +2 -2
  203. package/src/lib/sveltekit_helpers.ts +12 -12
  204. package/src/lib/sveltekit_shim_app.ts +3 -3
  205. package/src/lib/sync.task.ts +2 -2
  206. package/src/lib/task.ts +63 -63
  207. package/src/lib/task_logging.ts +11 -11
  208. package/src/lib/test.task.ts +4 -4
  209. package/src/lib/typecheck.task.ts +4 -4
  210. package/src/lib/upgrade.task.ts +7 -7
  211. package/src/lib/watch_dir.ts +10 -10
package/src/lib/gen.ts CHANGED
@@ -5,73 +5,73 @@ import type {Result} from '@ryanatkn/belt/result.js';
5
5
  import type {Timings} from '@ryanatkn/belt/timings.js';
6
6
  import {styleText as st} from 'node:util';
7
7
  import {existsSync} from 'node:fs';
8
- import type {Path_Id} from '@ryanatkn/belt/path.js';
8
+ import type {PathId} from '@ryanatkn/belt/path.js';
9
9
 
10
10
  import {print_path} from './paths.ts';
11
- import type {Gro_Config} from './gro_config.ts';
12
- import type {Parsed_Svelte_Config} from './svelte_config.ts';
13
- import {load_modules, type Load_Modules_Failure, type Module_Meta} from './modules.ts';
11
+ import type {GroConfig} from './gro_config.ts';
12
+ import type {ParsedSvelteConfig} from './svelte_config.ts';
13
+ import {load_modules, type LoadModulesFailure, type ModuleMeta} from './modules.ts';
14
14
  import {
15
- Input_Path,
15
+ InputPath,
16
16
  resolve_input_files,
17
17
  resolve_input_paths,
18
- type Resolved_Input_File,
19
- type Resolved_Input_Path,
18
+ type ResolvedInputFile,
19
+ type ResolvedInputPath,
20
20
  } from './input_path.ts';
21
21
  import {search_fs} from './search_fs.ts';
22
22
  import type {Filer} from './filer.ts';
23
- import type {Invoke_Task} from './task.ts';
23
+ import type {InvokeTask} from './task.ts';
24
24
 
25
25
  export const GEN_FILE_PATTERN_TEXT = 'gen';
26
26
  export const GEN_FILE_PATTERN = '.' + GEN_FILE_PATTERN_TEXT + '.';
27
27
 
28
28
  export const is_gen_path = (path: string): boolean => path.includes(GEN_FILE_PATTERN);
29
29
 
30
- export interface Gen_Result {
31
- origin_id: Path_Id;
32
- files: Array<Gen_File>;
30
+ export interface GenResult {
31
+ origin_id: PathId;
32
+ files: Array<GenFile>;
33
33
  }
34
- export interface Gen_File {
35
- id: Path_Id;
34
+ export interface GenFile {
35
+ id: PathId;
36
36
  content: string;
37
- origin_id: Path_Id;
37
+ origin_id: PathId;
38
38
  format: boolean;
39
39
  }
40
40
 
41
- export type Gen_Dependencies = 'all' | Gen_Dependencies_Config | Gen_Dependencies_Resolver;
41
+ export type GenDependencies = 'all' | GenDependenciesConfig | GenDependenciesResolver;
42
42
 
43
- export interface Gen_Dependencies_Config {
43
+ export interface GenDependenciesConfig {
44
44
  patterns?: Array<RegExp>;
45
- files?: Array<Path_Id>;
45
+ files?: Array<PathId>;
46
46
  }
47
47
 
48
- export type Gen_Dependencies_Resolver = (
49
- ctx: Gen_Context,
50
- ) => Gen_Dependencies_Config | 'all' | null | Promise<Gen_Dependencies_Config | 'all' | null>;
48
+ export type GenDependenciesResolver = (
49
+ ctx: GenContext,
50
+ ) => GenDependenciesConfig | 'all' | null | Promise<GenDependenciesConfig | 'all' | null>;
51
51
 
52
- export type Gen = Gen_Function | Gen_Config;
52
+ export type Gen = GenFunction | GenConfig;
53
53
 
54
- export type Gen_Function = (ctx: Gen_Context) => Raw_Gen_Result | Promise<Raw_Gen_Result>;
54
+ export type GenFunction = (ctx: GenContext) => RawGenResult | Promise<RawGenResult>;
55
55
 
56
- // TODO add a Gen_Config_Raw variant and change `normalize_gen_config` to `gen_cook_config`
57
- export interface Gen_Config {
58
- generate: Gen_Function;
59
- dependencies?: Gen_Dependencies;
56
+ // TODO add a GenConfigRaw variant and change `normalize_gen_config` to `gen_cook_config`
57
+ export interface GenConfig {
58
+ generate: GenFunction;
59
+ dependencies?: GenDependencies;
60
60
  // TODO think about what could be added
61
61
  // cache?: boolean;
62
62
  }
63
63
 
64
- export interface Gen_Context {
65
- config: Gro_Config;
66
- svelte_config: Parsed_Svelte_Config;
64
+ export interface GenContext {
65
+ config: GroConfig;
66
+ svelte_config: ParsedSvelteConfig;
67
67
  filer: Filer;
68
68
  log: Logger;
69
69
  timings: Timings;
70
- invoke_task: Invoke_Task;
70
+ invoke_task: InvokeTask;
71
71
  /**
72
72
  * Same as `import.meta.url` but in path form.
73
73
  */
74
- origin_id: Path_Id;
74
+ origin_id: PathId;
75
75
  /**
76
76
  * The `origin_id` relative to the root dir.
77
77
  */
@@ -81,12 +81,12 @@ export interface Gen_Context {
81
81
  * Only available when resolving dependencies dynamically.
82
82
  * `undefined` during actual generation.
83
83
  */
84
- changed_file_id: Path_Id | undefined;
84
+ changed_file_id: PathId | undefined;
85
85
  }
86
86
 
87
87
  // TODO consider other return data - metadata? effects? non-file build artifacts?
88
- export type Raw_Gen_Result = string | Raw_Gen_File | null | Array<Raw_Gen_Result>;
89
- export interface Raw_Gen_File {
88
+ export type RawGenResult = string | RawGenFile | null | Array<RawGenResult>;
89
+ export interface RawGenFile {
90
90
  content: string;
91
91
  // Defaults to file name without the `.gen`, and can be a relative path.
92
92
  // TODO maybe support a transform pattern or callback fn? like '[stem].thing.[ext]'
@@ -94,37 +94,37 @@ export interface Raw_Gen_File {
94
94
  format?: boolean; // defaults to `true`
95
95
  }
96
96
 
97
- export interface Gen_Results {
98
- results: Array<Genfile_Module_Result>;
99
- successes: Array<Genfile_Module_Result_Success>;
100
- failures: Array<Genfile_Module_Result_Failure>;
97
+ export interface GenResults {
98
+ results: Array<GenfileModuleResult>;
99
+ successes: Array<GenfileModuleResultSuccess>;
100
+ failures: Array<GenfileModuleResultFailure>;
101
101
  input_count: number;
102
102
  output_count: number;
103
103
  elapsed: number;
104
104
  }
105
- export type Genfile_Module_Result = Genfile_Module_Result_Success | Genfile_Module_Result_Failure;
106
- export interface Genfile_Module_Result_Success {
105
+ export type GenfileModuleResult = GenfileModuleResultSuccess | GenfileModuleResultFailure;
106
+ export interface GenfileModuleResultSuccess {
107
107
  ok: true;
108
- id: Path_Id;
109
- files: Array<Gen_File>;
108
+ id: PathId;
109
+ files: Array<GenFile>;
110
110
  elapsed: number;
111
111
  }
112
- export interface Genfile_Module_Result_Failure {
112
+ export interface GenfileModuleResultFailure {
113
113
  ok: false;
114
- id: Path_Id;
114
+ id: PathId;
115
115
  reason: string;
116
116
  error: Error;
117
117
  elapsed: number;
118
118
  }
119
119
 
120
- export const to_gen_result = (origin_id: Path_Id, raw_result: Raw_Gen_Result): Gen_Result => {
120
+ export const to_gen_result = (origin_id: PathId, raw_result: RawGenResult): GenResult => {
121
121
  return {
122
122
  origin_id,
123
123
  files: to_gen_files(origin_id, raw_result),
124
124
  };
125
125
  };
126
126
 
127
- const to_gen_files = (origin_id: Path_Id, raw_result: Raw_Gen_Result): Array<Gen_File> => {
127
+ const to_gen_files = (origin_id: PathId, raw_result: RawGenResult): Array<GenFile> => {
128
128
  if (raw_result === null) {
129
129
  return [];
130
130
  } else if (typeof raw_result === 'string') {
@@ -137,13 +137,13 @@ const to_gen_files = (origin_id: Path_Id, raw_result: Raw_Gen_Result): Array<Gen
137
137
  return [to_gen_file(origin_id, raw_result)];
138
138
  };
139
139
 
140
- const to_gen_file = (origin_id: Path_Id, raw_gen_file: Raw_Gen_File): Gen_File => {
140
+ const to_gen_file = (origin_id: PathId, raw_gen_file: RawGenFile): GenFile => {
141
141
  const {content, filename, format = true} = raw_gen_file;
142
142
  const id = to_output_file_id(origin_id, filename);
143
143
  return {id, content, origin_id, format};
144
144
  };
145
145
 
146
- const to_output_file_id = (origin_id: Path_Id, raw_file_name: string | undefined): string => {
146
+ const to_output_file_id = (origin_id: PathId, raw_file_name: string | undefined): string => {
147
147
  if (raw_file_name === '') {
148
148
  throw Error(`Output file name cannot be an empty string`);
149
149
  }
@@ -186,7 +186,7 @@ export const to_output_file_name = (filename: string): string => {
186
186
  return final_parts.join('.');
187
187
  };
188
188
 
189
- const validate_gen_files = (files: Array<Gen_File>) => {
189
+ const validate_gen_files = (files: Array<GenFile>) => {
190
190
  const ids = new Set();
191
191
  for (const file of files) {
192
192
  if (ids.has(file.id)) {
@@ -196,30 +196,30 @@ const validate_gen_files = (files: Array<Gen_File>) => {
196
196
  }
197
197
  };
198
198
 
199
- export type Analyzed_Gen_Result =
199
+ export type AnalyzedGenResult =
200
200
  | {
201
- file: Gen_File;
201
+ file: GenFile;
202
202
  existing_content: string;
203
203
  is_new: false;
204
204
  has_changed: boolean;
205
205
  }
206
206
  | {
207
- file: Gen_File;
207
+ file: GenFile;
208
208
  existing_content: null;
209
209
  is_new: true;
210
210
  has_changed: true;
211
211
  };
212
212
 
213
213
  export const analyze_gen_results = (
214
- gen_results: Gen_Results,
215
- ): Promise<Array<Analyzed_Gen_Result>> =>
214
+ gen_results: GenResults,
215
+ ): Promise<Array<AnalyzedGenResult>> =>
216
216
  Promise.all(
217
217
  gen_results.successes
218
218
  .map((result) => result.files.map((file) => analyze_gen_result(file)))
219
219
  .flat(),
220
220
  );
221
221
 
222
- export const analyze_gen_result = async (file: Gen_File): Promise<Analyzed_Gen_Result> => {
222
+ export const analyze_gen_result = async (file: GenFile): Promise<AnalyzedGenResult> => {
223
223
  if (!existsSync(file.id)) {
224
224
  return {
225
225
  file,
@@ -238,8 +238,8 @@ export const analyze_gen_result = async (file: Gen_File): Promise<Analyzed_Gen_R
238
238
  };
239
239
 
240
240
  export const write_gen_results = async (
241
- gen_results: Gen_Results,
242
- analyzed_gen_results: Array<Analyzed_Gen_Result>,
241
+ gen_results: GenResults,
242
+ analyzed_gen_results: Array<AnalyzedGenResult>,
243
243
  log: Logger,
244
244
  ): Promise<void> => {
245
245
  await Promise.all(
@@ -265,26 +265,26 @@ export const write_gen_results = async (
265
265
  );
266
266
  };
267
267
 
268
- export interface Found_Genfiles {
269
- resolved_input_files: Array<Resolved_Input_File>;
270
- resolved_input_files_by_root_dir: Map<Path_Id, Array<Resolved_Input_File>>;
271
- resolved_input_paths: Array<Resolved_Input_Path>;
268
+ export interface FoundGenfiles {
269
+ resolved_input_files: Array<ResolvedInputFile>;
270
+ resolved_input_files_by_root_dir: Map<PathId, Array<ResolvedInputFile>>;
271
+ resolved_input_paths: Array<ResolvedInputPath>;
272
272
  }
273
273
 
274
- export type Find_Genfiles_Result = Result<{value: Found_Genfiles}, Find_Genfiles_Failure>;
275
- export type Find_Genfiles_Failure =
274
+ export type FindGenfilesResult = Result<{value: FoundGenfiles}, FindGenfilesFailure>;
275
+ export type FindGenfilesFailure =
276
276
  | {
277
277
  type: 'unmapped_input_paths';
278
- unmapped_input_paths: Array<Input_Path>;
279
- resolved_input_paths: Array<Resolved_Input_Path>;
278
+ unmapped_input_paths: Array<InputPath>;
279
+ resolved_input_paths: Array<ResolvedInputPath>;
280
280
  reasons: Array<string>;
281
281
  }
282
282
  | {
283
283
  type: 'input_directories_with_no_files';
284
- input_directories_with_no_files: Array<Input_Path>;
285
- resolved_input_files: Array<Resolved_Input_File>;
286
- resolved_input_files_by_root_dir: Map<Path_Id, Array<Resolved_Input_File>>;
287
- resolved_input_paths: Array<Resolved_Input_Path>;
284
+ input_directories_with_no_files: Array<InputPath>;
285
+ resolved_input_files: Array<ResolvedInputFile>;
286
+ resolved_input_files_by_root_dir: Map<PathId, Array<ResolvedInputFile>>;
287
+ resolved_input_paths: Array<ResolvedInputPath>;
288
288
  reasons: Array<string>;
289
289
  };
290
290
 
@@ -292,11 +292,11 @@ export type Find_Genfiles_Failure =
292
292
  * Finds modules from input paths. (see `src/lib/input_path.ts` for more)
293
293
  */
294
294
  export const find_genfiles = (
295
- input_paths: Array<Input_Path>,
296
- root_dirs: Array<Path_Id>,
297
- config: Gro_Config,
295
+ input_paths: Array<InputPath>,
296
+ root_dirs: Array<PathId>,
297
+ config: GroConfig,
298
298
  timings?: Timings,
299
- ): Find_Genfiles_Result => {
299
+ ): FindGenfilesResult => {
300
300
  const extensions: Array<string> = [GEN_FILE_PATTERN];
301
301
 
302
302
  // Check which extension variation works - if it's a directory, prefer others first!
@@ -357,28 +357,28 @@ export const find_genfiles = (
357
357
  };
358
358
  };
359
359
 
360
- export interface Genfile_Module {
360
+ export interface GenfileModule {
361
361
  gen: Gen;
362
362
  }
363
363
 
364
- export type Genfile_Module_Meta = Module_Meta<Genfile_Module>;
364
+ export type GenfileModuleMeta = ModuleMeta<GenfileModule>;
365
365
 
366
- export interface Loaded_Genfiles {
367
- modules: Array<Genfile_Module_Meta>;
368
- found_genfiles: Found_Genfiles;
366
+ export interface LoadedGenfiles {
367
+ modules: Array<GenfileModuleMeta>;
368
+ found_genfiles: FoundGenfiles;
369
369
  }
370
370
 
371
- export type Load_Genfiles_Result = Result<{value: Loaded_Genfiles}, Load_Genfiles_Failure>;
372
- export type Load_Genfiles_Failure = Load_Modules_Failure<Genfile_Module_Meta>;
371
+ export type LoadGenfilesResult = Result<{value: LoadedGenfiles}, LoadGenfilesFailure>;
372
+ export type LoadGenfilesFailure = LoadModulesFailure<GenfileModuleMeta>;
373
373
 
374
374
  export const load_genfiles = async (
375
- found_genfiles: Found_Genfiles,
375
+ found_genfiles: FoundGenfiles,
376
376
  timings?: Timings,
377
- ): Promise<Load_Genfiles_Result> => {
377
+ ): Promise<LoadGenfilesResult> => {
378
378
  const loaded_modules = await load_modules(
379
379
  found_genfiles.resolved_input_files,
380
380
  validate_gen_module,
381
- (resolved_input_file, mod): Genfile_Module_Meta => ({id: resolved_input_file.id, mod}),
381
+ (resolved_input_file, mod): GenfileModuleMeta => ({id: resolved_input_file.id, mod}),
382
382
  timings,
383
383
  );
384
384
  if (!loaded_modules.ok) {
@@ -390,7 +390,7 @@ export const load_genfiles = async (
390
390
  };
391
391
  };
392
392
 
393
- export const validate_gen_module = (mod: Record<string, any>): mod is Genfile_Module => {
393
+ export const validate_gen_module = (mod: Record<string, any>): mod is GenfileModule => {
394
394
  if (typeof mod.gen === 'function') return true;
395
395
  if (typeof mod.gen === 'object' && mod.gen !== null && typeof mod.gen.generate === 'function') {
396
396
  return true;
@@ -398,5 +398,5 @@ export const validate_gen_module = (mod: Record<string, any>): mod is Genfile_Mo
398
398
  return false;
399
399
  };
400
400
 
401
- export const normalize_gen_config = (gen: Gen): Gen_Config =>
401
+ export const normalize_gen_config = (gen: Gen): GenConfig =>
402
402
  typeof gen === 'function' ? {generate: gen} : gen;
@@ -1,17 +1,17 @@
1
1
  import {resolve} from 'node:path';
2
2
  import type {Logger} from '@ryanatkn/belt/log.js';
3
3
  import type {Timings} from '@ryanatkn/belt/timings.js';
4
- import type {Path_Id} from '@ryanatkn/belt/path.js';
4
+ import type {PathId} from '@ryanatkn/belt/path.js';
5
5
 
6
- import type {Gro_Config} from './gro_config.ts';
6
+ import type {GroConfig} from './gro_config.ts';
7
7
  import {filter_dependents, type Filer} from './filer.ts';
8
- import type {Invoke_Task} from './task.ts';
8
+ import type {InvokeTask} from './task.ts';
9
9
  import {
10
10
  normalize_gen_config,
11
11
  validate_gen_module,
12
- type Gen_Context,
13
- type Gen_Dependencies,
14
- type Gen_Dependencies_Config,
12
+ type GenContext,
13
+ type GenDependencies,
14
+ type GenDependenciesConfig,
15
15
  } from './gen.ts';
16
16
  import {default_svelte_config} from './svelte_config.ts';
17
17
  import {to_root_path} from './paths.ts';
@@ -21,13 +21,13 @@ import {load_module} from './modules.ts';
21
21
  * Check if a file change should trigger a gen file.
22
22
  */
23
23
  export const should_trigger_gen = async (
24
- gen_file_id: Path_Id,
25
- changed_file_id: Path_Id,
26
- config: Gro_Config,
24
+ gen_file_id: PathId,
25
+ changed_file_id: PathId,
26
+ config: GroConfig,
27
27
  filer: Filer,
28
28
  log: Logger,
29
29
  timings: Timings,
30
- invoke_task: Invoke_Task,
30
+ invoke_task: InvokeTask,
31
31
  ): Promise<boolean> => {
32
32
  // Always trigger if the gen file itself changed
33
33
  const is_self_change = gen_file_id === changed_file_id;
@@ -74,14 +74,14 @@ export const should_trigger_gen = async (
74
74
  */
75
75
  const resolve_gen_dependencies = async (
76
76
  gen_file_id: string,
77
- changed_file_id: Path_Id | undefined,
77
+ changed_file_id: PathId | undefined,
78
78
  bust_cache: boolean,
79
- config: Gro_Config,
79
+ config: GroConfig,
80
80
  filer: Filer,
81
81
  log: Logger,
82
82
  timings: Timings,
83
- invoke_task: Invoke_Task,
84
- ): Promise<Gen_Dependencies_Config | 'all' | null> => {
83
+ invoke_task: InvokeTask,
84
+ ): Promise<GenDependenciesConfig | 'all' | null> => {
85
85
  const result = await load_module(gen_file_id, validate_gen_module, bust_cache);
86
86
 
87
87
  if (!result.ok) {
@@ -96,9 +96,9 @@ const resolve_gen_dependencies = async (
96
96
  return null;
97
97
  }
98
98
 
99
- let dependencies: Gen_Dependencies | null = gen_config.dependencies;
99
+ let dependencies: GenDependencies | null = gen_config.dependencies;
100
100
  if (typeof dependencies === 'function') {
101
- const gen_ctx: Gen_Context = {
101
+ const gen_ctx: GenContext = {
102
102
  config,
103
103
  svelte_config: default_svelte_config,
104
104
  filer,
@@ -116,7 +116,7 @@ const resolve_gen_dependencies = async (
116
116
  return dependencies;
117
117
  }
118
118
 
119
- // At this point, dependencies is either 'all' or Gen_Dependencies_Config
119
+ // At this point, dependencies is either 'all' or GenDependenciesConfig
120
120
  // For static dependencies, also normalize empty objects
121
121
  if (!dependencies.patterns?.length && !dependencies.files?.length) {
122
122
  return null;
package/src/lib/github.ts CHANGED
@@ -2,13 +2,13 @@
2
2
  // for now it's just calling a single endpoint so we do it manually
3
3
  // and we specify just the types we need
4
4
 
5
- import {Fetch_Value_Cache, fetch_value} from '@ryanatkn/belt/fetch.js';
5
+ import {FetchValueCache, fetch_value} from '@ryanatkn/belt/fetch.js';
6
6
  import type {Logger} from '@ryanatkn/belt/log.js';
7
7
  import {z} from 'zod';
8
8
 
9
9
  export const GITHUB_REPO_MATCHER = /.+github.com\/(.+)\/(.+)/;
10
10
 
11
- export const Github_Pull_Request = z.looseObject({
11
+ export const GithubPullRequest = z.looseObject({
12
12
  url: z.string(),
13
13
  id: z.number(),
14
14
  html_url: z.string(),
@@ -17,7 +17,7 @@ export const Github_Pull_Request = z.looseObject({
17
17
  login: z.string(),
18
18
  }),
19
19
  });
20
- export type Github_Pull_Request = z.infer<typeof Github_Pull_Request>;
20
+ export type GithubPullRequest = z.infer<typeof GithubPullRequest>;
21
21
 
22
22
  /**
23
23
  * @see https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#list-pull-requests-associated-with-a-commit
@@ -28,14 +28,14 @@ export const github_fetch_commit_prs = async (
28
28
  commit_sha: string,
29
29
  token?: string,
30
30
  log?: Logger,
31
- cache?: Fetch_Value_Cache,
31
+ cache?: FetchValueCache,
32
32
  api_version?: string,
33
- ): Promise<Array<Github_Pull_Request> | null> => {
33
+ ): Promise<Array<GithubPullRequest> | null> => {
34
34
  const headers = api_version ? new Headers({'x-github-api-version': api_version}) : undefined;
35
35
  const url = `https://api.github.com/repos/${owner}/${repo}/commits/${commit_sha}/pulls`;
36
36
  const fetched = await fetch_value(url, {
37
37
  request: {headers},
38
- parse: (v: Array<any>) => v.map((p) => Github_Pull_Request.parse(p)),
38
+ parse: (v: Array<any>) => v.map((p) => GithubPullRequest.parse(p)),
39
39
  token,
40
40
  cache,
41
41
  return_early_from_cache: true,
@@ -1,4 +1,4 @@
1
- import type {Create_Gro_Config} from './gro_config.ts';
1
+ import type {CreateGroConfig} from './gro_config.ts';
2
2
  import {gro_plugin_sveltekit_library} from './gro_plugin_sveltekit_library.ts';
3
3
  import {has_server, gro_plugin_server} from './gro_plugin_server.ts';
4
4
  import {gro_plugin_sveltekit_app} from './gro_plugin_sveltekit_app.ts';
@@ -17,7 +17,7 @@ import {load_package_json} from './package_json.ts';
17
17
  * - if `src/lib`, assumes a Node library - respects `KitConfig.kit.files.lib`
18
18
  * - if `src/lib/server/server.ts`, assumes a Node server - needs config
19
19
  */
20
- const config: Create_Gro_Config = async (cfg, svelte_config) => {
20
+ const config: CreateGroConfig = async (cfg, svelte_config) => {
21
21
  const package_json = load_package_json(); // TODO gets wastefully loaded by some plugins, maybe put in plugin/task context? how does that interact with `map_package_json`?
22
22
 
23
23
  const [has_server_result, has_sveltekit_library_result, has_sveltekit_app_result] =
@@ -1,7 +1,7 @@
1
1
  import {join, resolve} from 'node:path';
2
2
  import {existsSync} from 'node:fs';
3
3
  import {identity} from '@ryanatkn/belt/function.js';
4
- import type {Path_Filter, Path_Id} from '@ryanatkn/belt/path.js';
4
+ import type {PathFilter, PathId} from '@ryanatkn/belt/path.js';
5
5
  import {json_stringify_deterministic} from '@ryanatkn/belt/json.js';
6
6
 
7
7
  import {GRO_DIST_DIR, IS_THIS_GRO, paths} from './paths.ts';
@@ -15,9 +15,9 @@ import {
15
15
  SVELTEKIT_DIST_DIRNAME,
16
16
  } from './constants.ts';
17
17
  import create_default_config from './gro.config.default.ts';
18
- import type {Create_Config_Plugins} from './plugin.ts';
19
- import type {Package_Json_Mapper} from './package_json.ts';
20
- import type {Parsed_Svelte_Config} from './svelte_config.ts';
18
+ import type {CreateConfigPlugins} from './plugin.ts';
19
+ import type {PackageJsonMapper} from './package_json.ts';
20
+ import type {ParsedSvelteConfig} from './svelte_config.ts';
21
21
  import {to_hash} from './hash.ts';
22
22
 
23
23
  /**
@@ -32,27 +32,27 @@ export const EMPTY_BUILD_CACHE_CONFIG_HASH =
32
32
  * This is exposed to users in places like tasks and genfiles.
33
33
  * @see https://github.com/ryanatkn/gro/blob/main/src/docs/config.md
34
34
  */
35
- export interface Gro_Config extends Raw_Gro_Config {
35
+ export interface GroConfig extends RawGroConfig {
36
36
  /**
37
37
  * @see https://github.com/ryanatkn/gro/blob/main/src/docs/plugin.md
38
38
  */
39
- plugins: Create_Config_Plugins;
39
+ plugins: CreateConfigPlugins;
40
40
  /**
41
41
  * Maps the project's `package.json` before writing it to the filesystem.
42
42
  * The `package_json` argument may be mutated, but the return value is what's used by the caller.
43
43
  * Returning `null` is a no-op for the caller.
44
44
  */
45
- map_package_json: Package_Json_Mapper | null;
45
+ map_package_json: PackageJsonMapper | null;
46
46
  /**
47
47
  * The root directories to search for tasks given implicit relative input paths.
48
48
  * Defaults to `./src/lib`, then the cwd, then the Gro package dist.
49
49
  */
50
- task_root_dirs: Array<Path_Id>;
50
+ task_root_dirs: Array<PathId>;
51
51
  /**
52
52
  * When searching the filsystem for tasks and genfiles,
53
53
  * directories and files are included if they pass all of these filters.
54
54
  */
55
- search_filters: Array<Path_Filter>;
55
+ search_filters: Array<PathFilter>;
56
56
  /**
57
57
  * The CLI to use that's compatible with `node`.
58
58
  */
@@ -67,21 +67,21 @@ export interface Gro_Config extends Raw_Gro_Config {
67
67
  * SHA-256 hash of the user's `build_cache_config` from `gro.config.ts`.
68
68
  * This is computed during config normalization and the raw value is immediately deleted.
69
69
  * If no `build_cache_config` was provided, this is the hash of an empty string.
70
- * @see Raw_Gro_Config.build_cache_config
70
+ * @see RawGroConfig.build_cache_config
71
71
  */
72
72
  build_cache_config_hash: string;
73
73
  }
74
74
 
75
75
  /**
76
- * The relaxed variant of `Gro_Config` that users can provide via `gro.config.ts`.
77
- * Superset of `Gro_Config`.
76
+ * The relaxed variant of `GroConfig` that users can provide via `gro.config.ts`.
77
+ * Superset of `GroConfig`.
78
78
  * @see https://github.com/ryanatkn/gro/blob/main/src/docs/config.md
79
79
  */
80
- export interface Raw_Gro_Config {
81
- plugins?: Create_Config_Plugins;
82
- map_package_json?: Package_Json_Mapper | null;
80
+ export interface RawGroConfig {
81
+ plugins?: CreateConfigPlugins;
82
+ map_package_json?: PackageJsonMapper | null;
83
83
  task_root_dirs?: Array<string>;
84
- search_filters?: Path_Filter | Array<Path_Filter> | null;
84
+ search_filters?: PathFilter | Array<PathFilter> | null;
85
85
  js_cli?: string;
86
86
  pm_cli?: string;
87
87
  /**
@@ -104,12 +104,12 @@ export interface Raw_Gro_Config {
104
104
  | (() => Record<string, unknown> | Promise<Record<string, unknown>>);
105
105
  }
106
106
 
107
- export type Create_Gro_Config = (
108
- base_config: Gro_Config,
109
- svelte_config?: Parsed_Svelte_Config,
110
- ) => Raw_Gro_Config | Promise<Raw_Gro_Config>;
107
+ export type CreateGroConfig = (
108
+ base_config: GroConfig,
109
+ svelte_config?: ParsedSvelteConfig,
110
+ ) => RawGroConfig | Promise<RawGroConfig>;
111
111
 
112
- export const create_empty_gro_config = (): Gro_Config => ({
112
+ export const create_empty_gro_config = (): GroConfig => ({
113
113
  plugins: () => [],
114
114
  map_package_json: identity,
115
115
  task_root_dirs: [
@@ -127,7 +127,7 @@ export const create_empty_gro_config = (): Gro_Config => ({
127
127
  /**
128
128
  * The regexp used by default to exclude directories and files
129
129
  * when searching the filesystem for tasks and genfiles.
130
- * Customize via `search_filters` in the `Gro_Config`.
130
+ * Customize via `search_filters` in the `GroConfig`.
131
131
  * See the test cases for the exact behavior.
132
132
  */
133
133
  export const SEARCH_EXCLUDER_DEFAULT = new RegExp(
@@ -145,11 +145,11 @@ export const SEARCH_EXCLUDER_DEFAULT = new RegExp(
145
145
  export const EXPORTS_EXCLUDER_DEFAULT = /(\.md|\.(test|ignore)\.|\/(test|ignore)\/)/;
146
146
 
147
147
  /**
148
- * Transforms a `Raw_Gro_Config` to the more strict `Gro_Config`.
148
+ * Transforms a `RawGroConfig` to the more strict `GroConfig`.
149
149
  * This allows users to provide a more relaxed config.
150
150
  * Hashes the `build_cache_config` and deletes the raw value for security.
151
151
  */
152
- export const cook_gro_config = async (raw_config: Raw_Gro_Config): Promise<Gro_Config> => {
152
+ export const cook_gro_config = async (raw_config: RawGroConfig): Promise<GroConfig> => {
153
153
  const empty_config = create_empty_gro_config();
154
154
 
155
155
  // All of the raw config properties are optional,
@@ -198,11 +198,11 @@ export const cook_gro_config = async (raw_config: Raw_Gro_Config): Promise<Gro_C
198
198
  };
199
199
  };
200
200
 
201
- export interface Gro_Config_Module {
202
- readonly default: Raw_Gro_Config | Create_Gro_Config;
201
+ export interface GroConfigModule {
202
+ readonly default: RawGroConfig | CreateGroConfig;
203
203
  }
204
204
 
205
- export const load_gro_config = async (dir = paths.root): Promise<Gro_Config> => {
205
+ export const load_gro_config = async (dir = paths.root): Promise<GroConfig> => {
206
206
  const default_config = await cook_gro_config(
207
207
  await create_default_config(create_empty_gro_config()),
208
208
  );
@@ -228,7 +228,7 @@ export const load_gro_config = async (dir = paths.root): Promise<Gro_Config> =>
228
228
  export const validate_gro_config_module: (
229
229
  config_module: any,
230
230
  config_path: string,
231
- ) => asserts config_module is Gro_Config_Module = (config_module, config_path) => {
231
+ ) => asserts config_module is GroConfigModule = (config_module, config_path) => {
232
232
  const config = config_module.default;
233
233
  if (!config) {
234
234
  throw Error(`Invalid Gro config module at ${config_path}: expected a default export`);
@@ -1,7 +1,7 @@
1
1
  import {realpathSync, existsSync} from 'node:fs';
2
2
  import {join, resolve} from 'node:path';
3
3
  import {fileURLToPath} from 'node:url';
4
- import {spawn, type Spawn_Result} from '@ryanatkn/belt/process.js';
4
+ import {spawn, type SpawnResult} from '@ryanatkn/belt/process.js';
5
5
 
6
6
  import {JS_CLI_DEFAULT, NODE_MODULES_DIRNAME, SVELTEKIT_DIST_DIRNAME} from './constants.ts';
7
7
 
@@ -85,7 +85,7 @@ export const spawn_with_loader = (
85
85
  invoke_path: string,
86
86
  argv: Array<string>,
87
87
  js_cli = JS_CLI_DEFAULT, // TODO source from config when possible
88
- ): Promise<Spawn_Result> => {
88
+ ): Promise<SpawnResult> => {
89
89
  const args = [
90
90
  '--import',
91
91
  // This does the same as `$lib/register.ts` but without the cost of importing another file.