@ryanatkn/gro 0.147.1 → 0.149.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.
- package/README.md +5 -3
- package/dist/args.d.ts +5 -5
- package/dist/args.d.ts.map +1 -1
- package/dist/build.task.d.ts.map +1 -1
- package/dist/changelog.d.ts +2 -1
- package/dist/changelog.d.ts.map +1 -1
- package/dist/changeset.task.d.ts.map +1 -1
- package/dist/changeset_helpers.d.ts.map +1 -1
- package/dist/check.task.d.ts.map +1 -1
- package/dist/child_process_logging.d.ts +10 -0
- package/dist/child_process_logging.d.ts.map +1 -0
- package/dist/child_process_logging.js +26 -0
- package/dist/clean.task.d.ts.map +1 -1
- package/dist/clean_fs.d.ts.map +1 -1
- package/dist/cli.d.ts +4 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/commit.task.d.ts.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -0
- package/dist/deploy.task.d.ts +2 -2
- package/dist/deploy.task.d.ts.map +1 -1
- package/dist/dev.task.d.ts.map +1 -1
- package/dist/env.d.ts.map +1 -1
- package/dist/esbuild_helpers.d.ts.map +1 -1
- package/dist/esbuild_helpers.js +1 -1
- package/dist/esbuild_plugin_external_worker.d.ts +2 -2
- package/dist/esbuild_plugin_external_worker.d.ts.map +1 -1
- package/dist/esbuild_plugin_svelte.d.ts +1 -1
- package/dist/esbuild_plugin_svelte.d.ts.map +1 -1
- package/dist/esbuild_plugin_sveltekit_local_imports.d.ts.map +1 -1
- package/dist/esbuild_plugin_sveltekit_shim_alias.d.ts.map +1 -1
- package/dist/esbuild_plugin_sveltekit_shim_app.d.ts.map +1 -1
- package/dist/esbuild_plugin_sveltekit_shim_env.d.ts +1 -1
- package/dist/esbuild_plugin_sveltekit_shim_env.d.ts.map +1 -1
- package/dist/filer.d.ts.map +1 -1
- package/dist/format.task.d.ts.map +1 -1
- package/dist/format_directory.d.ts.map +1 -1
- package/dist/format_file.d.ts.map +1 -1
- package/dist/fs.d.ts.map +1 -1
- package/dist/gen.d.ts +23 -22
- package/dist/gen.d.ts.map +1 -1
- package/dist/gen.task.d.ts.map +1 -1
- package/dist/git.d.ts.map +1 -1
- package/dist/github.d.ts +3 -1
- package/dist/github.d.ts.map +1 -1
- package/dist/gro.config.default.d.ts.map +1 -1
- package/dist/gro.d.ts.map +1 -1
- package/dist/gro.js +1 -1
- package/dist/gro_config.d.ts +5 -5
- package/dist/gro_config.d.ts.map +1 -1
- package/dist/gro_helpers.d.ts +1 -1
- package/dist/gro_helpers.d.ts.map +1 -1
- package/dist/gro_plugin_gen.d.ts +2 -2
- package/dist/gro_plugin_gen.d.ts.map +1 -1
- package/dist/gro_plugin_moss.d.ts +1 -1
- package/dist/gro_plugin_moss.d.ts.map +1 -1
- package/dist/gro_plugin_moss.js +1 -1
- package/dist/gro_plugin_server.d.ts +2 -2
- package/dist/gro_plugin_server.d.ts.map +1 -1
- package/dist/gro_plugin_sveltekit_app.d.ts.map +1 -1
- package/dist/gro_plugin_sveltekit_library.d.ts.map +1 -1
- package/dist/hash.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/input_path.d.ts +10 -10
- package/dist/input_path.d.ts.map +1 -1
- package/dist/invoke.d.ts.map +1 -1
- package/dist/invoke.js +2 -0
- package/dist/invoke_task.d.ts.map +1 -1
- package/dist/lint.task.d.ts.map +1 -1
- package/dist/loader.d.ts.map +1 -1
- package/dist/module.d.ts.map +1 -1
- package/dist/modules.d.ts +6 -5
- package/dist/modules.d.ts.map +1 -1
- package/dist/package.d.ts +11 -1
- package/dist/package.d.ts.map +1 -1
- package/dist/package.gen.d.ts.map +1 -1
- package/dist/package.js +42 -31
- package/dist/package_json.d.ts +2 -2
- package/dist/package_json.d.ts.map +1 -1
- package/dist/package_meta.d.ts.map +1 -1
- package/dist/parse_imports.d.ts +1 -1
- package/dist/parse_imports.d.ts.map +1 -1
- package/dist/parse_imports.js +122 -12
- package/dist/path.d.ts.map +1 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/plugin.d.ts +2 -2
- package/dist/plugin.d.ts.map +1 -1
- package/dist/publish.task.d.ts.map +1 -1
- package/dist/register.d.ts.map +1 -1
- package/dist/reinstall.task.d.ts.map +1 -1
- package/dist/release.task.d.ts.map +1 -1
- package/dist/resolve.task.d.ts.map +1 -1
- package/dist/resolve_specifier.d.ts.map +1 -1
- package/dist/run.task.d.ts.map +1 -1
- package/dist/run_gen.d.ts +1 -1
- package/dist/run_gen.d.ts.map +1 -1
- package/dist/run_task.d.ts.map +1 -1
- package/dist/search_fs.d.ts +3 -3
- package/dist/search_fs.d.ts.map +1 -1
- package/dist/src_json.d.ts.map +1 -1
- package/dist/svelte_helpers.d.ts.map +1 -1
- package/dist/sveltekit_config.d.ts +1 -1
- package/dist/sveltekit_config.d.ts.map +1 -1
- package/dist/sveltekit_helpers.d.ts.map +1 -1
- package/dist/sveltekit_shim_app.d.ts.map +1 -1
- package/dist/sveltekit_shim_app_environment.d.ts.map +1 -1
- package/dist/sveltekit_shim_app_forms.d.ts.map +1 -1
- package/dist/sveltekit_shim_app_navigation.d.ts.map +1 -1
- package/dist/sveltekit_shim_app_paths.d.ts.map +1 -1
- package/dist/sveltekit_shim_app_stores.d.ts.map +1 -1
- package/dist/sveltekit_shim_env.d.ts +1 -1
- package/dist/sveltekit_shim_env.d.ts.map +1 -1
- package/dist/sync.task.d.ts.map +1 -1
- package/dist/task.d.ts +19 -19
- package/dist/task.d.ts.map +1 -1
- package/dist/task_logging.d.ts +1 -1
- package/dist/task_logging.d.ts.map +1 -1
- package/dist/task_logging.js +2 -2
- package/dist/test.task.d.ts.map +1 -1
- package/dist/typecheck.task.d.ts +6 -0
- package/dist/typecheck.task.d.ts.map +1 -1
- package/dist/typecheck.task.js +20 -5
- package/dist/upgrade.task.d.ts.map +1 -1
- package/dist/watch_dir.d.ts.map +1 -1
- package/package.json +33 -30
- package/src/lib/args.ts +10 -10
- package/src/lib/child_process_logging.ts +38 -0
- package/src/lib/cli.ts +3 -3
- package/src/lib/constants.ts +2 -0
- package/src/lib/esbuild_helpers.ts +1 -1
- package/src/lib/esbuild_plugin_external_worker.ts +2 -2
- package/src/lib/esbuild_plugin_svelte.ts +1 -1
- package/src/lib/esbuild_plugin_sveltekit_shim_env.ts +1 -1
- package/src/lib/gen.ts +28 -26
- package/src/lib/github.ts +2 -2
- package/src/lib/gro.ts +1 -1
- package/src/lib/gro_config.ts +5 -5
- package/src/lib/gro_helpers.ts +1 -1
- package/src/lib/gro_plugin_gen.ts +3 -3
- package/src/lib/gro_plugin_moss.ts +2 -2
- package/src/lib/gro_plugin_server.ts +2 -2
- package/src/lib/gro_plugin_sveltekit_app.ts +1 -1
- package/src/lib/input_path.ts +23 -23
- package/src/lib/invoke.ts +2 -0
- package/src/lib/modules.ts +8 -8
- package/src/lib/package.ts +42 -31
- package/src/lib/package_json.ts +2 -2
- package/src/lib/parse_imports.ts +151 -14
- package/src/lib/plugin.ts +4 -4
- package/src/lib/run_gen.ts +1 -1
- package/src/lib/search_fs.ts +8 -8
- package/src/lib/src_json.ts +1 -1
- package/src/lib/sveltekit_config.ts +1 -1
- package/src/lib/sveltekit_shim_app_stores.ts +3 -0
- package/src/lib/sveltekit_shim_env.ts +1 -1
- package/src/lib/task.ts +20 -20
- package/src/lib/task_logging.ts +8 -8
- package/src/lib/typecheck.task.ts +24 -5
- package/src/lib/upgrade.task.ts +1 -1
package/src/lib/input_path.ts
CHANGED
|
@@ -41,9 +41,9 @@ export const to_input_path = (
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
export const to_input_paths = (
|
|
44
|
-
raw_input_paths: Raw_Input_Path
|
|
44
|
+
raw_input_paths: Array<Raw_Input_Path>,
|
|
45
45
|
root_path?: string, // TODO @many isn't passed in anywhere, maybe hoist to `invoke_task` and others
|
|
46
|
-
): Input_Path
|
|
46
|
+
): Array<Input_Path> => raw_input_paths.map((p) => to_input_path(p, root_path));
|
|
47
47
|
|
|
48
48
|
export interface Possible_Path {
|
|
49
49
|
id: Path_Id;
|
|
@@ -57,9 +57,9 @@ export interface Possible_Path {
|
|
|
57
57
|
*/
|
|
58
58
|
export const get_possible_paths = (
|
|
59
59
|
input_path: Input_Path,
|
|
60
|
-
root_dirs: Path_Id
|
|
61
|
-
extensions: string
|
|
62
|
-
): Possible_Path
|
|
60
|
+
root_dirs: Array<Path_Id>,
|
|
61
|
+
extensions: Array<string>,
|
|
62
|
+
): Array<Possible_Path> => {
|
|
63
63
|
const possible_paths: Set<Possible_Path> = new Set();
|
|
64
64
|
|
|
65
65
|
const add_possible_paths = (path: string, root_dir: Path_Id) => {
|
|
@@ -113,9 +113,9 @@ export interface Resolved_Input_File {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
export interface Resolved_Input_Paths {
|
|
116
|
-
resolved_input_paths: Resolved_Input_Path
|
|
117
|
-
possible_paths_by_input_path: Map<Input_Path, Possible_Path
|
|
118
|
-
unmapped_input_paths: Input_Path
|
|
116
|
+
resolved_input_paths: Array<Resolved_Input_Path>;
|
|
117
|
+
possible_paths_by_input_path: Map<Input_Path, Array<Possible_Path>>;
|
|
118
|
+
unmapped_input_paths: Array<Input_Path>;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
/**
|
|
@@ -124,13 +124,13 @@ export interface Resolved_Input_Paths {
|
|
|
124
124
|
* If none is found for an input path, it's added to `unmapped_input_paths`.
|
|
125
125
|
*/
|
|
126
126
|
export const resolve_input_paths = (
|
|
127
|
-
input_paths: Input_Path
|
|
128
|
-
root_dirs: Path_Id
|
|
129
|
-
extensions: string
|
|
127
|
+
input_paths: Array<Input_Path>,
|
|
128
|
+
root_dirs: Array<Path_Id>,
|
|
129
|
+
extensions: Array<string>,
|
|
130
130
|
): Resolved_Input_Paths => {
|
|
131
|
-
const resolved_input_paths: Resolved_Input_Path
|
|
132
|
-
const possible_paths_by_input_path: Map<Input_Path, Possible_Path
|
|
133
|
-
const unmapped_input_paths: Input_Path
|
|
131
|
+
const resolved_input_paths: Array<Resolved_Input_Path> = [];
|
|
132
|
+
const possible_paths_by_input_path: Map<Input_Path, Array<Possible_Path>> = new Map();
|
|
133
|
+
const unmapped_input_paths: Array<Input_Path> = [];
|
|
134
134
|
for (const input_path of input_paths) {
|
|
135
135
|
let found_file: [Path_Info, Possible_Path] | null = null;
|
|
136
136
|
let found_dirs: Array<[Path_Info, Possible_Path]> | null = null;
|
|
@@ -177,9 +177,9 @@ export const resolve_input_paths = (
|
|
|
177
177
|
};
|
|
178
178
|
|
|
179
179
|
export interface Resolved_Input_Files {
|
|
180
|
-
resolved_input_files: Resolved_Input_File
|
|
181
|
-
resolved_input_files_by_root_dir: Map<Path_Id, Resolved_Input_File
|
|
182
|
-
input_directories_with_no_files: Input_Path
|
|
180
|
+
resolved_input_files: Array<Resolved_Input_File>;
|
|
181
|
+
resolved_input_files_by_root_dir: Map<Path_Id, Array<Resolved_Input_File>>;
|
|
182
|
+
input_directories_with_no_files: Array<Input_Path>;
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
/**
|
|
@@ -187,10 +187,10 @@ export interface Resolved_Input_Files {
|
|
|
187
187
|
* De-dupes source ids.
|
|
188
188
|
*/
|
|
189
189
|
export const resolve_input_files = (
|
|
190
|
-
resolved_input_paths: Resolved_Input_Path
|
|
191
|
-
search: (dir: string) => Resolved_Path
|
|
190
|
+
resolved_input_paths: Array<Resolved_Input_Path>,
|
|
191
|
+
search: (dir: string) => Array<Resolved_Path> = search_fs,
|
|
192
192
|
): Resolved_Input_Files => {
|
|
193
|
-
const resolved_input_files: Resolved_Input_File
|
|
193
|
+
const resolved_input_files: Array<Resolved_Input_File> = [];
|
|
194
194
|
// Add all input paths initially, and remove each when resolved to a file.
|
|
195
195
|
const existing_path_ids: Set<Path_Id> = new Set();
|
|
196
196
|
|
|
@@ -208,7 +208,7 @@ export const resolve_input_files = (
|
|
|
208
208
|
// Handle input paths that resolve to directories.
|
|
209
209
|
const files = search(id);
|
|
210
210
|
if (!files.length) continue;
|
|
211
|
-
const path_ids: Path_Id
|
|
211
|
+
const path_ids: Array<Path_Id> = [];
|
|
212
212
|
for (const {path, is_directory} of files) {
|
|
213
213
|
if (is_directory) continue;
|
|
214
214
|
const path_id = join(id, path);
|
|
@@ -219,7 +219,7 @@ export const resolve_input_files = (
|
|
|
219
219
|
handle_found(input_path, path_id);
|
|
220
220
|
}
|
|
221
221
|
if (!path_ids.length) continue;
|
|
222
|
-
const resolved_input_files_for_input_path: Resolved_Input_File
|
|
222
|
+
const resolved_input_files_for_input_path: Array<Resolved_Input_File> = [];
|
|
223
223
|
for (const path_id of path_ids) {
|
|
224
224
|
const resolved_input_file: Resolved_Input_File = {
|
|
225
225
|
id: path_id,
|
|
@@ -249,7 +249,7 @@ export const resolve_input_files = (
|
|
|
249
249
|
map.set(root_dir, [resolved_input_file]);
|
|
250
250
|
}
|
|
251
251
|
return map;
|
|
252
|
-
}, new Map<Path_Id, Resolved_Input_File
|
|
252
|
+
}, new Map<Path_Id, Array<Resolved_Input_File>>()),
|
|
253
253
|
input_directories_with_no_files: remaining.map((r) => r.input_path),
|
|
254
254
|
};
|
|
255
255
|
};
|
package/src/lib/invoke.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {attach_process_error_handlers} from '@ryanatkn/belt/process.js';
|
|
2
2
|
import {configure_log_colors} from '@ryanatkn/belt/log.js';
|
|
3
|
+
import {set_colors} from '@ryanatkn/belt/print.js';
|
|
3
4
|
import {styleText} from 'node:util';
|
|
4
5
|
|
|
5
6
|
import {invoke_task} from './invoke_task.js';
|
|
@@ -25,6 +26,7 @@ attach_process_error_handlers(
|
|
|
25
26
|
);
|
|
26
27
|
|
|
27
28
|
configure_log_colors(styleText);
|
|
29
|
+
set_colors(styleText);
|
|
28
30
|
|
|
29
31
|
await sveltekit_sync_if_obviously_needed();
|
|
30
32
|
|
package/src/lib/modules.ts
CHANGED
|
@@ -44,15 +44,15 @@ export const load_module = async <T_Module extends Record<string, any>>(
|
|
|
44
44
|
|
|
45
45
|
export interface Load_Modules_Failure<T_Module_Meta extends Module_Meta> {
|
|
46
46
|
type: 'load_module_failures';
|
|
47
|
-
load_module_failures: Load_Module_Failure
|
|
48
|
-
reasons: string
|
|
47
|
+
load_module_failures: Array<Load_Module_Failure>;
|
|
48
|
+
reasons: Array<string>;
|
|
49
49
|
// still return the modules and timings, deferring to the caller
|
|
50
|
-
modules: T_Module_Meta
|
|
50
|
+
modules: Array<T_Module_Meta>;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export type Load_Modules_Result<T_Module_Meta extends Module_Meta> = Result<
|
|
54
54
|
{
|
|
55
|
-
modules: T_Module_Meta
|
|
55
|
+
modules: Array<T_Module_Meta>;
|
|
56
56
|
},
|
|
57
57
|
Load_Modules_Failure<T_Module_Meta>
|
|
58
58
|
>;
|
|
@@ -62,15 +62,15 @@ export const load_modules = async <
|
|
|
62
62
|
T_Module extends Record<string, any>,
|
|
63
63
|
T_Module_Meta extends Module_Meta<T_Module>,
|
|
64
64
|
>(
|
|
65
|
-
resolved_input_files: Resolved_Input_File
|
|
65
|
+
resolved_input_files: Array<Resolved_Input_File>,
|
|
66
66
|
validate: (mod: any) => mod is T_Module,
|
|
67
67
|
map_module_meta: (resolved_input_file: Resolved_Input_File, mod: T_Module) => T_Module_Meta,
|
|
68
68
|
timings?: Timings,
|
|
69
69
|
): Promise<Load_Modules_Result<T_Module_Meta>> => {
|
|
70
70
|
const timing_to_load_modules = timings?.start('load modules');
|
|
71
|
-
const modules: T_Module_Meta
|
|
72
|
-
const load_module_failures: Load_Module_Failure
|
|
73
|
-
const reasons: string
|
|
71
|
+
const modules: Array<T_Module_Meta> = [];
|
|
72
|
+
const load_module_failures: Array<Load_Module_Failure> = [];
|
|
73
|
+
const reasons: Array<string> = [];
|
|
74
74
|
for (const resolved_input_file of resolved_input_files.values()) {
|
|
75
75
|
const {id, input_path} = resolved_input_file;
|
|
76
76
|
const result = await load_module(id, validate); // eslint-disable-line no-await-in-loop
|
package/src/lib/package.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {Src_Json} from './src_json.js';
|
|
|
5
5
|
|
|
6
6
|
export const package_json = {
|
|
7
7
|
name: '@ryanatkn/gro',
|
|
8
|
-
version: '0.
|
|
8
|
+
version: '0.149.0',
|
|
9
9
|
description: 'task runner and toolkit extending SvelteKit',
|
|
10
10
|
motto: 'generate, run, optimize',
|
|
11
11
|
glyph: '🌰',
|
|
@@ -30,7 +30,7 @@ export const package_json = {
|
|
|
30
30
|
deploy: 'gro deploy',
|
|
31
31
|
},
|
|
32
32
|
type: 'module',
|
|
33
|
-
engines: {node: '>=
|
|
33
|
+
engines: {node: '>=22.11'},
|
|
34
34
|
bin: {gro: 'dist/gro.js'},
|
|
35
35
|
keywords: [
|
|
36
36
|
'web',
|
|
@@ -44,38 +44,37 @@ export const package_json = {
|
|
|
44
44
|
'typescript',
|
|
45
45
|
],
|
|
46
46
|
dependencies: {
|
|
47
|
-
'@ryanatkn/belt': '^0.
|
|
48
|
-
chokidar: '^4.0.
|
|
49
|
-
dotenv: '^16.4.
|
|
50
|
-
'esm-env': '^1.
|
|
47
|
+
'@ryanatkn/belt': '^0.30.0',
|
|
48
|
+
chokidar: '^4.0.3',
|
|
49
|
+
dotenv: '^16.4.7',
|
|
50
|
+
'esm-env': '^1.2.2',
|
|
51
51
|
mri: '^1.2.0',
|
|
52
|
-
'oxc-parser': '^0.
|
|
53
|
-
prettier: '^3.
|
|
54
|
-
'prettier-plugin-svelte': '^3.
|
|
55
|
-
'ts-morph': '^
|
|
52
|
+
'oxc-parser': '^0.62.0',
|
|
53
|
+
prettier: '^3.5.3',
|
|
54
|
+
'prettier-plugin-svelte': '^3.3.3',
|
|
55
|
+
'ts-morph': '^25.0.1',
|
|
56
56
|
tslib: '^2.8.1',
|
|
57
|
-
zod: '^3.
|
|
57
|
+
zod: '^3.24.2',
|
|
58
58
|
},
|
|
59
|
-
peerDependencies: {esbuild: '^0.
|
|
59
|
+
peerDependencies: {esbuild: '^0.25', svelte: '^5'},
|
|
60
60
|
devDependencies: {
|
|
61
|
-
'@changesets/changelog-git': '^0.2.
|
|
62
|
-
'@changesets/types': '^6.
|
|
63
|
-
'@ryanatkn/eslint-config': '^0.
|
|
64
|
-
'@ryanatkn/fuz': '^0.
|
|
65
|
-
'@ryanatkn/moss': '^0.
|
|
66
|
-
'@sveltejs/adapter-static': '^3.0.
|
|
67
|
-
'@sveltejs/kit': '^2.
|
|
68
|
-
'@sveltejs/package': '^2.3.
|
|
69
|
-
'@sveltejs/vite-plugin-svelte': '^
|
|
70
|
-
'@types/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
eslint: '^
|
|
74
|
-
|
|
75
|
-
svelte: '^
|
|
76
|
-
|
|
77
|
-
typescript: '^
|
|
78
|
-
'typescript-eslint': '^8.12.2',
|
|
61
|
+
'@changesets/changelog-git': '^0.2.1',
|
|
62
|
+
'@changesets/types': '^6.1.0',
|
|
63
|
+
'@ryanatkn/eslint-config': '^0.8.0',
|
|
64
|
+
'@ryanatkn/fuz': '^0.135.0',
|
|
65
|
+
'@ryanatkn/moss': '^0.24.2',
|
|
66
|
+
'@sveltejs/adapter-static': '^3.0.8',
|
|
67
|
+
'@sveltejs/kit': '^2.20.4',
|
|
68
|
+
'@sveltejs/package': '^2.3.10',
|
|
69
|
+
'@sveltejs/vite-plugin-svelte': '^5.0.3',
|
|
70
|
+
'@types/node': '^22.14.0',
|
|
71
|
+
esbuild: '^0.25.2',
|
|
72
|
+
eslint: '^9.24.0',
|
|
73
|
+
'eslint-plugin-svelte': '^3.5.1',
|
|
74
|
+
svelte: '^5.25.6',
|
|
75
|
+
'svelte-check': '^4.1.5',
|
|
76
|
+
typescript: '^5.8.2',
|
|
77
|
+
'typescript-eslint': '^8.29.0',
|
|
79
78
|
uvu: '^0.5.6',
|
|
80
79
|
},
|
|
81
80
|
prettier: {
|
|
@@ -103,6 +102,10 @@ export const package_json = {
|
|
|
103
102
|
default: './dist/changeset.task.js',
|
|
104
103
|
},
|
|
105
104
|
'./check.task.js': {types: './dist/check.task.d.ts', default: './dist/check.task.js'},
|
|
105
|
+
'./child_process_logging.js': {
|
|
106
|
+
types: './dist/child_process_logging.d.ts',
|
|
107
|
+
default: './dist/child_process_logging.js',
|
|
108
|
+
},
|
|
106
109
|
'./clean_fs.js': {types: './dist/clean_fs.d.ts', default: './dist/clean_fs.js'},
|
|
107
110
|
'./clean.task.js': {types: './dist/clean.task.d.ts', default: './dist/clean.task.js'},
|
|
108
111
|
'./cli.js': {types: './dist/cli.d.ts', default: './dist/cli.js'},
|
|
@@ -266,7 +269,7 @@ export const package_json = {
|
|
|
266
269
|
|
|
267
270
|
export const src_json = {
|
|
268
271
|
name: '@ryanatkn/gro',
|
|
269
|
-
version: '0.
|
|
272
|
+
version: '0.149.0',
|
|
270
273
|
modules: {
|
|
271
274
|
'.': {
|
|
272
275
|
path: 'index.ts',
|
|
@@ -335,6 +338,13 @@ export const src_json = {
|
|
|
335
338
|
{name: 'task', kind: 'variable'},
|
|
336
339
|
],
|
|
337
340
|
},
|
|
341
|
+
'./child_process_logging.js': {
|
|
342
|
+
path: 'child_process_logging.ts',
|
|
343
|
+
declarations: [
|
|
344
|
+
{name: 'map_child_process_output', kind: 'function'},
|
|
345
|
+
{name: 'configure_colored_output_with_path_replacement', kind: 'function'},
|
|
346
|
+
],
|
|
347
|
+
},
|
|
338
348
|
'./clean_fs.js': {path: 'clean_fs.ts', declarations: [{name: 'clean_fs', kind: 'function'}]},
|
|
339
349
|
'./clean.task.js': {
|
|
340
350
|
path: 'clean.task.ts',
|
|
@@ -388,6 +398,7 @@ export const src_json = {
|
|
|
388
398
|
{name: 'TS_MATCHER', kind: 'variable'},
|
|
389
399
|
{name: 'JS_MATCHER', kind: 'variable'},
|
|
390
400
|
{name: 'JSON_MATCHER', kind: 'variable'},
|
|
401
|
+
{name: 'SVELTE_SCRIPT_MATCHER', kind: 'variable'},
|
|
391
402
|
{name: 'EVERYTHING_MATCHER', kind: 'variable'},
|
|
392
403
|
{name: 'JS_CLI_DEFAULT', kind: 'variable'},
|
|
393
404
|
{name: 'PM_CLI_DEFAULT', kind: 'variable'},
|
package/src/lib/package_json.ts
CHANGED
|
@@ -250,7 +250,7 @@ export const update_package_json = async (
|
|
|
250
250
|
|
|
251
251
|
const is_index = (path: string): boolean => path === 'index.ts' || path === 'index.js';
|
|
252
252
|
|
|
253
|
-
export const to_package_exports = (paths: string
|
|
253
|
+
export const to_package_exports = (paths: Array<string>): Package_Json_Exports => {
|
|
254
254
|
const sorted = paths
|
|
255
255
|
.slice()
|
|
256
256
|
.sort((a, b) => (is_index(a) ? -1 : is_index(b) ? 1 : a.localeCompare(b)));
|
|
@@ -360,7 +360,7 @@ export interface Package_Json_Dep {
|
|
|
360
360
|
version: string;
|
|
361
361
|
}
|
|
362
362
|
|
|
363
|
-
export const extract_deps = (package_json: Package_Json): Package_Json_Dep
|
|
363
|
+
export const extract_deps = (package_json: Package_Json): Array<Package_Json_Dep> => {
|
|
364
364
|
const deps_by_name: Map<string, Package_Json_Dep> = new Map();
|
|
365
365
|
// Earlier versions override later ones, so peer deps goes last.
|
|
366
366
|
const add_deps = (deps: Record<string, string> | undefined) => {
|
package/src/lib/parse_imports.ts
CHANGED
|
@@ -1,40 +1,177 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {parseSync, type ImportDeclaration} from 'oxc-parser';
|
|
2
2
|
import type {Flavored} from '@ryanatkn/belt/types.js';
|
|
3
|
+
import {Unreachable_Error} from '@ryanatkn/belt/error.js';
|
|
3
4
|
|
|
4
5
|
import type {Path_Id} from './path.js';
|
|
5
6
|
import {SVELTE_MATCHER} from './svelte_helpers.js';
|
|
6
|
-
import {JS_MATCHER, TS_MATCHER} from './constants.js';
|
|
7
|
+
import {JS_MATCHER, TS_MATCHER, SVELTE_SCRIPT_MATCHER} from './constants.js';
|
|
7
8
|
|
|
8
9
|
export type Import_Specifier = Flavored<string, 'Import_Specifier'>;
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
// TODO this is probably way more complicated that it should be, maybe report the issues upstream unless I made a mistake here
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Extracts the string value from a module request, handling different quote styles.
|
|
15
|
+
* Returns null if the value is not a valid string literal.
|
|
16
|
+
*/
|
|
17
|
+
const extract_string_literal = (content: string, start: number, end: number): string | null => {
|
|
18
|
+
const value = content.substring(start, end);
|
|
19
|
+
|
|
20
|
+
// Check if it's a string literal (starts and ends with quotes)
|
|
21
|
+
if (
|
|
22
|
+
(value.startsWith("'") && value.endsWith("'")) ||
|
|
23
|
+
(value.startsWith('"') && value.endsWith('"')) ||
|
|
24
|
+
(value.startsWith('`') && value.endsWith('`'))
|
|
25
|
+
) {
|
|
26
|
+
// Remove the quotes
|
|
27
|
+
return value.slice(1, -1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Not a valid string literal
|
|
31
|
+
return null;
|
|
32
|
+
};
|
|
11
33
|
|
|
12
34
|
export const parse_imports = (
|
|
13
35
|
id: Path_Id,
|
|
14
36
|
contents: string,
|
|
15
37
|
ignore_types = true,
|
|
16
|
-
): Import_Specifier
|
|
17
|
-
const specifiers: string
|
|
18
|
-
|
|
38
|
+
): Array<Import_Specifier> => {
|
|
39
|
+
const specifiers: Array<string> = [];
|
|
19
40
|
const is_svelte = SVELTE_MATCHER.test(id);
|
|
20
41
|
|
|
21
42
|
const parse_from = (s: string): void => {
|
|
22
|
-
const parsed =
|
|
23
|
-
|
|
43
|
+
const parsed = parseSync(is_svelte ? id + '.ts' : id, s, {});
|
|
44
|
+
|
|
45
|
+
// Process static imports
|
|
46
|
+
for (const static_import of parsed.module.staticImports) {
|
|
47
|
+
// Get the module source node
|
|
48
|
+
const import_decl = parsed.program.body.find(
|
|
49
|
+
(node) => node.type === 'ImportDeclaration' && node.start === static_import.start,
|
|
50
|
+
) as ImportDeclaration | undefined;
|
|
51
|
+
|
|
52
|
+
if (!import_decl?.source) continue;
|
|
53
|
+
|
|
54
|
+
// Extract the module request string value
|
|
55
|
+
const value = extract_string_literal(s, import_decl.source.start, import_decl.source.end);
|
|
56
|
+
|
|
57
|
+
if (!value) continue;
|
|
58
|
+
|
|
59
|
+
// Skip type-only imports if ignore_types is true
|
|
24
60
|
if (ignore_types) {
|
|
25
|
-
|
|
26
|
-
if (
|
|
61
|
+
// Handle import type {...} (type-only imports)
|
|
62
|
+
if (import_decl.importKind === 'type') {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Handle inline type imports ({type foo})
|
|
67
|
+
if (static_import.entries.length > 0) {
|
|
68
|
+
// If all imports are type imports, skip this import
|
|
69
|
+
const has_non_type_specifier = static_import.entries.some((entry) => !entry.isType);
|
|
70
|
+
if (!has_non_type_specifier) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
specifiers.push(value);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Process dynamic imports
|
|
80
|
+
for (const dynamic_import of parsed.module.dynamicImports) {
|
|
81
|
+
// Find the corresponding AST node
|
|
82
|
+
let found = false;
|
|
83
|
+
for (const node of parsed.program.body) {
|
|
84
|
+
if (
|
|
85
|
+
node.type === 'ExpressionStatement' &&
|
|
86
|
+
node.expression.type === 'AwaitExpression' &&
|
|
87
|
+
node.expression.argument.type === 'ImportExpression'
|
|
88
|
+
) {
|
|
89
|
+
const import_expr = node.expression.argument;
|
|
90
|
+
if (import_expr.start === dynamic_import.start) {
|
|
91
|
+
// Only process string literals (not expressions or variables)
|
|
92
|
+
if (import_expr.source.type === 'Literal') {
|
|
93
|
+
const value = String(import_expr.source.value);
|
|
94
|
+
if (value) {
|
|
95
|
+
specifiers.push(value);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
found = true;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// If we didn't find a match through AST, fall back to the original approach
|
|
105
|
+
// but only for simple string literals
|
|
106
|
+
if (!found) {
|
|
107
|
+
const value = extract_string_literal(
|
|
108
|
+
s,
|
|
109
|
+
dynamic_import.moduleRequest.start,
|
|
110
|
+
dynamic_import.moduleRequest.end,
|
|
111
|
+
);
|
|
112
|
+
if (value) {
|
|
113
|
+
specifiers.push(value);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Process re-exports
|
|
119
|
+
for (const node of parsed.program.body) {
|
|
120
|
+
if (node.type === 'ExportNamedDeclaration' && node.source) {
|
|
121
|
+
// Skip type-only exports if ignore_types is true
|
|
122
|
+
if (ignore_types && node.exportKind === 'type') {
|
|
27
123
|
continue;
|
|
28
124
|
}
|
|
125
|
+
|
|
126
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
127
|
+
if (node.source.type === 'Literal') {
|
|
128
|
+
const value = String(node.source.value);
|
|
129
|
+
if (value) {
|
|
130
|
+
specifiers.push(value);
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
throw new Unreachable_Error(node.source.type);
|
|
134
|
+
}
|
|
29
135
|
}
|
|
30
|
-
if (p.n) specifiers.push(p.n);
|
|
31
136
|
}
|
|
32
137
|
};
|
|
33
138
|
|
|
34
139
|
if (is_svelte) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
140
|
+
// Reset the regex state between calls
|
|
141
|
+
SVELTE_SCRIPT_MATCHER.lastIndex = 0;
|
|
142
|
+
|
|
143
|
+
// Capture script tags at the top level (not nested in HTML)
|
|
144
|
+
let last_index = 0;
|
|
145
|
+
const script_blocks: Array<{content: string; start: number; end: number}> = [];
|
|
146
|
+
|
|
147
|
+
// First collect all script blocks
|
|
148
|
+
let match;
|
|
149
|
+
while ((match = SVELTE_SCRIPT_MATCHER.exec(contents)) !== null) {
|
|
150
|
+
// Save position of the script tag
|
|
151
|
+
const start = match.index;
|
|
152
|
+
const end = SVELTE_SCRIPT_MATCHER.lastIndex;
|
|
153
|
+
|
|
154
|
+
// Only process top-level script tags (skip nested ones)
|
|
155
|
+
// A nested script would be inside another HTML tag between lastIndex and start
|
|
156
|
+
const text_between = contents.substring(last_index, start);
|
|
157
|
+
const contains_opening_tag = /<[a-z][^>]*>/i.test(text_between);
|
|
158
|
+
const contains_closing_tag = /<\/[a-z][^>]*>/i.test(text_between);
|
|
159
|
+
|
|
160
|
+
// If we're not nested (no HTML tag nesting), process this script
|
|
161
|
+
if (!(contains_opening_tag && !contains_closing_tag)) {
|
|
162
|
+
script_blocks.push({
|
|
163
|
+
content: match[1],
|
|
164
|
+
start,
|
|
165
|
+
end,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
last_index = end;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Process all the collected script blocks
|
|
173
|
+
for (const block of script_blocks) {
|
|
174
|
+
parse_from(block.content);
|
|
38
175
|
}
|
|
39
176
|
} else if (TS_MATCHER.test(id) || JS_MATCHER.test(id)) {
|
|
40
177
|
parse_from(contents);
|
package/src/lib/plugin.ts
CHANGED
|
@@ -24,7 +24,7 @@ export class Plugins<T_Plugin_Context extends Plugin_Context> {
|
|
|
24
24
|
/* prefer `Plugins.create` to the constructor */
|
|
25
25
|
constructor(
|
|
26
26
|
private ctx: T_Plugin_Context,
|
|
27
|
-
private instances: Plugin
|
|
27
|
+
private instances: Array<Plugin>,
|
|
28
28
|
) {}
|
|
29
29
|
|
|
30
30
|
static async create<T_Plugin_Context extends Plugin_Context>(
|
|
@@ -32,7 +32,7 @@ export class Plugins<T_Plugin_Context extends Plugin_Context> {
|
|
|
32
32
|
): Promise<Plugins<T_Plugin_Context>> {
|
|
33
33
|
const {timings} = ctx;
|
|
34
34
|
const timing_to_create = timings.start('plugins.create');
|
|
35
|
-
const instances: Plugin
|
|
35
|
+
const instances: Array<Plugin> = await ctx.config.plugins(ctx);
|
|
36
36
|
const plugins = new Plugins(ctx, instances);
|
|
37
37
|
timing_to_create();
|
|
38
38
|
return plugins;
|
|
@@ -91,10 +91,10 @@ export class Plugins<T_Plugin_Context extends Plugin_Context> {
|
|
|
91
91
|
* @returns `plugins` with `new_plugin` at the index of the plugin with `name`
|
|
92
92
|
*/
|
|
93
93
|
export const replace_plugin = (
|
|
94
|
-
plugins: Plugin
|
|
94
|
+
plugins: Array<Plugin>,
|
|
95
95
|
new_plugin: Plugin,
|
|
96
96
|
name = new_plugin.name,
|
|
97
|
-
): Plugin
|
|
97
|
+
): Array<Plugin> => {
|
|
98
98
|
const index = plugins.findIndex((p) => p.name === name);
|
|
99
99
|
if (index === -1) throw Error('Failed to find plugin to replace: ' + name);
|
|
100
100
|
const replaced = plugins.slice();
|
package/src/lib/run_gen.ts
CHANGED
|
@@ -19,7 +19,7 @@ import {default_sveltekit_config} from './sveltekit_config.js';
|
|
|
19
19
|
export const GEN_NO_PROD_MESSAGE = 'gen runs only during development';
|
|
20
20
|
|
|
21
21
|
export const run_gen = async (
|
|
22
|
-
gen_modules: Genfile_Module_Meta
|
|
22
|
+
gen_modules: Array<Genfile_Module_Meta>,
|
|
23
23
|
config: Gro_Config,
|
|
24
24
|
log: Logger,
|
|
25
25
|
timings: Timings,
|
package/src/lib/search_fs.ts
CHANGED
|
@@ -10,11 +10,11 @@ export interface Search_Fs_Options {
|
|
|
10
10
|
/**
|
|
11
11
|
* One or more filter functions, any of which can short-circuit the search by returning `false`.
|
|
12
12
|
*/
|
|
13
|
-
filter?: Path_Filter | Path_Filter
|
|
13
|
+
filter?: Path_Filter | Array<Path_Filter>;
|
|
14
14
|
/**
|
|
15
15
|
* One or more file filter functions. Every filter must pass for a file to be included.
|
|
16
16
|
*/
|
|
17
|
-
file_filter?: File_Filter | File_Filter
|
|
17
|
+
file_filter?: File_Filter | Array<File_Filter>;
|
|
18
18
|
/**
|
|
19
19
|
* Pass `null` or `false` to speed things up at the cost of volatile ordering.
|
|
20
20
|
*/
|
|
@@ -32,7 +32,7 @@ export interface Search_Fs_Options {
|
|
|
32
32
|
export const search_fs = (
|
|
33
33
|
dir: string,
|
|
34
34
|
options: Search_Fs_Options = EMPTY_OBJECT,
|
|
35
|
-
): Resolved_Path
|
|
35
|
+
): Array<Resolved_Path> => {
|
|
36
36
|
const {
|
|
37
37
|
filter,
|
|
38
38
|
file_filter,
|
|
@@ -52,7 +52,7 @@ export const search_fs = (
|
|
|
52
52
|
|
|
53
53
|
if (!existsSync(final_dir)) return [];
|
|
54
54
|
|
|
55
|
-
const paths: Resolved_Path
|
|
55
|
+
const paths: Array<Resolved_Path> = [];
|
|
56
56
|
crawl(final_dir, paths, filters, file_filters, include_directories, null);
|
|
57
57
|
|
|
58
58
|
return sort ? paths.sort(typeof sort === 'boolean' ? default_sort : sort) : paths;
|
|
@@ -62,12 +62,12 @@ const default_sort = (a: Resolved_Path, b: Resolved_Path): number => a.path.loca
|
|
|
62
62
|
|
|
63
63
|
const crawl = (
|
|
64
64
|
dir: string,
|
|
65
|
-
paths: Resolved_Path
|
|
66
|
-
filters: Path_Filter
|
|
67
|
-
file_filter: File_Filter
|
|
65
|
+
paths: Array<Resolved_Path>,
|
|
66
|
+
filters: Array<Path_Filter> | undefined,
|
|
67
|
+
file_filter: Array<File_Filter> | undefined,
|
|
68
68
|
include_directories: boolean,
|
|
69
69
|
base_dir: string | null,
|
|
70
|
-
): Resolved_Path
|
|
70
|
+
): Array<Resolved_Path> => {
|
|
71
71
|
// This sync version is significantly faster than using the `fs/promises` version -
|
|
72
72
|
// it doesn't parallelize but that's not the common case in Gro.
|
|
73
73
|
const dirents = readdirSync(dir, {withFileTypes: true});
|
package/src/lib/src_json.ts
CHANGED
|
@@ -58,7 +58,7 @@ export interface Parsed_Sveltekit_Config {
|
|
|
58
58
|
public_prefix: string | undefined;
|
|
59
59
|
svelte_compile_options: CompileOptions;
|
|
60
60
|
svelte_compile_module_options: ModuleCompileOptions;
|
|
61
|
-
svelte_preprocessors: PreprocessorGroup | PreprocessorGroup
|
|
61
|
+
svelte_preprocessors: PreprocessorGroup | Array<PreprocessorGroup> | undefined;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
// TODO currently incomplete and hack - maybe rethink
|
|
@@ -12,7 +12,7 @@ export const render_env_shim_module = (
|
|
|
12
12
|
public_prefix = 'PUBLIC_',
|
|
13
13
|
private_prefix = '',
|
|
14
14
|
env_dir?: string,
|
|
15
|
-
env_files?: string
|
|
15
|
+
env_files?: Array<string>,
|
|
16
16
|
ambient_env?: Record<string, string | undefined>,
|
|
17
17
|
): string => {
|
|
18
18
|
const env = load_env(
|