@ryanatkn/gro 0.129.0 → 0.129.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +3 -3
  2. package/dist/args.d.ts +2 -2
  3. package/dist/args.js +2 -2
  4. package/dist/changelog.test.js +1 -1
  5. package/dist/changeset.task.js +6 -6
  6. package/dist/cli.js +1 -1
  7. package/dist/config.d.ts +1 -3
  8. package/dist/config.js +2 -2
  9. package/dist/deploy.task.js +1 -1
  10. package/dist/docs/README.gen.md.js +1 -1
  11. package/dist/docs/package_json.md +2 -1
  12. package/dist/env.d.ts +2 -2
  13. package/dist/env.js +10 -11
  14. package/dist/esbuild_helpers.js +2 -1
  15. package/dist/esbuild_plugin_external_worker.js +1 -1
  16. package/dist/esbuild_plugin_svelte.js +3 -3
  17. package/dist/esbuild_plugin_sveltekit_local_imports.js +2 -2
  18. package/dist/esbuild_plugin_sveltekit_shim_env.js +2 -2
  19. package/dist/format_file.js +2 -2
  20. package/dist/gen.d.ts +10 -12
  21. package/dist/gen.js +3 -3
  22. package/dist/gen.task.js +1 -1
  23. package/dist/gen.test.js +2 -5
  24. package/dist/git.d.ts +1 -1
  25. package/dist/gro.config.default.js +1 -1
  26. package/dist/gro.js +1 -1
  27. package/dist/gro_helpers.js +1 -2
  28. package/dist/gro_plugin_gen.js +3 -4
  29. package/dist/gro_plugin_server.d.ts +5 -7
  30. package/dist/gro_plugin_server.js +3 -3
  31. package/dist/gro_plugin_sveltekit_app.d.ts +3 -5
  32. package/dist/gro_plugin_sveltekit_app.js +38 -28
  33. package/dist/gro_plugin_sveltekit_library.d.ts +2 -2
  34. package/dist/gro_plugin_sveltekit_library.js +2 -2
  35. package/dist/input_path.test.js +1 -1
  36. package/dist/invoke_task.js +3 -3
  37. package/dist/lint.task.js +1 -2
  38. package/dist/loader.js +3 -3
  39. package/dist/package.d.ts +7 -10
  40. package/dist/package.gen.js +3 -3
  41. package/dist/package.js +18 -15
  42. package/dist/package_json.d.ts +4 -6
  43. package/dist/package_json.js +14 -15
  44. package/dist/package_json.test.js +12 -12
  45. package/dist/path.d.ts +2 -6
  46. package/dist/plugin.d.ts +1 -3
  47. package/dist/plugin.js +2 -2
  48. package/dist/plugin.test.js +3 -3
  49. package/dist/publish.task.js +4 -4
  50. package/dist/release.task.js +2 -2
  51. package/dist/resolve.task.js +1 -1
  52. package/dist/resolve_node_specifier.d.ts +1 -1
  53. package/dist/resolve_node_specifier.js +2 -2
  54. package/dist/resolve_node_specifier.test.js +6 -6
  55. package/dist/resolve_specifier.d.ts +1 -1
  56. package/dist/resolve_specifier.js +1 -1
  57. package/dist/resolve_specifier.test.js +16 -16
  58. package/dist/run_gen.test.js +11 -11
  59. package/dist/run_task.js +1 -1
  60. package/dist/run_task.test.js +3 -2
  61. package/dist/src_json.d.ts +3 -5
  62. package/dist/src_json.js +11 -13
  63. package/dist/src_json.test.js +2 -2
  64. package/dist/sveltekit_config.js +1 -1
  65. package/dist/sveltekit_helpers.d.ts +4 -4
  66. package/dist/sveltekit_helpers.js +4 -4
  67. package/dist/sveltekit_shim_env.d.ts +1 -1
  68. package/dist/sveltekit_shim_env.js +2 -2
  69. package/dist/task.d.ts +1 -1
  70. package/dist/task_logging.d.ts +1 -1
  71. package/dist/task_logging.js +3 -4
  72. package/dist/upgrade.task.js +1 -1
  73. package/dist/watch_dir.d.ts +1 -3
  74. package/dist/watch_dir.js +6 -6
  75. package/package.json +18 -21
  76. package/dist/fs.test.d.ts +0 -1
  77. package/dist/fs.test.js +0 -16
@@ -1,6 +1,5 @@
1
- import { cp, mkdir, rm, writeFile } from 'node:fs/promises';
1
+ import { cpSync, mkdirSync, rmSync, writeFileSync, existsSync } from 'node:fs';
2
2
  import { dirname, join } from 'node:path';
3
- import { existsSync } from 'node:fs';
4
3
  import { serialize_args, to_forwarded_args } from './args.js';
5
4
  import { serialize_package_json, load_package_json } from './package_json.js';
6
5
  import { Task_Error } from './task.js';
@@ -32,7 +31,7 @@ export const gro_plugin_sveltekit_app = ({ host_target = 'github_pages', well_kn
32
31
  else {
33
32
  // `vite build` in production mode
34
33
  // `.well-known/package.json`
35
- const package_json = await load_package_json(); // TODO put in plugin context? same with sveltekit config?
34
+ const package_json = load_package_json(); // TODO put in plugin context? same with sveltekit config?
36
35
  if (well_known_package_json === undefined) {
37
36
  well_known_package_json = package_json.public; // eslint-disable-line no-param-reassign
38
37
  }
@@ -43,8 +42,8 @@ export const gro_plugin_sveltekit_app = ({ host_target = 'github_pages', well_kn
43
42
  : await well_known_package_json(package_json);
44
43
  const serialized_package_json = mapped_package_json && serialize_package_json(mapped_package_json);
45
44
  // `.well-known/src.json` and `.well-known/src/`
46
- const final_package_json = mapped_package_json || package_json;
47
- const src_json = await create_src_json(final_package_json);
45
+ const final_package_json = mapped_package_json ?? package_json;
46
+ const src_json = create_src_json(final_package_json);
48
47
  if (well_known_src_json === undefined) {
49
48
  well_known_src_json = final_package_json.public; // eslint-disable-line no-param-reassign
50
49
  }
@@ -61,13 +60,13 @@ export const gro_plugin_sveltekit_app = ({ host_target = 'github_pages', well_kn
61
60
  const { assets_path } = sveltekit_config_global;
62
61
  const cleanups = [
63
62
  serialized_package_json
64
- ? await create_temporarily(join(assets_path, '.well-known/package.json'), serialized_package_json)
63
+ ? create_temporarily(join(assets_path, '.well-known/package.json'), serialized_package_json)
65
64
  : null,
66
65
  serialized_src_json
67
- ? await create_temporarily(join(assets_path, '.well-known/src.json'), serialized_src_json)
66
+ ? create_temporarily(join(assets_path, '.well-known/src.json'), serialized_src_json)
68
67
  : null,
69
68
  serialized_src_json && well_known_src_files
70
- ? await copy_temporarily(SOURCE_DIRNAME, assets_path, '.well-known', well_known_src_files === true
69
+ ? copy_temporarily(SOURCE_DIRNAME, assets_path, '.well-known', well_known_src_files === true
71
70
  ? (file_path) => !DEFAULT_EXPORTS_EXCLUDER.test(file_path)
72
71
  : well_known_src_files)
73
72
  : null,
@@ -78,10 +77,13 @@ export const gro_plugin_sveltekit_app = ({ host_target = 'github_pages', well_kn
78
77
  * to tell GitHub Pages to treat the outputs as plain static files.
79
78
  */
80
79
  host_target === 'github_pages'
81
- ? await create_temporarily(join(assets_path, '.nojekyll'), '')
80
+ ? create_temporarily(join(assets_path, '.nojekyll'), '')
82
81
  : null,
83
- ].filter(Boolean);
84
- const cleanup = () => Promise.all(cleanups.map((c) => c()));
82
+ ].filter((v) => v != null);
83
+ const cleanup = () => {
84
+ for (const c of cleanups)
85
+ c();
86
+ };
85
87
  try {
86
88
  const serialized_args = ['build', ...serialize_args(to_forwarded_args(vite_cli))];
87
89
  const spawned = await spawn_cli(found_vite_cli, serialized_args, log);
@@ -90,10 +92,10 @@ export const gro_plugin_sveltekit_app = ({ host_target = 'github_pages', well_kn
90
92
  }
91
93
  }
92
94
  catch (err) {
93
- await cleanup();
95
+ cleanup();
94
96
  throw err;
95
97
  }
96
- await cleanup();
98
+ cleanup();
97
99
  }
98
100
  },
99
101
  teardown: async () => {
@@ -105,29 +107,33 @@ export const gro_plugin_sveltekit_app = ({ host_target = 'github_pages', well_kn
105
107
  };
106
108
  };
107
109
  // TODO probably extract these, and create a common helper or merge them
108
- const copy_temporarily = async (source_path, dest_dir, dest_base_dir = '', filter) => {
110
+ const copy_temporarily = (source_path, dest_dir, dest_base_dir = '', filter) => {
109
111
  const path = join(dest_dir, dest_base_dir, source_path);
110
112
  const dir = dirname(path);
111
113
  const dir_already_exists = existsSync(dir);
112
114
  let root_created_dir;
113
115
  if (!dir_already_exists) {
114
- root_created_dir = await to_root_dir_that_doesnt_exist(dir);
116
+ root_created_dir = to_root_dir_that_doesnt_exist(dir);
115
117
  if (!root_created_dir)
116
118
  throw Error();
117
- await mkdir(dir, { recursive: true });
119
+ mkdirSync(dir, { recursive: true });
118
120
  }
119
121
  const path_already_exists = existsSync(path);
120
122
  if (!path_already_exists) {
121
- await cp(source_path, path, { recursive: true, filter });
123
+ cpSync(source_path, path, { recursive: true, filter });
122
124
  }
123
- return async () => {
125
+ return () => {
124
126
  if (!dir_already_exists) {
125
127
  if (!root_created_dir)
126
128
  throw Error();
127
- await rm(root_created_dir, { recursive: true });
129
+ if (existsSync(root_created_dir)) {
130
+ rmSync(root_created_dir, { recursive: true });
131
+ }
128
132
  }
129
133
  else if (!path_already_exists) {
130
- await rm(path, { recursive: true });
134
+ if (existsSync(path)) {
135
+ rmSync(path, { recursive: true });
136
+ }
131
137
  }
132
138
  };
133
139
  };
@@ -138,28 +144,32 @@ const copy_temporarily = async (source_path, dest_dir, dest_base_dir = '', filte
138
144
  * @param contents
139
145
  * @returns cleanup function that deletes the file and any created dirs
140
146
  */
141
- const create_temporarily = async (path, contents) => {
147
+ const create_temporarily = (path, contents) => {
142
148
  const dir = dirname(path);
143
149
  const dir_already_exists = existsSync(dir);
144
150
  let root_created_dir;
145
151
  if (!dir_already_exists) {
146
- root_created_dir = await to_root_dir_that_doesnt_exist(dir);
152
+ root_created_dir = to_root_dir_that_doesnt_exist(dir);
147
153
  if (!root_created_dir)
148
154
  throw Error();
149
- await mkdir(dir, { recursive: true });
155
+ mkdirSync(dir, { recursive: true });
150
156
  }
151
157
  const path_already_exists = existsSync(path);
152
158
  if (!path_already_exists) {
153
- await writeFile(path, contents, 'utf8');
159
+ writeFileSync(path, contents, 'utf8');
154
160
  }
155
- return async () => {
161
+ return () => {
156
162
  if (!dir_already_exists) {
157
163
  if (!root_created_dir)
158
164
  throw Error();
159
- await rm(root_created_dir, { recursive: true });
165
+ if (existsSync(root_created_dir)) {
166
+ rmSync(root_created_dir, { recursive: true });
167
+ }
160
168
  }
161
169
  else if (!path_already_exists) {
162
- await rm(path);
170
+ if (existsSync(path)) {
171
+ rmSync(path);
172
+ }
163
173
  }
164
174
  };
165
175
  };
@@ -168,7 +178,7 @@ const create_temporarily = async (path, contents) => {
168
178
  * for `/a/b/DOESNT_EXIST/NOR_THIS/ETC` returns `/a/b/DOESNT_EXIST`
169
179
  * where `/a/b` does exist on the filesystem and `DOESNT_EXIST` is not one of its subdirectories.
170
180
  */
171
- const to_root_dir_that_doesnt_exist = async (dir) => {
181
+ const to_root_dir_that_doesnt_exist = (dir) => {
172
182
  let prev;
173
183
  let d = dir;
174
184
  do {
@@ -1,4 +1,4 @@
1
- import type { Plugin, Plugin_Context } from './plugin.js';
1
+ import type { Plugin } from './plugin.js';
2
2
  import { type Svelte_Package_Options } from './sveltekit_helpers.js';
3
3
  export interface Options {
4
4
  /**
@@ -12,4 +12,4 @@ export interface Options {
12
12
  */
13
13
  svelte_package_cli?: string;
14
14
  }
15
- export declare const gro_plugin_sveltekit_library: ({ svelte_package_options, svelte_package_cli, }?: Options) => Plugin<Plugin_Context>;
15
+ export declare const gro_plugin_sveltekit_library: ({ svelte_package_options, svelte_package_cli, }?: Options) => Plugin;
@@ -8,7 +8,7 @@ export const gro_plugin_sveltekit_library = ({ svelte_package_options, svelte_pa
8
8
  return {
9
9
  name: 'gro_plugin_sveltekit_library',
10
10
  setup: async ({ log }) => {
11
- const has_sveltekit_library_result = await has_sveltekit_library();
11
+ const has_sveltekit_library_result = has_sveltekit_library();
12
12
  if (!has_sveltekit_library_result.ok) {
13
13
  throw new Task_Error('Failed to find SvelteKit library: ' + has_sveltekit_library_result.message);
14
14
  }
@@ -23,7 +23,7 @@ export const gro_plugin_sveltekit_library = ({ svelte_package_options, svelte_pa
23
23
  await spawn_cli(found_svelte_package_cli, serialized_args, log);
24
24
  },
25
25
  adapt: async ({ log, timings }) => {
26
- const package_json = await load_package_json();
26
+ const package_json = load_package_json();
27
27
  // `npm link`
28
28
  if (package_json.bin) {
29
29
  const timing_to_npm_link = timings.start('npm link');
@@ -90,7 +90,7 @@ test('get_possible_paths implied to be a directory by trailing slash', () => {
90
90
  { id: input_path, input_path: resolve('src/foo/bar') + '/', root_dir: resolve('src/foo') },
91
91
  ]);
92
92
  });
93
- test('resolve_input_files', async () => {
93
+ test('resolve_input_files', () => {
94
94
  const test_files = {
95
95
  'fake/test1.ext.ts': [
96
96
  { id: 'fake/test1.ext.ts', path: 'fake/test1.ext.ts', is_directory: false },
@@ -43,7 +43,7 @@ export const invoke_task = async (task_name, args, config, initial_timings = nul
43
43
  };
44
44
  // Check if the caller just wants to see the version.
45
45
  if (!task_name && (args?.version || args?.v)) {
46
- const gro_package_json = await load_gro_package_json();
46
+ const gro_package_json = load_gro_package_json();
47
47
  log.info(`${gray('v')}${cyan(gro_package_json.version)}`);
48
48
  finish();
49
49
  return;
@@ -70,7 +70,7 @@ export const invoke_task = async (task_name, args, config, initial_timings = nul
70
70
  const loaded_tasks = loaded.value;
71
71
  if (resolved_input_files.length > 1 || resolved_input_files[0].resolved_input_path.is_directory) {
72
72
  // The input path matches a directory. Log the tasks but don't run them.
73
- await log_tasks(log, loaded_tasks);
73
+ log_tasks(log, loaded_tasks);
74
74
  finish();
75
75
  return;
76
76
  }
@@ -78,7 +78,7 @@ export const invoke_task = async (task_name, args, config, initial_timings = nul
78
78
  if (loaded_tasks.modules.length !== 1)
79
79
  throw Error('expected one loaded task'); // run only one task at a time
80
80
  const task = loaded_tasks.modules[0];
81
- log.info(`→ ${cyan(task.name)} ${(task.mod.task.summary && gray(task.mod.task.summary)) || ''}`);
81
+ log.info(`→ ${cyan(task.name)} ${(task.mod.task.summary && gray(task.mod.task.summary)) ?? ''}`);
82
82
  const timing_to_run_task = timings.start('run task ' + task_name);
83
83
  const result = await run_task(task, { ...args, ...to_forwarded_args(`gro ${task.name}`) }, invoke_task, config, timings);
84
84
  timing_to_run_task();
package/dist/lint.task.js CHANGED
@@ -2,12 +2,11 @@ import { print_spawn_result } from '@ryanatkn/belt/process.js';
2
2
  import { z } from 'zod';
3
3
  import { Task_Error } from './task.js';
4
4
  import { serialize_args, to_forwarded_args } from './args.js';
5
- import { SOURCE_DIRNAME } from './path_constants.js';
6
5
  import { find_cli, spawn_cli } from './cli.js';
7
6
  const ESLINT_CLI = 'eslint';
8
7
  export const Args = z
9
8
  .object({
10
- _: z.array(z.string(), { description: 'paths to serve' }).default([SOURCE_DIRNAME]),
9
+ _: z.array(z.string(), { description: 'paths to serve' }).default([]),
11
10
  eslint_cli: z.string({ description: 'the ESLint CLI to use' }).default(ESLINT_CLI),
12
11
  })
13
12
  .strict();
package/dist/loader.js CHANGED
@@ -122,7 +122,7 @@ export const load = async (url, context, nextLoad) => {
122
122
  return {
123
123
  format: 'module',
124
124
  shortCircuit: true,
125
- source: await render_env_shim_module(dev, mode, visibility, public_prefix, private_prefix, env_dir),
125
+ source: render_env_shim_module(dev, mode, visibility, public_prefix, private_prefix, env_dir),
126
126
  };
127
127
  }
128
128
  }
@@ -164,13 +164,13 @@ export const resolve = async (specifier, context, nextResolve) => {
164
164
  if (SVELTE_MATCHER.test(path) || JSON_MATCHER.test(path)) {
165
165
  // Match the behavior of Vite and esbuild for Svelte and JSON imports.
166
166
  // TODO maybe `.ts` too
167
- const path_id = await resolve_node_specifier(path, dir, parent_url, package_json_cache);
167
+ const path_id = resolve_node_specifier(path, dir, parent_url, package_json_cache);
168
168
  return { url: pathToFileURL(path_id).href, format: 'module', shortCircuit: true };
169
169
  }
170
170
  else {
171
171
  return nextResolve(path, context);
172
172
  }
173
173
  }
174
- const { path_id } = await resolve_specifier(path, dirname(fileURLToPath(parent_url)));
174
+ const { path_id } = resolve_specifier(path, dirname(fileURLToPath(parent_url)));
175
175
  return { url: pathToFileURL(path_id).href, format: 'module', shortCircuit: true };
176
176
  };
package/dist/package.d.ts CHANGED
@@ -21,9 +21,14 @@ export declare const package_json: {
21
21
  bugs: string;
22
22
  funding: string;
23
23
  scripts: {
24
- build: string;
24
+ bootstrap: string;
25
25
  start: string;
26
+ dev: string;
27
+ build: string;
28
+ check: string;
26
29
  test: string;
30
+ preview: string;
31
+ deploy: string;
27
32
  };
28
33
  type: string;
29
34
  engines: {
@@ -62,23 +67,15 @@ export declare const package_json: {
62
67
  '@sveltejs/vite-plugin-svelte': string;
63
68
  '@types/fs-extra': string;
64
69
  '@types/node': string;
65
- '@typescript-eslint/eslint-plugin': string;
66
- '@typescript-eslint/parser': string;
67
70
  esbuild: string;
68
71
  eslint: string;
69
72
  'eslint-plugin-svelte': string;
70
73
  svelte: string;
71
74
  'svelte-check': string;
72
75
  typescript: string;
76
+ 'typescript-eslint': string;
73
77
  uvu: string;
74
78
  };
75
- eslintConfig: {
76
- root: boolean;
77
- extends: string;
78
- rules: {
79
- 'no-console': number;
80
- };
81
- };
82
79
  prettier: {
83
80
  plugins: string[];
84
81
  useTabs: boolean;
@@ -8,9 +8,9 @@ import { create_src_json } from './src_json.js';
8
8
  * which mirrors `package.json` but in TypeScript,
9
9
  * allowing apps to import typesafe data from their own `package.json`.
10
10
  */
11
- export const gen = async ({ origin_id }) => {
12
- const package_json = await load_package_json();
13
- const src_json = await create_src_json(package_json);
11
+ export const gen = ({ origin_id }) => {
12
+ const package_json = load_package_json();
13
+ const src_json = create_src_json(package_json);
14
14
  return `
15
15
  // generated by ${to_root_path(origin_id)}
16
16
 
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.129.0',
4
+ version: '0.129.1',
5
5
  description: 'task runner and toolkit extending SvelteKit',
6
6
  motto: 'generate, run, optimize',
7
7
  glyph: '🌰',
@@ -15,9 +15,14 @@ export const package_json = {
15
15
  bugs: 'https://github.com/ryanatkn/gro/issues',
16
16
  funding: 'https://www.ryanatkn.com/funding',
17
17
  scripts: {
18
- build: 'rm -rf .gro dist && svelte-kit sync && svelte-package && chmod +x ./dist/gro.js && npm link -f',
18
+ bootstrap: 'rm -rf .gro dist && svelte-kit sync && svelte-package && chmod +x ./dist/gro.js && npm link -f',
19
19
  start: 'gro dev',
20
+ dev: 'gro dev',
21
+ build: 'gro build',
22
+ check: 'gro check',
20
23
  test: 'gro test',
24
+ preview: 'vite preview',
25
+ deploy: 'gro deploy',
21
26
  },
22
27
  type: 'module',
23
28
  engines: { node: '>=20.12' },
@@ -34,7 +39,7 @@ export const package_json = {
34
39
  'typescript',
35
40
  ],
36
41
  dependencies: {
37
- '@ryanatkn/belt': '^0.24.1',
42
+ '@ryanatkn/belt': '^0.24.2',
38
43
  chokidar: '^3.6.0',
39
44
  dotenv: '^16.4.5',
40
45
  'es-module-lexer': '^1.5.4',
@@ -46,30 +51,28 @@ export const package_json = {
46
51
  tslib: '^2.6.3',
47
52
  zod: '^3.23.8',
48
53
  },
49
- peerDependencies: { esbuild: '^0.21', svelte: '^5.0.0-next.0' },
54
+ peerDependencies: { esbuild: '^0.21.0', svelte: '^5.0.0-next.0' },
50
55
  devDependencies: {
51
56
  '@changesets/changelog-git': '^0.2.0',
52
57
  '@changesets/types': '^6.0.0',
53
- '@ryanatkn/eslint-config': '^0.1.3',
54
- '@ryanatkn/fuz': '^0.107.0',
55
- '@ryanatkn/moss': '^0.6.3',
58
+ '@ryanatkn/eslint-config': '^0.4.0',
59
+ '@ryanatkn/fuz': '^0.108.2',
60
+ '@ryanatkn/moss': '^0.7.0',
56
61
  '@sveltejs/adapter-static': '^3.0.2',
57
62
  '@sveltejs/kit': '^2.5.18',
58
63
  '@sveltejs/package': '^2.3.2',
59
64
  '@sveltejs/vite-plugin-svelte': '^3.1.1',
60
65
  '@types/fs-extra': '^11.0.4',
61
- '@types/node': '^20.14.9',
62
- '@typescript-eslint/eslint-plugin': '^7.14.1',
63
- '@typescript-eslint/parser': '^7.14.1',
66
+ '@types/node': '^20.14.10',
64
67
  esbuild: '^0.21.5',
65
- eslint: '^8.57.0',
68
+ eslint: '^9.6.0',
66
69
  'eslint-plugin-svelte': '^2.41.0',
67
- svelte: '^5.0.0-next.167',
70
+ svelte: '^5.0.0-next.175',
68
71
  'svelte-check': '^3.8.4',
69
- typescript: '^5.5.2',
72
+ typescript: '^5.5.3',
73
+ 'typescript-eslint': '^8.0.0-alpha.39',
70
74
  uvu: '^0.5.6',
71
75
  },
72
- eslintConfig: { root: true, extends: '@ryanatkn', rules: { 'no-console': 1 } },
73
76
  prettier: {
74
77
  plugins: ['prettier-plugin-svelte'],
75
78
  useTabs: true,
@@ -263,7 +266,7 @@ export const package_json = {
263
266
  };
264
267
  export const src_json = {
265
268
  name: '@ryanatkn/gro',
266
- version: '0.129.0',
269
+ version: '0.129.1',
267
270
  modules: {
268
271
  '.': {
269
272
  path: 'index.ts',
@@ -337,17 +337,15 @@ export declare const Package_Json: z.ZodObject<{
337
337
  exports: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>>, any, Record<string, string | Record<string, string> | undefined>>>;
338
338
  }, z.ZodTypeAny, "passthrough">>;
339
339
  export type Package_Json = z.infer<typeof Package_Json>;
340
- export interface Map_Package_Json {
341
- (package_json: Package_Json): Package_Json | null | Promise<Package_Json | null>;
342
- }
340
+ export type Map_Package_Json = (package_json: Package_Json) => Package_Json | null | Promise<Package_Json | null>;
343
341
  export declare const EMPTY_PACKAGE_JSON: Package_Json;
344
- export declare const load_package_json: (dir?: string, cache?: Record<string, Package_Json>) => Promise<Package_Json>;
342
+ export declare const load_package_json: (dir?: string, cache?: Record<string, Package_Json>) => Package_Json;
345
343
  export declare const sync_package_json: (map_package_json: Map_Package_Json, log: Logger, check?: boolean, dir?: string, exports_dir?: string) => Promise<{
346
344
  package_json: Package_Json | null;
347
345
  changed: boolean;
348
346
  }>;
349
- export declare const load_gro_package_json: () => Promise<Package_Json>;
350
- export declare const write_package_json: (serialized_package_json: string) => Promise<void>;
347
+ export declare const load_gro_package_json: () => Package_Json;
348
+ export declare const write_package_json: (serialized_package_json: string) => void;
351
349
  export declare const serialize_package_json: (package_json: Package_Json) => string;
352
350
  /**
353
351
  * Updates package.json. Writes to the filesystem only when contents change.
@@ -1,8 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { join } from 'node:path';
3
- import { readFile, writeFile } from 'node:fs/promises';
4
- import { count_graphemes, plural } from '@ryanatkn/belt/string.js';
5
- import { strip_end } from '@ryanatkn/belt/string.js';
3
+ import { readFileSync, writeFileSync } from 'node:fs';
4
+ import { count_graphemes, plural, strip_end } from '@ryanatkn/belt/string.js';
6
5
  import { red } from '@ryanatkn/belt/styletext.js';
7
6
  import { paths, gro_paths, IS_THIS_GRO, replace_extension } from './paths.js';
8
7
  import { SVELTEKIT_DIST_DIRNAME } from './path_constants.js';
@@ -16,7 +15,7 @@ export const Email = z.string();
16
15
  // TODO move this where?
17
16
  export const transform_empty_object_to_undefined = (val) => {
18
17
  if (val && Object.keys(val).length === 0) {
19
- return undefined;
18
+ return;
20
19
  }
21
20
  return val;
22
21
  };
@@ -111,15 +110,15 @@ export const Package_Json = z
111
110
  })
112
111
  .passthrough();
113
112
  export const EMPTY_PACKAGE_JSON = { name: '', version: '' };
114
- export const load_package_json = async (dir = IS_THIS_GRO ? gro_paths.root : paths.root, cache) => {
113
+ export const load_package_json = (dir = IS_THIS_GRO ? gro_paths.root : paths.root, cache) => {
115
114
  let package_json;
116
115
  if (cache && dir in cache) {
117
116
  return cache[dir];
118
117
  }
119
118
  try {
120
- package_json = JSON.parse(await load_package_json_contents(dir));
119
+ package_json = JSON.parse(load_package_json_contents(dir));
121
120
  }
122
- catch (err) {
121
+ catch (_err) {
123
122
  return EMPTY_PACKAGE_JSON;
124
123
  }
125
124
  package_json = parse_package_json(Package_Json, package_json);
@@ -131,7 +130,7 @@ export const sync_package_json = async (map_package_json, log, check = false, di
131
130
  const exported_files = search_fs(exports_dir);
132
131
  const exported_paths = exported_files.map((f) => f.path);
133
132
  const updated = await update_package_json(dir, async (package_json) => {
134
- if ((await has_sveltekit_library(package_json)).ok) {
133
+ if (has_sveltekit_library(package_json).ok) {
135
134
  const exports = to_package_exports(exported_paths);
136
135
  package_json.exports = exports;
137
136
  }
@@ -148,16 +147,16 @@ export const sync_package_json = async (map_package_json, log, check = false, di
148
147
  };
149
148
  export const load_gro_package_json = () => load_package_json(gro_paths.root);
150
149
  // TODO probably make this nullable and make callers handle failures
151
- const load_package_json_contents = (dir) => readFile(join(dir, 'package.json'), 'utf8');
152
- export const write_package_json = async (serialized_package_json) => {
153
- await writeFile(join(paths.root, 'package.json'), serialized_package_json);
150
+ const load_package_json_contents = (dir) => readFileSync(join(dir, 'package.json'), 'utf8');
151
+ export const write_package_json = (serialized_package_json) => {
152
+ writeFileSync(join(paths.root, 'package.json'), serialized_package_json);
154
153
  };
155
154
  export const serialize_package_json = (package_json) => JSON.stringify(parse_package_json(Package_Json, package_json), null, 2) + '\n';
156
155
  /**
157
156
  * Updates package.json. Writes to the filesystem only when contents change.
158
157
  */
159
158
  export const update_package_json = async (dir = paths.root, update, write = true) => {
160
- const original_contents = await load_package_json_contents(dir);
159
+ const original_contents = load_package_json_contents(dir);
161
160
  const original = JSON.parse(original_contents);
162
161
  const updated = await update(original);
163
162
  if (updated === null) {
@@ -168,7 +167,7 @@ export const update_package_json = async (dir = paths.root, update, write = true
168
167
  return { package_json: original, changed: false };
169
168
  }
170
169
  if (write)
171
- await write_package_json(updated_contents);
170
+ write_package_json(updated_contents);
172
171
  return { package_json: updated, changed: true };
173
172
  };
174
173
  const is_index = (path) => path === 'index.ts' || path === 'index.js';
@@ -232,11 +231,11 @@ export const parse_repo_url = (package_json) => {
232
231
  : repository.url
233
232
  : undefined;
234
233
  if (!repo_url) {
235
- return undefined;
234
+ return;
236
235
  }
237
236
  const parsed_repo_url = GITHUB_REPO_MATCHER.exec(strip_end(strip_end(repo_url, '/'), '.git'));
238
237
  if (!parsed_repo_url) {
239
- return undefined;
238
+ return;
240
239
  }
241
240
  const [, owner, repo] = parsed_repo_url;
242
241
  return { owner, repo };
@@ -1,26 +1,26 @@
1
1
  import { test } from 'uvu';
2
2
  import * as assert from 'uvu/assert';
3
3
  import { Package_Json, load_package_json, parse_repo_url, serialize_package_json, to_package_exports, } from './package_json.js';
4
- test('load_package_json', async () => {
5
- const package_json = await load_package_json();
4
+ test('load_package_json', () => {
5
+ const package_json = load_package_json();
6
6
  assert.ok(package_json);
7
7
  const parsed = Package_Json.parse(package_json);
8
8
  assert.ok(parsed);
9
9
  serialize_package_json(package_json);
10
10
  });
11
- test('load_package_json with cache', async () => {
11
+ test('load_package_json with cache', () => {
12
12
  const cache = {};
13
- const package_json1 = await load_package_json(undefined, cache);
13
+ const package_json1 = load_package_json(undefined, cache);
14
14
  assert.ok(package_json1);
15
15
  assert.is(Object.keys(cache).length, 1);
16
- const package_json2 = await load_package_json(undefined, cache);
16
+ const package_json2 = load_package_json(undefined, cache);
17
17
  assert.is(Object.keys(cache).length, 1);
18
18
  assert.is(package_json1, package_json2);
19
19
  });
20
- test('Package_Json.parse', async () => {
20
+ test('Package_Json.parse', () => {
21
21
  Package_Json.parse({ name: 'abc', version: '123' });
22
22
  });
23
- test('Package_Json.parse fails with bad data', async () => {
23
+ test('Package_Json.parse fails with bad data', () => {
24
24
  let err;
25
25
  try {
26
26
  Package_Json.parse({ version: '123' });
@@ -30,10 +30,10 @@ test('Package_Json.parse fails with bad data', async () => {
30
30
  }
31
31
  assert.ok(err);
32
32
  });
33
- test('serialize_package_json', async () => {
33
+ test('serialize_package_json', () => {
34
34
  serialize_package_json({ name: 'abc', version: '123' });
35
35
  });
36
- test('serialize_package_json fails with bad data', async () => {
36
+ test('serialize_package_json fails with bad data', () => {
37
37
  let err;
38
38
  try {
39
39
  serialize_package_json({ version: '123' });
@@ -43,7 +43,7 @@ test('serialize_package_json fails with bad data', async () => {
43
43
  }
44
44
  assert.ok(err);
45
45
  });
46
- test('to_package_exports', async () => {
46
+ test('to_package_exports', () => {
47
47
  assert.equal(to_package_exports(['a/b.ts']), {
48
48
  './package.json': './package.json',
49
49
  './a/b.js': {
@@ -76,8 +76,8 @@ test('to_package_exports', async () => {
76
76
  },
77
77
  });
78
78
  });
79
- test('parse_repo_url', async () => {
80
- const parsed = parse_repo_url(await load_package_json());
79
+ test('parse_repo_url', () => {
80
+ const parsed = parse_repo_url(load_package_json());
81
81
  assert.is(parsed?.owner, 'ryanatkn');
82
82
  assert.is(parsed?.repo, 'gro');
83
83
  });
package/dist/path.d.ts CHANGED
@@ -10,10 +10,6 @@ export interface Path_Info {
10
10
  export interface Resolved_Path extends Path_Info {
11
11
  path: string;
12
12
  }
13
- export interface Path_Filter {
14
- (path: string, is_directory: boolean): boolean;
15
- }
16
- export interface File_Filter {
17
- (path: string): boolean;
18
- }
13
+ export type Path_Filter = (path: string, is_directory: boolean) => boolean;
14
+ export type File_Filter = (path: string) => boolean;
19
15
  export declare const to_file_path: (path_or_url: string | URL) => string;
package/dist/plugin.d.ts CHANGED
@@ -9,9 +9,7 @@ export interface Plugin<T_Plugin_Context extends Plugin_Context = Plugin_Context
9
9
  adapt?: (ctx: T_Plugin_Context) => void | Promise<void>;
10
10
  teardown?: (ctx: T_Plugin_Context) => void | Promise<void>;
11
11
  }
12
- export interface Create_Config_Plugins<T_Plugin_Context extends Plugin_Context = Plugin_Context> {
13
- (ctx: T_Plugin_Context): (Plugin<T_Plugin_Context> | null | Array<Plugin<T_Plugin_Context> | null>) | Promise<Plugin<T_Plugin_Context> | null | Array<Plugin<T_Plugin_Context> | null>>;
14
- }
12
+ export type Create_Config_Plugins<T_Plugin_Context extends Plugin_Context = Plugin_Context> = (ctx: T_Plugin_Context) => (Plugin<T_Plugin_Context> | null | Array<Plugin<T_Plugin_Context> | null>) | Promise<Plugin<T_Plugin_Context> | null | Array<Plugin<T_Plugin_Context> | null>>;
15
13
  export interface Plugin_Context<T_Args = object> extends Task_Context<T_Args> {
16
14
  dev: boolean;
17
15
  watch: boolean;
package/dist/plugin.js CHANGED
@@ -10,7 +10,7 @@ export class Plugins {
10
10
  static async create(ctx) {
11
11
  const { timings } = ctx;
12
12
  const timing_to_create = timings.start('plugins.create');
13
- const instances = to_array(await ctx.config.plugins(ctx)).filter(Boolean);
13
+ const instances = to_array(await ctx.config.plugins(ctx)).filter((v) => v !== null); // TODO remove cast, should infer the type predicate? `Type '(Plugin<Plugin_Context<object>> | null)[]' is not assignable to type 'Plugin<Plugin_Context<object>>[]'.`
14
14
  const plugins = new Plugins(ctx, instances);
15
15
  timing_to_create();
16
16
  return plugins;
@@ -70,7 +70,7 @@ export class Plugins {
70
70
  * @returns `plugins` with `new_plugin` at the index of the plugin with `name`
71
71
  */
72
72
  export const replace_plugin = (plugins, new_plugin, name = new_plugin.name) => {
73
- const array = to_array(plugins).filter(Boolean);
73
+ const array = to_array(plugins).filter((v) => v !== null);
74
74
  const index = array.findIndex((p) => p.name === name);
75
75
  if (index === -1)
76
76
  throw Error('Failed to find plugin to replace: ' + name);