@ryanatkn/gro 0.117.0 → 0.118.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 (63) hide show
  1. package/README.md +31 -15
  2. package/dist/changeset.task.js +1 -1
  3. package/dist/clean_fs.js +2 -1
  4. package/dist/cli.js +1 -1
  5. package/dist/config.js +3 -2
  6. package/dist/deploy.task.js +5 -4
  7. package/dist/docs/gen.md +16 -0
  8. package/dist/docs/tasks.gen.md.js +2 -3
  9. package/dist/esbuild_plugin_external_worker.js +1 -2
  10. package/dist/esbuild_plugin_svelte.js +1 -2
  11. package/dist/esbuild_plugin_sveltekit_shim_alias.js +1 -2
  12. package/dist/format_directory.js +3 -2
  13. package/dist/gen.d.ts +5 -0
  14. package/dist/gen.task.js +2 -2
  15. package/dist/gro.config.default.js +3 -2
  16. package/dist/gro_helpers.js +18 -17
  17. package/dist/gro_plugin_server.js +9 -5
  18. package/dist/gro_plugin_sveltekit_app.d.ts +0 -1
  19. package/dist/gro_plugin_sveltekit_app.js +2 -4
  20. package/dist/gro_plugin_sveltekit_library.d.ts +0 -2
  21. package/dist/gro_plugin_sveltekit_library.js +1 -7
  22. package/dist/input_path.d.ts +1 -1
  23. package/dist/input_path.js +1 -1
  24. package/dist/input_path.test.js +3 -3
  25. package/dist/invoke_task.js +9 -10
  26. package/dist/lint.task.js +1 -1
  27. package/dist/loader.js +11 -4
  28. package/dist/module.d.ts +1 -1
  29. package/dist/module.js +2 -2
  30. package/dist/modules.test.js +2 -2
  31. package/dist/package.d.ts +41 -0
  32. package/dist/package.js +57 -31
  33. package/dist/package_json.d.ts +5 -0
  34. package/dist/package_json.js +7 -2
  35. package/dist/package_meta.d.ts +1 -2
  36. package/dist/path_constants.d.ts +20 -0
  37. package/dist/path_constants.js +27 -0
  38. package/dist/paths.d.ts +2 -26
  39. package/dist/paths.js +10 -33
  40. package/dist/publish.task.js +1 -1
  41. package/dist/register.d.ts +1 -0
  42. package/dist/register.js +2 -0
  43. package/dist/release.task.js +1 -2
  44. package/dist/resolve_node_specifier.js +2 -1
  45. package/dist/run_gen.d.ts +2 -1
  46. package/dist/run_gen.js +2 -2
  47. package/dist/run_gen.test.js +3 -2
  48. package/dist/sveltekit_config.d.ts +1 -1
  49. package/dist/sveltekit_config.js +9 -5
  50. package/dist/sveltekit_config_global.d.ts +4 -0
  51. package/dist/sveltekit_config_global.js +5 -0
  52. package/dist/sveltekit_helpers.d.ts +4 -0
  53. package/dist/sveltekit_helpers.js +12 -0
  54. package/dist/sync.task.js +4 -1
  55. package/dist/task.d.ts +1 -1
  56. package/dist/task.js +11 -7
  57. package/dist/task.test.js +9 -13
  58. package/dist/task_logging.d.ts +2 -2
  59. package/dist/task_logging.js +4 -4
  60. package/dist/task_module.d.ts +3 -3
  61. package/dist/task_module.js +6 -6
  62. package/dist/task_module.test.js +4 -7
  63. package/package.json +18 -2
package/dist/module.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export declare const MODULE_PATH_SRC_PREFIX: string;
2
- export declare const MODULE_PATH_LIB_PREFIX = "$lib/";
2
+ export declare const MODULE_PATH_LIB_PREFIX: string;
3
3
  export declare const is_external_module: (module_name: string) => boolean;
package/dist/module.js CHANGED
@@ -1,5 +1,5 @@
1
- // TODO refactor to be configurable, probably following Rollup's patterns
2
- import { SOURCE_DIR, SOURCE_DIRNAME, LIB_DIRNAME } from './paths.js';
1
+ import { LIB_DIRNAME } from './paths.js';
2
+ import { SOURCE_DIR, SOURCE_DIRNAME } from './path_constants.js';
3
3
  export const MODULE_PATH_SRC_PREFIX = SOURCE_DIR;
4
4
  export const MODULE_PATH_LIB_PREFIX = `$${LIB_DIRNAME}/`;
5
5
  const INTERNAL_MODULE_MATCHER = new RegExp(`^(\\.?\\.?|${SOURCE_DIRNAME}|\\$${LIB_DIRNAME})\\/`, 'u');
@@ -69,7 +69,7 @@ test__find_modules('with and without extension', async () => {
69
69
  const path1 = resolve('src/fixtures/test1');
70
70
  const id1 = resolve('src/fixtures/test1.foo.ts');
71
71
  const id2 = resolve('src/fixtures/test2.foo.ts');
72
- const result = await find_modules([path1, id2], (id) => search_fs(id, { files_only: false }), (input_path) => get_possible_source_ids(input_path, ['.foo.ts']));
72
+ const result = await find_modules([path1, id2], (id) => search_fs(id, { files_only: false }), (input_path) => get_possible_source_ids(input_path, ['.foo.ts'], []));
73
73
  assert.ok(result.ok);
74
74
  assert.equal(result.source_ids_by_input_path, new Map([
75
75
  [path1, [id1]],
@@ -93,7 +93,7 @@ test__find_modules('fail with unmapped_input_paths', async () => {
93
93
  resolve('src/fixtures/failme1'),
94
94
  resolve('src/fixtures/bar2'),
95
95
  resolve('src/fixtures/failme2'),
96
- ], (id) => search_fs(id, { files_only: false }), (input_path) => get_possible_source_ids(input_path, ['.foo.ts']));
96
+ ], (id) => search_fs(id, { files_only: false }), (input_path) => get_possible_source_ids(input_path, ['.foo.ts'], []));
97
97
  assert.ok(!result.ok);
98
98
  assert.ok(result.reasons.length);
99
99
  if (result.type === 'unmapped_input_paths') {
package/dist/package.d.ts CHANGED
@@ -290,6 +290,10 @@ export declare const package_json: {
290
290
  default: string;
291
291
  types: string;
292
292
  };
293
+ './path_constants.js': {
294
+ default: string;
295
+ types: string;
296
+ };
293
297
  './path.js': {
294
298
  default: string;
295
299
  types: string;
@@ -306,6 +310,10 @@ export declare const package_json: {
306
310
  default: string;
307
311
  types: string;
308
312
  };
313
+ './register.js': {
314
+ default: string;
315
+ types: string;
316
+ };
309
317
  './release.task.js': {
310
318
  default: string;
311
319
  types: string;
@@ -342,10 +350,18 @@ export declare const package_json: {
342
350
  default: string;
343
351
  types: string;
344
352
  };
353
+ './sveltekit_config_global.js': {
354
+ default: string;
355
+ types: string;
356
+ };
345
357
  './sveltekit_config.js': {
346
358
  default: string;
347
359
  types: string;
348
360
  };
361
+ './sveltekit_helpers.js': {
362
+ default: string;
363
+ types: string;
364
+ };
349
365
  './sveltekit_shim_app_environment.js': {
350
366
  default: string;
351
367
  types: string;
@@ -754,6 +770,13 @@ export declare const src_json: {
754
770
  kind: string;
755
771
  }[];
756
772
  };
773
+ './path_constants.js': {
774
+ path: string;
775
+ declarations: {
776
+ name: string;
777
+ kind: string;
778
+ }[];
779
+ };
757
780
  './path.js': {
758
781
  path: string;
759
782
  declarations: {
@@ -782,6 +805,10 @@ export declare const src_json: {
782
805
  kind: string;
783
806
  }[];
784
807
  };
808
+ './register.js': {
809
+ path: string;
810
+ declarations: never[];
811
+ };
785
812
  './release.task.js': {
786
813
  path: string;
787
814
  declarations: {
@@ -845,6 +872,13 @@ export declare const src_json: {
845
872
  kind: string;
846
873
  }[];
847
874
  };
875
+ './sveltekit_config_global.js': {
876
+ path: string;
877
+ declarations: {
878
+ name: string;
879
+ kind: string;
880
+ }[];
881
+ };
848
882
  './sveltekit_config.js': {
849
883
  path: string;
850
884
  declarations: {
@@ -852,6 +886,13 @@ export declare const src_json: {
852
886
  kind: string;
853
887
  }[];
854
888
  };
889
+ './sveltekit_helpers.js': {
890
+ path: string;
891
+ declarations: {
892
+ name: string;
893
+ kind: string;
894
+ }[];
895
+ };
855
896
  './sveltekit_shim_app_environment.js': {
856
897
  path: string;
857
898
  declarations: {
package/dist/package.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // generated by src/lib/package.gen.ts
2
2
  export const package_json = {
3
3
  name: '@ryanatkn/gro',
4
- version: '0.117.0',
4
+ version: '0.118.0',
5
5
  description: 'task runner and toolkit extending SvelteKit',
6
6
  motto: 'generate, run, optimize',
7
7
  icon: '🌰',
@@ -54,7 +54,7 @@ export const package_json = {
54
54
  '@ryanatkn/fuz': '^0.102.1',
55
55
  '@ryanatkn/moss': '^0.4.0',
56
56
  '@sveltejs/adapter-static': '^3.0.2',
57
- '@sveltejs/kit': '^2.5.13',
57
+ '@sveltejs/kit': '^2.5.15',
58
58
  '@sveltejs/package': '^2.3.2',
59
59
  '@sveltejs/vite-plugin-svelte': '^3.1.1',
60
60
  '@types/fs-extra': '^11.0.4',
@@ -171,10 +171,15 @@ export const package_json = {
171
171
  './package_meta.js': { default: './dist/package_meta.js', types: './dist/package_meta.d.ts' },
172
172
  './package.gen.js': { default: './dist/package.gen.js', types: './dist/package.gen.d.ts' },
173
173
  './package.js': { default: './dist/package.js', types: './dist/package.d.ts' },
174
+ './path_constants.js': {
175
+ default: './dist/path_constants.js',
176
+ types: './dist/path_constants.d.ts',
177
+ },
174
178
  './path.js': { default: './dist/path.js', types: './dist/path.d.ts' },
175
179
  './paths.js': { default: './dist/paths.js', types: './dist/paths.d.ts' },
176
180
  './plugin.js': { default: './dist/plugin.js', types: './dist/plugin.d.ts' },
177
181
  './publish.task.js': { default: './dist/publish.task.js', types: './dist/publish.task.d.ts' },
182
+ './register.js': { default: './dist/register.js', types: './dist/register.d.ts' },
178
183
  './release.task.js': { default: './dist/release.task.js', types: './dist/release.task.d.ts' },
179
184
  './resolve_node_specifier.js': {
180
185
  default: './dist/resolve_node_specifier.js',
@@ -193,10 +198,18 @@ export const package_json = {
193
198
  default: './dist/svelte_helpers.js',
194
199
  types: './dist/svelte_helpers.d.ts',
195
200
  },
201
+ './sveltekit_config_global.js': {
202
+ default: './dist/sveltekit_config_global.js',
203
+ types: './dist/sveltekit_config_global.d.ts',
204
+ },
196
205
  './sveltekit_config.js': {
197
206
  default: './dist/sveltekit_config.js',
198
207
  types: './dist/sveltekit_config.d.ts',
199
208
  },
209
+ './sveltekit_helpers.js': {
210
+ default: './dist/sveltekit_helpers.js',
211
+ types: './dist/sveltekit_helpers.d.ts',
212
+ },
200
213
  './sveltekit_shim_app_environment.js': {
201
214
  default: './dist/sveltekit_shim_app_environment.js',
202
215
  types: './dist/sveltekit_shim_app_environment.d.ts',
@@ -241,7 +254,7 @@ export const package_json = {
241
254
  };
242
255
  export const src_json = {
243
256
  name: '@ryanatkn/gro',
244
- version: '0.117.0',
257
+ version: '0.118.0',
245
258
  modules: {
246
259
  '.': {
247
260
  path: 'index.ts',
@@ -530,7 +543,6 @@ export const src_json = {
530
543
  './gro_plugin_sveltekit_app.js': {
531
544
  path: 'gro_plugin_sveltekit_app.ts',
532
545
  declarations: [
533
- { name: 'has_sveltekit_app', kind: 'function' },
534
546
  { name: 'Options', kind: 'type' },
535
547
  { name: 'Host_Target', kind: 'type' },
536
548
  { name: 'Copy_File_Filter', kind: 'type' },
@@ -539,10 +551,7 @@ export const src_json = {
539
551
  },
540
552
  './gro_plugin_sveltekit_library.js': {
541
553
  path: 'gro_plugin_sveltekit_library.ts',
542
- declarations: [
543
- { name: 'has_sveltekit_library', kind: 'function' },
544
- { name: 'gro_plugin_sveltekit_library', kind: 'function' },
545
- ],
554
+ declarations: [{ name: 'gro_plugin_sveltekit_library', kind: 'function' }],
546
555
  },
547
556
  './gro.config.default.js': {
548
557
  path: 'gro.config.default.ts',
@@ -600,6 +609,8 @@ export const src_json = {
600
609
  './package_json.js': {
601
610
  path: 'package_json.ts',
602
611
  declarations: [
612
+ { name: 'Url', kind: 'variable' },
613
+ { name: 'Email', kind: 'variable' },
603
614
  { name: 'transform_empty_object_to_undefined', kind: 'function' },
604
615
  { name: 'Package_Json_Repository', kind: 'variable' },
605
616
  { name: 'Package_Json_Author', kind: 'variable' },
@@ -635,50 +646,53 @@ export const src_json = {
635
646
  { name: 'src_json', kind: 'variable' },
636
647
  ],
637
648
  },
638
- './path.js': {
639
- path: 'path.ts',
640
- declarations: [
641
- { name: 'Input_Path', kind: 'variable' },
642
- { name: 'Raw_Input_Path', kind: 'variable' },
643
- { name: 'to_input_path', kind: 'function' },
644
- { name: 'to_input_paths', kind: 'function' },
645
- { name: 'get_possible_source_ids', kind: 'function' },
646
- { name: 'load_source_path_data_by_input_path', kind: 'function' },
647
- { name: 'load_source_ids_by_input_path', kind: 'function' },
648
- { name: 'to_gro_input_path', kind: 'function' },
649
- ],
650
- },
651
- './paths.js': {
652
- path: 'paths.ts',
649
+ './path_constants.js': {
650
+ path: 'path_constants.ts',
653
651
  declarations: [
654
652
  { name: 'SOURCE_DIRNAME', kind: 'variable' },
655
653
  { name: 'GRO_DIRNAME', kind: 'variable' },
656
654
  { name: 'GRO_DIST_PREFIX', kind: 'variable' },
657
655
  { name: 'SERVER_DIST_PATH', kind: 'variable' },
658
- { name: 'LIB_DIRNAME', kind: 'variable' },
659
- { name: 'ROUTES_DIRNAME', kind: 'variable' },
660
656
  { name: 'GRO_DEV_DIRNAME', kind: 'variable' },
661
657
  { name: 'SOURCE_DIR', kind: 'variable' },
662
658
  { name: 'GRO_DIR', kind: 'variable' },
663
659
  { name: 'GRO_DEV_DIR', kind: 'variable' },
664
- { name: 'LIB_PATH', kind: 'variable' },
665
- { name: 'LIB_DIR', kind: 'variable' },
666
- { name: 'CONFIG_PATH', kind: 'variable' },
660
+ { name: 'GRO_CONFIG_PATH', kind: 'variable' },
667
661
  { name: 'README_FILENAME', kind: 'variable' },
668
662
  { name: 'SVELTEKIT_CONFIG_FILENAME', kind: 'variable' },
669
663
  { name: 'VITE_CONFIG_FILENAME', kind: 'variable' },
664
+ { name: 'NODE_MODULES_DIRNAME', kind: 'variable' },
670
665
  { name: 'SVELTEKIT_DEV_DIRNAME', kind: 'variable' },
671
666
  { name: 'SVELTEKIT_BUILD_DIRNAME', kind: 'variable' },
672
667
  { name: 'SVELTEKIT_DIST_DIRNAME', kind: 'variable' },
673
- { name: 'NODE_MODULES_DIRNAME', kind: 'variable' },
674
668
  { name: 'SVELTEKIT_VITE_CACHE_PATH', kind: 'variable' },
675
669
  { name: 'GITHUB_DIRNAME', kind: 'variable' },
676
670
  { name: 'GIT_DIRNAME', kind: 'variable' },
677
671
  { name: 'TSCONFIG_FILENAME', kind: 'variable' },
672
+ ],
673
+ },
674
+ './path.js': {
675
+ path: 'path.ts',
676
+ declarations: [
677
+ { name: 'Input_Path', kind: 'variable' },
678
+ { name: 'Raw_Input_Path', kind: 'variable' },
679
+ { name: 'to_input_path', kind: 'function' },
680
+ { name: 'to_input_paths', kind: 'function' },
681
+ { name: 'get_possible_source_ids', kind: 'function' },
682
+ { name: 'load_source_path_data_by_input_path', kind: 'function' },
683
+ { name: 'load_source_ids_by_input_path', kind: 'function' },
684
+ { name: 'to_gro_input_path', kind: 'function' },
685
+ ],
686
+ },
687
+ './paths.js': {
688
+ path: 'paths.ts',
689
+ declarations: [
690
+ { name: 'LIB_DIRNAME', kind: 'variable' },
691
+ { name: 'LIB_PATH', kind: 'variable' },
692
+ { name: 'LIB_DIR', kind: 'variable' },
693
+ { name: 'ROUTES_DIRNAME', kind: 'variable' },
678
694
  { name: 'Paths', kind: 'type' },
679
695
  { name: 'Source_Id', kind: 'variable' },
680
- { name: 'Url', kind: 'variable' },
681
- { name: 'Email', kind: 'variable' },
682
696
  { name: 'create_paths', kind: 'function' },
683
697
  { name: 'paths_from_id', kind: 'function' },
684
698
  { name: 'is_gro_id', kind: 'function' },
@@ -713,6 +727,7 @@ export const src_json = {
713
727
  { name: 'task', kind: 'variable' },
714
728
  ],
715
729
  },
730
+ './register.js': { path: 'register.ts', declarations: [] },
716
731
  './release.task.js': {
717
732
  path: 'release.task.ts',
718
733
  declarations: [
@@ -784,6 +799,10 @@ export const src_json = {
784
799
  { name: 'SVELTE_RUNES_MATCHER', kind: 'variable' },
785
800
  ],
786
801
  },
802
+ './sveltekit_config_global.js': {
803
+ path: 'sveltekit_config_global.ts',
804
+ declarations: [{ name: 'sveltekit_config_global', kind: 'variable' }],
805
+ },
787
806
  './sveltekit_config.js': {
788
807
  path: 'sveltekit_config.ts',
789
808
  declarations: [
@@ -792,6 +811,13 @@ export const src_json = {
792
811
  { name: 'init_sveltekit_config', kind: 'function' },
793
812
  ],
794
813
  },
814
+ './sveltekit_helpers.js': {
815
+ path: 'sveltekit_helpers.ts',
816
+ declarations: [
817
+ { name: 'has_sveltekit_app', kind: 'function' },
818
+ { name: 'has_sveltekit_library', kind: 'function' },
819
+ ],
820
+ },
795
821
  './sveltekit_shim_app_environment.js': {
796
822
  path: 'sveltekit_shim_app_environment.ts',
797
823
  declarations: [
@@ -1,4 +1,9 @@
1
1
  import { z } from 'zod';
2
+ import type { Flavored } from '@ryanatkn/belt/types.js';
3
+ export declare const Url: z.ZodString;
4
+ export type Url = Flavored<z.infer<typeof Url>, 'Url'>;
5
+ export declare const Email: z.ZodString;
6
+ export type Email = Flavored<z.infer<typeof Email>, 'Email'>;
2
7
  export declare const transform_empty_object_to_undefined: (val: any) => any;
3
8
  export declare const Package_Json_Repository: z.ZodUnion<[z.ZodString, z.ZodObject<{
4
9
  type: z.ZodString;
@@ -3,9 +3,14 @@ import { join } from 'node:path';
3
3
  import { readFile, writeFile } from 'node:fs/promises';
4
4
  import { plural } from '@ryanatkn/belt/string.js';
5
5
  import { strip_end } from '@ryanatkn/belt/string.js';
6
- import { paths, gro_paths, IS_THIS_GRO, replace_extension, SVELTEKIT_DIST_DIRNAME, Url, Email, } from './paths.js';
6
+ import { paths, gro_paths, IS_THIS_GRO, replace_extension } from './paths.js';
7
+ import { SVELTEKIT_DIST_DIRNAME } from './path_constants.js';
7
8
  import { search_fs } from './search_fs.js';
8
- import { has_sveltekit_library } from './gro_plugin_sveltekit_library.js';
9
+ import { has_sveltekit_library } from './sveltekit_helpers.js';
10
+ // TODO @multiple belongs elsewhere
11
+ export const Url = z.string();
12
+ // TODO @multiple belongs elsewhere
13
+ export const Email = z.string();
9
14
  // TODO move this where?
10
15
  export const transform_empty_object_to_undefined = (val) => {
11
16
  if (val && Object.keys(val).length === 0) {
@@ -1,6 +1,5 @@
1
- import type { Package_Json } from './package_json.js';
1
+ import type { Package_Json, Url } from './package_json.js';
2
2
  import type { Src_Json } from './src_json.js';
3
- import type { Url } from './paths.js';
4
3
  export interface Package_Meta {
5
4
  url: Url;
6
5
  package_json: Package_Json;
@@ -0,0 +1,20 @@
1
+ export declare const SOURCE_DIRNAME = "src";
2
+ export declare const GRO_DIRNAME = ".gro";
3
+ export declare const GRO_DIST_PREFIX = "dist_";
4
+ export declare const SERVER_DIST_PATH = "dist_server";
5
+ export declare const GRO_DEV_DIRNAME: string;
6
+ export declare const SOURCE_DIR: string;
7
+ export declare const GRO_DIR: string;
8
+ export declare const GRO_DEV_DIR: string;
9
+ export declare const GRO_CONFIG_PATH = "gro.config.ts";
10
+ export declare const README_FILENAME = "README.md";
11
+ export declare const SVELTEKIT_CONFIG_FILENAME = "svelte.config.js";
12
+ export declare const VITE_CONFIG_FILENAME = "vite.config.ts";
13
+ export declare const NODE_MODULES_DIRNAME = "node_modules";
14
+ export declare const SVELTEKIT_DEV_DIRNAME = ".svelte-kit";
15
+ export declare const SVELTEKIT_BUILD_DIRNAME = "build";
16
+ export declare const SVELTEKIT_DIST_DIRNAME = "dist";
17
+ export declare const SVELTEKIT_VITE_CACHE_PATH: string;
18
+ export declare const GITHUB_DIRNAME = ".github";
19
+ export declare const GIT_DIRNAME = ".git";
20
+ export declare const TSCONFIG_FILENAME = "tsconfig.json";
@@ -0,0 +1,27 @@
1
+ /*
2
+
3
+ This module is intended to have no dependencies to avoid over-imports in the CLI and loader.
4
+ If any of these become customizable from SvelteKit or Gro's configs, move them to `./paths.ts`.
5
+
6
+ */
7
+ // TODO the slashes here are kinda gross - do we want to maintain the convention to have the trailing slash in most usage?
8
+ export const SOURCE_DIRNAME = 'src';
9
+ export const GRO_DIRNAME = '.gro';
10
+ export const GRO_DIST_PREFIX = 'dist_'; //
11
+ export const SERVER_DIST_PATH = 'dist_server'; // TODO should all of these be `_PATH` or should this be `DIRNAME`?
12
+ export const GRO_DEV_DIRNAME = GRO_DIRNAME + '/dev';
13
+ export const SOURCE_DIR = SOURCE_DIRNAME + '/';
14
+ export const GRO_DIR = GRO_DIRNAME + '/';
15
+ export const GRO_DEV_DIR = GRO_DEV_DIRNAME + '/';
16
+ export const GRO_CONFIG_PATH = 'gro.config.ts';
17
+ export const README_FILENAME = 'README.md';
18
+ export const SVELTEKIT_CONFIG_FILENAME = 'svelte.config.js';
19
+ export const VITE_CONFIG_FILENAME = 'vite.config.ts';
20
+ export const NODE_MODULES_DIRNAME = 'node_modules';
21
+ export const SVELTEKIT_DEV_DIRNAME = '.svelte-kit'; // TODO use Svelte config value `outDir`
22
+ export const SVELTEKIT_BUILD_DIRNAME = 'build';
23
+ export const SVELTEKIT_DIST_DIRNAME = 'dist';
24
+ export const SVELTEKIT_VITE_CACHE_PATH = NODE_MODULES_DIRNAME + '/.vite';
25
+ export const GITHUB_DIRNAME = '.github';
26
+ export const GIT_DIRNAME = '.git';
27
+ export const TSCONFIG_FILENAME = 'tsconfig.json';
package/dist/paths.d.ts CHANGED
@@ -1,29 +1,9 @@
1
1
  import type { Flavored } from '@ryanatkn/belt/types.js';
2
2
  import { z } from 'zod';
3
- export declare const SOURCE_DIRNAME = "src";
4
- export declare const GRO_DIRNAME = ".gro";
5
- export declare const GRO_DIST_PREFIX = "dist_";
6
- export declare const SERVER_DIST_PATH = "dist_server";
7
- export declare const LIB_DIRNAME = "lib";
8
- export declare const ROUTES_DIRNAME = "routes";
9
- export declare const GRO_DEV_DIRNAME: string;
10
- export declare const SOURCE_DIR: string;
11
- export declare const GRO_DIR: string;
12
- export declare const GRO_DEV_DIR: string;
3
+ export declare const LIB_DIRNAME: string;
13
4
  export declare const LIB_PATH: string;
14
5
  export declare const LIB_DIR: string;
15
- export declare const CONFIG_PATH = "gro.config.ts";
16
- export declare const README_FILENAME = "README.md";
17
- export declare const SVELTEKIT_CONFIG_FILENAME = "svelte.config.js";
18
- export declare const VITE_CONFIG_FILENAME = "vite.config.ts";
19
- export declare const SVELTEKIT_DEV_DIRNAME = ".svelte-kit";
20
- export declare const SVELTEKIT_BUILD_DIRNAME = "build";
21
- export declare const SVELTEKIT_DIST_DIRNAME = "dist";
22
- export declare const NODE_MODULES_DIRNAME = "node_modules";
23
- export declare const SVELTEKIT_VITE_CACHE_PATH: string;
24
- export declare const GITHUB_DIRNAME = ".github";
25
- export declare const GIT_DIRNAME = ".git";
26
- export declare const TSCONFIG_FILENAME = "tsconfig.json";
6
+ export declare const ROUTES_DIRNAME: string;
27
7
  export interface Paths {
28
8
  root: string;
29
9
  source: string;
@@ -34,10 +14,6 @@ export interface Paths {
34
14
  }
35
15
  export declare const Source_Id: z.ZodString;
36
16
  export type Source_Id = Flavored<z.infer<typeof Source_Id>, 'Source_Id'>;
37
- export declare const Url: z.ZodString;
38
- export type Url = Flavored<z.infer<typeof Url>, 'Url'>;
39
- export declare const Email: z.ZodString;
40
- export type Email = Flavored<z.infer<typeof Email>, 'Email'>;
41
17
  export declare const create_paths: (root_dir: string) => Paths;
42
18
  export declare const paths_from_id: (id: string) => Paths;
43
19
  export declare const is_gro_id: (id: string) => boolean;
package/dist/paths.js CHANGED
@@ -1,56 +1,33 @@
1
- import { join, extname, relative } from 'node:path';
1
+ import { join, extname, relative, basename } from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  import { strip_end, strip_start } from '@ryanatkn/belt/string.js';
4
4
  import { gray } from 'kleur/colors';
5
5
  import { z } from 'zod';
6
+ import { GRO_CONFIG_PATH, GRO_DEV_DIR, GRO_DIR, SOURCE_DIR, SVELTEKIT_DIST_DIRNAME, } from './path_constants.js';
7
+ import { sveltekit_config_global } from './sveltekit_config_global.js';
6
8
  /*
7
9
 
8
10
  A path `id` is an absolute path to the source/.gro/dist directory.
9
11
  It's the same name that Rollup uses.
10
12
 
11
13
  */
12
- // TODO pass these to `create_paths` and override from gro config
13
- // TODO this is kinda gross - do we want to maintain the convention to have the trailing slash in most usage?
14
- export const SOURCE_DIRNAME = 'src';
15
- export const GRO_DIRNAME = '.gro';
16
- export const GRO_DIST_PREFIX = 'dist_'; //
17
- export const SERVER_DIST_PATH = 'dist_server'; // TODO should all of these be `_PATH` or should this be `DIRNAME`?
18
- export const LIB_DIRNAME = 'lib'; // TODO use Svelte config `files.lib`
19
- export const ROUTES_DIRNAME = 'routes'; // TODO use Svelte config `files.lib`
20
- export const GRO_DEV_DIRNAME = GRO_DIRNAME + '/dev';
21
- export const SOURCE_DIR = SOURCE_DIRNAME + '/';
22
- export const GRO_DIR = GRO_DIRNAME + '/';
23
- export const GRO_DEV_DIR = GRO_DEV_DIRNAME + '/';
14
+ export const LIB_DIRNAME = basename(sveltekit_config_global.lib_path);
24
15
  export const LIB_PATH = SOURCE_DIR + LIB_DIRNAME;
25
- export const LIB_DIR = LIB_PATH + '/'; // TODO @multiple get from the sveltekit config
26
- export const CONFIG_PATH = 'gro.config.ts';
27
- export const README_FILENAME = 'README.md';
28
- export const SVELTEKIT_CONFIG_FILENAME = 'svelte.config.js';
29
- export const VITE_CONFIG_FILENAME = 'vite.config.ts';
30
- export const SVELTEKIT_DEV_DIRNAME = '.svelte-kit'; // TODO use Svelte config value `outDir`
31
- export const SVELTEKIT_BUILD_DIRNAME = 'build';
32
- export const SVELTEKIT_DIST_DIRNAME = 'dist';
33
- export const NODE_MODULES_DIRNAME = 'node_modules';
34
- export const SVELTEKIT_VITE_CACHE_PATH = NODE_MODULES_DIRNAME + '/.vite';
35
- export const GITHUB_DIRNAME = '.github';
36
- export const GIT_DIRNAME = '.git';
37
- export const TSCONFIG_FILENAME = 'tsconfig.json';
16
+ export const LIB_DIR = LIB_PATH + '/';
17
+ export const ROUTES_DIRNAME = basename(sveltekit_config_global.routes_path);
18
+ // TODO probably rename to `Path_Id` from `Source_Id`?
38
19
  // TODO Flavored doesn't work when used in schemas, use Zod brand instead? problem is ergonomics
39
20
  export const Source_Id = z.string();
40
- // TODO @multiple belongs elsewhere
41
- export const Url = z.string();
42
- // TODO @multiple belongs elsewhere
43
- export const Email = z.string();
44
21
  export const create_paths = (root_dir) => {
45
22
  // TODO remove reliance on trailing slash towards windows support
46
23
  const root = strip_end(root_dir, '/') + '/';
47
24
  return {
48
25
  root,
49
26
  source: root + SOURCE_DIR,
50
- lib: root + LIB_DIR, // TODO @multiple get from the sveltekit config
27
+ lib: root + LIB_DIR,
51
28
  build: root + GRO_DIR,
52
29
  build_dev: root + GRO_DEV_DIR,
53
- config: root + CONFIG_PATH,
30
+ config: root + GRO_CONFIG_PATH,
54
31
  };
55
32
  };
56
33
  export const paths_from_id = (id) => (is_gro_id(id) ? gro_paths : paths);
@@ -94,7 +71,7 @@ export const replace_extension = (path, new_extension) => {
94
71
  /**
95
72
  * Paths for the user repo.
96
73
  */
97
- export const paths = create_paths(process.cwd() + '/');
74
+ export const paths = create_paths(process.cwd());
98
75
  export const GRO_PACKAGE_DIR = 'gro/';
99
76
  // TODO document these conditions with comments
100
77
  // TODO there's probably a more robust way to do this
@@ -6,7 +6,7 @@ import { load_package_json, parse_repo_url } from './package_json.js';
6
6
  import { find_cli, spawn_cli } from './cli.js';
7
7
  import { exists } from './fs.js';
8
8
  import { IS_THIS_GRO } from './paths.js';
9
- import { has_sveltekit_library } from './gro_plugin_sveltekit_library.js';
9
+ import { has_sveltekit_library } from './sveltekit_helpers.js';
10
10
  import { update_changelog } from './changelog.js';
11
11
  import { load_from_env } from './env.js';
12
12
  import { Git_Branch, Git_Origin, git_checkout, git_fetch, git_pull } from './git.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { register } from 'node:module';
2
+ register('./loader.js', import.meta.url);
@@ -1,6 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { has_sveltekit_library } from './gro_plugin_sveltekit_library.js';
3
- import { has_sveltekit_app } from './gro_plugin_sveltekit_app.js';
2
+ import { has_sveltekit_library, has_sveltekit_app } from './sveltekit_helpers.js';
4
3
  export const Args = z.object({}).strict();
5
4
  export const task = {
6
5
  summary: 'publish and deploy',
@@ -1,6 +1,7 @@
1
1
  import { join } from 'node:path';
2
2
  import { Package_Json, load_package_json } from './package_json.js';
3
- import { NODE_MODULES_DIRNAME, Source_Id, paths } from './paths.js';
3
+ import { Source_Id, paths } from './paths.js';
4
+ import { NODE_MODULES_DIRNAME } from './path_constants.js';
4
5
  export const resolve_node_specifier = async (specifier, dir = paths.root, parent_url, cache, exports_key = specifier.endsWith('.svelte') ? 'svelte' : 'default') => {
5
6
  const parsed = parse_node_specifier(specifier);
6
7
  const subpath = './' + parsed.path;
package/dist/run_gen.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { type Gen_Module_Meta } from './gen_module.js';
2
2
  import { type Gen_Results } from './gen.js';
3
3
  import type { format_file as base_format_file } from './format_file.js';
4
+ import type { Gro_Config } from './config.js';
4
5
  export declare const GEN_NO_PROD_MESSAGE = "gen runs only during development";
5
- export declare const run_gen: (gen_modules: Gen_Module_Meta[], log: Logger, timings: Timings, format_file?: typeof base_format_file) => Promise<Gen_Results>;
6
+ export declare const run_gen: (gen_modules: Gen_Module_Meta[], config: Gro_Config, log: Logger, timings: Timings, format_file?: typeof base_format_file) => Promise<Gen_Results>;
6
7
  export declare const to_gen_import_path: (id: string) => string;
package/dist/run_gen.js CHANGED
@@ -6,7 +6,7 @@ import { GEN_SCHEMA_PATH_SUFFIX } from './gen_module.js';
6
6
  import { to_gen_result, } from './gen.js';
7
7
  import { print_path, source_id_to_base_path } from './paths.js';
8
8
  export const GEN_NO_PROD_MESSAGE = 'gen runs only during development';
9
- export const run_gen = async (gen_modules, log, timings, format_file) => {
9
+ export const run_gen = async (gen_modules, config, log, timings, format_file) => {
10
10
  let input_count = 0;
11
11
  let output_count = 0;
12
12
  const timing_for_run_gen = timings.start('run_gen');
@@ -15,7 +15,7 @@ export const run_gen = async (gen_modules, log, timings, format_file) => {
15
15
  const { id } = module_meta;
16
16
  const timing_for_module = timings.start(id);
17
17
  // Perform code generation by calling `gen` on the module.
18
- const gen_ctx = { origin_id: id, log };
18
+ const gen_ctx = { origin_id: id, config, log };
19
19
  let raw_gen_result;
20
20
  try {
21
21
  switch (module_meta.type) {
@@ -4,6 +4,7 @@ import { resolve, join } from 'node:path';
4
4
  import { Logger } from '@ryanatkn/belt/log.js';
5
5
  import { Timings } from '@ryanatkn/belt/timings.js';
6
6
  import { run_gen } from './run_gen.js';
7
+ import { load_config } from './config.js';
7
8
  const log = new Logger('test__gen'); // TODO test logger?
8
9
  /* test__gen */
9
10
  const test__gen = suite('gen');
@@ -69,7 +70,7 @@ test__gen('basic behavior', async () => {
69
70
  },
70
71
  };
71
72
  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
+ const gen_results = await run_gen(gen_modules_by_input_path, await load_config(), log, new Timings(), async (content, opts) => opts.filepath.endsWith('output_b.ts') ? `${content}/*FORMATTED*/` : content);
73
74
  assert.is(gen_results.input_count, 3);
74
75
  assert.is(gen_results.output_count, 4);
75
76
  assert.is(gen_results.successes.length, 3);
@@ -153,7 +154,7 @@ test__gen('failing gen function', async () => {
153
154
  },
154
155
  };
155
156
  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
+ const gen_results = await run_gen(gen_modules_by_input_path, await load_config(), log, new Timings());
157
158
  assert.is(gen_results.input_count, 2);
158
159
  assert.is(gen_results.output_count, 1);
159
160
  assert.is(gen_results.successes.length, 1);
@@ -3,7 +3,7 @@ import type { Config as SveltekitConfig } from '@sveltejs/kit';
3
3
  import type { CompileOptions, PreprocessorGroup, ModuleCompileOptions } from 'svelte/compiler';
4
4
  /**
5
5
  * Loads a SvelteKit config at `dir`.
6
- * @returns
6
+ * @returns `null` if no config is found
7
7
  */
8
8
  export declare const load_sveltekit_config: (dir?: string) => Promise<SveltekitConfig | null>;
9
9
  /**