@ryanatkn/gro 0.134.0 → 0.135.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +6 -2
- package/dist/changeset.task.js +3 -3
- package/dist/check.task.js +2 -2
- package/dist/deploy.task.d.ts +2 -2
- package/dist/deploy.task.d.ts.map +1 -1
- package/dist/deploy.task.js +7 -7
- package/dist/esbuild_helpers.js +3 -3
- package/dist/gen.js +3 -3
- package/dist/gen.task.d.ts.map +1 -1
- package/dist/gen.task.js +8 -8
- package/dist/gro_helpers.js +1 -1
- package/dist/invoke.js +3 -0
- package/dist/invoke_task.d.ts.map +1 -1
- package/dist/invoke_task.js +8 -8
- package/dist/package.js +15 -15
- package/dist/package_json.js +3 -3
- package/dist/paths.js +2 -2
- package/dist/publish.task.js +4 -4
- package/dist/resolve.task.js +3 -3
- package/dist/run.task.js +2 -2
- package/dist/run_gen.js +3 -3
- package/dist/run_task.d.ts.map +1 -1
- package/dist/run_task.js +6 -5
- package/dist/task.js +3 -3
- package/dist/task_logging.js +7 -7
- package/dist/test.task.js +2 -2
- package/dist/watch_dir.js +1 -1
- package/package.json +14 -14
- package/src/lib/args.ts +6 -2
- package/src/lib/changeset.task.ts +3 -3
- package/src/lib/check.task.ts +2 -2
- package/src/lib/deploy.task.ts +12 -7
- package/src/lib/esbuild_helpers.ts +3 -3
- package/src/lib/gen.task.ts +11 -9
- package/src/lib/gen.ts +3 -3
- package/src/lib/gro_helpers.ts +1 -1
- package/src/lib/invoke.ts +4 -0
- package/src/lib/invoke_task.ts +10 -8
- package/src/lib/package.ts +15 -15
- package/src/lib/package_json.ts +3 -3
- package/src/lib/paths.ts +2 -2
- package/src/lib/publish.task.ts +4 -4
- package/src/lib/resolve.task.ts +3 -3
- package/src/lib/run.task.ts +2 -2
- package/src/lib/run_gen.ts +3 -3
- package/src/lib/run_task.ts +8 -5
- package/src/lib/task.ts +3 -3
- package/src/lib/task_logging.ts +10 -10
- package/src/lib/test.task.ts +2 -2
- package/src/lib/watch_dir.ts +1 -1
package/dist/task_logging.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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${
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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' +
|
|
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 {
|
|
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(
|
|
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')]);
|
package/dist/watch_dir.js
CHANGED
|
@@ -4,7 +4,7 @@ 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
|
|
7
|
+
export const watch_dir = ({ dir, on_change, filter, absolute = true, chokidar, }) => {
|
|
8
8
|
let watcher;
|
|
9
9
|
return {
|
|
10
10
|
init: async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ryanatkn/gro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.135.1",
|
|
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.
|
|
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.
|
|
53
|
-
"chokidar": "^4.0.
|
|
52
|
+
"@ryanatkn/belt": "^0.25.0",
|
|
53
|
+
"chokidar": "^4.0.1",
|
|
54
54
|
"dotenv": "^16.4.5",
|
|
55
55
|
"es-module-lexer": "^1.5.4",
|
|
56
56
|
"esm-env": "^1.0.0",
|
|
@@ -69,21 +69,21 @@
|
|
|
69
69
|
"@changesets/changelog-git": "^0.2.0",
|
|
70
70
|
"@changesets/types": "^6.0.0",
|
|
71
71
|
"@ryanatkn/eslint-config": "^0.5.3",
|
|
72
|
-
"@ryanatkn/fuz": "^0.
|
|
73
|
-
"@ryanatkn/moss": "^0.
|
|
74
|
-
"@sveltejs/adapter-static": "^3.0.
|
|
75
|
-
"@sveltejs/kit": "^2.5.
|
|
76
|
-
"@sveltejs/package": "^2.3.
|
|
72
|
+
"@ryanatkn/fuz": "^0.124.4",
|
|
73
|
+
"@ryanatkn/moss": "^0.16.1",
|
|
74
|
+
"@sveltejs/adapter-static": "^3.0.5",
|
|
75
|
+
"@sveltejs/kit": "^2.5.28",
|
|
76
|
+
"@sveltejs/package": "^2.3.5",
|
|
77
77
|
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
|
78
78
|
"@types/fs-extra": "^11.0.4",
|
|
79
|
-
"@types/node": "^22.5.
|
|
79
|
+
"@types/node": "^22.5.5",
|
|
80
80
|
"esbuild": "^0.21.5",
|
|
81
|
-
"eslint": "^9.
|
|
82
|
-
"eslint-plugin-svelte": "^2.
|
|
83
|
-
"svelte": "^5.0.0-next.
|
|
81
|
+
"eslint": "^9.11.0",
|
|
82
|
+
"eslint-plugin-svelte": "^2.44.0",
|
|
83
|
+
"svelte": "^5.0.0-next.257",
|
|
84
84
|
"svelte-check": "^4.0.2",
|
|
85
85
|
"typescript": "^5.6.2",
|
|
86
|
-
"typescript-eslint": "^8.
|
|
86
|
+
"typescript-eslint": "^8.6.0",
|
|
87
87
|
"uvu": "^0.5.6"
|
|
88
88
|
},
|
|
89
89
|
"prettier": {
|
package/src/lib/args.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
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 {
|
|
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
|
|
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};
|
package/src/lib/check.task.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {z} from 'zod';
|
|
2
2
|
import {spawn} from '@ryanatkn/belt/process.js';
|
|
3
|
-
import {
|
|
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(
|
|
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/deploy.task.ts
CHANGED
|
@@ -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 {
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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 {
|
|
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(
|
|
9
|
+
log.error(st('red', 'esbuild error'), error);
|
|
10
10
|
}
|
|
11
11
|
for (const warning of build_result.warnings) {
|
|
12
|
-
log.warn(
|
|
12
|
+
log.warn(st('yellow', 'esbuild warning'), warning);
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
|
package/src/lib/gen.task.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
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 =
|
|
110
|
-
log_result += `\n\t${new_count} ` +
|
|
111
|
-
log_result += `\n\t${changed_count} ` +
|
|
112
|
-
log_result += `\n\t${unchanged_count} ` +
|
|
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 ?
|
|
115
|
+
log_result += `\n\t${result.ok ? st('green', '✓') : st('red', '🞩')} ${
|
|
115
116
|
result.ok ? result.files.length : 0
|
|
116
|
-
} ${
|
|
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
|
-
|
|
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 {
|
|
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
|
|
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
|
|
315
|
+
st('red', `Input directory contains no matching files: ${print_path(input_path)}`),
|
|
316
316
|
),
|
|
317
317
|
};
|
|
318
318
|
}
|
package/src/lib/gro_helpers.ts
CHANGED
|
@@ -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
|
}
|
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();
|
package/src/lib/invoke_task.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {System_Logger
|
|
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
|
|
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(`${
|
|
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(
|
|
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(`${
|
|
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
|
|
115
|
+
log.info(`✓ ${st('cyan', task.name)}`);
|
|
114
116
|
|
|
115
117
|
finish();
|
|
116
118
|
};
|
package/src/lib/package.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {Src_Json} from './src_json.js';
|
|
|
5
5
|
|
|
6
6
|
export const package_json = {
|
|
7
7
|
name: '@ryanatkn/gro',
|
|
8
|
-
version: '0.
|
|
8
|
+
version: '0.135.1',
|
|
9
9
|
description: 'task runner and toolkit extending SvelteKit',
|
|
10
10
|
motto: 'generate, run, optimize',
|
|
11
11
|
glyph: '🌰',
|
|
@@ -30,7 +30,7 @@ export const package_json = {
|
|
|
30
30
|
deploy: 'gro deploy',
|
|
31
31
|
},
|
|
32
32
|
type: 'module',
|
|
33
|
-
engines: {node: '>=20.
|
|
33
|
+
engines: {node: '>=20.17'},
|
|
34
34
|
bin: {gro: 'dist/gro.js'},
|
|
35
35
|
keywords: [
|
|
36
36
|
'web',
|
|
@@ -44,8 +44,8 @@ export const package_json = {
|
|
|
44
44
|
'typescript',
|
|
45
45
|
],
|
|
46
46
|
dependencies: {
|
|
47
|
-
'@ryanatkn/belt': '^0.
|
|
48
|
-
chokidar: '^4.0.
|
|
47
|
+
'@ryanatkn/belt': '^0.25.0',
|
|
48
|
+
chokidar: '^4.0.1',
|
|
49
49
|
dotenv: '^16.4.5',
|
|
50
50
|
'es-module-lexer': '^1.5.4',
|
|
51
51
|
'esm-env': '^1.0.0',
|
|
@@ -61,21 +61,21 @@ export const package_json = {
|
|
|
61
61
|
'@changesets/changelog-git': '^0.2.0',
|
|
62
62
|
'@changesets/types': '^6.0.0',
|
|
63
63
|
'@ryanatkn/eslint-config': '^0.5.3',
|
|
64
|
-
'@ryanatkn/fuz': '^0.
|
|
65
|
-
'@ryanatkn/moss': '^0.
|
|
66
|
-
'@sveltejs/adapter-static': '^3.0.
|
|
67
|
-
'@sveltejs/kit': '^2.5.
|
|
68
|
-
'@sveltejs/package': '^2.3.
|
|
64
|
+
'@ryanatkn/fuz': '^0.124.4',
|
|
65
|
+
'@ryanatkn/moss': '^0.16.1',
|
|
66
|
+
'@sveltejs/adapter-static': '^3.0.5',
|
|
67
|
+
'@sveltejs/kit': '^2.5.28',
|
|
68
|
+
'@sveltejs/package': '^2.3.5',
|
|
69
69
|
'@sveltejs/vite-plugin-svelte': '^3.1.2',
|
|
70
70
|
'@types/fs-extra': '^11.0.4',
|
|
71
|
-
'@types/node': '^22.5.
|
|
71
|
+
'@types/node': '^22.5.5',
|
|
72
72
|
esbuild: '^0.21.5',
|
|
73
|
-
eslint: '^9.
|
|
74
|
-
'eslint-plugin-svelte': '^2.
|
|
75
|
-
svelte: '^5.0.0-next.
|
|
73
|
+
eslint: '^9.11.0',
|
|
74
|
+
'eslint-plugin-svelte': '^2.44.0',
|
|
75
|
+
svelte: '^5.0.0-next.257',
|
|
76
76
|
'svelte-check': '^4.0.2',
|
|
77
77
|
typescript: '^5.6.2',
|
|
78
|
-
'typescript-eslint': '^8.
|
|
78
|
+
'typescript-eslint': '^8.6.0',
|
|
79
79
|
uvu: '^0.5.6',
|
|
80
80
|
},
|
|
81
81
|
prettier: {
|
|
@@ -268,7 +268,7 @@ export const package_json = {
|
|
|
268
268
|
|
|
269
269
|
export const src_json = {
|
|
270
270
|
name: '@ryanatkn/gro',
|
|
271
|
-
version: '0.
|
|
271
|
+
version: '0.135.1',
|
|
272
272
|
modules: {
|
|
273
273
|
'.': {
|
|
274
274
|
path: 'index.ts',
|
package/src/lib/package_json.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {readFileSync, writeFileSync} from 'node:fs';
|
|
|
4
4
|
import {count_graphemes, plural, strip_end} from '@ryanatkn/belt/string.js';
|
|
5
5
|
import type {Logger} from '@ryanatkn/belt/log.js';
|
|
6
6
|
import type {Flavored} from '@ryanatkn/belt/types.js';
|
|
7
|
-
import {
|
|
7
|
+
import {styleText as st} from 'node:util';
|
|
8
8
|
|
|
9
9
|
import {paths, gro_paths, IS_THIS_GRO, replace_extension} from './paths.js';
|
|
10
10
|
import {SVELTEKIT_DIST_DIRNAME} from './path_constants.js';
|
|
@@ -320,9 +320,9 @@ const parse_or_throw_formatted_error = <T extends z.ZodTypeAny>(
|
|
|
320
320
|
): z.infer<T> => {
|
|
321
321
|
const parsed = schema.safeParse(value);
|
|
322
322
|
if (!parsed.success) {
|
|
323
|
-
let msg = red
|
|
323
|
+
let msg = st('red', `Failed to parse ${name}:\n`);
|
|
324
324
|
for (const issue of parsed.error.issues) {
|
|
325
|
-
msg += red
|
|
325
|
+
msg += st('red', `\n\t"${issue.path}" ${issue.message}\n`);
|
|
326
326
|
}
|
|
327
327
|
throw Error(msg);
|
|
328
328
|
}
|
package/src/lib/paths.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {join, extname, relative, basename} from 'node:path';
|
|
2
2
|
import {fileURLToPath} from 'node:url';
|
|
3
3
|
import {strip_end} from '@ryanatkn/belt/string.js';
|
|
4
|
-
import {
|
|
4
|
+
import {styleText as st} from 'node:util';
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
GRO_CONFIG_PATH,
|
|
@@ -68,7 +68,7 @@ export const print_path = (path: string, p = infer_paths(path)): string => {
|
|
|
68
68
|
strip_end(path, '/') === strip_end(GRO_DIST_DIR, '/') ? 'gro' : to_root_path(path, p);
|
|
69
69
|
final_path =
|
|
70
70
|
final_path === 'gro' ? final_path : final_path[0] === '.' ? final_path : './' + final_path;
|
|
71
|
-
return gray
|
|
71
|
+
return st('gray', final_path);
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
export const replace_extension = (path: string, new_extension: string): string => {
|
package/src/lib/publish.task.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {spawn} from '@ryanatkn/belt/process.js';
|
|
2
2
|
import {z} from 'zod';
|
|
3
|
-
import {
|
|
3
|
+
import {styleText as st} from 'node:util';
|
|
4
4
|
import {existsSync} from 'node:fs';
|
|
5
5
|
|
|
6
6
|
import {Task_Error, type Task} from './task.js';
|
|
@@ -74,7 +74,7 @@ export const task: Task<Args> = {
|
|
|
74
74
|
changeset_cli,
|
|
75
75
|
} = args;
|
|
76
76
|
if (dry) {
|
|
77
|
-
log.info(
|
|
77
|
+
log.info(st('green', 'dry run!'));
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
const has_sveltekit_library_result = has_sveltekit_library();
|
|
@@ -181,7 +181,7 @@ export const task: Task<Args> = {
|
|
|
181
181
|
|
|
182
182
|
if (dry) {
|
|
183
183
|
log.info('publishing branch ' + branch);
|
|
184
|
-
log.info(
|
|
184
|
+
log.info(st('green', 'dry run complete!'));
|
|
185
185
|
return;
|
|
186
186
|
}
|
|
187
187
|
|
|
@@ -198,6 +198,6 @@ export const task: Task<Args> = {
|
|
|
198
198
|
await spawn('git', ['commit', '-a', '-m', `publish v${version}`]);
|
|
199
199
|
await spawn('git', ['push', '--follow-tags']);
|
|
200
200
|
|
|
201
|
-
log.info(green
|
|
201
|
+
log.info(st('green', `published to branch ${st('cyan', branch)}!`));
|
|
202
202
|
},
|
|
203
203
|
};
|
package/src/lib/resolve.task.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {z} from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import {styleText as st} from 'node:util';
|
|
3
3
|
|
|
4
4
|
import {TASK_FILE_SUFFIXES, type Task} from './task.js';
|
|
5
5
|
import {resolve_input_paths, to_input_paths} from './input_path.js';
|
|
@@ -33,11 +33,11 @@ export const task: Task<Args> = {
|
|
|
33
33
|
if (verbose) log.info('unmapped_input_paths:', unmapped_input_paths);
|
|
34
34
|
|
|
35
35
|
for (const p of resolved_input_paths) {
|
|
36
|
-
log.info('resolved:', green
|
|
36
|
+
log.info('resolved:', st('green', p.id));
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
if (!resolved_input_paths.length) {
|
|
40
|
-
log.warn(
|
|
40
|
+
log.warn(st('yellow', 'no input paths were resolved'));
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
};
|
package/src/lib/run.task.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {z} from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import {styleText as st} from 'node:util';
|
|
3
3
|
import {existsSync} from 'node:fs';
|
|
4
4
|
|
|
5
5
|
import {Task_Error, type Task} from './task.js';
|
|
@@ -23,7 +23,7 @@ export const task: Task<Args> = {
|
|
|
23
23
|
} = args;
|
|
24
24
|
|
|
25
25
|
if (!path) {
|
|
26
|
-
log.info(
|
|
26
|
+
log.info(st('green', '\n\nUsage: ') + st('cyan', 'gro run path/to/file.ts [...node_args]\n'));
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
|
package/src/lib/run_gen.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {styleText as st} from 'node:util';
|
|
2
2
|
import {print_error} from '@ryanatkn/belt/print.js';
|
|
3
3
|
import type {Timings} from '@ryanatkn/belt/timings.js';
|
|
4
4
|
import type {Logger} from '@ryanatkn/belt/log.js';
|
|
@@ -50,7 +50,7 @@ export const run_gen = async (
|
|
|
50
50
|
ok: false,
|
|
51
51
|
id,
|
|
52
52
|
error: err,
|
|
53
|
-
reason: red
|
|
53
|
+
reason: st('red', `Error generating ${print_path(id)}`),
|
|
54
54
|
elapsed: timing_for_module(),
|
|
55
55
|
};
|
|
56
56
|
}
|
|
@@ -67,7 +67,7 @@ export const run_gen = async (
|
|
|
67
67
|
return {...file, content: await format_file(file.content, {filepath: file.id})};
|
|
68
68
|
} catch (err) {
|
|
69
69
|
log.error(
|
|
70
|
-
red
|
|
70
|
+
st('red', `Error formatting ${print_path(file.id)} via ${print_path(id)}`),
|
|
71
71
|
print_error(err),
|
|
72
72
|
);
|
|
73
73
|
return file;
|