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