@ryanatkn/gro 0.116.2 → 0.118.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -15
- package/dist/changeset.task.js +1 -1
- package/dist/clean_fs.js +2 -1
- package/dist/cli.js +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.js +11 -3
- package/dist/deploy.task.js +5 -4
- package/dist/docs/config.md +25 -0
- package/dist/docs/gen.md +16 -0
- package/dist/docs/task.md +38 -32
- package/dist/docs/tasks.gen.md.js +3 -4
- package/dist/esbuild_plugin_external_worker.js +1 -2
- package/dist/esbuild_plugin_svelte.js +1 -2
- package/dist/esbuild_plugin_sveltekit_shim_alias.js +1 -2
- package/dist/format_directory.js +3 -2
- package/dist/gen.d.ts +5 -0
- package/dist/gen.task.js +7 -8
- package/dist/gen_module.d.ts +2 -1
- package/dist/gen_module.js +1 -1
- package/dist/gro.config.default.js +3 -2
- package/dist/gro_helpers.js +18 -17
- package/dist/gro_plugin_server.js +9 -5
- package/dist/gro_plugin_sveltekit_app.d.ts +0 -1
- package/dist/gro_plugin_sveltekit_app.js +2 -4
- package/dist/gro_plugin_sveltekit_library.d.ts +0 -2
- package/dist/gro_plugin_sveltekit_library.js +1 -7
- package/dist/input_path.d.ts +27 -28
- package/dist/input_path.js +62 -66
- package/dist/input_path.test.js +26 -48
- package/dist/invoke_task.d.ts +1 -1
- package/dist/invoke_task.js +78 -88
- package/dist/lint.task.js +1 -1
- package/dist/loader.js +11 -4
- package/dist/module.d.ts +1 -1
- package/dist/module.js +2 -2
- package/dist/modules.d.ts +13 -9
- package/dist/modules.js +5 -13
- package/dist/modules.test.js +2 -2
- package/dist/package.d.ts +47 -6
- package/dist/package.gen.js +3 -3
- package/dist/package.js +89 -60
- package/dist/package_json.d.ts +5 -0
- package/dist/package_json.js +9 -4
- package/dist/package_meta.d.ts +1 -2
- package/dist/path_constants.d.ts +20 -0
- package/dist/path_constants.js +27 -0
- package/dist/paths.d.ts +11 -34
- package/dist/paths.js +28 -67
- package/dist/publish.task.js +3 -3
- package/dist/register.d.ts +1 -0
- package/dist/register.js +2 -0
- package/dist/release.task.js +1 -2
- package/dist/resolve_node_specifier.js +2 -1
- package/dist/run_gen.d.ts +2 -1
- package/dist/run_gen.js +2 -2
- package/dist/run_gen.test.js +3 -2
- package/dist/run_task.js +2 -2
- package/dist/sveltekit_config.d.ts +1 -1
- package/dist/sveltekit_config.js +9 -5
- package/dist/sveltekit_config_global.d.ts +4 -0
- package/dist/sveltekit_config_global.js +5 -0
- package/dist/sveltekit_helpers.d.ts +4 -0
- package/dist/sveltekit_helpers.js +12 -0
- package/dist/sync.task.js +4 -1
- package/dist/task.d.ts +1 -1
- package/dist/task.js +11 -6
- package/dist/task.test.js +9 -13
- package/dist/task_logging.d.ts +8 -0
- package/dist/{print_task.js → task_logging.js} +30 -16
- package/dist/task_module.d.ts +4 -3
- package/dist/task_module.js +7 -8
- package/dist/task_module.test.js +4 -7
- package/package.json +36 -20
- package/dist/print_task.d.ts +0 -4
package/dist/invoke_task.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { cyan, red, gray } from 'kleur/colors';
|
|
2
|
-
import {
|
|
2
|
+
import { System_Logger, print_log_label } from '@ryanatkn/belt/log.js';
|
|
3
3
|
import { create_stopwatch, Timings } from '@ryanatkn/belt/timings.js';
|
|
4
4
|
import { print_ms, print_timings } from '@ryanatkn/belt/print.js';
|
|
5
5
|
import { to_forwarded_args } from './args.js';
|
|
6
6
|
import { run_task } from './run_task.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { find_modules, load_modules } from './modules.js';
|
|
7
|
+
import { to_input_path, Raw_Input_Path } from './input_path.js';
|
|
8
|
+
import { is_gro_id, IS_THIS_GRO, print_path, print_path_or_gro_path } from './paths.js';
|
|
9
|
+
import { load_modules } from './modules.js';
|
|
11
10
|
import { find_task_modules, load_task_module } from './task_module.js';
|
|
12
11
|
import { load_gro_package_json } from './package_json.js';
|
|
13
|
-
import {
|
|
14
|
-
import { search_fs } from './search_fs.js';
|
|
12
|
+
import { log_tasks, log_error_reasons, log_gro_package_tasks } from './task_logging.js';
|
|
15
13
|
/**
|
|
16
14
|
* Invokes Gro tasks by name using the filesystem as the source.
|
|
17
15
|
*
|
|
@@ -33,108 +31,100 @@ export const invoke_task = async (task_name, args, config, timings = new Timings
|
|
|
33
31
|
const log = new System_Logger(print_log_label(task_name || 'gro'));
|
|
34
32
|
log.info('invoking', task_name ? cyan(task_name) : 'gro');
|
|
35
33
|
const total_timing = create_stopwatch();
|
|
34
|
+
const finish = () => {
|
|
35
|
+
print_timings(timings, log);
|
|
36
|
+
log.info(`🕒 ${print_ms(total_timing())}`);
|
|
37
|
+
};
|
|
36
38
|
// Check if the caller just wants to see the version.
|
|
37
39
|
if (!task_name && (args.version || args.v)) {
|
|
38
40
|
const gro_package_json = await load_gro_package_json();
|
|
39
41
|
log.info(`${gray('v')}${cyan(gro_package_json.version)}`);
|
|
40
|
-
|
|
42
|
+
finish();
|
|
41
43
|
return;
|
|
42
44
|
}
|
|
43
45
|
// Resolve the input path for the provided task name.
|
|
44
|
-
const input_path =
|
|
46
|
+
const input_path = to_input_path(task_name);
|
|
47
|
+
const { task_root_paths } = config;
|
|
45
48
|
// Find the task or directory specified by the `input_path`.
|
|
46
49
|
// Fall back to searching the Gro directory as well.
|
|
47
|
-
const find_modules_result = await find_task_modules([input_path],
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (load_modules_result.ok) {
|
|
58
|
-
// We found a task module. Run it!
|
|
59
|
-
// `path_data` is not a directory, so there's a single task module here.
|
|
60
|
-
const task = load_modules_result.modules[0];
|
|
61
|
-
log.info(`→ ${cyan(task.name)} ${(task.mod.task.summary && gray(task.mod.task.summary)) || ''}`);
|
|
62
|
-
const timing_to_run_task = timings.start('run task ' + task_name);
|
|
63
|
-
const result = await run_task(task, { ...args, ...to_forwarded_args(`gro ${task.name}`) }, invoke_task, config, timings);
|
|
64
|
-
timing_to_run_task();
|
|
65
|
-
if (result.ok) {
|
|
66
|
-
log.info(`✓ ${cyan(task.name)}`);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
log.info(`${red('🞩')} ${cyan(task.name)}`);
|
|
70
|
-
log_error_reasons(log, [result.reason]);
|
|
71
|
-
throw result.error;
|
|
72
|
-
}
|
|
50
|
+
const find_modules_result = await find_task_modules([input_path], task_root_paths);
|
|
51
|
+
if (!find_modules_result.ok) {
|
|
52
|
+
if (find_modules_result.type === 'input_directories_with_no_files') {
|
|
53
|
+
// The input path matched a directory, but it contains no matching files.
|
|
54
|
+
if (IS_THIS_GRO ||
|
|
55
|
+
// this is null safe because of the failure type
|
|
56
|
+
is_gro_id(find_modules_result.source_id_path_data_by_input_path.get(input_path).id)) {
|
|
57
|
+
// If the directory is inside Gro, just log the errors.
|
|
58
|
+
log_error_reasons(log, find_modules_result.reasons);
|
|
59
|
+
process.exit(1);
|
|
73
60
|
}
|
|
74
61
|
else {
|
|
75
|
-
|
|
76
|
-
|
|
62
|
+
// If there's a matching directory in the current working directory,
|
|
63
|
+
// but it has no matching files, we still want to search Gro's directory.
|
|
64
|
+
const gro_dir_find_modules_result = await log_gro_package_tasks(input_path, task_root_paths, log);
|
|
65
|
+
if (!gro_dir_find_modules_result.ok) {
|
|
66
|
+
// Log the original errors, not the Gro-specific ones.
|
|
67
|
+
log_error_reasons(log, find_modules_result.reasons);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
finish();
|
|
71
|
+
return;
|
|
77
72
|
}
|
|
78
73
|
}
|
|
79
74
|
else {
|
|
80
|
-
//
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
75
|
+
// Some unknown find modules result failure happened, so log it out.
|
|
76
|
+
// (currently, just "unmapped_input_paths")
|
|
77
|
+
log_error_reasons(log, find_modules_result.reasons);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Found a match either in the current working directory or Gro's directory.
|
|
82
|
+
const path_data = find_modules_result.source_id_path_data_by_input_path.get(input_path); // this is null safe because result is ok
|
|
83
|
+
if (!path_data.isDirectory) {
|
|
84
|
+
// The input path matches a file, so load and run it.
|
|
85
|
+
// Try to load the task module.
|
|
86
|
+
const load_modules_result = await load_modules(find_modules_result.source_ids_by_input_path, (id) => load_task_module(id, task_root_paths));
|
|
87
|
+
if (load_modules_result.ok) {
|
|
88
|
+
// We found a task module. Run it!
|
|
89
|
+
// `path_data` is not a directory, so there's a single task module here.
|
|
90
|
+
const task = load_modules_result.modules[0];
|
|
91
|
+
log.info(`→ ${cyan(task.name)} ${(task.mod.task.summary && gray(task.mod.task.summary)) || ''}`);
|
|
92
|
+
const timing_to_run_task = timings.start('run task ' + task_name);
|
|
93
|
+
const result = await run_task(task, { ...args, ...to_forwarded_args(`gro ${task.name}`) }, invoke_task, config, timings);
|
|
94
|
+
timing_to_run_task();
|
|
95
|
+
if (result.ok) {
|
|
96
|
+
log.info(`✓ ${cyan(task.name)}`);
|
|
89
97
|
}
|
|
90
98
|
else {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
// and log everything out.
|
|
95
|
-
// Ignore any errors - the directory may not exist or have any files!
|
|
96
|
-
const gro_dir_find_modules_result = await to_gro_dir_find_modules_result(input_path, log);
|
|
97
|
-
// Then log the current working directory matches.
|
|
98
|
-
await log_available_tasks(log, print_path(path_data.id), find_modules_result.source_ids_by_input_path, !gro_dir_find_modules_result.ok);
|
|
99
|
+
log.info(`${red('🞩')} ${cyan(task.name)}`);
|
|
100
|
+
log_error_reasons(log, [result.reason]);
|
|
101
|
+
throw result.error;
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
|
-
}
|
|
102
|
-
else if (find_modules_result.type === 'input_directories_with_no_files') {
|
|
103
|
-
// The input path matched a directory, but it contains no matching files.
|
|
104
|
-
if (is_this_project_gro ||
|
|
105
|
-
// this is null safe because of the failure type
|
|
106
|
-
is_gro_id(find_modules_result.source_id_path_data_by_input_path.get(input_path).id)) {
|
|
107
|
-
// If the directory is inside Gro, just log the errors.
|
|
108
|
-
log_error_reasons(log, find_modules_result.reasons);
|
|
109
|
-
process.exit(1);
|
|
110
|
-
}
|
|
111
104
|
else {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const gro_dir_find_modules_result = await to_gro_dir_find_modules_result(input_path, log);
|
|
115
|
-
if (!gro_dir_find_modules_result.ok) {
|
|
116
|
-
// Log the original errors, not the Gro-specific ones.
|
|
117
|
-
log_error_reasons(log, find_modules_result.reasons);
|
|
118
|
-
process.exit(1);
|
|
119
|
-
}
|
|
105
|
+
log_error_reasons(log, load_modules_result.reasons);
|
|
106
|
+
process.exit(1);
|
|
120
107
|
}
|
|
121
108
|
}
|
|
122
109
|
else {
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
110
|
+
// The input path matches a directory. Log the tasks but don't run them.
|
|
111
|
+
if (IS_THIS_GRO) {
|
|
112
|
+
// Is the Gro directory the same as the cwd? Log the matching files.
|
|
113
|
+
await log_tasks(log, print_path(path_data.id), find_modules_result.source_ids_by_input_path, task_root_paths);
|
|
114
|
+
}
|
|
115
|
+
else if (is_gro_id(path_data.id)) {
|
|
116
|
+
// Does the Gro directory contain the matching files? Log them.
|
|
117
|
+
await log_tasks(log, print_path_or_gro_path(path_data.id), find_modules_result.source_ids_by_input_path, task_root_paths);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
// The Gro directory is not the same as the cwd and it doesn't contain the matching files.
|
|
121
|
+
// Find all of the possible matches in both the current project and the Gro directory,
|
|
122
|
+
// and log everything out.
|
|
123
|
+
// Ignore any errors - the directory may not exist or have any files!
|
|
124
|
+
const gro_dir_find_modules_result = await log_gro_package_tasks(input_path, task_root_paths, log);
|
|
125
|
+
// Then log the current working directory matches.
|
|
126
|
+
await log_tasks(log, print_path(path_data.id), find_modules_result.source_ids_by_input_path, task_root_paths, !gro_dir_find_modules_result.ok);
|
|
127
|
+
}
|
|
138
128
|
}
|
|
139
|
-
|
|
129
|
+
finish();
|
|
140
130
|
};
|
package/dist/lint.task.js
CHANGED
|
@@ -2,7 +2,7 @@ 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 { print_command_args, serialize_args, to_forwarded_args } from './args.js';
|
|
5
|
-
import { SOURCE_DIRNAME } from './
|
|
5
|
+
import { SOURCE_DIRNAME } from './path_constants.js';
|
|
6
6
|
import { find_cli, spawn_cli } from './cli.js';
|
|
7
7
|
export const Args = z
|
|
8
8
|
.object({
|
package/dist/loader.js
CHANGED
|
@@ -5,21 +5,28 @@ import { dirname, join } from 'node:path';
|
|
|
5
5
|
import { escape_regexp } from '@ryanatkn/belt/regexp.js';
|
|
6
6
|
import { render_env_shim_module } from './sveltekit_shim_env.js';
|
|
7
7
|
import { render_sveltekit_shim_app_environment, render_sveltekit_shim_app_paths, sveltekit_shim_app_environment_matcher, sveltekit_shim_app_paths_matcher, sveltekit_shim_app_specifiers, } from './sveltekit_shim_app.js';
|
|
8
|
-
import {
|
|
8
|
+
import { sveltekit_config_global } from './sveltekit_config_global.js';
|
|
9
9
|
import { SVELTE_MATCHER, SVELTE_RUNES_MATCHER } from './svelte_helpers.js';
|
|
10
|
-
import { paths
|
|
10
|
+
import { paths } from './paths.js';
|
|
11
|
+
import { NODE_MODULES_DIRNAME } from './path_constants.js';
|
|
11
12
|
import { to_define_import_meta_env, ts_transform_options } from './esbuild_helpers.js';
|
|
12
13
|
import { resolve_specifier } from './resolve_specifier.js';
|
|
13
14
|
import { resolve_node_specifier } from './resolve_node_specifier.js';
|
|
14
15
|
/*
|
|
15
16
|
|
|
17
|
+
Usage via `$lib/register.ts`:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
node --import @ryanatkn/gro/register.js foo.ts
|
|
21
|
+
```
|
|
22
|
+
|
|
16
23
|
Usage via `$lib/run.task.ts`:
|
|
17
24
|
|
|
18
25
|
```bash
|
|
19
26
|
gro run foo.ts
|
|
20
27
|
```
|
|
21
28
|
|
|
22
|
-
Direct usage (see also `$lib/gro.ts`):
|
|
29
|
+
Direct usage without register (see also `$lib/gro.ts`):
|
|
23
30
|
|
|
24
31
|
```bash
|
|
25
32
|
node --import 'data:text/javascript,import {register} from "node:module"; import {pathToFileURL} from "node:url"; register("@ryanatkn/gro/loader.js", pathToFileURL("./"));' --enable-source-maps' foo.ts
|
|
@@ -34,7 +41,7 @@ TODO how to improve that gnarly import line? was originally designed for the now
|
|
|
34
41
|
// dev is always true in the loader
|
|
35
42
|
const dev = true;
|
|
36
43
|
const dir = paths.root;
|
|
37
|
-
const { alias, base_url, assets_url, env_dir, private_prefix, public_prefix, svelte_compile_options, svelte_compile_module_options, svelte_preprocessors, } =
|
|
44
|
+
const { alias, base_url, assets_url, env_dir, private_prefix, public_prefix, svelte_compile_options, svelte_compile_module_options, svelte_preprocessors, } = sveltekit_config_global;
|
|
38
45
|
const final_ts_transform_options = {
|
|
39
46
|
...ts_transform_options,
|
|
40
47
|
define: to_define_import_meta_env(dev, base_url),
|
package/dist/module.d.ts
CHANGED
package/dist/module.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import { SOURCE_DIR, SOURCE_DIRNAME
|
|
1
|
+
import { LIB_DIRNAME } from './paths.js';
|
|
2
|
+
import { SOURCE_DIR, SOURCE_DIRNAME } from './path_constants.js';
|
|
3
3
|
export const MODULE_PATH_SRC_PREFIX = SOURCE_DIR;
|
|
4
4
|
export const MODULE_PATH_LIB_PREFIX = `$${LIB_DIRNAME}/`;
|
|
5
5
|
const INTERNAL_MODULE_MATCHER = new RegExp(`^(\\.?\\.?|${SOURCE_DIRNAME}|\\$${LIB_DIRNAME})\\/`, 'u');
|
package/dist/modules.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Result } from '@ryanatkn/belt/result.js';
|
|
2
|
+
import { Input_Path } from './input_path.js';
|
|
2
3
|
import type { Path_Data } from './path.js';
|
|
3
4
|
import { type Source_Id } from './paths.js';
|
|
4
5
|
export interface Module_Meta<T_Module extends Record<string, any> = Record<string, any>> {
|
|
@@ -22,19 +23,19 @@ export type Load_Module_Failure = {
|
|
|
22
23
|
};
|
|
23
24
|
export declare const load_module: <T extends Record<string, any>>(id: string, validate?: (mod: Record<string, any>) => mod is T) => Promise<Load_Module_Result<Module_Meta<T>>>;
|
|
24
25
|
export type Find_Modules_Result = Result<{
|
|
25
|
-
source_ids_by_input_path: Map<
|
|
26
|
-
source_id_path_data_by_input_path: Map<
|
|
26
|
+
source_ids_by_input_path: Map<Input_Path, Source_Id[]>;
|
|
27
|
+
source_id_path_data_by_input_path: Map<Input_Path, Path_Data>;
|
|
27
28
|
}, Find_Modules_Failure>;
|
|
28
29
|
export type Find_Modules_Failure = {
|
|
29
30
|
type: 'unmapped_input_paths';
|
|
30
|
-
source_id_path_data_by_input_path: Map<
|
|
31
|
-
unmapped_input_paths:
|
|
31
|
+
source_id_path_data_by_input_path: Map<Input_Path, Path_Data>;
|
|
32
|
+
unmapped_input_paths: Input_Path[];
|
|
32
33
|
reasons: string[];
|
|
33
34
|
} | {
|
|
34
35
|
type: 'input_directories_with_no_files';
|
|
35
|
-
source_ids_by_input_path: Map<
|
|
36
|
-
source_id_path_data_by_input_path: Map<
|
|
37
|
-
input_directories_with_no_files:
|
|
36
|
+
source_ids_by_input_path: Map<Input_Path, Source_Id[]>;
|
|
37
|
+
source_id_path_data_by_input_path: Map<Input_Path, Path_Data>;
|
|
38
|
+
input_directories_with_no_files: Input_Path[];
|
|
38
39
|
reasons: string[];
|
|
39
40
|
};
|
|
40
41
|
export type Load_Modules_Result<T_Module_Meta extends Module_Meta> = Result<{
|
|
@@ -45,5 +46,8 @@ export type Load_Modules_Result<T_Module_Meta extends Module_Meta> = Result<{
|
|
|
45
46
|
reasons: string[];
|
|
46
47
|
modules: T_Module_Meta[];
|
|
47
48
|
}>;
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Finds modules from input paths. (see `src/lib/input_path.ts` for more)
|
|
51
|
+
*/
|
|
52
|
+
export declare const find_modules: (input_paths: Input_Path[], custom_search_fs?: (dir: string, options?: import("./search_fs.js").Search_Fs_Options) => Promise<Map<string, import("./path.js").Path_Stats>>, get_possible_source_ids?: (input_path: Input_Path) => Source_Id[], timings?: any) => Promise<Find_Modules_Result>;
|
|
53
|
+
export declare const load_modules: <Module_Type extends Record<string, any>, T_Module_Meta extends Module_Meta<Module_Type>>(source_ids_by_input_path: Map<Input_Path, Source_Id[]>, load_module_by_id: (source_id: Source_Id) => Promise<Load_Module_Result<T_Module_Meta>>, timings?: any) => Promise<Load_Modules_Result<T_Module_Meta>>;
|
package/dist/modules.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { red } from 'kleur/colors';
|
|
2
2
|
import { Unreachable_Error } from '@ryanatkn/belt/error.js';
|
|
3
3
|
import { print_error } from '@ryanatkn/belt/print.js';
|
|
4
|
-
import { load_source_path_data_by_input_path, load_source_ids_by_input_path } from './input_path.js';
|
|
4
|
+
import { load_source_path_data_by_input_path, load_source_ids_by_input_path, Input_Path, } from './input_path.js';
|
|
5
5
|
import { paths_from_id, print_path, print_path_or_gro_path } from './paths.js';
|
|
6
6
|
import { search_fs } from './search_fs.js';
|
|
7
7
|
export const load_module = async (id, validate) => {
|
|
@@ -17,11 +17,9 @@ export const load_module = async (id, validate) => {
|
|
|
17
17
|
}
|
|
18
18
|
return { ok: true, mod: { id, mod } };
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*/
|
|
20
|
+
/**
|
|
21
|
+
* Finds modules from input paths. (see `src/lib/input_path.ts` for more)
|
|
22
|
+
*/
|
|
25
23
|
export const find_modules = async (input_paths, custom_search_fs = search_fs, get_possible_source_ids, timings) => {
|
|
26
24
|
// Check which extension variation works - if it's a directory, prefer others first!
|
|
27
25
|
const timing_to_map_input_paths = timings?.start('map input paths');
|
|
@@ -53,13 +51,7 @@ export const find_modules = async (input_paths, custom_search_fs = search_fs, ge
|
|
|
53
51
|
}
|
|
54
52
|
: { ok: true, source_ids_by_input_path, source_id_path_data_by_input_path };
|
|
55
53
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
Load modules by source id.
|
|
59
|
-
|
|
60
|
-
TODO parallelize, originally it needed to be serial for a specific usecase we no longer have
|
|
61
|
-
|
|
62
|
-
*/
|
|
54
|
+
// TODO parallelize, originally it needed to be serial for a specific usecase we no longer have
|
|
63
55
|
export const load_modules = async (source_ids_by_input_path, // TODO maybe make this a flat array and remove `input_path`?
|
|
64
56
|
load_module_by_id, timings) => {
|
|
65
57
|
const timing_to_load_modules = timings?.start('load modules');
|
package/dist/modules.test.js
CHANGED
|
@@ -69,7 +69,7 @@ test__find_modules('with and without extension', async () => {
|
|
|
69
69
|
const path1 = resolve('src/fixtures/test1');
|
|
70
70
|
const id1 = resolve('src/fixtures/test1.foo.ts');
|
|
71
71
|
const id2 = resolve('src/fixtures/test2.foo.ts');
|
|
72
|
-
const result = await find_modules([path1, id2], (id) => search_fs(id, { files_only: false }), (input_path) => get_possible_source_ids(input_path, ['.foo.ts']));
|
|
72
|
+
const result = await find_modules([path1, id2], (id) => search_fs(id, { files_only: false }), (input_path) => get_possible_source_ids(input_path, ['.foo.ts'], []));
|
|
73
73
|
assert.ok(result.ok);
|
|
74
74
|
assert.equal(result.source_ids_by_input_path, new Map([
|
|
75
75
|
[path1, [id1]],
|
|
@@ -93,7 +93,7 @@ test__find_modules('fail with unmapped_input_paths', async () => {
|
|
|
93
93
|
resolve('src/fixtures/failme1'),
|
|
94
94
|
resolve('src/fixtures/bar2'),
|
|
95
95
|
resolve('src/fixtures/failme2'),
|
|
96
|
-
], (id) => search_fs(id, { files_only: false }), (input_path) => get_possible_source_ids(input_path, ['.foo.ts']));
|
|
96
|
+
], (id) => search_fs(id, { files_only: false }), (input_path) => get_possible_source_ids(input_path, ['.foo.ts'], []));
|
|
97
97
|
assert.ok(!result.ok);
|
|
98
98
|
assert.ok(result.reasons.length);
|
|
99
99
|
if (result.type === 'unmapped_input_paths') {
|
package/dist/package.d.ts
CHANGED
|
@@ -290,6 +290,10 @@ export declare const package_json: {
|
|
|
290
290
|
default: string;
|
|
291
291
|
types: string;
|
|
292
292
|
};
|
|
293
|
+
'./path_constants.js': {
|
|
294
|
+
default: string;
|
|
295
|
+
types: string;
|
|
296
|
+
};
|
|
293
297
|
'./path.js': {
|
|
294
298
|
default: string;
|
|
295
299
|
types: string;
|
|
@@ -302,11 +306,11 @@ export declare const package_json: {
|
|
|
302
306
|
default: string;
|
|
303
307
|
types: string;
|
|
304
308
|
};
|
|
305
|
-
'./
|
|
309
|
+
'./publish.task.js': {
|
|
306
310
|
default: string;
|
|
307
311
|
types: string;
|
|
308
312
|
};
|
|
309
|
-
'./
|
|
313
|
+
'./register.js': {
|
|
310
314
|
default: string;
|
|
311
315
|
types: string;
|
|
312
316
|
};
|
|
@@ -346,10 +350,18 @@ export declare const package_json: {
|
|
|
346
350
|
default: string;
|
|
347
351
|
types: string;
|
|
348
352
|
};
|
|
353
|
+
'./sveltekit_config_global.js': {
|
|
354
|
+
default: string;
|
|
355
|
+
types: string;
|
|
356
|
+
};
|
|
349
357
|
'./sveltekit_config.js': {
|
|
350
358
|
default: string;
|
|
351
359
|
types: string;
|
|
352
360
|
};
|
|
361
|
+
'./sveltekit_helpers.js': {
|
|
362
|
+
default: string;
|
|
363
|
+
types: string;
|
|
364
|
+
};
|
|
353
365
|
'./sveltekit_shim_app_environment.js': {
|
|
354
366
|
default: string;
|
|
355
367
|
types: string;
|
|
@@ -382,6 +394,10 @@ export declare const package_json: {
|
|
|
382
394
|
default: string;
|
|
383
395
|
types: string;
|
|
384
396
|
};
|
|
397
|
+
'./task_logging.js': {
|
|
398
|
+
default: string;
|
|
399
|
+
types: string;
|
|
400
|
+
};
|
|
385
401
|
'./task_module.js': {
|
|
386
402
|
default: string;
|
|
387
403
|
types: string;
|
|
@@ -754,28 +770,28 @@ export declare const src_json: {
|
|
|
754
770
|
kind: string;
|
|
755
771
|
}[];
|
|
756
772
|
};
|
|
757
|
-
'./
|
|
773
|
+
'./path_constants.js': {
|
|
758
774
|
path: string;
|
|
759
775
|
declarations: {
|
|
760
776
|
name: string;
|
|
761
777
|
kind: string;
|
|
762
778
|
}[];
|
|
763
779
|
};
|
|
764
|
-
'./
|
|
780
|
+
'./path.js': {
|
|
765
781
|
path: string;
|
|
766
782
|
declarations: {
|
|
767
783
|
name: string;
|
|
768
784
|
kind: string;
|
|
769
785
|
}[];
|
|
770
786
|
};
|
|
771
|
-
'./
|
|
787
|
+
'./paths.js': {
|
|
772
788
|
path: string;
|
|
773
789
|
declarations: {
|
|
774
790
|
name: string;
|
|
775
791
|
kind: string;
|
|
776
792
|
}[];
|
|
777
793
|
};
|
|
778
|
-
'./
|
|
794
|
+
'./plugin.js': {
|
|
779
795
|
path: string;
|
|
780
796
|
declarations: {
|
|
781
797
|
name: string;
|
|
@@ -789,6 +805,10 @@ export declare const src_json: {
|
|
|
789
805
|
kind: string;
|
|
790
806
|
}[];
|
|
791
807
|
};
|
|
808
|
+
'./register.js': {
|
|
809
|
+
path: string;
|
|
810
|
+
declarations: never[];
|
|
811
|
+
};
|
|
792
812
|
'./release.task.js': {
|
|
793
813
|
path: string;
|
|
794
814
|
declarations: {
|
|
@@ -852,6 +872,13 @@ export declare const src_json: {
|
|
|
852
872
|
kind: string;
|
|
853
873
|
}[];
|
|
854
874
|
};
|
|
875
|
+
'./sveltekit_config_global.js': {
|
|
876
|
+
path: string;
|
|
877
|
+
declarations: {
|
|
878
|
+
name: string;
|
|
879
|
+
kind: string;
|
|
880
|
+
}[];
|
|
881
|
+
};
|
|
855
882
|
'./sveltekit_config.js': {
|
|
856
883
|
path: string;
|
|
857
884
|
declarations: {
|
|
@@ -859,6 +886,13 @@ export declare const src_json: {
|
|
|
859
886
|
kind: string;
|
|
860
887
|
}[];
|
|
861
888
|
};
|
|
889
|
+
'./sveltekit_helpers.js': {
|
|
890
|
+
path: string;
|
|
891
|
+
declarations: {
|
|
892
|
+
name: string;
|
|
893
|
+
kind: string;
|
|
894
|
+
}[];
|
|
895
|
+
};
|
|
862
896
|
'./sveltekit_shim_app_environment.js': {
|
|
863
897
|
path: string;
|
|
864
898
|
declarations: {
|
|
@@ -915,6 +949,13 @@ export declare const src_json: {
|
|
|
915
949
|
kind: string;
|
|
916
950
|
}[];
|
|
917
951
|
};
|
|
952
|
+
'./task_logging.js': {
|
|
953
|
+
path: string;
|
|
954
|
+
declarations: {
|
|
955
|
+
name: string;
|
|
956
|
+
kind: string;
|
|
957
|
+
}[];
|
|
958
|
+
};
|
|
918
959
|
'./task_module.js': {
|
|
919
960
|
path: string;
|
|
920
961
|
declarations: never[];
|
package/dist/package.gen.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { load_package_json } from './package_json.js';
|
|
2
|
-
import {
|
|
2
|
+
import { IS_THIS_GRO, to_root_path } from './paths.js';
|
|
3
3
|
import { create_src_json } from './src_json.js';
|
|
4
4
|
// TODO rename? `Package_Json + Src_Json = package.ts` currently, idk
|
|
5
5
|
// TODO consider an api that uses magic imports like SvelteKit's `$app`, like `$repo/package.json`
|
|
@@ -14,8 +14,8 @@ export const gen = async ({ origin_id }) => {
|
|
|
14
14
|
return `
|
|
15
15
|
// generated by ${to_root_path(origin_id)}
|
|
16
16
|
|
|
17
|
-
import type {Package_Json} from '${
|
|
18
|
-
import type {Src_Json} from '${
|
|
17
|
+
import type {Package_Json} from '${IS_THIS_GRO ? './package_json.js' : '@ryanatkn/gro/package_json.js'}';
|
|
18
|
+
import type {Src_Json} from '${IS_THIS_GRO ? './src_json.js' : '@ryanatkn/gro/src_json.js'}';
|
|
19
19
|
|
|
20
20
|
export const package_json = ${JSON.stringify(package_json)} satisfies Package_Json;
|
|
21
21
|
|