@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ryanatkn/gro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.149.0",
|
|
4
4
|
"description": "task runner and toolkit extending SvelteKit",
|
|
5
5
|
"motto": "generate, run, optimize",
|
|
6
6
|
"glyph": "🌰",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"type": "module",
|
|
34
34
|
"engines": {
|
|
35
|
-
"node": ">=
|
|
35
|
+
"node": ">=22.11"
|
|
36
36
|
},
|
|
37
37
|
"bin": {
|
|
38
38
|
"gro": "dist/gro.js"
|
|
@@ -49,41 +49,40 @@
|
|
|
49
49
|
"typescript"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@ryanatkn/belt": "^0.
|
|
53
|
-
"chokidar": "^4.0.
|
|
54
|
-
"dotenv": "^16.4.
|
|
55
|
-
"esm-env": "^1.
|
|
52
|
+
"@ryanatkn/belt": "^0.30.0",
|
|
53
|
+
"chokidar": "^4.0.3",
|
|
54
|
+
"dotenv": "^16.4.7",
|
|
55
|
+
"esm-env": "^1.2.2",
|
|
56
56
|
"mri": "^1.2.0",
|
|
57
|
-
"oxc-parser": "^0.
|
|
58
|
-
"prettier": "^3.
|
|
59
|
-
"prettier-plugin-svelte": "^3.
|
|
60
|
-
"ts-morph": "^
|
|
57
|
+
"oxc-parser": "^0.62.0",
|
|
58
|
+
"prettier": "^3.5.3",
|
|
59
|
+
"prettier-plugin-svelte": "^3.3.3",
|
|
60
|
+
"ts-morph": "^25.0.1",
|
|
61
61
|
"tslib": "^2.8.1",
|
|
62
|
-
"zod": "^3.
|
|
62
|
+
"zod": "^3.24.2"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"esbuild": "^0.
|
|
65
|
+
"esbuild": "^0.25",
|
|
66
66
|
"svelte": "^5"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@changesets/changelog-git": "^0.2.
|
|
70
|
-
"@changesets/types": "^6.
|
|
71
|
-
"@ryanatkn/eslint-config": "^0.
|
|
72
|
-
"@ryanatkn/fuz": "^0.
|
|
73
|
-
"@ryanatkn/moss": "^0.
|
|
74
|
-
"@sveltejs/adapter-static": "^3.0.
|
|
75
|
-
"@sveltejs/kit": "^2.
|
|
76
|
-
"@sveltejs/package": "^2.3.
|
|
77
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
78
|
-
"@types/
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"eslint": "^
|
|
82
|
-
"
|
|
83
|
-
"svelte": "^
|
|
84
|
-
"
|
|
85
|
-
"typescript": "^
|
|
86
|
-
"typescript-eslint": "^8.12.2",
|
|
69
|
+
"@changesets/changelog-git": "^0.2.1",
|
|
70
|
+
"@changesets/types": "^6.1.0",
|
|
71
|
+
"@ryanatkn/eslint-config": "^0.8.0",
|
|
72
|
+
"@ryanatkn/fuz": "^0.135.0",
|
|
73
|
+
"@ryanatkn/moss": "^0.24.2",
|
|
74
|
+
"@sveltejs/adapter-static": "^3.0.8",
|
|
75
|
+
"@sveltejs/kit": "^2.20.4",
|
|
76
|
+
"@sveltejs/package": "^2.3.10",
|
|
77
|
+
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
|
78
|
+
"@types/node": "^22.14.0",
|
|
79
|
+
"esbuild": "^0.25.2",
|
|
80
|
+
"eslint": "^9.24.0",
|
|
81
|
+
"eslint-plugin-svelte": "^3.5.1",
|
|
82
|
+
"svelte": "^5.25.6",
|
|
83
|
+
"svelte-check": "^4.1.5",
|
|
84
|
+
"typescript": "^5.8.2",
|
|
85
|
+
"typescript-eslint": "^8.29.0",
|
|
87
86
|
"uvu": "^0.5.6"
|
|
88
87
|
},
|
|
89
88
|
"prettier": {
|
|
@@ -142,6 +141,10 @@
|
|
|
142
141
|
"types": "./dist/check.task.d.ts",
|
|
143
142
|
"default": "./dist/check.task.js"
|
|
144
143
|
},
|
|
144
|
+
"./child_process_logging.js": {
|
|
145
|
+
"types": "./dist/child_process_logging.d.ts",
|
|
146
|
+
"default": "./dist/child_process_logging.js"
|
|
147
|
+
},
|
|
145
148
|
"./clean_fs.js": {
|
|
146
149
|
"types": "./dist/clean_fs.d.ts",
|
|
147
150
|
"default": "./dist/clean_fs.js"
|
package/src/lib/args.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type {z} from 'zod';
|
|
|
12
12
|
* The raw CLI ares are handled by `mri` - https://github.com/lukeed/mri
|
|
13
13
|
*/
|
|
14
14
|
export interface Args {
|
|
15
|
-
_?: string
|
|
15
|
+
_?: Array<string>;
|
|
16
16
|
help?: boolean;
|
|
17
17
|
[key: string]: Arg_Value;
|
|
18
18
|
}
|
|
@@ -65,8 +65,8 @@ export const parse_args = <
|
|
|
65
65
|
/**
|
|
66
66
|
* Serializes parsed `Args` for CLI commands.
|
|
67
67
|
*/
|
|
68
|
-
export const serialize_args = (args: Args): string
|
|
69
|
-
const result: string
|
|
68
|
+
export const serialize_args = (args: Args): Array<string> => {
|
|
69
|
+
const result: Array<string> = [];
|
|
70
70
|
const add_value = (name: string, value: string | number | boolean | undefined): void => {
|
|
71
71
|
if (value === undefined) return;
|
|
72
72
|
result.push(name);
|
|
@@ -74,10 +74,10 @@ export const serialize_args = (args: Args): string[] => {
|
|
|
74
74
|
result.push(value + '');
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
|
-
let _: string
|
|
77
|
+
let _: Array<string> | null = null;
|
|
78
78
|
for (const [key, value] of Object.entries(args)) {
|
|
79
79
|
if (key === '_') {
|
|
80
|
-
_ = value ? (value as any
|
|
80
|
+
_ = value ? (value as Array<any>).map((v) => (v === undefined ? '' : v + '')) : [];
|
|
81
81
|
} else {
|
|
82
82
|
const name = `${key.length === 1 ? '-' : '--'}${key}`;
|
|
83
83
|
if (Array.isArray(value)) {
|
|
@@ -105,7 +105,7 @@ export const to_task_args = (argv = process.argv): {task_name: string; args: Arg
|
|
|
105
105
|
/**
|
|
106
106
|
* Gets the array of raw string args starting with the first `--`, if any.
|
|
107
107
|
*/
|
|
108
|
-
export const to_raw_rest_args = (argv = process.argv): string
|
|
108
|
+
export const to_raw_rest_args = (argv = process.argv): Array<string> => {
|
|
109
109
|
const forwarded_index = argv.indexOf('--');
|
|
110
110
|
return forwarded_index === -1 ? [] : argv.slice(forwarded_index);
|
|
111
111
|
};
|
|
@@ -118,7 +118,7 @@ export const to_raw_rest_args = (argv = process.argv): string[] => {
|
|
|
118
118
|
*/
|
|
119
119
|
export const to_forwarded_args = (
|
|
120
120
|
command: string,
|
|
121
|
-
raw_rest_args?: string
|
|
121
|
+
raw_rest_args?: Array<string>,
|
|
122
122
|
cache = to_forwarded_args_by_command(raw_rest_args),
|
|
123
123
|
): Args => cache[command] ?? {};
|
|
124
124
|
|
|
@@ -126,8 +126,8 @@ export const to_forwarded_args_by_command = (
|
|
|
126
126
|
raw_rest_args = to_raw_rest_args(),
|
|
127
127
|
): Record<string, Args | undefined> => {
|
|
128
128
|
// Parse each segment of `argv` separated by `--`.
|
|
129
|
-
const argvs: string
|
|
130
|
-
let arr: string
|
|
129
|
+
const argvs: Array<Array<string>> = [];
|
|
130
|
+
let arr: Array<string> | undefined;
|
|
131
131
|
for (const arg of raw_rest_args) {
|
|
132
132
|
if (arg === '--') {
|
|
133
133
|
if (arr?.length) argvs.push(arr);
|
|
@@ -165,7 +165,7 @@ export const to_forwarded_args_by_command = (
|
|
|
165
165
|
return forwarded_args_by_command;
|
|
166
166
|
};
|
|
167
167
|
|
|
168
|
-
export const print_command_args = (serialized_args: string
|
|
168
|
+
export const print_command_args = (serialized_args: Array<string>): string =>
|
|
169
169
|
st('gray', '[') +
|
|
170
170
|
st('magenta', 'running command') +
|
|
171
171
|
st('gray', ']') +
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type {ChildProcess} from 'node:child_process';
|
|
2
|
+
import {strip_end} from '@ryanatkn/belt/string.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Maps child process output through a transform function.
|
|
6
|
+
*/
|
|
7
|
+
export const map_child_process_output = (
|
|
8
|
+
child_process: ChildProcess,
|
|
9
|
+
transform: (data: string) => string,
|
|
10
|
+
): void => {
|
|
11
|
+
if (child_process.stdout) {
|
|
12
|
+
child_process.stdout.on('data', (data) => {
|
|
13
|
+
process.stdout.write(transform(data.toString()));
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (child_process.stderr) {
|
|
18
|
+
child_process.stderr.on('data', (data) => {
|
|
19
|
+
process.stderr.write(transform(data.toString()));
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Configures process output handling with path replacements while preserving ANSI colors.
|
|
26
|
+
*/
|
|
27
|
+
export const configure_colored_output_with_path_replacement = (
|
|
28
|
+
child_process: ChildProcess,
|
|
29
|
+
replacement: string = '.',
|
|
30
|
+
cwd: string = process.cwd(),
|
|
31
|
+
): void => {
|
|
32
|
+
// Escape special characters in the cwd for regex safety
|
|
33
|
+
const cwd_escaped = strip_end(cwd, '/').replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
34
|
+
const cwd_reg_exp = new RegExp(cwd_escaped, 'g');
|
|
35
|
+
|
|
36
|
+
// Use the generic mapper with a path replacement transform
|
|
37
|
+
map_child_process_output(child_process, (data) => data.replace(cwd_reg_exp, replacement));
|
|
38
|
+
};
|
package/src/lib/cli.ts
CHANGED
|
@@ -47,7 +47,7 @@ export const find_cli = (
|
|
|
47
47
|
*/
|
|
48
48
|
export const spawn_cli = async (
|
|
49
49
|
name_or_cli: string | Cli,
|
|
50
|
-
args: string
|
|
50
|
+
args: Array<string> = [],
|
|
51
51
|
log?: Logger,
|
|
52
52
|
options?: SpawnOptions,
|
|
53
53
|
): Promise<Spawn_Result | undefined> => {
|
|
@@ -63,7 +63,7 @@ export const spawn_cli = async (
|
|
|
63
63
|
*/
|
|
64
64
|
export const spawn_cli_process = (
|
|
65
65
|
name_or_cli: string | Cli,
|
|
66
|
-
args: string
|
|
66
|
+
args: Array<string> = [],
|
|
67
67
|
log?: Logger,
|
|
68
68
|
options?: SpawnOptions,
|
|
69
69
|
): Spawned_Process | undefined => {
|
|
@@ -74,7 +74,7 @@ export const spawn_cli_process = (
|
|
|
74
74
|
|
|
75
75
|
export const resolve_cli = (
|
|
76
76
|
name_or_cli: string | Cli,
|
|
77
|
-
args: string
|
|
77
|
+
args: Array<string> = [],
|
|
78
78
|
cwd: string | URL | undefined,
|
|
79
79
|
log?: Logger,
|
|
80
80
|
options?: SpawnOptions,
|
package/src/lib/constants.ts
CHANGED
|
@@ -32,6 +32,8 @@ export const TSCONFIG_FILENAME = 'tsconfig.json';
|
|
|
32
32
|
export const TS_MATCHER = /\.(ts|tsx|mts|cts)$/;
|
|
33
33
|
export const JS_MATCHER = /\.(js|jsx|mjs|cjs)$/;
|
|
34
34
|
export const JSON_MATCHER = /\.json$/;
|
|
35
|
+
/** Extracts the script content from Svelte files. */
|
|
36
|
+
export const SVELTE_SCRIPT_MATCHER = /<script(?:\s+[^>]*)?>([\s\S]*?)<\/script>/gim; // TODO maybe this shouldnt be global? or make a getter?
|
|
35
37
|
export const EVERYTHING_MATCHER = /.*/;
|
|
36
38
|
|
|
37
39
|
export const JS_CLI_DEFAULT = 'node';
|
|
@@ -38,7 +38,7 @@ export const to_define_import_meta_env = (
|
|
|
38
38
|
[import_meta_env + 'SSR']: JSON.stringify(ssr),
|
|
39
39
|
[import_meta_env + 'MODE']: JSON.stringify(mode),
|
|
40
40
|
// it appears SvelteKit's `''` translates to Vite's `'/'`, so this intentionally falls back for falsy values, not just undefined
|
|
41
|
-
[import_meta_env + 'BASE_URL']: JSON.stringify(base_url || '/'),
|
|
41
|
+
[import_meta_env + 'BASE_URL']: JSON.stringify(base_url || '/'),
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
export const default_ts_transform_options: esbuild.TransformOptions = {
|
|
@@ -19,14 +19,14 @@ export interface Esbuild_Plugin_External_Worker_Options {
|
|
|
19
19
|
dir?: string;
|
|
20
20
|
svelte_compile_options?: CompileOptions;
|
|
21
21
|
svelte_compile_module_options?: ModuleCompileOptions;
|
|
22
|
-
svelte_preprocessors?: PreprocessorGroup | PreprocessorGroup
|
|
22
|
+
svelte_preprocessors?: PreprocessorGroup | Array<PreprocessorGroup>;
|
|
23
23
|
alias?: Record<string, string>;
|
|
24
24
|
base_url?: Parsed_Sveltekit_Config['base_url'];
|
|
25
25
|
assets_url?: Parsed_Sveltekit_Config['assets_url'];
|
|
26
26
|
public_prefix?: string;
|
|
27
27
|
private_prefix?: string;
|
|
28
28
|
env_dir?: string;
|
|
29
|
-
env_files?: string
|
|
29
|
+
env_files?: Array<string>;
|
|
30
30
|
ambient_env?: Record<string, string>;
|
|
31
31
|
log?: Logger;
|
|
32
32
|
}
|
|
@@ -25,7 +25,7 @@ export interface Esbuild_Plugin_Svelte_Options {
|
|
|
25
25
|
dir?: string;
|
|
26
26
|
svelte_compile_options?: CompileOptions;
|
|
27
27
|
svelte_compile_module_options?: ModuleCompileOptions;
|
|
28
|
-
svelte_preprocessors?: PreprocessorGroup | PreprocessorGroup
|
|
28
|
+
svelte_preprocessors?: PreprocessorGroup | Array<PreprocessorGroup>;
|
|
29
29
|
ts_transform_options?: esbuild.TransformOptions;
|
|
30
30
|
is_ts?: (filename: string) => boolean;
|
|
31
31
|
}
|
package/src/lib/gen.ts
CHANGED
|
@@ -28,7 +28,7 @@ export const is_gen_path = (path: string): boolean => path.includes(GEN_FILE_PAT
|
|
|
28
28
|
|
|
29
29
|
export interface Gen_Result {
|
|
30
30
|
origin_id: Path_Id;
|
|
31
|
-
files: Gen_File
|
|
31
|
+
files: Array<Gen_File>;
|
|
32
32
|
}
|
|
33
33
|
export interface Gen_File {
|
|
34
34
|
id: Path_Id;
|
|
@@ -52,7 +52,7 @@ export interface Gen_Context {
|
|
|
52
52
|
log: Logger;
|
|
53
53
|
}
|
|
54
54
|
// TODO consider other return data - metadata? effects? non-file build artifacts?
|
|
55
|
-
export type Raw_Gen_Result = string | Raw_Gen_File | null | Raw_Gen_Result
|
|
55
|
+
export type Raw_Gen_Result = string | Raw_Gen_File | null | Array<Raw_Gen_Result>;
|
|
56
56
|
export interface Raw_Gen_File {
|
|
57
57
|
content: string;
|
|
58
58
|
// Defaults to file name without the `.gen`, and can be a relative path.
|
|
@@ -67,9 +67,9 @@ export const Gen_Config = z.object({
|
|
|
67
67
|
export type Gen_Config = z.infer<typeof Gen_Config>;
|
|
68
68
|
|
|
69
69
|
export interface Gen_Results {
|
|
70
|
-
results: Genfile_Module_Result
|
|
71
|
-
successes: Genfile_Module_Result_Success
|
|
72
|
-
failures: Genfile_Module_Result_Failure
|
|
70
|
+
results: Array<Genfile_Module_Result>;
|
|
71
|
+
successes: Array<Genfile_Module_Result_Success>;
|
|
72
|
+
failures: Array<Genfile_Module_Result_Failure>;
|
|
73
73
|
input_count: number;
|
|
74
74
|
output_count: number;
|
|
75
75
|
elapsed: number;
|
|
@@ -78,7 +78,7 @@ export type Genfile_Module_Result = Genfile_Module_Result_Success | Genfile_Modu
|
|
|
78
78
|
export interface Genfile_Module_Result_Success {
|
|
79
79
|
ok: true;
|
|
80
80
|
id: Path_Id;
|
|
81
|
-
files: Gen_File
|
|
81
|
+
files: Array<Gen_File>;
|
|
82
82
|
elapsed: number;
|
|
83
83
|
}
|
|
84
84
|
export interface Genfile_Module_Result_Failure {
|
|
@@ -96,7 +96,7 @@ export const to_gen_result = (origin_id: Path_Id, raw_result: Raw_Gen_Result): G
|
|
|
96
96
|
};
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
const to_gen_files = (origin_id: Path_Id, raw_result: Raw_Gen_Result): Gen_File
|
|
99
|
+
const to_gen_files = (origin_id: Path_Id, raw_result: Raw_Gen_Result): Array<Gen_File> => {
|
|
100
100
|
if (raw_result === null) {
|
|
101
101
|
return [];
|
|
102
102
|
} else if (typeof raw_result === 'string') {
|
|
@@ -147,7 +147,7 @@ export const to_output_file_name = (filename: string): string => {
|
|
|
147
147
|
`Invalid gen file name - only one additional extension is allowed to follow '${GEN_FILE_PATTERN}' in '${filename}'`,
|
|
148
148
|
);
|
|
149
149
|
}
|
|
150
|
-
const final_parts: string
|
|
150
|
+
const final_parts: Array<string> = [];
|
|
151
151
|
const has_different_ext = gen_pattern_index === parts.length - 3;
|
|
152
152
|
const length = has_different_ext ? parts.length - 1 : parts.length;
|
|
153
153
|
for (let i = 0; i < length; i++) {
|
|
@@ -158,7 +158,7 @@ export const to_output_file_name = (filename: string): string => {
|
|
|
158
158
|
return final_parts.join('.');
|
|
159
159
|
};
|
|
160
160
|
|
|
161
|
-
const validate_gen_files = (files: Gen_File
|
|
161
|
+
const validate_gen_files = (files: Array<Gen_File>) => {
|
|
162
162
|
const ids = new Set();
|
|
163
163
|
for (const file of files) {
|
|
164
164
|
if (ids.has(file.id)) {
|
|
@@ -182,7 +182,9 @@ export type Analyzed_Gen_Result =
|
|
|
182
182
|
has_changed: true;
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
-
export const analyze_gen_results = (
|
|
185
|
+
export const analyze_gen_results = (
|
|
186
|
+
gen_results: Gen_Results,
|
|
187
|
+
): Promise<Array<Analyzed_Gen_Result>> =>
|
|
186
188
|
Promise.all(
|
|
187
189
|
gen_results.successes
|
|
188
190
|
.map((result) => result.files.map((file) => analyze_gen_result(file)))
|
|
@@ -209,7 +211,7 @@ export const analyze_gen_result = async (file: Gen_File): Promise<Analyzed_Gen_R
|
|
|
209
211
|
|
|
210
212
|
export const write_gen_results = async (
|
|
211
213
|
gen_results: Gen_Results,
|
|
212
|
-
analyzed_gen_results: Analyzed_Gen_Result
|
|
214
|
+
analyzed_gen_results: Array<Analyzed_Gen_Result>,
|
|
213
215
|
log: Logger,
|
|
214
216
|
): Promise<void> => {
|
|
215
217
|
await Promise.all(
|
|
@@ -236,38 +238,38 @@ export const write_gen_results = async (
|
|
|
236
238
|
};
|
|
237
239
|
|
|
238
240
|
export interface Found_Genfiles {
|
|
239
|
-
resolved_input_files: Resolved_Input_File
|
|
240
|
-
resolved_input_files_by_root_dir: Map<Path_Id, Resolved_Input_File
|
|
241
|
-
resolved_input_paths: Resolved_Input_Path
|
|
241
|
+
resolved_input_files: Array<Resolved_Input_File>;
|
|
242
|
+
resolved_input_files_by_root_dir: Map<Path_Id, Array<Resolved_Input_File>>;
|
|
243
|
+
resolved_input_paths: Array<Resolved_Input_Path>;
|
|
242
244
|
}
|
|
243
245
|
|
|
244
246
|
export type Find_Genfiles_Result = Result<{value: Found_Genfiles}, Find_Genfiles_Failure>;
|
|
245
247
|
export type Find_Genfiles_Failure =
|
|
246
248
|
| {
|
|
247
249
|
type: 'unmapped_input_paths';
|
|
248
|
-
unmapped_input_paths: Input_Path
|
|
249
|
-
resolved_input_paths: Resolved_Input_Path
|
|
250
|
-
reasons: string
|
|
250
|
+
unmapped_input_paths: Array<Input_Path>;
|
|
251
|
+
resolved_input_paths: Array<Resolved_Input_Path>;
|
|
252
|
+
reasons: Array<string>;
|
|
251
253
|
}
|
|
252
254
|
| {
|
|
253
255
|
type: 'input_directories_with_no_files';
|
|
254
|
-
input_directories_with_no_files: Input_Path
|
|
255
|
-
resolved_input_files: Resolved_Input_File
|
|
256
|
-
resolved_input_files_by_root_dir: Map<Path_Id, Resolved_Input_File
|
|
257
|
-
resolved_input_paths: Resolved_Input_Path
|
|
258
|
-
reasons: string
|
|
256
|
+
input_directories_with_no_files: Array<Input_Path>;
|
|
257
|
+
resolved_input_files: Array<Resolved_Input_File>;
|
|
258
|
+
resolved_input_files_by_root_dir: Map<Path_Id, Array<Resolved_Input_File>>;
|
|
259
|
+
resolved_input_paths: Array<Resolved_Input_Path>;
|
|
260
|
+
reasons: Array<string>;
|
|
259
261
|
};
|
|
260
262
|
|
|
261
263
|
/**
|
|
262
264
|
* Finds modules from input paths. (see `src/lib/input_path.ts` for more)
|
|
263
265
|
*/
|
|
264
266
|
export const find_genfiles = (
|
|
265
|
-
input_paths: Input_Path
|
|
266
|
-
root_dirs: Path_Id
|
|
267
|
+
input_paths: Array<Input_Path>,
|
|
268
|
+
root_dirs: Array<Path_Id>,
|
|
267
269
|
config: Gro_Config,
|
|
268
270
|
timings?: Timings,
|
|
269
271
|
): Find_Genfiles_Result => {
|
|
270
|
-
const extensions: string
|
|
272
|
+
const extensions: Array<string> = [GEN_FILE_PATTERN];
|
|
271
273
|
|
|
272
274
|
// Check which extension variation works - if it's a directory, prefer others first!
|
|
273
275
|
const timing_to_resolve_input_paths = timings?.start('resolve input paths');
|
|
@@ -334,7 +336,7 @@ export interface Genfile_Module {
|
|
|
334
336
|
export type Genfile_Module_Meta = Module_Meta<Genfile_Module>;
|
|
335
337
|
|
|
336
338
|
export interface Loaded_Genfiles {
|
|
337
|
-
modules: Genfile_Module_Meta
|
|
339
|
+
modules: Array<Genfile_Module_Meta>;
|
|
338
340
|
found_genfiles: Found_Genfiles;
|
|
339
341
|
}
|
|
340
342
|
|
package/src/lib/github.ts
CHANGED
|
@@ -30,12 +30,12 @@ export const github_fetch_commit_prs = async (
|
|
|
30
30
|
log?: Logger,
|
|
31
31
|
cache?: Fetch_Value_Cache,
|
|
32
32
|
api_version?: string,
|
|
33
|
-
): Promise<Github_Pull_Request
|
|
33
|
+
): Promise<Array<Github_Pull_Request> | null> => {
|
|
34
34
|
const headers = api_version ? new Headers({'x-github-api-version': api_version}) : undefined;
|
|
35
35
|
const url = `https://api.github.com/repos/${owner}/${repo}/commits/${commit_sha}/pulls`;
|
|
36
36
|
const fetched = await fetch_value(url, {
|
|
37
37
|
request: {headers},
|
|
38
|
-
parse: (v: any
|
|
38
|
+
parse: (v: Array<any>) => v.map((p) => Github_Pull_Request.parse(p)),
|
|
39
39
|
token,
|
|
40
40
|
cache,
|
|
41
41
|
return_early_from_cache: true,
|
package/src/lib/gro.ts
CHANGED
|
@@ -21,5 +21,5 @@ const loader_path = join(invoke_path, '../loader.js');
|
|
|
21
21
|
|
|
22
22
|
const spawned = await spawn_with_loader(loader_path, invoke_path, process.argv.slice(2));
|
|
23
23
|
if (!spawned.ok) {
|
|
24
|
-
process.exitCode = spawned.code || 1;
|
|
24
|
+
process.exitCode = spawned.code || 1;
|
|
25
25
|
}
|
package/src/lib/gro_config.ts
CHANGED
|
@@ -21,7 +21,7 @@ import type {Path_Filter, Path_Id} from './path.js';
|
|
|
21
21
|
* This is exposed to users in places like tasks and genfiles.
|
|
22
22
|
* @see https://github.com/ryanatkn/gro/blob/main/src/docs/config.md
|
|
23
23
|
*/
|
|
24
|
-
export interface Gro_Config {
|
|
24
|
+
export interface Gro_Config extends Raw_Gro_Config {
|
|
25
25
|
/**
|
|
26
26
|
* @see https://github.com/ryanatkn/gro/blob/main/src/docs/plugin.md
|
|
27
27
|
*/
|
|
@@ -36,12 +36,12 @@ export interface Gro_Config {
|
|
|
36
36
|
* The root directories to search for tasks given implicit relative input paths.
|
|
37
37
|
* Defaults to `./src/lib`, then the cwd, then the Gro package dist.
|
|
38
38
|
*/
|
|
39
|
-
task_root_dirs: Path_Id
|
|
39
|
+
task_root_dirs: Array<Path_Id>;
|
|
40
40
|
/**
|
|
41
41
|
* When searching the filsystem for tasks and genfiles,
|
|
42
42
|
* directories and files are included if they pass all of these filters.
|
|
43
43
|
*/
|
|
44
|
-
search_filters: Path_Filter
|
|
44
|
+
search_filters: Array<Path_Filter>;
|
|
45
45
|
/**
|
|
46
46
|
* The CLI to use that's compatible with `node`.
|
|
47
47
|
*/
|
|
@@ -60,8 +60,8 @@ export interface Gro_Config {
|
|
|
60
60
|
export interface Raw_Gro_Config {
|
|
61
61
|
plugins?: Create_Config_Plugins;
|
|
62
62
|
map_package_json?: Map_Package_Json | null;
|
|
63
|
-
task_root_dirs?: string
|
|
64
|
-
search_filters?: Path_Filter | Path_Filter
|
|
63
|
+
task_root_dirs?: Array<string>;
|
|
64
|
+
search_filters?: Path_Filter | Array<Path_Filter> | null;
|
|
65
65
|
js_cli?: string;
|
|
66
66
|
pm_cli?: string;
|
|
67
67
|
}
|
package/src/lib/gro_helpers.ts
CHANGED
|
@@ -83,7 +83,7 @@ export const resolve_gro_module_path = (path = ''): string => {
|
|
|
83
83
|
export const spawn_with_loader = (
|
|
84
84
|
loader_path: string,
|
|
85
85
|
invoke_path: string,
|
|
86
|
-
argv: string
|
|
86
|
+
argv: Array<string>,
|
|
87
87
|
js_cli = JS_CLI_DEFAULT, // TODO source from config when possible
|
|
88
88
|
): Promise<Spawn_Result> => {
|
|
89
89
|
const args = [
|
|
@@ -17,8 +17,8 @@ export interface Task_Args extends Args {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export interface Gro_Plugin_Gen_Options {
|
|
20
|
-
input_paths?: string
|
|
21
|
-
root_dirs?: string
|
|
20
|
+
input_paths?: Array<string>;
|
|
21
|
+
root_dirs?: Array<string>;
|
|
22
22
|
flush_debounce_delay?: number;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -46,7 +46,7 @@ export const gro_plugin_gen = ({
|
|
|
46
46
|
},
|
|
47
47
|
{delay: flush_debounce_delay},
|
|
48
48
|
);
|
|
49
|
-
const gen = (files: string
|
|
49
|
+
const gen = (files: Array<string> = []) => spawn_cli('gro', ['gen', ...files]);
|
|
50
50
|
|
|
51
51
|
let cleanup: Cleanup_Watch | undefined;
|
|
52
52
|
|
|
@@ -22,7 +22,7 @@ export interface Task_Args extends Args {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export interface Gro_Plugin_Moss_Options {
|
|
25
|
-
include_classes?: string
|
|
25
|
+
include_classes?: Array<string> | Set<string> | null;
|
|
26
26
|
outfile?: string;
|
|
27
27
|
filter_file?: File_Filter | null;
|
|
28
28
|
flush_debounce_delay?: number;
|
|
@@ -53,7 +53,7 @@ export const gro_plugin_moss = ({
|
|
|
53
53
|
};
|
|
54
54
|
const flush_gen_queue = throttle(
|
|
55
55
|
async () => {
|
|
56
|
-
const css = generate_classes_css(css_classes.
|
|
56
|
+
const css = generate_classes_css(css_classes.get(), css_classes_by_name);
|
|
57
57
|
const contents = `/* ${banner} */\n\n${css}\n\n/* ${banner} */`;
|
|
58
58
|
const output = await format_file(contents, {filepath: outfile});
|
|
59
59
|
// TODO think about using gen to implement this, would have some nice benefits like automatic change detection
|
|
@@ -37,7 +37,7 @@ export interface Gro_Plugin_Server_Options {
|
|
|
37
37
|
/**
|
|
38
38
|
* same as esbuild's `entryPoints`
|
|
39
39
|
*/
|
|
40
|
-
entry_points?: string
|
|
40
|
+
entry_points?: Array<string>;
|
|
41
41
|
/**
|
|
42
42
|
* @default cwd
|
|
43
43
|
*/
|
|
@@ -51,7 +51,7 @@ export interface Gro_Plugin_Server_Options {
|
|
|
51
51
|
/**
|
|
52
52
|
* @default SvelteKit's `.env`, `.env.development`, and `.env.production`
|
|
53
53
|
*/
|
|
54
|
-
env_files?: string
|
|
54
|
+
env_files?: Array<string>;
|
|
55
55
|
/**
|
|
56
56
|
* @default process.env
|
|
57
57
|
*/
|
|
@@ -109,7 +109,7 @@ export const gro_plugin_sveltekit_app = ({
|
|
|
109
109
|
// copy files to `static` before building, in such a way
|
|
110
110
|
// that's non-destructive to existing files and dirs and easy to clean up
|
|
111
111
|
const {assets_path} = default_sveltekit_config;
|
|
112
|
-
const cleanups: Cleanup
|
|
112
|
+
const cleanups: Array<Cleanup> = [
|
|
113
113
|
serialized_package_json
|
|
114
114
|
? create_temporarily(
|
|
115
115
|
join(assets_path, '.well-known/package.json'),
|