@ryanatkn/gro 0.179.0 → 0.181.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 (196) hide show
  1. package/README.md +1 -1
  2. package/dist/build.task.d.ts +2 -0
  3. package/dist/build.task.d.ts.map +1 -1
  4. package/dist/build.task.js +15 -11
  5. package/dist/build_cache.d.ts +4 -4
  6. package/dist/build_cache.d.ts.map +1 -1
  7. package/dist/build_cache.js +54 -44
  8. package/dist/changelog.d.ts +2 -2
  9. package/dist/changelog.d.ts.map +1 -1
  10. package/dist/changeset.task.js +11 -11
  11. package/dist/check.task.js +2 -2
  12. package/dist/child_process_logging.js +1 -1
  13. package/dist/clean.task.js +2 -2
  14. package/dist/clean_fs.d.ts +1 -1
  15. package/dist/clean_fs.d.ts.map +1 -1
  16. package/dist/clean_fs.js +3 -4
  17. package/dist/cli.d.ts +7 -7
  18. package/dist/cli.d.ts.map +1 -1
  19. package/dist/cli.js +11 -12
  20. package/dist/commit.task.js +2 -2
  21. package/dist/deploy.task.d.ts +7 -0
  22. package/dist/deploy.task.d.ts.map +1 -1
  23. package/dist/deploy.task.js +30 -17
  24. package/dist/disknode.d.ts +1 -1
  25. package/dist/disknode.d.ts.map +1 -1
  26. package/dist/esbuild_helpers.d.ts +1 -1
  27. package/dist/esbuild_helpers.d.ts.map +1 -1
  28. package/dist/esbuild_plugin_external_worker.d.ts +1 -1
  29. package/dist/esbuild_plugin_external_worker.d.ts.map +1 -1
  30. package/dist/esbuild_plugin_external_worker.js +1 -1
  31. package/dist/esbuild_plugin_svelte.js +4 -4
  32. package/dist/esbuild_plugin_sveltekit_local_imports.js +2 -2
  33. package/dist/esbuild_plugin_sveltekit_shim_alias.js +1 -1
  34. package/dist/filer.d.ts +4 -4
  35. package/dist/filer.d.ts.map +1 -1
  36. package/dist/filer.js +105 -54
  37. package/dist/format.task.js +1 -1
  38. package/dist/format_directory.d.ts +2 -2
  39. package/dist/format_directory.d.ts.map +1 -1
  40. package/dist/format_file.js +1 -1
  41. package/dist/gen.d.ts +5 -5
  42. package/dist/gen.d.ts.map +1 -1
  43. package/dist/gen.js +28 -22
  44. package/dist/gen.task.js +3 -3
  45. package/dist/gen_helpers.d.ts +3 -3
  46. package/dist/gen_helpers.d.ts.map +1 -1
  47. package/dist/github.d.ts +2 -2
  48. package/dist/github.d.ts.map +1 -1
  49. package/dist/github.js +1 -1
  50. package/dist/gro.config.default.js +1 -1
  51. package/dist/gro_config.d.ts +1 -1
  52. package/dist/gro_config.d.ts.map +1 -1
  53. package/dist/gro_config.js +4 -4
  54. package/dist/gro_helpers.d.ts +1 -1
  55. package/dist/gro_helpers.d.ts.map +1 -1
  56. package/dist/gro_helpers.js +1 -1
  57. package/dist/gro_plugin_gen.js +4 -4
  58. package/dist/gro_plugin_server.d.ts +2 -2
  59. package/dist/gro_plugin_server.d.ts.map +1 -1
  60. package/dist/gro_plugin_server.js +7 -7
  61. package/dist/gro_plugin_sveltekit_app.d.ts.map +1 -1
  62. package/dist/gro_plugin_sveltekit_app.js +40 -36
  63. package/dist/gro_plugin_sveltekit_library.js +3 -2
  64. package/dist/input_path.d.ts +5 -5
  65. package/dist/input_path.d.ts.map +1 -1
  66. package/dist/input_path.js +17 -15
  67. package/dist/invoke.js +2 -2
  68. package/dist/invoke_task.d.ts +2 -2
  69. package/dist/invoke_task.d.ts.map +1 -1
  70. package/dist/invoke_task.js +5 -5
  71. package/dist/lint.task.js +2 -2
  72. package/dist/loader.js +2 -2
  73. package/dist/modules.d.ts +3 -3
  74. package/dist/modules.d.ts.map +1 -1
  75. package/dist/modules.js +4 -4
  76. package/dist/package_json.d.ts +6 -6
  77. package/dist/package_json.d.ts.map +1 -1
  78. package/dist/package_json.js +14 -16
  79. package/dist/parse_exports.d.ts +4 -4
  80. package/dist/parse_exports.d.ts.map +1 -1
  81. package/dist/parse_exports_context.d.ts +1 -1
  82. package/dist/parse_exports_context.d.ts.map +1 -1
  83. package/dist/parse_imports.d.ts +2 -2
  84. package/dist/parse_imports.d.ts.map +1 -1
  85. package/dist/parse_imports.js +1 -1
  86. package/dist/paths.d.ts +1 -1
  87. package/dist/paths.d.ts.map +1 -1
  88. package/dist/paths.js +1 -1
  89. package/dist/publish.task.js +8 -8
  90. package/dist/reinstall.task.js +1 -1
  91. package/dist/release.task.js +1 -1
  92. package/dist/resolve.task.js +2 -2
  93. package/dist/resolve_specifier.d.ts +2 -2
  94. package/dist/resolve_specifier.d.ts.map +1 -1
  95. package/dist/resolve_specifier.js +5 -4
  96. package/dist/run.task.js +2 -2
  97. package/dist/run_gen.d.ts +2 -2
  98. package/dist/run_gen.d.ts.map +1 -1
  99. package/dist/run_gen.js +10 -9
  100. package/dist/run_task.d.ts +2 -2
  101. package/dist/run_task.d.ts.map +1 -1
  102. package/dist/run_task.js +4 -4
  103. package/dist/source_json.d.ts +5 -5
  104. package/dist/source_json.d.ts.map +1 -1
  105. package/dist/source_json.js +18 -17
  106. package/dist/svelte_config.js +1 -1
  107. package/dist/sveltekit_helpers.d.ts +3 -3
  108. package/dist/sveltekit_helpers.d.ts.map +1 -1
  109. package/dist/sveltekit_helpers.js +4 -4
  110. package/dist/sveltekit_shim_app_forms.js +1 -1
  111. package/dist/sveltekit_shim_app_navigation.js +1 -1
  112. package/dist/sveltekit_shim_app_paths.js +1 -1
  113. package/dist/sveltekit_shim_env.js +1 -1
  114. package/dist/sync.task.js +1 -1
  115. package/dist/task.d.ts +5 -5
  116. package/dist/task.d.ts.map +1 -1
  117. package/dist/task.js +5 -5
  118. package/dist/task_logging.d.ts +1 -1
  119. package/dist/task_logging.d.ts.map +1 -1
  120. package/dist/task_logging.js +2 -2
  121. package/dist/test.task.d.ts.map +1 -1
  122. package/dist/test.task.js +5 -4
  123. package/dist/typecheck.task.js +4 -4
  124. package/dist/upgrade.task.js +6 -6
  125. package/dist/watch_dir.d.ts +1 -1
  126. package/dist/watch_dir.d.ts.map +1 -1
  127. package/dist/watch_dir.js +2 -2
  128. package/package.json +8 -8
  129. package/src/lib/build.task.ts +16 -11
  130. package/src/lib/build_cache.ts +81 -65
  131. package/src/lib/changelog.ts +2 -2
  132. package/src/lib/changeset.task.ts +12 -12
  133. package/src/lib/check.task.ts +2 -2
  134. package/src/lib/child_process_logging.ts +1 -1
  135. package/src/lib/clean.task.ts +2 -2
  136. package/src/lib/clean_fs.ts +4 -4
  137. package/src/lib/cli.ts +18 -17
  138. package/src/lib/commit.task.ts +2 -2
  139. package/src/lib/deploy.task.ts +33 -16
  140. package/src/lib/disknode.ts +1 -1
  141. package/src/lib/esbuild_helpers.ts +1 -1
  142. package/src/lib/esbuild_plugin_external_worker.ts +3 -3
  143. package/src/lib/esbuild_plugin_svelte.ts +4 -4
  144. package/src/lib/esbuild_plugin_sveltekit_local_imports.ts +2 -2
  145. package/src/lib/esbuild_plugin_sveltekit_shim_alias.ts +1 -1
  146. package/src/lib/filer.ts +117 -58
  147. package/src/lib/format.task.ts +1 -1
  148. package/src/lib/format_directory.ts +2 -2
  149. package/src/lib/format_file.ts +1 -1
  150. package/src/lib/gen.task.ts +3 -3
  151. package/src/lib/gen.ts +56 -50
  152. package/src/lib/gen_helpers.ts +3 -3
  153. package/src/lib/github.ts +2 -2
  154. package/src/lib/gro.config.default.ts +1 -1
  155. package/src/lib/gro_config.ts +5 -5
  156. package/src/lib/gro_helpers.ts +1 -1
  157. package/src/lib/gro_plugin_gen.ts +4 -4
  158. package/src/lib/gro_plugin_server.ts +9 -9
  159. package/src/lib/gro_plugin_sveltekit_app.ts +44 -40
  160. package/src/lib/gro_plugin_sveltekit_library.ts +3 -3
  161. package/src/lib/input_path.ts +23 -24
  162. package/src/lib/invoke.ts +2 -2
  163. package/src/lib/invoke_task.ts +5 -5
  164. package/src/lib/lint.task.ts +2 -2
  165. package/src/lib/loader.ts +2 -2
  166. package/src/lib/modules.ts +7 -7
  167. package/src/lib/package_json.ts +19 -23
  168. package/src/lib/parse_exports.ts +4 -4
  169. package/src/lib/parse_exports_context.ts +2 -2
  170. package/src/lib/parse_imports.ts +3 -3
  171. package/src/lib/paths.ts +2 -2
  172. package/src/lib/publish.task.ts +8 -8
  173. package/src/lib/reinstall.task.ts +1 -1
  174. package/src/lib/release.task.ts +1 -1
  175. package/src/lib/resolve.task.ts +2 -2
  176. package/src/lib/resolve_specifier.ts +9 -5
  177. package/src/lib/run.task.ts +2 -2
  178. package/src/lib/run_gen.ts +18 -13
  179. package/src/lib/run_task.ts +6 -6
  180. package/src/lib/source_json.ts +26 -22
  181. package/src/lib/svelte_config.ts +1 -1
  182. package/src/lib/sveltekit_helpers.ts +7 -7
  183. package/src/lib/sveltekit_shim_app_forms.ts +1 -1
  184. package/src/lib/sveltekit_shim_app_navigation.ts +1 -1
  185. package/src/lib/sveltekit_shim_app_paths.ts +1 -1
  186. package/src/lib/sync.task.ts +1 -1
  187. package/src/lib/task.ts +16 -14
  188. package/src/lib/task_logging.ts +3 -3
  189. package/src/lib/test.task.ts +4 -3
  190. package/src/lib/typecheck.task.ts +4 -4
  191. package/src/lib/upgrade.task.ts +6 -6
  192. package/src/lib/watch_dir.ts +3 -3
  193. package/dist/search_fs.d.ts +0 -26
  194. package/dist/search_fs.d.ts.map +0 -1
  195. package/dist/search_fs.js +0 -52
  196. package/src/lib/search_fs.ts +0 -100
@@ -1,4 +1,4 @@
1
- import {print_spawn_result} from '@ryanatkn/belt/process.js';
1
+ import {print_spawn_result} from '@fuzdev/fuz_util/process.js';
2
2
  import {z} from 'zod';
3
3
 
4
4
  import {TaskError, type Task} from './task.ts';
@@ -21,7 +21,7 @@ export const task: Task<Args> = {
21
21
  run: async ({log, args}): Promise<void> => {
22
22
  const {_, eslint_cli} = args;
23
23
 
24
- const found_eslint_cli = find_cli(eslint_cli);
24
+ const found_eslint_cli = await find_cli(eslint_cli);
25
25
  if (!found_eslint_cli) {
26
26
  // TODO maybe make this an option?
27
27
  log.info('ESLint is not installed; skipping linting');
package/src/lib/loader.ts CHANGED
@@ -2,7 +2,7 @@ import {compile, compileModule, preprocess} from 'svelte/compiler';
2
2
  import {fileURLToPath, pathToFileURL} from 'node:url';
3
3
  import {dirname, join} from 'node:path';
4
4
  import type {LoadHook, ResolveHook} from 'node:module';
5
- import {escape_regexp} from '@ryanatkn/belt/regexp.js';
5
+ import {escape_regexp} from '@fuzdev/fuz_util/regexp.js';
6
6
  import {readFileSync} from 'node:fs';
7
7
  import ts_blank_space from 'ts-blank-space';
8
8
 
@@ -233,7 +233,7 @@ export const resolve: ResolveHook = async (specifier, context, nextResolve) => {
233
233
  return nextResolve(s, context);
234
234
  }
235
235
 
236
- const resolved = resolve_specifier(s, dirname(fileURLToPath(parent_url)));
236
+ const resolved = await resolve_specifier(s, dirname(fileURLToPath(parent_url)));
237
237
 
238
238
  return {
239
239
  url: pathToFileURL(resolved.path_id_with_querystring).href,
@@ -1,9 +1,9 @@
1
- import type {Timings} from '@ryanatkn/belt/timings.js';
2
- import {UnreachableError} from '@ryanatkn/belt/error.js';
3
- import type {Result} from '@ryanatkn/belt/result.js';
4
- import {print_error} from '@ryanatkn/belt/print.js';
1
+ import type {Timings} from '@fuzdev/fuz_util/timings.js';
2
+ import {UnreachableError} from '@fuzdev/fuz_util/error.js';
3
+ import type {Result} from '@fuzdev/fuz_util/result.js';
4
+ import {print_error} from '@fuzdev/fuz_util/print.js';
5
5
  import {pathToFileURL} from 'node:url';
6
- import type {PathId} from '@ryanatkn/belt/path.js';
6
+ import type {PathId} from '@fuzdev/fuz_util/path.js';
7
7
 
8
8
  import type {ResolvedInputFile} from './input_path.ts';
9
9
  import {print_path} from './paths.ts';
@@ -38,8 +38,8 @@ export const load_module = async <TModule extends Record<string, any>>(
38
38
  import_path = url.href;
39
39
  }
40
40
  mod = await import(import_path);
41
- } catch (err) {
42
- return {ok: false, type: 'failed_import', id, error: err};
41
+ } catch (error) {
42
+ return {ok: false, type: 'failed_import', id, error};
43
43
  }
44
44
  if (validate && !validate(mod)) {
45
45
  return {ok: false, type: 'failed_validation', id, mod, validation: validate.name};
@@ -1,10 +1,11 @@
1
1
  import {z} from 'zod';
2
2
  import {join} from 'node:path';
3
- import {readFileSync, writeFileSync} from 'node:fs';
4
- import {plural, strip_end} from '@ryanatkn/belt/string.js';
5
- import type {Logger} from '@ryanatkn/belt/log.js';
3
+ import {readFile, writeFile} from 'node:fs/promises';
4
+ import {plural, strip_end} from '@fuzdev/fuz_util/string.js';
5
+ import type {Logger} from '@fuzdev/fuz_util/log.js';
6
6
  import {styleText as st} from 'node:util';
7
- import {PackageJson, PackageJsonExports} from '@ryanatkn/belt/package_json.js';
7
+ import {PackageJson, PackageJsonExports} from '@fuzdev/fuz_util/package_json.js';
8
+ import {fs_search} from '@fuzdev/fuz_util/fs.js';
8
9
 
9
10
  import {paths, gro_paths, IS_THIS_GRO} from './paths.ts';
10
11
  import {
@@ -16,7 +17,6 @@ import {
16
17
  JSON_MATCHER,
17
18
  CSS_MATCHER,
18
19
  } from './constants.ts';
19
- import {search_fs} from './search_fs.ts';
20
20
  import {has_sveltekit_library} from './sveltekit_helpers.ts';
21
21
  import {GITHUB_REPO_MATCHER} from './github.ts';
22
22
 
@@ -26,20 +26,20 @@ export type PackageJsonMapper = (
26
26
 
27
27
  export const EMPTY_PACKAGE_JSON: PackageJson = {name: '', version: ''};
28
28
 
29
- export const load_package_json = (
29
+ export const load_package_json = async (
30
30
  dir = IS_THIS_GRO ? gro_paths.root : paths.root,
31
31
  cache?: Record<string, PackageJson>,
32
32
  parse = true, // TODO pass `false` here in more places, especially anything perf-sensitive like work on startup
33
33
  log?: Logger,
34
- ): PackageJson => {
34
+ ): Promise<PackageJson> => {
35
35
  let package_json: PackageJson;
36
36
  if (cache && dir in cache) {
37
37
  return cache[dir]!;
38
38
  }
39
39
  try {
40
- package_json = JSON.parse(load_package_json_contents(dir));
41
- } catch (err) {
42
- log?.error(st('yellow', `Failed to load package.json in ${dir}`), err);
40
+ package_json = JSON.parse(await load_package_json_contents(dir));
41
+ } catch (error) {
42
+ log?.error(st('yellow', `Failed to load package.json in ${dir}`), error);
43
43
  return EMPTY_PACKAGE_JSON;
44
44
  }
45
45
  if (parse) {
@@ -58,7 +58,7 @@ export const sync_package_json = async (
58
58
  dir = paths.root,
59
59
  exports_dir = paths.lib,
60
60
  ): Promise<{package_json: PackageJson | null; changed: boolean}> => {
61
- const exported_files = search_fs(exports_dir);
61
+ const exported_files = await fs_search(exports_dir);
62
62
  const exported_paths = exported_files.map((f) => f.path);
63
63
  const updated = await update_package_json(
64
64
  async (package_json) => {
@@ -85,15 +85,14 @@ export const sync_package_json = async (
85
85
  return updated;
86
86
  };
87
87
 
88
- export const load_gro_package_json = (): PackageJson => load_package_json(gro_paths.root);
88
+ export const load_gro_package_json = (): Promise<PackageJson> => load_package_json(gro_paths.root);
89
89
 
90
90
  // TODO probably make this nullable and make callers handle failures
91
- const load_package_json_contents = (dir: string): string =>
92
- readFileSync(join(dir, PACKAGE_JSON_FILENAME), 'utf8');
91
+ const load_package_json_contents = (dir: string): Promise<string> =>
92
+ readFile(join(dir, PACKAGE_JSON_FILENAME), 'utf8');
93
93
 
94
- export const write_package_json = (serialized_package_json: string): void => {
95
- writeFileSync(join(paths.root, PACKAGE_JSON_FILENAME), serialized_package_json);
96
- };
94
+ export const write_package_json = (serialized_package_json: string): Promise<void> =>
95
+ writeFile(join(paths.root, PACKAGE_JSON_FILENAME), serialized_package_json);
97
96
 
98
97
  export const serialize_package_json = (package_json: PackageJson): string =>
99
98
  JSON.stringify(parse_package_json(PackageJson, package_json), null, 2) + '\n';
@@ -106,7 +105,7 @@ export const update_package_json = async (
106
105
  dir = paths.root,
107
106
  write = true,
108
107
  ): Promise<{package_json: PackageJson | null; changed: boolean}> => {
109
- const original_contents = load_package_json_contents(dir);
108
+ const original_contents = await load_package_json_contents(dir);
110
109
  const original = JSON.parse(original_contents);
111
110
  const updated = await update(original);
112
111
  if (updated === null) {
@@ -116,7 +115,7 @@ export const update_package_json = async (
116
115
  if (updated_contents === original_contents) {
117
116
  return {package_json: original, changed: false};
118
117
  }
119
- if (write) write_package_json(updated_contents);
118
+ if (write) await write_package_json(updated_contents);
120
119
  return {package_json: updated, changed: true};
121
120
  };
122
121
 
@@ -225,10 +224,7 @@ const parse_or_throw_formatted_error = <T extends z.ZodType>(
225
224
  return parsed.data;
226
225
  };
227
226
 
228
- export const has_dep = (
229
- dep_name: string,
230
- package_json: PackageJson = load_package_json(),
231
- ): boolean =>
227
+ export const has_dep = (dep_name: string, package_json: PackageJson): boolean =>
232
228
  !!package_json.devDependencies?.[dep_name] ||
233
229
  !!package_json.dependencies?.[dep_name] ||
234
230
  !!package_json.peerDependencies?.[dep_name];
@@ -1,9 +1,9 @@
1
1
  import ts from 'typescript';
2
2
  import {extname} from 'node:path';
3
- import type {Flavored} from '@ryanatkn/belt/types.js';
4
- import type {Logger} from '@ryanatkn/belt/log.js';
5
- import type {DeclarationKind} from '@ryanatkn/belt/source_json.js';
6
- import type {PathId} from '@ryanatkn/belt/path.js';
3
+ import type {Flavored} from '@fuzdev/fuz_util/types.js';
4
+ import type {Logger} from '@fuzdev/fuz_util/log.js';
5
+ import type {DeclarationKind} from '@fuzdev/fuz_util/source_json.js';
6
+ import type {PathId} from '@fuzdev/fuz_util/path.js';
7
7
 
8
8
  import {TS_MATCHER} from './constants.ts';
9
9
  import {ParseExportsContext} from './parse_exports_context.ts';
@@ -1,6 +1,6 @@
1
1
  import ts from 'typescript';
2
- import type {Logger} from '@ryanatkn/belt/log.js';
3
- import type {DeclarationKind} from '@ryanatkn/belt/source_json.js';
2
+ import type {Logger} from '@fuzdev/fuz_util/log.js';
3
+ import type {DeclarationKind} from '@fuzdev/fuz_util/source_json.js';
4
4
 
5
5
  import type {ExportDeclaration} from './parse_exports.ts';
6
6
 
@@ -1,7 +1,7 @@
1
1
  import {parseSync, type ImportDeclaration} from 'oxc-parser';
2
- import type {Flavored} from '@ryanatkn/belt/types.js';
3
- import {UnreachableError} from '@ryanatkn/belt/error.js';
4
- import type {PathId} from '@ryanatkn/belt/path.js';
2
+ import type {Flavored} from '@fuzdev/fuz_util/types.js';
3
+ import {UnreachableError} from '@fuzdev/fuz_util/error.js';
4
+ import type {PathId} from '@fuzdev/fuz_util/path.js';
5
5
 
6
6
  import {JS_MATCHER, TS_MATCHER, SVELTE_MATCHER, SVELTE_SCRIPT_MATCHER} from './constants.ts';
7
7
 
package/src/lib/paths.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import {join, extname, relative, basename} from 'node:path';
2
2
  import {fileURLToPath} from 'node:url';
3
- import {ensure_end, strip_end} from '@ryanatkn/belt/string.js';
3
+ import {ensure_end, strip_end} from '@fuzdev/fuz_util/string.js';
4
4
  import {styleText as st} from 'node:util';
5
- import type {PathId} from '@ryanatkn/belt/path.js';
5
+ import type {PathId} from '@fuzdev/fuz_util/path.js';
6
6
 
7
7
  import {
8
8
  GRO_CONFIG_FILENAME,
@@ -1,7 +1,7 @@
1
- import {spawn} from '@ryanatkn/belt/process.js';
1
+ import {spawn} from '@fuzdev/fuz_util/process.js';
2
2
  import {z} from 'zod';
3
3
  import {styleText as st} from 'node:util';
4
- import {existsSync} from 'node:fs';
4
+ import {fs_exists} from '@fuzdev/fuz_util/fs.js';
5
5
  import {
6
6
  GitBranch,
7
7
  GitOrigin,
@@ -9,7 +9,7 @@ import {
9
9
  git_checkout,
10
10
  git_fetch,
11
11
  git_pull,
12
- } from '@ryanatkn/belt/git.js';
12
+ } from '@fuzdev/fuz_util/git.js';
13
13
 
14
14
  import {TaskError, type Task} from './task.ts';
15
15
  import {load_package_json, parse_repo_url} from './package_json.ts';
@@ -85,7 +85,7 @@ export const task: Task<Args> = {
85
85
  log.info(st('green', 'dry run!'));
86
86
  }
87
87
 
88
- const package_json = load_package_json();
88
+ const package_json = await load_package_json();
89
89
 
90
90
  const has_sveltekit_library_result = await has_sveltekit_library(package_json);
91
91
  if (!has_sveltekit_library_result.ok) {
@@ -94,9 +94,9 @@ export const task: Task<Args> = {
94
94
  );
95
95
  }
96
96
 
97
- const changelog_exists = existsSync(changelog);
97
+ const changelog_exists = await fs_exists(changelog);
98
98
 
99
- const found_changeset_cli = find_cli(changeset_cli);
99
+ const found_changeset_cli = await find_cli(changeset_cli);
100
100
  if (!found_changeset_cli) {
101
101
  throw new TaskError(
102
102
  'changeset command not found, install @changesets/cli locally or globally',
@@ -178,7 +178,7 @@ export const task: Task<Args> = {
178
178
  // The check above ensures gen is updated.
179
179
  await invoke_task('gen');
180
180
 
181
- const package_json_after_versioning = load_package_json();
181
+ const package_json_after_versioning = await load_package_json();
182
182
  version = package_json_after_versioning.version!;
183
183
  if (package_json.version === version) {
184
184
  // The version didn't change.
@@ -217,7 +217,7 @@ export const task: Task<Args> = {
217
217
  );
218
218
  }
219
219
 
220
- if (!changelog_exists && existsSync(changelog)) {
220
+ if (!changelog_exists && (await fs_exists(changelog))) {
221
221
  await spawn('git', ['add', changelog]);
222
222
  }
223
223
  await spawn('git', ['commit', '-a', '-m', `publish v${version}`]);
@@ -1,5 +1,5 @@
1
1
  import {z} from 'zod';
2
- import {spawn} from '@ryanatkn/belt/process.js';
2
+ import {spawn} from '@fuzdev/fuz_util/process.js';
3
3
  import {rm} from 'node:fs/promises';
4
4
 
5
5
  import {TaskError, type Task} from './task.ts';
@@ -13,7 +13,7 @@ export const task: Task<Args> = {
13
13
  summary: 'publish and deploy',
14
14
  Args,
15
15
  run: async ({invoke_task}) => {
16
- const package_json = load_package_json();
16
+ const package_json = await load_package_json();
17
17
 
18
18
  const publish = (await has_sveltekit_library(package_json)).ok;
19
19
  if (publish) {
@@ -15,7 +15,7 @@ export type Args = z.infer<typeof Args>;
15
15
  export const task: Task<Args> = {
16
16
  summary: 'diagnostic that logs resolved filesystem info for the given input paths',
17
17
  Args,
18
- run: ({args, config, log}): void => {
18
+ run: async ({args, config, log}): Promise<void> => {
19
19
  const {_, verbose} = args;
20
20
 
21
21
  if (verbose) log.info('raw input paths:', _);
@@ -27,7 +27,7 @@ export const task: Task<Args> = {
27
27
  if (verbose) log.info('task root paths:', task_root_dirs);
28
28
 
29
29
  const {resolved_input_paths, possible_paths_by_input_path, unmapped_input_paths} =
30
- resolve_input_paths(input_paths, task_root_dirs, TASK_FILE_SUFFIXES);
30
+ await resolve_input_paths(input_paths, task_root_dirs, TASK_FILE_SUFFIXES);
31
31
  if (verbose) log.info('resolved_input_paths:', resolved_input_paths);
32
32
  if (verbose) log.info('possible_paths_by_input_path:', possible_paths_by_input_path);
33
33
  if (verbose) log.info('unmapped_input_paths:', unmapped_input_paths);
@@ -1,6 +1,6 @@
1
1
  import {extname, isAbsolute, join, relative} from 'node:path';
2
- import {existsSync} from 'node:fs';
3
- import type {PathId} from '@ryanatkn/belt/path.js';
2
+ import {fs_exists} from '@fuzdev/fuz_util/fs.js';
3
+ import type {PathId} from '@fuzdev/fuz_util/path.js';
4
4
 
5
5
  import {replace_extension} from './paths.ts';
6
6
 
@@ -26,7 +26,10 @@ export interface ResolvedSpecifier {
26
26
  * and infer the correct extension following Vite conventions.
27
27
  * If no `.js` file is found for the specifier on the filesystem, it assumes `.ts`.
28
28
  */
29
- export const resolve_specifier = (specifier: string, dir: string): ResolvedSpecifier => {
29
+ export const resolve_specifier = async (
30
+ specifier: string,
31
+ dir: string,
32
+ ): Promise<ResolvedSpecifier> => {
30
33
  const raw = specifier.endsWith('?raw'); // TODO more robust detection? other values?
31
34
  const final_specifier = raw ? specifier.substring(0, specifier.length - 4) : specifier;
32
35
  const absolute_path = isAbsolute(final_specifier) ? final_specifier : join(dir, final_specifier);
@@ -39,7 +42,7 @@ export const resolve_specifier = (specifier: string, dir: string): ResolvedSpeci
39
42
  const is_js = ext === '.js';
40
43
  const is_ts = ext === '.ts';
41
44
 
42
- if (!is_js && !is_ts && existsSync(absolute_path)) {
45
+ if (!is_js && !is_ts && (await fs_exists(absolute_path))) {
43
46
  // unrecognized extension and the file exists
44
47
  mapped_path = absolute_path;
45
48
  path_id = absolute_path;
@@ -52,7 +55,8 @@ export const resolve_specifier = (specifier: string, dir: string): ResolvedSpeci
52
55
  // extensionless, or js that points to ts, or just js
53
56
  const js_id = is_js ? absolute_path : absolute_path + '.js';
54
57
  const ts_id = is_js ? replace_extension(absolute_path, '.ts') : absolute_path + '.ts';
55
- if (!existsSync(ts_id) && existsSync(js_id)) {
58
+ const [ts_exists, js_exists] = await Promise.all([fs_exists(ts_id), fs_exists(js_id)]);
59
+ if (!ts_exists && js_exists) {
56
60
  mapped_path = js_id;
57
61
  path_id = js_id;
58
62
  namespace = 'sveltekit_local_imports_js';
@@ -1,6 +1,6 @@
1
1
  import {z} from 'zod';
2
2
  import {styleText as st} from 'node:util';
3
- import {existsSync} from 'node:fs';
3
+ import {fs_exists} from '@fuzdev/fuz_util/fs.js';
4
4
 
5
5
  import {TaskError, type Task} from './task.ts';
6
6
  import {resolve_gro_module_path, spawn_with_loader} from './gro_helpers.ts';
@@ -39,7 +39,7 @@ export const task: Task<Args> = {
39
39
  return;
40
40
  }
41
41
 
42
- if (!existsSync(path)) {
42
+ if (!(await fs_exists(path))) {
43
43
  throw new TaskError('Cannot find file to run at path: ' + path);
44
44
  }
45
45
 
@@ -1,7 +1,8 @@
1
1
  import {styleText as st} from 'node:util';
2
- import {print_error} from '@ryanatkn/belt/print.js';
3
- import type {Timings} from '@ryanatkn/belt/timings.js';
4
- import type {Logger} from '@ryanatkn/belt/log.js';
2
+ import {print_error} from '@fuzdev/fuz_util/print.js';
3
+ import type {Timings} from '@fuzdev/fuz_util/timings.js';
4
+ import type {Logger} from '@fuzdev/fuz_util/log.js';
5
+ import {map_concurrent} from '@fuzdev/fuz_util/async.js';
5
6
 
6
7
  import {
7
8
  type GenResults,
@@ -33,8 +34,9 @@ export const run_gen = async (
33
34
  let input_count = 0;
34
35
  let output_count = 0;
35
36
  const timing_for_run_gen = timings.start('run_gen');
36
- const results = await Promise.all(
37
- gen_modules.map(async (module_meta): Promise<GenfileModuleResult> => {
37
+ const results = await map_concurrent(
38
+ gen_modules,
39
+ async (module_meta): Promise<GenfileModuleResult> => {
38
40
  input_count++;
39
41
  const {id} = module_meta;
40
42
  const timing_for_module = timings.start(id);
@@ -54,11 +56,11 @@ export const run_gen = async (
54
56
  let raw_gen_result: RawGenResult;
55
57
  try {
56
58
  raw_gen_result = await gen_config.generate(gen_ctx);
57
- } catch (err) {
59
+ } catch (error) {
58
60
  return {
59
61
  ok: false,
60
62
  id,
61
- error: err,
63
+ error,
62
64
  reason: st('red', `Error generating ${print_path(id)}`),
63
65
  elapsed: timing_for_module(),
64
66
  };
@@ -69,19 +71,21 @@ export const run_gen = async (
69
71
 
70
72
  // Format the files if needed.
71
73
  const files = format_file
72
- ? await Promise.all(
73
- gen_result.files.map(async (file) => {
74
+ ? await map_concurrent(
75
+ gen_result.files,
76
+ async (file) => {
74
77
  if (!file.format) return file;
75
78
  try {
76
79
  return {...file, content: await format_file(file.content, {filepath: file.id})};
77
- } catch (err) {
80
+ } catch (error) {
78
81
  log.error(
79
82
  st('red', `Error formatting ${print_path(file.id)} via ${print_path(id)}`),
80
- print_error(err),
83
+ print_error(error),
81
84
  );
82
85
  return file;
83
86
  }
84
- }),
87
+ },
88
+ 10,
85
89
  )
86
90
  : gen_result.files;
87
91
 
@@ -92,7 +96,8 @@ export const run_gen = async (
92
96
  files,
93
97
  elapsed: timing_for_module(),
94
98
  };
95
- }),
99
+ },
100
+ 10,
96
101
  );
97
102
  return {
98
103
  results,
@@ -1,6 +1,6 @@
1
1
  import {styleText as st} from 'node:util';
2
- import type {Timings} from '@ryanatkn/belt/timings.js';
3
- import type {Logger} from '@ryanatkn/belt/log.js';
2
+ import type {Timings} from '@fuzdev/fuz_util/timings.js';
3
+ import type {Logger} from '@fuzdev/fuz_util/log.js';
4
4
  import {z} from 'zod';
5
5
 
6
6
  import {parse_args, type Args} from './args.ts';
@@ -63,19 +63,19 @@ export const run_task = async (
63
63
  invoke_task: (invoked_task_name, invoked_args, invoked_config) =>
64
64
  invoke_task(invoked_task_name, invoked_args, invoked_config ?? config, filer, timings, log),
65
65
  });
66
- } catch (err) {
66
+ } catch (error) {
67
67
  return {
68
68
  ok: false,
69
69
  reason: st(
70
70
  'red',
71
- err?.constructor?.name === 'TaskError'
72
- ? (err.message as string)
71
+ error?.constructor?.name === 'TaskError'
72
+ ? (error.message as string)
73
73
  : `Unexpected error running task ${st(
74
74
  'cyan',
75
75
  task_meta.name,
76
76
  )}. If this is unexpected try running \`${config.pm_cli} install\` and \`gro clean\`.`,
77
77
  ),
78
- error: err,
78
+ error,
79
79
  };
80
80
  }
81
81
  return {ok: true, output};
@@ -1,29 +1,28 @@
1
1
  import {join} from 'node:path';
2
- import {ensure_end, strip_start} from '@ryanatkn/belt/string.js';
3
- import {existsSync} from 'node:fs';
2
+ import {ensure_end, strip_start} from '@fuzdev/fuz_util/string.js';
3
+ import {fs_exists, fs_search} from '@fuzdev/fuz_util/fs.js';
4
4
  import ts from 'typescript';
5
- import type {PackageJson, PackageJsonExports} from '@ryanatkn/belt/package_json.js';
6
- import {SourceJson, type ModuleJson, type DeclarationKind} from '@ryanatkn/belt/source_json.js';
7
- import type {Logger} from '@ryanatkn/belt/log.js';
5
+ import type {PackageJson, PackageJsonExports} from '@fuzdev/fuz_util/package_json.js';
6
+ import {SourceJson, type ModuleJson, type DeclarationKind} from '@fuzdev/fuz_util/source_json.js';
7
+ import type {Logger} from '@fuzdev/fuz_util/log.js';
8
8
 
9
9
  import {paths, replace_extension} from './paths.ts';
10
10
  import {parse_exports} from './parse_exports.ts';
11
11
  import {TS_MATCHER, SVELTE_MATCHER, JSON_MATCHER, CSS_MATCHER} from './constants.ts';
12
- import {search_fs} from './search_fs.ts';
13
12
 
14
13
  export type SourceJsonMapper = (
15
14
  source_json: SourceJson,
16
15
  ) => SourceJson | null | Promise<SourceJson | null>;
17
16
 
18
- export const source_json_create = (
17
+ export const source_json_create = async (
19
18
  package_json: PackageJson,
20
19
  lib_path?: string,
21
20
  log?: Logger,
22
- ): SourceJson =>
21
+ ): Promise<SourceJson> =>
23
22
  SourceJson.parse({
24
23
  name: package_json.name,
25
24
  version: package_json.version,
26
- modules: source_modules_create(package_json.exports, lib_path, log),
25
+ modules: await source_modules_create(package_json.exports, lib_path, log),
27
26
  });
28
27
 
29
28
  export const source_json_serialize = (source_json: SourceJson): string => {
@@ -31,14 +30,14 @@ export const source_json_serialize = (source_json: SourceJson): string => {
31
30
  return JSON.stringify(parsed, null, 2) + '\n';
32
31
  };
33
32
 
34
- export const source_modules_create = (
33
+ export const source_modules_create = async (
35
34
  exports: PackageJsonExports | undefined,
36
35
  lib_path = paths.lib,
37
36
  log?: Logger,
38
- ): Array<ModuleJson> | undefined => {
37
+ ): Promise<Array<ModuleJson> | undefined> => {
39
38
  if (!exports) return;
40
39
 
41
- const file_paths = collect_file_paths(exports, lib_path);
40
+ const file_paths = await collect_file_paths(exports, lib_path);
42
41
 
43
42
  // Create a TypeScript program for all TypeScript files
44
43
  const ts_files = file_paths
@@ -85,15 +84,15 @@ export const source_modules_create = (
85
84
  return result;
86
85
  };
87
86
 
88
- const collect_file_paths = (
87
+ const collect_file_paths = async (
89
88
  exports: PackageJsonExports,
90
89
  lib_path: string,
91
- ): Array<{export_key: string; file_path: string}> => {
90
+ ): Promise<Array<{export_key: string; file_path: string}>> => {
92
91
  const file_paths: Array<{export_key: string; file_path: string}> = [];
93
92
 
94
93
  // Handle string exports (single default export)
95
94
  if (typeof exports === 'string') {
96
- const source_file = infer_source_from_export(exports, lib_path);
95
+ const source_file = await infer_source_from_export(exports, lib_path);
97
96
  if (source_file) {
98
97
  file_paths.push({export_key: '.', file_path: source_file});
99
98
  } else {
@@ -112,7 +111,8 @@ const collect_file_paths = (
112
111
  // Check if this is a pattern export
113
112
  if (k.includes('*')) {
114
113
  // Handle pattern exports by finding matching files in lib
115
- const matching_files = search_fs(lib_path, {
114
+ // eslint-disable-next-line no-await-in-loop
115
+ const matching_files = await fs_search(lib_path, {
116
116
  file_filter: (path) => {
117
117
  const p = path.replace(ensure_end(lib_path, '/'), '');
118
118
  // Only match files in the root directory (no subdirectories)
@@ -144,7 +144,8 @@ const collect_file_paths = (
144
144
  }
145
145
  } else {
146
146
  // Handle explicit exports (non-patterns)
147
- const source_file = infer_source_from_export(k, lib_path);
147
+ // eslint-disable-next-line no-await-in-loop
148
+ const source_file = await infer_source_from_export(k, lib_path);
148
149
  if (source_file) {
149
150
  file_paths.push({export_key: k, file_path: source_file});
150
151
  } else {
@@ -158,13 +159,16 @@ const collect_file_paths = (
158
159
  return file_paths;
159
160
  };
160
161
 
161
- const infer_source_from_export = (export_path: string, lib_path: string): string | null => {
162
+ const infer_source_from_export = async (
163
+ export_path: string,
164
+ lib_path: string,
165
+ ): Promise<string | null> => {
162
166
  // Handle index specially
163
167
  if (export_path === '.' || export_path === './') {
164
168
  const index_ts = join(lib_path, 'index.ts');
165
- if (existsSync(index_ts)) return index_ts;
169
+ if (await fs_exists(index_ts)) return index_ts;
166
170
  const index_js = join(lib_path, 'index.js');
167
- if (existsSync(index_js)) return index_js;
171
+ if (await fs_exists(index_js)) return index_js;
168
172
  return null;
169
173
  }
170
174
 
@@ -173,12 +177,12 @@ const infer_source_from_export = (export_path: string, lib_path: string): string
173
177
  // For .js exports, try .ts first
174
178
  if (clean_path.endsWith('.js')) {
175
179
  const ts_path = join(lib_path, replace_extension(clean_path, '.ts'));
176
- if (existsSync(ts_path)) return ts_path;
180
+ if (await fs_exists(ts_path)) return ts_path;
177
181
  }
178
182
 
179
183
  // Try the exact path
180
184
  const exact_path = join(lib_path, clean_path);
181
- if (existsSync(exact_path)) return exact_path;
185
+ if (await fs_exists(exact_path)) return exact_path;
182
186
 
183
187
  return null;
184
188
  };
@@ -1,7 +1,7 @@
1
1
  import type {Config as SvelteConfig} from '@sveltejs/kit';
2
2
  import type {CompileOptions, ModuleCompileOptions, PreprocessorGroup} from 'svelte/compiler';
3
3
  import {join} from 'node:path';
4
- import {EMPTY_OBJECT} from '@ryanatkn/belt/object.js';
4
+ import {EMPTY_OBJECT} from '@fuzdev/fuz_util/object.js';
5
5
 
6
6
  import {SVELTE_CONFIG_FILENAME} from './constants.ts';
7
7
 
@@ -1,8 +1,8 @@
1
- import type {Result} from '@ryanatkn/belt/result.js';
2
- import type {Logger} from '@ryanatkn/belt/log.js';
1
+ import type {Result} from '@fuzdev/fuz_util/result.js';
2
+ import type {Logger} from '@fuzdev/fuz_util/log.js';
3
3
  import {join} from 'node:path';
4
- import type {PackageJson} from '@ryanatkn/belt/package_json.js';
5
- import {fs_exists} from '@ryanatkn/belt/fs.js';
4
+ import type {PackageJson} from '@fuzdev/fuz_util/package_json.js';
5
+ import {fs_exists} from '@fuzdev/fuz_util/fs.js';
6
6
 
7
7
  import {has_dep} from './package_json.ts';
8
8
  import {default_svelte_config, type ParsedSvelteConfig} from './svelte_config.ts';
@@ -73,7 +73,7 @@ export const sveltekit_sync_if_available = async (
73
73
  sveltekit_cli: string | Cli = SVELTEKIT_CLI,
74
74
  ): Promise<void> => {
75
75
  const found_sveltekit_cli =
76
- typeof sveltekit_cli === 'string' ? find_cli(sveltekit_cli) : sveltekit_cli;
76
+ typeof sveltekit_cli === 'string' ? await find_cli(sveltekit_cli) : sveltekit_cli;
77
77
  if (found_sveltekit_cli) {
78
78
  return sveltekit_sync(found_sveltekit_cli);
79
79
  }
@@ -89,7 +89,7 @@ export const sveltekit_sync_if_obviously_needed = async (
89
89
  return;
90
90
  }
91
91
  const found_sveltekit_cli =
92
- typeof sveltekit_cli === 'string' ? find_cli(sveltekit_cli) : sveltekit_cli;
92
+ typeof sveltekit_cli === 'string' ? await find_cli(sveltekit_cli) : sveltekit_cli;
93
93
  if (!found_sveltekit_cli) {
94
94
  return;
95
95
  }
@@ -160,7 +160,7 @@ export const run_svelte_package = async (
160
160
  );
161
161
  }
162
162
  const cli_name = typeof cli === 'string' ? cli : cli.name;
163
- const found_svelte_package_cli = cli === cli_name ? find_cli(cli) : (cli as Cli);
163
+ const found_svelte_package_cli = cli === cli_name ? await find_cli(cli) : (cli as Cli);
164
164
  if (found_svelte_package_cli?.kind !== 'local') {
165
165
  throw new TaskError(
166
166
  `Failed to find SvelteKit packaging CLI \`${cli_name}\`, do you need to run \`${pm_cli} install\`?`,