@ryanatkn/gro 0.128.0 → 0.129.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/args.d.ts +2 -2
- package/dist/args.js +2 -2
- package/dist/changelog.js +1 -1
- package/dist/changelog.test.js +2 -2
- package/dist/changeset.task.js +6 -6
- package/dist/cli.js +1 -1
- package/dist/config.d.ts +1 -3
- package/dist/config.js +2 -2
- package/dist/deploy.task.js +1 -1
- package/dist/docs/README.gen.md.js +1 -1
- package/dist/docs/dev.md +1 -1
- package/dist/docs/package_json.md +2 -1
- package/dist/env.d.ts +2 -2
- package/dist/env.js +10 -11
- package/dist/esbuild_helpers.js +2 -1
- package/dist/esbuild_plugin_external_worker.js +1 -1
- package/dist/esbuild_plugin_svelte.js +3 -3
- package/dist/esbuild_plugin_sveltekit_local_imports.js +2 -2
- package/dist/esbuild_plugin_sveltekit_shim_env.js +2 -2
- package/dist/format_file.js +2 -2
- package/dist/gen.d.ts +10 -12
- package/dist/gen.js +3 -3
- package/dist/gen.task.js +1 -1
- package/dist/gen.test.js +2 -5
- package/dist/git.d.ts +2 -2
- package/dist/gro.config.default.js +1 -1
- package/dist/gro.js +2 -2
- package/dist/gro_helpers.d.ts +6 -1
- package/dist/gro_helpers.js +22 -11
- package/dist/gro_plugin_gen.js +3 -4
- package/dist/gro_plugin_server.d.ts +5 -7
- package/dist/gro_plugin_server.js +3 -3
- package/dist/gro_plugin_sveltekit_app.d.ts +3 -5
- package/dist/gro_plugin_sveltekit_app.js +38 -28
- package/dist/gro_plugin_sveltekit_library.d.ts +2 -2
- package/dist/gro_plugin_sveltekit_library.js +2 -2
- package/dist/input_path.test.js +1 -1
- package/dist/invoke_task.js +3 -3
- package/dist/lint.task.js +1 -2
- package/dist/loader.js +3 -3
- package/dist/package.d.ts +8 -10
- package/dist/package.gen.js +3 -3
- package/dist/package.js +20 -16
- package/dist/package_json.d.ts +4 -6
- package/dist/package_json.js +14 -15
- package/dist/package_json.test.js +12 -12
- package/dist/path.d.ts +2 -6
- package/dist/plugin.d.ts +1 -3
- package/dist/plugin.js +2 -2
- package/dist/plugin.test.js +3 -3
- package/dist/publish.task.js +4 -4
- package/dist/reinstall.task.js +1 -1
- package/dist/release.task.js +2 -2
- package/dist/resolve.task.js +1 -1
- package/dist/resolve_node_specifier.d.ts +1 -1
- package/dist/resolve_node_specifier.js +2 -2
- package/dist/resolve_node_specifier.test.js +6 -6
- package/dist/resolve_specifier.d.ts +1 -1
- package/dist/resolve_specifier.js +1 -1
- package/dist/resolve_specifier.test.js +16 -16
- package/dist/run.task.js +1 -1
- package/dist/run_gen.test.js +11 -11
- package/dist/run_task.js +1 -1
- package/dist/run_task.test.js +3 -2
- package/dist/src_json.d.ts +3 -5
- package/dist/src_json.js +11 -13
- package/dist/src_json.test.js +2 -2
- package/dist/sveltekit_config.js +1 -1
- package/dist/sveltekit_helpers.d.ts +4 -4
- package/dist/sveltekit_helpers.js +4 -4
- package/dist/sveltekit_shim_env.d.ts +1 -1
- package/dist/sveltekit_shim_env.js +2 -2
- package/dist/task.d.ts +1 -1
- package/dist/task_logging.d.ts +1 -1
- package/dist/task_logging.js +3 -4
- package/dist/upgrade.task.js +1 -1
- package/dist/watch_dir.d.ts +1 -3
- package/dist/watch_dir.js +6 -6
- package/package.json +20 -22
- package/dist/fs.test.d.ts +0 -1
- package/dist/fs.test.js +0 -16
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { test } from 'uvu';
|
|
2
2
|
import * as assert from 'uvu/assert';
|
|
3
3
|
import { Package_Json, load_package_json, parse_repo_url, serialize_package_json, to_package_exports, } from './package_json.js';
|
|
4
|
-
test('load_package_json',
|
|
5
|
-
const package_json =
|
|
4
|
+
test('load_package_json', () => {
|
|
5
|
+
const package_json = load_package_json();
|
|
6
6
|
assert.ok(package_json);
|
|
7
7
|
const parsed = Package_Json.parse(package_json);
|
|
8
8
|
assert.ok(parsed);
|
|
9
9
|
serialize_package_json(package_json);
|
|
10
10
|
});
|
|
11
|
-
test('load_package_json with cache',
|
|
11
|
+
test('load_package_json with cache', () => {
|
|
12
12
|
const cache = {};
|
|
13
|
-
const package_json1 =
|
|
13
|
+
const package_json1 = load_package_json(undefined, cache);
|
|
14
14
|
assert.ok(package_json1);
|
|
15
15
|
assert.is(Object.keys(cache).length, 1);
|
|
16
|
-
const package_json2 =
|
|
16
|
+
const package_json2 = load_package_json(undefined, cache);
|
|
17
17
|
assert.is(Object.keys(cache).length, 1);
|
|
18
18
|
assert.is(package_json1, package_json2);
|
|
19
19
|
});
|
|
20
|
-
test('Package_Json.parse',
|
|
20
|
+
test('Package_Json.parse', () => {
|
|
21
21
|
Package_Json.parse({ name: 'abc', version: '123' });
|
|
22
22
|
});
|
|
23
|
-
test('Package_Json.parse fails with bad data',
|
|
23
|
+
test('Package_Json.parse fails with bad data', () => {
|
|
24
24
|
let err;
|
|
25
25
|
try {
|
|
26
26
|
Package_Json.parse({ version: '123' });
|
|
@@ -30,10 +30,10 @@ test('Package_Json.parse fails with bad data', async () => {
|
|
|
30
30
|
}
|
|
31
31
|
assert.ok(err);
|
|
32
32
|
});
|
|
33
|
-
test('serialize_package_json',
|
|
33
|
+
test('serialize_package_json', () => {
|
|
34
34
|
serialize_package_json({ name: 'abc', version: '123' });
|
|
35
35
|
});
|
|
36
|
-
test('serialize_package_json fails with bad data',
|
|
36
|
+
test('serialize_package_json fails with bad data', () => {
|
|
37
37
|
let err;
|
|
38
38
|
try {
|
|
39
39
|
serialize_package_json({ version: '123' });
|
|
@@ -43,7 +43,7 @@ test('serialize_package_json fails with bad data', async () => {
|
|
|
43
43
|
}
|
|
44
44
|
assert.ok(err);
|
|
45
45
|
});
|
|
46
|
-
test('to_package_exports',
|
|
46
|
+
test('to_package_exports', () => {
|
|
47
47
|
assert.equal(to_package_exports(['a/b.ts']), {
|
|
48
48
|
'./package.json': './package.json',
|
|
49
49
|
'./a/b.js': {
|
|
@@ -76,8 +76,8 @@ test('to_package_exports', async () => {
|
|
|
76
76
|
},
|
|
77
77
|
});
|
|
78
78
|
});
|
|
79
|
-
test('parse_repo_url',
|
|
80
|
-
const parsed = parse_repo_url(
|
|
79
|
+
test('parse_repo_url', () => {
|
|
80
|
+
const parsed = parse_repo_url(load_package_json());
|
|
81
81
|
assert.is(parsed?.owner, 'ryanatkn');
|
|
82
82
|
assert.is(parsed?.repo, 'gro');
|
|
83
83
|
});
|
package/dist/path.d.ts
CHANGED
|
@@ -10,10 +10,6 @@ export interface Path_Info {
|
|
|
10
10
|
export interface Resolved_Path extends Path_Info {
|
|
11
11
|
path: string;
|
|
12
12
|
}
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
export interface File_Filter {
|
|
17
|
-
(path: string): boolean;
|
|
18
|
-
}
|
|
13
|
+
export type Path_Filter = (path: string, is_directory: boolean) => boolean;
|
|
14
|
+
export type File_Filter = (path: string) => boolean;
|
|
19
15
|
export declare const to_file_path: (path_or_url: string | URL) => string;
|
package/dist/plugin.d.ts
CHANGED
|
@@ -9,9 +9,7 @@ export interface Plugin<T_Plugin_Context extends Plugin_Context = Plugin_Context
|
|
|
9
9
|
adapt?: (ctx: T_Plugin_Context) => void | Promise<void>;
|
|
10
10
|
teardown?: (ctx: T_Plugin_Context) => void | Promise<void>;
|
|
11
11
|
}
|
|
12
|
-
export
|
|
13
|
-
(ctx: T_Plugin_Context): (Plugin<T_Plugin_Context> | null | Array<Plugin<T_Plugin_Context> | null>) | Promise<Plugin<T_Plugin_Context> | null | Array<Plugin<T_Plugin_Context> | null>>;
|
|
14
|
-
}
|
|
12
|
+
export type Create_Config_Plugins<T_Plugin_Context extends Plugin_Context = Plugin_Context> = (ctx: T_Plugin_Context) => (Plugin<T_Plugin_Context> | null | Array<Plugin<T_Plugin_Context> | null>) | Promise<Plugin<T_Plugin_Context> | null | Array<Plugin<T_Plugin_Context> | null>>;
|
|
15
13
|
export interface Plugin_Context<T_Args = object> extends Task_Context<T_Args> {
|
|
16
14
|
dev: boolean;
|
|
17
15
|
watch: boolean;
|
package/dist/plugin.js
CHANGED
|
@@ -10,7 +10,7 @@ export class Plugins {
|
|
|
10
10
|
static async create(ctx) {
|
|
11
11
|
const { timings } = ctx;
|
|
12
12
|
const timing_to_create = timings.start('plugins.create');
|
|
13
|
-
const instances = to_array(await ctx.config.plugins(ctx)).filter(
|
|
13
|
+
const instances = to_array(await ctx.config.plugins(ctx)).filter((v) => v !== null); // TODO remove cast, should infer the type predicate? `Type '(Plugin<Plugin_Context<object>> | null)[]' is not assignable to type 'Plugin<Plugin_Context<object>>[]'.`
|
|
14
14
|
const plugins = new Plugins(ctx, instances);
|
|
15
15
|
timing_to_create();
|
|
16
16
|
return plugins;
|
|
@@ -70,7 +70,7 @@ export class Plugins {
|
|
|
70
70
|
* @returns `plugins` with `new_plugin` at the index of the plugin with `name`
|
|
71
71
|
*/
|
|
72
72
|
export const replace_plugin = (plugins, new_plugin, name = new_plugin.name) => {
|
|
73
|
-
const array = to_array(plugins).filter(
|
|
73
|
+
const array = to_array(plugins).filter((v) => v !== null);
|
|
74
74
|
const index = array.findIndex((p) => p.name === name);
|
|
75
75
|
if (index === -1)
|
|
76
76
|
throw Error('Failed to find plugin to replace: ' + name);
|
package/dist/plugin.test.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { test } from 'uvu';
|
|
2
2
|
import * as assert from 'uvu/assert';
|
|
3
3
|
import { replace_plugin } from './plugin.js';
|
|
4
|
-
test('replace_plugin',
|
|
4
|
+
test('replace_plugin', () => {
|
|
5
5
|
const a = { name: 'a' };
|
|
6
6
|
const b = { name: 'b' };
|
|
7
7
|
const c = { name: 'c' };
|
|
@@ -32,13 +32,13 @@ test('replace_plugin', async () => {
|
|
|
32
32
|
assert.is(p[1], b2);
|
|
33
33
|
assert.is(p[2], c2);
|
|
34
34
|
});
|
|
35
|
-
test('replace_plugin without an array',
|
|
35
|
+
test('replace_plugin without an array', () => {
|
|
36
36
|
const a = { name: 'a' };
|
|
37
37
|
const a2 = { name: 'a' };
|
|
38
38
|
const p = replace_plugin(a, a2);
|
|
39
39
|
assert.is(p[0], a2);
|
|
40
40
|
});
|
|
41
|
-
test('replace_plugin throws if it cannot find the given name',
|
|
41
|
+
test('replace_plugin throws if it cannot find the given name', () => {
|
|
42
42
|
const a = { name: 'a' };
|
|
43
43
|
const plugins = [a];
|
|
44
44
|
let err;
|
package/dist/publish.task.js
CHANGED
|
@@ -52,7 +52,7 @@ export const task = {
|
|
|
52
52
|
if (dry) {
|
|
53
53
|
log.info(green('dry run!'));
|
|
54
54
|
}
|
|
55
|
-
const has_sveltekit_library_result =
|
|
55
|
+
const has_sveltekit_library_result = has_sveltekit_library();
|
|
56
56
|
if (!has_sveltekit_library_result.ok) {
|
|
57
57
|
throw new Task_Error('Failed to find SvelteKit library: ' + has_sveltekit_library_result.message);
|
|
58
58
|
}
|
|
@@ -88,7 +88,7 @@ export const task = {
|
|
|
88
88
|
log.info('dry run, skipping changeset version');
|
|
89
89
|
}
|
|
90
90
|
else {
|
|
91
|
-
const package_json_before =
|
|
91
|
+
const package_json_before = load_package_json();
|
|
92
92
|
if (typeof package_json_before.version !== 'string') {
|
|
93
93
|
throw new Task_Error('Failed to find package.json version');
|
|
94
94
|
}
|
|
@@ -104,13 +104,13 @@ export const task = {
|
|
|
104
104
|
throw Error('npm version failed: no commits were made: see the error above');
|
|
105
105
|
}
|
|
106
106
|
if (!preserve_changelog) {
|
|
107
|
-
const token =
|
|
107
|
+
const token = load_from_env('GITHUB_TOKEN_SECRET');
|
|
108
108
|
if (!token) {
|
|
109
109
|
log.warn('the env var GITHUB_TOKEN_SECRET was not found, so API calls with be unauthorized');
|
|
110
110
|
}
|
|
111
111
|
await update_changelog(parsed_repo_url.owner, parsed_repo_url.repo, changelog, token, log);
|
|
112
112
|
}
|
|
113
|
-
const package_json_after =
|
|
113
|
+
const package_json_after = load_package_json();
|
|
114
114
|
version = package_json_after.version;
|
|
115
115
|
if (package_json_before.version === version) {
|
|
116
116
|
// The version didn't change.
|
package/dist/reinstall.task.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { spawn } from '@ryanatkn/belt/process.js';
|
|
3
|
-
import { rm } from 'fs/promises';
|
|
3
|
+
import { rm } from 'node:fs/promises';
|
|
4
4
|
import { Task_Error } from './task.js';
|
|
5
5
|
import { LOCKFILE_FILENAME, NODE_MODULES_DIRNAME } from './path_constants.js';
|
|
6
6
|
export const Args = z.object({}).strict();
|
package/dist/release.task.js
CHANGED
|
@@ -5,11 +5,11 @@ export const task = {
|
|
|
5
5
|
summary: 'publish and deploy',
|
|
6
6
|
Args,
|
|
7
7
|
run: async ({ invoke_task }) => {
|
|
8
|
-
const publish =
|
|
8
|
+
const publish = has_sveltekit_library().ok;
|
|
9
9
|
if (publish) {
|
|
10
10
|
await invoke_task('publish', { optional: true });
|
|
11
11
|
}
|
|
12
|
-
if (
|
|
12
|
+
if (has_sveltekit_app().ok) {
|
|
13
13
|
await invoke_task('deploy', { build: !publish });
|
|
14
14
|
}
|
|
15
15
|
},
|
package/dist/resolve.task.js
CHANGED
|
@@ -9,7 +9,7 @@ export const Args = z
|
|
|
9
9
|
export const task = {
|
|
10
10
|
summary: 'diagnostic that logs resolved filesystem info for the given input paths',
|
|
11
11
|
Args,
|
|
12
|
-
run:
|
|
12
|
+
run: ({ args, config, log }) => {
|
|
13
13
|
const { _ } = args;
|
|
14
14
|
log.info('raw input paths:', _);
|
|
15
15
|
const input_paths = to_input_paths(_);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Package_Json } from './package_json.js';
|
|
2
2
|
import type { Path_Id } from './path.js';
|
|
3
|
-
export declare const resolve_node_specifier: (specifier: string, dir?: string, parent_url?: string, cache?: Record<string, Package_Json>, exports_key?: string) =>
|
|
3
|
+
export declare const resolve_node_specifier: (specifier: string, dir?: string, parent_url?: string, cache?: Record<string, Package_Json>, exports_key?: string) => Path_Id;
|
|
4
4
|
export interface Parsed_Node_Specifier {
|
|
5
5
|
name: string;
|
|
6
6
|
path: string;
|
|
@@ -2,11 +2,11 @@ import { join } from 'node:path';
|
|
|
2
2
|
import { Package_Json, load_package_json } from './package_json.js';
|
|
3
3
|
import { paths } from './paths.js';
|
|
4
4
|
import { NODE_MODULES_DIRNAME } from './path_constants.js';
|
|
5
|
-
export const resolve_node_specifier =
|
|
5
|
+
export const resolve_node_specifier = (specifier, dir = paths.root, parent_url, cache, exports_key = specifier.endsWith('.svelte') ? 'svelte' : 'default') => {
|
|
6
6
|
const parsed = parse_node_specifier(specifier);
|
|
7
7
|
const subpath = './' + parsed.path;
|
|
8
8
|
const package_dir = join(dir, NODE_MODULES_DIRNAME, parsed.name);
|
|
9
|
-
const package_json =
|
|
9
|
+
const package_json = load_package_json(package_dir, cache);
|
|
10
10
|
const exported = package_json.exports?.[subpath];
|
|
11
11
|
if (!exported) {
|
|
12
12
|
// same error message as Node
|
|
@@ -2,16 +2,16 @@ import { test } from 'uvu';
|
|
|
2
2
|
import * as assert from 'uvu/assert';
|
|
3
3
|
import { resolve_node_specifier } from './resolve_node_specifier.js';
|
|
4
4
|
import { paths } from './paths.js';
|
|
5
|
-
test('resolves a JS specifier',
|
|
6
|
-
assert.is(
|
|
5
|
+
test('resolves a JS specifier', () => {
|
|
6
|
+
assert.is(resolve_node_specifier('@ryanatkn/fuz/tome.js'), paths.root + 'node_modules/@ryanatkn/fuz/dist/tome.js');
|
|
7
7
|
});
|
|
8
|
-
test('resolves a Svelte specifier',
|
|
9
|
-
assert.is(
|
|
8
|
+
test('resolves a Svelte specifier', () => {
|
|
9
|
+
assert.is(resolve_node_specifier('@ryanatkn/fuz/Library.svelte'), paths.root + 'node_modules/@ryanatkn/fuz/dist/Library.svelte');
|
|
10
10
|
});
|
|
11
|
-
test('throws for a specifier that does not exist',
|
|
11
|
+
test('throws for a specifier that does not exist', () => {
|
|
12
12
|
let err;
|
|
13
13
|
try {
|
|
14
|
-
|
|
14
|
+
resolve_node_specifier('@ryanatkn/fuz/this_does_not_exist');
|
|
15
15
|
}
|
|
16
16
|
catch (_err) {
|
|
17
17
|
err = _err;
|
|
@@ -13,4 +13,4 @@ export interface Resolved_Specifier {
|
|
|
13
13
|
* @param passthrough_extensions - used to support specifiers that have no file extention, which Vite supports, so we do our best effort
|
|
14
14
|
* @returns
|
|
15
15
|
*/
|
|
16
|
-
export declare const resolve_specifier: (path: string, dir: string) =>
|
|
16
|
+
export declare const resolve_specifier: (path: string, dir: string) => Resolved_Specifier;
|
|
@@ -10,7 +10,7 @@ import { replace_extension } from './paths.js';
|
|
|
10
10
|
* @param passthrough_extensions - used to support specifiers that have no file extention, which Vite supports, so we do our best effort
|
|
11
11
|
* @returns
|
|
12
12
|
*/
|
|
13
|
-
export const resolve_specifier =
|
|
13
|
+
export const resolve_specifier = (path, dir) => {
|
|
14
14
|
const absolute_path = isAbsolute(path) ? path : join(dir, path);
|
|
15
15
|
let mapped_path;
|
|
16
16
|
let path_id;
|
|
@@ -4,60 +4,60 @@ import { join } from 'node:path';
|
|
|
4
4
|
import { resolve_specifier } from './resolve_specifier.js';
|
|
5
5
|
import { paths } from './paths.js';
|
|
6
6
|
const dir = paths.source + 'fixtures/';
|
|
7
|
-
test('resolves a specifier to a file that exists with an unknown file extension',
|
|
8
|
-
assert.equal(
|
|
7
|
+
test('resolves a specifier to a file that exists with an unknown file extension', () => {
|
|
8
|
+
assert.equal(resolve_specifier(join(dir, 'test_file.other.ext'), dir), {
|
|
9
9
|
specifier: './test_file.other.ext',
|
|
10
10
|
path_id: join(dir, 'test_file.other.ext'),
|
|
11
11
|
namespace: undefined,
|
|
12
12
|
});
|
|
13
13
|
});
|
|
14
|
-
test('resolves a ts specifier',
|
|
15
|
-
assert.equal(
|
|
14
|
+
test('resolves a ts specifier', () => {
|
|
15
|
+
assert.equal(resolve_specifier(join(dir, 'test_ts.ts'), dir), {
|
|
16
16
|
specifier: './test_ts.js',
|
|
17
17
|
path_id: join(dir, 'test_ts.ts'),
|
|
18
18
|
namespace: 'sveltekit_local_imports_ts',
|
|
19
19
|
});
|
|
20
20
|
});
|
|
21
|
-
test('resolves relative ts specifiers',
|
|
22
|
-
assert.equal(
|
|
21
|
+
test('resolves relative ts specifiers', () => {
|
|
22
|
+
assert.equal(resolve_specifier('./test_ts.ts', dir), {
|
|
23
23
|
specifier: './test_ts.js',
|
|
24
24
|
path_id: join(dir, 'test_ts.ts'),
|
|
25
25
|
namespace: 'sveltekit_local_imports_ts',
|
|
26
26
|
});
|
|
27
|
-
assert.equal(
|
|
27
|
+
assert.equal(resolve_specifier('./a/b/test_ts.ts', dir), {
|
|
28
28
|
specifier: './a/b/test_ts.js',
|
|
29
29
|
path_id: join(dir, 'a/b/test_ts.ts'),
|
|
30
30
|
namespace: 'sveltekit_local_imports_ts',
|
|
31
31
|
});
|
|
32
|
-
assert.equal(
|
|
32
|
+
assert.equal(resolve_specifier('../../test_ts.ts', dir), {
|
|
33
33
|
specifier: '../../test_ts.js',
|
|
34
34
|
path_id: join(dir, '../../test_ts.ts'),
|
|
35
35
|
namespace: 'sveltekit_local_imports_ts',
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
|
-
test('resolves an extensionless specifier',
|
|
39
|
-
assert.equal(
|
|
38
|
+
test('resolves an extensionless specifier', () => {
|
|
39
|
+
assert.equal(resolve_specifier(join(dir, 'test_ts'), dir), {
|
|
40
40
|
specifier: './test_ts.js',
|
|
41
41
|
path_id: join(dir, 'test_ts.ts'),
|
|
42
42
|
namespace: 'sveltekit_local_imports_ts',
|
|
43
43
|
});
|
|
44
44
|
});
|
|
45
|
-
test('resolves a js specifier',
|
|
46
|
-
assert.equal(
|
|
45
|
+
test('resolves a js specifier', () => {
|
|
46
|
+
assert.equal(resolve_specifier(join(dir, 'test_js.js'), dir), {
|
|
47
47
|
specifier: './test_js.js',
|
|
48
48
|
path_id: join(dir, 'test_js.js'),
|
|
49
49
|
namespace: 'sveltekit_local_imports_js',
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
-
test('resolves a js specifier as ts for a file that does not exist',
|
|
53
|
-
assert.equal(
|
|
52
|
+
test('resolves a js specifier as ts for a file that does not exist', () => {
|
|
53
|
+
assert.equal(resolve_specifier(join(dir, 'test_missing.js'), dir), {
|
|
54
54
|
specifier: './test_missing.js',
|
|
55
55
|
path_id: join(dir, 'test_missing.ts'),
|
|
56
56
|
namespace: 'sveltekit_local_imports_ts',
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
|
-
test('resolves an extensionless specifier for a file that does not exist',
|
|
60
|
-
assert.equal(
|
|
59
|
+
test('resolves an extensionless specifier for a file that does not exist', () => {
|
|
60
|
+
assert.equal(resolve_specifier(join(dir, 'test_missing'), dir), {
|
|
61
61
|
specifier: './test_missing.js',
|
|
62
62
|
path_id: join(dir, 'test_missing.ts'),
|
|
63
63
|
namespace: 'sveltekit_local_imports_ts',
|
package/dist/run.task.js
CHANGED
|
@@ -22,7 +22,7 @@ export const task = {
|
|
|
22
22
|
if (!existsSync(path)) {
|
|
23
23
|
throw new Task_Error('Cannot find file to run at path: ' + path);
|
|
24
24
|
}
|
|
25
|
-
const loader_path =
|
|
25
|
+
const loader_path = resolve_gro_module_path('loader.js');
|
|
26
26
|
const spawned = await spawn_with_loader(loader_path, path, argv);
|
|
27
27
|
if (!spawned.ok) {
|
|
28
28
|
throw new Task_Error(`\`gro run ${path}\` failed with exit code ${spawned.code}`);
|
package/dist/run_gen.test.js
CHANGED
|
@@ -18,7 +18,7 @@ test__gen('basic behavior', async () => {
|
|
|
18
18
|
const mod_a = {
|
|
19
19
|
id: path_id_a,
|
|
20
20
|
mod: {
|
|
21
|
-
gen:
|
|
21
|
+
gen: (ctx) => {
|
|
22
22
|
assert.is(ctx.origin_id, path_id_a);
|
|
23
23
|
if (file_a)
|
|
24
24
|
throw Error('Already generated file_a');
|
|
@@ -33,7 +33,7 @@ test__gen('basic behavior', async () => {
|
|
|
33
33
|
const mod_b = {
|
|
34
34
|
id: join(path_id_bc, 'mod_b.gen.ts'),
|
|
35
35
|
mod: {
|
|
36
|
-
gen:
|
|
36
|
+
gen: (ctx) => {
|
|
37
37
|
assert.is(ctx.origin_id, mod_b.id);
|
|
38
38
|
if (file_b)
|
|
39
39
|
throw Error('Already generated file_b');
|
|
@@ -48,7 +48,7 @@ test__gen('basic behavior', async () => {
|
|
|
48
48
|
const mod_c = {
|
|
49
49
|
id: join(path_id_bc, 'mod_c.gen.ts'),
|
|
50
50
|
mod: {
|
|
51
|
-
gen:
|
|
51
|
+
gen: (ctx) => {
|
|
52
52
|
assert.is(ctx.origin_id, mod_c.id);
|
|
53
53
|
if (file_c1)
|
|
54
54
|
throw Error('Already generated file_c1');
|
|
@@ -67,7 +67,7 @@ test__gen('basic behavior', async () => {
|
|
|
67
67
|
},
|
|
68
68
|
};
|
|
69
69
|
const gen_modules_by_input_path = [mod_a, mod_b, mod_c];
|
|
70
|
-
const gen_results = await run_gen(gen_modules_by_input_path, await load_config(), log, new Timings(),
|
|
70
|
+
const gen_results = await run_gen(gen_modules_by_input_path, await load_config(), log, new Timings(), (content, opts) => Promise.resolve(opts.filepath.endsWith('output_b.ts') ? `${content}/*FORMATTED*/` : content));
|
|
71
71
|
assert.is(gen_results.input_count, 3);
|
|
72
72
|
assert.is(gen_results.output_count, 4);
|
|
73
73
|
assert.is(gen_results.successes.length, 3);
|
|
@@ -77,7 +77,7 @@ test__gen('basic behavior', async () => {
|
|
|
77
77
|
assert.is(gen_results.results[1], gen_results.successes[1]);
|
|
78
78
|
assert.is(gen_results.results[2], gen_results.successes[2]);
|
|
79
79
|
const result_a = gen_results.results[0];
|
|
80
|
-
assert.ok(result_a
|
|
80
|
+
assert.ok(result_a.ok);
|
|
81
81
|
assert.ok(file_a);
|
|
82
82
|
assert.equal(result_a.files, [
|
|
83
83
|
{
|
|
@@ -88,7 +88,7 @@ test__gen('basic behavior', async () => {
|
|
|
88
88
|
},
|
|
89
89
|
]);
|
|
90
90
|
const result_b = gen_results.results[1];
|
|
91
|
-
assert.ok(result_b
|
|
91
|
+
assert.ok(result_b.ok);
|
|
92
92
|
assert.ok(file_b);
|
|
93
93
|
assert.equal(result_b.files, [
|
|
94
94
|
{
|
|
@@ -99,7 +99,7 @@ test__gen('basic behavior', async () => {
|
|
|
99
99
|
},
|
|
100
100
|
]);
|
|
101
101
|
const result_c = gen_results.results[2];
|
|
102
|
-
assert.ok(result_c
|
|
102
|
+
assert.ok(result_c.ok);
|
|
103
103
|
assert.ok(file_c1);
|
|
104
104
|
assert.ok(file_c2);
|
|
105
105
|
assert.equal(result_c.files, [
|
|
@@ -127,7 +127,7 @@ test__gen('failing gen function', async () => {
|
|
|
127
127
|
const mod_a = {
|
|
128
128
|
id: path_id_a,
|
|
129
129
|
mod: {
|
|
130
|
-
gen:
|
|
130
|
+
gen: () => {
|
|
131
131
|
genError = Error('This fails for testing');
|
|
132
132
|
throw genError;
|
|
133
133
|
},
|
|
@@ -136,7 +136,7 @@ test__gen('failing gen function', async () => {
|
|
|
136
136
|
const mod_b = {
|
|
137
137
|
id: join(path_idB, 'mod_b.gen.ts'),
|
|
138
138
|
mod: {
|
|
139
|
-
gen:
|
|
139
|
+
gen: (ctx) => {
|
|
140
140
|
assert.is(ctx.origin_id, mod_b.id);
|
|
141
141
|
if (file_b)
|
|
142
142
|
throw Error('Already generated file_b');
|
|
@@ -159,11 +159,11 @@ test__gen('failing gen function', async () => {
|
|
|
159
159
|
assert.is(gen_results.results[1], gen_results.successes[0]);
|
|
160
160
|
const result_a = gen_results.results[0];
|
|
161
161
|
assert.ok(result_a);
|
|
162
|
-
assert.ok(!result_a
|
|
162
|
+
assert.ok(!result_a.ok);
|
|
163
163
|
assert.ok(result_a.reason);
|
|
164
164
|
assert.ok(result_a.error);
|
|
165
165
|
const result_b = gen_results.results[1];
|
|
166
|
-
assert.ok(result_b
|
|
166
|
+
assert.ok(result_b.ok);
|
|
167
167
|
assert.ok(file_b);
|
|
168
168
|
assert.equal(result_b.files, [
|
|
169
169
|
{
|
package/dist/run_task.js
CHANGED
|
@@ -30,7 +30,7 @@ export const run_task = async (task_meta, unparsed_args, invoke_task, config, ti
|
|
|
30
30
|
sveltekit_config: sveltekit_config_global,
|
|
31
31
|
log,
|
|
32
32
|
timings,
|
|
33
|
-
invoke_task: (invoked_task_name, invoked_args, invoked_config) => invoke_task(invoked_task_name, invoked_args, invoked_config
|
|
33
|
+
invoke_task: (invoked_task_name, invoked_args, invoked_config) => invoke_task(invoked_task_name, invoked_args, invoked_config ?? config, timings),
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
catch (err) {
|
package/dist/run_task.test.js
CHANGED
|
@@ -32,9 +32,10 @@ test('invokes a sub task', async () => {
|
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
|
-
}, args,
|
|
35
|
+
}, args, (invoking_task_name, invoking_args) => {
|
|
36
36
|
invoked_task_name = invoking_task_name;
|
|
37
37
|
invoked_args = invoking_args;
|
|
38
|
+
return Promise.resolve();
|
|
38
39
|
}, await load_config(), new Timings());
|
|
39
40
|
assert.ok(result.ok);
|
|
40
41
|
assert.is(invoked_task_name, 'bar/testTask');
|
|
@@ -48,7 +49,7 @@ test('failing task', async () => {
|
|
|
48
49
|
id: 'foo/testTask',
|
|
49
50
|
mod: {
|
|
50
51
|
task: {
|
|
51
|
-
run:
|
|
52
|
+
run: () => {
|
|
52
53
|
err = Error();
|
|
53
54
|
throw err;
|
|
54
55
|
},
|
package/dist/src_json.d.ts
CHANGED
|
@@ -248,9 +248,7 @@ export declare const Src_Json: z.ZodIntersection<z.ZodRecord<z.ZodString, z.ZodU
|
|
|
248
248
|
}, z.ZodTypeAny, "passthrough">>>>;
|
|
249
249
|
}, z.ZodTypeAny, "passthrough">>>;
|
|
250
250
|
export type Src_Json = z.infer<typeof Src_Json>;
|
|
251
|
-
export
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
export declare const create_src_json: (package_json: Package_Json, log?: any, lib_path?: string) => Promise<Src_Json>;
|
|
251
|
+
export type Map_Src_Json = (src_json: Src_Json) => Src_Json | null | Promise<Src_Json | null>;
|
|
252
|
+
export declare const create_src_json: (package_json: Package_Json, log?: any, lib_path?: string) => Src_Json;
|
|
255
253
|
export declare const serialize_src_json: (src_json: Src_Json) => string;
|
|
256
|
-
export declare const to_src_modules: (exports: Package_Json_Exports | undefined, log?: any, lib_path?: string) =>
|
|
254
|
+
export declare const to_src_modules: (exports: Package_Json_Exports | undefined, log?: any, lib_path?: string) => Src_Modules | undefined;
|
package/dist/src_json.js
CHANGED
|
@@ -32,23 +32,22 @@ z
|
|
|
32
32
|
modules: Src_Modules.transform(transform_empty_object_to_undefined).optional(),
|
|
33
33
|
})
|
|
34
34
|
.passthrough());
|
|
35
|
-
export const create_src_json =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
};
|
|
35
|
+
export const create_src_json = (package_json, log, lib_path) => Src_Json.parse({
|
|
36
|
+
name: package_json.name,
|
|
37
|
+
version: package_json.version,
|
|
38
|
+
modules: to_src_modules(package_json.exports, log, lib_path),
|
|
39
|
+
});
|
|
42
40
|
export const serialize_src_json = (src_json) => {
|
|
43
41
|
const parsed = Src_Json.parse(src_json); // TODO can parse do the logic that normalize does? see `.transform`
|
|
44
42
|
return JSON.stringify(parsed, null, 2) + '\n';
|
|
45
43
|
};
|
|
46
|
-
export const to_src_modules =
|
|
44
|
+
export const to_src_modules = (exports, log, lib_path = paths.lib) => {
|
|
47
45
|
if (!exports)
|
|
48
|
-
return
|
|
46
|
+
return;
|
|
49
47
|
const project = new Project();
|
|
50
48
|
project.addSourceFilesAtPaths('src/**/*.ts'); // TODO dir? maybe rewrite with `lib_path`?
|
|
51
|
-
return Object.fromEntries(
|
|
49
|
+
return Object.fromEntries(Object.entries(exports)
|
|
50
|
+
.map(([k, _v]) => {
|
|
52
51
|
// TODO hacky - doesn't handle any but the normal mappings, also add a helper?
|
|
53
52
|
const source_file_path = k === '.' || k === './'
|
|
54
53
|
? 'index.ts'
|
|
@@ -68,8 +67,6 @@ export const to_src_modules = async (exports, log, lib_path = paths.lib) => {
|
|
|
68
67
|
const source_file = project.getSourceFile((f) => f.getFilePath().endsWith(source_file_path)); // TODO expected this to work without the callback, according to my read of the docs it is, but `project.getSourceFile(source_file_path)` fails
|
|
69
68
|
if (source_file) {
|
|
70
69
|
for (const [name, decls] of source_file.getExportedDeclarations()) {
|
|
71
|
-
if (!decls)
|
|
72
|
-
continue;
|
|
73
70
|
// TODO how to correctly handle multiples?
|
|
74
71
|
for (const decl of decls) {
|
|
75
72
|
// TODO helper
|
|
@@ -106,5 +103,6 @@ export const to_src_modules = async (exports, log, lib_path = paths.lib) => {
|
|
|
106
103
|
}
|
|
107
104
|
const src_module = { path: source_file_path, declarations };
|
|
108
105
|
return [k, src_module];
|
|
109
|
-
})
|
|
106
|
+
})
|
|
107
|
+
.filter((v) => v !== null));
|
|
110
108
|
};
|
package/dist/src_json.test.js
CHANGED
|
@@ -3,8 +3,8 @@ import * as assert from 'uvu/assert';
|
|
|
3
3
|
import { to_src_modules } from './src_json.js';
|
|
4
4
|
import { to_package_exports } from './package_json.js';
|
|
5
5
|
import { paths } from './paths.js';
|
|
6
|
-
test('to_package_modules',
|
|
7
|
-
assert.equal(
|
|
6
|
+
test('to_package_modules', () => {
|
|
7
|
+
assert.equal(to_src_modules(to_package_exports([
|
|
8
8
|
'fixtures/modules/some_test_css.css',
|
|
9
9
|
'fixtures/modules/Some_Test_Svelte.svelte',
|
|
10
10
|
'fixtures/modules/some_test_ts.ts',
|
package/dist/sveltekit_config.js
CHANGED
|
@@ -7,12 +7,12 @@ export declare const SVELTE_CHECK_CLI = "svelte-check";
|
|
|
7
7
|
export declare const SVELTE_PACKAGE_CLI = "svelte-package";
|
|
8
8
|
export declare const SVELTE_PACKAGE_DEP_NAME = "@sveltejs/package";
|
|
9
9
|
export declare const VITE_CLI = "vite";
|
|
10
|
-
export declare const has_sveltekit_app: () =>
|
|
10
|
+
export declare const has_sveltekit_app: () => Result<object, {
|
|
11
11
|
message: string;
|
|
12
|
-
}
|
|
13
|
-
export declare const has_sveltekit_library: (package_json?: Package_Json, sveltekit_config?: Parsed_Sveltekit_Config) =>
|
|
12
|
+
}>;
|
|
13
|
+
export declare const has_sveltekit_library: (package_json?: Package_Json, sveltekit_config?: Parsed_Sveltekit_Config) => Result<object, {
|
|
14
14
|
message: string;
|
|
15
|
-
}
|
|
15
|
+
}>;
|
|
16
16
|
export declare const sveltekit_sync: (sveltekit_cli?: string | Cli) => Promise<void>;
|
|
17
17
|
/**
|
|
18
18
|
* If the SvelteKit CLI is found and its `.svelte-kit` directory is not, run `svelte-kit sync`.
|
|
@@ -9,22 +9,22 @@ export const SVELTE_CHECK_CLI = 'svelte-check';
|
|
|
9
9
|
export const SVELTE_PACKAGE_CLI = 'svelte-package';
|
|
10
10
|
export const SVELTE_PACKAGE_DEP_NAME = '@sveltejs/package';
|
|
11
11
|
export const VITE_CLI = 'vite';
|
|
12
|
-
export const has_sveltekit_app =
|
|
12
|
+
export const has_sveltekit_app = () => {
|
|
13
13
|
if (!existsSync(SVELTEKIT_CONFIG_FILENAME)) {
|
|
14
14
|
return { ok: false, message: `no SvelteKit config found at ${SVELTEKIT_CONFIG_FILENAME}` };
|
|
15
15
|
}
|
|
16
16
|
// TODO check for routes?
|
|
17
17
|
return { ok: true };
|
|
18
18
|
};
|
|
19
|
-
export const has_sveltekit_library =
|
|
20
|
-
const has_sveltekit_app_result =
|
|
19
|
+
export const has_sveltekit_library = (package_json, sveltekit_config = sveltekit_config_global) => {
|
|
20
|
+
const has_sveltekit_app_result = has_sveltekit_app();
|
|
21
21
|
if (!has_sveltekit_app_result.ok) {
|
|
22
22
|
return has_sveltekit_app_result;
|
|
23
23
|
}
|
|
24
24
|
if (!existsSync(sveltekit_config.lib_path)) {
|
|
25
25
|
return { ok: false, message: `no SvelteKit lib directory found at ${sveltekit_config.lib_path}` };
|
|
26
26
|
}
|
|
27
|
-
const pkg = package_json ??
|
|
27
|
+
const pkg = package_json ?? load_package_json();
|
|
28
28
|
if (!(pkg.devDependencies?.[SVELTE_PACKAGE_DEP_NAME] || pkg.dependencies?.[SVELTE_PACKAGE_DEP_NAME])) {
|
|
29
29
|
return {
|
|
30
30
|
ok: false,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generates a module shim for SvelteKit's `$env` imports.
|
|
3
3
|
*/
|
|
4
|
-
export declare const render_env_shim_module: (dev: boolean, mode: "static" | "dynamic", visibility: "public" | "private", public_prefix?: string, private_prefix?: string, env_dir?: string, env_files?: string[], ambient_env?: Record<string, string | undefined>) =>
|
|
4
|
+
export declare const render_env_shim_module: (dev: boolean, mode: "static" | "dynamic", visibility: "public" | "private", public_prefix?: string, private_prefix?: string, env_dir?: string, env_files?: string[], ambient_env?: Record<string, string | undefined>) => string;
|
|
@@ -3,8 +3,8 @@ import { load_env } from './env.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Generates a module shim for SvelteKit's `$env` imports.
|
|
5
5
|
*/
|
|
6
|
-
export const render_env_shim_module =
|
|
7
|
-
const env =
|
|
6
|
+
export const render_env_shim_module = (dev, mode, visibility, public_prefix = 'PUBLIC_', private_prefix = '', env_dir, env_files, ambient_env) => {
|
|
7
|
+
const env = load_env(dev, visibility, public_prefix, private_prefix, env_dir, env_files, ambient_env);
|
|
8
8
|
if (mode === 'static') {
|
|
9
9
|
return `// shim for $env/static/${visibility}
|
|
10
10
|
// @see https://github.com/sveltejs/kit/issues/1485
|