@ryanatkn/gro 0.133.8 → 0.135.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 (62) hide show
  1. package/dist/args.d.ts.map +1 -1
  2. package/dist/args.js +6 -2
  3. package/dist/changeset.task.js +3 -3
  4. package/dist/check.task.js +2 -2
  5. package/dist/cli.d.ts +5 -4
  6. package/dist/cli.d.ts.map +1 -1
  7. package/dist/deploy.task.d.ts +2 -2
  8. package/dist/deploy.task.d.ts.map +1 -1
  9. package/dist/deploy.task.js +7 -7
  10. package/dist/esbuild_helpers.js +3 -3
  11. package/dist/gen.js +3 -3
  12. package/dist/gen.task.d.ts.map +1 -1
  13. package/dist/gen.task.js +8 -8
  14. package/dist/gro_helpers.js +1 -1
  15. package/dist/gro_plugin_server.d.ts.map +1 -1
  16. package/dist/gro_plugin_server.js +6 -1
  17. package/dist/invoke.js +3 -0
  18. package/dist/invoke_task.d.ts.map +1 -1
  19. package/dist/invoke_task.js +8 -8
  20. package/dist/package.js +19 -19
  21. package/dist/package_json.js +3 -3
  22. package/dist/path.d.ts +1 -0
  23. package/dist/path.d.ts.map +1 -1
  24. package/dist/paths.js +2 -2
  25. package/dist/publish.task.js +4 -4
  26. package/dist/resolve.task.js +3 -3
  27. package/dist/run.task.js +2 -2
  28. package/dist/run_gen.js +3 -3
  29. package/dist/run_task.d.ts.map +1 -1
  30. package/dist/run_task.js +6 -5
  31. package/dist/task.js +3 -3
  32. package/dist/task_logging.js +7 -7
  33. package/dist/test.task.js +2 -2
  34. package/dist/watch_dir.d.ts +3 -3
  35. package/dist/watch_dir.d.ts.map +1 -1
  36. package/dist/watch_dir.js +3 -3
  37. package/package.json +18 -18
  38. package/src/lib/args.ts +6 -2
  39. package/src/lib/changeset.task.ts +3 -3
  40. package/src/lib/check.task.ts +2 -2
  41. package/src/lib/cli.ts +5 -5
  42. package/src/lib/deploy.task.ts +12 -7
  43. package/src/lib/esbuild_helpers.ts +3 -3
  44. package/src/lib/gen.task.ts +11 -9
  45. package/src/lib/gen.ts +3 -3
  46. package/src/lib/gro_helpers.ts +1 -1
  47. package/src/lib/gro_plugin_server.ts +6 -1
  48. package/src/lib/invoke.ts +4 -0
  49. package/src/lib/invoke_task.ts +10 -8
  50. package/src/lib/package.ts +19 -19
  51. package/src/lib/package_json.ts +3 -3
  52. package/src/lib/path.ts +1 -1
  53. package/src/lib/paths.ts +2 -2
  54. package/src/lib/publish.task.ts +4 -4
  55. package/src/lib/resolve.task.ts +3 -3
  56. package/src/lib/run.task.ts +2 -2
  57. package/src/lib/run_gen.ts +3 -3
  58. package/src/lib/run_task.ts +8 -5
  59. package/src/lib/task.ts +3 -3
  60. package/src/lib/task_logging.ts +10 -10
  61. package/src/lib/test.task.ts +2 -2
  62. package/src/lib/watch_dir.ts +5 -5
package/dist/run_task.js CHANGED
@@ -1,5 +1,6 @@
1
- import { cyan, red } from '@ryanatkn/belt/styletext.js';
2
- import { print_log_label, System_Logger } from '@ryanatkn/belt/log.js';
1
+ import { styleText as st } from 'node:util';
2
+ import { print_log_label } from '@ryanatkn/belt/print.js';
3
+ import { System_Logger } from '@ryanatkn/belt/log.js';
3
4
  import { parse_args } from './args.js';
4
5
  import { log_task_help } from './task_logging.js';
5
6
  import { Task_Error } from './task.js';
@@ -16,7 +17,7 @@ export const run_task = async (task_meta, unparsed_args, invoke_task, config, ti
16
17
  if (task.Args) {
17
18
  const parsed = parse_args(unparsed_args, task.Args);
18
19
  if (!parsed.success) {
19
- log.error(red(`Args validation failed:`), '\n', parsed.error.format());
20
+ log.error(st('red', `Args validation failed:`), '\n', parsed.error.format());
20
21
  throw new Task_Error(`Task args failed validation`);
21
22
  }
22
23
  args = parsed.data;
@@ -36,9 +37,9 @@ export const run_task = async (task_meta, unparsed_args, invoke_task, config, ti
36
37
  catch (err) {
37
38
  return {
38
39
  ok: false,
39
- reason: red(err?.constructor?.name === 'Task_Error'
40
+ reason: st('red', err?.constructor?.name === 'Task_Error'
40
41
  ? err.message
41
- : `Unexpected error running task ${cyan(task_meta.name)}. If this is unexpected try running \`npm i\` and \`gro clean\`.`),
42
+ : `Unexpected error running task ${st('cyan', task_meta.name)}. If this is unexpected try running \`npm i\` and \`gro clean\`.`),
42
43
  error: err,
43
44
  };
44
45
  }
package/dist/task.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ensure_end, strip_end, strip_start } from '@ryanatkn/belt/string.js';
2
- import { red } from '@ryanatkn/belt/styletext.js';
2
+ import { styleText as st } from 'node:util';
3
3
  import { isAbsolute, join, relative } from 'node:path';
4
4
  import { resolve_input_files, resolve_input_paths, } from './input_path.js';
5
5
  import { GRO_DIST_DIR, print_path } from './paths.js';
@@ -57,7 +57,7 @@ export const find_tasks = (input_paths, task_root_dirs, config, timings) => {
57
57
  resolved_input_paths,
58
58
  input_paths,
59
59
  task_root_dirs,
60
- reasons: unmapped_input_paths.map((input_path) => red(`Input path ${print_path(input_path)} cannot be mapped to a file or directory.`)),
60
+ reasons: unmapped_input_paths.map((input_path) => st('red', `Input path ${print_path(input_path)} cannot be mapped to a file or directory.`)),
61
61
  };
62
62
  }
63
63
  // Find all of the files for any directories.
@@ -78,7 +78,7 @@ export const find_tasks = (input_paths, task_root_dirs, config, timings) => {
78
78
  resolved_input_paths,
79
79
  input_paths,
80
80
  task_root_dirs,
81
- reasons: input_directories_with_no_files.map((input_path) => red(`Input directory contains no matching files: ${print_path(input_path)}`)),
81
+ reasons: input_directories_with_no_files.map((input_path) => st('red', `Input directory contains no matching files: ${print_path(input_path)}`)),
82
82
  };
83
83
  }
84
84
  return {
@@ -1,4 +1,4 @@
1
- import { cyan, gray, green, red } from '@ryanatkn/belt/styletext.js';
1
+ import { styleText as st } from 'node:util';
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';
@@ -8,7 +8,7 @@ export const log_tasks = (log, loaded_tasks, log_intro = true) => {
8
8
  const { resolved_input_files_by_root_dir } = found_tasks;
9
9
  const logged = [];
10
10
  if (log_intro) {
11
- logged.unshift(`\n\n${gray('Run a task:')} gro [name]`, `\n${gray('View help:')} gro [name] --help`);
11
+ logged.unshift(`\n\n${st('gray', 'Run a task:')} gro [name]`, `\n${st('gray', 'View help:')} gro [name] --help`);
12
12
  }
13
13
  for (const [root_dir, resolved_input_files] of resolved_input_files_by_root_dir) {
14
14
  const dir_label = print_path(root_dir);
@@ -20,21 +20,21 @@ export const log_tasks = (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(meta.name.padEnd(longest_task_name)), ' ', meta.mod.task.summary ?? '');
23
+ logged.push('\n' + st('cyan', meta.name.padEnd(longest_task_name)), ' ', meta.mod.task.summary ?? '');
24
24
  }
25
25
  }
26
26
  log[log_intro ? 'info' : 'plain'](logged.join('') + '\n');
27
27
  };
28
28
  export const log_error_reasons = (log, reasons) => {
29
29
  for (const reason of reasons) {
30
- log.error(red(reason));
30
+ log.error(st('red', reason));
31
31
  }
32
32
  };
33
33
  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 ?? '(no summary available)'}\n`);
37
+ logged.push(st('cyan', name), 'help', st('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
@@ -43,10 +43,10 @@ export const log_task_help = (log, meta) => {
43
43
  const longest_default = to_max_length(properties, (p) => print_value(p.schema.default));
44
44
  for (const property of properties) {
45
45
  const name = property.name === '_' ? ARGS_PROPERTY_NAME : property.name;
46
- logged.push(`\n${green(name.padEnd(longest_task_name))} `, gray(property.schema.type.padEnd(longest_type)) + ' ', print_value(property.schema.default).padEnd(longest_default) + ' ', property.schema.description || '(no description available)');
46
+ logged.push(`\n${st('green', name.padEnd(longest_task_name))} `, st('gray', property.schema.type.padEnd(longest_type)) + ' ', print_value(property.schema.default).padEnd(longest_default) + ' ', property.schema.description || '(no description available)');
47
47
  }
48
48
  if (!properties.length) {
49
- logged.push('\n' + gray('this task has no args'));
49
+ logged.push('\n' + st('gray', 'this task has no args'));
50
50
  }
51
51
  }
52
52
  log.info(...logged, '\n');
package/dist/test.task.js CHANGED
@@ -1,4 +1,4 @@
1
- import { yellow } from '@ryanatkn/belt/styletext.js';
1
+ import { styleText as st } from 'node:util';
2
2
  import { z } from 'zod';
3
3
  import { Task_Error } from './task.js';
4
4
  import { paths } from './paths.js';
@@ -21,7 +21,7 @@ export const task = {
21
21
  run: async ({ args, log }) => {
22
22
  const { _: patterns, bail, cwd, ignore } = args;
23
23
  if (!find_cli('uvu')) {
24
- log.warn(yellow('uvu is not installed, skipping tests'));
24
+ log.warn(st('yellow', 'uvu is not installed, skipping tests'));
25
25
  return;
26
26
  }
27
27
  const [{ run }, { parse }] = await Promise.all([import('uvu/run'), import('uvu/parse')]);
@@ -1,4 +1,4 @@
1
- import { type WatchOptions } from 'chokidar';
1
+ import { type ChokidarOptions } from 'chokidar';
2
2
  import type { Path_Filter } from './path.js';
3
3
  export interface Watch_Node_Fs {
4
4
  init: () => Promise<void>;
@@ -15,7 +15,7 @@ export interface Options {
15
15
  dir: string;
16
16
  on_change: Watcher_Change_Callback;
17
17
  filter?: Path_Filter | null | undefined;
18
- chokidar?: WatchOptions;
18
+ chokidar?: ChokidarOptions;
19
19
  /**
20
20
  * When `false`, returns the `path` relative to `dir`.
21
21
  * @default true
@@ -25,5 +25,5 @@ export interface Options {
25
25
  /**
26
26
  * Watch for changes on the filesystem using chokidar.
27
27
  */
28
- export declare const watch_dir: ({ dir, on_change, filter, absolute, chokidar: chokidar_options, }: Options) => Watch_Node_Fs;
28
+ export declare const watch_dir: ({ dir, on_change, filter, absolute, chokidar, }: Options) => Watch_Node_Fs;
29
29
  //# sourceMappingURL=watch_dir.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"watch_dir.d.ts","sourceRoot":"../src/lib/","sources":["watch_dir.ts"],"names":[],"mappings":"AAAA,OAAiB,EAAC,KAAK,YAAY,EAAC,MAAM,UAAU,CAAC;AAGrD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,WAAW,CAAC;AAK3C,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,OAAO,CAAC;CACtB;AACD,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACjE,MAAM,MAAM,uBAAuB,GAAG,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;AAEvE,MAAM,WAAW,OAAO;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,uBAAuB,CAAC;IACnC,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,sEAMnB,OAAO,KAAG,aA6CZ,CAAC"}
1
+ {"version":3,"file":"watch_dir.d.ts","sourceRoot":"../src/lib/","sources":["watch_dir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,eAAe,EAAiB,MAAM,UAAU,CAAC;AAGrE,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,WAAW,CAAC;AAK3C,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,OAAO,CAAC;CACtB;AACD,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACjE,MAAM,MAAM,uBAAuB,GAAG,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;AAEvE,MAAM,WAAW,OAAO;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,uBAAuB,CAAC;IACnC,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,oDAMnB,OAAO,KAAG,aA6CZ,CAAC"}
package/dist/watch_dir.js CHANGED
@@ -1,14 +1,14 @@
1
- import chokidar, {} from 'chokidar';
1
+ import { watch } from 'chokidar';
2
2
  import { relative } from 'node:path';
3
3
  import { statSync } from 'node:fs';
4
4
  /**
5
5
  * Watch for changes on the filesystem using chokidar.
6
6
  */
7
- export const watch_dir = ({ dir, on_change, filter, absolute = true, chokidar: chokidar_options, }) => {
7
+ export const watch_dir = ({ dir, on_change, filter, absolute = true, chokidar = {}, }) => {
8
8
  let watcher;
9
9
  return {
10
10
  init: async () => {
11
- watcher = chokidar.watch(dir, chokidar_options);
11
+ watcher = watch(dir, chokidar);
12
12
  watcher.on('add', (path, s) => {
13
13
  const stats = s ?? statSync(path);
14
14
  const final_path = absolute ? path : relative(dir, path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryanatkn/gro",
3
- "version": "0.133.8",
3
+ "version": "0.135.0",
4
4
  "description": "task runner and toolkit extending SvelteKit",
5
5
  "motto": "generate, run, optimize",
6
6
  "glyph": "🌰",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "type": "module",
34
34
  "engines": {
35
- "node": ">=20.12"
35
+ "node": ">=20.17"
36
36
  },
37
37
  "bin": {
38
38
  "gro": "dist/gro.js"
@@ -49,8 +49,8 @@
49
49
  "typescript"
50
50
  ],
51
51
  "dependencies": {
52
- "@ryanatkn/belt": "^0.24.12",
53
- "chokidar": "^3.6.0",
52
+ "@ryanatkn/belt": "^0.25.0",
53
+ "chokidar": "^4.0.0",
54
54
  "dotenv": "^16.4.5",
55
55
  "es-module-lexer": "^1.5.4",
56
56
  "esm-env": "^1.0.0",
@@ -58,7 +58,7 @@
58
58
  "prettier": "^3.3.3",
59
59
  "prettier-plugin-svelte": "^3.2.6",
60
60
  "ts-morph": "^23.0.0",
61
- "tslib": "^2.6.3",
61
+ "tslib": "^2.7.0",
62
62
  "zod": "^3.23.8"
63
63
  },
64
64
  "peerDependencies": {
@@ -68,22 +68,22 @@
68
68
  "devDependencies": {
69
69
  "@changesets/changelog-git": "^0.2.0",
70
70
  "@changesets/types": "^6.0.0",
71
- "@ryanatkn/eslint-config": "^0.5.1",
72
- "@ryanatkn/fuz": "^0.120.4",
73
- "@ryanatkn/moss": "^0.13.3",
71
+ "@ryanatkn/eslint-config": "^0.5.3",
72
+ "@ryanatkn/fuz": "^0.121.0",
73
+ "@ryanatkn/moss": "^0.15.0",
74
74
  "@sveltejs/adapter-static": "^3.0.4",
75
- "@sveltejs/kit": "^2.5.26",
76
- "@sveltejs/package": "^2.3.4",
77
- "@sveltejs/vite-plugin-svelte": "^3.1.1",
75
+ "@sveltejs/kit": "^2.5.27",
76
+ "@sveltejs/package": "^2.3.5",
77
+ "@sveltejs/vite-plugin-svelte": "^3.1.2",
78
78
  "@types/fs-extra": "^11.0.4",
79
- "@types/node": "^22.3.0",
79
+ "@types/node": "^22.5.5",
80
80
  "esbuild": "^0.21.5",
81
- "eslint": "^9.9.0",
82
- "eslint-plugin-svelte": "^2.43.0",
83
- "svelte": "^5.0.0-next.244",
84
- "svelte-check": "^4.0.1",
85
- "typescript": "^5.5.4",
86
- "typescript-eslint": "^8.1.0",
81
+ "eslint": "^9.10.0",
82
+ "eslint-plugin-svelte": "^2.44.0",
83
+ "svelte": "^5.0.0-next.246",
84
+ "svelte-check": "^4.0.2",
85
+ "typescript": "^5.6.2",
86
+ "typescript-eslint": "^8.5.0",
87
87
  "uvu": "^0.5.6"
88
88
  },
89
89
  "prettier": {
package/src/lib/args.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {gray, magenta} from '@ryanatkn/belt/styletext.js';
1
+ import {styleText as st} from 'node:util';
2
2
  import mri from 'mri';
3
3
  import type {z} from 'zod';
4
4
 
@@ -166,4 +166,8 @@ export const to_forwarded_args_by_command = (
166
166
  };
167
167
 
168
168
  export const print_command_args = (serialized_args: string[]): string =>
169
- gray('[') + magenta('running command') + gray(']') + ' ' + serialized_args.join(' ');
169
+ st('gray', '[') +
170
+ st('magenta', 'running command') +
171
+ st('gray', ']') +
172
+ ' ' +
173
+ serialized_args.join(' ');
@@ -1,6 +1,6 @@
1
1
  import {z} from 'zod';
2
2
  import {spawn} from '@ryanatkn/belt/process.js';
3
- import {red, blue} from '@ryanatkn/belt/styletext.js';
3
+ import {styleText as st} from 'node:util';
4
4
  import type {WrittenConfig} from '@changesets/types';
5
5
  import {readFile, writeFile} from 'node:fs/promises';
6
6
  import {join} from 'node:path';
@@ -100,8 +100,8 @@ export const task: Task<Args> = {
100
100
  ? CHANGESET_RESTRICTED_ACCESS
101
101
  : CHANGESET_PUBLIC_ACCESS;
102
102
 
103
- const access_color = access === CHANGESET_RESTRICTED_ACCESS ? blue : red;
104
- log.info('initing changeset with ' + access_color(access) + ' access');
103
+ const access_color = access === CHANGESET_RESTRICTED_ACCESS ? 'blue' : 'red';
104
+ log.info('initing changeset with ' + st(access_color, access) + ' access');
105
105
  if (access !== CHANGESET_RESTRICTED_ACCESS) {
106
106
  await update_changeset_config(path, (config) => {
107
107
  const updated = {...config};
@@ -1,6 +1,6 @@
1
1
  import {z} from 'zod';
2
2
  import {spawn} from '@ryanatkn/belt/process.js';
3
- import {red} from '@ryanatkn/belt/styletext.js';
3
+ import {styleText as st} from 'node:util';
4
4
 
5
5
  import {Task_Error, type Task} from './task.js';
6
6
  import {git_check_clean_workspace} from './git.js';
@@ -78,7 +78,7 @@ export const task: Task<Args> = {
78
78
  if (workspace) {
79
79
  const error_message = await git_check_clean_workspace();
80
80
  if (error_message) {
81
- log.error(red('git status'));
81
+ log.error(st('red', 'git status'));
82
82
  await spawn('git', ['status']);
83
83
  throw new Task_Error(
84
84
  'Failed check for git_check_clean_workspace:' +
package/src/lib/cli.ts CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  } from '@ryanatkn/belt/process.js';
8
8
  import {join} from 'node:path';
9
9
  import {existsSync} from 'node:fs';
10
- import {fileURLToPath} from 'node:url';
10
+ import {fileURLToPath, type URL} from 'node:url';
11
11
  import type {Logger} from '@ryanatkn/belt/log.js';
12
12
 
13
13
  import {NODE_MODULES_DIRNAME} from './path_constants.js';
@@ -27,7 +27,7 @@ export type Cli =
27
27
  export const find_cli = (
28
28
  name: string,
29
29
  cwd: string | URL = process.cwd(),
30
- options?: SpawnOptions | undefined,
30
+ options?: SpawnOptions,
31
31
  ): Cli | null => {
32
32
  const final_cwd = typeof cwd === 'string' ? cwd : fileURLToPath(cwd);
33
33
  const local_id = join(final_cwd, NODE_MODULES_DIRNAME, `.bin/${name}`);
@@ -49,7 +49,7 @@ export const spawn_cli = async (
49
49
  name_or_cli: string | Cli,
50
50
  args: string[] = [],
51
51
  log?: Logger,
52
- options?: SpawnOptions | undefined,
52
+ options?: SpawnOptions,
53
53
  ): Promise<Spawn_Result | undefined> => {
54
54
  const cli = resolve_cli(name_or_cli, args, options?.cwd, log, options);
55
55
  if (!cli) return;
@@ -65,7 +65,7 @@ export const spawn_cli_process = (
65
65
  name_or_cli: string | Cli,
66
66
  args: string[] = [],
67
67
  log?: Logger,
68
- options?: SpawnOptions | undefined,
68
+ options?: SpawnOptions,
69
69
  ): Spawned_Process | undefined => {
70
70
  const cli = resolve_cli(name_or_cli, args, options?.cwd, log, options);
71
71
  if (!cli) return;
@@ -77,7 +77,7 @@ export const resolve_cli = (
77
77
  args: string[] = [],
78
78
  cwd: string | URL | undefined,
79
79
  log?: Logger,
80
- options?: SpawnOptions | undefined,
80
+ options?: SpawnOptions,
81
81
  ): Cli | undefined => {
82
82
  let final_cli;
83
83
  if (typeof name_or_cli === 'string') {
@@ -1,6 +1,6 @@
1
1
  import {spawn} from '@ryanatkn/belt/process.js';
2
2
  import {print_error} from '@ryanatkn/belt/print.js';
3
- import {green, red} from '@ryanatkn/belt/styletext.js';
3
+ import {styleText as st} from 'node:util';
4
4
  import {z} from 'zod';
5
5
  import {cp, mkdir, rm} from 'node:fs/promises';
6
6
  import {join, resolve} from 'node:path';
@@ -204,13 +204,18 @@ export const task: Task<Args> = {
204
204
  await invoke_task('build');
205
205
  }
206
206
  if (!existsSync(build_dir)) {
207
- log.error(red('directory to deploy does not exist after building:'), build_dir);
207
+ log.error(st('red', 'directory to deploy does not exist after building:'), build_dir);
208
208
  return;
209
209
  }
210
210
  } catch (err) {
211
- log.error(red('build failed'), 'but', green('no changes were made to git'), print_error(err));
211
+ log.error(
212
+ st('red', 'build failed'),
213
+ 'but',
214
+ st('green', 'no changes were made to git'),
215
+ print_error(err),
216
+ );
212
217
  if (dry) {
213
- log.info(red('dry deploy failed'));
218
+ log.info(st('red', 'dry deploy failed'));
214
219
  }
215
220
  throw new Task_Error(`Deploy safely canceled due to build failure. See the error above.`);
216
221
  }
@@ -224,7 +229,7 @@ export const task: Task<Args> = {
224
229
 
225
230
  // At this point, `dist/` is ready to be committed and deployed!
226
231
  if (dry) {
227
- log.info(green('dry deploy complete:'), 'files at', print_path(resolved_deploy_dir));
232
+ log.info(st('green', 'dry deploy complete:'), 'files at', print_path(resolved_deploy_dir));
228
233
  return;
229
234
  }
230
235
 
@@ -234,10 +239,10 @@ export const task: Task<Args> = {
234
239
  await spawn('git', ['commit', '-m', 'deployment'], target_spawn_options);
235
240
  await spawn('git', ['push', origin, target, '-f'], target_spawn_options); // force push because we may be resetting the branch, see the checks above to make this safer
236
241
  } catch (err) {
237
- log.error(red('updating git failed:'), print_error(err));
242
+ log.error(st('red', 'updating git failed:'), print_error(err));
238
243
  throw new Task_Error(`Deploy failed in a bad state: built but not pushed, see error above.`);
239
244
  }
240
245
 
241
- log.info(green('deployed')); // TODO log a different message if "Everything up-to-date"
246
+ log.info(st('green', 'deployed')); // TODO log a different message if "Everything up-to-date"
242
247
  },
243
248
  };
@@ -1,4 +1,4 @@
1
- import {yellow, red} from '@ryanatkn/belt/styletext.js';
1
+ import {styleText as st} from 'node:util';
2
2
  import type {Logger} from '@ryanatkn/belt/log.js';
3
3
  import type * as esbuild from 'esbuild';
4
4
 
@@ -6,10 +6,10 @@ import type {Parsed_Sveltekit_Config} from './sveltekit_config.js';
6
6
 
7
7
  export const print_build_result = (log: Logger, build_result: esbuild.BuildResult): void => {
8
8
  for (const error of build_result.errors) {
9
- log.error(red('esbuild error'), error);
9
+ log.error(st('red', 'esbuild error'), error);
10
10
  }
11
11
  for (const warning of build_result.warnings) {
12
- log.warn(yellow('esbuild warning'), warning);
12
+ log.warn(st('yellow', 'esbuild warning'), warning);
13
13
  }
14
14
  };
15
15
 
@@ -1,4 +1,4 @@
1
- import {red, green, gray} from '@ryanatkn/belt/styletext.js';
1
+ import {styleText as st} from 'node:util';
2
2
  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';
@@ -79,7 +79,8 @@ export const task: Task<Args> = {
79
79
  if (!analyzed.has_changed) continue;
80
80
  has_unexpected_changes = true;
81
81
  log.error(
82
- red(
82
+ st(
83
+ 'red',
83
84
  `Generated file ${print_path(analyzed.file.id)} via ${print_path(
84
85
  analyzed.file.origin_id,
85
86
  )} ${analyzed.is_new ? 'is new' : 'has changed'}.`,
@@ -106,18 +107,19 @@ export const task: Task<Args> = {
106
107
  const new_count = analyzed_gen_results.filter((r) => r.is_new).length;
107
108
  const changed_count = analyzed_gen_results.filter((r) => r.has_changed).length;
108
109
  const unchanged_count = analyzed_gen_results.filter((r) => !r.is_new && !r.has_changed).length;
109
- let log_result = green('gen results:');
110
- log_result += `\n\t${new_count} ` + gray('new');
111
- log_result += `\n\t${changed_count} ` + gray('changed');
112
- log_result += `\n\t${unchanged_count} ` + gray('unchanged');
110
+ let log_result = st('green', 'gen results:');
111
+ log_result += `\n\t${new_count} ` + st('gray', 'new');
112
+ log_result += `\n\t${changed_count} ` + st('gray', 'changed');
113
+ log_result += `\n\t${unchanged_count} ` + st('gray', 'unchanged');
113
114
  for (const result of gen_results.results) {
114
- log_result += `\n\t${result.ok ? green('✓') : red('🞩')} ${
115
+ log_result += `\n\t${result.ok ? st('green', '✓') : st('red', '🞩')} ${
115
116
  result.ok ? result.files.length : 0
116
- } ${gray('in')} ${print_ms(result.elapsed)} ${gray('←')} ${print_path(result.id)}`;
117
+ } ${st('gray', 'in')} ${print_ms(result.elapsed)} ${st('gray', '←')} ${print_path(result.id)}`;
117
118
  }
118
119
  log.info(log_result);
119
120
  log.info(
120
- green(
121
+ st(
122
+ 'green',
121
123
  `generated ${gen_results.output_count} file${plural(gen_results.output_count)} from ${
122
124
  gen_results.successes.length
123
125
  } input file${plural(gen_results.successes.length)}`,
package/src/lib/gen.ts CHANGED
@@ -4,7 +4,7 @@ import {mkdir, readFile, writeFile} from 'node:fs/promises';
4
4
  import {z} from 'zod';
5
5
  import type {Result} from '@ryanatkn/belt/result.js';
6
6
  import type {Timings} from '@ryanatkn/belt/timings.js';
7
- import {red} from '@ryanatkn/belt/styletext.js';
7
+ import {styleText as st} from 'node:util';
8
8
  import {existsSync} from 'node:fs';
9
9
 
10
10
  import {print_path} from './paths.js';
@@ -286,7 +286,7 @@ export const find_genfiles = (
286
286
  unmapped_input_paths,
287
287
  resolved_input_paths,
288
288
  reasons: unmapped_input_paths.map((input_path) =>
289
- red(`Input path ${print_path(input_path)} cannot be mapped to a file or directory.`),
289
+ st('red', `Input path ${print_path(input_path)} cannot be mapped to a file or directory.`),
290
290
  ),
291
291
  };
292
292
  }
@@ -312,7 +312,7 @@ export const find_genfiles = (
312
312
  resolved_input_files_by_root_dir,
313
313
  resolved_input_paths,
314
314
  reasons: input_directories_with_no_files.map((input_path) =>
315
- red(`Input directory contains no matching files: ${print_path(input_path)}`),
315
+ st('red', `Input directory contains no matching files: ${print_path(input_path)}`),
316
316
  ),
317
317
  };
318
318
  }
@@ -94,7 +94,7 @@ export const spawn_with_loader = (
94
94
  register("${loader_path}", pathToFileURL("./"));`,
95
95
  '--enable-source-maps', // because TypeScript
96
96
  ];
97
- // In almost all cases we want the exports condition to be `"development"`.
97
+ // In almost all cases we want the exports condition to be `"development"`. Needed for `esm-env`.
98
98
  if (process.env.NODE_ENV !== 'production') {
99
99
  args.push('-C', 'development'); // same as `--conditions`
100
100
  }
@@ -248,7 +248,12 @@ export const gro_plugin_server = ({
248
248
  }
249
249
 
250
250
  if (run || dev) {
251
- server_process = spawn_restartable_process(cli_command, [server_outpath]);
251
+ const cli_args = [];
252
+ if (dev) {
253
+ cli_args.push('-C', 'development'); // same as `--conditions`
254
+ }
255
+ cli_args.push(server_outpath);
256
+ server_process = spawn_restartable_process(cli_command, cli_args);
252
257
  }
253
258
  },
254
259
  teardown: async () => {
package/src/lib/invoke.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import {attach_process_error_handlers} from '@ryanatkn/belt/process.js';
2
+ import {configure_log_colors} from '@ryanatkn/belt/log.js';
3
+ import {styleText} from 'node:util';
2
4
 
3
5
  import {invoke_task} from './invoke_task.js';
4
6
  import {to_task_args} from './args.js';
@@ -22,6 +24,8 @@ attach_process_error_handlers(
22
24
  (err) => (err.constructor.name === 'Silent_Error' ? '' : null),
23
25
  );
24
26
 
27
+ configure_log_colors(styleText);
28
+
25
29
  await sveltekit_sync_if_obviously_needed();
26
30
 
27
31
  const {task_name, args} = to_task_args();
@@ -1,7 +1,7 @@
1
- import {cyan, red, gray} from '@ryanatkn/belt/styletext.js';
2
- import {System_Logger, print_log_label} from '@ryanatkn/belt/log.js';
1
+ import {styleText as st} from 'node:util';
2
+ import {System_Logger} from '@ryanatkn/belt/log.js';
3
3
  import {create_stopwatch, Timings} from '@ryanatkn/belt/timings.js';
4
- import {print_ms, print_timings} from '@ryanatkn/belt/print.js';
4
+ import {print_ms, print_timings, print_log_label} from '@ryanatkn/belt/print.js';
5
5
 
6
6
  import {to_forwarded_args, type Args} from './args.js';
7
7
  import {run_task} from './run_task.js';
@@ -40,7 +40,7 @@ export const invoke_task = async (
40
40
  initial_timings: Timings | null = null,
41
41
  ): Promise<void> => {
42
42
  const log = new System_Logger(print_log_label(task_name || 'gro'));
43
- log.info('invoking', task_name ? cyan(task_name) : 'gro');
43
+ log.info('invoking', task_name ? st('cyan', task_name) : 'gro');
44
44
 
45
45
  const timings = initial_timings ?? new Timings();
46
46
 
@@ -54,7 +54,7 @@ export const invoke_task = async (
54
54
  // Check if the caller just wants to see the version.
55
55
  if (!task_name && (args?.version || args?.v)) {
56
56
  const gro_package_json = load_gro_package_json();
57
- log.info(`${gray('v')}${cyan(gro_package_json.version)}`);
57
+ log.info(`${st('gray', 'v')}${st('cyan', gro_package_json.version)}`);
58
58
  finish();
59
59
  return;
60
60
  }
@@ -94,7 +94,9 @@ export const invoke_task = async (
94
94
  // The input path matches a file that's presumable a task, so load and run it.
95
95
  if (loaded_tasks.modules.length !== 1) throw Error('expected one loaded task'); // run only one task at a time
96
96
  const task = loaded_tasks.modules[0];
97
- log.info(`→ ${cyan(task.name)} ${(task.mod.task.summary && gray(task.mod.task.summary)) ?? ''}`);
97
+ log.info(
98
+ `→ ${st('cyan', task.name)} ${(task.mod.task.summary && st('gray', task.mod.task.summary)) ?? ''}`,
99
+ );
98
100
 
99
101
  const timing_to_run_task = timings.start('run task ' + task_name);
100
102
  const result = await run_task(
@@ -106,11 +108,11 @@ export const invoke_task = async (
106
108
  );
107
109
  timing_to_run_task();
108
110
  if (!result.ok) {
109
- log.info(`${red('🞩')} ${cyan(task.name)}`);
111
+ log.info(`${st('red', '🞩')} ${st('cyan', task.name)}`);
110
112
  log_error_reasons(log, [result.reason]);
111
113
  throw result.error;
112
114
  }
113
- log.info(`✓ ${cyan(task.name)}`);
115
+ log.info(`✓ ${st('cyan', task.name)}`);
114
116
 
115
117
  finish();
116
118
  };