@ryanatkn/gro 0.116.2 → 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 (74) 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.d.ts +5 -0
  6. package/dist/config.js +11 -3
  7. package/dist/deploy.task.js +5 -4
  8. package/dist/docs/config.md +25 -0
  9. package/dist/docs/gen.md +16 -0
  10. package/dist/docs/task.md +38 -32
  11. package/dist/docs/tasks.gen.md.js +3 -4
  12. package/dist/esbuild_plugin_external_worker.js +1 -2
  13. package/dist/esbuild_plugin_svelte.js +1 -2
  14. package/dist/esbuild_plugin_sveltekit_shim_alias.js +1 -2
  15. package/dist/format_directory.js +3 -2
  16. package/dist/gen.d.ts +5 -0
  17. package/dist/gen.task.js +7 -8
  18. package/dist/gen_module.d.ts +2 -1
  19. package/dist/gen_module.js +1 -1
  20. package/dist/gro.config.default.js +3 -2
  21. package/dist/gro_helpers.js +18 -17
  22. package/dist/gro_plugin_server.js +9 -5
  23. package/dist/gro_plugin_sveltekit_app.d.ts +0 -1
  24. package/dist/gro_plugin_sveltekit_app.js +2 -4
  25. package/dist/gro_plugin_sveltekit_library.d.ts +0 -2
  26. package/dist/gro_plugin_sveltekit_library.js +1 -7
  27. package/dist/input_path.d.ts +27 -28
  28. package/dist/input_path.js +62 -66
  29. package/dist/input_path.test.js +26 -48
  30. package/dist/invoke_task.d.ts +1 -1
  31. package/dist/invoke_task.js +78 -88
  32. package/dist/lint.task.js +1 -1
  33. package/dist/loader.js +11 -4
  34. package/dist/module.d.ts +1 -1
  35. package/dist/module.js +2 -2
  36. package/dist/modules.d.ts +13 -9
  37. package/dist/modules.js +5 -13
  38. package/dist/modules.test.js +2 -2
  39. package/dist/package.d.ts +47 -6
  40. package/dist/package.gen.js +3 -3
  41. package/dist/package.js +89 -60
  42. package/dist/package_json.d.ts +5 -0
  43. package/dist/package_json.js +9 -4
  44. package/dist/package_meta.d.ts +1 -2
  45. package/dist/path_constants.d.ts +20 -0
  46. package/dist/path_constants.js +27 -0
  47. package/dist/paths.d.ts +11 -34
  48. package/dist/paths.js +28 -67
  49. package/dist/publish.task.js +3 -3
  50. package/dist/register.d.ts +1 -0
  51. package/dist/register.js +2 -0
  52. package/dist/release.task.js +1 -2
  53. package/dist/resolve_node_specifier.js +2 -1
  54. package/dist/run_gen.d.ts +2 -1
  55. package/dist/run_gen.js +2 -2
  56. package/dist/run_gen.test.js +3 -2
  57. package/dist/run_task.js +2 -2
  58. package/dist/sveltekit_config.d.ts +1 -1
  59. package/dist/sveltekit_config.js +9 -5
  60. package/dist/sveltekit_config_global.d.ts +4 -0
  61. package/dist/sveltekit_config_global.js +5 -0
  62. package/dist/sveltekit_helpers.d.ts +4 -0
  63. package/dist/sveltekit_helpers.js +12 -0
  64. package/dist/sync.task.js +4 -1
  65. package/dist/task.d.ts +1 -1
  66. package/dist/task.js +11 -6
  67. package/dist/task.test.js +9 -13
  68. package/dist/task_logging.d.ts +8 -0
  69. package/dist/{print_task.js → task_logging.js} +30 -16
  70. package/dist/task_module.d.ts +4 -3
  71. package/dist/task_module.js +7 -8
  72. package/dist/task_module.test.js +4 -7
  73. package/package.json +36 -20
  74. package/dist/print_task.d.ts +0 -4
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.116.2',
4
+ version: '0.118.0',
5
5
  description: 'task runner and toolkit extending SvelteKit',
6
6
  motto: 'generate, run, optimize',
7
7
  icon: '🌰',
@@ -39,11 +39,11 @@ export const package_json = {
39
39
  'es-module-lexer': '^1.5.3',
40
40
  kleur: '^4.1.5',
41
41
  mri: '^1.2.0',
42
- prettier: '^3.2.5',
43
- 'prettier-plugin-svelte': '^3.2.3',
42
+ prettier: '^3.3.2',
43
+ 'prettier-plugin-svelte': '^3.2.4',
44
44
  'tiny-glob': '^0.2.9',
45
45
  'ts-morph': '^22.0.0',
46
- tslib: '^2.6.2',
46
+ tslib: '^2.6.3',
47
47
  zod: '^3.23.8',
48
48
  },
49
49
  peerDependencies: { esbuild: '^0.20', svelte: '^5.0.0-next.0' },
@@ -51,21 +51,21 @@ export const package_json = {
51
51
  '@changesets/changelog-git': '^0.2.0',
52
52
  '@changesets/types': '^6.0.0',
53
53
  '@ryanatkn/eslint-config': '^0.1.2',
54
- '@ryanatkn/fuz': '^0.101.4',
55
- '@ryanatkn/moss': '^0.3.0',
56
- '@sveltejs/adapter-static': '^3.0.1',
57
- '@sveltejs/kit': '^2.5.10',
58
- '@sveltejs/package': '^2.3.1',
59
- '@sveltejs/vite-plugin-svelte': '^3.1.0',
54
+ '@ryanatkn/fuz': '^0.102.1',
55
+ '@ryanatkn/moss': '^0.4.0',
56
+ '@sveltejs/adapter-static': '^3.0.2',
57
+ '@sveltejs/kit': '^2.5.15',
58
+ '@sveltejs/package': '^2.3.2',
59
+ '@sveltejs/vite-plugin-svelte': '^3.1.1',
60
60
  '@types/fs-extra': '^11.0.4',
61
- '@types/node': '^20.12.12',
62
- '@typescript-eslint/eslint-plugin': '^7.10.0',
63
- '@typescript-eslint/parser': '^7.10.0',
61
+ '@types/node': '^20.14.2',
62
+ '@typescript-eslint/eslint-plugin': '^7.13.0',
63
+ '@typescript-eslint/parser': '^7.13.0',
64
64
  esbuild: '^0.20.2',
65
65
  eslint: '^8.57.0',
66
- 'eslint-plugin-svelte': '^2.39.0',
67
- svelte: '^5.0.0-next.153',
68
- 'svelte-check': '^3.7.1',
66
+ 'eslint-plugin-svelte': '^2.39.3',
67
+ svelte: '^5.0.0-next.155',
68
+ 'svelte-check': '^3.8.0',
69
69
  typescript: '^5.4.5',
70
70
  uvu: '^0.5.6',
71
71
  },
@@ -171,11 +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
- './print_task.js': { default: './dist/print_task.js', types: './dist/print_task.d.ts' },
178
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' },
179
183
  './release.task.js': { default: './dist/release.task.js', types: './dist/release.task.d.ts' },
180
184
  './resolve_node_specifier.js': {
181
185
  default: './dist/resolve_node_specifier.js',
@@ -194,10 +198,18 @@ export const package_json = {
194
198
  default: './dist/svelte_helpers.js',
195
199
  types: './dist/svelte_helpers.d.ts',
196
200
  },
201
+ './sveltekit_config_global.js': {
202
+ default: './dist/sveltekit_config_global.js',
203
+ types: './dist/sveltekit_config_global.d.ts',
204
+ },
197
205
  './sveltekit_config.js': {
198
206
  default: './dist/sveltekit_config.js',
199
207
  types: './dist/sveltekit_config.d.ts',
200
208
  },
209
+ './sveltekit_helpers.js': {
210
+ default: './dist/sveltekit_helpers.js',
211
+ types: './dist/sveltekit_helpers.d.ts',
212
+ },
201
213
  './sveltekit_shim_app_environment.js': {
202
214
  default: './dist/sveltekit_shim_app_environment.js',
203
215
  types: './dist/sveltekit_shim_app_environment.d.ts',
@@ -227,6 +239,7 @@ export const package_json = {
227
239
  types: './dist/sveltekit_shim_env.d.ts',
228
240
  },
229
241
  './sync.task.js': { default: './dist/sync.task.js', types: './dist/sync.task.d.ts' },
242
+ './task_logging.js': { default: './dist/task_logging.js', types: './dist/task_logging.d.ts' },
230
243
  './task_module.js': { default: './dist/task_module.js', types: './dist/task_module.d.ts' },
231
244
  './task.js': { default: './dist/task.js', types: './dist/task.d.ts' },
232
245
  './test.task.js': { default: './dist/test.task.js', types: './dist/test.task.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.116.2',
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',
@@ -553,11 +562,14 @@ export const src_json = {
553
562
  './input_path.js': {
554
563
  path: 'input_path.ts',
555
564
  declarations: [
556
- { name: 'resolve_input_path', kind: 'function' },
557
- { name: 'resolve_input_paths', kind: 'function' },
565
+ { name: 'Input_Path', kind: 'variable' },
566
+ { name: 'Raw_Input_Path', kind: 'variable' },
567
+ { name: 'to_input_path', kind: 'function' },
568
+ { name: 'to_input_paths', kind: 'function' },
558
569
  { name: 'get_possible_source_ids', kind: 'function' },
559
570
  { name: 'load_source_path_data_by_input_path', kind: 'function' },
560
571
  { name: 'load_source_ids_by_input_path', kind: 'function' },
572
+ { name: 'to_gro_input_path', kind: 'function' },
561
573
  ],
562
574
  },
563
575
  './invoke_task.js': {
@@ -597,6 +609,8 @@ export const src_json = {
597
609
  './package_json.js': {
598
610
  path: 'package_json.ts',
599
611
  declarations: [
612
+ { name: 'Url', kind: 'variable' },
613
+ { name: 'Email', kind: 'variable' },
600
614
  { name: 'transform_empty_object_to_undefined', kind: 'function' },
601
615
  { name: 'Package_Json_Repository', kind: 'variable' },
602
616
  { name: 'Package_Json_Author', kind: 'variable' },
@@ -632,66 +646,68 @@ export const src_json = {
632
646
  { name: 'src_json', kind: 'variable' },
633
647
  ],
634
648
  },
635
- './path.js': {
636
- path: 'path.ts',
637
- declarations: [
638
- { name: 'resolve_input_path', kind: 'function' },
639
- { name: 'resolve_input_paths', kind: 'function' },
640
- { name: 'get_possible_source_ids', kind: 'function' },
641
- { name: 'load_source_path_data_by_input_path', kind: 'function' },
642
- { name: 'load_source_ids_by_input_path', kind: 'function' },
643
- ],
644
- },
645
- './paths.js': {
646
- path: 'paths.ts',
649
+ './path_constants.js': {
650
+ path: 'path_constants.ts',
647
651
  declarations: [
648
652
  { name: 'SOURCE_DIRNAME', kind: 'variable' },
649
653
  { name: 'GRO_DIRNAME', kind: 'variable' },
650
654
  { name: 'GRO_DIST_PREFIX', kind: 'variable' },
651
655
  { name: 'SERVER_DIST_PATH', kind: 'variable' },
652
- { name: 'LIB_DIRNAME', kind: 'variable' },
653
- { name: 'ROUTES_DIRNAME', kind: 'variable' },
654
656
  { name: 'GRO_DEV_DIRNAME', kind: 'variable' },
655
657
  { name: 'SOURCE_DIR', kind: 'variable' },
656
658
  { name: 'GRO_DIR', kind: 'variable' },
657
659
  { name: 'GRO_DEV_DIR', kind: 'variable' },
658
- { name: 'LIB_PATH', kind: 'variable' },
659
- { name: 'LIB_DIR', kind: 'variable' },
660
- { name: 'CONFIG_PATH', kind: 'variable' },
660
+ { name: 'GRO_CONFIG_PATH', kind: 'variable' },
661
661
  { name: 'README_FILENAME', kind: 'variable' },
662
662
  { name: 'SVELTEKIT_CONFIG_FILENAME', kind: 'variable' },
663
663
  { name: 'VITE_CONFIG_FILENAME', kind: 'variable' },
664
+ { name: 'NODE_MODULES_DIRNAME', kind: 'variable' },
664
665
  { name: 'SVELTEKIT_DEV_DIRNAME', kind: 'variable' },
665
666
  { name: 'SVELTEKIT_BUILD_DIRNAME', kind: 'variable' },
666
667
  { name: 'SVELTEKIT_DIST_DIRNAME', kind: 'variable' },
667
- { name: 'NODE_MODULES_DIRNAME', kind: 'variable' },
668
668
  { name: 'SVELTEKIT_VITE_CACHE_PATH', kind: 'variable' },
669
669
  { name: 'GITHUB_DIRNAME', kind: 'variable' },
670
670
  { name: 'GIT_DIRNAME', kind: 'variable' },
671
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' },
672
694
  { name: 'Paths', kind: 'type' },
673
- { name: 'Url', kind: 'variable' },
674
- { name: 'Email', kind: 'variable' },
675
695
  { name: 'Source_Id', kind: 'variable' },
676
- { name: 'Build_Id', kind: 'variable' },
677
696
  { name: 'create_paths', kind: 'function' },
678
697
  { name: 'paths_from_id', kind: 'function' },
679
698
  { name: 'is_gro_id', kind: 'function' },
680
699
  { name: 'to_root_path', kind: 'function' },
681
700
  { name: 'source_id_to_base_path', kind: 'function' },
682
701
  { name: 'base_path_to_source_id', kind: 'function' },
683
- { name: 'lib_path_to_import_id', kind: 'function' },
684
702
  { name: 'import_id_to_lib_path', kind: 'function' },
685
- { name: 'to_gro_input_path', kind: 'function' },
686
- { name: 'replace_root_dir', kind: 'function' },
687
703
  { name: 'print_path', kind: 'function' },
688
704
  { name: 'print_path_or_gro_path', kind: 'function' },
689
705
  { name: 'replace_extension', kind: 'function' },
690
- { name: 'gro_dir_basename', kind: 'variable' },
691
706
  { name: 'paths', kind: 'variable' },
692
- { name: 'is_this_project_gro', kind: 'variable' },
707
+ { name: 'GRO_PACKAGE_DIR', kind: 'variable' },
708
+ { name: 'IS_THIS_GRO', kind: 'variable' },
693
709
  { name: 'gro_paths', kind: 'variable' },
694
- { name: 'gro_sveltekit_dist_dir', kind: 'variable' },
710
+ { name: 'GRO_DIST_DIR', kind: 'variable' },
695
711
  ],
696
712
  },
697
713
  './plugin.js': {
@@ -704,14 +720,6 @@ export const src_json = {
704
720
  { name: 'replace_plugin', kind: 'function' },
705
721
  ],
706
722
  },
707
- './print_task.js': {
708
- path: 'print_task.ts',
709
- declarations: [
710
- { name: 'log_available_tasks', kind: 'function' },
711
- { name: 'log_error_reasons', kind: 'function' },
712
- { name: 'print_task_help', kind: 'function' },
713
- ],
714
- },
715
723
  './publish.task.js': {
716
724
  path: 'publish.task.ts',
717
725
  declarations: [
@@ -719,6 +727,7 @@ export const src_json = {
719
727
  { name: 'task', kind: 'variable' },
720
728
  ],
721
729
  },
730
+ './register.js': { path: 'register.ts', declarations: [] },
722
731
  './release.task.js': {
723
732
  path: 'release.task.ts',
724
733
  declarations: [
@@ -790,6 +799,10 @@ export const src_json = {
790
799
  { name: 'SVELTE_RUNES_MATCHER', kind: 'variable' },
791
800
  ],
792
801
  },
802
+ './sveltekit_config_global.js': {
803
+ path: 'sveltekit_config_global.ts',
804
+ declarations: [{ name: 'sveltekit_config_global', kind: 'variable' }],
805
+ },
793
806
  './sveltekit_config.js': {
794
807
  path: 'sveltekit_config.ts',
795
808
  declarations: [
@@ -798,6 +811,13 @@ export const src_json = {
798
811
  { name: 'init_sveltekit_config', kind: 'function' },
799
812
  ],
800
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
+ },
801
821
  './sveltekit_shim_app_environment.js': {
802
822
  path: 'sveltekit_shim_app_environment.ts',
803
823
  declarations: [
@@ -867,6 +887,15 @@ export const src_json = {
867
887
  { name: 'sveltekit_sync', kind: 'function' },
868
888
  ],
869
889
  },
890
+ './task_logging.js': {
891
+ path: 'task_logging.ts',
892
+ declarations: [
893
+ { name: 'log_tasks', kind: 'function' },
894
+ { name: 'log_gro_package_tasks', kind: 'function' },
895
+ { name: 'log_error_reasons', kind: 'function' },
896
+ { name: 'log_task_help', kind: 'function' },
897
+ ],
898
+ },
870
899
  './task_module.js': { path: 'task_module.ts', declarations: [] },
871
900
  './task.js': {
872
901
  path: 'task.ts',
@@ -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_project_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) {
@@ -88,7 +93,7 @@ export const Package_Json = z.intersection(z.record(z.unknown()), z
88
93
  })
89
94
  .passthrough());
90
95
  export const EMPTY_PACKAGE_JSON = { name: '', version: '' };
91
- export const load_package_json = async (dir = is_this_project_gro ? gro_paths.root : paths.root, cache) => {
96
+ export const load_package_json = async (dir = IS_THIS_GRO ? gro_paths.root : paths.root, cache) => {
92
97
  let package_json;
93
98
  if (cache && dir in cache) {
94
99
  return cache[dir];
@@ -97,7 +102,7 @@ export const load_package_json = async (dir = is_this_project_gro ? gro_paths.ro
97
102
  package_json = JSON.parse(await load_package_json_contents(dir));
98
103
  }
99
104
  catch (err) {
100
- throw Error('failed to load package.json at ' + dir);
105
+ return EMPTY_PACKAGE_JSON;
101
106
  }
102
107
  if (cache)
103
108
  cache[dir] = package_json;
@@ -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;
@@ -32,29 +12,26 @@ export interface Paths {
32
12
  build_dev: string;
33
13
  config: string;
34
14
  }
35
- export declare const Url: z.ZodString;
36
- export type Url = Flavored<z.infer<typeof Url>, 'Url'>;
37
- export declare const Email: z.ZodString;
38
- export type Email = Flavored<z.infer<typeof Email>, 'Email'>;
39
15
  export declare const Source_Id: z.ZodString;
40
16
  export type Source_Id = Flavored<z.infer<typeof Source_Id>, 'Source_Id'>;
41
- export declare const Build_Id: z.ZodString;
42
- export type Build_Id = Flavored<z.infer<typeof Build_Id>, 'Build_Id'>;
43
17
  export declare const create_paths: (root_dir: string) => Paths;
44
18
  export declare const paths_from_id: (id: string) => Paths;
45
19
  export declare const is_gro_id: (id: string) => boolean;
46
20
  export declare const to_root_path: (id: string, p?: Paths) => string;
47
21
  export declare const source_id_to_base_path: (source_id: Flavored<string, "Source_Id">, p?: Paths) => string;
48
22
  export declare const base_path_to_source_id: (base_path: string, p?: Paths) => Flavored<string, "Source_Id">;
49
- export declare const lib_path_to_import_id: (base_path: string, p?: Paths) => Flavored<string, "Source_Id">;
50
23
  export declare const import_id_to_lib_path: (import_id: string, p?: Paths) => string;
51
- export declare const to_gro_input_path: (input_path: string) => string;
52
- export declare const replace_root_dir: (id: string, root_dir: string, p?: Paths) => string;
53
24
  export declare const print_path: (path: string, p?: Paths, prefix?: string) => string;
54
25
  export declare const print_path_or_gro_path: (path: string, from_paths?: Paths) => string;
55
26
  export declare const replace_extension: (path: string, new_extension: string) => string;
56
- export declare const gro_dir_basename: string;
27
+ /**
28
+ * Paths for the user repo.
29
+ */
57
30
  export declare const paths: Paths;
58
- export declare const is_this_project_gro: boolean;
31
+ export declare const GRO_PACKAGE_DIR = "gro/";
32
+ export declare const IS_THIS_GRO: boolean;
33
+ /**
34
+ * Paths for the Gro package being used by the user repo.
35
+ */
59
36
  export declare const gro_paths: Paths;
60
- export declare const gro_sveltekit_dist_dir: string;
37
+ export declare const GRO_DIST_DIR: string;
package/dist/paths.js CHANGED
@@ -1,63 +1,33 @@
1
- import { join, basename, 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
- It's the same nomenclature that Rollup uses.
10
-
11
- A `base_path` is the format used by `CheapWatch`.
12
- It's a bare relative path without a source or .gro directory,
13
- e.g. 'foo/bar.ts'.
14
-
15
- `CheapWatch` also uses an array of `path_parts`.
16
- For path './foo/bar/baz.ts',
17
- the `path_parts` are `['foo', 'foo/bar', 'foo/bar/baz.ts']`.
11
+ It's the same name that Rollup uses.
18
12
 
19
13
  */
20
- // TODO pass these to `create_paths` and override from gro config
21
- // TODO this is kinda gross - do we want to maintain the convention to have the trailing slash in most usage?
22
- export const SOURCE_DIRNAME = 'src';
23
- export const GRO_DIRNAME = '.gro';
24
- export const GRO_DIST_PREFIX = 'dist_'; //
25
- export const SERVER_DIST_PATH = 'dist_server'; // TODO should all of these be `_PATH` or should this be `DIRNAME`?
26
- export const LIB_DIRNAME = 'lib'; // TODO use Svelte config `files.lib`
27
- export const ROUTES_DIRNAME = 'routes'; // TODO use Svelte config `files.lib`
28
- export const GRO_DEV_DIRNAME = GRO_DIRNAME + '/dev';
29
- export const SOURCE_DIR = SOURCE_DIRNAME + '/';
30
- export const GRO_DIR = GRO_DIRNAME + '/';
31
- export const GRO_DEV_DIR = GRO_DEV_DIRNAME + '/';
14
+ export const LIB_DIRNAME = basename(sveltekit_config_global.lib_path);
32
15
  export const LIB_PATH = SOURCE_DIR + LIB_DIRNAME;
33
- export const LIB_DIR = LIB_PATH + '/'; // TODO @multiple get from the sveltekit config
34
- export const CONFIG_PATH = 'gro.config.ts';
35
- export const README_FILENAME = 'README.md';
36
- export const SVELTEKIT_CONFIG_FILENAME = 'svelte.config.js';
37
- export const VITE_CONFIG_FILENAME = 'vite.config.ts';
38
- export const SVELTEKIT_DEV_DIRNAME = '.svelte-kit'; // TODO use Svelte config value `outDir`
39
- export const SVELTEKIT_BUILD_DIRNAME = 'build';
40
- export const SVELTEKIT_DIST_DIRNAME = 'dist';
41
- export const NODE_MODULES_DIRNAME = 'node_modules';
42
- export const SVELTEKIT_VITE_CACHE_PATH = NODE_MODULES_DIRNAME + '/.vite';
43
- export const GITHUB_DIRNAME = '.github';
44
- export const GIT_DIRNAME = '.git';
45
- export const TSCONFIG_FILENAME = 'tsconfig.json';
46
- // TODO upstream to util, and probably add `Path`/`FilePath` and `FileUrl`
47
- export const Url = z.string();
48
- export const Email = z.string();
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`?
19
+ // TODO Flavored doesn't work when used in schemas, use Zod brand instead? problem is ergonomics
49
20
  export const Source_Id = z.string();
50
- export const Build_Id = z.string();
51
21
  export const create_paths = (root_dir) => {
52
22
  // TODO remove reliance on trailing slash towards windows support
53
23
  const root = strip_end(root_dir, '/') + '/';
54
24
  return {
55
25
  root,
56
26
  source: root + SOURCE_DIR,
57
- lib: root + LIB_DIR, // TODO @multiple get from the sveltekit config
27
+ lib: root + LIB_DIR,
58
28
  build: root + GRO_DIR,
59
29
  build_dev: root + GRO_DEV_DIR,
60
- config: root + CONFIG_PATH,
30
+ config: root + GRO_CONFIG_PATH,
61
31
  };
62
32
  };
63
33
  export const paths_from_id = (id) => (is_gro_id(id) ? gro_paths : paths);
@@ -70,38 +40,21 @@ export const source_id_to_base_path = (source_id, p = paths) => relative(p.sourc
70
40
  // TODO base_path is an obsolete concept, it was a remnant from forcing `src/`
71
41
  // 'foo/bar/baz.ts' → '/home/me/app/src/foo/bar/baz.ts'
72
42
  export const base_path_to_source_id = (base_path, p = paths) => join(p.source, base_path);
73
- // To run Gro's tasks from its own project, we resolve from dist/ instead of src/.
74
- // 'foo/bar/baz.ts' → '/home/me/app/src/lib/foo/bar/baz.ts'
75
- // 'foo/bar/baz.ts' → '/home/me/app/dist/foo/bar/baz.ts'
76
- export const lib_path_to_import_id = (base_path, p = paths) => {
77
- if (p.root === gro_paths.root) {
78
- return p.root + 'dist/' + base_path;
79
- }
80
- else {
81
- return base_path_to_source_id(LIB_DIRNAME + '/' + base_path, p);
82
- }
83
- };
84
43
  // An `import_id` can be a source_id in a project,
85
44
  // or a Gro source_id when running inside Gro,
86
45
  // or a `gro/dist/` file id in node_modules when inside another project.
87
46
  export const import_id_to_lib_path = (import_id, p = paths_from_id(import_id)) => {
88
47
  if (p.root === gro_paths.root) {
89
- const stripped = strip_start(strip_start(import_id, p.lib), gro_sveltekit_dist_dir); // TODO hacky, needs more work to clarify related things
90
- const lib_path = is_this_project_gro ? stripped : replace_extension(stripped, '.ts');
48
+ const stripped = strip_start(strip_start(import_id, p.lib), GRO_DIST_DIR); // TODO hacky, needs more work to clarify related things
49
+ const lib_path = IS_THIS_GRO ? stripped : replace_extension(stripped, '.ts');
91
50
  return lib_path;
92
51
  }
93
52
  else {
94
53
  return strip_start(import_id, p.lib);
95
54
  }
96
55
  };
97
- export const to_gro_input_path = (input_path) => {
98
- const base_path = input_path === paths.lib.slice(0, -1) ? '' : strip_start(input_path, paths.lib);
99
- return gro_sveltekit_dist_dir + base_path;
100
- };
101
- // Can be used to map a source id from e.g. the cwd to gro's.
102
- export const replace_root_dir = (id, root_dir, p = paths) => join(root_dir, to_root_path(id, p));
103
56
  export const print_path = (path, p = paths, prefix = './') => {
104
- const root_path = path === gro_sveltekit_dist_dir ? 'gro' : to_root_path(path, p);
57
+ const root_path = path === GRO_DIST_DIR ? 'gro' : to_root_path(path, p);
105
58
  return gray(`${prefix}${root_path}`);
106
59
  };
107
60
  export const print_path_or_gro_path = (path, from_paths = paths) => {
@@ -115,14 +68,22 @@ export const replace_extension = (path, new_extension) => {
115
68
  const { length } = extname(path);
116
69
  return (length === 0 ? path : path.substring(0, path.length - length)) + new_extension;
117
70
  };
71
+ /**
72
+ * Paths for the user repo.
73
+ */
74
+ export const paths = create_paths(process.cwd());
75
+ export const GRO_PACKAGE_DIR = 'gro/';
76
+ // TODO document these conditions with comments
77
+ // TODO there's probably a more robust way to do this
118
78
  const filename = fileURLToPath(import.meta.url);
119
- const gro_dir = join(filename, filename.includes('/gro/src/lib/')
79
+ const gro_package_dir_path = join(filename, filename.includes('/gro/src/lib/')
120
80
  ? '../../../'
121
81
  : filename.includes('/gro/dist/')
122
82
  ? '../../'
123
83
  : '../');
124
- export const gro_dir_basename = basename(gro_dir) + '/';
125
- export const paths = create_paths(process.cwd() + '/');
126
- export const is_this_project_gro = gro_dir === paths.root;
127
- export const gro_paths = is_this_project_gro ? paths : create_paths(gro_dir);
128
- export const gro_sveltekit_dist_dir = gro_paths.root + SVELTEKIT_DIST_DIRNAME + '/';
84
+ export const IS_THIS_GRO = gro_package_dir_path === paths.root;
85
+ /**
86
+ * Paths for the Gro package being used by the user repo.
87
+ */
88
+ export const gro_paths = IS_THIS_GRO ? paths : create_paths(gro_package_dir_path);
89
+ export const GRO_DIST_DIR = gro_paths.root + SVELTEKIT_DIST_DIRNAME + '/';