@ryanatkn/gro 0.151.2 → 0.153.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/dist/changeset.task.js +2 -2
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/esbuild_helpers.d.ts +2 -2
- package/dist/esbuild_helpers.d.ts.map +1 -1
- package/dist/esbuild_plugin_external_worker.d.ts +3 -3
- package/dist/esbuild_plugin_external_worker.d.ts.map +1 -1
- package/dist/esbuild_plugin_svelte.d.ts +2 -2
- package/dist/esbuild_plugin_svelte.d.ts.map +1 -1
- package/dist/esbuild_plugin_svelte.js +2 -2
- package/dist/esbuild_plugin_sveltekit_shim_app.d.ts +3 -3
- package/dist/esbuild_plugin_sveltekit_shim_app.d.ts.map +1 -1
- package/dist/filer.d.ts +1 -0
- package/dist/filer.d.ts.map +1 -1
- package/dist/filer.js +10 -9
- package/dist/format_directory.js +2 -2
- package/dist/gen.d.ts +2 -2
- package/dist/gen.d.ts.map +1 -1
- package/dist/gro.config.default.d.ts +4 -4
- package/dist/gro.config.default.d.ts.map +1 -1
- package/dist/gro.config.default.js +22 -12
- package/dist/gro_config.d.ts +4 -1
- package/dist/gro_config.d.ts.map +1 -1
- package/dist/gro_plugin_server.d.ts +5 -5
- package/dist/gro_plugin_server.d.ts.map +1 -1
- package/dist/gro_plugin_server.js +9 -6
- package/dist/gro_plugin_sveltekit_app.js +2 -2
- package/dist/invoke_task.js +1 -1
- package/dist/loader.js +2 -2
- package/dist/package.d.ts +14 -17
- package/dist/package.d.ts.map +1 -1
- package/dist/package.js +29 -33
- package/dist/package_json.d.ts +0 -1
- package/dist/package_json.d.ts.map +1 -1
- package/dist/package_json.js +0 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +3 -3
- package/dist/run_gen.js +2 -2
- package/dist/run_task.js +2 -2
- package/dist/search_fs.d.ts +1 -0
- package/dist/search_fs.d.ts.map +1 -1
- package/dist/search_fs.js +8 -0
- package/dist/{sveltekit_config.d.ts → svelte_config.d.ts} +16 -10
- package/dist/svelte_config.d.ts.map +1 -0
- package/dist/{sveltekit_config.js → svelte_config.js} +16 -12
- package/dist/sveltekit_helpers.d.ts +3 -3
- package/dist/sveltekit_helpers.d.ts.map +1 -1
- package/dist/sveltekit_helpers.js +8 -8
- package/dist/sveltekit_shim_app.d.ts +2 -2
- package/dist/sveltekit_shim_app.d.ts.map +1 -1
- package/dist/sveltekit_shim_app.js +1 -1
- 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/task.d.ts +2 -2
- package/dist/task.d.ts.map +1 -1
- package/dist/upgrade.task.d.ts +12 -0
- package/dist/upgrade.task.d.ts.map +1 -1
- package/dist/upgrade.task.js +29 -1
- package/package.json +17 -17
- package/src/lib/changeset.task.ts +2 -2
- package/src/lib/constants.ts +1 -1
- package/src/lib/esbuild_helpers.ts +2 -2
- package/src/lib/esbuild_plugin_external_worker.ts +3 -3
- package/src/lib/esbuild_plugin_svelte.ts +5 -5
- package/src/lib/esbuild_plugin_sveltekit_shim_app.ts +3 -3
- package/src/lib/filer.ts +13 -9
- package/src/lib/format_directory.ts +2 -2
- package/src/lib/gen.ts +2 -2
- package/src/lib/gro.config.default.ts +25 -12
- package/src/lib/gro_config.ts +4 -0
- package/src/lib/gro_plugin_server.ts +14 -11
- package/src/lib/gro_plugin_sveltekit_app.ts +2 -2
- package/src/lib/invoke_task.ts +1 -1
- package/src/lib/loader.ts +2 -2
- package/src/lib/package.ts +29 -33
- package/src/lib/package_json.ts +0 -5
- package/src/lib/paths.ts +3 -3
- package/src/lib/run_gen.ts +2 -2
- package/src/lib/run_task.ts +2 -2
- package/src/lib/search_fs.ts +9 -0
- package/src/lib/{sveltekit_config.ts → svelte_config.ts} +31 -21
- package/src/lib/sveltekit_helpers.ts +10 -8
- package/src/lib/sveltekit_shim_app.ts +4 -4
- package/src/lib/sveltekit_shim_app_state.ts +35 -0
- package/src/lib/task.ts +3 -3
- package/src/lib/upgrade.task.ts +43 -1
- package/dist/sveltekit_config.d.ts.map +0 -1
- package/dist/sveltekit_shim_app_stores.d.ts +0 -6
- package/dist/sveltekit_shim_app_stores.d.ts.map +0 -1
- package/dist/sveltekit_shim_app_stores.js +0 -17
- package/src/lib/sveltekit_shim_app_stores.ts +0 -28
package/src/lib/package.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {Src_Json} from './src_json.js';
|
|
|
5
5
|
|
|
6
6
|
export const package_json = {
|
|
7
7
|
name: '@ryanatkn/gro',
|
|
8
|
-
version: '0.
|
|
8
|
+
version: '0.153.0',
|
|
9
9
|
description: 'task runner and toolkit extending SvelteKit',
|
|
10
10
|
motto: 'generate, run, optimize',
|
|
11
11
|
glyph: '🌰',
|
|
@@ -49,32 +49,32 @@ export const package_json = {
|
|
|
49
49
|
dotenv: '^16.5.0',
|
|
50
50
|
'esm-env': '^1.2.2',
|
|
51
51
|
mri: '^1.2.0',
|
|
52
|
-
'oxc-parser': '^0.
|
|
52
|
+
'oxc-parser': '^0.67.0',
|
|
53
53
|
prettier: '^3.5.3',
|
|
54
54
|
'prettier-plugin-svelte': '^3.3.3',
|
|
55
55
|
'ts-morph': '^25.0.1',
|
|
56
56
|
tslib: '^2.8.1',
|
|
57
|
-
zod: '^3.24.
|
|
57
|
+
zod: '^3.24.3',
|
|
58
58
|
},
|
|
59
59
|
peerDependencies: {esbuild: '^0.25', svelte: '^5'},
|
|
60
60
|
devDependencies: {
|
|
61
61
|
'@changesets/changelog-git': '^0.2.1',
|
|
62
62
|
'@changesets/types': '^6.1.0',
|
|
63
63
|
'@ryanatkn/eslint-config': '^0.8.0',
|
|
64
|
-
'@ryanatkn/fuz': '^0.139.
|
|
64
|
+
'@ryanatkn/fuz': '^0.139.2',
|
|
65
65
|
'@ryanatkn/moss': '^0.26.0',
|
|
66
66
|
'@sveltejs/adapter-static': '^3.0.8',
|
|
67
|
-
'@sveltejs/kit': '^2.20.
|
|
67
|
+
'@sveltejs/kit': '^2.20.8',
|
|
68
68
|
'@sveltejs/package': '^2.3.11',
|
|
69
69
|
'@sveltejs/vite-plugin-svelte': '^5.0.3',
|
|
70
|
-
'@types/node': '^22.
|
|
71
|
-
esbuild: '^0.25.
|
|
72
|
-
eslint: '^9.
|
|
70
|
+
'@types/node': '^22.15.3',
|
|
71
|
+
esbuild: '^0.25.3',
|
|
72
|
+
eslint: '^9.25.1',
|
|
73
73
|
'eslint-plugin-svelte': '^3.5.1',
|
|
74
|
-
svelte: '^5.
|
|
74
|
+
svelte: '^5.28.2',
|
|
75
75
|
'svelte-check': '^4.1.6',
|
|
76
76
|
typescript: '^5.8.3',
|
|
77
|
-
'typescript-eslint': '^8.
|
|
77
|
+
'typescript-eslint': '^8.31.1',
|
|
78
78
|
uvu: '^0.5.6',
|
|
79
79
|
},
|
|
80
80
|
optionalDependencies: {'@ryanatkn/moss': '^0.26.0'},
|
|
@@ -211,14 +211,11 @@ export const package_json = {
|
|
|
211
211
|
'./run.task.js': {types: './dist/run.task.d.ts', default: './dist/run.task.js'},
|
|
212
212
|
'./search_fs.js': {types: './dist/search_fs.d.ts', default: './dist/search_fs.js'},
|
|
213
213
|
'./src_json.js': {types: './dist/src_json.d.ts', default: './dist/src_json.js'},
|
|
214
|
+
'./svelte_config.js': {types: './dist/svelte_config.d.ts', default: './dist/svelte_config.js'},
|
|
214
215
|
'./svelte_helpers.js': {
|
|
215
216
|
types: './dist/svelte_helpers.d.ts',
|
|
216
217
|
default: './dist/svelte_helpers.js',
|
|
217
218
|
},
|
|
218
|
-
'./sveltekit_config.js': {
|
|
219
|
-
types: './dist/sveltekit_config.d.ts',
|
|
220
|
-
default: './dist/sveltekit_config.js',
|
|
221
|
-
},
|
|
222
219
|
'./sveltekit_helpers.js': {
|
|
223
220
|
types: './dist/sveltekit_helpers.d.ts',
|
|
224
221
|
default: './dist/sveltekit_helpers.js',
|
|
@@ -239,9 +236,9 @@ export const package_json = {
|
|
|
239
236
|
types: './dist/sveltekit_shim_app_paths.d.ts',
|
|
240
237
|
default: './dist/sveltekit_shim_app_paths.js',
|
|
241
238
|
},
|
|
242
|
-
'./
|
|
243
|
-
types: './dist/
|
|
244
|
-
default: './dist/
|
|
239
|
+
'./sveltekit_shim_app_state.js': {
|
|
240
|
+
types: './dist/sveltekit_shim_app_state.d.ts',
|
|
241
|
+
default: './dist/sveltekit_shim_app_state.js',
|
|
245
242
|
},
|
|
246
243
|
'./sveltekit_shim_app.js': {
|
|
247
244
|
types: './dist/sveltekit_shim_app.d.ts',
|
|
@@ -266,7 +263,7 @@ export const package_json = {
|
|
|
266
263
|
|
|
267
264
|
export const src_json = {
|
|
268
265
|
name: '@ryanatkn/gro',
|
|
269
|
-
version: '0.
|
|
266
|
+
version: '0.153.0',
|
|
270
267
|
modules: {
|
|
271
268
|
'.': {
|
|
272
269
|
path: 'index.ts',
|
|
@@ -381,7 +378,7 @@ export const src_json = {
|
|
|
381
378
|
{name: 'GRO_DEV_DIR', kind: 'variable'},
|
|
382
379
|
{name: 'GRO_CONFIG_PATH', kind: 'variable'},
|
|
383
380
|
{name: 'README_FILENAME', kind: 'variable'},
|
|
384
|
-
{name: '
|
|
381
|
+
{name: 'SVELTE_CONFIG_FILENAME', kind: 'variable'},
|
|
385
382
|
{name: 'VITE_CONFIG_FILENAME', kind: 'variable'},
|
|
386
383
|
{name: 'NODE_MODULES_DIRNAME', kind: 'variable'},
|
|
387
384
|
{name: 'LOCKFILE_FILENAME', kind: 'variable'},
|
|
@@ -717,7 +714,6 @@ export const src_json = {
|
|
|
717
714
|
{name: 'update_package_json', kind: 'function'},
|
|
718
715
|
{name: 'to_package_exports', kind: 'function'},
|
|
719
716
|
{name: 'parse_repo_url', kind: 'function'},
|
|
720
|
-
{name: 'is_dep', kind: 'function'},
|
|
721
717
|
{name: 'has_dep', kind: 'function'},
|
|
722
718
|
{name: 'Package_Json_Dep', kind: 'type'},
|
|
723
719
|
{name: 'extract_deps', kind: 'function'},
|
|
@@ -853,6 +849,7 @@ export const src_json = {
|
|
|
853
849
|
declarations: [
|
|
854
850
|
{name: 'Search_Fs_Options', kind: 'type'},
|
|
855
851
|
{name: 'search_fs', kind: 'function'},
|
|
852
|
+
{name: 'find_first_existing_file', kind: 'function'},
|
|
856
853
|
],
|
|
857
854
|
},
|
|
858
855
|
'./src_json.js': {
|
|
@@ -868,6 +865,16 @@ export const src_json = {
|
|
|
868
865
|
{name: 'to_src_modules', kind: 'function'},
|
|
869
866
|
],
|
|
870
867
|
},
|
|
868
|
+
'./svelte_config.js': {
|
|
869
|
+
path: 'svelte_config.ts',
|
|
870
|
+
declarations: [
|
|
871
|
+
{name: 'load_svelte_config', kind: 'function'},
|
|
872
|
+
{name: 'Parsed_Svelte_Config', kind: 'type'},
|
|
873
|
+
{name: 'parse_svelte_config', kind: 'function'},
|
|
874
|
+
{name: 'to_default_compile_module_options', kind: 'function'},
|
|
875
|
+
{name: 'default_svelte_config', kind: 'variable'},
|
|
876
|
+
],
|
|
877
|
+
},
|
|
871
878
|
'./svelte_helpers.js': {
|
|
872
879
|
path: 'svelte_helpers.ts',
|
|
873
880
|
declarations: [
|
|
@@ -875,16 +882,6 @@ export const src_json = {
|
|
|
875
882
|
{name: 'SVELTE_RUNES_MATCHER', kind: 'variable'},
|
|
876
883
|
],
|
|
877
884
|
},
|
|
878
|
-
'./sveltekit_config.js': {
|
|
879
|
-
path: 'sveltekit_config.ts',
|
|
880
|
-
declarations: [
|
|
881
|
-
{name: 'load_sveltekit_config', kind: 'function'},
|
|
882
|
-
{name: 'Parsed_Sveltekit_Config', kind: 'type'},
|
|
883
|
-
{name: 'init_sveltekit_config', kind: 'function'},
|
|
884
|
-
{name: 'to_default_compile_module_options', kind: 'function'},
|
|
885
|
-
{name: 'default_sveltekit_config', kind: 'variable'},
|
|
886
|
-
],
|
|
887
|
-
},
|
|
888
885
|
'./sveltekit_helpers.js': {
|
|
889
886
|
path: 'sveltekit_helpers.ts',
|
|
890
887
|
declarations: [
|
|
@@ -943,10 +940,9 @@ export const src_json = {
|
|
|
943
940
|
{name: 'resolveRoute', kind: 'function'},
|
|
944
941
|
],
|
|
945
942
|
},
|
|
946
|
-
'./
|
|
947
|
-
path: '
|
|
943
|
+
'./sveltekit_shim_app_state.js': {
|
|
944
|
+
path: 'sveltekit_shim_app_state.ts',
|
|
948
945
|
declarations: [
|
|
949
|
-
{name: 'getStores', kind: 'function'},
|
|
950
946
|
{name: 'navigating', kind: 'variable'},
|
|
951
947
|
{name: 'page', kind: 'variable'},
|
|
952
948
|
{name: 'updated', kind: 'variable'},
|
package/src/lib/package_json.ts
CHANGED
|
@@ -347,11 +347,6 @@ const parse_or_throw_formatted_error = <T extends z.ZodTypeAny>(
|
|
|
347
347
|
return parsed.data;
|
|
348
348
|
};
|
|
349
349
|
|
|
350
|
-
export const is_dep = (
|
|
351
|
-
dep_name: string,
|
|
352
|
-
package_json: Package_Json = load_package_json(),
|
|
353
|
-
): boolean => package_json.name === dep_name;
|
|
354
|
-
|
|
355
350
|
export const has_dep = (
|
|
356
351
|
dep_name: string,
|
|
357
352
|
package_json: Package_Json = load_package_json(),
|
package/src/lib/paths.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
SOURCE_DIR,
|
|
11
11
|
SVELTEKIT_DIST_DIRNAME,
|
|
12
12
|
} from './constants.js';
|
|
13
|
-
import {
|
|
13
|
+
import {default_svelte_config} from './svelte_config.js';
|
|
14
14
|
import type {Path_Id} from './path.js';
|
|
15
15
|
|
|
16
16
|
/*
|
|
@@ -20,10 +20,10 @@ It's the same name that Rollup uses.
|
|
|
20
20
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
export const LIB_DIRNAME = basename(
|
|
23
|
+
export const LIB_DIRNAME = basename(default_svelte_config.lib_path);
|
|
24
24
|
export const LIB_PATH = SOURCE_DIR + LIB_DIRNAME;
|
|
25
25
|
export const LIB_DIR = LIB_PATH + '/';
|
|
26
|
-
export const ROUTES_DIRNAME = basename(
|
|
26
|
+
export const ROUTES_DIRNAME = basename(default_svelte_config.routes_path);
|
|
27
27
|
|
|
28
28
|
export interface Paths {
|
|
29
29
|
root: string;
|
package/src/lib/run_gen.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import {print_path, to_root_path} from './paths.js';
|
|
15
15
|
import type {format_file as base_format_file} from './format_file.js';
|
|
16
16
|
import type {Gro_Config} from './gro_config.js';
|
|
17
|
-
import {
|
|
17
|
+
import {default_svelte_config} from './svelte_config.js';
|
|
18
18
|
|
|
19
19
|
export const GEN_NO_PROD_MESSAGE = 'gen runs only during development';
|
|
20
20
|
|
|
@@ -37,7 +37,7 @@ export const run_gen = async (
|
|
|
37
37
|
// Perform code generation by calling `gen` on the module.
|
|
38
38
|
const gen_ctx: Gen_Context = {
|
|
39
39
|
config,
|
|
40
|
-
|
|
40
|
+
svelte_config: default_svelte_config,
|
|
41
41
|
origin_id: id,
|
|
42
42
|
origin_path: to_root_path(id),
|
|
43
43
|
log,
|
package/src/lib/run_task.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type {invoke_task as base_invoke_task} from './invoke_task.js';
|
|
|
8
8
|
import {log_task_help} from './task_logging.js';
|
|
9
9
|
import type {Gro_Config} from './gro_config.js';
|
|
10
10
|
import {Task_Error, type Task_Module_Meta} from './task.js';
|
|
11
|
-
import {
|
|
11
|
+
import {default_svelte_config} from './svelte_config.js';
|
|
12
12
|
import type {Filer} from './filer.js';
|
|
13
13
|
|
|
14
14
|
export type Run_Task_Result =
|
|
@@ -55,7 +55,7 @@ export const run_task = async (
|
|
|
55
55
|
output = await task.run({
|
|
56
56
|
args,
|
|
57
57
|
config,
|
|
58
|
-
|
|
58
|
+
svelte_config: default_svelte_config,
|
|
59
59
|
filer,
|
|
60
60
|
log,
|
|
61
61
|
timings,
|
package/src/lib/search_fs.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type {Config as
|
|
1
|
+
import type {Config as SvelteConfig} from '@sveltejs/kit';
|
|
2
2
|
import type {CompileOptions, ModuleCompileOptions, PreprocessorGroup} from 'svelte/compiler';
|
|
3
3
|
import {join} from 'node:path';
|
|
4
|
+
import {EMPTY_OBJECT} from '@ryanatkn/belt/object.js';
|
|
4
5
|
|
|
5
|
-
import {
|
|
6
|
+
import {SVELTE_CONFIG_FILENAME} from './constants.js';
|
|
6
7
|
|
|
7
8
|
/*
|
|
8
9
|
|
|
@@ -14,11 +15,12 @@ This module is intended to have minimal dependencies to avoid over-imports in th
|
|
|
14
15
|
* Loads a SvelteKit config at `dir`.
|
|
15
16
|
* @returns `null` if no config is found
|
|
16
17
|
*/
|
|
17
|
-
export const
|
|
18
|
-
dir
|
|
19
|
-
|
|
18
|
+
export const load_svelte_config = async ({
|
|
19
|
+
dir = process.cwd(),
|
|
20
|
+
config_filename = SVELTE_CONFIG_FILENAME,
|
|
21
|
+
}: {dir?: string; config_filename?: string} = EMPTY_OBJECT): Promise<SvelteConfig | null> => {
|
|
20
22
|
try {
|
|
21
|
-
return (await import(join(dir,
|
|
23
|
+
return (await import(join(dir, config_filename))).default;
|
|
22
24
|
} catch (_err) {
|
|
23
25
|
return null;
|
|
24
26
|
}
|
|
@@ -28,13 +30,13 @@ export const load_sveltekit_config = async (
|
|
|
28
30
|
* A subset of SvelteKit's config in a form that Gro uses
|
|
29
31
|
* because SvelteKit doesn't expose its config resolver.
|
|
30
32
|
* Flattens things out to keep them simple and easy to pass around,
|
|
31
|
-
* and doesn't deal with most properties
|
|
33
|
+
* and doesn't deal with most properties, but includes the full `svelte_config`.
|
|
32
34
|
* The `base` and `assets` in particular are renamed for clarity with Gro's internal systems,
|
|
33
35
|
* so these properties become first-class vocabulary inside Gro.
|
|
34
36
|
*/
|
|
35
|
-
export interface
|
|
37
|
+
export interface Parsed_Svelte_Config {
|
|
36
38
|
// TODO probably fill these out with defaults
|
|
37
|
-
|
|
39
|
+
svelte_config: SvelteConfig | null;
|
|
38
40
|
alias: Record<string, string>;
|
|
39
41
|
base_url: '' | `/${string}` | undefined;
|
|
40
42
|
assets_url: '' | `http://${string}` | `https://${string}` | undefined;
|
|
@@ -64,15 +66,22 @@ export interface Parsed_Sveltekit_Config {
|
|
|
64
66
|
// TODO currently incomplete and hack - maybe rethink
|
|
65
67
|
/**
|
|
66
68
|
* Returns Gro-relevant properties of a SvelteKit config
|
|
67
|
-
* as a convenience wrapper around `
|
|
69
|
+
* as a convenience wrapper around `load_svelte_config`.
|
|
68
70
|
* Needed because SvelteKit doesn't expose its config resolver.
|
|
69
71
|
*/
|
|
70
|
-
export const
|
|
71
|
-
dir_or_config
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
export const parse_svelte_config = async ({
|
|
73
|
+
dir_or_config = process.cwd(), // TODO maybe not the best API, maybe a type union? `({svelte_config} | {dir}) & {config_filename}`
|
|
74
|
+
config_filename = SVELTE_CONFIG_FILENAME,
|
|
75
|
+
}: {
|
|
76
|
+
dir_or_config?: string | SvelteConfig;
|
|
77
|
+
config_filename?: string;
|
|
78
|
+
} = EMPTY_OBJECT): Promise<Parsed_Svelte_Config> => {
|
|
79
|
+
const svelte_config =
|
|
80
|
+
typeof dir_or_config === 'string'
|
|
81
|
+
? await load_svelte_config({dir: dir_or_config, config_filename})
|
|
82
|
+
: dir_or_config;
|
|
83
|
+
|
|
84
|
+
const kit = svelte_config?.kit;
|
|
76
85
|
|
|
77
86
|
const alias = {$lib: 'src/lib', ...kit?.alias};
|
|
78
87
|
|
|
@@ -88,17 +97,17 @@ export const init_sveltekit_config = async (
|
|
|
88
97
|
const private_prefix = kit?.env?.privatePrefix;
|
|
89
98
|
const public_prefix = kit?.env?.publicPrefix;
|
|
90
99
|
|
|
91
|
-
const svelte_compile_options: CompileOptions =
|
|
100
|
+
const svelte_compile_options: CompileOptions = svelte_config?.compilerOptions ?? {};
|
|
92
101
|
// Change the default to `generate: 'server'`,
|
|
93
102
|
// because SvelteKit handles the client in the normal cases.
|
|
94
103
|
if (svelte_compile_options.generate === undefined) {
|
|
95
104
|
svelte_compile_options.generate = 'server';
|
|
96
105
|
}
|
|
97
106
|
const svelte_compile_module_options = to_default_compile_module_options(svelte_compile_options); // TODO will kit have these separately?
|
|
98
|
-
const svelte_preprocessors =
|
|
107
|
+
const svelte_preprocessors = svelte_config?.preprocess;
|
|
99
108
|
|
|
100
109
|
return {
|
|
101
|
-
|
|
110
|
+
svelte_config,
|
|
102
111
|
alias,
|
|
103
112
|
base_url,
|
|
104
113
|
assets_url,
|
|
@@ -119,9 +128,10 @@ export const to_default_compile_module_options = ({
|
|
|
119
128
|
generate,
|
|
120
129
|
filename,
|
|
121
130
|
rootDir,
|
|
122
|
-
|
|
131
|
+
warningFilter,
|
|
132
|
+
}: CompileOptions): ModuleCompileOptions => ({dev, generate, filename, rootDir, warningFilter});
|
|
123
133
|
|
|
124
134
|
/**
|
|
125
135
|
* The parsed SvelteKit config for the cwd, cached globally at the module level.
|
|
126
136
|
*/
|
|
127
|
-
export const
|
|
137
|
+
export const default_svelte_config = await parse_svelte_config(); // always load it to keep things simple ahead
|
|
@@ -4,8 +4,8 @@ import type {Logger} from '@ryanatkn/belt/log.js';
|
|
|
4
4
|
import {join} from 'node:path';
|
|
5
5
|
|
|
6
6
|
import {Package_Json, has_dep} from './package_json.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import {default_svelte_config, type Parsed_Svelte_Config} from './svelte_config.js';
|
|
8
|
+
import {SVELTE_CONFIG_FILENAME, SVELTEKIT_DEV_DIRNAME, PM_CLI_DEFAULT} from './constants.js';
|
|
9
9
|
import {find_cli, spawn_cli, to_cli_name, type Cli} from './cli.js';
|
|
10
10
|
import {Task_Error} from './task.js';
|
|
11
11
|
import {serialize_args, to_forwarded_args} from './args.js';
|
|
@@ -22,9 +22,11 @@ export const VITE_CLI = 'vite';
|
|
|
22
22
|
export const SVELTEKIT_ENV_MATCHER = /^\$env\/(static|dynamic)\/(public|private)$/;
|
|
23
23
|
export const SVELTEKIT_GLOBAL_SPECIFIER = /^\$(env|app)\//;
|
|
24
24
|
|
|
25
|
-
export const has_sveltekit_app = (
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
export const has_sveltekit_app = (
|
|
26
|
+
svelte_config_path: string = SVELTE_CONFIG_FILENAME,
|
|
27
|
+
): Result<object, {message: string}> => {
|
|
28
|
+
if (!existsSync(svelte_config_path)) {
|
|
29
|
+
return {ok: false, message: `no SvelteKit config found at ${SVELTE_CONFIG_FILENAME}`};
|
|
28
30
|
}
|
|
29
31
|
// TODO check for routes?
|
|
30
32
|
return {ok: true};
|
|
@@ -32,7 +34,7 @@ export const has_sveltekit_app = (): Result<object, {message: string}> => {
|
|
|
32
34
|
|
|
33
35
|
export const has_sveltekit_library = (
|
|
34
36
|
package_json: Package_Json,
|
|
35
|
-
|
|
37
|
+
svelte_config: Parsed_Svelte_Config = default_svelte_config,
|
|
36
38
|
dep_name = SVELTE_PACKAGE_DEP_NAME,
|
|
37
39
|
): Result<object, {message: string}> => {
|
|
38
40
|
const has_sveltekit_app_result = has_sveltekit_app();
|
|
@@ -40,8 +42,8 @@ export const has_sveltekit_library = (
|
|
|
40
42
|
return has_sveltekit_app_result;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
if (!existsSync(
|
|
44
|
-
return {ok: false, message: `no SvelteKit lib directory found at ${
|
|
45
|
+
if (!existsSync(svelte_config.lib_path)) {
|
|
46
|
+
return {ok: false, message: `no SvelteKit lib directory found at ${svelte_config.lib_path}`};
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
if (!has_dep(dep_name, package_json)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {Parsed_Svelte_Config} from './svelte_config.js';
|
|
2
2
|
|
|
3
3
|
export const SVELTEKIT_SHIM_APP_PATHS_MATCHER = /\/util\/sveltekit_shim_app_paths\.js$/;
|
|
4
4
|
export const SVELTEKIT_SHIM_APP_ENVIRONMENT_MATCHER = /\/util\/sveltekit_shim_app_environment\.js$/;
|
|
@@ -12,12 +12,12 @@ export const sveltekit_shim_app_specifiers = new Map([
|
|
|
12
12
|
['$app/forms', '@ryanatkn/gro/sveltekit_shim_app_forms.js'],
|
|
13
13
|
['$app/navigation', '@ryanatkn/gro/sveltekit_shim_app_navigation.js'],
|
|
14
14
|
['$app/paths', '@ryanatkn/gro/sveltekit_shim_app_paths.js'],
|
|
15
|
-
['$app/
|
|
15
|
+
['$app/state', '@ryanatkn/gro/sveltekit_shim_app_state.js'],
|
|
16
16
|
]);
|
|
17
17
|
|
|
18
18
|
export const render_sveltekit_shim_app_paths = (
|
|
19
|
-
base_url:
|
|
20
|
-
assets_url:
|
|
19
|
+
base_url: Parsed_Svelte_Config['base_url'] = '',
|
|
20
|
+
assets_url: Parsed_Svelte_Config['assets_url'] = '',
|
|
21
21
|
): string => `// shim for $app/paths
|
|
22
22
|
// @see https://github.com/sveltejs/kit/issues/1485
|
|
23
23
|
|
|
@@ -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/ryanatkn/gro'),
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const updated: typeof base_updated = {
|
|
31
|
+
current: false,
|
|
32
|
+
check: () => {
|
|
33
|
+
throw new Error('Can only call updated.check() in the browser');
|
|
34
|
+
},
|
|
35
|
+
};
|
package/src/lib/task.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {isAbsolute, join, relative} from 'node:path';
|
|
|
9
9
|
import type {Args} from './args.js';
|
|
10
10
|
import type {Path_Id} from './path.js';
|
|
11
11
|
import type {Gro_Config} from './gro_config.js';
|
|
12
|
-
import type {
|
|
12
|
+
import type {Parsed_Svelte_Config} from './svelte_config.js';
|
|
13
13
|
import {
|
|
14
14
|
resolve_input_files,
|
|
15
15
|
resolve_input_paths,
|
|
@@ -35,10 +35,10 @@ export interface Task<
|
|
|
35
35
|
export interface Task_Context<T_Args = object> {
|
|
36
36
|
args: T_Args;
|
|
37
37
|
config: Gro_Config;
|
|
38
|
-
|
|
38
|
+
svelte_config: Parsed_Svelte_Config;
|
|
39
39
|
filer: Filer;
|
|
40
40
|
// TODO should this go here or on `config` for convenience?
|
|
41
|
-
//
|
|
41
|
+
// svelte_config: Parsed_Svelte_Config;
|
|
42
42
|
log: Logger;
|
|
43
43
|
timings: Timings;
|
|
44
44
|
invoke_task: (task_name: string, args?: Args, config?: Gro_Config) => Promise<void>;
|
package/src/lib/upgrade.task.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {spawn} from '@ryanatkn/belt/process.js';
|
|
2
2
|
import {z} from 'zod';
|
|
3
|
+
import {rmSync} from 'node:fs';
|
|
3
4
|
|
|
4
5
|
import {Task_Error, type Task} from './task.js';
|
|
5
6
|
import {extract_deps, load_package_json, type Package_Json_Dep} from './package_json.js';
|
|
6
7
|
import {Git_Origin, git_pull} from './git.js';
|
|
7
8
|
import {spawn_cli} from './cli.js';
|
|
8
9
|
import {serialize_args, to_forwarded_args} from './args.js';
|
|
10
|
+
import {NODE_MODULES_DIRNAME} from './constants.js';
|
|
9
11
|
|
|
10
12
|
export const Args = z
|
|
11
13
|
.object({
|
|
@@ -20,6 +22,18 @@ export const Args = z
|
|
|
20
22
|
force: z.boolean({description: 'if true, print out the planned upgrades'}).default(false),
|
|
21
23
|
pull: z.boolean({description: 'dual of no-pull'}).default(true),
|
|
22
24
|
'no-pull': z.boolean({description: 'opt out of git pull'}).default(false),
|
|
25
|
+
delete_node_modules: z
|
|
26
|
+
.boolean({description: 'if true, deletes node_modules before upgrading'})
|
|
27
|
+
.default(false),
|
|
28
|
+
node_modules_path: z // TODO maybe configured globally instead
|
|
29
|
+
.string({description: 'path to modules directory to delete'})
|
|
30
|
+
.default(NODE_MODULES_DIRNAME),
|
|
31
|
+
delete_lockfile: z
|
|
32
|
+
.boolean({description: 'if true, deletes the lockfile before upgrading'})
|
|
33
|
+
.default(false),
|
|
34
|
+
lockfile_path: z
|
|
35
|
+
.string({description: 'path to the lockfile to delete'})
|
|
36
|
+
.default('package-lock.json'),
|
|
23
37
|
dry: z.boolean({description: 'if true, print out the planned upgrades'}).default(false),
|
|
24
38
|
})
|
|
25
39
|
.strict();
|
|
@@ -29,7 +43,18 @@ export const task: Task<Args> = {
|
|
|
29
43
|
summary: 'upgrade deps',
|
|
30
44
|
Args,
|
|
31
45
|
run: async ({args, log, config}): Promise<void> => {
|
|
32
|
-
const {
|
|
46
|
+
const {
|
|
47
|
+
_,
|
|
48
|
+
only,
|
|
49
|
+
origin,
|
|
50
|
+
force,
|
|
51
|
+
pull,
|
|
52
|
+
delete_node_modules,
|
|
53
|
+
node_modules_path,
|
|
54
|
+
delete_lockfile,
|
|
55
|
+
lockfile_path,
|
|
56
|
+
dry,
|
|
57
|
+
} = args;
|
|
33
58
|
|
|
34
59
|
if (_.length && only.length) {
|
|
35
60
|
throw new Task_Error('Cannot call `gro upgrade` with both rest args and --only.');
|
|
@@ -40,6 +65,16 @@ export const task: Task<Args> = {
|
|
|
40
65
|
await git_pull(origin);
|
|
41
66
|
}
|
|
42
67
|
|
|
68
|
+
if (delete_node_modules) {
|
|
69
|
+
log.info(`deleting node_modules at `, node_modules_path);
|
|
70
|
+
rmSync(node_modules_path, {recursive: true, force: true});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (delete_lockfile) {
|
|
74
|
+
log.info(`deleting lockfile at`, lockfile_path);
|
|
75
|
+
rmSync(lockfile_path, {force: true});
|
|
76
|
+
}
|
|
77
|
+
|
|
43
78
|
const package_json = load_package_json();
|
|
44
79
|
|
|
45
80
|
const all_deps = extract_deps(package_json);
|
|
@@ -69,6 +104,13 @@ export const task: Task<Args> = {
|
|
|
69
104
|
install_args.push(...serialize_args(to_forwarded_args(config.pm_cli)));
|
|
70
105
|
await spawn(config.pm_cli, install_args);
|
|
71
106
|
|
|
107
|
+
// If we deleted the lockfile or node modules, `npm install` again
|
|
108
|
+
// to fix a recurring npm bug getting the lockfile to its final state.
|
|
109
|
+
if (!dry && (delete_node_modules || delete_lockfile)) {
|
|
110
|
+
log.info(`installing again to fix npm lockfile bugs`);
|
|
111
|
+
await spawn(config.pm_cli, ['install']);
|
|
112
|
+
}
|
|
113
|
+
|
|
72
114
|
// Sync in a new process to pick up any changes after installing, avoiding some errors.
|
|
73
115
|
await spawn_cli('gro', ['sync', '--no-install']); // don't install because we do above
|
|
74
116
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sveltekit_config.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/sveltekit_config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,IAAI,eAAe,EAAC,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAC,cAAc,EAAE,oBAAoB,EAAE,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAW7F;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GACjC,MAAK,MAAsB,KACzB,OAAO,CAAC,eAAe,GAAG,IAAI,CAMhC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,WAAW,uBAAuB;IAEvC,gBAAgB,EAAE,eAAe,GAAG,IAAI,CAAC;IACzC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,QAAQ,EAAE,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,SAAS,CAAC;IACxC,UAAU,EAAE,EAAE,GAAG,UAAU,MAAM,EAAE,GAAG,WAAW,MAAM,EAAE,GAAG,SAAS,CAAC;IAGtE;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,sBAAsB,EAAE,cAAc,CAAC;IACvC,6BAA6B,EAAE,oBAAoB,CAAC;IACpD,oBAAoB,EAAE,iBAAiB,GAAG,KAAK,CAAC,iBAAiB,CAAC,GAAG,SAAS,CAAC;CAC/E;AAGD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GACjC,gBAAe,MAAM,GAAG,eAA+B,KACrD,OAAO,CAAC,uBAAuB,CA2CjC,CAAC;AAEF,eAAO,MAAM,iCAAiC,GAAI,uCAK/C,cAAc,KAAG,oBAA4D,CAAC;AAEjF;;GAEG;AACH,eAAO,MAAM,wBAAwB,yBAAgC,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { getStores as base_getStores, navigating as base_navigating, page as base_page, updated as base_updated } from '$app/stores';
|
|
2
|
-
export declare const getStores: typeof base_getStores;
|
|
3
|
-
export declare const navigating: typeof base_navigating;
|
|
4
|
-
export declare const page: typeof base_page;
|
|
5
|
-
export declare const updated: typeof base_updated;
|
|
6
|
-
//# sourceMappingURL=sveltekit_shim_app_stores.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sveltekit_shim_app_stores.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/sveltekit_shim_app_stores.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACX,SAAS,IAAI,cAAc,EAC3B,UAAU,IAAI,eAAe,EAC7B,IAAI,IAAI,SAAS,EACjB,OAAO,IAAI,YAAY,EACvB,MAAM,aAAa,CAAC;AAGrB,eAAO,MAAM,SAAS,EAAE,OAAO,cAA6D,CAAC;AAC7F,eAAO,MAAM,UAAU,EAAE,OAAO,eAAgC,CAAC;AACjE,eAAO,MAAM,IAAI,EAAE,OAAO,SASxB,CAAC;AACH,eAAO,MAAM,OAAO,EAAE,OAAO,YAAoC,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// shim for $app/stores
|
|
2
|
-
// @see https://github.com/sveltejs/kit/issues/1485
|
|
3
|
-
import { readable } from 'svelte/store';
|
|
4
|
-
export const getStores = () => ({ navigating, page, updated });
|
|
5
|
-
export const navigating = readable(null);
|
|
6
|
-
export const page = readable({
|
|
7
|
-
url: new URL('https://gro.ryanatkn.com/TODO'),
|
|
8
|
-
params: {},
|
|
9
|
-
route: { id: 'RouteId' },
|
|
10
|
-
status: 200,
|
|
11
|
-
error: null,
|
|
12
|
-
data: {},
|
|
13
|
-
state: {},
|
|
14
|
-
form: {},
|
|
15
|
-
});
|
|
16
|
-
export const updated = readable(true);
|
|
17
|
-
updated.check = () => Promise.resolve(true);
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// shim for $app/stores
|
|
2
|
-
// @see https://github.com/sveltejs/kit/issues/1485
|
|
3
|
-
|
|
4
|
-
// TODO support `$app/state`
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-deprecated */
|
|
6
|
-
|
|
7
|
-
import type {
|
|
8
|
-
getStores as base_getStores,
|
|
9
|
-
navigating as base_navigating,
|
|
10
|
-
page as base_page,
|
|
11
|
-
updated as base_updated,
|
|
12
|
-
} from '$app/stores';
|
|
13
|
-
import {readable} from 'svelte/store';
|
|
14
|
-
|
|
15
|
-
export const getStores: typeof base_getStores = () => ({navigating, page, updated}) as const;
|
|
16
|
-
export const navigating: typeof base_navigating = readable(null);
|
|
17
|
-
export const page: typeof base_page = readable({
|
|
18
|
-
url: new URL('https://gro.ryanatkn.com/TODO'),
|
|
19
|
-
params: {},
|
|
20
|
-
route: {id: 'RouteId'},
|
|
21
|
-
status: 200,
|
|
22
|
-
error: null,
|
|
23
|
-
data: {},
|
|
24
|
-
state: {},
|
|
25
|
-
form: {},
|
|
26
|
-
});
|
|
27
|
-
export const updated: typeof base_updated = readable(true) as any;
|
|
28
|
-
updated.check = () => Promise.resolve(true);
|