@ryanatkn/gro 0.141.1 → 0.143.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/build.task.js +1 -1
- package/dist/changeset.task.d.ts.map +1 -1
- package/dist/changeset.task.js +4 -4
- package/dist/check.task.d.ts.map +1 -1
- package/dist/check.task.js +4 -2
- package/dist/clean_fs.js +1 -1
- package/dist/cli.js +1 -1
- package/dist/{path_constants.d.ts → constants.d.ts} +4 -1
- package/dist/constants.d.ts.map +1 -0
- package/dist/{path_constants.js → constants.js} +3 -0
- package/dist/deploy.task.js +1 -1
- package/dist/dev.task.js +1 -1
- package/dist/esbuild_plugin_svelte.js +1 -1
- package/dist/esbuild_plugin_sveltekit_local_imports.js +1 -1
- package/dist/esbuild_plugin_sveltekit_shim_app.js +1 -1
- package/dist/esbuild_plugin_sveltekit_shim_env.js +1 -1
- package/dist/filer.d.ts +7 -0
- package/dist/filer.d.ts.map +1 -1
- package/dist/filer.js +28 -29
- package/dist/format.task.d.ts.map +1 -1
- package/dist/format.task.js +2 -2
- package/dist/format_directory.d.ts +1 -1
- package/dist/format_directory.d.ts.map +1 -1
- package/dist/format_directory.js +5 -6
- package/dist/gen.task.js +1 -1
- package/dist/gro_config.d.ts +12 -2
- package/dist/gro_config.d.ts.map +1 -1
- package/dist/gro_config.js +10 -6
- package/dist/gro_helpers.d.ts +1 -1
- package/dist/gro_helpers.d.ts.map +1 -1
- package/dist/gro_helpers.js +3 -3
- package/dist/gro_plugin_server.js +4 -4
- package/dist/gro_plugin_sveltekit_app.d.ts.map +1 -1
- package/dist/gro_plugin_sveltekit_app.js +5 -5
- package/dist/gro_plugin_sveltekit_library.js +7 -7
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +23 -17
- package/dist/module.js +1 -1
- package/dist/moss_helpers.d.ts +1 -1
- package/dist/moss_helpers.d.ts.map +1 -1
- package/dist/moss_helpers.js +4 -3
- package/dist/package.d.ts +334 -172
- package/dist/package.d.ts.map +1 -1
- package/dist/package.js +51 -51
- package/dist/package_json.d.ts +9 -6
- package/dist/package_json.d.ts.map +1 -1
- package/dist/package_json.js +21 -6
- package/dist/package_meta.d.ts +1 -1
- package/dist/parse_imports.js +1 -1
- package/dist/paths.js +1 -1
- package/dist/publish.task.d.ts.map +1 -1
- package/dist/publish.task.js +7 -20
- package/dist/reinstall.task.js +11 -11
- package/dist/resolve_node_specifier.d.ts +7 -1
- package/dist/resolve_node_specifier.d.ts.map +1 -1
- package/dist/resolve_node_specifier.js +78 -14
- package/dist/resolve_specifier.d.ts +2 -6
- package/dist/resolve_specifier.d.ts.map +1 -1
- package/dist/resolve_specifier.js +2 -6
- package/dist/run_task.js +1 -1
- package/dist/src_json.d.ts +39 -3
- package/dist/src_json.d.ts.map +1 -1
- package/dist/sveltekit_config.d.ts +1 -1
- package/dist/sveltekit_config.d.ts.map +1 -1
- package/dist/sveltekit_config.js +1 -1
- package/dist/sveltekit_helpers.d.ts +3 -3
- package/dist/sveltekit_helpers.d.ts.map +1 -1
- package/dist/sveltekit_helpers.js +7 -7
- package/dist/sync.task.js +5 -5
- package/dist/upgrade.task.d.ts.map +1 -1
- package/dist/upgrade.task.js +4 -2
- package/dist/watch_dir.d.ts.map +1 -1
- package/dist/watch_dir.js +5 -5
- package/package.json +18 -18
- package/src/lib/build.task.ts +1 -1
- package/src/lib/changeset.task.ts +4 -3
- package/src/lib/check.task.ts +4 -2
- package/src/lib/clean_fs.ts +1 -1
- package/src/lib/cli.ts +1 -1
- package/src/lib/{path_constants.ts → constants.ts} +4 -0
- package/src/lib/deploy.task.ts +1 -1
- package/src/lib/dev.task.ts +1 -1
- package/src/lib/esbuild_plugin_svelte.ts +1 -1
- package/src/lib/esbuild_plugin_sveltekit_local_imports.ts +1 -1
- package/src/lib/esbuild_plugin_sveltekit_shim_app.ts +1 -1
- package/src/lib/esbuild_plugin_sveltekit_shim_env.ts +1 -1
- package/src/lib/filer.ts +37 -27
- package/src/lib/format.task.ts +10 -2
- package/src/lib/format_directory.ts +10 -9
- package/src/lib/gen.task.ts +1 -1
- package/src/lib/gro_config.ts +23 -5
- package/src/lib/gro_helpers.ts +3 -2
- package/src/lib/gro_plugin_server.ts +4 -4
- package/src/lib/gro_plugin_sveltekit_app.ts +7 -5
- package/src/lib/gro_plugin_sveltekit_library.ts +7 -7
- package/src/lib/loader.ts +25 -17
- package/src/lib/module.ts +1 -1
- package/src/lib/moss_helpers.ts +4 -2
- package/src/lib/package.ts +51 -51
- package/src/lib/package_json.ts +23 -6
- package/src/lib/package_meta.ts +1 -1
- package/src/lib/parse_imports.ts +1 -1
- package/src/lib/paths.ts +1 -1
- package/src/lib/publish.task.ts +7 -22
- package/src/lib/reinstall.task.ts +11 -11
- package/src/lib/resolve_node_specifier.ts +100 -18
- package/src/lib/resolve_specifier.ts +2 -6
- package/src/lib/run_task.ts +1 -1
- package/src/lib/sveltekit_config.ts +2 -2
- package/src/lib/sveltekit_helpers.ts +7 -4
- package/src/lib/sync.task.ts +5 -5
- package/src/lib/upgrade.task.ts +4 -2
- package/src/lib/watch_dir.ts +6 -6
- package/dist/path_constants.d.ts.map +0 -1
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.143.0',
|
|
9
9
|
description: 'task runner and toolkit extending SvelteKit',
|
|
10
10
|
motto: 'generate, run, optimize',
|
|
11
11
|
glyph: '🌰',
|
|
@@ -53,7 +53,7 @@ export const package_json = {
|
|
|
53
53
|
prettier: '^3.3.3',
|
|
54
54
|
'prettier-plugin-svelte': '^3.2.7',
|
|
55
55
|
'ts-morph': '^24.0.0',
|
|
56
|
-
tslib: '^2.
|
|
56
|
+
tslib: '^2.8.0',
|
|
57
57
|
zod: '^3.23.8',
|
|
58
58
|
},
|
|
59
59
|
peerDependencies: {esbuild: '^0.21.0', svelte: '^5.0.0-next.0'},
|
|
@@ -61,21 +61,21 @@ export const package_json = {
|
|
|
61
61
|
'@changesets/changelog-git': '^0.2.0',
|
|
62
62
|
'@changesets/types': '^6.0.0',
|
|
63
63
|
'@ryanatkn/eslint-config': '^0.5.5',
|
|
64
|
-
'@ryanatkn/fuz': '^0.129.
|
|
65
|
-
'@ryanatkn/moss': '^0.18.
|
|
66
|
-
'@sveltejs/adapter-static': '^3.0.
|
|
67
|
-
'@sveltejs/kit': '^2.
|
|
68
|
-
'@sveltejs/package': '^2.3.
|
|
69
|
-
'@sveltejs/vite-plugin-svelte': '^4.0.0
|
|
64
|
+
'@ryanatkn/fuz': '^0.129.5',
|
|
65
|
+
'@ryanatkn/moss': '^0.18.2',
|
|
66
|
+
'@sveltejs/adapter-static': '^3.0.6',
|
|
67
|
+
'@sveltejs/kit': '^2.7.3',
|
|
68
|
+
'@sveltejs/package': '^2.3.7',
|
|
69
|
+
'@sveltejs/vite-plugin-svelte': '^4.0.0',
|
|
70
70
|
'@types/fs-extra': '^11.0.4',
|
|
71
|
-
'@types/node': '^22.
|
|
71
|
+
'@types/node': '^22.8.1',
|
|
72
72
|
esbuild: '^0.21.5',
|
|
73
|
-
eslint: '^9.
|
|
74
|
-
'eslint-plugin-svelte': '^2.
|
|
75
|
-
svelte: '^5.
|
|
76
|
-
'svelte-check': '^4.0.
|
|
73
|
+
eslint: '^9.13.0',
|
|
74
|
+
'eslint-plugin-svelte': '^2.46.0',
|
|
75
|
+
svelte: '^5.1.3',
|
|
76
|
+
'svelte-check': '^4.0.5',
|
|
77
77
|
typescript: '^5.6.3',
|
|
78
|
-
'typescript-eslint': '^8.
|
|
78
|
+
'typescript-eslint': '^8.11.0',
|
|
79
79
|
uvu: '^0.5.6',
|
|
80
80
|
},
|
|
81
81
|
prettier: {
|
|
@@ -107,6 +107,7 @@ export const package_json = {
|
|
|
107
107
|
'./clean.task.js': {types: './dist/clean.task.d.ts', default: './dist/clean.task.js'},
|
|
108
108
|
'./cli.js': {types: './dist/cli.d.ts', default: './dist/cli.js'},
|
|
109
109
|
'./commit.task.js': {types: './dist/commit.task.d.ts', default: './dist/commit.task.js'},
|
|
110
|
+
'./constants.js': {types: './dist/constants.d.ts', default: './dist/constants.js'},
|
|
110
111
|
'./deploy.task.js': {types: './dist/deploy.task.d.ts', default: './dist/deploy.task.js'},
|
|
111
112
|
'./dev.task.js': {types: './dist/dev.task.d.ts', default: './dist/dev.task.js'},
|
|
112
113
|
'./env.js': {types: './dist/env.d.ts', default: './dist/env.js'},
|
|
@@ -187,10 +188,6 @@ export const package_json = {
|
|
|
187
188
|
'./package.gen.js': {types: './dist/package.gen.d.ts', default: './dist/package.gen.js'},
|
|
188
189
|
'./package.js': {types: './dist/package.d.ts', default: './dist/package.js'},
|
|
189
190
|
'./parse_imports.js': {types: './dist/parse_imports.d.ts', default: './dist/parse_imports.js'},
|
|
190
|
-
'./path_constants.js': {
|
|
191
|
-
types: './dist/path_constants.d.ts',
|
|
192
|
-
default: './dist/path_constants.js',
|
|
193
|
-
},
|
|
194
191
|
'./path.js': {types: './dist/path.d.ts', default: './dist/path.js'},
|
|
195
192
|
'./paths.js': {types: './dist/paths.d.ts', default: './dist/paths.js'},
|
|
196
193
|
'./plugin.js': {types: './dist/plugin.d.ts', default: './dist/plugin.js'},
|
|
@@ -270,7 +267,7 @@ export const package_json = {
|
|
|
270
267
|
|
|
271
268
|
export const src_json = {
|
|
272
269
|
name: '@ryanatkn/gro',
|
|
273
|
-
version: '0.
|
|
270
|
+
version: '0.143.0',
|
|
274
271
|
modules: {
|
|
275
272
|
'.': {
|
|
276
273
|
path: 'index.ts',
|
|
@@ -365,6 +362,39 @@ export const src_json = {
|
|
|
365
362
|
{name: 'task', kind: 'variable'},
|
|
366
363
|
],
|
|
367
364
|
},
|
|
365
|
+
'./constants.js': {
|
|
366
|
+
path: 'constants.ts',
|
|
367
|
+
declarations: [
|
|
368
|
+
{name: 'SOURCE_DIRNAME', kind: 'variable'},
|
|
369
|
+
{name: 'GRO_DIRNAME', kind: 'variable'},
|
|
370
|
+
{name: 'GRO_DIST_PREFIX', kind: 'variable'},
|
|
371
|
+
{name: 'SERVER_DIST_PATH', kind: 'variable'},
|
|
372
|
+
{name: 'GRO_DEV_DIRNAME', kind: 'variable'},
|
|
373
|
+
{name: 'SOURCE_DIR', kind: 'variable'},
|
|
374
|
+
{name: 'GRO_DIR', kind: 'variable'},
|
|
375
|
+
{name: 'GRO_DEV_DIR', kind: 'variable'},
|
|
376
|
+
{name: 'GRO_CONFIG_PATH', kind: 'variable'},
|
|
377
|
+
{name: 'README_FILENAME', kind: 'variable'},
|
|
378
|
+
{name: 'SVELTEKIT_CONFIG_FILENAME', kind: 'variable'},
|
|
379
|
+
{name: 'VITE_CONFIG_FILENAME', kind: 'variable'},
|
|
380
|
+
{name: 'NODE_MODULES_DIRNAME', kind: 'variable'},
|
|
381
|
+
{name: 'LOCKFILE_FILENAME', kind: 'variable'},
|
|
382
|
+
{name: 'SVELTEKIT_DEV_DIRNAME', kind: 'variable'},
|
|
383
|
+
{name: 'SVELTEKIT_BUILD_DIRNAME', kind: 'variable'},
|
|
384
|
+
{name: 'SVELTEKIT_DIST_DIRNAME', kind: 'variable'},
|
|
385
|
+
{name: 'SVELTEKIT_VITE_CACHE_PATH', kind: 'variable'},
|
|
386
|
+
{name: 'GITHUB_DIRNAME', kind: 'variable'},
|
|
387
|
+
{name: 'GIT_DIRNAME', kind: 'variable'},
|
|
388
|
+
{name: 'TSCONFIG_FILENAME', kind: 'variable'},
|
|
389
|
+
{name: 'TS_MATCHER', kind: 'variable'},
|
|
390
|
+
{name: 'JS_MATCHER', kind: 'variable'},
|
|
391
|
+
{name: 'JSON_MATCHER', kind: 'variable'},
|
|
392
|
+
{name: 'EVERYTHING_MATCHER', kind: 'variable'},
|
|
393
|
+
{name: 'JS_CLI_DEFAULT', kind: 'variable'},
|
|
394
|
+
{name: 'PM_CLI_DEFAULT', kind: 'variable'},
|
|
395
|
+
{name: 'PRETTIER_CLI_DEFAULT', kind: 'variable'},
|
|
396
|
+
],
|
|
397
|
+
},
|
|
368
398
|
'./deploy.task.js': {
|
|
369
399
|
path: 'deploy.task.ts',
|
|
370
400
|
declarations: [
|
|
@@ -545,8 +575,8 @@ export const src_json = {
|
|
|
545
575
|
{name: 'Raw_Gro_Config', kind: 'type'},
|
|
546
576
|
{name: 'Create_Gro_Config', kind: 'type'},
|
|
547
577
|
{name: 'create_empty_gro_config', kind: 'function'},
|
|
548
|
-
{name: '
|
|
549
|
-
{name: '
|
|
578
|
+
{name: 'SEARCH_EXCLUDER_DEFAULT', kind: 'variable'},
|
|
579
|
+
{name: 'EXPORTS_EXCLUDER_DEFAULT', kind: 'variable'},
|
|
550
580
|
{name: 'normalize_gro_config', kind: 'function'},
|
|
551
581
|
{name: 'Gro_Config_Module', kind: 'type'},
|
|
552
582
|
{name: 'load_gro_config', kind: 'function'},
|
|
@@ -716,36 +746,6 @@ export const src_json = {
|
|
|
716
746
|
{name: 'parse_imports', kind: 'function'},
|
|
717
747
|
],
|
|
718
748
|
},
|
|
719
|
-
'./path_constants.js': {
|
|
720
|
-
path: 'path_constants.ts',
|
|
721
|
-
declarations: [
|
|
722
|
-
{name: 'SOURCE_DIRNAME', kind: 'variable'},
|
|
723
|
-
{name: 'GRO_DIRNAME', kind: 'variable'},
|
|
724
|
-
{name: 'GRO_DIST_PREFIX', kind: 'variable'},
|
|
725
|
-
{name: 'SERVER_DIST_PATH', kind: 'variable'},
|
|
726
|
-
{name: 'GRO_DEV_DIRNAME', kind: 'variable'},
|
|
727
|
-
{name: 'SOURCE_DIR', kind: 'variable'},
|
|
728
|
-
{name: 'GRO_DIR', kind: 'variable'},
|
|
729
|
-
{name: 'GRO_DEV_DIR', kind: 'variable'},
|
|
730
|
-
{name: 'GRO_CONFIG_PATH', kind: 'variable'},
|
|
731
|
-
{name: 'README_FILENAME', kind: 'variable'},
|
|
732
|
-
{name: 'SVELTEKIT_CONFIG_FILENAME', kind: 'variable'},
|
|
733
|
-
{name: 'VITE_CONFIG_FILENAME', kind: 'variable'},
|
|
734
|
-
{name: 'NODE_MODULES_DIRNAME', kind: 'variable'},
|
|
735
|
-
{name: 'LOCKFILE_FILENAME', kind: 'variable'},
|
|
736
|
-
{name: 'SVELTEKIT_DEV_DIRNAME', kind: 'variable'},
|
|
737
|
-
{name: 'SVELTEKIT_BUILD_DIRNAME', kind: 'variable'},
|
|
738
|
-
{name: 'SVELTEKIT_DIST_DIRNAME', kind: 'variable'},
|
|
739
|
-
{name: 'SVELTEKIT_VITE_CACHE_PATH', kind: 'variable'},
|
|
740
|
-
{name: 'GITHUB_DIRNAME', kind: 'variable'},
|
|
741
|
-
{name: 'GIT_DIRNAME', kind: 'variable'},
|
|
742
|
-
{name: 'TSCONFIG_FILENAME', kind: 'variable'},
|
|
743
|
-
{name: 'TS_MATCHER', kind: 'variable'},
|
|
744
|
-
{name: 'JS_MATCHER', kind: 'variable'},
|
|
745
|
-
{name: 'JSON_MATCHER', kind: 'variable'},
|
|
746
|
-
{name: 'EVERYTHING_MATCHER', kind: 'variable'},
|
|
747
|
-
],
|
|
748
|
-
},
|
|
749
749
|
'./path.js': {
|
|
750
750
|
path: 'path.ts',
|
|
751
751
|
declarations: [
|
package/src/lib/package_json.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type {Flavored} from '@ryanatkn/belt/types.js';
|
|
|
7
7
|
import {styleText as st} from 'node:util';
|
|
8
8
|
|
|
9
9
|
import {paths, gro_paths, IS_THIS_GRO, replace_extension} from './paths.js';
|
|
10
|
-
import {SVELTEKIT_DIST_DIRNAME} from './
|
|
10
|
+
import {SVELTEKIT_DIST_DIRNAME} from './constants.js';
|
|
11
11
|
import {search_fs} from './search_fs.js';
|
|
12
12
|
import {has_sveltekit_library} from './sveltekit_helpers.js';
|
|
13
13
|
import {GITHUB_REPO_MATCHER} from './github.js';
|
|
@@ -21,7 +21,7 @@ export const Email = z.string();
|
|
|
21
21
|
export type Email = Flavored<z.infer<typeof Email>, 'Email'>;
|
|
22
22
|
|
|
23
23
|
// TODO move this where?
|
|
24
|
-
export const transform_empty_object_to_undefined = (val:
|
|
24
|
+
export const transform_empty_object_to_undefined = <T>(val: T): T | undefined => {
|
|
25
25
|
if (val && Object.keys(val).length === 0) {
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
@@ -63,8 +63,19 @@ export const Package_Json_Funding = z.union([
|
|
|
63
63
|
]);
|
|
64
64
|
export type Package_Json_Funding = z.infer<typeof Package_Json_Funding>;
|
|
65
65
|
|
|
66
|
+
// exports: {
|
|
67
|
+
// './': './index.js',
|
|
68
|
+
// './record': {default: './record.js'},
|
|
69
|
+
// './export_condition': {default: {development: './ec1', default: './ec2.js'}},
|
|
70
|
+
// }
|
|
66
71
|
export const Package_Json_Exports = z.record(
|
|
67
|
-
z
|
|
72
|
+
z
|
|
73
|
+
.union([
|
|
74
|
+
z.string(),
|
|
75
|
+
z.record(z.string().optional()),
|
|
76
|
+
z.record(z.record(z.string().optional()).optional()),
|
|
77
|
+
])
|
|
78
|
+
.optional(),
|
|
68
79
|
);
|
|
69
80
|
export type Package_Json_Exports = z.infer<typeof Package_Json_Exports>;
|
|
70
81
|
|
|
@@ -76,7 +87,7 @@ export const Package_Json = z
|
|
|
76
87
|
// according to the npm docs, `name` and `version` are the only required properties
|
|
77
88
|
name: z.string(),
|
|
78
89
|
version: z.string(),
|
|
79
|
-
private: z.boolean({description: 'disallow
|
|
90
|
+
private: z.boolean({description: 'disallow publishing to the configured registry'}).optional(),
|
|
80
91
|
public: z
|
|
81
92
|
.boolean({
|
|
82
93
|
description:
|
|
@@ -131,6 +142,7 @@ export const Package_Json = z
|
|
|
131
142
|
bin: z.record(z.string()).optional(),
|
|
132
143
|
sideEffects: z.array(z.string()).optional(),
|
|
133
144
|
files: z.array(z.string()).optional(),
|
|
145
|
+
main: z.string().optional(),
|
|
134
146
|
exports: Package_Json_Exports.transform(transform_empty_object_to_undefined).optional(),
|
|
135
147
|
})
|
|
136
148
|
.passthrough();
|
|
@@ -145,6 +157,7 @@ export const EMPTY_PACKAGE_JSON: Package_Json = {name: '', version: ''};
|
|
|
145
157
|
export const load_package_json = (
|
|
146
158
|
dir = IS_THIS_GRO ? gro_paths.root : paths.root,
|
|
147
159
|
cache?: Record<string, Package_Json>,
|
|
160
|
+
parse = true, // TODO pass `false` here in more places, especially anything perf-sensitive like work on startup
|
|
148
161
|
): Package_Json => {
|
|
149
162
|
let package_json: Package_Json;
|
|
150
163
|
if (cache && dir in cache) {
|
|
@@ -155,8 +168,12 @@ export const load_package_json = (
|
|
|
155
168
|
} catch (_err) {
|
|
156
169
|
return EMPTY_PACKAGE_JSON;
|
|
157
170
|
}
|
|
158
|
-
|
|
159
|
-
|
|
171
|
+
if (parse) {
|
|
172
|
+
package_json = parse_package_json(Package_Json, package_json);
|
|
173
|
+
}
|
|
174
|
+
if (cache) {
|
|
175
|
+
cache[dir] = package_json;
|
|
176
|
+
}
|
|
160
177
|
return package_json;
|
|
161
178
|
};
|
|
162
179
|
|
package/src/lib/package_meta.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface Package_Meta {
|
|
|
11
11
|
name: string; // '@ryanatkn/fuz_library'
|
|
12
12
|
repo_name: string; // fuz_library
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* The github user/org.
|
|
15
15
|
*/
|
|
16
16
|
owner_name: string | null; // 'fuz-dev'
|
|
17
17
|
homepage_url: Url | null; // 'https://www.fuz.dev/'
|
package/src/lib/parse_imports.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type {Flavored} from '@ryanatkn/belt/types.js';
|
|
|
3
3
|
|
|
4
4
|
import type {Path_Id} from './path.js';
|
|
5
5
|
import {SVELTE_MATCHER} from './svelte_helpers.js';
|
|
6
|
-
import {JS_MATCHER, TS_MATCHER} from './
|
|
6
|
+
import {JS_MATCHER, TS_MATCHER} from './constants.js';
|
|
7
7
|
|
|
8
8
|
export const init_lexer = (): Promise<void> => init;
|
|
9
9
|
|
package/src/lib/paths.ts
CHANGED
package/src/lib/publish.task.ts
CHANGED
|
@@ -6,7 +6,6 @@ import {existsSync} from 'node:fs';
|
|
|
6
6
|
import {Task_Error, type Task} from './task.js';
|
|
7
7
|
import {load_package_json, parse_repo_url} from './package_json.js';
|
|
8
8
|
import {find_cli, spawn_cli} from './cli.js';
|
|
9
|
-
import {IS_THIS_GRO} from './paths.js';
|
|
10
9
|
import {has_sveltekit_library} from './sveltekit_helpers.js';
|
|
11
10
|
import {update_changelog} from './changelog.js';
|
|
12
11
|
import {load_from_env} from './env.js';
|
|
@@ -20,13 +19,6 @@ import {
|
|
|
20
19
|
} from './git.js';
|
|
21
20
|
import {CHANGESET_CLI} from './changeset_helpers.js';
|
|
22
21
|
|
|
23
|
-
// publish.task.ts
|
|
24
|
-
// - usage: `gro publish patch`
|
|
25
|
-
// - forwards args to `npm version`: https://docs.npmjs.com/v6/commands/npm-version
|
|
26
|
-
// - runs the production build
|
|
27
|
-
// - publishes to npm from the `main` branch, configurable with `--branch`
|
|
28
|
-
// - syncs commits and tags to the configured main branch
|
|
29
|
-
|
|
30
22
|
export const Args = z
|
|
31
23
|
.object({
|
|
32
24
|
branch: Git_Branch.describe('branch to publish from').default('main'),
|
|
@@ -45,9 +37,7 @@ export const Args = z
|
|
|
45
37
|
.boolean({description: 'build and prepare to publish without actually publishing'})
|
|
46
38
|
.default(false),
|
|
47
39
|
check: z.boolean({description: 'dual of no-check'}).default(true),
|
|
48
|
-
'no-check': z
|
|
49
|
-
.boolean({description: 'opt out of npm checking before publishing'})
|
|
50
|
-
.default(false),
|
|
40
|
+
'no-check': z.boolean({description: 'opt out of checking before publishing'}).default(false),
|
|
51
41
|
build: z.boolean({description: 'dual of no-build'}).default(true),
|
|
52
42
|
'no-build': z.boolean({description: 'opt out of building'}).default(false),
|
|
53
43
|
pull: z.boolean({description: 'dual of no-pull'}).default(true),
|
|
@@ -58,7 +48,7 @@ export const Args = z
|
|
|
58
48
|
export type Args = z.infer<typeof Args>;
|
|
59
49
|
|
|
60
50
|
export const task: Task<Args> = {
|
|
61
|
-
summary: 'bump version, publish to
|
|
51
|
+
summary: 'bump version, publish to the configured registry, and git push',
|
|
62
52
|
Args,
|
|
63
53
|
run: async ({args, log, invoke_task}): Promise<void> => {
|
|
64
54
|
const {
|
|
@@ -84,11 +74,6 @@ export const task: Task<Args> = {
|
|
|
84
74
|
);
|
|
85
75
|
}
|
|
86
76
|
|
|
87
|
-
// TODO hacky, ensures Gro bootstraps itself
|
|
88
|
-
if (IS_THIS_GRO) {
|
|
89
|
-
await spawn('npm', ['run', 'build']);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
77
|
const changelog_exists = existsSync(changelog);
|
|
93
78
|
|
|
94
79
|
const found_changeset_cli = find_cli(changeset_cli);
|
|
@@ -139,9 +124,9 @@ export const task: Task<Args> = {
|
|
|
139
124
|
|
|
140
125
|
// This is the first line that alters the repo.
|
|
141
126
|
|
|
142
|
-
const
|
|
143
|
-
if (!
|
|
144
|
-
throw Error('
|
|
127
|
+
const changeset_ersion_result = await spawn_cli(found_changeset_cli, ['version'], log);
|
|
128
|
+
if (!changeset_ersion_result?.ok) {
|
|
129
|
+
throw Error('changeset version failed: no commits were made: see the error above');
|
|
145
130
|
}
|
|
146
131
|
|
|
147
132
|
if (!preserve_changelog) {
|
|
@@ -185,8 +170,8 @@ export const task: Task<Args> = {
|
|
|
185
170
|
return;
|
|
186
171
|
}
|
|
187
172
|
|
|
188
|
-
const
|
|
189
|
-
if (!
|
|
173
|
+
const changeset_publish_result = await spawn_cli(found_changeset_cli, ['publish'], log);
|
|
174
|
+
if (!changeset_publish_result?.ok) {
|
|
190
175
|
throw new Task_Error(
|
|
191
176
|
`\`${changeset_cli} publish\` failed - continue manually or try again after running \`git reset --hard\``,
|
|
192
177
|
);
|
|
@@ -3,7 +3,7 @@ import {spawn} from '@ryanatkn/belt/process.js';
|
|
|
3
3
|
import {rm} from 'node:fs/promises';
|
|
4
4
|
|
|
5
5
|
import {Task_Error, type Task} from './task.js';
|
|
6
|
-
import {LOCKFILE_FILENAME, NODE_MODULES_DIRNAME} from './
|
|
6
|
+
import {LOCKFILE_FILENAME, NODE_MODULES_DIRNAME} from './constants.js';
|
|
7
7
|
|
|
8
8
|
export const Args = z.object({}).strict();
|
|
9
9
|
export type Args = z.infer<typeof Args>;
|
|
@@ -11,32 +11,32 @@ export type Args = z.infer<typeof Args>;
|
|
|
11
11
|
export const task: Task<Args> = {
|
|
12
12
|
summary: `refreshes ${LOCKFILE_FILENAME} with the latest and cleanest deps`,
|
|
13
13
|
Args,
|
|
14
|
-
run: async ({log}): Promise<void> => {
|
|
15
|
-
log.info(
|
|
16
|
-
const initial_install_result = await spawn(
|
|
14
|
+
run: async ({log, config}): Promise<void> => {
|
|
15
|
+
log.info(`running the initial \`${config.pm_cli} install\``);
|
|
16
|
+
const initial_install_result = await spawn(config.pm_cli, ['install']);
|
|
17
17
|
if (!initial_install_result.ok) {
|
|
18
|
-
throw new Task_Error(
|
|
18
|
+
throw new Task_Error(`Failed initial \`${config.pm_cli} install\``);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
// Deleting both the lockfile and node_modules upgrades to the latest minor/patch versions.
|
|
22
22
|
await Promise.all([rm(LOCKFILE_FILENAME), rm(NODE_MODULES_DIRNAME, {recursive: true})]);
|
|
23
23
|
log.info(
|
|
24
|
-
`running
|
|
24
|
+
`running \`${config.pm_cli} install\` after deleting ${LOCKFILE_FILENAME} and ${NODE_MODULES_DIRNAME}, this can take a while...`,
|
|
25
25
|
);
|
|
26
|
-
const second_install_result = await spawn(
|
|
26
|
+
const second_install_result = await spawn(config.pm_cli, ['install']);
|
|
27
27
|
if (!second_install_result.ok) {
|
|
28
28
|
throw new Task_Error(
|
|
29
|
-
`Failed
|
|
29
|
+
`Failed \`${config.pm_cli} install\` after deleting ${LOCKFILE_FILENAME} and ${NODE_MODULES_DIRNAME}`,
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
// Deleting the lockfile and reinstalling cleans the lockfile of unnecessary dep noise,
|
|
34
34
|
// like esbuild's many packages for each platform.
|
|
35
35
|
await rm(LOCKFILE_FILENAME);
|
|
36
|
-
log.info(`running
|
|
37
|
-
const final_install_result = await spawn(
|
|
36
|
+
log.info(`running \`${config.pm_cli} install\` one last time to clean ${LOCKFILE_FILENAME}`);
|
|
37
|
+
const final_install_result = await spawn(config.pm_cli, ['install']);
|
|
38
38
|
if (!final_install_result.ok) {
|
|
39
|
-
throw new Task_Error(
|
|
39
|
+
throw new Task_Error(`Failed \`${config.pm_cli} install\``);
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
};
|
|
@@ -1,21 +1,32 @@
|
|
|
1
1
|
import {join} from 'node:path';
|
|
2
|
+
import {existsSync} from 'node:fs';
|
|
3
|
+
import {DEV} from 'esm-env';
|
|
2
4
|
|
|
3
|
-
import {Package_Json, load_package_json} from './package_json.js';
|
|
5
|
+
import {Package_Json, Package_Json_Exports, load_package_json} from './package_json.js';
|
|
4
6
|
import {paths} from './paths.js';
|
|
5
|
-
import {NODE_MODULES_DIRNAME} from './
|
|
7
|
+
import {NODE_MODULES_DIRNAME} from './constants.js';
|
|
6
8
|
import type {Resolved_Specifier} from './resolve_specifier.js';
|
|
7
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Like `resolve_specifier` but for Node specifiers,
|
|
12
|
+
* typically those that aren't relative or absolute.
|
|
13
|
+
* Optionally return `null` instead of throwing by setting
|
|
14
|
+
* `throw_on_missing_package` to `false`.
|
|
15
|
+
*/
|
|
8
16
|
export const resolve_node_specifier = (
|
|
9
17
|
specifier: string,
|
|
10
18
|
dir = paths.root,
|
|
11
|
-
|
|
19
|
+
parent_path?: string,
|
|
12
20
|
cache?: Record<string, Package_Json>,
|
|
13
|
-
|
|
14
|
-
|
|
21
|
+
throw_on_missing_package = true,
|
|
22
|
+
// TODO this needs to use `--conditions`/`-C` to determine the correct key
|
|
23
|
+
exports_condition = DEV ? 'development' : 'default',
|
|
24
|
+
): Resolved_Specifier | null => {
|
|
15
25
|
const raw = specifier.endsWith('?raw');
|
|
16
26
|
const mapped_specifier = raw ? specifier.substring(0, specifier.length - 4) : specifier;
|
|
17
27
|
|
|
18
|
-
|
|
28
|
+
// Parse the specifier
|
|
29
|
+
let idx: number = -1;
|
|
19
30
|
if (mapped_specifier[0] === '@') {
|
|
20
31
|
// get the index of the second `/`
|
|
21
32
|
let count = 0;
|
|
@@ -29,21 +40,47 @@ export const resolve_node_specifier = (
|
|
|
29
40
|
} else {
|
|
30
41
|
idx = mapped_specifier.indexOf('/');
|
|
31
42
|
}
|
|
32
|
-
const
|
|
33
|
-
const
|
|
43
|
+
const pkg_name = idx === -1 ? mapped_specifier : mapped_specifier.substring(0, idx);
|
|
44
|
+
const module_path = idx === -1 ? '' : mapped_specifier.substring(idx + 1);
|
|
45
|
+
const subpath = module_path ? './' + module_path : '.';
|
|
46
|
+
const package_dir = join(dir, NODE_MODULES_DIRNAME, pkg_name);
|
|
34
47
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
48
|
+
if (!existsSync(package_dir)) {
|
|
49
|
+
if (throw_on_missing_package) {
|
|
50
|
+
throw Error(
|
|
51
|
+
`Package not found at ${package_dir} for specifier ${specifier}, you may need to install packages or fix the path` +
|
|
52
|
+
(parent_path ? ` imported from ${parent_path}` : ''),
|
|
53
|
+
);
|
|
54
|
+
} else {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const package_json = load_package_json(package_dir, cache, false);
|
|
60
|
+
const {exported, exports_key} = resolve_subpath(package_json, specifier, subpath);
|
|
39
61
|
if (!exported) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
62
|
+
if (throw_on_missing_package) {
|
|
63
|
+
// same error message as Node
|
|
64
|
+
throw Error(
|
|
65
|
+
`[ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath '${subpath}' is not defined by 'exports' in ${package_dir}/package.json` +
|
|
66
|
+
(parent_path ? ` imported from ${parent_path}` : ''),
|
|
67
|
+
);
|
|
68
|
+
} else {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
45
71
|
}
|
|
46
|
-
const
|
|
72
|
+
const exported_value = resolve_exported_value(exported, exports_key, exports_condition);
|
|
73
|
+
if (exported_value === undefined) {
|
|
74
|
+
if (throw_on_missing_package) {
|
|
75
|
+
throw Error(
|
|
76
|
+
`Package subpath '${subpath}' does not define the key '${exports_key}' in 'exports' in ${package_dir}/package.json` +
|
|
77
|
+
(parent_path ? ` imported from ${parent_path}` : ''),
|
|
78
|
+
);
|
|
79
|
+
} else {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const path_id = join(package_dir, exported_value);
|
|
47
84
|
|
|
48
85
|
return {
|
|
49
86
|
path_id,
|
|
@@ -54,3 +91,48 @@ export const resolve_node_specifier = (
|
|
|
54
91
|
namespace: undefined,
|
|
55
92
|
};
|
|
56
93
|
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Resolves the subpath of a package.json `exports` field based on the `specifier`.
|
|
97
|
+
*/
|
|
98
|
+
const resolve_subpath = (
|
|
99
|
+
package_json: Package_Json,
|
|
100
|
+
specifier: string,
|
|
101
|
+
subpath: string,
|
|
102
|
+
): {exported: Package_Json_Exports[string]; exports_key: string} => {
|
|
103
|
+
const exports_key = specifier.endsWith('.svelte') ? 'svelte' : 'default';
|
|
104
|
+
|
|
105
|
+
const exported =
|
|
106
|
+
subpath === '.' && !package_json.exports
|
|
107
|
+
? {[exports_key]: package_json.main}
|
|
108
|
+
: package_json.exports?.[subpath];
|
|
109
|
+
|
|
110
|
+
return {exported, exports_key};
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Resolves the exported value based on the exports key and condition.
|
|
115
|
+
*/
|
|
116
|
+
const resolve_exported_value = (
|
|
117
|
+
exported: Exclude<Package_Json_Exports[string], undefined>,
|
|
118
|
+
exports_key: string,
|
|
119
|
+
exports_condition: string,
|
|
120
|
+
): string | undefined => {
|
|
121
|
+
let exported_value = typeof exported === 'string' ? exported : exported[exports_key];
|
|
122
|
+
|
|
123
|
+
// TODO best effort fallback, support `default` but fall back to `import` or `node` as the exports key.
|
|
124
|
+
if (exported_value === undefined && typeof exported !== 'string' && exports_key === 'default') {
|
|
125
|
+
exported_value = exported.import ?? exported.node;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Possibly resolve to conditional exports.
|
|
129
|
+
exported_value =
|
|
130
|
+
exported_value === undefined || typeof exported_value === 'string'
|
|
131
|
+
? exported_value
|
|
132
|
+
: (exported_value[exports_condition] ??
|
|
133
|
+
exported_value.default ??
|
|
134
|
+
exported_value.import ??
|
|
135
|
+
exported_value.node); // TODO this fallback has corner case bugs for off-spec exports
|
|
136
|
+
|
|
137
|
+
return exported_value;
|
|
138
|
+
};
|
|
@@ -20,13 +20,9 @@ export interface Resolved_Specifier {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* Maps
|
|
23
|
+
* Maps an import `specifier` relative to `dir`,
|
|
24
24
|
* and infer the correct extension following Vite conventions.
|
|
25
|
-
* If no `.js` file is found for the
|
|
26
|
-
* @param specifier
|
|
27
|
-
* @param dir - if defined, enables relative importers like from esbuild plugins
|
|
28
|
-
* @param passthrough_extensions - used to support specifiers that have no file extention, which Vite supports, so we do our best effort
|
|
29
|
-
* @returns
|
|
25
|
+
* If no `.js` file is found for the specifier on the filesystem, it assumes `.ts`.
|
|
30
26
|
*/
|
|
31
27
|
export const resolve_specifier = (specifier: string, dir: string): Resolved_Specifier => {
|
|
32
28
|
const raw = specifier.endsWith('?raw');
|
package/src/lib/run_task.ts
CHANGED
|
@@ -72,7 +72,7 @@ export const run_task = async (
|
|
|
72
72
|
: `Unexpected error running task ${st(
|
|
73
73
|
'cyan',
|
|
74
74
|
task_meta.name,
|
|
75
|
-
)}. If this is unexpected try running
|
|
75
|
+
)}. If this is unexpected try running \`${config.pm_cli} install\` and \`gro clean\`.`,
|
|
76
76
|
),
|
|
77
77
|
error: err,
|
|
78
78
|
};
|
|
@@ -2,7 +2,7 @@ import type {Config as SveltekitConfig} from '@sveltejs/kit';
|
|
|
2
2
|
import type {CompileOptions, ModuleCompileOptions, PreprocessorGroup} from 'svelte/compiler';
|
|
3
3
|
import {join} from 'node:path';
|
|
4
4
|
|
|
5
|
-
import {SVELTEKIT_CONFIG_FILENAME} from './
|
|
5
|
+
import {SVELTEKIT_CONFIG_FILENAME} from './constants.js';
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
8
|
|
|
@@ -57,7 +57,7 @@ export interface Parsed_Sveltekit_Config {
|
|
|
57
57
|
private_prefix: string | undefined;
|
|
58
58
|
public_prefix: string | undefined;
|
|
59
59
|
svelte_compile_options: CompileOptions;
|
|
60
|
-
svelte_compile_module_options:
|
|
60
|
+
svelte_compile_module_options: ModuleCompileOptions;
|
|
61
61
|
svelte_preprocessors: PreprocessorGroup | PreprocessorGroup[] | undefined;
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -5,7 +5,7 @@ import {join} from 'node:path';
|
|
|
5
5
|
|
|
6
6
|
import {Package_Json, has_dep} from './package_json.js';
|
|
7
7
|
import {default_sveltekit_config, type Parsed_Sveltekit_Config} from './sveltekit_config.js';
|
|
8
|
-
import {SVELTEKIT_CONFIG_FILENAME, SVELTEKIT_DEV_DIRNAME} from './
|
|
8
|
+
import {SVELTEKIT_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';
|
|
@@ -33,6 +33,7 @@ export const has_sveltekit_library = (
|
|
|
33
33
|
package_json?: Package_Json,
|
|
34
34
|
sveltekit_config: Parsed_Sveltekit_Config = default_sveltekit_config,
|
|
35
35
|
dep_name = SVELTE_PACKAGE_DEP_NAME,
|
|
36
|
+
pm_cli = PM_CLI_DEFAULT, // TODO source from config when possible, is just needed for error messages
|
|
36
37
|
): Result<object, {message: string}> => {
|
|
37
38
|
const has_sveltekit_app_result = has_sveltekit_app();
|
|
38
39
|
if (!has_sveltekit_app_result.ok) {
|
|
@@ -46,7 +47,7 @@ export const has_sveltekit_library = (
|
|
|
46
47
|
if (!has_dep(dep_name, package_json)) {
|
|
47
48
|
return {
|
|
48
49
|
ok: false,
|
|
49
|
-
message: `no dependency found in package.json for ${dep_name}, install it with
|
|
50
|
+
message: `no dependency found in package.json for ${dep_name}, install it with \`${pm_cli} install -D ${dep_name}\``,
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
53
|
|
|
@@ -55,11 +56,12 @@ export const has_sveltekit_library = (
|
|
|
55
56
|
|
|
56
57
|
export const sveltekit_sync = async (
|
|
57
58
|
sveltekit_cli: string | Cli = SVELTEKIT_CLI,
|
|
59
|
+
pm_cli = PM_CLI_DEFAULT, // TODO source from config when possible, is just needed for error messages
|
|
58
60
|
): Promise<void> => {
|
|
59
61
|
const result = await spawn_cli(sveltekit_cli, ['sync']);
|
|
60
62
|
if (!result) {
|
|
61
63
|
throw new Task_Error(
|
|
62
|
-
`Failed to find SvelteKit CLI \`${to_cli_name(sveltekit_cli)}\`, do you need to run
|
|
64
|
+
`Failed to find SvelteKit CLI \`${to_cli_name(sveltekit_cli)}\`, do you need to run \`${pm_cli} install\`?`,
|
|
63
65
|
);
|
|
64
66
|
} else if (!result.ok) {
|
|
65
67
|
throw new Task_Error(`Failed ${to_cli_name(sveltekit_cli)} sync`);
|
|
@@ -151,6 +153,7 @@ export const run_svelte_package = async (
|
|
|
151
153
|
options: Svelte_Package_Options | undefined,
|
|
152
154
|
cli: string | Cli,
|
|
153
155
|
log: Logger,
|
|
156
|
+
pm_cli: string,
|
|
154
157
|
): Promise<void> => {
|
|
155
158
|
const has_sveltekit_library_result = has_sveltekit_library();
|
|
156
159
|
if (!has_sveltekit_library_result.ok) {
|
|
@@ -162,7 +165,7 @@ export const run_svelte_package = async (
|
|
|
162
165
|
const found_svelte_package_cli = cli === cli_name ? find_cli(cli) : (cli as Cli);
|
|
163
166
|
if (found_svelte_package_cli?.kind !== 'local') {
|
|
164
167
|
throw new Task_Error(
|
|
165
|
-
`Failed to find SvelteKit packaging CLI \`${cli_name}\`, do you need to run
|
|
168
|
+
`Failed to find SvelteKit packaging CLI \`${cli_name}\`, do you need to run \`${pm_cli} install\`?`,
|
|
166
169
|
);
|
|
167
170
|
}
|
|
168
171
|
const serialized_args = serialize_args({
|