@ryanatkn/gro 0.116.2 → 0.118.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.
Files changed (74) hide show
  1. package/README.md +31 -15
  2. package/dist/changeset.task.js +1 -1
  3. package/dist/clean_fs.js +2 -1
  4. package/dist/cli.js +1 -1
  5. package/dist/config.d.ts +5 -0
  6. package/dist/config.js +11 -3
  7. package/dist/deploy.task.js +5 -4
  8. package/dist/docs/config.md +25 -0
  9. package/dist/docs/gen.md +16 -0
  10. package/dist/docs/task.md +38 -32
  11. package/dist/docs/tasks.gen.md.js +3 -4
  12. package/dist/esbuild_plugin_external_worker.js +1 -2
  13. package/dist/esbuild_plugin_svelte.js +1 -2
  14. package/dist/esbuild_plugin_sveltekit_shim_alias.js +1 -2
  15. package/dist/format_directory.js +3 -2
  16. package/dist/gen.d.ts +5 -0
  17. package/dist/gen.task.js +7 -8
  18. package/dist/gen_module.d.ts +2 -1
  19. package/dist/gen_module.js +1 -1
  20. package/dist/gro.config.default.js +3 -2
  21. package/dist/gro_helpers.js +18 -17
  22. package/dist/gro_plugin_server.js +9 -5
  23. package/dist/gro_plugin_sveltekit_app.d.ts +0 -1
  24. package/dist/gro_plugin_sveltekit_app.js +2 -4
  25. package/dist/gro_plugin_sveltekit_library.d.ts +0 -2
  26. package/dist/gro_plugin_sveltekit_library.js +1 -7
  27. package/dist/input_path.d.ts +27 -28
  28. package/dist/input_path.js +62 -66
  29. package/dist/input_path.test.js +26 -48
  30. package/dist/invoke_task.d.ts +1 -1
  31. package/dist/invoke_task.js +78 -88
  32. package/dist/lint.task.js +1 -1
  33. package/dist/loader.js +11 -4
  34. package/dist/module.d.ts +1 -1
  35. package/dist/module.js +2 -2
  36. package/dist/modules.d.ts +13 -9
  37. package/dist/modules.js +5 -13
  38. package/dist/modules.test.js +2 -2
  39. package/dist/package.d.ts +47 -6
  40. package/dist/package.gen.js +3 -3
  41. package/dist/package.js +89 -60
  42. package/dist/package_json.d.ts +5 -0
  43. package/dist/package_json.js +9 -4
  44. package/dist/package_meta.d.ts +1 -2
  45. package/dist/path_constants.d.ts +20 -0
  46. package/dist/path_constants.js +27 -0
  47. package/dist/paths.d.ts +11 -34
  48. package/dist/paths.js +28 -67
  49. package/dist/publish.task.js +3 -3
  50. package/dist/register.d.ts +1 -0
  51. package/dist/register.js +2 -0
  52. package/dist/release.task.js +1 -2
  53. package/dist/resolve_node_specifier.js +2 -1
  54. package/dist/run_gen.d.ts +2 -1
  55. package/dist/run_gen.js +2 -2
  56. package/dist/run_gen.test.js +3 -2
  57. package/dist/run_task.js +2 -2
  58. package/dist/sveltekit_config.d.ts +1 -1
  59. package/dist/sveltekit_config.js +9 -5
  60. package/dist/sveltekit_config_global.d.ts +4 -0
  61. package/dist/sveltekit_config_global.js +5 -0
  62. package/dist/sveltekit_helpers.d.ts +4 -0
  63. package/dist/sveltekit_helpers.js +12 -0
  64. package/dist/sync.task.js +4 -1
  65. package/dist/task.d.ts +1 -1
  66. package/dist/task.js +11 -6
  67. package/dist/task.test.js +9 -13
  68. package/dist/task_logging.d.ts +8 -0
  69. package/dist/{print_task.js → task_logging.js} +30 -16
  70. package/dist/task_module.d.ts +4 -3
  71. package/dist/task_module.js +7 -8
  72. package/dist/task_module.test.js +4 -7
  73. package/package.json +36 -20
  74. package/dist/print_task.d.ts +0 -4
@@ -5,8 +5,8 @@ import { Task_Error } from './task.js';
5
5
  import { load_package_json, parse_repo_url } from './package_json.js';
6
6
  import { find_cli, spawn_cli } from './cli.js';
7
7
  import { exists } from './fs.js';
8
- import { is_this_project_gro } from './paths.js';
9
- import { has_sveltekit_library } from './gro_plugin_sveltekit_library.js';
8
+ import { IS_THIS_GRO } from './paths.js';
9
+ import { has_sveltekit_library } from './sveltekit_helpers.js';
10
10
  import { update_changelog } from './changelog.js';
11
11
  import { load_from_env } from './env.js';
12
12
  import { Git_Branch, Git_Origin, git_checkout, git_fetch, git_pull } from './git.js';
@@ -55,7 +55,7 @@ export const task = {
55
55
  throw new Task_Error('gro publish failed to detect a library, run `npm i -D @sveltejs/package` to enable it');
56
56
  }
57
57
  // TODO hacky, ensures Gro bootstraps itself
58
- if (is_this_project_gro) {
58
+ if (IS_THIS_GRO) {
59
59
  await spawn('npm', ['run', 'build']);
60
60
  }
61
61
  const changelog_exists = await exists(changelog);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { register } from 'node:module';
2
+ register('./loader.js', import.meta.url);
@@ -1,6 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { has_sveltekit_library } from './gro_plugin_sveltekit_library.js';
3
- import { has_sveltekit_app } from './gro_plugin_sveltekit_app.js';
2
+ import { has_sveltekit_library, has_sveltekit_app } from './sveltekit_helpers.js';
4
3
  export const Args = z.object({}).strict();
5
4
  export const task = {
6
5
  summary: 'publish and deploy',
@@ -1,6 +1,7 @@
1
1
  import { join } from 'node:path';
2
2
  import { Package_Json, load_package_json } from './package_json.js';
3
- import { NODE_MODULES_DIRNAME, Source_Id, paths } from './paths.js';
3
+ import { Source_Id, paths } from './paths.js';
4
+ import { NODE_MODULES_DIRNAME } from './path_constants.js';
4
5
  export const resolve_node_specifier = async (specifier, dir = paths.root, parent_url, cache, exports_key = specifier.endsWith('.svelte') ? 'svelte' : 'default') => {
5
6
  const parsed = parse_node_specifier(specifier);
6
7
  const subpath = './' + parsed.path;
package/dist/run_gen.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { type Gen_Module_Meta } from './gen_module.js';
2
2
  import { type Gen_Results } from './gen.js';
3
3
  import type { format_file as base_format_file } from './format_file.js';
4
+ import type { Gro_Config } from './config.js';
4
5
  export declare const GEN_NO_PROD_MESSAGE = "gen runs only during development";
5
- export declare const run_gen: (gen_modules: Gen_Module_Meta[], log: Logger, timings: Timings, format_file?: typeof base_format_file) => Promise<Gen_Results>;
6
+ export declare const run_gen: (gen_modules: Gen_Module_Meta[], config: Gro_Config, log: Logger, timings: Timings, format_file?: typeof base_format_file) => Promise<Gen_Results>;
6
7
  export declare const to_gen_import_path: (id: string) => string;
package/dist/run_gen.js CHANGED
@@ -6,7 +6,7 @@ import { GEN_SCHEMA_PATH_SUFFIX } from './gen_module.js';
6
6
  import { to_gen_result, } from './gen.js';
7
7
  import { print_path, source_id_to_base_path } from './paths.js';
8
8
  export const GEN_NO_PROD_MESSAGE = 'gen runs only during development';
9
- export const run_gen = async (gen_modules, log, timings, format_file) => {
9
+ export const run_gen = async (gen_modules, config, log, timings, format_file) => {
10
10
  let input_count = 0;
11
11
  let output_count = 0;
12
12
  const timing_for_run_gen = timings.start('run_gen');
@@ -15,7 +15,7 @@ export const run_gen = async (gen_modules, log, timings, format_file) => {
15
15
  const { id } = module_meta;
16
16
  const timing_for_module = timings.start(id);
17
17
  // Perform code generation by calling `gen` on the module.
18
- const gen_ctx = { origin_id: id, log };
18
+ const gen_ctx = { origin_id: id, config, log };
19
19
  let raw_gen_result;
20
20
  try {
21
21
  switch (module_meta.type) {
@@ -4,6 +4,7 @@ import { resolve, join } from 'node:path';
4
4
  import { Logger } from '@ryanatkn/belt/log.js';
5
5
  import { Timings } from '@ryanatkn/belt/timings.js';
6
6
  import { run_gen } from './run_gen.js';
7
+ import { load_config } from './config.js';
7
8
  const log = new Logger('test__gen'); // TODO test logger?
8
9
  /* test__gen */
9
10
  const test__gen = suite('gen');
@@ -69,7 +70,7 @@ test__gen('basic behavior', async () => {
69
70
  },
70
71
  };
71
72
  const gen_modules_by_input_path = [mod_a, mod_b, mod_c];
72
- const gen_results = await run_gen(gen_modules_by_input_path, log, new Timings(), async (content, opts) => opts.filepath.endsWith('output_b.ts') ? `${content}/*FORMATTED*/` : content);
73
+ const gen_results = await run_gen(gen_modules_by_input_path, await load_config(), log, new Timings(), async (content, opts) => opts.filepath.endsWith('output_b.ts') ? `${content}/*FORMATTED*/` : content);
73
74
  assert.is(gen_results.input_count, 3);
74
75
  assert.is(gen_results.output_count, 4);
75
76
  assert.is(gen_results.successes.length, 3);
@@ -153,7 +154,7 @@ test__gen('failing gen function', async () => {
153
154
  },
154
155
  };
155
156
  const gen_modules_by_input_path = [mod_a, mod_b];
156
- const gen_results = await run_gen(gen_modules_by_input_path, log, new Timings());
157
+ const gen_results = await run_gen(gen_modules_by_input_path, await load_config(), log, new Timings());
157
158
  assert.is(gen_results.input_count, 2);
158
159
  assert.is(gen_results.output_count, 1);
159
160
  assert.is(gen_results.successes.length, 1);
package/dist/run_task.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { cyan, red } from 'kleur/colors';
2
2
  import { print_log_label, System_Logger } from '@ryanatkn/belt/log.js';
3
3
  import { parse_args } from './args.js';
4
- import { print_task_help } from './print_task.js';
4
+ import { log_task_help } from './task_logging.js';
5
5
  import { Task_Error } from './task.js';
6
6
  export const run_task = async (task_meta, unparsed_args, invoke_task, config, timings) => {
7
7
  const { task } = task_meta.mod;
8
8
  const log = new System_Logger(print_log_label(task_meta.name));
9
9
  if (unparsed_args.help) {
10
- print_task_help(log, task_meta);
10
+ log_task_help(log, task_meta);
11
11
  return { ok: true, output: null };
12
12
  }
13
13
  // Parse and validate args.
@@ -3,7 +3,7 @@ import type { Config as SveltekitConfig } from '@sveltejs/kit';
3
3
  import type { CompileOptions, PreprocessorGroup, ModuleCompileOptions } from 'svelte/compiler';
4
4
  /**
5
5
  * Loads a SvelteKit config at `dir`.
6
- * @returns
6
+ * @returns `null` if no config is found
7
7
  */
8
8
  export declare const load_sveltekit_config: (dir?: string) => Promise<SveltekitConfig | null>;
9
9
  /**
@@ -1,11 +1,15 @@
1
1
  import { join } from 'node:path';
2
- import { cwd } from 'node:process';
3
- import { SVELTEKIT_CONFIG_FILENAME } from './paths.js';
2
+ import { SVELTEKIT_CONFIG_FILENAME } from './path_constants.js';
3
+ /*
4
+
5
+ This module is intended to have minimal dependencies to avoid over-imports in the CLI.
6
+
7
+ */
4
8
  /**
5
9
  * Loads a SvelteKit config at `dir`.
6
- * @returns
10
+ * @returns `null` if no config is found
7
11
  */
8
- export const load_sveltekit_config = async (dir = cwd()) => {
12
+ export const load_sveltekit_config = async (dir = process.cwd()) => {
9
13
  try {
10
14
  return (await import(join(dir, SVELTEKIT_CONFIG_FILENAME))).default;
11
15
  }
@@ -19,7 +23,7 @@ export const load_sveltekit_config = async (dir = cwd()) => {
19
23
  * as a convenience wrapper around `load_sveltekit_config`.
20
24
  * Needed because SvelteKit doesn't expose its config resolver.
21
25
  */
22
- export const init_sveltekit_config = async (dir_or_config = cwd()) => {
26
+ export const init_sveltekit_config = async (dir_or_config = process.cwd()) => {
23
27
  const sveltekit_config = typeof dir_or_config === 'string' ? await load_sveltekit_config(dir_or_config) : dir_or_config;
24
28
  const kit = sveltekit_config?.kit;
25
29
  const alias = kit?.alias;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * The parsed SvelteKit config for the cwd, cached globally at the module level.
3
+ */
4
+ export declare const sveltekit_config_global: import("./sveltekit_config.js").Parsed_Sveltekit_Config;
@@ -0,0 +1,5 @@
1
+ import { init_sveltekit_config } from './sveltekit_config.js';
2
+ /**
3
+ * The parsed SvelteKit config for the cwd, cached globally at the module level.
4
+ */
5
+ export const sveltekit_config_global = await init_sveltekit_config(); // always load it to keep things simple ahead
@@ -0,0 +1,4 @@
1
+ import { Package_Json } from './package_json.js';
2
+ import type { Parsed_Sveltekit_Config } from './sveltekit_config.js';
3
+ export declare const has_sveltekit_app: () => Promise<boolean>;
4
+ export declare const has_sveltekit_library: (package_json?: Package_Json, sveltekit_config?: Parsed_Sveltekit_Config) => Promise<boolean>;
@@ -0,0 +1,12 @@
1
+ import { Package_Json, load_package_json } from './package_json.js';
2
+ import { exists } from './fs.js';
3
+ import { sveltekit_config_global } from './sveltekit_config_global.js';
4
+ import { SVELTEKIT_CONFIG_FILENAME } from './path_constants.js';
5
+ export const has_sveltekit_app = () => exists(SVELTEKIT_CONFIG_FILENAME);
6
+ export const has_sveltekit_library = async (package_json, sveltekit_config = sveltekit_config_global) => {
7
+ if (!(await has_sveltekit_app()) || !(await exists(sveltekit_config.lib_path))) {
8
+ return false;
9
+ }
10
+ const p = package_json ?? (await load_package_json());
11
+ return !!p.devDependencies?.['@sveltejs/package'] || !!p.dependencies?.['@sveltejs/package'];
12
+ };
package/dist/sync.task.js CHANGED
@@ -20,7 +20,10 @@ export const task = {
20
20
  run: async ({ args, invoke_task, config, log }) => {
21
21
  const { sveltekit, package_json, gen, install } = args;
22
22
  if (install) {
23
- await spawn('npm', ['i']);
23
+ const result = await spawn('npm', ['i']);
24
+ if (!result.ok) {
25
+ throw new Task_Error('failed npm install');
26
+ }
24
27
  }
25
28
  if (sveltekit) {
26
29
  await sveltekit_sync();
package/dist/task.d.ts CHANGED
@@ -19,7 +19,7 @@ export interface Task_Context<T_Args = object> {
19
19
  export declare const TASK_FILE_SUFFIX_TS = ".task.ts";
20
20
  export declare const TASK_FILE_SUFFIX_JS = ".task.js";
21
21
  export declare const is_task_path: (path: string) => boolean;
22
- export declare const to_task_name: (id: Flavored<string, "Source_Id">) => string;
22
+ export declare const to_task_name: (id: Flavored<string, "Source_Id">, task_root_paths: string[]) => string;
23
23
  /**
24
24
  * This is used by tasks to signal a known failure.
25
25
  * It's useful for cleaning up logging because
package/dist/task.js CHANGED
@@ -1,12 +1,17 @@
1
- import { strip_end } from '@ryanatkn/belt/string.js';
2
- import { import_id_to_lib_path } from './paths.js';
1
+ import { strip_end, strip_start } from '@ryanatkn/belt/string.js';
3
2
  export const TASK_FILE_SUFFIX_TS = '.task.ts';
4
3
  export const TASK_FILE_SUFFIX_JS = '.task.js';
5
4
  export const is_task_path = (path) => path.endsWith(TASK_FILE_SUFFIX_TS) || path.endsWith(TASK_FILE_SUFFIX_JS);
6
- export const to_task_name = (id) => {
7
- const lib_path = import_id_to_lib_path(id);
8
- const name = strip_end(strip_end(lib_path, TASK_FILE_SUFFIX_TS), TASK_FILE_SUFFIX_JS);
9
- return name;
5
+ export const to_task_name = (id, task_root_paths) => {
6
+ let base_path = id;
7
+ // If the id is in any of the task root paths, use the first match and strip it.
8
+ for (const task_root_path of task_root_paths) {
9
+ if (id.startsWith(task_root_path)) {
10
+ base_path = strip_start(strip_start(id, task_root_path), '/');
11
+ break;
12
+ }
13
+ }
14
+ return strip_end(strip_end(base_path, TASK_FILE_SUFFIX_TS), TASK_FILE_SUFFIX_JS);
10
15
  };
11
16
  /**
12
17
  * This is used by tasks to signal a known failure.
package/dist/task.test.js CHANGED
@@ -1,22 +1,18 @@
1
- import { suite } from 'uvu';
1
+ import { test } from 'uvu';
2
2
  import * as assert from 'uvu/assert';
3
3
  import { is_task_path, to_task_name } from './task.js';
4
- /* test__is_task_path */
5
- const test__is_task_path = suite('is_task_path');
6
- test__is_task_path('basic behavior', () => {
4
+ test('is_task_path basic behavior', () => {
7
5
  assert.ok(is_task_path('foo.task.ts'));
8
6
  assert.ok(is_task_path('foo.task.js'));
9
7
  assert.ok(!is_task_path('foo.ts'));
10
8
  assert.ok(is_task_path('bar/baz/foo.task.ts'));
11
9
  assert.ok(!is_task_path('bar/baz/foo.ts'));
12
10
  });
13
- test__is_task_path.run();
14
- /* test__is_task_path */
15
- /* test__to_task_name */
16
- const test__to_task_name = suite('to_task_name');
17
- test__to_task_name('basic behavior', () => {
18
- assert.is(to_task_name('foo.task.ts'), 'foo');
19
- assert.is(to_task_name('bar/baz/foo.task.ts'), 'bar/baz/foo');
11
+ test('to_task_name basic behavior', () => {
12
+ assert.is(to_task_name('foo.task.ts', []), 'foo');
13
+ assert.is(to_task_name('bar/baz/foo.task.ts', []), 'bar/baz/foo');
14
+ assert.is(to_task_name('a/b/c/foo.task.ts', ['a/b/c', 'a']), 'foo');
15
+ assert.is(to_task_name('a/b/c/foo.task.ts', ['a']), 'b/c/foo');
16
+ assert.is(to_task_name('a/b/c/foo.task.ts', ['a/b', 'a']), 'c/foo');
20
17
  });
21
- test__to_task_name.run();
22
- /* test__to_task_name */
18
+ test.run();
@@ -0,0 +1,8 @@
1
+ import { type Find_Modules_Result } from './modules.js';
2
+ import { type Task_Module_Meta } from './task_module.js';
3
+ import { type Input_Path } from './input_path.js';
4
+ import { type Source_Id } from './paths.js';
5
+ export declare const log_tasks: (log: Logger, dir_label: string, source_ids_by_input_path: Map<Input_Path, Source_Id[]>, task_root_paths: string[], log_intro?: boolean) => Promise<void>;
6
+ export declare const log_gro_package_tasks: (input_path: Flavored<string, "Input_Path">, task_root_paths: string[], log: Logger) => Promise<Find_Modules_Result>;
7
+ export declare const log_error_reasons: (log: Logger, reasons: string[]) => void;
8
+ export declare const log_task_help: (log: Logger, meta: Task_Module_Meta) => void;
@@ -2,43 +2,57 @@ import { cyan, gray, green, red } from 'kleur/colors';
2
2
  import { plural } from '@ryanatkn/belt/string.js';
3
3
  import { print_value } from '@ryanatkn/belt/print.js';
4
4
  import { ZodFirstPartyTypeKind } from 'zod';
5
- import { load_modules } from './modules.js';
5
+ import { find_modules, load_modules } from './modules.js';
6
6
  import { load_task_module } from './task_module.js';
7
- export const log_available_tasks = async (log, dir_label, source_ids_by_input_path, print_intro = true) => {
7
+ import { to_gro_input_path } from './input_path.js';
8
+ import { print_path_or_gro_path } from './paths.js';
9
+ import { is_task_path } from './task.js';
10
+ import { search_fs } from './search_fs.js';
11
+ export const log_tasks = async (log, dir_label, source_ids_by_input_path, task_root_paths, log_intro = true) => {
8
12
  const source_ids = Array.from(source_ids_by_input_path.values()).flat();
9
13
  if (source_ids.length) {
10
- // Load all of the tasks so we can print their summary, and args for the `--help` flag.
11
- const load_modules_result = await load_modules(source_ids_by_input_path, load_task_module);
14
+ // Load all of the tasks so we can log their summary, and args for the `--help` flag.
15
+ const load_modules_result = await load_modules(source_ids_by_input_path, (id) => load_task_module(id, task_root_paths));
12
16
  if (!load_modules_result.ok) {
13
17
  log_error_reasons(log, load_modules_result.reasons);
14
18
  process.exit(1);
15
19
  }
16
- const printed = [
17
- `${print_intro ? '\n\n' : ''}${source_ids.length} task${plural(source_ids.length)} in ${dir_label}:\n`,
20
+ const logged = [
21
+ `${log_intro ? '\n\n' : ''}${source_ids.length} task${plural(source_ids.length)} in ${dir_label}:\n`,
18
22
  ];
19
- if (print_intro) {
20
- printed.unshift(`\n\n${gray('Run a task:')} gro [name]`, `\n${gray('View help:')} gro [name] --help`);
23
+ if (log_intro) {
24
+ logged.unshift(`\n\n${gray('Run a task:')} gro [name]`, `\n${gray('View help:')} gro [name] --help`);
21
25
  }
22
26
  const longest_task_name = to_max_length(load_modules_result.modules, (m) => m.name);
23
27
  for (const meta of load_modules_result.modules) {
24
- printed.push('\n' + cyan(pad(meta.name, longest_task_name)), ' ', meta.mod.task.summary || '');
28
+ logged.push('\n' + cyan(pad(meta.name, longest_task_name)), ' ', meta.mod.task.summary || '');
25
29
  }
26
- log[print_intro ? 'info' : 'plain'](printed.join('') + '\n');
30
+ log[log_intro ? 'info' : 'plain'](logged.join('') + '\n');
27
31
  }
28
32
  else {
29
33
  log.info(`No tasks found in ${dir_label}.`);
30
34
  }
31
35
  };
36
+ export const log_gro_package_tasks = async (input_path, task_root_paths, log) => {
37
+ const gro_dir_input_path = to_gro_input_path(input_path);
38
+ const gro_dir_find_modules_result = await find_modules([gro_dir_input_path], (id) => search_fs(id, { filter: (path) => is_task_path(path) }));
39
+ if (gro_dir_find_modules_result.ok) {
40
+ const gro_path_data = gro_dir_find_modules_result.source_id_path_data_by_input_path.get(gro_dir_input_path);
41
+ // Log the Gro matches.
42
+ await log_tasks(log, print_path_or_gro_path(gro_path_data.id), gro_dir_find_modules_result.source_ids_by_input_path, task_root_paths);
43
+ }
44
+ return gro_dir_find_modules_result;
45
+ };
32
46
  export const log_error_reasons = (log, reasons) => {
33
47
  for (const reason of reasons) {
34
48
  log.error(red(reason));
35
49
  }
36
50
  };
37
51
  const ARGS_PROPERTY_NAME = '[...args]';
38
- export const print_task_help = (log, meta) => {
52
+ export const log_task_help = (log, meta) => {
39
53
  const { name, mod: { task }, } = meta;
40
- const printed = [];
41
- printed.push(cyan(name), 'help', cyan(`\n\ngro ${name}`) + `: ${task.summary || '(no summary available)'}\n`);
54
+ const logged = [];
55
+ logged.push(cyan(name), 'help', cyan(`\n\ngro ${name}`) + `: ${task.summary || '(no summary available)'}\n`);
42
56
  if (task.Args) {
43
57
  const properties = to_arg_properties(task.Args._def, meta);
44
58
  // TODO hacky padding for some quick and dirty tables
@@ -47,13 +61,13 @@ export const print_task_help = (log, meta) => {
47
61
  const longest_default = to_max_length(properties, (p) => print_value(p.schema.default));
48
62
  for (const property of properties) {
49
63
  const name = property.name === '_' ? ARGS_PROPERTY_NAME : property.name;
50
- printed.push(`\n${green(pad(name, longest_task_name))} `, gray(pad(property.schema.type, longest_type)) + ' ', pad(print_value(property.schema.default), longest_default) + ' ', property.schema.description || '(no description available)');
64
+ logged.push(`\n${green(pad(name, longest_task_name))} `, gray(pad(property.schema.type, longest_type)) + ' ', pad(print_value(property.schema.default), longest_default) + ' ', property.schema.description || '(no description available)');
51
65
  }
52
66
  if (!properties.length) {
53
- printed.push('\n' + gray('this task has no args'));
67
+ logged.push('\n' + gray('this task has no args'));
54
68
  }
55
69
  }
56
- log.info(...printed, '\n');
70
+ log.info(...logged, '\n');
57
71
  };
58
72
  const to_arg_properties = (def, meta) => {
59
73
  const type_name = to_type_name(def);
@@ -1,5 +1,6 @@
1
1
  import { load_modules, find_modules, type Module_Meta, type Load_Module_Result, type Find_Modules_Failure } from './modules.js';
2
2
  import { type Task } from './task.js';
3
+ import { Input_Path } from './input_path.js';
3
4
  export interface Task_Module {
4
5
  task: Task;
5
6
  }
@@ -7,8 +8,8 @@ export interface Task_Module_Meta extends Module_Meta<Task_Module> {
7
8
  name: string;
8
9
  }
9
10
  export declare const validate_task_module: (mod: Record<string, any>) => mod is Task_Module;
10
- export declare const load_task_module: (id: string) => Promise<Load_Module_Result<Task_Module_Meta>>;
11
- export declare const find_task_modules: (input_paths?: string[], extensions?: string[], root_dirs?: string[]) => Promise<ReturnType<typeof find_modules>>;
12
- export declare const load_task_modules: (input_paths?: string[], extensions?: string[], root_dirs?: string[]) => Promise<ReturnType<typeof load_modules<Task_Module, Task_Module_Meta>> | ({
11
+ export declare const load_task_module: (id: string, task_root_paths: string[]) => Promise<Load_Module_Result<Task_Module_Meta>>;
12
+ export declare const find_task_modules: (input_paths: Input_Path[], task_root_paths: string[]) => Promise<ReturnType<typeof find_modules>>;
13
+ export declare const load_task_modules: (input_paths: Input_Path[], task_root_paths: string[]) => Promise<ReturnType<typeof load_modules<Task_Module, Task_Module_Meta>> | ({
13
14
  ok: false;
14
15
  } & Find_Modules_Failure)>;
@@ -1,19 +1,18 @@
1
- import { paths } from './paths.js';
2
1
  import { load_module, load_modules, find_modules, } from './modules.js';
3
2
  import { to_task_name, is_task_path, TASK_FILE_SUFFIX_TS, TASK_FILE_SUFFIX_JS, } from './task.js';
4
- import { get_possible_source_ids } from './input_path.js';
3
+ import { Input_Path, get_possible_source_ids } from './input_path.js';
5
4
  import { search_fs } from './search_fs.js';
6
5
  export const validate_task_module = (mod) => !!mod.task && typeof mod.task.run === 'function';
7
- export const load_task_module = async (id) => {
6
+ export const load_task_module = async (id, task_root_paths) => {
8
7
  const result = await load_module(id, validate_task_module);
9
8
  if (!result.ok)
10
9
  return result;
11
- return { ...result, mod: { ...result.mod, name: to_task_name(id) } };
10
+ return { ...result, mod: { ...result.mod, name: to_task_name(id, task_root_paths) } }; // TODO this task name needs to use task root paths or cwd
12
11
  };
13
- export const find_task_modules = async (input_paths = [paths.lib], extensions = [TASK_FILE_SUFFIX_TS, TASK_FILE_SUFFIX_JS], root_dirs) => find_modules(input_paths, (id) => search_fs(id, { filter: (path) => is_task_path(path) }), (input_path) => get_possible_source_ids(input_path, extensions, root_dirs));
14
- export const load_task_modules = async (input_paths, extensions, root_dirs) => {
15
- const find_modules_result = await find_task_modules(input_paths, extensions, root_dirs);
12
+ export const find_task_modules = async (input_paths, task_root_paths) => find_modules(input_paths, (id) => search_fs(id, { filter: (path) => is_task_path(path) }), (input_path) => get_possible_source_ids(input_path, [TASK_FILE_SUFFIX_TS, TASK_FILE_SUFFIX_JS], task_root_paths));
13
+ export const load_task_modules = async (input_paths, task_root_paths) => {
14
+ const find_modules_result = await find_task_modules(input_paths, task_root_paths);
16
15
  if (!find_modules_result.ok)
17
16
  return find_modules_result;
18
- return load_modules(find_modules_result.source_ids_by_input_path, load_task_module);
17
+ return load_modules(find_modules_result.source_ids_by_input_path, (id) => load_task_module(id, task_root_paths));
19
18
  };
@@ -21,7 +21,7 @@ const test__load_task_module = suite('load_task_module');
21
21
  test__load_task_module('basic behavior', async () => {
22
22
  const name = 'fixtures/test_task_module.task_fixture.js';
23
23
  const id = resolve('src/' + name);
24
- const result = await load_task_module(id);
24
+ const result = await load_task_module(id, []);
25
25
  assert.ok(result.ok);
26
26
  assert.is(result.mod.id, id);
27
27
  assert.is(result.mod.id, id);
@@ -30,7 +30,7 @@ test__load_task_module('basic behavior', async () => {
30
30
  });
31
31
  test__load_task_module('invalid module', async () => {
32
32
  const id = resolve('src/fixtures/test_invalid_task_module.js');
33
- const result = await load_task_module(id);
33
+ const result = await load_task_module(id, []);
34
34
  assert.ok(!result.ok);
35
35
  if (result.type === 'invalid') {
36
36
  assert.is(result.id, id);
@@ -43,7 +43,7 @@ test__load_task_module('invalid module', async () => {
43
43
  });
44
44
  test__load_task_module('failing module', async () => {
45
45
  const id = resolve('src/fixtures/test_failing_task_module.js');
46
- const result = await load_task_module(id);
46
+ const result = await load_task_module(id, []);
47
47
  assert.ok(!result.ok);
48
48
  if (result.type === 'importFailed') {
49
49
  assert.is(result.id, id);
@@ -58,10 +58,7 @@ test__load_task_module.run();
58
58
  /* test__load_task_modules */
59
59
  const test__load_task_modules = suite('load_task_modules');
60
60
  test__load_task_modules('basic behavior', async () => {
61
- const result = await load_task_modules([
62
- resolve('src/lib/test'),
63
- resolve('src/lib/test.task.ts'),
64
- ]);
61
+ const result = await load_task_modules([resolve('src/lib/test'), resolve('src/lib/test.task.ts')], [resolve('src/lib')]);
65
62
  assert.ok(result.ok);
66
63
  assert.is(result.modules.length, 1);
67
64
  assert.is(result.modules[0].mod, actual_test_task_module);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryanatkn/gro",
3
- "version": "0.116.2",
3
+ "version": "0.118.0",
4
4
  "description": "task runner and toolkit extending SvelteKit",
5
5
  "motto": "generate, run, optimize",
6
6
  "icon": "🌰",
@@ -51,11 +51,11 @@
51
51
  "es-module-lexer": "^1.5.3",
52
52
  "kleur": "^4.1.5",
53
53
  "mri": "^1.2.0",
54
- "prettier": "^3.2.5",
55
- "prettier-plugin-svelte": "^3.2.3",
54
+ "prettier": "^3.3.2",
55
+ "prettier-plugin-svelte": "^3.2.4",
56
56
  "tiny-glob": "^0.2.9",
57
57
  "ts-morph": "^22.0.0",
58
- "tslib": "^2.6.2",
58
+ "tslib": "^2.6.3",
59
59
  "zod": "^3.23.8"
60
60
  },
61
61
  "peerDependencies": {
@@ -66,21 +66,21 @@
66
66
  "@changesets/changelog-git": "^0.2.0",
67
67
  "@changesets/types": "^6.0.0",
68
68
  "@ryanatkn/eslint-config": "^0.1.2",
69
- "@ryanatkn/fuz": "^0.101.4",
70
- "@ryanatkn/moss": "^0.3.0",
71
- "@sveltejs/adapter-static": "^3.0.1",
72
- "@sveltejs/kit": "^2.5.10",
73
- "@sveltejs/package": "^2.3.1",
74
- "@sveltejs/vite-plugin-svelte": "^3.1.0",
69
+ "@ryanatkn/fuz": "^0.102.1",
70
+ "@ryanatkn/moss": "^0.4.0",
71
+ "@sveltejs/adapter-static": "^3.0.2",
72
+ "@sveltejs/kit": "^2.5.15",
73
+ "@sveltejs/package": "^2.3.2",
74
+ "@sveltejs/vite-plugin-svelte": "^3.1.1",
75
75
  "@types/fs-extra": "^11.0.4",
76
- "@types/node": "^20.12.12",
77
- "@typescript-eslint/eslint-plugin": "^7.10.0",
78
- "@typescript-eslint/parser": "^7.10.0",
76
+ "@types/node": "^20.14.2",
77
+ "@typescript-eslint/eslint-plugin": "^7.13.0",
78
+ "@typescript-eslint/parser": "^7.13.0",
79
79
  "esbuild": "^0.20.2",
80
80
  "eslint": "^8.57.0",
81
- "eslint-plugin-svelte": "^2.39.0",
82
- "svelte": "^5.0.0-next.153",
83
- "svelte-check": "^3.7.1",
81
+ "eslint-plugin-svelte": "^2.39.3",
82
+ "svelte": "^5.0.0-next.155",
83
+ "svelte-check": "^3.8.0",
84
84
  "typescript": "^5.4.5",
85
85
  "uvu": "^0.5.6"
86
86
  },
@@ -306,6 +306,10 @@
306
306
  "default": "./dist/package.js",
307
307
  "types": "./dist/package.d.ts"
308
308
  },
309
+ "./path_constants.js": {
310
+ "default": "./dist/path_constants.js",
311
+ "types": "./dist/path_constants.d.ts"
312
+ },
309
313
  "./path.js": {
310
314
  "default": "./dist/path.js",
311
315
  "types": "./dist/path.d.ts"
@@ -318,14 +322,14 @@
318
322
  "default": "./dist/plugin.js",
319
323
  "types": "./dist/plugin.d.ts"
320
324
  },
321
- "./print_task.js": {
322
- "default": "./dist/print_task.js",
323
- "types": "./dist/print_task.d.ts"
324
- },
325
325
  "./publish.task.js": {
326
326
  "default": "./dist/publish.task.js",
327
327
  "types": "./dist/publish.task.d.ts"
328
328
  },
329
+ "./register.js": {
330
+ "default": "./dist/register.js",
331
+ "types": "./dist/register.d.ts"
332
+ },
329
333
  "./release.task.js": {
330
334
  "default": "./dist/release.task.js",
331
335
  "types": "./dist/release.task.d.ts"
@@ -362,10 +366,18 @@
362
366
  "default": "./dist/svelte_helpers.js",
363
367
  "types": "./dist/svelte_helpers.d.ts"
364
368
  },
369
+ "./sveltekit_config_global.js": {
370
+ "default": "./dist/sveltekit_config_global.js",
371
+ "types": "./dist/sveltekit_config_global.d.ts"
372
+ },
365
373
  "./sveltekit_config.js": {
366
374
  "default": "./dist/sveltekit_config.js",
367
375
  "types": "./dist/sveltekit_config.d.ts"
368
376
  },
377
+ "./sveltekit_helpers.js": {
378
+ "default": "./dist/sveltekit_helpers.js",
379
+ "types": "./dist/sveltekit_helpers.d.ts"
380
+ },
369
381
  "./sveltekit_shim_app_environment.js": {
370
382
  "default": "./dist/sveltekit_shim_app_environment.js",
371
383
  "types": "./dist/sveltekit_shim_app_environment.d.ts"
@@ -398,6 +410,10 @@
398
410
  "default": "./dist/sync.task.js",
399
411
  "types": "./dist/sync.task.d.ts"
400
412
  },
413
+ "./task_logging.js": {
414
+ "default": "./dist/task_logging.js",
415
+ "types": "./dist/task_logging.d.ts"
416
+ },
401
417
  "./task_module.js": {
402
418
  "default": "./dist/task_module.js",
403
419
  "types": "./dist/task_module.d.ts"
@@ -1,4 +0,0 @@
1
- import { type Task_Module_Meta } from './task_module.js';
2
- export declare const log_available_tasks: (log: Logger, dir_label: string, source_ids_by_input_path: Map<string, string[]>, print_intro?: boolean) => Promise<void>;
3
- export declare const log_error_reasons: (log: Logger, reasons: string[]) => void;
4
- export declare const print_task_help: (log: Logger, meta: Task_Module_Meta) => void;