@ryanatkn/gro 0.129.0 → 0.129.2
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 +3 -3
- package/dist/args.d.ts +2 -2
- package/dist/args.js +2 -2
- package/dist/changelog.test.js +1 -1
- 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/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 +1 -1
- package/dist/gro.config.default.js +1 -1
- package/dist/gro.js +1 -1
- package/dist/gro_helpers.js +1 -2
- 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 +7 -10
- package/dist/package.gen.js +3 -3
- package/dist/package.js +18 -15
- 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/release.task.js +2 -2
- package/dist/resolve.task.d.ts +3 -0
- package/dist/resolve.task.js +22 -8
- 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_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.js +6 -1
- package/dist/task.test.js +5 -0
- package/dist/task_logging.d.ts +1 -1
- package/dist/task_logging.js +3 -4
- package/dist/upgrade.task.js +9 -3
- package/dist/watch_dir.d.ts +1 -3
- package/dist/watch_dir.js +6 -6
- package/package.json +18 -21
- package/dist/fs.test.d.ts +0 -1
- package/dist/fs.test.js +0 -16
package/README.md
CHANGED
|
@@ -237,13 +237,13 @@ For more see [the tasks index](/src/lib/docs/tasks.md),
|
|
|
237
237
|
|
|
238
238
|
```bash
|
|
239
239
|
npm i
|
|
240
|
-
npm run
|
|
241
|
-
gro build # same as `npm run
|
|
240
|
+
npm run bootstrap # build and link `gro` without itself - needed only once
|
|
241
|
+
gro build # same as `npm run bootstrap` when the `gro` CLI is available
|
|
242
242
|
gro test # make sure everything looks good - same as `npm test`
|
|
243
243
|
gro test some.test another.test
|
|
244
244
|
|
|
245
245
|
# use your development version of `gro` locally in another project:
|
|
246
|
-
gro build # updates the `gro` CLI, same as `npm run
|
|
246
|
+
gro build # updates the `gro` CLI, same as `npm run bootstrap`
|
|
247
247
|
cd ../otherproject
|
|
248
248
|
npm link ../gro # from `otherproject/`
|
|
249
249
|
gro build # from `../gro` on changes
|
package/dist/args.d.ts
CHANGED
|
@@ -54,6 +54,6 @@ export declare const to_raw_rest_args: (argv?: string[]) => string[];
|
|
|
54
54
|
* the `command` `'eslint'` returns `eslintarg1 --eslintarg2`
|
|
55
55
|
* and `'tsc'` returns `--tscarg1` and `--tscarg2`.
|
|
56
56
|
*/
|
|
57
|
-
export declare const to_forwarded_args: (command: string, raw_rest_args?: string[], cache?: Record<string, Args>) => Args;
|
|
58
|
-
export declare const to_forwarded_args_by_command: (raw_rest_args?: string[]) => Record<string, Args>;
|
|
57
|
+
export declare const to_forwarded_args: (command: string, raw_rest_args?: string[], cache?: Record<string, Args | undefined>) => Args;
|
|
58
|
+
export declare const to_forwarded_args_by_command: (raw_rest_args?: string[]) => Record<string, Args | undefined>;
|
|
59
59
|
export declare const print_command_args: (serialized_args: string[]) => string;
|
package/dist/args.js
CHANGED
|
@@ -69,7 +69,7 @@ export const serialize_args = (args) => {
|
|
|
69
69
|
export const to_task_args = (argv = process.argv) => {
|
|
70
70
|
const forwarded_index = argv.indexOf('--');
|
|
71
71
|
const args = mri(forwarded_index === -1 ? argv.slice(2) : argv.slice(2, forwarded_index));
|
|
72
|
-
const task_name = args._.shift()
|
|
72
|
+
const task_name = args._.shift() ?? '';
|
|
73
73
|
if (!args._.length)
|
|
74
74
|
delete args._; // enable schema defaults
|
|
75
75
|
return { task_name, args };
|
|
@@ -87,7 +87,7 @@ export const to_raw_rest_args = (argv = process.argv) => {
|
|
|
87
87
|
* the `command` `'eslint'` returns `eslintarg1 --eslintarg2`
|
|
88
88
|
* and `'tsc'` returns `--tscarg1` and `--tscarg2`.
|
|
89
89
|
*/
|
|
90
|
-
export const to_forwarded_args = (command, raw_rest_args, cache = to_forwarded_args_by_command(raw_rest_args)) => cache[command]
|
|
90
|
+
export const to_forwarded_args = (command, raw_rest_args, cache = to_forwarded_args_by_command(raw_rest_args)) => cache[command] ?? {};
|
|
91
91
|
export const to_forwarded_args_by_command = (raw_rest_args = to_raw_rest_args()) => {
|
|
92
92
|
// Parse each segment of `argv` separated by `--`.
|
|
93
93
|
const argvs = [];
|
package/dist/changelog.test.js
CHANGED
|
@@ -5,7 +5,7 @@ import { readFile, writeFile } from 'node:fs/promises';
|
|
|
5
5
|
import { update_changelog } from './changelog.js';
|
|
6
6
|
import { load_from_env } from './env.js';
|
|
7
7
|
const log = new Logger();
|
|
8
|
-
const token =
|
|
8
|
+
const token = load_from_env('GITHUB_TOKEN_SECRET');
|
|
9
9
|
if (!token) {
|
|
10
10
|
log.warn('the env var GITHUB_TOKEN_SECRET was not found, so API calls with be unauthorized');
|
|
11
11
|
}
|
package/dist/changeset.task.js
CHANGED
|
@@ -5,11 +5,11 @@ import { readFile, writeFile } from 'node:fs/promises';
|
|
|
5
5
|
import { join } from 'node:path';
|
|
6
6
|
import { existsSync, readdirSync } from 'node:fs';
|
|
7
7
|
import { Task_Error } from './task.js';
|
|
8
|
-
import { load_package_json } from './package_json.js';
|
|
9
8
|
import { find_cli, spawn_cli } from './cli.js';
|
|
10
9
|
import { Git_Origin, git_check_fully_staged_workspace, git_push_to_create } from './git.js';
|
|
11
10
|
import { has_sveltekit_library } from './sveltekit_helpers.js';
|
|
12
11
|
import { CHANGESET_CLI, CHANGESET_DIR, Changeset_Access, Changeset_Bump, CHANGESET_PUBLIC_ACCESS, CHANGESET_RESTRICTED_ACCESS, } from './changeset_helpers.js';
|
|
12
|
+
import { load_package_json } from './package_json.js';
|
|
13
13
|
export const Args = z
|
|
14
14
|
.object({
|
|
15
15
|
/**
|
|
@@ -44,7 +44,7 @@ export const task = {
|
|
|
44
44
|
summary: 'call changeset with gro patterns',
|
|
45
45
|
Args,
|
|
46
46
|
run: async (ctx) => {
|
|
47
|
-
const { invoke_task, args: { _, minor, major, dir, access: access_arg, changelog, install, origin, changeset_cli }, log, } = ctx;
|
|
47
|
+
const { invoke_task, args: { _, minor, major, dir, access: access_arg, changelog, install, origin, changeset_cli }, log, sveltekit_config, } = ctx;
|
|
48
48
|
const message = _.join(' ');
|
|
49
49
|
if (!message && (minor || major))
|
|
50
50
|
throw new Task_Error('cannot bump version without a message');
|
|
@@ -55,8 +55,8 @@ export const task = {
|
|
|
55
55
|
if (!found_changeset_cli) {
|
|
56
56
|
throw new Task_Error('changeset command not found: install @changesets/cli locally or globally');
|
|
57
57
|
}
|
|
58
|
-
const package_json =
|
|
59
|
-
const has_sveltekit_library_result =
|
|
58
|
+
const package_json = load_package_json();
|
|
59
|
+
const has_sveltekit_library_result = has_sveltekit_library(package_json, sveltekit_config);
|
|
60
60
|
if (!has_sveltekit_library_result.ok) {
|
|
61
61
|
throw new Task_Error('Failed to find SvelteKit library: ' + has_sveltekit_library_result.message);
|
|
62
62
|
}
|
|
@@ -84,7 +84,7 @@ export const task = {
|
|
|
84
84
|
await invoke_task('sync'); // after the `npm i` above, and in all cases
|
|
85
85
|
if (message) {
|
|
86
86
|
// TODO see the helper below, simplify this to CLI flags when support is added to Changesets
|
|
87
|
-
const changeset_adder =
|
|
87
|
+
const changeset_adder = create_changeset_adder(package_json.name, dir, message, bump);
|
|
88
88
|
await spawn_cli(found_changeset_cli, ['add', '--empty'], log);
|
|
89
89
|
await changeset_adder();
|
|
90
90
|
if (!(await git_check_fully_staged_workspace())) {
|
|
@@ -102,7 +102,7 @@ export const task = {
|
|
|
102
102
|
* TODO ideally this wouldn't exist and we'd use CLI flags, but they doesn't exist yet
|
|
103
103
|
* @see https://github.com/changesets/changesets/pull/1121
|
|
104
104
|
*/
|
|
105
|
-
const create_changeset_adder =
|
|
105
|
+
const create_changeset_adder = (repo_name, dir, message, bump) => {
|
|
106
106
|
const filenames_before = readdirSync(dir);
|
|
107
107
|
return async () => {
|
|
108
108
|
const filenames_after = readdirSync(dir);
|
package/dist/cli.js
CHANGED
|
@@ -16,7 +16,7 @@ export const find_cli = (name, cwd = process.cwd(), options) => {
|
|
|
16
16
|
return { name, id: local_id, kind: 'local' };
|
|
17
17
|
}
|
|
18
18
|
const { stdout } = spawnSync('which', [name], options);
|
|
19
|
-
const global_id = stdout
|
|
19
|
+
const global_id = stdout.toString().trim();
|
|
20
20
|
if (!global_id)
|
|
21
21
|
return null;
|
|
22
22
|
return { name, id: global_id, kind: 'global' };
|
package/dist/config.d.ts
CHANGED
|
@@ -39,9 +39,7 @@ export interface Raw_Gro_Config {
|
|
|
39
39
|
task_root_dirs?: string[];
|
|
40
40
|
search_filters?: Path_Filter | Path_Filter[] | null;
|
|
41
41
|
}
|
|
42
|
-
export
|
|
43
|
-
(base_config: Gro_Config): Raw_Gro_Config | Promise<Raw_Gro_Config>;
|
|
44
|
-
}
|
|
42
|
+
export type Create_Gro_Config = (base_config: Gro_Config) => Raw_Gro_Config | Promise<Raw_Gro_Config>;
|
|
45
43
|
export declare const create_empty_config: () => Gro_Config;
|
|
46
44
|
/**
|
|
47
45
|
* The regexp used by default to exclude directories and files
|
package/dist/config.js
CHANGED
|
@@ -11,7 +11,7 @@ export const create_empty_config = () => ({
|
|
|
11
11
|
paths.lib,
|
|
12
12
|
IS_THIS_GRO ? null : paths.root,
|
|
13
13
|
IS_THIS_GRO ? null : GRO_DIST_DIR,
|
|
14
|
-
].filter(
|
|
14
|
+
].filter((v) => v !== null),
|
|
15
15
|
search_filters: [(id) => !DEFAULT_SEARCH_EXCLUDER.test(id)],
|
|
16
16
|
});
|
|
17
17
|
/**
|
|
@@ -27,7 +27,7 @@ export const DEFAULT_SEARCH_EXCLUDER = new RegExp(`(${'(^|/)\\.[^/]+' + // exclu
|
|
|
27
27
|
`|(^|/)(?<!(^|/)gro/)${SVELTEKIT_DIST_DIRNAME}` + // exclude the SvelteKit dist directory unless it's in the Gro directory
|
|
28
28
|
`|(^|/)${SERVER_DIST_PATH}` // exclude the Gro server plugin dist directory
|
|
29
29
|
})($|/)`, 'u');
|
|
30
|
-
const default_map_package_json =
|
|
30
|
+
const default_map_package_json = (package_json) => {
|
|
31
31
|
if (package_json.exports) {
|
|
32
32
|
package_json.exports = Object.fromEntries(Object.entries(package_json.exports).filter(([k]) => !DEFAULT_EXPORTS_EXCLUDER.test(k)));
|
|
33
33
|
}
|
package/dist/deploy.task.js
CHANGED
|
@@ -12,7 +12,7 @@ import { empty_dir } from './fs.js';
|
|
|
12
12
|
import { git_check_clean_workspace, git_checkout, git_local_branch_exists, git_remote_branch_exists, Git_Origin, Git_Branch, git_delete_local_branch, git_push_to_create, git_reset_branch_to_first_commit, git_pull, git_fetch, git_check_setting_pull_rebase, git_clone_locally, git_current_branch_name, } from './git.js';
|
|
13
13
|
// docs at ./docs/deploy.md
|
|
14
14
|
// terminal command for testing:
|
|
15
|
-
// npm run
|
|
15
|
+
// npm run bootstrap && rm -rf .gro && clear && gro deploy --source no-git-workspace --no-build --dry
|
|
16
16
|
// TODO customize
|
|
17
17
|
const dir = process.cwd();
|
|
18
18
|
const INITIAL_FILE_PATH = '.gitkeep';
|
|
@@ -10,7 +10,7 @@ import { search_fs } from '../search_fs.js';
|
|
|
10
10
|
/**
|
|
11
11
|
* Renders a simple index of a possibly nested directory of files.
|
|
12
12
|
*/
|
|
13
|
-
export const gen =
|
|
13
|
+
export const gen = ({ origin_id }) => {
|
|
14
14
|
// TODO need to get this from project config or something
|
|
15
15
|
const root_path = parse_path_segments(paths.root).at(-1);
|
|
16
16
|
const origin_dir = dirname(origin_id);
|
|
@@ -18,7 +18,8 @@ behavior designed for public open source projects:
|
|
|
18
18
|
containing additional information about the source modules,
|
|
19
19
|
mapping it with the optional
|
|
20
20
|
[`well_known_src_json` option](./gro_plugin_sveltekit_app.md#well_known_src_json).
|
|
21
|
-
- If you
|
|
21
|
+
- If you define a truthy value for the
|
|
22
|
+
[`well_known_src_files` option](./gro_plugin_sveltekit_app.md#well_known_src_files),
|
|
22
23
|
`gro_plugin_sveltekit_app` outputs `.well-known/src/` by
|
|
23
24
|
copying over `src/` during `vite build`, filtered by `well_known_src_files` if it's a function.
|
|
24
25
|
This is costly (usually more than doubling the final output size
|
package/dist/env.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const load_env: (dev: boolean, visibility: "public" | "private", public_prefix: string, private_prefix: string, env_dir?: string, env_files?: string[], ambient_env?: NodeJS.ProcessEnv) =>
|
|
1
|
+
export declare const load_env: (dev: boolean, visibility: "public" | "private", public_prefix: string, private_prefix: string, env_dir?: string, env_files?: string[], ambient_env?: NodeJS.ProcessEnv) => Record<string, string>;
|
|
2
2
|
export declare const merge_envs: (envs: Array<Record<string, string | undefined>>, visibility: "public" | "private", public_prefix: string, private_prefix: string) => Record<string, string>;
|
|
3
3
|
export declare const is_private_env: (key: string, public_prefix: string, private_prefix: string) => boolean;
|
|
4
4
|
export declare const is_public_env: (key: string, public_prefix: string, private_prefix: string) => boolean;
|
|
@@ -6,4 +6,4 @@ export declare const is_public_env: (key: string, public_prefix: string, private
|
|
|
6
6
|
* Loads a single env value without merging it into `process.env`.
|
|
7
7
|
* By default searches process.env, then a local `.env` if one exists, then `../.env` if it exists.
|
|
8
8
|
*/
|
|
9
|
-
export declare const load_from_env: (key: string, paths?: string[]) =>
|
|
9
|
+
export declare const load_from_env: (key: string, paths?: string[]) => string | undefined;
|
package/dist/env.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import dotenv from 'dotenv';
|
|
2
|
-
import { readFile } from 'node:fs/promises';
|
|
3
2
|
import { resolve } from 'node:path';
|
|
4
|
-
import { existsSync } from 'node:fs';
|
|
5
|
-
export const load_env =
|
|
6
|
-
const envs =
|
|
7
|
-
.map(
|
|
8
|
-
.filter(
|
|
3
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
4
|
+
export const load_env = (dev, visibility, public_prefix, private_prefix, env_dir, env_files = ['.env', '.env.' + (dev ? 'development' : 'production')], ambient_env = process.env) => {
|
|
5
|
+
const envs = env_files
|
|
6
|
+
.map((path) => load(env_dir === undefined ? path : resolve(env_dir, path)))
|
|
7
|
+
.filter((v) => v !== undefined);
|
|
9
8
|
envs.push(ambient_env);
|
|
10
9
|
return merge_envs(envs, visibility, public_prefix, private_prefix);
|
|
11
10
|
};
|
|
12
|
-
const load =
|
|
11
|
+
const load = (path) => {
|
|
13
12
|
if (!existsSync(path))
|
|
14
|
-
return
|
|
15
|
-
const loaded =
|
|
13
|
+
return;
|
|
14
|
+
const loaded = readFileSync(path, 'utf8');
|
|
16
15
|
return dotenv.parse(loaded);
|
|
17
16
|
};
|
|
18
17
|
export const merge_envs = (envs, visibility, public_prefix, private_prefix) => {
|
|
@@ -35,11 +34,11 @@ export const is_public_env = (key, public_prefix, private_prefix) => key.startsW
|
|
|
35
34
|
* Loads a single env value without merging it into `process.env`.
|
|
36
35
|
* By default searches process.env, then a local `.env` if one exists, then `../.env` if it exists.
|
|
37
36
|
*/
|
|
38
|
-
export const load_from_env =
|
|
37
|
+
export const load_from_env = (key, paths = ['.env', '../.env']) => {
|
|
39
38
|
if (process.env[key])
|
|
40
39
|
return process.env[key];
|
|
41
40
|
for (const path of paths) {
|
|
42
|
-
const env =
|
|
41
|
+
const env = load(path);
|
|
43
42
|
if (env?.[key])
|
|
44
43
|
return env[key];
|
|
45
44
|
}
|
package/dist/esbuild_helpers.js
CHANGED
|
@@ -25,7 +25,8 @@ export const to_define_import_meta_env = (dev, base_url, ssr = true, mode = dev
|
|
|
25
25
|
[import_meta_env + 'PROD']: JSON.stringify(!dev),
|
|
26
26
|
[import_meta_env + 'SSR']: JSON.stringify(ssr),
|
|
27
27
|
[import_meta_env + 'MODE']: JSON.stringify(mode),
|
|
28
|
-
|
|
28
|
+
// it appears SvelteKit's `''` translates to Vite's `'/'`, so this intentionally falls back for falsy values, not just undefined
|
|
29
|
+
[import_meta_env + 'BASE_URL']: JSON.stringify(base_url || '/'), // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing
|
|
29
30
|
});
|
|
30
31
|
export const ts_transform_options = {
|
|
31
32
|
target: 'esnext',
|
|
@@ -42,7 +42,7 @@ export const esbuild_plugin_external_worker = ({ dev, build_options, dir = proce
|
|
|
42
42
|
return building;
|
|
43
43
|
};
|
|
44
44
|
build.onResolve({ filter: /\.worker(|\.js|\.ts)$/u }, async ({ path, resolveDir }) => {
|
|
45
|
-
const parsed =
|
|
45
|
+
const parsed = resolve_specifier(path, resolveDir);
|
|
46
46
|
const { specifier, path_id, namespace } = parsed;
|
|
47
47
|
const build_result = await build_worker(path_id);
|
|
48
48
|
if (log)
|
|
@@ -15,7 +15,7 @@ export const esbuild_plugin_svelte = (options = {}) => {
|
|
|
15
15
|
filename,
|
|
16
16
|
...svelte_compile_module_options,
|
|
17
17
|
});
|
|
18
|
-
const contents = js.
|
|
18
|
+
const contents = js.code + '//# sourceMappingURL=' + js.map.toUrl();
|
|
19
19
|
return {
|
|
20
20
|
contents,
|
|
21
21
|
warnings: warnings.map((w) => convert_svelte_message_to_esbuild(filename, source, w)),
|
|
@@ -34,12 +34,12 @@ export const esbuild_plugin_svelte = (options = {}) => {
|
|
|
34
34
|
: null;
|
|
35
35
|
// TODO handle preprocessor sourcemaps, same as in loader - merge?
|
|
36
36
|
if (preprocessed?.code)
|
|
37
|
-
source = preprocessed
|
|
37
|
+
source = preprocessed.code;
|
|
38
38
|
const { js, warnings } = compile(source, {
|
|
39
39
|
filename,
|
|
40
40
|
...svelte_compile_options,
|
|
41
41
|
});
|
|
42
|
-
const contents = js.
|
|
42
|
+
const contents = js.code + '//# sourceMappingURL=' + js.map.toUrl();
|
|
43
43
|
return {
|
|
44
44
|
contents,
|
|
45
45
|
warnings: warnings.map((w) => convert_svelte_message_to_esbuild(filename, source, w)),
|
|
@@ -9,11 +9,11 @@ import { resolve_specifier } from './resolve_specifier.js';
|
|
|
9
9
|
export const esbuild_plugin_sveltekit_local_imports = () => ({
|
|
10
10
|
name: 'sveltekit_local_imports',
|
|
11
11
|
setup: (build) => {
|
|
12
|
-
build.onResolve({ filter: /^(\/|\.)/u },
|
|
12
|
+
build.onResolve({ filter: /^(\/|\.)/u }, (args) => {
|
|
13
13
|
const { path, importer } = args;
|
|
14
14
|
if (!importer)
|
|
15
15
|
return { path };
|
|
16
|
-
const { path_id, namespace } =
|
|
16
|
+
const { path_id, namespace } = resolve_specifier(path, dirname(importer));
|
|
17
17
|
return { path: path_id, namespace }; // `namespace` may be `undefined`, but esbuild needs the absolute path for json etc
|
|
18
18
|
});
|
|
19
19
|
build.onLoad({ filter: /.*/u, namespace: 'sveltekit_local_imports_ts' }, async ({ path }) => ({
|
|
@@ -5,13 +5,13 @@ export const esbuild_plugin_sveltekit_shim_env = ({ dev, public_prefix, private_
|
|
|
5
5
|
const namespace = 'sveltekit_shim_env';
|
|
6
6
|
const filter = /^\$env\/(static|dynamic)\/(public|private)$/u;
|
|
7
7
|
build.onResolve({ filter }, ({ path }) => ({ path, namespace }));
|
|
8
|
-
build.onLoad({ filter: /.*/u, namespace },
|
|
8
|
+
build.onLoad({ filter: /.*/u, namespace }, ({ path }) => {
|
|
9
9
|
const matches = filter.exec(path);
|
|
10
10
|
const mode = matches[1];
|
|
11
11
|
const visibility = matches[2];
|
|
12
12
|
return {
|
|
13
13
|
loader: 'ts',
|
|
14
|
-
contents:
|
|
14
|
+
contents: render_env_shim_module(dev, mode, visibility, public_prefix, private_prefix, env_dir, env_files, ambient_env),
|
|
15
15
|
};
|
|
16
16
|
});
|
|
17
17
|
},
|
package/dist/format_file.js
CHANGED
|
@@ -11,7 +11,7 @@ let cached_base_options;
|
|
|
11
11
|
export const format_file = async (content, options, base_options = cached_base_options) => {
|
|
12
12
|
const final_base_options = base_options !== undefined
|
|
13
13
|
? base_options
|
|
14
|
-
: (cached_base_options =
|
|
14
|
+
: (cached_base_options = load_package_json().prettier);
|
|
15
15
|
let final_options = options;
|
|
16
16
|
if (options.filepath && !options.parser) {
|
|
17
17
|
const { filepath, ...rest } = options;
|
|
@@ -22,7 +22,7 @@ export const format_file = async (content, options, base_options = cached_base_o
|
|
|
22
22
|
try {
|
|
23
23
|
return await prettier.format(content, { ...final_base_options, ...final_options });
|
|
24
24
|
}
|
|
25
|
-
catch (
|
|
25
|
+
catch (_err) {
|
|
26
26
|
return content;
|
|
27
27
|
}
|
|
28
28
|
};
|
package/dist/gen.d.ts
CHANGED
|
@@ -9,19 +9,17 @@ import { Input_Path, type Resolved_Input_File, type Resolved_Input_Path } from '
|
|
|
9
9
|
export declare const GEN_FILE_PATTERN_TEXT = "gen";
|
|
10
10
|
export declare const GEN_FILE_PATTERN: string;
|
|
11
11
|
export declare const is_gen_path: (path: string) => boolean;
|
|
12
|
-
export
|
|
12
|
+
export interface Gen_Result {
|
|
13
13
|
origin_id: Path_Id;
|
|
14
14
|
files: Gen_File[];
|
|
15
|
-
}
|
|
15
|
+
}
|
|
16
16
|
export interface Gen_File {
|
|
17
17
|
id: Path_Id;
|
|
18
18
|
content: string;
|
|
19
19
|
origin_id: Path_Id;
|
|
20
20
|
format: boolean;
|
|
21
21
|
}
|
|
22
|
-
export
|
|
23
|
-
(ctx: Gen_Context): Raw_Gen_Result | Promise<Raw_Gen_Result>;
|
|
24
|
-
}
|
|
22
|
+
export type Gen = (ctx: Gen_Context) => Raw_Gen_Result | Promise<Raw_Gen_Result>;
|
|
25
23
|
export interface Gen_Context {
|
|
26
24
|
config: Gro_Config;
|
|
27
25
|
sveltekit_config: Parsed_Sveltekit_Config;
|
|
@@ -45,28 +43,28 @@ export declare const Gen_Config: z.ZodObject<{
|
|
|
45
43
|
imports?: Record<string, string> | undefined;
|
|
46
44
|
}>;
|
|
47
45
|
export type Gen_Config = z.infer<typeof Gen_Config>;
|
|
48
|
-
export
|
|
46
|
+
export interface Gen_Results {
|
|
49
47
|
results: Genfile_Module_Result[];
|
|
50
48
|
successes: Genfile_Module_Result_Success[];
|
|
51
49
|
failures: Genfile_Module_Result_Failure[];
|
|
52
50
|
input_count: number;
|
|
53
51
|
output_count: number;
|
|
54
52
|
elapsed: number;
|
|
55
|
-
}
|
|
53
|
+
}
|
|
56
54
|
export type Genfile_Module_Result = Genfile_Module_Result_Success | Genfile_Module_Result_Failure;
|
|
57
|
-
export
|
|
55
|
+
export interface Genfile_Module_Result_Success {
|
|
58
56
|
ok: true;
|
|
59
57
|
id: Path_Id;
|
|
60
58
|
files: Gen_File[];
|
|
61
59
|
elapsed: number;
|
|
62
|
-
}
|
|
63
|
-
export
|
|
60
|
+
}
|
|
61
|
+
export interface Genfile_Module_Result_Failure {
|
|
64
62
|
ok: false;
|
|
65
63
|
id: Path_Id;
|
|
66
64
|
reason: string;
|
|
67
65
|
error: Error;
|
|
68
66
|
elapsed: number;
|
|
69
|
-
}
|
|
67
|
+
}
|
|
70
68
|
export declare const to_gen_result: (origin_id: Path_Id, raw_result: Raw_Gen_Result) => Gen_Result;
|
|
71
69
|
export declare const to_output_file_name: (filename: string) => string;
|
|
72
70
|
export type Analyzed_Gen_Result = {
|
|
@@ -107,7 +105,7 @@ export type Find_Genfiles_Failure = {
|
|
|
107
105
|
/**
|
|
108
106
|
* Finds modules from input paths. (see `src/lib/input_path.ts` for more)
|
|
109
107
|
*/
|
|
110
|
-
export declare const find_genfiles: (input_paths: Input_Path[], root_dirs: Path_Id[], config: Gro_Config, timings?: any) =>
|
|
108
|
+
export declare const find_genfiles: (input_paths: Input_Path[], root_dirs: Path_Id[], config: Gro_Config, timings?: any) => Find_Genfiles_Result;
|
|
111
109
|
export interface Genfile_Module {
|
|
112
110
|
gen: Gen;
|
|
113
111
|
}
|
package/dist/gen.js
CHANGED
|
@@ -42,7 +42,7 @@ const to_output_file_id = (origin_id, raw_file_name) => {
|
|
|
42
42
|
if (raw_file_name === '') {
|
|
43
43
|
throw Error(`Output file name cannot be an empty string`);
|
|
44
44
|
}
|
|
45
|
-
const filename = raw_file_name
|
|
45
|
+
const filename = raw_file_name ?? to_output_file_name(basename(origin_id));
|
|
46
46
|
if (isAbsolute(filename))
|
|
47
47
|
return filename;
|
|
48
48
|
const dir = dirname(origin_id);
|
|
@@ -132,7 +132,7 @@ export const write_gen_results = async (gen_results, analyzed_gen_results, log)
|
|
|
132
132
|
/**
|
|
133
133
|
* Finds modules from input paths. (see `src/lib/input_path.ts` for more)
|
|
134
134
|
*/
|
|
135
|
-
export const find_genfiles =
|
|
135
|
+
export const find_genfiles = (input_paths, root_dirs, config, timings) => {
|
|
136
136
|
const extensions = [GEN_FILE_PATTERN];
|
|
137
137
|
// Check which extension variation works - if it's a directory, prefer others first!
|
|
138
138
|
const timing_to_resolve_input_paths = timings?.start('resolve input paths');
|
|
@@ -186,4 +186,4 @@ export const load_genfiles = async (found_genfiles, timings) => {
|
|
|
186
186
|
value: { modules: loaded_modules.modules, found_genfiles },
|
|
187
187
|
};
|
|
188
188
|
};
|
|
189
|
-
export const validate_gen_module = (mod) => typeof mod
|
|
189
|
+
export const validate_gen_module = (mod) => typeof mod.gen === 'function';
|
package/dist/gen.task.js
CHANGED
|
@@ -30,7 +30,7 @@ export const task = {
|
|
|
30
30
|
const { _: raw_input_paths, root_dirs, check } = args;
|
|
31
31
|
const input_paths = to_input_paths(raw_input_paths);
|
|
32
32
|
// load all of the gen modules
|
|
33
|
-
const found =
|
|
33
|
+
const found = find_genfiles(input_paths, root_dirs, config, timings);
|
|
34
34
|
if (!found.ok) {
|
|
35
35
|
if (found.type === 'input_directories_with_no_files') {
|
|
36
36
|
// TODO maybe let this error like the normal case, but only call `gro gen` if we find gen files? problem is the args would need to be hoisted to callers like `gro sync`
|
package/dist/gen.test.js
CHANGED
|
@@ -239,12 +239,9 @@ test('validate_gen_module basic behavior', () => {
|
|
|
239
239
|
assert.ok(validate_gen_module({ gen: Function.prototype }));
|
|
240
240
|
assert.ok(!validate_gen_module({ gen: {} }));
|
|
241
241
|
assert.ok(!validate_gen_module({ task: { run: {} } }));
|
|
242
|
-
assert.ok(!validate_gen_module(undefined));
|
|
243
|
-
assert.ok(!validate_gen_module(null));
|
|
244
|
-
assert.ok(!validate_gen_module(false));
|
|
245
242
|
});
|
|
246
|
-
test('find_genfiles_result finds gen modules in a directory',
|
|
247
|
-
const find_genfiles_result =
|
|
243
|
+
test('find_genfiles_result finds gen modules in a directory', () => {
|
|
244
|
+
const find_genfiles_result = find_genfiles(['docs'], [paths.lib], create_empty_config());
|
|
248
245
|
assert.ok(find_genfiles_result.ok);
|
|
249
246
|
assert.ok(find_genfiles_result.value.resolved_input_paths.length);
|
|
250
247
|
});
|
package/dist/git.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ export declare const git_pull: (origin?: Git_Origin, branch?: Git_Branch, option
|
|
|
42
42
|
/**
|
|
43
43
|
* Calls `git push` and throws if anything goes wrong.
|
|
44
44
|
*/
|
|
45
|
-
export declare const git_push: (origin: Git_Origin, branch
|
|
45
|
+
export declare const git_push: (origin: Git_Origin, branch?: Git_Branch, options?: SpawnOptions, set_upstream?: boolean) => Promise<void>;
|
|
46
46
|
/**
|
|
47
47
|
* Calls `git push` and throws if anything goes wrong.
|
|
48
48
|
*/
|
|
@@ -13,7 +13,7 @@ import { has_sveltekit_app, has_sveltekit_library } from './sveltekit_helpers.js
|
|
|
13
13
|
*/
|
|
14
14
|
const config = async (cfg) => {
|
|
15
15
|
const [has_sveltekit_library_result, has_server_result, has_sveltekit_app_result] = await Promise.all([has_sveltekit_library(), has_server(), has_sveltekit_app()]);
|
|
16
|
-
cfg.plugins =
|
|
16
|
+
cfg.plugins = () => [
|
|
17
17
|
has_sveltekit_library_result.ok ? gro_plugin_sveltekit_library() : null,
|
|
18
18
|
has_server_result.ok ? gro_plugin_server() : null,
|
|
19
19
|
has_sveltekit_app_result.ok
|
package/dist/gro.js
CHANGED
|
@@ -15,5 +15,5 @@ const invoke_path = resolve_gro_module_path('invoke.js');
|
|
|
15
15
|
const loader_path = join(invoke_path, '../loader.js');
|
|
16
16
|
const spawned = await spawn_with_loader(loader_path, invoke_path, process.argv.slice(2));
|
|
17
17
|
if (!spawned.ok) {
|
|
18
|
-
process.exit(spawned.code || 1);
|
|
18
|
+
process.exit(spawned.code || 1); // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing
|
|
19
19
|
}
|
package/dist/gro_helpers.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { realpathSync } from 'node:fs';
|
|
1
|
+
import { realpathSync, existsSync } from 'node:fs';
|
|
2
2
|
import { join, resolve } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { spawn } from '@ryanatkn/belt/process.js';
|
|
5
|
-
import { existsSync } from 'node:fs';
|
|
6
5
|
import { NODE_MODULES_DIRNAME, SVELTEKIT_DIST_DIRNAME } from './path_constants.js';
|
|
7
6
|
/*
|
|
8
7
|
|
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;
|