@fuzdev/gro 0.192.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/LICENSE +21 -0
- package/README.md +283 -0
- package/dist/args.d.ts +37 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +102 -0
- package/dist/build.task.d.ts +20 -0
- package/dist/build.task.d.ts.map +1 -0
- package/dist/build.task.js +119 -0
- package/dist/build_cache.d.ts +100 -0
- package/dist/build_cache.d.ts.map +1 -0
- package/dist/build_cache.js +299 -0
- package/dist/changelog.d.ts +11 -0
- package/dist/changelog.d.ts.map +1 -0
- package/dist/changelog.js +47 -0
- package/dist/changeset.task.d.ts +35 -0
- package/dist/changeset.task.d.ts.map +1 -0
- package/dist/changeset.task.js +151 -0
- package/dist/changeset_helpers.d.ts +17 -0
- package/dist/changeset_helpers.d.ts.map +1 -0
- package/dist/changeset_helpers.js +7 -0
- package/dist/check.task.d.ts +28 -0
- package/dist/check.task.d.ts.map +1 -0
- package/dist/check.task.js +104 -0
- 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 +15 -0
- package/dist/clean.task.d.ts.map +1 -0
- package/dist/clean.task.js +40 -0
- package/dist/clean_fs.d.ts +9 -0
- package/dist/clean_fs.d.ts.map +1 -0
- package/dist/clean_fs.js +28 -0
- package/dist/cli.d.ts +34 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +61 -0
- package/dist/commit.task.d.ts +11 -0
- package/dist/commit.task.d.ts.map +1 -0
- package/dist/commit.task.js +24 -0
- package/dist/constants.d.ts +46 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +52 -0
- package/dist/deploy.task.d.ts +29 -0
- package/dist/deploy.task.d.ts.map +1 -0
- package/dist/deploy.task.js +217 -0
- package/dist/dev.task.d.ts +16 -0
- package/dist/dev.task.d.ts.map +1 -0
- package/dist/dev.task.js +44 -0
- package/dist/disknode.d.ts +23 -0
- package/dist/disknode.d.ts.map +1 -0
- package/dist/disknode.js +1 -0
- package/dist/env.d.ts +11 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +49 -0
- package/dist/esbuild_helpers.d.ts +16 -0
- package/dist/esbuild_helpers.d.ts.map +1 -0
- package/dist/esbuild_helpers.js +36 -0
- package/dist/esbuild_plugin_external_worker.d.ts +23 -0
- package/dist/esbuild_plugin_external_worker.d.ts.map +1 -0
- package/dist/esbuild_plugin_external_worker.js +55 -0
- package/dist/esbuild_plugin_svelte.d.ts +15 -0
- package/dist/esbuild_plugin_svelte.d.ts.map +1 -0
- package/dist/esbuild_plugin_svelte.js +83 -0
- package/dist/esbuild_plugin_sveltekit_local_imports.d.ts +8 -0
- package/dist/esbuild_plugin_sveltekit_local_imports.d.ts.map +1 -0
- package/dist/esbuild_plugin_sveltekit_local_imports.js +30 -0
- package/dist/esbuild_plugin_sveltekit_shim_alias.d.ts +7 -0
- package/dist/esbuild_plugin_sveltekit_shim_alias.d.ts.map +1 -0
- package/dist/esbuild_plugin_sveltekit_shim_alias.js +18 -0
- package/dist/esbuild_plugin_sveltekit_shim_app.d.ts +9 -0
- package/dist/esbuild_plugin_sveltekit_shim_app.d.ts.map +1 -0
- package/dist/esbuild_plugin_sveltekit_shim_app.js +22 -0
- package/dist/esbuild_plugin_sveltekit_shim_env.d.ts +11 -0
- package/dist/esbuild_plugin_sveltekit_shim_env.d.ts.map +1 -0
- package/dist/esbuild_plugin_sveltekit_shim_env.js +18 -0
- package/dist/filer.d.ts +33 -0
- package/dist/filer.d.ts.map +1 -0
- package/dist/filer.js +385 -0
- package/dist/format.task.d.ts +11 -0
- package/dist/format.task.d.ts.map +1 -0
- package/dist/format.task.js +27 -0
- package/dist/format_directory.d.ts +13 -0
- package/dist/format_directory.d.ts.map +1 -0
- package/dist/format_directory.js +40 -0
- package/dist/format_file.d.ts +9 -0
- package/dist/format_file.d.ts.map +1 -0
- package/dist/format_file.js +42 -0
- package/dist/gen.d.ts +142 -0
- package/dist/gen.d.ts.map +1 -0
- package/dist/gen.js +199 -0
- package/dist/gen.task.d.ts +12 -0
- package/dist/gen.task.d.ts.map +1 -0
- package/dist/gen.task.js +149 -0
- package/dist/gen_helpers.d.ts +11 -0
- package/dist/gen_helpers.d.ts.map +1 -0
- package/dist/gen_helpers.js +76 -0
- package/dist/github.d.ts +19 -0
- package/dist/github.d.ts.map +1 -0
- package/dist/github.js +33 -0
- package/dist/gro.config.default.d.ts +13 -0
- package/dist/gro.config.default.d.ts.map +1 -0
- package/dist/gro.config.default.js +33 -0
- package/dist/gro.d.ts +3 -0
- package/dist/gro.d.ts.map +1 -0
- package/dist/gro.js +21 -0
- package/dist/gro_config.d.ts +115 -0
- package/dist/gro_config.d.ts.map +1 -0
- package/dist/gro_config.js +114 -0
- package/dist/gro_helpers.d.ts +49 -0
- package/dist/gro_helpers.d.ts.map +1 -0
- package/dist/gro_helpers.js +97 -0
- package/dist/gro_plugin_gen.d.ts +12 -0
- package/dist/gro_plugin_gen.d.ts.map +1 -0
- package/dist/gro_plugin_gen.js +101 -0
- package/dist/gro_plugin_server.d.ts +80 -0
- package/dist/gro_plugin_server.d.ts.map +1 -0
- package/dist/gro_plugin_server.js +167 -0
- package/dist/gro_plugin_sveltekit_app.d.ts +9 -0
- package/dist/gro_plugin_sveltekit_app.d.ts.map +1 -0
- package/dist/gro_plugin_sveltekit_app.js +42 -0
- package/dist/gro_plugin_sveltekit_library.d.ts +16 -0
- package/dist/gro_plugin_sveltekit_library.d.ts.map +1 -0
- package/dist/gro_plugin_sveltekit_library.js +34 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/input_path.d.ts +64 -0
- package/dist/input_path.d.ts.map +1 -0
- package/dist/input_path.js +199 -0
- package/dist/invoke.d.ts +2 -0
- package/dist/invoke.d.ts.map +1 -0
- package/dist/invoke.js +28 -0
- package/dist/invoke_task.d.ts +30 -0
- package/dist/invoke_task.d.ts.map +1 -0
- package/dist/invoke_task.js +104 -0
- package/dist/lint.task.d.ts +11 -0
- package/dist/lint.task.d.ts.map +1 -0
- package/dist/lint.task.js +32 -0
- package/dist/loader.d.ts +6 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +192 -0
- package/dist/module.d.ts +4 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +6 -0
- package/dist/modules.d.ts +36 -0
- package/dist/modules.d.ts.map +1 -0
- package/dist/modules.js +71 -0
- package/dist/package_json.d.ts +32 -0
- package/dist/package_json.d.ts.map +1 -0
- package/dist/package_json.js +178 -0
- package/dist/parse_exports.d.ts +20 -0
- package/dist/parse_exports.d.ts.map +1 -0
- package/dist/parse_exports.js +65 -0
- package/dist/parse_exports_context.d.ts +21 -0
- package/dist/parse_exports_context.d.ts.map +1 -0
- package/dist/parse_exports_context.js +332 -0
- package/dist/parse_imports.d.ts +5 -0
- package/dist/parse_imports.d.ts.map +1 -0
- package/dist/parse_imports.js +140 -0
- package/dist/paths.d.ts +41 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +69 -0
- package/dist/plugin.d.ts +36 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +78 -0
- package/dist/publish.task.d.ts +26 -0
- package/dist/publish.task.d.ts.map +1 -0
- package/dist/publish.task.js +176 -0
- package/dist/register.d.ts +2 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +2 -0
- package/dist/reinstall.task.d.ts +8 -0
- package/dist/reinstall.task.d.ts.map +1 -0
- package/dist/reinstall.task.js +35 -0
- package/dist/release.task.d.ts +8 -0
- package/dist/release.task.d.ts.map +1 -0
- package/dist/release.task.js +20 -0
- package/dist/resolve.task.d.ts +11 -0
- package/dist/resolve.task.d.ts.map +1 -0
- package/dist/resolve.task.js +38 -0
- package/dist/resolve_specifier.d.ts +22 -0
- package/dist/resolve_specifier.d.ts.map +1 -0
- package/dist/resolve_specifier.js +57 -0
- package/dist/run.task.d.ts +16 -0
- package/dist/run.task.d.ts.map +1 -0
- package/dist/run.task.js +52 -0
- package/dist/run_gen.d.ts +10 -0
- package/dist/run_gen.d.ts.map +1 -0
- package/dist/run_gen.js +73 -0
- package/dist/run_task.d.ts +17 -0
- package/dist/run_task.d.ts.map +1 -0
- package/dist/run_task.js +45 -0
- package/dist/source_json.d.ts +7 -0
- package/dist/source_json.d.ts.map +1 -0
- package/dist/source_json.js +145 -0
- package/dist/svelte_config.d.ts +57 -0
- package/dist/svelte_config.d.ts.map +1 -0
- package/dist/svelte_config.js +81 -0
- package/dist/sveltekit_helpers.d.ts +75 -0
- package/dist/sveltekit_helpers.d.ts.map +1 -0
- package/dist/sveltekit_helpers.js +94 -0
- package/dist/sveltekit_shim_app.d.ts +11 -0
- package/dist/sveltekit_shim_app.d.ts.map +1 -0
- package/dist/sveltekit_shim_app.js +31 -0
- package/dist/sveltekit_shim_app_environment.d.ts +13 -0
- package/dist/sveltekit_shim_app_environment.d.ts.map +1 -0
- package/dist/sveltekit_shim_app_environment.js +14 -0
- package/dist/sveltekit_shim_app_forms.d.ts +5 -0
- package/dist/sveltekit_shim_app_forms.d.ts.map +1 -0
- package/dist/sveltekit_shim_app_forms.js +6 -0
- package/dist/sveltekit_shim_app_navigation.d.ts +10 -0
- package/dist/sveltekit_shim_app_navigation.d.ts.map +1 -0
- package/dist/sveltekit_shim_app_navigation.js +11 -0
- package/dist/sveltekit_shim_app_paths.d.ts +17 -0
- package/dist/sveltekit_shim_app_paths.d.ts.map +1 -0
- package/dist/sveltekit_shim_app_paths.js +10 -0
- package/dist/sveltekit_shim_app_state.d.ts +5 -0
- package/dist/sveltekit_shim_app_state.d.ts.map +1 -0
- package/dist/sveltekit_shim_app_state.js +26 -0
- package/dist/sveltekit_shim_env.d.ts +5 -0
- package/dist/sveltekit_shim_env.d.ts.map +1 -0
- package/dist/sveltekit_shim_env.js +23 -0
- package/dist/sync.task.d.ts +16 -0
- package/dist/sync.task.d.ts.map +1 -0
- package/dist/sync.task.js +39 -0
- package/dist/task.d.ts +98 -0
- package/dist/task.d.ts.map +1 -0
- package/dist/task.js +109 -0
- package/dist/task_logging.d.ts +6 -0
- package/dist/task_logging.d.ts.map +1 -0
- package/dist/task_logging.js +201 -0
- package/dist/test.task.d.ts +13 -0
- package/dist/test.task.d.ts.map +1 -0
- package/dist/test.task.js +53 -0
- package/dist/typecheck.task.d.ts +13 -0
- package/dist/typecheck.task.d.ts.map +1 -0
- package/dist/typecheck.task.js +68 -0
- package/dist/upgrade.task.d.ts +20 -0
- package/dist/upgrade.task.d.ts.map +1 -0
- package/dist/upgrade.task.js +111 -0
- package/dist/watch_dir.d.ts +36 -0
- package/dist/watch_dir.d.ts.map +1 -0
- package/dist/watch_dir.js +69 -0
- package/package.json +149 -0
- package/src/lib/args.ts +115 -0
- package/src/lib/build.task.ts +151 -0
- package/src/lib/build_cache.ts +378 -0
- package/src/lib/changelog.ts +69 -0
- package/src/lib/changeset.task.ts +228 -0
- package/src/lib/changeset_helpers.ts +14 -0
- package/src/lib/check.task.ts +132 -0
- package/src/lib/child_process_logging.ts +38 -0
- package/src/lib/clean.task.ts +48 -0
- package/src/lib/clean_fs.ts +54 -0
- package/src/lib/cli.ts +98 -0
- package/src/lib/commit.task.ts +34 -0
- package/src/lib/constants.ts +56 -0
- package/src/lib/deploy.task.ts +287 -0
- package/src/lib/dev.task.ts +52 -0
- package/src/lib/disknode.ts +26 -0
- package/src/lib/env.ts +78 -0
- package/src/lib/esbuild_helpers.ts +49 -0
- package/src/lib/esbuild_plugin_external_worker.ts +94 -0
- package/src/lib/esbuild_plugin_svelte.ts +134 -0
- package/src/lib/esbuild_plugin_sveltekit_local_imports.ts +38 -0
- package/src/lib/esbuild_plugin_sveltekit_shim_alias.ts +27 -0
- package/src/lib/esbuild_plugin_sveltekit_shim_app.ts +42 -0
- package/src/lib/esbuild_plugin_sveltekit_shim_env.ts +47 -0
- package/src/lib/filer.ts +458 -0
- package/src/lib/format.task.ts +44 -0
- package/src/lib/format_directory.ts +65 -0
- package/src/lib/format_file.ts +49 -0
- package/src/lib/gen.task.ts +206 -0
- package/src/lib/gen.ts +406 -0
- package/src/lib/gen_helpers.ts +131 -0
- package/src/lib/github.ts +46 -0
- package/src/lib/gro.config.default.ts +42 -0
- package/src/lib/gro.ts +29 -0
- package/src/lib/gro_config.ts +254 -0
- package/src/lib/gro_helpers.ts +108 -0
- package/src/lib/gro_plugin_gen.ts +149 -0
- package/src/lib/gro_plugin_server.ts +288 -0
- package/src/lib/gro_plugin_sveltekit_app.ts +58 -0
- package/src/lib/gro_plugin_sveltekit_library.ts +63 -0
- package/src/lib/index.ts +8 -0
- package/src/lib/input_path.ts +254 -0
- package/src/lib/invoke.ts +34 -0
- package/src/lib/invoke_task.ts +139 -0
- package/src/lib/lint.task.ts +39 -0
- package/src/lib/loader.ts +229 -0
- package/src/lib/module.ts +13 -0
- package/src/lib/modules.ts +117 -0
- package/src/lib/package_json.ts +255 -0
- package/src/lib/parse_exports.ts +100 -0
- package/src/lib/parse_exports_context.ts +395 -0
- package/src/lib/parse_imports.ts +180 -0
- package/src/lib/paths.ts +111 -0
- package/src/lib/plugin.ts +106 -0
- package/src/lib/publish.task.ts +228 -0
- package/src/lib/register.ts +3 -0
- package/src/lib/reinstall.task.ts +45 -0
- package/src/lib/release.task.ts +26 -0
- package/src/lib/resolve.task.ts +43 -0
- package/src/lib/resolve_specifier.ts +81 -0
- package/src/lib/run.task.ts +65 -0
- package/src/lib/run_gen.ts +110 -0
- package/src/lib/run_task.ts +82 -0
- package/src/lib/source_json.ts +183 -0
- package/src/lib/svelte_config.ts +140 -0
- package/src/lib/sveltekit_helpers.ts +193 -0
- package/src/lib/sveltekit_shim_app.ts +41 -0
- package/src/lib/sveltekit_shim_app_environment.ts +16 -0
- package/src/lib/sveltekit_shim_app_forms.ts +13 -0
- package/src/lib/sveltekit_shim_app_navigation.ts +23 -0
- package/src/lib/sveltekit_shim_app_paths.ts +26 -0
- package/src/lib/sveltekit_shim_app_state.ts +35 -0
- package/src/lib/sveltekit_shim_env.ts +45 -0
- package/src/lib/sync.task.ts +47 -0
- package/src/lib/task.ts +245 -0
- package/src/lib/task_logging.ts +255 -0
- package/src/lib/test.task.ts +63 -0
- package/src/lib/typecheck.task.ts +81 -0
- package/src/lib/upgrade.task.ts +148 -0
- package/src/lib/watch_dir.ts +115 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type {ParsedSvelteConfig} from './svelte_config.ts';
|
|
2
|
+
|
|
3
|
+
export const SVELTEKIT_SHIM_APP_PATHS_MATCHER = /\/util\/sveltekit_shim_app_paths\.js$/;
|
|
4
|
+
export const SVELTEKIT_SHIM_APP_ENVIRONMENT_MATCHER = /\/util\/sveltekit_shim_app_environment\.js$/;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Maps SvelteKit `$app` specifiers to their Gro shims.
|
|
8
|
+
* @see https://kit.svelte.dev/docs/modules
|
|
9
|
+
*/
|
|
10
|
+
export const sveltekit_shim_app_specifiers = new Map([
|
|
11
|
+
['$app/environment', '@fuzdev/gro/sveltekit_shim_app_environment.js'],
|
|
12
|
+
['$app/forms', '@fuzdev/gro/sveltekit_shim_app_forms.js'],
|
|
13
|
+
['$app/navigation', '@fuzdev/gro/sveltekit_shim_app_navigation.js'],
|
|
14
|
+
['$app/paths', '@fuzdev/gro/sveltekit_shim_app_paths.js'],
|
|
15
|
+
['$app/state', '@fuzdev/gro/sveltekit_shim_app_state.js'],
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
export const render_sveltekit_shim_app_paths = (
|
|
19
|
+
base_url: ParsedSvelteConfig['base_url'] = '',
|
|
20
|
+
assets_url: ParsedSvelteConfig['assets_url'] = '',
|
|
21
|
+
): string => `// shim for $app/paths
|
|
22
|
+
// @see https://github.com/sveltejs/kit/issues/1485
|
|
23
|
+
|
|
24
|
+
export const assets = ${JSON.stringify(assets_url)};
|
|
25
|
+
export const base = ${JSON.stringify(base_url)};
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
// TODO improve support
|
|
29
|
+
// `dev` is not guaranteed to be the same as `MODE` - https://kit.svelte.dev/docs/modules#$app-environment-dev
|
|
30
|
+
// `version` is `config.kit.version.name` but I couldn't see how to load a SvelteKit `ValidatedConfig`
|
|
31
|
+
// `building` is just being hardcoded, might be better (but still not correct) to be `!dev`
|
|
32
|
+
export const render_sveltekit_shim_app_environment = (
|
|
33
|
+
dev: boolean,
|
|
34
|
+
): string => `// shim for $app/environment
|
|
35
|
+
// @see https://github.com/sveltejs/kit/issues/1485
|
|
36
|
+
|
|
37
|
+
export const browser = false;
|
|
38
|
+
export const building = false;
|
|
39
|
+
export const dev = ${JSON.stringify(dev)};
|
|
40
|
+
export const version = 'TODO';
|
|
41
|
+
`;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// shim for $app/environment
|
|
2
|
+
// @see https://github.com/sveltejs/kit/issues/1485
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This file is created dynamically by `render_sveltekit_shim_app_environment`
|
|
6
|
+
* but exists here for the sake of the Node loader.
|
|
7
|
+
* There may be a cleaner workaround but I couldn't find it.
|
|
8
|
+
* @see https://github.com/nodejs/loaders for details about the forthcoming virtual file support
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const browser = false;
|
|
14
|
+
export const building = false;
|
|
15
|
+
export const dev = true;
|
|
16
|
+
export const version = 'TODO';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// shim for $app/forms
|
|
2
|
+
// @see https://github.com/sveltejs/kit/issues/1485
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
applyAction as base_applyAction,
|
|
6
|
+
deserialize as base_deserialize,
|
|
7
|
+
enhance as base_enhance,
|
|
8
|
+
} from '$app/forms';
|
|
9
|
+
import {noop, noop_async} from '@fuzdev/fuz_util/function.js';
|
|
10
|
+
|
|
11
|
+
export const applyAction: typeof base_applyAction = noop_async;
|
|
12
|
+
export const deserialize: typeof base_deserialize = () => ({}) as any;
|
|
13
|
+
export const enhance: typeof base_enhance = () => ({destroy: noop});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// shim for $app/navigation
|
|
2
|
+
// @see https://github.com/sveltejs/kit/issues/1485
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
afterNavigate as base_afterNavigate,
|
|
6
|
+
beforeNavigate as base_beforeNavigate,
|
|
7
|
+
disableScrollHandling as base_disableScrollHandling,
|
|
8
|
+
goto as base_goto,
|
|
9
|
+
invalidate as base_invalidate,
|
|
10
|
+
invalidateAll as base_invalidateAll,
|
|
11
|
+
preloadCode as base_preloadCode,
|
|
12
|
+
preloadData as base_preloadData,
|
|
13
|
+
} from '$app/navigation';
|
|
14
|
+
import {noop, noop_async} from '@fuzdev/fuz_util/function.js';
|
|
15
|
+
|
|
16
|
+
export const afterNavigate: typeof base_afterNavigate = noop;
|
|
17
|
+
export const beforeNavigate: typeof base_beforeNavigate = noop;
|
|
18
|
+
export const disableScrollHandling: typeof base_disableScrollHandling = noop;
|
|
19
|
+
export const goto: typeof base_goto = noop_async;
|
|
20
|
+
export const invalidate: typeof base_invalidate = noop_async;
|
|
21
|
+
export const invalidateAll: typeof base_invalidateAll = noop_async;
|
|
22
|
+
export const preloadCode: typeof base_preloadCode = noop_async;
|
|
23
|
+
export const preloadData: typeof base_preloadData = noop_async;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// shim for $app/paths
|
|
2
|
+
// @see https://github.com/sveltejs/kit/issues/1485
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This file is created dynamically by `render_sveltekit_shim_app_paths`
|
|
6
|
+
* but exists here for the sake of the Node loader.
|
|
7
|
+
* There may be a cleaner workaround but I couldn't find it.
|
|
8
|
+
* @see https://github.com/nodejs/loaders for details about the forthcoming virtual file support
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type {
|
|
14
|
+
resolve as base_resolve,
|
|
15
|
+
asset as base_asset,
|
|
16
|
+
resolveRoute as base_resolveRoute,
|
|
17
|
+
} from '$app/paths';
|
|
18
|
+
import {noop} from '@fuzdev/fuz_util/function.js';
|
|
19
|
+
|
|
20
|
+
export const assets = '';
|
|
21
|
+
/** @deprecated */
|
|
22
|
+
export const base = '';
|
|
23
|
+
export const resolve: typeof base_resolve = (v, ..._rest) => ('/' + v.replace(/^\//, '')) as any; // TODO needs to use SvelteKit config base
|
|
24
|
+
/** @deprecated */
|
|
25
|
+
export const resolveRoute: typeof base_resolveRoute = noop; // eslint-disable-line @typescript-eslint/no-deprecated
|
|
26
|
+
export const asset: typeof base_asset = (v) => ('/' + v.replace(/^\//, '')) as any; // TODO needs to use SvelteKit config base
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// shim for $app/state
|
|
2
|
+
// @see https://github.com/sveltejs/kit/issues/1485
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
navigating as base_navigating,
|
|
6
|
+
page as base_page,
|
|
7
|
+
updated as base_updated,
|
|
8
|
+
} from '$app/state';
|
|
9
|
+
|
|
10
|
+
export const navigating: typeof base_navigating = {
|
|
11
|
+
from: null,
|
|
12
|
+
to: null,
|
|
13
|
+
type: null,
|
|
14
|
+
willUnload: null,
|
|
15
|
+
delta: null,
|
|
16
|
+
complete: null,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const page: typeof base_page = {
|
|
20
|
+
data: {},
|
|
21
|
+
form: null,
|
|
22
|
+
error: null,
|
|
23
|
+
params: {},
|
|
24
|
+
route: {id: null},
|
|
25
|
+
state: {},
|
|
26
|
+
status: -1,
|
|
27
|
+
url: new URL('https://github.com/fuzdev/gro') as any, // TODO maybe use package.json?
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const updated: typeof base_updated = {
|
|
31
|
+
current: false,
|
|
32
|
+
check: () => {
|
|
33
|
+
throw Error('Can only call updated.check() in the browser');
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {load_env} from './env.ts';
|
|
2
|
+
|
|
3
|
+
// TODO might want to do more escaping and validation
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Generates a module shim for SvelteKit's `$env` imports.
|
|
7
|
+
*/
|
|
8
|
+
export const render_env_shim_module = (
|
|
9
|
+
dev: boolean,
|
|
10
|
+
mode: 'static' | 'dynamic',
|
|
11
|
+
visibility: 'public' | 'private',
|
|
12
|
+
public_prefix = 'PUBLIC_',
|
|
13
|
+
private_prefix = '',
|
|
14
|
+
env_dir?: string,
|
|
15
|
+
env_files?: Array<string>,
|
|
16
|
+
ambient_env?: Record<string, string | undefined>,
|
|
17
|
+
): string => {
|
|
18
|
+
const env = load_env(
|
|
19
|
+
dev,
|
|
20
|
+
visibility,
|
|
21
|
+
public_prefix,
|
|
22
|
+
private_prefix,
|
|
23
|
+
env_dir,
|
|
24
|
+
env_files,
|
|
25
|
+
ambient_env,
|
|
26
|
+
);
|
|
27
|
+
if (mode === 'static') {
|
|
28
|
+
return `// shim for $env/static/${visibility}
|
|
29
|
+
// @see https://github.com/sveltejs/kit/issues/1485
|
|
30
|
+
${Object.entries(env)
|
|
31
|
+
.map(([k, v]) => `export let ${k} = ${JSON.stringify(v)};`)
|
|
32
|
+
.join('\n')}
|
|
33
|
+
`;
|
|
34
|
+
} else {
|
|
35
|
+
return `// shim for $env/dynamic/${visibility}
|
|
36
|
+
// @see https://github.com/sveltejs/kit/issues/1485
|
|
37
|
+
import {load_env} from '@fuzdev/gro/env.js';
|
|
38
|
+
export const env = load_env(${dev}, ${JSON.stringify(visibility)}, ${JSON.stringify(
|
|
39
|
+
public_prefix,
|
|
40
|
+
)}, ${JSON.stringify(private_prefix)}, ${JSON.stringify(env_dir)}, ${JSON.stringify(
|
|
41
|
+
env_files,
|
|
42
|
+
)}, ${JSON.stringify(ambient_env)});
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {z} from 'zod';
|
|
2
|
+
import {spawn} from '@fuzdev/fuz_util/process.js';
|
|
3
|
+
|
|
4
|
+
import {TaskError, type Task} from './task.ts';
|
|
5
|
+
import {package_json_sync} from './package_json.ts';
|
|
6
|
+
import {sveltekit_sync} from './sveltekit_helpers.ts';
|
|
7
|
+
|
|
8
|
+
/** @nodocs */
|
|
9
|
+
export const Args = z.strictObject({
|
|
10
|
+
sveltekit: z.boolean().meta({description: 'dual of no-sveltekit'}).default(true),
|
|
11
|
+
'no-sveltekit': z.boolean().meta({description: 'opt out of svelte-kit sync'}).default(false),
|
|
12
|
+
package_json: z.boolean().meta({description: 'dual of no-package_json'}).default(true),
|
|
13
|
+
'no-package_json': z.boolean().meta({description: 'opt out of package.json sync'}).default(false),
|
|
14
|
+
gen: z.boolean().meta({description: 'dual of no-gen'}).default(true),
|
|
15
|
+
'no-gen': z.boolean().meta({description: 'opt out of running gen'}).default(false),
|
|
16
|
+
install: z.boolean().meta({description: 'opt into installing packages'}).default(false),
|
|
17
|
+
});
|
|
18
|
+
export type Args = z.infer<typeof Args>;
|
|
19
|
+
|
|
20
|
+
/** @nodocs */
|
|
21
|
+
export const task: Task<Args> = {
|
|
22
|
+
summary: 'run `gro gen`, update `package.json`, and optionally install packages to sync up',
|
|
23
|
+
Args,
|
|
24
|
+
run: async ({args, invoke_task, config, log}): Promise<void> => {
|
|
25
|
+
const {sveltekit, package_json, gen, install} = args;
|
|
26
|
+
|
|
27
|
+
if (install) {
|
|
28
|
+
const result = await spawn(config.pm_cli, ['install']);
|
|
29
|
+
if (!result.ok) {
|
|
30
|
+
throw new TaskError(`Failed \`${config.pm_cli} install\``);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (sveltekit) {
|
|
35
|
+
await sveltekit_sync(undefined, config.pm_cli);
|
|
36
|
+
log.info('synced SvelteKit');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (package_json && config.map_package_json) {
|
|
40
|
+
await package_json_sync(config.map_package_json, log);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (gen) {
|
|
44
|
+
await invoke_task('gen');
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
};
|
package/src/lib/task.ts
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import type {Args} from '@fuzdev/fuz_util/args.js';
|
|
2
|
+
import {fs_search} from '@fuzdev/fuz_util/fs.js';
|
|
3
|
+
import type {Logger} from '@fuzdev/fuz_util/log.js';
|
|
4
|
+
import type {PathId} from '@fuzdev/fuz_util/path.js';
|
|
5
|
+
import type {Result} from '@fuzdev/fuz_util/result.js';
|
|
6
|
+
import {ensure_end, strip_end, strip_start} from '@fuzdev/fuz_util/string.js';
|
|
7
|
+
import type {Timings} from '@fuzdev/fuz_util/timings.js';
|
|
8
|
+
import {isAbsolute, join, relative} from 'node:path';
|
|
9
|
+
import {styleText as st} from 'node:util';
|
|
10
|
+
import type {z} from 'zod';
|
|
11
|
+
import type {GroConfig} from './gro_config.ts';
|
|
12
|
+
import type {ParsedSvelteConfig} from './svelte_config.ts';
|
|
13
|
+
import {
|
|
14
|
+
resolve_input_files,
|
|
15
|
+
resolve_input_paths,
|
|
16
|
+
type InputPath,
|
|
17
|
+
type ResolvedInputFile,
|
|
18
|
+
type ResolvedInputPath,
|
|
19
|
+
} from './input_path.ts';
|
|
20
|
+
import {GRO_DIST_DIR, print_path} from './paths.ts';
|
|
21
|
+
import {load_modules, type LoadModulesFailure, type ModuleMeta} from './modules.ts';
|
|
22
|
+
import type {Filer} from './filer.ts';
|
|
23
|
+
|
|
24
|
+
export interface Task<
|
|
25
|
+
TArgs = Args,
|
|
26
|
+
TArgsSchema extends z.ZodType<Args, Args> = z.ZodType<Args, Args>, // TODO improve type? separate input/output?
|
|
27
|
+
TReturn = unknown,
|
|
28
|
+
> {
|
|
29
|
+
run: (ctx: TaskContext<TArgs>) => TReturn | Promise<TReturn>; // TODO unused return value
|
|
30
|
+
summary?: string;
|
|
31
|
+
Args?: TArgsSchema;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface TaskContext<TArgs = object> {
|
|
35
|
+
args: TArgs;
|
|
36
|
+
config: GroConfig;
|
|
37
|
+
svelte_config: ParsedSvelteConfig;
|
|
38
|
+
filer: Filer;
|
|
39
|
+
log: Logger;
|
|
40
|
+
timings: Timings;
|
|
41
|
+
invoke_task: InvokeTask;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type InvokeTask = (task_name: string, args?: Args, config?: GroConfig) => Promise<void>;
|
|
45
|
+
|
|
46
|
+
export const TASK_FILE_SUFFIX_TS = '.task.ts';
|
|
47
|
+
export const TASK_FILE_SUFFIX_JS = '.task.js';
|
|
48
|
+
export const TASK_FILE_SUFFIXES = [TASK_FILE_SUFFIX_TS, TASK_FILE_SUFFIX_JS]; // TODO from `GroConfig`, but needs to be used everywhere the constants are
|
|
49
|
+
|
|
50
|
+
export const is_task_path = (path: string): boolean =>
|
|
51
|
+
path.endsWith(TASK_FILE_SUFFIX_TS) || path.endsWith(TASK_FILE_SUFFIX_JS);
|
|
52
|
+
|
|
53
|
+
export const to_task_name = (
|
|
54
|
+
id: PathId,
|
|
55
|
+
task_root_dir: PathId,
|
|
56
|
+
input_path: InputPath,
|
|
57
|
+
root_path: PathId,
|
|
58
|
+
): string => {
|
|
59
|
+
let task_name = id.startsWith(task_root_dir)
|
|
60
|
+
? strip_start(strip_start(id, task_root_dir), '/')
|
|
61
|
+
: id;
|
|
62
|
+
for (const suffix of TASK_FILE_SUFFIXES) {
|
|
63
|
+
task_name = strip_end(task_name, suffix);
|
|
64
|
+
}
|
|
65
|
+
if (ensure_end(task_root_dir, '/') === GRO_DIST_DIR) {
|
|
66
|
+
// TODO ideally it would display this in some contexts like the task progress logs,
|
|
67
|
+
// but not all, like printing the task list, UNLESS there's a local override
|
|
68
|
+
// return 'gro/' + task_name;
|
|
69
|
+
return task_name;
|
|
70
|
+
}
|
|
71
|
+
if (isAbsolute(input_path)) {
|
|
72
|
+
return relative(root_path, join(task_root_dir, task_name));
|
|
73
|
+
}
|
|
74
|
+
return task_name;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* This is used by tasks to signal a known failure.
|
|
79
|
+
* It's useful for cleaning up logging because
|
|
80
|
+
* we usually don't need their stack trace.
|
|
81
|
+
*/
|
|
82
|
+
export class TaskError extends Error {}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* This is used to tell Gro to exit silently, usually still with with a non-zero exit code.
|
|
86
|
+
* Using it means error logging is handled by the code that threw it.
|
|
87
|
+
*/
|
|
88
|
+
export class SilentError extends Error {}
|
|
89
|
+
|
|
90
|
+
export interface FoundTask {
|
|
91
|
+
input_path: InputPath;
|
|
92
|
+
id: PathId;
|
|
93
|
+
task_root_dir: PathId;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface FoundTasks {
|
|
97
|
+
resolved_input_files: Array<ResolvedInputFile>;
|
|
98
|
+
resolved_input_files_by_root_dir: Map<PathId, Array<ResolvedInputFile>>;
|
|
99
|
+
resolved_input_paths: Array<ResolvedInputPath>;
|
|
100
|
+
input_paths: Array<InputPath>;
|
|
101
|
+
task_root_dirs: Array<PathId>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export type FindTasksResult = Result<{value: FoundTasks}, FindModulesFailure>;
|
|
105
|
+
export type FindModulesFailure =
|
|
106
|
+
| {
|
|
107
|
+
type: 'unmapped_input_paths';
|
|
108
|
+
unmapped_input_paths: Array<InputPath>;
|
|
109
|
+
resolved_input_paths: Array<ResolvedInputPath>;
|
|
110
|
+
input_paths: Array<InputPath>;
|
|
111
|
+
task_root_dirs: Array<PathId>;
|
|
112
|
+
reasons: Array<string>;
|
|
113
|
+
}
|
|
114
|
+
| {
|
|
115
|
+
type: 'input_directories_with_no_files';
|
|
116
|
+
input_directories_with_no_files: Array<InputPath>;
|
|
117
|
+
resolved_input_files: Array<ResolvedInputFile>;
|
|
118
|
+
resolved_input_files_by_root_dir: Map<PathId, Array<ResolvedInputFile>>;
|
|
119
|
+
resolved_input_paths: Array<ResolvedInputPath>;
|
|
120
|
+
input_paths: Array<InputPath>;
|
|
121
|
+
task_root_dirs: Array<PathId>;
|
|
122
|
+
reasons: Array<string>;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Finds modules from input paths. (see `src/lib/input_path.ts` for more)
|
|
127
|
+
*/
|
|
128
|
+
export const find_tasks = async (
|
|
129
|
+
input_paths: Array<InputPath>,
|
|
130
|
+
task_root_dirs: Array<PathId>,
|
|
131
|
+
config: GroConfig,
|
|
132
|
+
timings?: Timings,
|
|
133
|
+
): Promise<FindTasksResult> => {
|
|
134
|
+
// Check which extension variation works - if it's a directory, prefer others first!
|
|
135
|
+
const timing_to_resolve_input_paths = timings?.start('resolve input paths');
|
|
136
|
+
const {resolved_input_paths, unmapped_input_paths} = await resolve_input_paths(
|
|
137
|
+
input_paths,
|
|
138
|
+
task_root_dirs,
|
|
139
|
+
TASK_FILE_SUFFIXES,
|
|
140
|
+
);
|
|
141
|
+
timing_to_resolve_input_paths?.();
|
|
142
|
+
|
|
143
|
+
// Error if any input path could not be mapped.
|
|
144
|
+
if (unmapped_input_paths.length) {
|
|
145
|
+
return {
|
|
146
|
+
ok: false,
|
|
147
|
+
type: 'unmapped_input_paths',
|
|
148
|
+
unmapped_input_paths,
|
|
149
|
+
resolved_input_paths,
|
|
150
|
+
input_paths,
|
|
151
|
+
task_root_dirs,
|
|
152
|
+
reasons: unmapped_input_paths.map((input_path) =>
|
|
153
|
+
st('red', `Input path ${print_path(input_path)} cannot be mapped to a file or directory.`),
|
|
154
|
+
),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Find all of the files for any directories.
|
|
159
|
+
const timing_to_resolve_input_files = timings?.start('resolve input files');
|
|
160
|
+
const {resolved_input_files, resolved_input_files_by_root_dir, input_directories_with_no_files} =
|
|
161
|
+
await resolve_input_files(
|
|
162
|
+
resolved_input_paths,
|
|
163
|
+
async (id) =>
|
|
164
|
+
await fs_search(id, {
|
|
165
|
+
filter: config.search_filters,
|
|
166
|
+
file_filter: (p) => TASK_FILE_SUFFIXES.some((s) => p.endsWith(s)),
|
|
167
|
+
}),
|
|
168
|
+
);
|
|
169
|
+
timing_to_resolve_input_files?.();
|
|
170
|
+
|
|
171
|
+
// Error if any input path has no files. (means we have an empty directory)
|
|
172
|
+
if (input_directories_with_no_files.length) {
|
|
173
|
+
return {
|
|
174
|
+
ok: false,
|
|
175
|
+
type: 'input_directories_with_no_files',
|
|
176
|
+
input_directories_with_no_files,
|
|
177
|
+
resolved_input_files,
|
|
178
|
+
resolved_input_files_by_root_dir,
|
|
179
|
+
resolved_input_paths,
|
|
180
|
+
input_paths,
|
|
181
|
+
task_root_dirs,
|
|
182
|
+
reasons: input_directories_with_no_files.map((input_path) =>
|
|
183
|
+
st('red', `Input directory contains no matching files: ${print_path(input_path)}`),
|
|
184
|
+
),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return {
|
|
189
|
+
ok: true,
|
|
190
|
+
value: {
|
|
191
|
+
resolved_input_files,
|
|
192
|
+
resolved_input_files_by_root_dir,
|
|
193
|
+
resolved_input_paths,
|
|
194
|
+
input_paths,
|
|
195
|
+
task_root_dirs,
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export interface LoadedTasks {
|
|
201
|
+
modules: Array<TaskModuleMeta>;
|
|
202
|
+
found_tasks: FoundTasks;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface TaskModule {
|
|
206
|
+
task: Task;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export interface TaskModuleMeta extends ModuleMeta<TaskModule> {
|
|
210
|
+
name: string;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export type LoadTasksResult = Result<{value: LoadedTasks}, LoadTasksFailure>;
|
|
214
|
+
export type LoadTasksFailure = LoadModulesFailure<TaskModuleMeta>;
|
|
215
|
+
|
|
216
|
+
export const load_tasks = async (
|
|
217
|
+
found_tasks: FoundTasks,
|
|
218
|
+
root_path: PathId = process.cwd(), // TODO @many isn't passed in anywhere, maybe hoist to `invoke_task` and others
|
|
219
|
+
): Promise<LoadTasksResult> => {
|
|
220
|
+
const loaded_modules = await load_modules(
|
|
221
|
+
found_tasks.resolved_input_files,
|
|
222
|
+
validate_task_module,
|
|
223
|
+
(resolved_input_file, mod): TaskModuleMeta => ({
|
|
224
|
+
id: resolved_input_file.id,
|
|
225
|
+
mod,
|
|
226
|
+
name: to_task_name(
|
|
227
|
+
resolved_input_file.id,
|
|
228
|
+
resolved_input_file.resolved_input_path.root_dir,
|
|
229
|
+
resolved_input_file.resolved_input_path.input_path,
|
|
230
|
+
root_path,
|
|
231
|
+
),
|
|
232
|
+
}),
|
|
233
|
+
);
|
|
234
|
+
if (!loaded_modules.ok) {
|
|
235
|
+
return loaded_modules;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return {
|
|
239
|
+
ok: true,
|
|
240
|
+
value: {modules: loaded_modules.modules, found_tasks},
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
export const validate_task_module = (mod: Record<string, any>): mod is TaskModule =>
|
|
245
|
+
!!mod.task && typeof mod.task.run === 'function';
|