@ryanatkn/gro 0.129.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 +3 -3
- package/dist/args.d.ts +2 -2
- package/dist/args.js +2 -2
- package/dist/changelog.test.js +1 -1
- package/dist/changeset.task.js +6 -6
- package/dist/cli.js +1 -1
- package/dist/config.d.ts +1 -3
- package/dist/config.js +2 -2
- package/dist/deploy.task.js +1 -1
- package/dist/docs/README.gen.md.js +1 -1
- package/dist/docs/package_json.md +2 -1
- package/dist/env.d.ts +2 -2
- package/dist/env.js +10 -11
- package/dist/esbuild_helpers.js +2 -1
- package/dist/esbuild_plugin_external_worker.js +1 -1
- package/dist/esbuild_plugin_svelte.js +3 -3
- package/dist/esbuild_plugin_sveltekit_local_imports.js +2 -2
- package/dist/esbuild_plugin_sveltekit_shim_env.js +2 -2
- package/dist/format_file.js +2 -2
- package/dist/gen.d.ts +10 -12
- package/dist/gen.js +3 -3
- package/dist/gen.task.js +1 -1
- package/dist/gen.test.js +2 -5
- package/dist/git.d.ts +1 -1
- package/dist/gro.config.default.js +1 -1
- package/dist/gro.js +1 -1
- package/dist/gro_helpers.js +1 -2
- package/dist/gro_plugin_gen.js +3 -4
- package/dist/gro_plugin_server.d.ts +5 -7
- package/dist/gro_plugin_server.js +3 -3
- package/dist/gro_plugin_sveltekit_app.d.ts +3 -5
- package/dist/gro_plugin_sveltekit_app.js +38 -28
- package/dist/gro_plugin_sveltekit_library.d.ts +2 -2
- package/dist/gro_plugin_sveltekit_library.js +2 -2
- package/dist/input_path.test.js +1 -1
- package/dist/invoke_task.js +3 -3
- package/dist/lint.task.js +1 -2
- package/dist/loader.js +3 -3
- package/dist/package.d.ts +7 -10
- package/dist/package.gen.js +3 -3
- package/dist/package.js +18 -15
- package/dist/package_json.d.ts +4 -6
- package/dist/package_json.js +14 -15
- package/dist/package_json.test.js +12 -12
- package/dist/path.d.ts +2 -6
- package/dist/plugin.d.ts +1 -3
- package/dist/plugin.js +2 -2
- package/dist/plugin.test.js +3 -3
- package/dist/publish.task.js +4 -4
- package/dist/release.task.js +2 -2
- package/dist/resolve.task.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_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 +18 -21
- package/dist/fs.test.d.ts +0 -1
- package/dist/fs.test.js +0 -16
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/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_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
|
package/dist/task.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { type Input_Path, type Resolved_Input_File, type Resolved_Input_Path } f
|
|
|
10
10
|
import { type Load_Modules_Failure, type Module_Meta } from './modules.js';
|
|
11
11
|
export interface Task<T_Args = Args, // same as `z.infer<typeof Args>`
|
|
12
12
|
T_Args_Schema extends z.ZodType = z.ZodType, T_Return = unknown> {
|
|
13
|
-
run: (ctx: Task_Context<T_Args>) => Promise<T_Return>;
|
|
13
|
+
run: (ctx: Task_Context<T_Args>) => T_Return | Promise<T_Return>;
|
|
14
14
|
summary?: string;
|
|
15
15
|
Args?: T_Args_Schema;
|
|
16
16
|
}
|
package/dist/task_logging.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Logger } from '@ryanatkn/belt/log.js';
|
|
2
2
|
import type { Loaded_Tasks, Task_Module_Meta } from './task.js';
|
|
3
|
-
export declare const log_tasks: (log: Logger, loaded_tasks: Loaded_Tasks, log_intro?: boolean) =>
|
|
3
|
+
export declare const log_tasks: (log: Logger, loaded_tasks: Loaded_Tasks, log_intro?: boolean) => void;
|
|
4
4
|
export declare const log_error_reasons: (log: Logger, reasons: string[]) => void;
|
|
5
5
|
export declare const log_task_help: (log: Logger, meta: Task_Module_Meta) => void;
|
package/dist/task_logging.js
CHANGED
|
@@ -3,7 +3,7 @@ import { plural } from '@ryanatkn/belt/string.js';
|
|
|
3
3
|
import { print_value } from '@ryanatkn/belt/print.js';
|
|
4
4
|
import { ZodFirstPartyTypeKind } from 'zod';
|
|
5
5
|
import { print_path } from './paths.js';
|
|
6
|
-
export const log_tasks =
|
|
6
|
+
export const log_tasks = (log, loaded_tasks, log_intro = true) => {
|
|
7
7
|
const { modules, found_tasks } = loaded_tasks;
|
|
8
8
|
const { resolved_input_files_by_root_dir } = found_tasks;
|
|
9
9
|
const logged = [];
|
|
@@ -20,7 +20,7 @@ export const log_tasks = async (log, loaded_tasks, log_intro = true) => {
|
|
|
20
20
|
const longest_task_name = to_max_length(modules, (m) => m.name);
|
|
21
21
|
for (const resolved_input_file of resolved_input_files) {
|
|
22
22
|
const meta = modules.find((m) => m.id === resolved_input_file.id);
|
|
23
|
-
logged.push('\n' + cyan(pad(meta.name, longest_task_name)), ' ', meta.mod.task.summary
|
|
23
|
+
logged.push('\n' + cyan(pad(meta.name, longest_task_name)), ' ', meta.mod.task.summary ?? '');
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
log[log_intro ? 'info' : 'plain'](logged.join('') + '\n');
|
|
@@ -34,7 +34,7 @@ const ARGS_PROPERTY_NAME = '[...args]';
|
|
|
34
34
|
export const log_task_help = (log, meta) => {
|
|
35
35
|
const { name, mod: { task }, } = meta;
|
|
36
36
|
const logged = [];
|
|
37
|
-
logged.push(cyan(name), 'help', cyan(`\n\ngro ${name}`) + `: ${task.summary
|
|
37
|
+
logged.push(cyan(name), 'help', cyan(`\n\ngro ${name}`) + `: ${task.summary ?? '(no summary available)'}\n`);
|
|
38
38
|
if (task.Args) {
|
|
39
39
|
const properties = to_arg_properties(task.Args._def, meta);
|
|
40
40
|
// TODO hacky padding for some quick and dirty tables
|
|
@@ -121,7 +121,6 @@ const to_args_schema_default = ({ _def }) => {
|
|
|
121
121
|
if (subschema) {
|
|
122
122
|
return to_args_schema_default(subschema);
|
|
123
123
|
}
|
|
124
|
-
return undefined;
|
|
125
124
|
};
|
|
126
125
|
const to_subschema = (_def) => {
|
|
127
126
|
if ('type' in _def) {
|
package/dist/upgrade.task.js
CHANGED
|
@@ -32,7 +32,7 @@ export const task = {
|
|
|
32
32
|
if (pull) {
|
|
33
33
|
await git_pull(origin);
|
|
34
34
|
}
|
|
35
|
-
const package_json =
|
|
35
|
+
const package_json = load_package_json();
|
|
36
36
|
const all_deps = to_deps(package_json);
|
|
37
37
|
const deps = only.length
|
|
38
38
|
? all_deps.filter((d) => only.includes(d.key))
|
package/dist/watch_dir.d.ts
CHANGED
|
@@ -10,9 +10,7 @@ export interface Watcher_Change {
|
|
|
10
10
|
is_directory: boolean;
|
|
11
11
|
}
|
|
12
12
|
export type Watcher_Change_Type = 'create' | 'update' | 'delete';
|
|
13
|
-
export
|
|
14
|
-
(change: Watcher_Change): void;
|
|
15
|
-
}
|
|
13
|
+
export type Watcher_Change_Callback = (change: Watcher_Change) => void;
|
|
16
14
|
export interface Options {
|
|
17
15
|
dir: string;
|
|
18
16
|
on_change: Watcher_Change_Callback;
|
package/dist/watch_dir.js
CHANGED
|
@@ -9,22 +9,22 @@ export const watch_dir = ({ dir, on_change, filter, absolute = true, chokidar: c
|
|
|
9
9
|
return {
|
|
10
10
|
init: async () => {
|
|
11
11
|
watcher = chokidar.watch(dir, chokidar_options);
|
|
12
|
-
watcher.on('add',
|
|
13
|
-
const stats = s
|
|
12
|
+
watcher.on('add', (path, s) => {
|
|
13
|
+
const stats = s ?? statSync(path);
|
|
14
14
|
const final_path = absolute ? path : relative(dir, path);
|
|
15
15
|
if (filter && !filter(final_path, stats.isDirectory()))
|
|
16
16
|
return;
|
|
17
17
|
on_change({ type: 'create', path: final_path, is_directory: stats.isDirectory() });
|
|
18
18
|
});
|
|
19
|
-
watcher.on('addDir',
|
|
20
|
-
const stats = s
|
|
19
|
+
watcher.on('addDir', (path, s) => {
|
|
20
|
+
const stats = s ?? statSync(path);
|
|
21
21
|
const final_path = absolute ? path : relative(dir, path);
|
|
22
22
|
if (filter && !filter(final_path, stats.isDirectory()))
|
|
23
23
|
return;
|
|
24
24
|
on_change({ type: 'create', path: final_path, is_directory: stats.isDirectory() });
|
|
25
25
|
});
|
|
26
|
-
watcher.on('change',
|
|
27
|
-
const stats = s
|
|
26
|
+
watcher.on('change', (path, s) => {
|
|
27
|
+
const stats = s ?? statSync(path);
|
|
28
28
|
const final_path = absolute ? path : relative(dir, path);
|
|
29
29
|
if (filter && !filter(final_path, stats.isDirectory()))
|
|
30
30
|
return;
|