@ryanatkn/gro 0.175.0 → 0.177.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/args.d.ts +5 -5
- package/dist/args.d.ts.map +1 -1
- package/dist/build.task.d.ts.map +1 -1
- package/dist/build.task.js +2 -2
- package/dist/build_cache.d.ts +12 -12
- package/dist/build_cache.d.ts.map +1 -1
- package/dist/build_cache.js +4 -4
- package/dist/changelog.d.ts +2 -2
- package/dist/changelog.d.ts.map +1 -1
- package/dist/changelog.js +1 -1
- package/dist/changeset.task.d.ts.map +1 -1
- package/dist/changeset.task.js +9 -9
- package/dist/changeset_helpers.d.ts +4 -4
- package/dist/changeset_helpers.d.ts.map +1 -1
- package/dist/changeset_helpers.js +2 -2
- package/dist/check.task.d.ts.map +1 -1
- package/dist/check.task.js +3 -3
- package/dist/clean.task.js +2 -2
- package/dist/cli.d.ts +6 -6
- package/dist/cli.d.ts.map +1 -1
- package/dist/commit.task.js +2 -2
- package/dist/deploy.task.d.ts.map +1 -1
- package/dist/deploy.task.js +13 -13
- package/dist/dev.task.d.ts +2 -2
- package/dist/dev.task.d.ts.map +1 -1
- package/dist/disknode.d.ts +4 -4
- package/dist/disknode.d.ts.map +1 -1
- package/dist/esbuild_helpers.d.ts +2 -2
- package/dist/esbuild_helpers.d.ts.map +1 -1
- package/dist/esbuild_plugin_external_worker.d.ts +5 -5
- package/dist/esbuild_plugin_external_worker.d.ts.map +1 -1
- package/dist/esbuild_plugin_svelte.d.ts +4 -4
- package/dist/esbuild_plugin_svelte.d.ts.map +1 -1
- package/dist/esbuild_plugin_sveltekit_shim_alias.d.ts +2 -2
- package/dist/esbuild_plugin_sveltekit_shim_alias.d.ts.map +1 -1
- package/dist/esbuild_plugin_sveltekit_shim_app.d.ts +5 -5
- package/dist/esbuild_plugin_sveltekit_shim_app.d.ts.map +1 -1
- package/dist/esbuild_plugin_sveltekit_shim_env.d.ts +2 -2
- package/dist/esbuild_plugin_sveltekit_shim_env.d.ts.map +1 -1
- package/dist/filer.d.ts +15 -15
- package/dist/filer.d.ts.map +1 -1
- package/dist/filer.js +2 -2
- package/dist/format.task.d.ts.map +1 -1
- package/dist/format.task.js +2 -2
- package/dist/format_directory.d.ts +2 -2
- package/dist/format_directory.d.ts.map +1 -1
- package/dist/gen.d.ts +73 -73
- package/dist/gen.d.ts.map +1 -1
- package/dist/gen.js +1 -1
- package/dist/gen.task.d.ts.map +1 -1
- package/dist/gen.task.js +8 -8
- package/dist/gen_helpers.d.ts +4 -4
- package/dist/gen_helpers.d.ts.map +1 -1
- package/dist/gen_helpers.js +1 -1
- package/dist/github.d.ts +4 -4
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +3 -3
- package/dist/gro.config.default.d.ts +2 -2
- package/dist/gro.config.default.d.ts.map +1 -1
- package/dist/gro_config.d.ts +25 -25
- package/dist/gro_config.d.ts.map +1 -1
- package/dist/gro_config.js +2 -2
- package/dist/gro_helpers.d.ts +2 -2
- package/dist/gro_helpers.d.ts.map +1 -1
- package/dist/gro_plugin_gen.d.ts +3 -3
- package/dist/gro_plugin_gen.d.ts.map +1 -1
- package/dist/gro_plugin_gen.js +2 -2
- package/dist/gro_plugin_server.d.ts +7 -7
- package/dist/gro_plugin_server.d.ts.map +1 -1
- package/dist/gro_plugin_sveltekit_app.d.ts +10 -10
- package/dist/gro_plugin_sveltekit_app.d.ts.map +1 -1
- package/dist/gro_plugin_sveltekit_app.js +2 -2
- package/dist/gro_plugin_sveltekit_library.d.ts +4 -4
- package/dist/gro_plugin_sveltekit_library.d.ts.map +1 -1
- package/dist/gro_plugin_sveltekit_library.js +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/input_path.d.ts +30 -30
- package/dist/input_path.d.ts.map +1 -1
- package/dist/input_path.js +2 -2
- package/dist/invoke.js +1 -1
- package/dist/invoke_task.d.ts +3 -3
- package/dist/invoke_task.d.ts.map +1 -1
- package/dist/invoke_task.js +4 -4
- package/dist/lint.task.d.ts.map +1 -1
- package/dist/lint.task.js +2 -2
- package/dist/modules.d.ts +20 -20
- package/dist/modules.d.ts.map +1 -1
- package/dist/modules.js +2 -2
- package/dist/package_json.d.ts +16 -16
- package/dist/package_json.d.ts.map +1 -1
- package/dist/package_json.js +6 -6
- package/dist/parse_exports.d.ts +7 -7
- package/dist/parse_exports.d.ts.map +1 -1
- package/dist/parse_exports.js +3 -3
- package/dist/parse_exports_context.d.ts +3 -3
- package/dist/parse_exports_context.d.ts.map +1 -1
- package/dist/parse_exports_context.js +1 -1
- package/dist/parse_imports.d.ts +3 -3
- package/dist/parse_imports.d.ts.map +1 -1
- package/dist/parse_imports.js +2 -2
- package/dist/paths.d.ts +6 -6
- package/dist/paths.d.ts.map +1 -1
- package/dist/plugin.d.ts +13 -13
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/publish.task.d.ts.map +1 -1
- package/dist/publish.task.js +12 -12
- package/dist/reinstall.task.d.ts.map +1 -1
- package/dist/reinstall.task.js +4 -4
- package/dist/resolve_specifier.d.ts +4 -4
- package/dist/resolve_specifier.d.ts.map +1 -1
- package/dist/run.task.d.ts +5 -1
- package/dist/run.task.d.ts.map +1 -1
- package/dist/run.task.js +25 -15
- package/dist/run_gen.d.ts +4 -4
- package/dist/run_gen.d.ts.map +1 -1
- package/dist/run_task.d.ts +4 -4
- package/dist/run_task.d.ts.map +1 -1
- package/dist/run_task.js +3 -3
- package/dist/search_fs.d.ts +6 -6
- package/dist/search_fs.d.ts.map +1 -1
- package/dist/src_json.d.ts +6 -6
- package/dist/src_json.d.ts.map +1 -1
- package/dist/src_json.js +3 -3
- package/dist/svelte_config.d.ts +3 -3
- package/dist/svelte_config.d.ts.map +1 -1
- package/dist/sveltekit_helpers.d.ts +5 -5
- package/dist/sveltekit_helpers.d.ts.map +1 -1
- package/dist/sveltekit_helpers.js +5 -5
- package/dist/sveltekit_shim_app.d.ts +2 -2
- package/dist/sveltekit_shim_app.d.ts.map +1 -1
- package/dist/sync.task.d.ts.map +1 -1
- package/dist/sync.task.js +2 -2
- package/dist/task.d.ts +54 -54
- package/dist/task.d.ts.map +1 -1
- package/dist/task.js +3 -3
- package/dist/task_logging.d.ts +3 -3
- package/dist/task_logging.d.ts.map +1 -1
- package/dist/test.task.d.ts.map +1 -1
- package/dist/test.task.js +4 -4
- package/dist/typecheck.task.d.ts.map +1 -1
- package/dist/typecheck.task.js +4 -4
- package/dist/upgrade.task.d.ts.map +1 -1
- package/dist/upgrade.task.js +5 -5
- package/dist/watch_dir.d.ts +10 -10
- package/dist/watch_dir.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/lib/args.ts +9 -9
- package/src/lib/build.task.ts +2 -2
- package/src/lib/build_cache.ts +18 -18
- package/src/lib/changelog.ts +10 -10
- package/src/lib/changeset.task.ts +16 -16
- package/src/lib/changeset_helpers.ts +4 -4
- package/src/lib/check.task.ts +3 -3
- package/src/lib/clean.task.ts +2 -2
- package/src/lib/cli.ts +7 -7
- package/src/lib/commit.task.ts +2 -2
- package/src/lib/deploy.task.ts +15 -15
- package/src/lib/dev.task.ts +2 -2
- package/src/lib/disknode.ts +4 -4
- package/src/lib/esbuild_helpers.ts +2 -2
- package/src/lib/esbuild_plugin_external_worker.ts +7 -7
- package/src/lib/esbuild_plugin_svelte.ts +4 -4
- package/src/lib/esbuild_plugin_sveltekit_shim_alias.ts +2 -2
- package/src/lib/esbuild_plugin_sveltekit_shim_app.ts +5 -5
- package/src/lib/esbuild_plugin_sveltekit_shim_env.ts +2 -2
- package/src/lib/filer.ts +35 -35
- package/src/lib/format.task.ts +2 -2
- package/src/lib/format_directory.ts +2 -2
- package/src/lib/gen.task.ts +19 -19
- package/src/lib/gen.ts +85 -85
- package/src/lib/gen_helpers.ts +17 -17
- package/src/lib/github.ts +6 -6
- package/src/lib/gro.config.default.ts +2 -2
- package/src/lib/gro_config.ts +28 -28
- package/src/lib/gro_helpers.ts +2 -2
- package/src/lib/gro_plugin_gen.ts +5 -5
- package/src/lib/gro_plugin_server.ts +8 -8
- package/src/lib/gro_plugin_sveltekit_app.ts +15 -15
- package/src/lib/gro_plugin_sveltekit_library.ts +6 -6
- package/src/lib/index.ts +3 -3
- package/src/lib/input_path.ts +56 -56
- package/src/lib/invoke.ts +2 -2
- package/src/lib/invoke_task.ts +7 -7
- package/src/lib/lint.task.ts +2 -2
- package/src/lib/modules.ts +31 -31
- package/src/lib/package_json.ts +27 -27
- package/src/lib/parse_exports.ts +15 -15
- package/src/lib/parse_exports_context.ts +9 -9
- package/src/lib/parse_imports.ts +6 -6
- package/src/lib/paths.ts +6 -6
- package/src/lib/plugin.ts +17 -17
- package/src/lib/publish.task.ts +13 -13
- package/src/lib/reinstall.task.ts +4 -4
- package/src/lib/resolve_specifier.ts +5 -5
- package/src/lib/run.task.ts +28 -17
- package/src/lib/run_gen.ts +14 -14
- package/src/lib/run_task.ts +8 -8
- package/src/lib/search_fs.ts +13 -13
- package/src/lib/src_json.ts +13 -13
- package/src/lib/svelte_config.ts +2 -2
- package/src/lib/sveltekit_helpers.ts +12 -12
- package/src/lib/sveltekit_shim_app.ts +3 -3
- package/src/lib/sync.task.ts +2 -2
- package/src/lib/task.ts +63 -63
- package/src/lib/task_logging.ts +11 -11
- package/src/lib/test.task.ts +4 -4
- package/src/lib/typecheck.task.ts +4 -4
- package/src/lib/upgrade.task.ts +7 -7
- package/src/lib/watch_dir.ts +10 -10
package/src/lib/filer.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {EMPTY_OBJECT} from '@ryanatkn/belt/object.js';
|
|
2
2
|
import {readFileSync, statSync} from 'node:fs';
|
|
3
3
|
import {dirname, resolve} from 'node:path';
|
|
4
|
-
import type {
|
|
4
|
+
import type {OmitStrict} from '@ryanatkn/belt/types.js';
|
|
5
5
|
import {isBuiltin} from 'node:module';
|
|
6
6
|
import {fileURLToPath, pathToFileURL} from 'node:url';
|
|
7
|
-
import {
|
|
7
|
+
import {UnreachableError} from '@ryanatkn/belt/error.js';
|
|
8
8
|
import type {Logger} from '@ryanatkn/belt/log.js';
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
9
|
+
import type {PackageJson} from '@ryanatkn/belt/package_json.js';
|
|
10
|
+
import type {FileFilter, PathId} from '@ryanatkn/belt/path.js';
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
13
|
watch_dir,
|
|
14
|
-
type
|
|
15
|
-
type
|
|
16
|
-
type
|
|
17
|
-
type
|
|
14
|
+
type WatchNodeFs,
|
|
15
|
+
type WatcherChange,
|
|
16
|
+
type WatchDirOptions,
|
|
17
|
+
type WatcherChangeCallback,
|
|
18
18
|
} from './watch_dir.ts';
|
|
19
19
|
import {paths} from './paths.ts';
|
|
20
20
|
import {parse_imports} from './parse_imports.ts';
|
|
@@ -26,32 +26,32 @@ import type {Disknode} from './disknode.ts';
|
|
|
26
26
|
|
|
27
27
|
const aliases = Object.entries(default_svelte_config.alias);
|
|
28
28
|
|
|
29
|
-
export type
|
|
29
|
+
export type OnFilerChange = (change: WatcherChange, disknode: Disknode) => void;
|
|
30
30
|
|
|
31
|
-
export interface
|
|
31
|
+
export interface FilerOptions {
|
|
32
32
|
watch_dir?: typeof watch_dir;
|
|
33
|
-
watch_dir_options?: Partial<
|
|
34
|
-
package_json_cache?: Record<string,
|
|
33
|
+
watch_dir_options?: Partial<OmitStrict<WatchDirOptions, 'on_change'>>;
|
|
34
|
+
package_json_cache?: Record<string, PackageJson>;
|
|
35
35
|
log?: Logger;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export class Filer {
|
|
39
|
-
readonly root_dir:
|
|
39
|
+
readonly root_dir: PathId;
|
|
40
40
|
|
|
41
41
|
// TODO rename everything to `disknode`
|
|
42
|
-
readonly files: Map<
|
|
42
|
+
readonly files: Map<PathId, Disknode> = new Map();
|
|
43
43
|
|
|
44
44
|
#watch_dir: typeof watch_dir;
|
|
45
|
-
#watch_dir_options: Partial<
|
|
45
|
+
#watch_dir_options: Partial<WatchDirOptions>;
|
|
46
46
|
|
|
47
47
|
#log?: Logger;
|
|
48
48
|
|
|
49
|
-
#listeners: Set<
|
|
50
|
-
#watching:
|
|
49
|
+
#listeners: Set<OnFilerChange> = new Set();
|
|
50
|
+
#watching: WatchNodeFs | undefined;
|
|
51
51
|
#initing: Promise<void> | undefined;
|
|
52
52
|
#closing: Promise<void> | undefined;
|
|
53
53
|
|
|
54
|
-
constructor(options:
|
|
54
|
+
constructor(options: FilerOptions = EMPTY_OBJECT) {
|
|
55
55
|
this.#watch_dir = options.watch_dir ?? watch_dir;
|
|
56
56
|
this.#watch_dir_options = options.watch_dir_options ?? EMPTY_OBJECT;
|
|
57
57
|
this.root_dir = resolve(options.watch_dir_options?.dir ?? paths.source);
|
|
@@ -65,11 +65,11 @@ export class Filer {
|
|
|
65
65
|
return this.#watching !== undefined;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
get_by_id = (id:
|
|
68
|
+
get_by_id = (id: PathId): Disknode | undefined => {
|
|
69
69
|
return this.files.get(id);
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
get_or_create = (id:
|
|
72
|
+
get_or_create = (id: PathId): Disknode => {
|
|
73
73
|
const existing = this.get_by_id(id);
|
|
74
74
|
if (existing) return existing;
|
|
75
75
|
const file: Disknode = {
|
|
@@ -155,7 +155,7 @@ export class Filer {
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
async watch(listener:
|
|
158
|
+
async watch(listener: OnFilerChange): Promise<() => void> {
|
|
159
159
|
await this.#add_listener(listener);
|
|
160
160
|
return () => {
|
|
161
161
|
this.#remove_listener(listener);
|
|
@@ -214,7 +214,7 @@ export class Filer {
|
|
|
214
214
|
this.#cleanup();
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
#update(id:
|
|
217
|
+
#update(id: PathId): Disknode | null {
|
|
218
218
|
const file = this.get_or_create(id);
|
|
219
219
|
|
|
220
220
|
let stats: ReturnType<typeof statSync> | null = null;
|
|
@@ -284,7 +284,7 @@ export class Filer {
|
|
|
284
284
|
return file;
|
|
285
285
|
}
|
|
286
286
|
|
|
287
|
-
#remove(id:
|
|
287
|
+
#remove(id: PathId): Disknode | null {
|
|
288
288
|
const file = this.get_by_id(id);
|
|
289
289
|
if (!file) return null; // this is safe because the object would exist if any other file referenced it as a dependency or dependent
|
|
290
290
|
|
|
@@ -300,7 +300,7 @@ export class Filer {
|
|
|
300
300
|
return file;
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
-
#sync_listener_with_files(listener:
|
|
303
|
+
#sync_listener_with_files(listener: OnFilerChange): void {
|
|
304
304
|
for (const disknode of this.files.values()) {
|
|
305
305
|
try {
|
|
306
306
|
listener({type: 'add', path: disknode.id, is_directory: false}, disknode);
|
|
@@ -310,7 +310,7 @@ export class Filer {
|
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
#notify_change(change:
|
|
313
|
+
#notify_change(change: WatcherChange, disknode: Disknode): void {
|
|
314
314
|
for (const listener of this.#listeners) {
|
|
315
315
|
try {
|
|
316
316
|
listener(change, disknode);
|
|
@@ -320,7 +320,7 @@ export class Filer {
|
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
-
async #add_listener(listener:
|
|
323
|
+
async #add_listener(listener: OnFilerChange): Promise<void> {
|
|
324
324
|
this.#listeners.add(listener);
|
|
325
325
|
|
|
326
326
|
// ensure initialized
|
|
@@ -330,12 +330,12 @@ export class Filer {
|
|
|
330
330
|
this.#sync_listener_with_files(listener);
|
|
331
331
|
}
|
|
332
332
|
|
|
333
|
-
#remove_listener(listener:
|
|
333
|
+
#remove_listener(listener: OnFilerChange): void {
|
|
334
334
|
this.#listeners.delete(listener);
|
|
335
335
|
// keep watching active even with no listeners, only close() tears down
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
#on_change:
|
|
338
|
+
#on_change: WatcherChangeCallback = (change) => {
|
|
339
339
|
if (this.#closing) return; // ignore changes during close
|
|
340
340
|
if (change.is_directory) return; // TODO manage directories?
|
|
341
341
|
let disknode: Disknode | null;
|
|
@@ -350,14 +350,14 @@ export class Filer {
|
|
|
350
350
|
break;
|
|
351
351
|
}
|
|
352
352
|
default:
|
|
353
|
-
throw new
|
|
353
|
+
throw new UnreachableError(change.type);
|
|
354
354
|
}
|
|
355
355
|
if (disknode && this.#listeners.size > 0) {
|
|
356
356
|
this.#notify_change(change, disknode);
|
|
357
357
|
}
|
|
358
358
|
};
|
|
359
359
|
|
|
360
|
-
#is_external(id:
|
|
360
|
+
#is_external(id: PathId): boolean {
|
|
361
361
|
const {filter} = this.#watch_dir_options;
|
|
362
362
|
return !id.startsWith(this.root_dir + '/') || (!!filter && !filter(id, false));
|
|
363
363
|
}
|
|
@@ -366,12 +366,12 @@ export class Filer {
|
|
|
366
366
|
// TODO maybe `Disknode` class?
|
|
367
367
|
export const filter_dependents = (
|
|
368
368
|
disknode: Disknode,
|
|
369
|
-
get_by_id: (id:
|
|
370
|
-
filter?:
|
|
371
|
-
results: Set<
|
|
372
|
-
searched: Set<
|
|
369
|
+
get_by_id: (id: PathId) => Disknode | undefined,
|
|
370
|
+
filter?: FileFilter,
|
|
371
|
+
results: Set<PathId> = new Set(),
|
|
372
|
+
searched: Set<PathId> = new Set(),
|
|
373
373
|
log?: Logger,
|
|
374
|
-
): Set<
|
|
374
|
+
): Set<PathId> => {
|
|
375
375
|
const {dependents} = disknode;
|
|
376
376
|
for (const dependent_id of dependents.keys()) {
|
|
377
377
|
if (searched.has(dependent_id)) continue;
|
package/src/lib/format.task.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {print_spawn_result} from '@ryanatkn/belt/process.js';
|
|
2
2
|
import {z} from 'zod';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {TaskError, type Task} from './task.ts';
|
|
5
5
|
import {format_directory} from './format_directory.ts';
|
|
6
6
|
import {paths} from './paths.ts';
|
|
7
7
|
|
|
@@ -31,7 +31,7 @@ export const task: Task<Args> = {
|
|
|
31
31
|
config.pm_cli,
|
|
32
32
|
);
|
|
33
33
|
if (!format_result.ok) {
|
|
34
|
-
throw new
|
|
34
|
+
throw new TaskError(
|
|
35
35
|
`Failed ${check ? 'formatting check' : 'to format'}. ${print_spawn_result(format_result)}`,
|
|
36
36
|
);
|
|
37
37
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {SpawnResult} from '@ryanatkn/belt/process.js';
|
|
2
2
|
import type {Logger} from '@ryanatkn/belt/log.js';
|
|
3
3
|
|
|
4
4
|
import {paths} from './paths.ts';
|
|
@@ -39,7 +39,7 @@ export const format_directory = async (
|
|
|
39
39
|
root_paths = ROOT_PATHS_DEFAULT,
|
|
40
40
|
prettier_cli: string | Cli = PRETTIER_CLI_DEFAULT,
|
|
41
41
|
pm_cli: string = PM_CLI_DEFAULT,
|
|
42
|
-
): Promise<
|
|
42
|
+
): Promise<SpawnResult> => {
|
|
43
43
|
const forwarded_args = to_forwarded_args(to_cli_name(prettier_cli));
|
|
44
44
|
forwarded_args[check ? 'check' : 'write'] = true;
|
|
45
45
|
const serialized_args = serialize_args(forwarded_args);
|
package/src/lib/gen.task.ts
CHANGED
|
@@ -3,9 +3,9 @@ import {print_ms, print_error} from '@ryanatkn/belt/print.js';
|
|
|
3
3
|
import {plural} from '@ryanatkn/belt/string.js';
|
|
4
4
|
import {z} from 'zod';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {TaskError, type Task} from './task.ts';
|
|
7
7
|
import {run_gen} from './run_gen.ts';
|
|
8
|
-
import {
|
|
8
|
+
import {RawInputPath, to_input_paths} from './input_path.ts';
|
|
9
9
|
import {format_file} from './format_file.ts';
|
|
10
10
|
import {print_path} from './paths.ts';
|
|
11
11
|
import {log_error_reasons} from './task_logging.ts';
|
|
@@ -14,20 +14,20 @@ import {
|
|
|
14
14
|
analyze_gen_results,
|
|
15
15
|
find_genfiles,
|
|
16
16
|
load_genfiles,
|
|
17
|
-
type
|
|
18
|
-
type
|
|
17
|
+
type AnalyzedGenResult,
|
|
18
|
+
type GenResults,
|
|
19
19
|
} from './gen.ts';
|
|
20
20
|
import {SOURCE_DIRNAME} from './constants.ts';
|
|
21
21
|
|
|
22
22
|
/** @nodocs */
|
|
23
23
|
export const Args = z.strictObject({
|
|
24
24
|
_: z
|
|
25
|
-
.array(
|
|
25
|
+
.array(RawInputPath)
|
|
26
26
|
.meta({description: 'input paths to generate'})
|
|
27
27
|
.default([SOURCE_DIRNAME]),
|
|
28
28
|
root_dirs: z
|
|
29
29
|
.array(z.string())
|
|
30
|
-
.meta({description: 'root directories to resolve input paths against'}) // TODO `
|
|
30
|
+
.meta({description: 'root directories to resolve input paths against'}) // TODO `PathId` schema
|
|
31
31
|
.default([process.cwd()]),
|
|
32
32
|
check: z
|
|
33
33
|
.boolean()
|
|
@@ -54,7 +54,7 @@ export const task: Task<Args> = {
|
|
|
54
54
|
return;
|
|
55
55
|
} else {
|
|
56
56
|
log_error_reasons(log, found.reasons);
|
|
57
|
-
throw new
|
|
57
|
+
throw new TaskError('Failed to find gen modules.');
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
const found_genfiles = found.value;
|
|
@@ -65,7 +65,7 @@ export const task: Task<Args> = {
|
|
|
65
65
|
const loaded = await load_genfiles(found_genfiles, timings);
|
|
66
66
|
if (!loaded.ok) {
|
|
67
67
|
log_error_reasons(log, loaded.reasons);
|
|
68
|
-
throw new
|
|
68
|
+
throw new TaskError('Failed to load gen modules.');
|
|
69
69
|
}
|
|
70
70
|
const loaded_genfiles = loaded.value;
|
|
71
71
|
|
|
@@ -106,7 +106,7 @@ export const task: Task<Args> = {
|
|
|
106
106
|
);
|
|
107
107
|
}
|
|
108
108
|
if (has_unexpected_changes) {
|
|
109
|
-
throw new
|
|
109
|
+
throw new TaskError(
|
|
110
110
|
'Failed gen check. Some generated files have unexpectedly changed.' +
|
|
111
111
|
' Run `gro gen` and try again.',
|
|
112
112
|
);
|
|
@@ -135,26 +135,26 @@ export const task: Task<Args> = {
|
|
|
135
135
|
for (const result of gen_results.failures) {
|
|
136
136
|
log.error(result.reason, '\n', print_error(result.error));
|
|
137
137
|
}
|
|
138
|
-
throw new
|
|
138
|
+
throw new TaskError(`Failed to generate ${fail_count} file${plural(fail_count)}.`);
|
|
139
139
|
}
|
|
140
140
|
},
|
|
141
141
|
};
|
|
142
142
|
|
|
143
|
-
interface
|
|
143
|
+
interface GenStatus {
|
|
144
144
|
symbol: string;
|
|
145
145
|
color: Parameters<typeof st>[0];
|
|
146
146
|
text: string;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
const format_gen_status = (analyzed:
|
|
149
|
+
const format_gen_status = (analyzed: AnalyzedGenResult | undefined): GenStatus => {
|
|
150
150
|
if (!analyzed) return {symbol: '?', color: 'gray', text: 'unknown'};
|
|
151
151
|
if (analyzed.is_new) return {symbol: '●', color: 'green', text: 'new'};
|
|
152
152
|
if (analyzed.has_changed) return {symbol: '◐', color: 'cyan', text: 'changed'};
|
|
153
153
|
return {symbol: '○', color: 'gray', text: 'unchanged'};
|
|
154
154
|
};
|
|
155
155
|
|
|
156
|
-
interface
|
|
157
|
-
status:
|
|
156
|
+
interface OutputLine {
|
|
157
|
+
status: GenStatus;
|
|
158
158
|
elapsed: string;
|
|
159
159
|
source: string;
|
|
160
160
|
target: string;
|
|
@@ -162,10 +162,10 @@ interface Output_Line {
|
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
const collect_output_lines = (
|
|
165
|
-
gen_results:
|
|
166
|
-
analyzed_gen_results: Array<
|
|
167
|
-
): Array<
|
|
168
|
-
const output_lines: Array<
|
|
165
|
+
gen_results: GenResults,
|
|
166
|
+
analyzed_gen_results: Array<AnalyzedGenResult>,
|
|
167
|
+
): Array<OutputLine> => {
|
|
168
|
+
const output_lines: Array<OutputLine> = [];
|
|
169
169
|
|
|
170
170
|
for (const result of gen_results.results) {
|
|
171
171
|
if (result.ok) {
|
|
@@ -193,7 +193,7 @@ const collect_output_lines = (
|
|
|
193
193
|
return output_lines;
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
-
const format_gen_output = (output_lines: Array<
|
|
196
|
+
const format_gen_output = (output_lines: Array<OutputLine>): string => {
|
|
197
197
|
// calculate column widths for alignment
|
|
198
198
|
const max_elapsed_length = Math.max(...output_lines.map((l) => l.elapsed.length));
|
|
199
199
|
const max_source_length = Math.max(...output_lines.map((l) => l.source.length));
|