From 2040fb2ae0a4bf9e0d90cf6dda20dddb4a5e2c70 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Fri, 19 Jul 2024 07:26:33 -0600 Subject: [PATCH 1/5] wip --- package-lock.json | 47 +++++++++------------------------------------- package.json | 2 +- src/lib/invoke.ts | 9 ++++++--- src/lib/package.ts | 2 +- 4 files changed, 17 insertions(+), 43 deletions(-) diff --git a/package-lock.json b/package-lock.json index 42e89d19a5..0de193530d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,7 @@ "@changesets/changelog-git": "^0.2.0", "@changesets/types": "^6.0.0", "@ryanatkn/eslint-config": "^0.4.2", - "@ryanatkn/fuz": "^0.115.0", + "@ryanatkn/fuz": "^0.115.1", "@ryanatkn/moss": "^0.8.0", "@sveltejs/adapter-static": "^3.0.2", "@sveltejs/kit": "^2.5.18", @@ -446,9 +446,9 @@ } }, "node_modules/@ryanatkn/fuz": { - "version": "0.115.0", - "resolved": "https://registry.npmjs.org/@ryanatkn/fuz/-/fuz-0.115.0.tgz", - "integrity": "sha512-AbLSraP8uKgjinSo9FHCkWDnYt57MqNJOuEaG5sTzkXVsQ6bFrf6ScNLYefoNWPqMtmeURn7ilgBA7d7kaelKw==", + "version": "0.115.1", + "resolved": "https://registry.npmjs.org/@ryanatkn/fuz/-/fuz-0.115.1.tgz", + "integrity": "sha512-fzkk6SnFeeRbWsx6MXmny/nS++fv05y4tTUXqqvaA/KjMI35gUQ1DFAgamLkB0sl72FFo5x9nRNrnE2YHWE0gw==", "dev": true, "license": "MIT", "engines": { @@ -459,44 +459,15 @@ }, "peerDependencies": { "@ryanatkn/belt": "^0.24.9", - "@ryanatkn/gro": "^0.133.0", + "@ryanatkn/gro": "^0.133.1", "@ryanatkn/moss": "^0.8.0", "@sveltejs/kit": "^2", "svelte": "^5.0.0-next.0" - } - }, - "node_modules/@ryanatkn/gro": { - "version": "0.133.0", - "resolved": "https://registry.npmjs.org/@ryanatkn/gro/-/gro-0.133.0.tgz", - "integrity": "sha512-DaHScC2mI8K40+fx/nkWKmtGRl0k7XS5KWSOHE/hW2cuBFaKV36z+wJfKID2dqnSYJtY6NbBB6ldCC/GB5vexA==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "@ryanatkn/belt": "^0.24.9", - "chokidar": "^3.6.0", - "dotenv": "^16.4.5", - "es-module-lexer": "^1.5.4", - "esm-env": "^1.0.0", - "mri": "^1.2.0", - "prettier": "^3.3.3", - "prettier-plugin-svelte": "^3.2.5", - "ts-morph": "^23.0.0", - "tslib": "^2.6.3", - "zod": "^3.23.8" - }, - "bin": { - "gro": "dist/gro.js" - }, - "engines": { - "node": ">=20.12" - }, - "funding": { - "url": "https://www.ryanatkn.com/funding" }, - "peerDependencies": { - "esbuild": "^0.21.0", - "svelte": "^5.0.0-next.0" + "peerDependenciesMeta": { + "@ryanatkn/gro": { + "optional": true + } } }, "node_modules/@ryanatkn/moss": { diff --git a/package.json b/package.json index 9d4f713380..05eaa51672 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "@changesets/changelog-git": "^0.2.0", "@changesets/types": "^6.0.0", "@ryanatkn/eslint-config": "^0.4.2", - "@ryanatkn/fuz": "^0.115.0", + "@ryanatkn/fuz": "^0.115.1", "@ryanatkn/moss": "^0.8.0", "@sveltejs/adapter-static": "^3.0.2", "@sveltejs/kit": "^2.5.18", diff --git a/src/lib/invoke.ts b/src/lib/invoke.ts index aef4bb966b..ade2a49625 100644 --- a/src/lib/invoke.ts +++ b/src/lib/invoke.ts @@ -17,11 +17,14 @@ and the rest of the args are forwarded to the task's `run` function. */ // handle uncaught errors -attach_process_error_handlers((err) => - err?.constructor?.name === 'Task_Error' ? 'Task_Error' : null, -); +attach_process_error_handlers((err) => { + console.log(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>err`, err?.constructor?.name); + return err?.constructor?.name === 'Task_Error' ? 'Task_Error' : null; +}); await sveltekit_sync_if_obviously_needed(); const {task_name, args} = to_task_args(); await invoke_task(task_name, args, await load_gro_config()); + +const a: 5 = 34; diff --git a/src/lib/package.ts b/src/lib/package.ts index 0c5779f635..969bb2bb21 100644 --- a/src/lib/package.ts +++ b/src/lib/package.ts @@ -61,7 +61,7 @@ export const package_json = { '@changesets/changelog-git': '^0.2.0', '@changesets/types': '^6.0.0', '@ryanatkn/eslint-config': '^0.4.2', - '@ryanatkn/fuz': '^0.115.0', + '@ryanatkn/fuz': '^0.115.1', '@ryanatkn/moss': '^0.8.0', '@sveltejs/adapter-static': '^3.0.2', '@sveltejs/kit': '^2.5.18', From 1fd157f33d20c04046f1dfa9a144e3f45efda8d5 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Fri, 19 Jul 2024 07:52:01 -0600 Subject: [PATCH 2/5] wip --- src/lib/invoke.ts | 10 ++++------ src/lib/invoke_task.ts | 6 +++--- src/lib/task.ts | 6 ++++++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/lib/invoke.ts b/src/lib/invoke.ts index ade2a49625..1f5807b13c 100644 --- a/src/lib/invoke.ts +++ b/src/lib/invoke.ts @@ -17,14 +17,12 @@ and the rest of the args are forwarded to the task's `run` function. */ // handle uncaught errors -attach_process_error_handlers((err) => { - console.log(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>err`, err?.constructor?.name); - return err?.constructor?.name === 'Task_Error' ? 'Task_Error' : null; -}); +attach_process_error_handlers( + (err) => (err?.constructor?.name === 'Task_Error' ? 'Task_Error' : null), + (err) => (err?.constructor?.name === 'Silent_Error' ? '' : null), +); await sveltekit_sync_if_obviously_needed(); const {task_name, args} = to_task_args(); await invoke_task(task_name, args, await load_gro_config()); - -const a: 5 = 34; diff --git a/src/lib/invoke_task.ts b/src/lib/invoke_task.ts index d0b728a7a1..7d0a1ffaa7 100644 --- a/src/lib/invoke_task.ts +++ b/src/lib/invoke_task.ts @@ -6,7 +6,7 @@ import {print_ms, print_timings} from '@ryanatkn/belt/print.js'; import {to_forwarded_args, type Args} from './args.js'; import {run_task} from './run_task.js'; import {to_input_path, Raw_Input_Path} from './input_path.js'; -import {find_tasks, load_tasks} from './task.js'; +import {find_tasks, load_tasks, Silent_Error} from './task.js'; import {load_gro_package_json} from './package_json.js'; import {log_tasks, log_error_reasons} from './task_logging.js'; import type {Gro_Config} from './gro_config.js'; @@ -69,7 +69,7 @@ export const invoke_task = async ( const found = find_tasks([input_path], task_root_dirs, config); if (!found.ok) { log_error_reasons(log, found.reasons); - process.exit(1); + throw new Silent_Error(); } // Found a match either in the current working directory or Gro's directory. @@ -80,7 +80,7 @@ export const invoke_task = async ( const loaded = await load_tasks(found_tasks); if (!loaded.ok) { log_error_reasons(log, loaded.reasons); - process.exit(1); + throw new Silent_Error(); } const loaded_tasks = loaded.value; diff --git a/src/lib/task.ts b/src/lib/task.ts index fd62766531..e2af424e07 100644 --- a/src/lib/task.ts +++ b/src/lib/task.ts @@ -80,6 +80,12 @@ export const to_task_name = ( */ export class Task_Error extends Error {} +/** + * This is used to tell Gro to exit silently, usually still with with a non-zero exit code. + * Using it means error logging is handled by the code that threw it. + */ +export class Silent_Error extends Error {} + export interface Found_Task { input_path: Input_Path; id: Path_Id; From eb3966a8edf424ad9f6f17cf0868b1bfc625f52d Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Fri, 19 Jul 2024 07:54:59 -0600 Subject: [PATCH 3/5] wip --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0de193530d..ab10c732e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.133.1", "license": "MIT", "dependencies": { - "@ryanatkn/belt": "^0.24.9", + "@ryanatkn/belt": "^0.24.10", "chokidar": "^3.6.0", "dotenv": "^16.4.5", "es-module-lexer": "^1.5.4", @@ -401,9 +401,9 @@ "peer": true }, "node_modules/@ryanatkn/belt": { - "version": "0.24.9", - "resolved": "https://registry.npmjs.org/@ryanatkn/belt/-/belt-0.24.9.tgz", - "integrity": "sha512-rr7loJweYavGNsFXWBYqhkoqhDaXxQrDos5ps5Gphxm7NjngtJfN/ofbehg+3RgtCm3dMGa391N4aJsF3Ak6Kg==", + "version": "0.24.10", + "resolved": "https://registry.npmjs.org/@ryanatkn/belt/-/belt-0.24.10.tgz", + "integrity": "sha512-CrWshOlp+tiqJotCjceT5PaPTgIu5lcwjQsXAk6Ma2R+ZeO4FgYWiHm5RYSyzuaSV9B2qiUXVhMA6nnGIz7S9Q==", "license": "MIT", "engines": { "node": ">=20.12" diff --git a/package.json b/package.json index 05eaa51672..571a64977d 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "typescript" ], "dependencies": { - "@ryanatkn/belt": "^0.24.9", + "@ryanatkn/belt": "^0.24.10", "chokidar": "^3.6.0", "dotenv": "^16.4.5", "es-module-lexer": "^1.5.4", From 71254dd559a3d48f4e23f0d548acb6015317f438 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Fri, 19 Jul 2024 07:55:16 -0600 Subject: [PATCH 4/5] wip --- src/lib/package.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/package.ts b/src/lib/package.ts index 969bb2bb21..1725a0727f 100644 --- a/src/lib/package.ts +++ b/src/lib/package.ts @@ -44,7 +44,7 @@ export const package_json = { 'typescript', ], dependencies: { - '@ryanatkn/belt': '^0.24.9', + '@ryanatkn/belt': '^0.24.10', chokidar: '^3.6.0', dotenv: '^16.4.5', 'es-module-lexer': '^1.5.4', @@ -964,6 +964,7 @@ export const src_json = { {name: 'is_task_path', kind: 'function'}, {name: 'to_task_name', kind: 'function'}, {name: 'Task_Error', kind: 'class'}, + {name: 'Silent_Error', kind: 'class'}, {name: 'Found_Task', kind: 'type'}, {name: 'Found_Tasks', kind: 'type'}, {name: 'Find_Tasks_Result', kind: 'type'}, From cc9c86efb0b04f9e1d496cb50fdc592293462c46 Mon Sep 17 00:00:00 2001 From: Ryan Atkinson Date: Fri, 19 Jul 2024 07:55:44 -0600 Subject: [PATCH 5/5] wip --- src/lib/invoke.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/invoke.ts b/src/lib/invoke.ts index 1f5807b13c..96a2a103d6 100644 --- a/src/lib/invoke.ts +++ b/src/lib/invoke.ts @@ -18,8 +18,8 @@ and the rest of the args are forwarded to the task's `run` function. // handle uncaught errors attach_process_error_handlers( - (err) => (err?.constructor?.name === 'Task_Error' ? 'Task_Error' : null), - (err) => (err?.constructor?.name === 'Silent_Error' ? '' : null), + (err) => (err.constructor.name === 'Task_Error' ? 'Task_Error' : null), + (err) => (err.constructor.name === 'Silent_Error' ? '' : null), ); await sveltekit_sync_if_obviously_needed();