@ryanatkn/gro 0.141.1 → 0.143.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 (114) hide show
  1. package/dist/build.task.js +1 -1
  2. package/dist/changeset.task.d.ts.map +1 -1
  3. package/dist/changeset.task.js +4 -4
  4. package/dist/check.task.d.ts.map +1 -1
  5. package/dist/check.task.js +4 -2
  6. package/dist/clean_fs.js +1 -1
  7. package/dist/cli.js +1 -1
  8. package/dist/{path_constants.d.ts → constants.d.ts} +4 -1
  9. package/dist/constants.d.ts.map +1 -0
  10. package/dist/{path_constants.js → constants.js} +3 -0
  11. package/dist/deploy.task.js +1 -1
  12. package/dist/dev.task.js +1 -1
  13. package/dist/esbuild_plugin_svelte.js +1 -1
  14. package/dist/esbuild_plugin_sveltekit_local_imports.js +1 -1
  15. package/dist/esbuild_plugin_sveltekit_shim_app.js +1 -1
  16. package/dist/esbuild_plugin_sveltekit_shim_env.js +1 -1
  17. package/dist/filer.d.ts +7 -0
  18. package/dist/filer.d.ts.map +1 -1
  19. package/dist/filer.js +28 -29
  20. package/dist/format.task.d.ts.map +1 -1
  21. package/dist/format.task.js +2 -2
  22. package/dist/format_directory.d.ts +1 -1
  23. package/dist/format_directory.d.ts.map +1 -1
  24. package/dist/format_directory.js +5 -6
  25. package/dist/gen.task.js +1 -1
  26. package/dist/gro_config.d.ts +12 -2
  27. package/dist/gro_config.d.ts.map +1 -1
  28. package/dist/gro_config.js +10 -6
  29. package/dist/gro_helpers.d.ts +1 -1
  30. package/dist/gro_helpers.d.ts.map +1 -1
  31. package/dist/gro_helpers.js +3 -3
  32. package/dist/gro_plugin_server.js +4 -4
  33. package/dist/gro_plugin_sveltekit_app.d.ts.map +1 -1
  34. package/dist/gro_plugin_sveltekit_app.js +5 -5
  35. package/dist/gro_plugin_sveltekit_library.js +7 -7
  36. package/dist/loader.d.ts.map +1 -1
  37. package/dist/loader.js +23 -17
  38. package/dist/module.js +1 -1
  39. package/dist/moss_helpers.d.ts +1 -1
  40. package/dist/moss_helpers.d.ts.map +1 -1
  41. package/dist/moss_helpers.js +4 -3
  42. package/dist/package.d.ts +334 -172
  43. package/dist/package.d.ts.map +1 -1
  44. package/dist/package.js +51 -51
  45. package/dist/package_json.d.ts +9 -6
  46. package/dist/package_json.d.ts.map +1 -1
  47. package/dist/package_json.js +21 -6
  48. package/dist/package_meta.d.ts +1 -1
  49. package/dist/parse_imports.js +1 -1
  50. package/dist/paths.js +1 -1
  51. package/dist/publish.task.d.ts.map +1 -1
  52. package/dist/publish.task.js +7 -20
  53. package/dist/reinstall.task.js +11 -11
  54. package/dist/resolve_node_specifier.d.ts +7 -1
  55. package/dist/resolve_node_specifier.d.ts.map +1 -1
  56. package/dist/resolve_node_specifier.js +78 -14
  57. package/dist/resolve_specifier.d.ts +2 -6
  58. package/dist/resolve_specifier.d.ts.map +1 -1
  59. package/dist/resolve_specifier.js +2 -6
  60. package/dist/run_task.js +1 -1
  61. package/dist/src_json.d.ts +39 -3
  62. package/dist/src_json.d.ts.map +1 -1
  63. package/dist/sveltekit_config.d.ts +1 -1
  64. package/dist/sveltekit_config.d.ts.map +1 -1
  65. package/dist/sveltekit_config.js +1 -1
  66. package/dist/sveltekit_helpers.d.ts +3 -3
  67. package/dist/sveltekit_helpers.d.ts.map +1 -1
  68. package/dist/sveltekit_helpers.js +7 -7
  69. package/dist/sync.task.js +5 -5
  70. package/dist/upgrade.task.d.ts.map +1 -1
  71. package/dist/upgrade.task.js +4 -2
  72. package/dist/watch_dir.d.ts.map +1 -1
  73. package/dist/watch_dir.js +5 -5
  74. package/package.json +18 -18
  75. package/src/lib/build.task.ts +1 -1
  76. package/src/lib/changeset.task.ts +4 -3
  77. package/src/lib/check.task.ts +4 -2
  78. package/src/lib/clean_fs.ts +1 -1
  79. package/src/lib/cli.ts +1 -1
  80. package/src/lib/{path_constants.ts → constants.ts} +4 -0
  81. package/src/lib/deploy.task.ts +1 -1
  82. package/src/lib/dev.task.ts +1 -1
  83. package/src/lib/esbuild_plugin_svelte.ts +1 -1
  84. package/src/lib/esbuild_plugin_sveltekit_local_imports.ts +1 -1
  85. package/src/lib/esbuild_plugin_sveltekit_shim_app.ts +1 -1
  86. package/src/lib/esbuild_plugin_sveltekit_shim_env.ts +1 -1
  87. package/src/lib/filer.ts +37 -27
  88. package/src/lib/format.task.ts +10 -2
  89. package/src/lib/format_directory.ts +10 -9
  90. package/src/lib/gen.task.ts +1 -1
  91. package/src/lib/gro_config.ts +23 -5
  92. package/src/lib/gro_helpers.ts +3 -2
  93. package/src/lib/gro_plugin_server.ts +4 -4
  94. package/src/lib/gro_plugin_sveltekit_app.ts +7 -5
  95. package/src/lib/gro_plugin_sveltekit_library.ts +7 -7
  96. package/src/lib/loader.ts +25 -17
  97. package/src/lib/module.ts +1 -1
  98. package/src/lib/moss_helpers.ts +4 -2
  99. package/src/lib/package.ts +51 -51
  100. package/src/lib/package_json.ts +23 -6
  101. package/src/lib/package_meta.ts +1 -1
  102. package/src/lib/parse_imports.ts +1 -1
  103. package/src/lib/paths.ts +1 -1
  104. package/src/lib/publish.task.ts +7 -22
  105. package/src/lib/reinstall.task.ts +11 -11
  106. package/src/lib/resolve_node_specifier.ts +100 -18
  107. package/src/lib/resolve_specifier.ts +2 -6
  108. package/src/lib/run_task.ts +1 -1
  109. package/src/lib/sveltekit_config.ts +2 -2
  110. package/src/lib/sveltekit_helpers.ts +7 -4
  111. package/src/lib/sync.task.ts +5 -5
  112. package/src/lib/upgrade.task.ts +4 -2
  113. package/src/lib/watch_dir.ts +6 -6
  114. package/dist/path_constants.d.ts.map +0 -1
@@ -7,7 +7,7 @@ export const Args = z
7
7
  'no-sync': z.boolean({ description: 'opt out of gro sync' }).default(false),
8
8
  install: z.boolean({ description: 'dual of no-install' }).default(true),
9
9
  'no-install': z // convenience, same as `gro build -- gro sync --no-install` but the latter takes precedence
10
- .boolean({ description: 'opt out of `npm install` before building' })
10
+ .boolean({ description: 'opt out of installing packages before building' })
11
11
  .default(false),
12
12
  })
13
13
  .strict();
@@ -1 +1 @@
1
- {"version":3,"file":"changeset.task.d.ts","sourceRoot":"../src/lib/","sources":["changeset.task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAQtB,OAAO,EAAa,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAchD,eAAO,MAAM,IAAI;IAEf;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBK,CAAC;AACX,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CAiF3B,CAAC"}
1
+ {"version":3,"file":"changeset.task.d.ts","sourceRoot":"../src/lib/","sources":["changeset.task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAQtB,OAAO,EAAa,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAchD,eAAO,MAAM,IAAI;IAEf;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBK,CAAC;AACX,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CAkF3B,CAAC"}
@@ -25,7 +25,7 @@ export const Args = z
25
25
  .default('@changesets/changelog-git'),
26
26
  dep: z.boolean({ description: 'dual of no-dep' }).default(true),
27
27
  'no-dep': z
28
- .boolean({ description: 'opt out of npm installing the changelog package' })
28
+ .boolean({ description: 'opt out of installing the changelog package' })
29
29
  .default(false),
30
30
  origin: Git_Origin.describe('git origin to deploy to').default('origin'),
31
31
  changeset_cli: z.string({ description: 'the changeset CLI to use' }).default(CHANGESET_CLI),
@@ -44,7 +44,7 @@ export const task = {
44
44
  summary: 'call changeset with gro patterns',
45
45
  Args,
46
46
  run: async (ctx) => {
47
- const { invoke_task, args: { _, minor, major, dir, access: access_arg, changelog, dep, origin, changeset_cli }, log, sveltekit_config, } = ctx;
47
+ const { invoke_task, args: { _, minor, major, dir, access: access_arg, changelog, dep, origin, changeset_cli }, log, sveltekit_config, config, } = ctx;
48
48
  const message = _.join(' ');
49
49
  if (!message && (minor || major))
50
50
  throw new Task_Error('cannot bump version without a message');
@@ -79,11 +79,11 @@ export const task = {
79
79
  }
80
80
  await spawn('git', ['add', dir]);
81
81
  if (dep) {
82
- await spawn('npm', ['i', '-D', changelog]);
82
+ await spawn(config.pm_cli, ['install', '-D', changelog]);
83
83
  }
84
84
  }
85
85
  // TODO small problem here where generated files don't get committed
86
- await invoke_task('sync', { install: inited || !dep }); // after the `npm i` above, and in all cases
86
+ await invoke_task('sync', { install: inited || !dep }); // after installing above, and in all cases
87
87
  if (message) {
88
88
  // TODO see the helper below, simplify this to CLI flags when support is added to Changesets
89
89
  const changeset_adder = create_changeset_adder(package_json.name, dir, message, bump);
@@ -1 +1 @@
1
- {"version":3,"file":"check.task.d.ts","sourceRoot":"../src/lib/","sources":["check.task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAItB,OAAO,EAAa,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAIhD,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsBP,CAAC;AACX,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CAyD3B,CAAC"}
1
+ {"version":3,"file":"check.task.d.ts","sourceRoot":"../src/lib/","sources":["check.task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAItB,OAAO,EAAa,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAIhD,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwBP,CAAC;AACX,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CAyD3B,CAAC"}
@@ -21,7 +21,9 @@ export const Args = z
21
21
  sync: z.boolean({ description: 'dual of no-sync' }).default(true),
22
22
  'no-sync': z.boolean({ description: 'opt out of syncing' }).default(false),
23
23
  install: z.boolean({ description: 'dual of no-install' }).default(true),
24
- 'no-install': z.boolean({ description: 'opt out of `npm install` when syncing' }).default(false), // convenience, same as `gro check -- gro sync --no-install` but the latter takes precedence
24
+ 'no-install': z
25
+ .boolean({ description: 'opt out of installing packages when syncing' })
26
+ .default(false), // convenience, same as `gro check -- gro sync --no-install` but the latter takes precedence
25
27
  workspace: z
26
28
  .boolean({ description: 'ensure a clean git workspace, useful for CI, also implies --no-sync' })
27
29
  .default(false),
@@ -33,7 +35,7 @@ export const task = {
33
35
  run: async ({ args, invoke_task, log, config }) => {
34
36
  const { typecheck, test, gen, format, package_json, lint, sync, install, workspace } = args;
35
37
  // When checking the workspace, which was added for CI, never sync.
36
- // Setup like `npm i` and `sveltekit-sync` should be done in the CI setup.
38
+ // Setup like installing packages and `sveltekit-sync` should be done in the CI setup.
37
39
  if (sync && !workspace) {
38
40
  await invoke_task('sync', { install, gen: false }); // never generate because `gro gen --check` runs below
39
41
  }
package/dist/clean_fs.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { rm } from 'node:fs/promises';
2
2
  import { readdirSync } from 'node:fs';
3
3
  import { paths } from './paths.js';
4
- import { NODE_MODULES_DIRNAME, GRO_DIST_PREFIX, SVELTEKIT_DEV_DIRNAME, SVELTEKIT_BUILD_DIRNAME, SVELTEKIT_VITE_CACHE_PATH, SVELTEKIT_DIST_DIRNAME, } from './path_constants.js';
4
+ import { NODE_MODULES_DIRNAME, GRO_DIST_PREFIX, SVELTEKIT_DEV_DIRNAME, SVELTEKIT_BUILD_DIRNAME, SVELTEKIT_VITE_CACHE_PATH, SVELTEKIT_DIST_DIRNAME, } from './constants.js';
5
5
  export const clean_fs = async ({ build = false, build_dev = false, build_dist = false, sveltekit = false, nodemodules = false, }, rm_options = { force: true, recursive: true }) => {
6
6
  const promises = [];
7
7
  if (build) {
package/dist/cli.js CHANGED
@@ -3,7 +3,7 @@ import { spawn, spawn_process, } from '@ryanatkn/belt/process.js';
3
3
  import { join } from 'node:path';
4
4
  import { existsSync } from 'node:fs';
5
5
  import { fileURLToPath } from 'node:url';
6
- import { NODE_MODULES_DIRNAME } from './path_constants.js';
6
+ import { NODE_MODULES_DIRNAME } from './constants.js';
7
7
  import { print_command_args } from './args.js';
8
8
  /**
9
9
  * Searches the filesystem for the CLI `name`, first local to the cwd and then globally.
@@ -23,4 +23,7 @@ export declare const TS_MATCHER: RegExp;
23
23
  export declare const JS_MATCHER: RegExp;
24
24
  export declare const JSON_MATCHER: RegExp;
25
25
  export declare const EVERYTHING_MATCHER: RegExp;
26
- //# sourceMappingURL=path_constants.d.ts.map
26
+ export declare const JS_CLI_DEFAULT = "node";
27
+ export declare const PM_CLI_DEFAULT = "npm";
28
+ export declare const PRETTIER_CLI_DEFAULT = "prettier";
29
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"../src/lib/","sources":["constants.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,cAAc,QAAQ,CAAC;AACpC,eAAO,MAAM,WAAW,SAAS,CAAC;AAClC,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAC9C,eAAO,MAAM,eAAe,QAAuB,CAAC;AACpD,eAAO,MAAM,UAAU,QAAuB,CAAC;AAC/C,eAAO,MAAM,OAAO,QAAoB,CAAC;AACzC,eAAO,MAAM,WAAW,QAAwB,CAAC;AACjD,eAAO,MAAM,eAAe,kBAAkB,CAAC;AAC/C,eAAO,MAAM,eAAe,cAAc,CAAC;AAC3C,eAAO,MAAM,yBAAyB,qBAAqB,CAAC;AAC5D,eAAO,MAAM,oBAAoB,mBAAmB,CAAC;AACrD,eAAO,MAAM,oBAAoB,iBAAiB,CAAC;AACnD,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AACrD,eAAO,MAAM,qBAAqB,gBAAgB,CAAC;AACnD,eAAO,MAAM,uBAAuB,UAAU,CAAC;AAC/C,eAAO,MAAM,sBAAsB,SAAS,CAAC;AAC7C,eAAO,MAAM,yBAAyB,QAAkC,CAAC;AACzE,eAAO,MAAM,cAAc,YAAY,CAAC;AACxC,eAAO,MAAM,WAAW,SAAS,CAAC;AAClC,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD,eAAO,MAAM,UAAU,QAAwB,CAAC;AAChD,eAAO,MAAM,UAAU,QAAwB,CAAC;AAChD,eAAO,MAAM,YAAY,QAAY,CAAC;AACtC,eAAO,MAAM,kBAAkB,QAAO,CAAC;AAEvC,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,cAAc,QAAQ,CAAC;AACpC,eAAO,MAAM,oBAAoB,aAAa,CAAC"}
@@ -30,3 +30,6 @@ export const TS_MATCHER = /\.(ts|tsx|mts|cts)$/;
30
30
  export const JS_MATCHER = /\.(js|jsx|mjs|cjs)$/;
31
31
  export const JSON_MATCHER = /\.json$/;
32
32
  export const EVERYTHING_MATCHER = /.*/;
33
+ export const JS_CLI_DEFAULT = 'node';
34
+ export const PM_CLI_DEFAULT = 'npm';
35
+ export const PRETTIER_CLI_DEFAULT = 'prettier';
@@ -7,7 +7,7 @@ import { join, resolve } from 'node:path';
7
7
  import { existsSync, readdirSync } from 'node:fs';
8
8
  import { Task_Error } from './task.js';
9
9
  import { print_path } from './paths.js';
10
- import { GRO_DIRNAME, GIT_DIRNAME, SVELTEKIT_BUILD_DIRNAME } from './path_constants.js';
10
+ import { GRO_DIRNAME, GIT_DIRNAME, SVELTEKIT_BUILD_DIRNAME } from './constants.js';
11
11
  import { empty_dir } from './fs.js';
12
12
  import { git_check_clean_workspace, git_checkout, git_local_branch_exists, git_remote_branch_exists, Git_Origin, Git_Branch, git_delete_local_branch, git_push_to_create, git_reset_branch_to_first_commit, git_pull, git_fetch, git_check_setting_pull_rebase, git_clone_locally, git_current_branch_name, } from './git.js';
13
13
  // docs at ./docs/deploy.md
package/dist/dev.task.js CHANGED
@@ -13,7 +13,7 @@ export const Args = z
13
13
  'no-sync': z.boolean({ description: 'opt out of gro sync' }).default(false),
14
14
  install: z.boolean({ description: 'dual of no-install' }).default(true),
15
15
  'no-install': z // convenience, same as `gro dev -- gro sync --no-install` but the latter takes precedence
16
- .boolean({ description: 'opt out of `npm install` before starting the dev server' })
16
+ .boolean({ description: 'opt out of installing packages before starting the dev server' })
17
17
  .default(false),
18
18
  })
19
19
  .strict();
@@ -5,7 +5,7 @@ import { relative } from 'node:path';
5
5
  import { SVELTE_MATCHER, SVELTE_RUNES_MATCHER } from './svelte_helpers.js';
6
6
  import { to_define_import_meta_env, default_ts_transform_options } from './esbuild_helpers.js';
7
7
  import { default_sveltekit_config, to_default_compile_module_options, } from './sveltekit_config.js';
8
- import { TS_MATCHER } from './path_constants.js';
8
+ import { TS_MATCHER } from './constants.js';
9
9
  export const esbuild_plugin_svelte = (options) => {
10
10
  const { dev, base_url, dir = process.cwd(), svelte_compile_options = default_sveltekit_config.svelte_compile_options, svelte_compile_module_options = to_default_compile_module_options(svelte_compile_options), svelte_preprocessors, ts_transform_options = default_ts_transform_options, is_ts = (f) => TS_MATCHER.test(f), } = options;
11
11
  const final_ts_transform_options = {
@@ -1,7 +1,7 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { dirname } from 'node:path';
3
3
  import { resolve_specifier } from './resolve_specifier.js';
4
- import { EVERYTHING_MATCHER } from './path_constants.js';
4
+ import { EVERYTHING_MATCHER } from './constants.js';
5
5
  /**
6
6
  * Adds support for imports to both `.ts` and `.js`,
7
7
  * as well as imports without extensions that resolve to `.js` or `.ts`.
@@ -1,5 +1,5 @@
1
1
  import { render_sveltekit_shim_app_environment, render_sveltekit_shim_app_paths, sveltekit_shim_app_specifiers, } from './sveltekit_shim_app.js';
2
- import { EVERYTHING_MATCHER } from './path_constants.js';
2
+ import { EVERYTHING_MATCHER } from './constants.js';
3
3
  export const esbuild_plugin_sveltekit_shim_app = ({ dev, base_url, assets_url, }) => ({
4
4
  name: 'sveltekit_shim_app',
5
5
  setup: (build) => {
@@ -1,5 +1,5 @@
1
1
  import { render_env_shim_module } from './sveltekit_shim_env.js';
2
- import { EVERYTHING_MATCHER } from './path_constants.js';
2
+ import { EVERYTHING_MATCHER } from './constants.js';
3
3
  import { SVELTEKIT_ENV_MATCHER } from './sveltekit_helpers.js';
4
4
  const namespace = 'sveltekit_shim_env';
5
5
  export const esbuild_plugin_sveltekit_shim_env = ({ dev, public_prefix, private_prefix, env_dir, env_files, ambient_env, }) => ({
package/dist/filer.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { Omit_Strict } from '@ryanatkn/belt/types.js';
2
2
  import type { Path_Id } from './path.js';
3
3
  import { watch_dir, type Watcher_Change, type Options as Watch_Dir_Options } from './watch_dir.js';
4
+ import type { Package_Json } from './package_json.js';
4
5
  export interface Source_File {
5
6
  id: Path_Id;
6
7
  /**
@@ -8,6 +9,11 @@ export interface Source_File {
8
9
  * We create the file in memory to track its dependents regardless of its existence on disk.
9
10
  */
10
11
  contents: string | null;
12
+ /**
13
+ * Is the source file outside of the `root_dir` or excluded by `watch_dir_options.filter`?
14
+ */
15
+ external: boolean;
16
+ ctime: number | null;
11
17
  mtime: number | null;
12
18
  dependents: Map<Path_Id, Source_File>;
13
19
  dependencies: Map<Path_Id, Source_File>;
@@ -17,6 +23,7 @@ export type On_Filer_Change = (change: Watcher_Change, source_file: Source_File)
17
23
  export interface Options {
18
24
  watch_dir?: typeof watch_dir;
19
25
  watch_dir_options?: Partial<Omit_Strict<Watch_Dir_Options, 'on_change'>>;
26
+ package_json_cache?: Record<string, Package_Json>;
20
27
  }
21
28
  export declare class Filer {
22
29
  #private;
@@ -1 +1 @@
1
- {"version":3,"file":"filer.d.ts","sourceRoot":"../src/lib/","sources":["filer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAGzD,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,EACN,SAAS,EAET,KAAK,cAAc,EACnB,KAAK,OAAO,IAAI,iBAAiB,EAEjC,MAAM,gBAAgB,CAAC;AAYxB,MAAM,WAAW,WAAW;IAC3B,EAAE,EAAE,OAAO,CAAC;IAEZ;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,EAAE,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IACtC,YAAY,EAAE,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;CACxC;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;AAEhD,MAAM,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,KAAK,IAAI,CAAC;AAEzF,MAAM,WAAW,OAAO;IACvB,SAAS,CAAC,EAAE,OAAO,SAAS,CAAC;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC,CAAC;CACzE;AAED,qBAAa,KAAK;;IACjB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAa;gBAK1C,O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iBAAiB,EAAE,WAAW,CAAC,CAAC,CAAC;IACzE,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CAClD;AAED,qBAAa,KAAK;;IACjB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAa;gBAO1C,OAAO,GAAE,OAAsB;IAY3C,SAAS,OAAQ,OAAO,KAAG,WAAW,GAAG,SAAS,CAEhD;IAEF,aAAa,OAAQ,OAAO,KAAG,WAAW,CAkBxC;IAmII,KAAK,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAKxD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAa5B"}
package/dist/filer.js CHANGED
@@ -9,6 +9,7 @@ import { resolve_specifier } from './resolve_specifier.js';
9
9
  import { default_sveltekit_config } from './sveltekit_config.js';
10
10
  import { map_sveltekit_aliases } from './sveltekit_helpers.js';
11
11
  import { Unreachable_Error } from '@ryanatkn/belt/error.js';
12
+ import { resolve_node_specifier } from './resolve_node_specifier.js';
12
13
  // TODO see below
13
14
  // import {resolve_node_specifier} from './resolve_node_specifier.js';
14
15
  const aliases = Object.entries(default_sveltekit_config.alias);
@@ -17,10 +18,12 @@ export class Filer {
17
18
  files = new Map();
18
19
  #watch_dir;
19
20
  #watch_dir_options;
21
+ #package_json_cache;
20
22
  constructor(options = EMPTY_OBJECT) {
21
23
  this.#watch_dir = options.watch_dir ?? watch_dir;
22
24
  this.#watch_dir_options = options.watch_dir_options ?? EMPTY_OBJECT;
23
25
  this.root_dir = resolve(options.watch_dir_options?.dir ?? paths.source);
26
+ this.#package_json_cache = options.package_json_cache ?? {};
24
27
  }
25
28
  #watching;
26
29
  #listeners = new Set();
@@ -35,18 +38,23 @@ export class Filer {
35
38
  const file = {
36
39
  id,
37
40
  contents: null,
41
+ external: this.#is_external(id), // TODO maybe filter externals by default? the user needs to configure the filer then
42
+ ctime: null,
38
43
  mtime: null,
39
44
  dependents: new Map(),
40
45
  dependencies: new Map(),
41
46
  };
42
47
  this.files.set(id, file);
48
+ // TODO this may need to be batched/deferred
49
+ if (file.external) {
50
+ this.#on_change({ type: 'add', path: file.id, is_directory: false });
51
+ }
43
52
  return file;
44
53
  };
45
54
  #update(id) {
46
55
  const file = this.get_or_create(id);
47
56
  const stats = existsSync(id) ? statSync(id) : null;
48
- // const mtime_prev = file.mtime;
49
- // const mtime_changed = mtime_prev !== (stats?.mtimeMs ?? null);
57
+ file.ctime = stats?.ctimeMs ?? null;
50
58
  file.mtime = stats?.mtimeMs ?? null;
51
59
  const new_contents = stats ? readFileSync(id, 'utf8') : null;
52
60
  if (file.contents === new_contents) {
@@ -61,37 +69,24 @@ export class Filer {
61
69
  // TODO logic is duplicated from loader
62
70
  const path = map_sveltekit_aliases(specifier, aliases);
63
71
  // The specifier `path` has now been mapped to its final form, so we can inspect it.
64
- if (path[0] === '.' || path[0] === '/') {
65
- const { path_id } = resolve_specifier(path, dir);
66
- dependencies_removed.delete(path_id);
67
- if (!dependencies_before.has(path_id)) {
68
- const d = this.get_or_create(path_id);
69
- file.dependencies.set(d.id, d);
70
- d.dependents.set(file.id, file);
71
- }
72
+ const resolved = path[0] === '.' || path[0] === '/'
73
+ ? resolve_specifier(path, dir)
74
+ : resolve_node_specifier(path, undefined, file.id, this.#package_json_cache, false);
75
+ if (!resolved)
76
+ continue; // ignore any missing imports like Node identifiers
77
+ const { path_id } = resolved;
78
+ dependencies_removed.delete(path_id);
79
+ if (!dependencies_before.has(path_id)) {
80
+ const d = this.get_or_create(path_id);
81
+ file.dependencies.set(d.id, d);
82
+ d.dependents.set(file.id, file);
72
83
  }
73
- // TODO this doesn't work
74
- // const resolved =
75
- // path[0] === '.' || path[0] === '/'
76
- // ? resolve_specifier(path, dir)
77
- // : resolve_node_specifier(path, dir);
78
- // const {path_id} = resolved;
79
- // dependencies_removed.delete(path_id);
80
- // if (!dependencies_before.has(path_id)) {
81
- // const d = this.get_or_create(path_id);
82
- // file.dependencies.set(d.id, d);
83
- // d.dependents.set(file.id, file);
84
- // }
85
84
  }
86
85
  // update any removed dependencies
87
86
  for (const dependency_removed of dependencies_removed) {
88
- const deleted1 = file.dependencies.delete(dependency_removed);
89
- if (!deleted1)
90
- throw Error('expected to delete1 ' + file.id); // TODO @many delete if correct
87
+ file.dependencies.delete(dependency_removed);
91
88
  const dependency_removed_file = this.get_or_create(dependency_removed);
92
- const deleted2 = dependency_removed_file.dependents.delete(file.id);
93
- if (!deleted2)
94
- throw Error('expected to delete2 ' + file.id); // TODO @many delete if correct
89
+ dependency_removed_file.dependents.delete(file.id);
95
90
  }
96
91
  return file;
97
92
  }
@@ -151,7 +146,7 @@ export class Filer {
151
146
  }
152
147
  #on_change = (change) => {
153
148
  if (change.is_directory)
154
- return;
149
+ return; // TODO manage directories?
155
150
  let source_file;
156
151
  switch (change.type) {
157
152
  case 'add':
@@ -182,4 +177,8 @@ export class Filer {
182
177
  this.#watching = undefined;
183
178
  }
184
179
  }
180
+ #is_external(id) {
181
+ const { filter } = this.#watch_dir_options;
182
+ return !id.startsWith(this.root_dir + '/') || (!!filter && !filter(id, false));
183
+ }
185
184
  }
@@ -1 +1 @@
1
- {"version":3,"file":"format.task.d.ts","sourceRoot":"../src/lib/","sources":["format.task.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAa,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAIhD,eAAO,MAAM,IAAI;;;;;;EAMP,CAAC;AACX,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CAa3B,CAAC"}
1
+ {"version":3,"file":"format.task.d.ts","sourceRoot":"../src/lib/","sources":["format.task.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAa,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAIhD,eAAO,MAAM,IAAI;;;;;;EAMP,CAAC;AACX,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CAqB3B,CAAC"}
@@ -13,10 +13,10 @@ export const Args = z
13
13
  export const task = {
14
14
  summary: 'format source files',
15
15
  Args,
16
- run: async ({ args, log }) => {
16
+ run: async ({ args, log, config }) => {
17
17
  const { check } = args;
18
18
  // TODO forward prettier args
19
- const format_result = await format_directory(log, paths.source, check);
19
+ const format_result = await format_directory(log, paths.source, check, undefined, undefined, undefined, config.pm_cli);
20
20
  if (!format_result.ok) {
21
21
  throw new Task_Error(`Failed ${check ? 'formatting check' : 'to format'}. ${print_spawn_result(format_result)}`);
22
22
  }
@@ -7,5 +7,5 @@ import { type Cli } from './cli.js';
7
7
  * This is separated from `./format_file` to avoid importing all of the `prettier` code
8
8
  * inside modules that import this one. (which has a nontrivial cost)
9
9
  */
10
- export declare const format_directory: (log: Logger, dir: string, check?: boolean, extensions?: string, root_paths?: string, prettier_cli?: string | Cli) => Promise<Spawn_Result>;
10
+ export declare const format_directory: (log: Logger, dir: string, check?: boolean, extensions?: string, root_paths?: string, prettier_cli?: string | Cli, pm_cli?: string) => Promise<Spawn_Result>;
11
11
  //# sourceMappingURL=format_directory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"format_directory.d.ts","sourceRoot":"../src/lib/","sources":["format_directory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,uBAAuB,CAAC;AAYlD,OAAO,EAAyB,KAAK,GAAG,EAAC,MAAM,UAAU,CAAC;AAc1D;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,QACvB,MAAM,OACN,MAAM,4EAIG,MAAM,GAAG,GAAG,KACxB,OAAO,CAAC,YAAY,CActB,CAAC"}
1
+ {"version":3,"file":"format_directory.d.ts","sourceRoot":"../src/lib/","sources":["format_directory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,uBAAuB,CAAC;AAclD,OAAO,EAAyB,KAAK,GAAG,EAAC,MAAM,UAAU,CAAC;AAY1D;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,QACvB,MAAM,OACN,MAAM,4EAIG,MAAM,GAAG,GAAG,WAClB,MAAM,KACZ,OAAO,CAAC,YAAY,CActB,CAAC"}
@@ -1,10 +1,9 @@
1
1
  import { paths } from './paths.js';
2
- import { GITHUB_DIRNAME, README_FILENAME, SVELTEKIT_CONFIG_FILENAME, VITE_CONFIG_FILENAME, TSCONFIG_FILENAME, GRO_CONFIG_PATH, } from './path_constants.js';
2
+ import { GITHUB_DIRNAME, README_FILENAME, SVELTEKIT_CONFIG_FILENAME, VITE_CONFIG_FILENAME, TSCONFIG_FILENAME, GRO_CONFIG_PATH, PM_CLI_DEFAULT, PRETTIER_CLI_DEFAULT, } from './constants.js';
3
3
  import { serialize_args, to_forwarded_args } from './args.js';
4
4
  import { spawn_cli, to_cli_name } from './cli.js';
5
- const PRETTIER_CLI = 'prettier';
6
- const DEFAULT_EXTENSIONS = 'ts,js,json,svelte,html,css,md,yml';
7
- const DEFAULT_ROOT_PATHS = `${[
5
+ const EXTENSIONS_DEFAULT = 'ts,js,json,svelte,html,css,md,yml';
6
+ const ROOT_PATHS_DEFAULT = `${[
8
7
  README_FILENAME,
9
8
  GRO_CONFIG_PATH,
10
9
  SVELTEKIT_CONFIG_FILENAME,
@@ -18,7 +17,7 @@ const DEFAULT_ROOT_PATHS = `${[
18
17
  * This is separated from `./format_file` to avoid importing all of the `prettier` code
19
18
  * inside modules that import this one. (which has a nontrivial cost)
20
19
  */
21
- export const format_directory = async (log, dir, check = false, extensions = DEFAULT_EXTENSIONS, root_paths = DEFAULT_ROOT_PATHS, prettier_cli = PRETTIER_CLI) => {
20
+ export const format_directory = async (log, dir, check = false, extensions = EXTENSIONS_DEFAULT, root_paths = ROOT_PATHS_DEFAULT, prettier_cli = PRETTIER_CLI_DEFAULT, pm_cli = PM_CLI_DEFAULT) => {
22
21
  const forwarded_args = to_forwarded_args(to_cli_name(prettier_cli));
23
22
  forwarded_args[check ? 'check' : 'write'] = true;
24
23
  const serialized_args = serialize_args(forwarded_args);
@@ -28,6 +27,6 @@ export const format_directory = async (log, dir, check = false, extensions = DEF
28
27
  }
29
28
  const spawned = await spawn_cli(prettier_cli, serialized_args, log);
30
29
  if (!spawned)
31
- throw new Error(`failed to find \`${to_cli_name(prettier_cli)}\` CLI locally or globally, do you need to run \`npm i\`?`);
30
+ throw new Error(`failed to find \`${to_cli_name(prettier_cli)}\` CLI locally or globally, do you need to run \`${pm_cli} install\`?`);
32
31
  return spawned;
33
32
  };
package/dist/gen.task.js CHANGED
@@ -9,7 +9,7 @@ import { format_file } from './format_file.js';
9
9
  import { print_path } from './paths.js';
10
10
  import { log_error_reasons } from './task_logging.js';
11
11
  import { write_gen_results, analyze_gen_results, find_genfiles, load_genfiles } from './gen.js';
12
- import { SOURCE_DIRNAME } from './path_constants.js';
12
+ import { SOURCE_DIRNAME } from './constants.js';
13
13
  export const Args = z
14
14
  .object({
15
15
  _: z.array(Raw_Input_Path, { description: 'input paths to generate' }).default([SOURCE_DIRNAME]),
@@ -27,6 +27,14 @@ export interface Gro_Config {
27
27
  * directories and files are included if they pass all of these filters.
28
28
  */
29
29
  search_filters: Path_Filter[];
30
+ /**
31
+ * The CLI to use that's compatible with `node`.
32
+ */
33
+ js_cli: string;
34
+ /**
35
+ * The CLI to use that's compatible with `npm install` and `npm link`. Defaults to `'npm'`.
36
+ */
37
+ pm_cli: string;
30
38
  }
31
39
  /**
32
40
  * The relaxed variant of `Gro_Config` that users can provide via `gro.config.ts`.
@@ -38,6 +46,8 @@ export interface Raw_Gro_Config {
38
46
  map_package_json?: Map_Package_Json | null;
39
47
  task_root_dirs?: string[];
40
48
  search_filters?: Path_Filter | Path_Filter[] | null;
49
+ js_cli?: string;
50
+ pm_cli?: string;
41
51
  }
42
52
  export type Create_Gro_Config = (base_config: Gro_Config) => Raw_Gro_Config | Promise<Raw_Gro_Config>;
43
53
  export declare const create_empty_gro_config: () => Gro_Config;
@@ -47,8 +57,8 @@ export declare const create_empty_gro_config: () => Gro_Config;
47
57
  * Customize via `search_filters` in the `Gro_Config`.
48
58
  * See the test cases for the exact behavior.
49
59
  */
50
- export declare const DEFAULT_SEARCH_EXCLUDER: RegExp;
51
- export declare const DEFAULT_EXPORTS_EXCLUDER: RegExp;
60
+ export declare const SEARCH_EXCLUDER_DEFAULT: RegExp;
61
+ export declare const EXPORTS_EXCLUDER_DEFAULT: RegExp;
52
62
  /**
53
63
  * Transforms a `Raw_Gro_Config` to the more strict `Gro_Config`.
54
64
  * This allows users to provide a more relaxed config.
@@ -1 +1 @@
1
- {"version":3,"file":"gro_config.d.ts","sourceRoot":"../src/lib/","sources":["gro_config.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,WAAW,CAAC;AAEpD;;;;GAIG;AACH,MAAM,WAAW,UAAU;IAC1B;;OAEG;IACH,OAAO,EAAE,qBAAqB,CAAC;IAC/B;;;;OAIG;IACH,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC1C;;;OAGG;IACH,cAAc,EAAE,OAAO,EAAE,CAAC;IAC1B;;;OAGG;IACH,cAAc,EAAE,WAAW,EAAE,CAAC;CAC9B;AAED;;;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ths } from './paths.js';
4
- import { GRO_CONFIG_PATH, NODE_MODULES_DIRNAME, SERVER_DIST_PATH, SVELTEKIT_BUILD_DIRNAME, SVELTEKIT_DIST_DIRNAME, } from './path_constants.js';
4
+ import { GRO_CONFIG_PATH, JS_CLI_DEFAULT, NODE_MODULES_DIRNAME, PM_CLI_DEFAULT, SERVER_DIST_PATH, SVELTEKIT_BUILD_DIRNAME, SVELTEKIT_DIST_DIRNAME, } from './constants.js';
5
5
  import create_default_config from './gro.config.default.js';
6
6
  export const create_empty_gro_config = () => ({
7
7
  plugins: () => [],
@@ -12,7 +12,9 @@ export const create_empty_gro_config = () => ({
12
12
  IS_THIS_GRO ? null : paths.root,
13
13
  IS_THIS_GRO ? null : GRO_DIST_DIR,
14
14
  ].filter((v) => v !== null),
15
- search_filters: [(id) => !DEFAULT_SEARCH_EXCLUDER.test(id)],
15
+ search_filters: [(id) => !SEARCH_EXCLUDER_DEFAULT.test(id)],
16
+ js_cli: JS_CLI_DEFAULT,
17
+ pm_cli: PM_CLI_DEFAULT,
16
18
  });
17
19
  /**
18
20
  * The regexp used by default to exclude directories and files
@@ -20,7 +22,7 @@ export const create_empty_gro_config = () => ({
20
22
  * Customize via `search_filters` in the `Gro_Config`.
21
23
  * See the test cases for the exact behavior.
22
24
  */
23
- export const DEFAULT_SEARCH_EXCLUDER = new RegExp(`(${'(^|/)\\.[^/]+' + // exclude all `.`-prefixed directories
25
+ export const SEARCH_EXCLUDER_DEFAULT = new RegExp(`(${'(^|/)\\.[^/]+' + // exclude all `.`-prefixed directories
24
26
  // TODO probably change to `pkg.name` instead of this catch-all (also `gro` below)
25
27
  `|(^|/)${NODE_MODULES_DIRNAME}(?!/(@[^/]+/)?gro/${SVELTEKIT_DIST_DIRNAME})` + // exclude `node_modules` unless it's to the Gro directory
26
28
  `|(^|/)${SVELTEKIT_BUILD_DIRNAME}` + // exclude the SvelteKit build directory
@@ -29,11 +31,11 @@ export const DEFAULT_SEARCH_EXCLUDER = new RegExp(`(${'(^|/)\\.[^/]+' + // exclu
29
31
  })($|/)`, 'u');
30
32
  const default_map_package_json = (package_json) => {
31
33
  if (package_json.exports) {
32
- package_json.exports = Object.fromEntries(Object.entries(package_json.exports).filter(([k]) => !DEFAULT_EXPORTS_EXCLUDER.test(k)));
34
+ package_json.exports = Object.fromEntries(Object.entries(package_json.exports).filter(([k]) => !EXPORTS_EXCLUDER_DEFAULT.test(k)));
33
35
  }
34
36
  return package_json;
35
37
  };
36
- export const DEFAULT_EXPORTS_EXCLUDER = /(\.md|\.(test|ignore)\.|\/(test|fixtures|ignore)\/)/;
38
+ export const EXPORTS_EXCLUDER_DEFAULT = /(\.md|\.(test|ignore)\.|\/(test|fixtures|ignore)\/)/;
37
39
  /**
38
40
  * Transforms a `Raw_Gro_Config` to the more strict `Gro_Config`.
39
41
  * This allows users to provide a more relaxed config.
@@ -42,7 +44,7 @@ export const normalize_gro_config = (raw_config) => {
42
44
  const empty_config = create_empty_gro_config();
43
45
  // All of the raw config properties are optional,
44
46
  // so fall back to the empty values when `undefined`.
45
- const { plugins = empty_config.plugins, map_package_json = empty_config.map_package_json, task_root_dirs = empty_config.task_root_dirs, search_filters = empty_config.search_filters, } = raw_config;
47
+ const { plugins = empty_config.plugins, map_package_json = empty_config.map_package_json, task_root_dirs = empty_config.task_root_dirs, search_filters = empty_config.search_filters, js_cli = empty_config.js_cli, pm_cli = empty_config.pm_cli, } = raw_config;
46
48
  return {
47
49
  plugins,
48
50
  map_package_json,
@@ -52,6 +54,8 @@ export const normalize_gro_config = (raw_config) => {
52
54
  : search_filters
53
55
  ? [search_filters]
54
56
  : [],
57
+ js_cli,
58
+ pm_cli,
55
59
  };
56
60
  };
57
61
  export const load_gro_config = async (dir = paths.root) => {
@@ -45,5 +45,5 @@ export declare const resolve_gro_module_path: (path?: string) => string;
45
45
  * @param loader_path path to loader
46
46
  * @param invoke_path path to file to spawn with `node`
47
47
  */
48
- export declare const spawn_with_loader: (loader_path: string, invoke_path: string, argv: string[]) => Promise<Spawn_Result>;
48
+ export declare const spawn_with_loader: (loader_path: string, invoke_path: string, argv: string[], js_cli?: string) => Promise<Spawn_Result>;
49
49
  //# sourceMappingURL=gro_helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gro_helpers.d.ts","sourceRoot":"../src/lib/","sources":["gro_helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,KAAK,YAAY,EAAC,MAAM,2BAA2B,CAAC;AAUnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,uBAAuB,qBAAgB,MAsBnD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,gBAChB,MAAM,eACN,MAAM,QACb,MAAM,EAAE,KACZ,OAAO,CAAC,YAAY,CAgBtB,CAAC"}
1
+ {"version":3,"file":"gro_helpers.d.ts","sourceRoot":"../src/lib/","sources":["gro_helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,KAAK,YAAY,EAAC,MAAM,2BAA2B,CAAC;AAUnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,uBAAuB,qBAAgB,MAsBnD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,gBAChB,MAAM,eACN,MAAM,QACb,MAAM,EAAE,sBAEZ,OAAO,CAAC,YAAY,CAgBtB,CAAC"}
@@ -2,7 +2,7 @@ import { realpathSync, existsSync } from 'node:fs';
2
2
  import { join, resolve } from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  import { spawn } from '@ryanatkn/belt/process.js';
5
- import { NODE_MODULES_DIRNAME, SVELTEKIT_DIST_DIRNAME } from './path_constants.js';
5
+ import { JS_CLI_DEFAULT, NODE_MODULES_DIRNAME, SVELTEKIT_DIST_DIRNAME } from './constants.js';
6
6
  /*
7
7
 
8
8
  This module is intended to have minimal dependencies to avoid over-imports in the CLI.
@@ -74,7 +74,7 @@ export const resolve_gro_module_path = (path = '') => {
74
74
  * @param loader_path path to loader
75
75
  * @param invoke_path path to file to spawn with `node`
76
76
  */
77
- export const spawn_with_loader = (loader_path, invoke_path, argv) => {
77
+ export const spawn_with_loader = (loader_path, invoke_path, argv, js_cli = JS_CLI_DEFAULT) => {
78
78
  const args = [
79
79
  '--import',
80
80
  // This does the same as `$lib/register.ts` but without the cost of importing another file.
@@ -89,5 +89,5 @@ export const spawn_with_loader = (loader_path, invoke_path, argv) => {
89
89
  args.push('-C', 'development'); // same as `--conditions`
90
90
  }
91
91
  args.push(invoke_path, ...argv);
92
- return spawn('node', args);
92
+ return spawn(js_cli, args);
93
93
  };
@@ -6,7 +6,7 @@ import { strip_before, strip_end } from '@ryanatkn/belt/string.js';
6
6
  import { existsSync } from 'node:fs';
7
7
  import { throttle } from '@ryanatkn/belt/throttle.js';
8
8
  import { base_path_to_path_id, LIB_DIRNAME, paths } from './paths.js';
9
- import { GRO_DEV_DIRNAME, SERVER_DIST_PATH } from './path_constants.js';
9
+ import { GRO_DEV_DIRNAME, SERVER_DIST_PATH } from './constants.js';
10
10
  import { watch_dir } from './watch_dir.js';
11
11
  import { init_sveltekit_config, default_sveltekit_config } from './sveltekit_config.js';
12
12
  import { esbuild_plugin_sveltekit_shim_app } from './esbuild_plugin_sveltekit_shim_app.js';
@@ -28,7 +28,7 @@ export const gro_plugin_server = ({ entry_points = [SERVER_SOURCE_ID], dir = pro
28
28
  outdir: join(dir, dev ? GRO_DEV_DIRNAME : SERVER_DIST_PATH),
29
29
  outbase: paths.lib,
30
30
  outname: 'server/server.js',
31
- }), env_files, ambient_env, sveltekit_config, target = 'esnext', esbuild_build_options = identity, rebuild_throttle_delay = 1000, cli_command = 'node', run, // `dev` default is not available in this scope
31
+ }), env_files, ambient_env, sveltekit_config, target = 'esnext', esbuild_build_options = identity, rebuild_throttle_delay = 1000, cli_command, run, // `dev` default is not available in this scope
32
32
  } = {}) => {
33
33
  let build_ctx = null;
34
34
  let watcher = null;
@@ -36,7 +36,7 @@ export const gro_plugin_server = ({ entry_points = [SERVER_SOURCE_ID], dir = pro
36
36
  let deps = null;
37
37
  return {
38
38
  name: 'gro_plugin_server',
39
- setup: async ({ dev, watch, timings, log }) => {
39
+ setup: async ({ dev, watch, timings, log, config }) => {
40
40
  const parsed_sveltekit_config = !sveltekit_config && strip_end(dir, '/') === process.cwd()
41
41
  ? default_sveltekit_config
42
42
  : await init_sveltekit_config(sveltekit_config ?? dir);
@@ -141,7 +141,7 @@ export const gro_plugin_server = ({ entry_points = [SERVER_SOURCE_ID], dir = pro
141
141
  cli_args.push('-C', 'development'); // same as `--conditions`
142
142
  }
143
143
  cli_args.push(server_outpath);
144
- server_process = spawn_restartable_process(cli_command, cli_args);
144
+ server_process = spawn_restartable_process(cli_command ?? config.js_cli, cli_args);
145
145
  }
146
146
  },
147
147
  teardown: async () => {
@@ -1 +1 @@
1
- {"version":3,"file":"gro_plugin_sveltekit_app.d.ts","sourceRoot":"../src/lib/","sources":["gro_plugin_sveltekit_app.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAExC,OAAO,EAAyB,KAAK,gBAAgB,EAAoB,MAAM,mBAAmB,CAAC;AAGnG,OAAO,EAAC,KAAK,YAAY,EAAsC,MAAM,eAAe,CAAC;AAMrF,MAAM,WAAW,OAAO;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B;;;OAGG;IACH,uBAAuB,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC;IAErD;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,GAAG,YAAY,CAAC;IAE7C;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC;IAClD;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE7D,MAAM,MAA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