@ryanatkn/gro 0.116.1 → 0.117.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.d.ts +5 -0
- package/dist/config.js +9 -2
- package/dist/docs/config.md +25 -0
- package/dist/docs/task.md +38 -32
- package/dist/docs/tasks.gen.md.js +2 -2
- package/dist/gen.task.js +5 -6
- package/dist/gen_module.d.ts +2 -1
- package/dist/gen_module.js +1 -1
- package/dist/input_path.d.ts +27 -28
- package/dist/input_path.js +62 -66
- package/dist/input_path.test.js +23 -45
- package/dist/invoke_task.d.ts +1 -1
- package/dist/invoke_task.js +78 -87
- package/dist/modules.d.ts +13 -9
- package/dist/modules.js +5 -13
- package/dist/package.d.ts +11 -11
- package/dist/package.gen.js +3 -3
- package/dist/package.js +41 -38
- package/dist/package_json.js +3 -3
- package/dist/paths.d.ts +11 -10
- package/dist/paths.js +23 -39
- package/dist/publish.task.js +2 -2
- package/dist/run_task.js +2 -2
- package/dist/task.js +1 -0
- package/dist/task_logging.d.ts +8 -0
- package/dist/{print_task.js → task_logging.js} +33 -16
- package/dist/task_module.d.ts +3 -2
- package/dist/task_module.js +5 -6
- package/package.json +20 -20
- package/dist/print_task.d.ts +0 -4
package/dist/package.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// generated by src/lib/package.gen.ts
|
|
2
2
|
export const package_json = {
|
|
3
3
|
name: '@ryanatkn/gro',
|
|
4
|
-
version: '0.
|
|
4
|
+
version: '0.117.0',
|
|
5
5
|
description: 'task runner and toolkit extending SvelteKit',
|
|
6
6
|
motto: 'generate, run, optimize',
|
|
7
7
|
icon: '🌰',
|
|
@@ -39,11 +39,11 @@ export const package_json = {
|
|
|
39
39
|
'es-module-lexer': '^1.5.3',
|
|
40
40
|
kleur: '^4.1.5',
|
|
41
41
|
mri: '^1.2.0',
|
|
42
|
-
prettier: '^3.2
|
|
43
|
-
'prettier-plugin-svelte': '^3.2.
|
|
42
|
+
prettier: '^3.3.2',
|
|
43
|
+
'prettier-plugin-svelte': '^3.2.4',
|
|
44
44
|
'tiny-glob': '^0.2.9',
|
|
45
45
|
'ts-morph': '^22.0.0',
|
|
46
|
-
tslib: '^2.6.
|
|
46
|
+
tslib: '^2.6.3',
|
|
47
47
|
zod: '^3.23.8',
|
|
48
48
|
},
|
|
49
49
|
peerDependencies: { esbuild: '^0.20', svelte: '^5.0.0-next.0' },
|
|
@@ -51,21 +51,21 @@ export const package_json = {
|
|
|
51
51
|
'@changesets/changelog-git': '^0.2.0',
|
|
52
52
|
'@changesets/types': '^6.0.0',
|
|
53
53
|
'@ryanatkn/eslint-config': '^0.1.2',
|
|
54
|
-
'@ryanatkn/fuz': '^0.
|
|
55
|
-
'@ryanatkn/moss': '^0.
|
|
56
|
-
'@sveltejs/adapter-static': '^3.0.
|
|
57
|
-
'@sveltejs/kit': '^2.5.
|
|
58
|
-
'@sveltejs/package': '^2.3.
|
|
59
|
-
'@sveltejs/vite-plugin-svelte': '^3.1.
|
|
54
|
+
'@ryanatkn/fuz': '^0.102.1',
|
|
55
|
+
'@ryanatkn/moss': '^0.4.0',
|
|
56
|
+
'@sveltejs/adapter-static': '^3.0.2',
|
|
57
|
+
'@sveltejs/kit': '^2.5.13',
|
|
58
|
+
'@sveltejs/package': '^2.3.2',
|
|
59
|
+
'@sveltejs/vite-plugin-svelte': '^3.1.1',
|
|
60
60
|
'@types/fs-extra': '^11.0.4',
|
|
61
|
-
'@types/node': '^20.
|
|
62
|
-
'@typescript-eslint/eslint-plugin': '^7.
|
|
63
|
-
'@typescript-eslint/parser': '^7.
|
|
61
|
+
'@types/node': '^20.14.2',
|
|
62
|
+
'@typescript-eslint/eslint-plugin': '^7.13.0',
|
|
63
|
+
'@typescript-eslint/parser': '^7.13.0',
|
|
64
64
|
esbuild: '^0.20.2',
|
|
65
65
|
eslint: '^8.57.0',
|
|
66
|
-
'eslint-plugin-svelte': '^2.39.
|
|
67
|
-
svelte: '^5.0.0-next.
|
|
68
|
-
'svelte-check': '^3.
|
|
66
|
+
'eslint-plugin-svelte': '^2.39.3',
|
|
67
|
+
svelte: '^5.0.0-next.155',
|
|
68
|
+
'svelte-check': '^3.8.0',
|
|
69
69
|
typescript: '^5.4.5',
|
|
70
70
|
uvu: '^0.5.6',
|
|
71
71
|
},
|
|
@@ -174,7 +174,6 @@ export const package_json = {
|
|
|
174
174
|
'./path.js': { default: './dist/path.js', types: './dist/path.d.ts' },
|
|
175
175
|
'./paths.js': { default: './dist/paths.js', types: './dist/paths.d.ts' },
|
|
176
176
|
'./plugin.js': { default: './dist/plugin.js', types: './dist/plugin.d.ts' },
|
|
177
|
-
'./print_task.js': { default: './dist/print_task.js', types: './dist/print_task.d.ts' },
|
|
178
177
|
'./publish.task.js': { default: './dist/publish.task.js', types: './dist/publish.task.d.ts' },
|
|
179
178
|
'./release.task.js': { default: './dist/release.task.js', types: './dist/release.task.d.ts' },
|
|
180
179
|
'./resolve_node_specifier.js': {
|
|
@@ -227,6 +226,7 @@ export const package_json = {
|
|
|
227
226
|
types: './dist/sveltekit_shim_env.d.ts',
|
|
228
227
|
},
|
|
229
228
|
'./sync.task.js': { default: './dist/sync.task.js', types: './dist/sync.task.d.ts' },
|
|
229
|
+
'./task_logging.js': { default: './dist/task_logging.js', types: './dist/task_logging.d.ts' },
|
|
230
230
|
'./task_module.js': { default: './dist/task_module.js', types: './dist/task_module.d.ts' },
|
|
231
231
|
'./task.js': { default: './dist/task.js', types: './dist/task.d.ts' },
|
|
232
232
|
'./test.task.js': { default: './dist/test.task.js', types: './dist/test.task.d.ts' },
|
|
@@ -241,7 +241,7 @@ export const package_json = {
|
|
|
241
241
|
};
|
|
242
242
|
export const src_json = {
|
|
243
243
|
name: '@ryanatkn/gro',
|
|
244
|
-
version: '0.
|
|
244
|
+
version: '0.117.0',
|
|
245
245
|
modules: {
|
|
246
246
|
'.': {
|
|
247
247
|
path: 'index.ts',
|
|
@@ -553,11 +553,14 @@ export const src_json = {
|
|
|
553
553
|
'./input_path.js': {
|
|
554
554
|
path: 'input_path.ts',
|
|
555
555
|
declarations: [
|
|
556
|
-
{ name: '
|
|
557
|
-
{ name: '
|
|
556
|
+
{ name: 'Input_Path', kind: 'variable' },
|
|
557
|
+
{ name: 'Raw_Input_Path', kind: 'variable' },
|
|
558
|
+
{ name: 'to_input_path', kind: 'function' },
|
|
559
|
+
{ name: 'to_input_paths', kind: 'function' },
|
|
558
560
|
{ name: 'get_possible_source_ids', kind: 'function' },
|
|
559
561
|
{ name: 'load_source_path_data_by_input_path', kind: 'function' },
|
|
560
562
|
{ name: 'load_source_ids_by_input_path', kind: 'function' },
|
|
563
|
+
{ name: 'to_gro_input_path', kind: 'function' },
|
|
561
564
|
],
|
|
562
565
|
},
|
|
563
566
|
'./invoke_task.js': {
|
|
@@ -635,11 +638,14 @@ export const src_json = {
|
|
|
635
638
|
'./path.js': {
|
|
636
639
|
path: 'path.ts',
|
|
637
640
|
declarations: [
|
|
638
|
-
{ name: '
|
|
639
|
-
{ name: '
|
|
641
|
+
{ name: 'Input_Path', kind: 'variable' },
|
|
642
|
+
{ name: 'Raw_Input_Path', kind: 'variable' },
|
|
643
|
+
{ name: 'to_input_path', kind: 'function' },
|
|
644
|
+
{ name: 'to_input_paths', kind: 'function' },
|
|
640
645
|
{ name: 'get_possible_source_ids', kind: 'function' },
|
|
641
646
|
{ name: 'load_source_path_data_by_input_path', kind: 'function' },
|
|
642
647
|
{ name: 'load_source_ids_by_input_path', kind: 'function' },
|
|
648
|
+
{ name: 'to_gro_input_path', kind: 'function' },
|
|
643
649
|
],
|
|
644
650
|
},
|
|
645
651
|
'./paths.js': {
|
|
@@ -670,28 +676,24 @@ export const src_json = {
|
|
|
670
676
|
{ name: 'GIT_DIRNAME', kind: 'variable' },
|
|
671
677
|
{ name: 'TSCONFIG_FILENAME', kind: 'variable' },
|
|
672
678
|
{ name: 'Paths', kind: 'type' },
|
|
679
|
+
{ name: 'Source_Id', kind: 'variable' },
|
|
673
680
|
{ name: 'Url', kind: 'variable' },
|
|
674
681
|
{ name: 'Email', kind: 'variable' },
|
|
675
|
-
{ name: 'Source_Id', kind: 'variable' },
|
|
676
|
-
{ name: 'Build_Id', kind: 'variable' },
|
|
677
682
|
{ name: 'create_paths', kind: 'function' },
|
|
678
683
|
{ name: 'paths_from_id', kind: 'function' },
|
|
679
684
|
{ name: 'is_gro_id', kind: 'function' },
|
|
680
685
|
{ name: 'to_root_path', kind: 'function' },
|
|
681
686
|
{ name: 'source_id_to_base_path', kind: 'function' },
|
|
682
687
|
{ name: 'base_path_to_source_id', kind: 'function' },
|
|
683
|
-
{ name: 'lib_path_to_import_id', kind: 'function' },
|
|
684
688
|
{ name: 'import_id_to_lib_path', kind: 'function' },
|
|
685
|
-
{ name: 'to_gro_input_path', kind: 'function' },
|
|
686
|
-
{ name: 'replace_root_dir', kind: 'function' },
|
|
687
689
|
{ name: 'print_path', kind: 'function' },
|
|
688
690
|
{ name: 'print_path_or_gro_path', kind: 'function' },
|
|
689
691
|
{ name: 'replace_extension', kind: 'function' },
|
|
690
|
-
{ name: 'gro_dir_basename', kind: 'variable' },
|
|
691
692
|
{ name: 'paths', kind: 'variable' },
|
|
692
|
-
{ name: '
|
|
693
|
+
{ name: 'GRO_PACKAGE_DIR', kind: 'variable' },
|
|
694
|
+
{ name: 'IS_THIS_GRO', kind: 'variable' },
|
|
693
695
|
{ name: 'gro_paths', kind: 'variable' },
|
|
694
|
-
{ name: '
|
|
696
|
+
{ name: 'GRO_DIST_DIR', kind: 'variable' },
|
|
695
697
|
],
|
|
696
698
|
},
|
|
697
699
|
'./plugin.js': {
|
|
@@ -704,14 +706,6 @@ export const src_json = {
|
|
|
704
706
|
{ name: 'replace_plugin', kind: 'function' },
|
|
705
707
|
],
|
|
706
708
|
},
|
|
707
|
-
'./print_task.js': {
|
|
708
|
-
path: 'print_task.ts',
|
|
709
|
-
declarations: [
|
|
710
|
-
{ name: 'log_available_tasks', kind: 'function' },
|
|
711
|
-
{ name: 'log_error_reasons', kind: 'function' },
|
|
712
|
-
{ name: 'print_task_help', kind: 'function' },
|
|
713
|
-
],
|
|
714
|
-
},
|
|
715
709
|
'./publish.task.js': {
|
|
716
710
|
path: 'publish.task.ts',
|
|
717
711
|
declarations: [
|
|
@@ -867,6 +861,15 @@ export const src_json = {
|
|
|
867
861
|
{ name: 'sveltekit_sync', kind: 'function' },
|
|
868
862
|
],
|
|
869
863
|
},
|
|
864
|
+
'./task_logging.js': {
|
|
865
|
+
path: 'task_logging.ts',
|
|
866
|
+
declarations: [
|
|
867
|
+
{ name: 'log_tasks', kind: 'function' },
|
|
868
|
+
{ name: 'log_gro_package_tasks', kind: 'function' },
|
|
869
|
+
{ name: 'log_error_reasons', kind: 'function' },
|
|
870
|
+
{ name: 'log_task_help', kind: 'function' },
|
|
871
|
+
],
|
|
872
|
+
},
|
|
870
873
|
'./task_module.js': { path: 'task_module.ts', declarations: [] },
|
|
871
874
|
'./task.js': {
|
|
872
875
|
path: 'task.ts',
|
package/dist/package_json.js
CHANGED
|
@@ -3,7 +3,7 @@ import { join } from 'node:path';
|
|
|
3
3
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
4
4
|
import { plural } from '@ryanatkn/belt/string.js';
|
|
5
5
|
import { strip_end } from '@ryanatkn/belt/string.js';
|
|
6
|
-
import { paths, gro_paths,
|
|
6
|
+
import { paths, gro_paths, IS_THIS_GRO, replace_extension, SVELTEKIT_DIST_DIRNAME, Url, Email, } from './paths.js';
|
|
7
7
|
import { search_fs } from './search_fs.js';
|
|
8
8
|
import { has_sveltekit_library } from './gro_plugin_sveltekit_library.js';
|
|
9
9
|
// TODO move this where?
|
|
@@ -88,7 +88,7 @@ export const Package_Json = z.intersection(z.record(z.unknown()), z
|
|
|
88
88
|
})
|
|
89
89
|
.passthrough());
|
|
90
90
|
export const EMPTY_PACKAGE_JSON = { name: '', version: '' };
|
|
91
|
-
export const load_package_json = async (dir =
|
|
91
|
+
export const load_package_json = async (dir = IS_THIS_GRO ? gro_paths.root : paths.root, cache) => {
|
|
92
92
|
let package_json;
|
|
93
93
|
if (cache && dir in cache) {
|
|
94
94
|
return cache[dir];
|
|
@@ -97,7 +97,7 @@ export const load_package_json = async (dir = is_this_project_gro ? gro_paths.ro
|
|
|
97
97
|
package_json = JSON.parse(await load_package_json_contents(dir));
|
|
98
98
|
}
|
|
99
99
|
catch (err) {
|
|
100
|
-
|
|
100
|
+
return EMPTY_PACKAGE_JSON;
|
|
101
101
|
}
|
|
102
102
|
if (cache)
|
|
103
103
|
cache[dir] = package_json;
|
package/dist/paths.d.ts
CHANGED
|
@@ -32,29 +32,30 @@ export interface Paths {
|
|
|
32
32
|
build_dev: string;
|
|
33
33
|
config: string;
|
|
34
34
|
}
|
|
35
|
+
export declare const Source_Id: z.ZodString;
|
|
36
|
+
export type Source_Id = Flavored<z.infer<typeof Source_Id>, 'Source_Id'>;
|
|
35
37
|
export declare const Url: z.ZodString;
|
|
36
38
|
export type Url = Flavored<z.infer<typeof Url>, 'Url'>;
|
|
37
39
|
export declare const Email: z.ZodString;
|
|
38
40
|
export type Email = Flavored<z.infer<typeof Email>, 'Email'>;
|
|
39
|
-
export declare const Source_Id: z.ZodString;
|
|
40
|
-
export type Source_Id = Flavored<z.infer<typeof Source_Id>, 'Source_Id'>;
|
|
41
|
-
export declare const Build_Id: z.ZodString;
|
|
42
|
-
export type Build_Id = Flavored<z.infer<typeof Build_Id>, 'Build_Id'>;
|
|
43
41
|
export declare const create_paths: (root_dir: string) => Paths;
|
|
44
42
|
export declare const paths_from_id: (id: string) => Paths;
|
|
45
43
|
export declare const is_gro_id: (id: string) => boolean;
|
|
46
44
|
export declare const to_root_path: (id: string, p?: Paths) => string;
|
|
47
45
|
export declare const source_id_to_base_path: (source_id: Flavored<string, "Source_Id">, p?: Paths) => string;
|
|
48
46
|
export declare const base_path_to_source_id: (base_path: string, p?: Paths) => Flavored<string, "Source_Id">;
|
|
49
|
-
export declare const lib_path_to_import_id: (base_path: string, p?: Paths) => Flavored<string, "Source_Id">;
|
|
50
47
|
export declare const import_id_to_lib_path: (import_id: string, p?: Paths) => string;
|
|
51
|
-
export declare const to_gro_input_path: (input_path: string) => string;
|
|
52
|
-
export declare const replace_root_dir: (id: string, root_dir: string, p?: Paths) => string;
|
|
53
48
|
export declare const print_path: (path: string, p?: Paths, prefix?: string) => string;
|
|
54
49
|
export declare const print_path_or_gro_path: (path: string, from_paths?: Paths) => string;
|
|
55
50
|
export declare const replace_extension: (path: string, new_extension: string) => string;
|
|
56
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Paths for the user repo.
|
|
53
|
+
*/
|
|
57
54
|
export declare const paths: Paths;
|
|
58
|
-
export declare const
|
|
55
|
+
export declare const GRO_PACKAGE_DIR = "gro/";
|
|
56
|
+
export declare const IS_THIS_GRO: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Paths for the Gro package being used by the user repo.
|
|
59
|
+
*/
|
|
59
60
|
export declare const gro_paths: Paths;
|
|
60
|
-
export declare const
|
|
61
|
+
export declare const GRO_DIST_DIR: string;
|
package/dist/paths.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { join,
|
|
1
|
+
import { join, extname, relative } from 'node:path';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import { strip_end, strip_start } from '@ryanatkn/belt/string.js';
|
|
4
4
|
import { gray } from 'kleur/colors';
|
|
@@ -6,15 +6,7 @@ import { z } from 'zod';
|
|
|
6
6
|
/*
|
|
7
7
|
|
|
8
8
|
A path `id` is an absolute path to the source/.gro/dist directory.
|
|
9
|
-
It's the same
|
|
10
|
-
|
|
11
|
-
A `base_path` is the format used by `CheapWatch`.
|
|
12
|
-
It's a bare relative path without a source or .gro directory,
|
|
13
|
-
e.g. 'foo/bar.ts'.
|
|
14
|
-
|
|
15
|
-
`CheapWatch` also uses an array of `path_parts`.
|
|
16
|
-
For path './foo/bar/baz.ts',
|
|
17
|
-
the `path_parts` are `['foo', 'foo/bar', 'foo/bar/baz.ts']`.
|
|
9
|
+
It's the same name that Rollup uses.
|
|
18
10
|
|
|
19
11
|
*/
|
|
20
12
|
// TODO pass these to `create_paths` and override from gro config
|
|
@@ -43,11 +35,12 @@ export const SVELTEKIT_VITE_CACHE_PATH = NODE_MODULES_DIRNAME + '/.vite';
|
|
|
43
35
|
export const GITHUB_DIRNAME = '.github';
|
|
44
36
|
export const GIT_DIRNAME = '.git';
|
|
45
37
|
export const TSCONFIG_FILENAME = 'tsconfig.json';
|
|
46
|
-
// TODO
|
|
38
|
+
// TODO Flavored doesn't work when used in schemas, use Zod brand instead? problem is ergonomics
|
|
39
|
+
export const Source_Id = z.string();
|
|
40
|
+
// TODO @multiple belongs elsewhere
|
|
47
41
|
export const Url = z.string();
|
|
42
|
+
// TODO @multiple belongs elsewhere
|
|
48
43
|
export const Email = z.string();
|
|
49
|
-
export const Source_Id = z.string();
|
|
50
|
-
export const Build_Id = z.string();
|
|
51
44
|
export const create_paths = (root_dir) => {
|
|
52
45
|
// TODO remove reliance on trailing slash towards windows support
|
|
53
46
|
const root = strip_end(root_dir, '/') + '/';
|
|
@@ -70,38 +63,21 @@ export const source_id_to_base_path = (source_id, p = paths) => relative(p.sourc
|
|
|
70
63
|
// TODO base_path is an obsolete concept, it was a remnant from forcing `src/`
|
|
71
64
|
// 'foo/bar/baz.ts' → '/home/me/app/src/foo/bar/baz.ts'
|
|
72
65
|
export const base_path_to_source_id = (base_path, p = paths) => join(p.source, base_path);
|
|
73
|
-
// To run Gro's tasks from its own project, we resolve from dist/ instead of src/.
|
|
74
|
-
// 'foo/bar/baz.ts' → '/home/me/app/src/lib/foo/bar/baz.ts'
|
|
75
|
-
// 'foo/bar/baz.ts' → '/home/me/app/dist/foo/bar/baz.ts'
|
|
76
|
-
export const lib_path_to_import_id = (base_path, p = paths) => {
|
|
77
|
-
if (p.root === gro_paths.root) {
|
|
78
|
-
return p.root + 'dist/' + base_path;
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
return base_path_to_source_id(LIB_DIRNAME + '/' + base_path, p);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
66
|
// An `import_id` can be a source_id in a project,
|
|
85
67
|
// or a Gro source_id when running inside Gro,
|
|
86
68
|
// or a `gro/dist/` file id in node_modules when inside another project.
|
|
87
69
|
export const import_id_to_lib_path = (import_id, p = paths_from_id(import_id)) => {
|
|
88
70
|
if (p.root === gro_paths.root) {
|
|
89
|
-
const stripped = strip_start(strip_start(import_id, p.lib),
|
|
90
|
-
const lib_path =
|
|
71
|
+
const stripped = strip_start(strip_start(import_id, p.lib), GRO_DIST_DIR); // TODO hacky, needs more work to clarify related things
|
|
72
|
+
const lib_path = IS_THIS_GRO ? stripped : replace_extension(stripped, '.ts');
|
|
91
73
|
return lib_path;
|
|
92
74
|
}
|
|
93
75
|
else {
|
|
94
76
|
return strip_start(import_id, p.lib);
|
|
95
77
|
}
|
|
96
78
|
};
|
|
97
|
-
export const to_gro_input_path = (input_path) => {
|
|
98
|
-
const base_path = input_path === paths.lib.slice(0, -1) ? '' : strip_start(input_path, paths.lib);
|
|
99
|
-
return gro_sveltekit_dist_dir + base_path;
|
|
100
|
-
};
|
|
101
|
-
// Can be used to map a source id from e.g. the cwd to gro's.
|
|
102
|
-
export const replace_root_dir = (id, root_dir, p = paths) => join(root_dir, to_root_path(id, p));
|
|
103
79
|
export const print_path = (path, p = paths, prefix = './') => {
|
|
104
|
-
const root_path = path ===
|
|
80
|
+
const root_path = path === GRO_DIST_DIR ? 'gro' : to_root_path(path, p);
|
|
105
81
|
return gray(`${prefix}${root_path}`);
|
|
106
82
|
};
|
|
107
83
|
export const print_path_or_gro_path = (path, from_paths = paths) => {
|
|
@@ -115,14 +91,22 @@ export const replace_extension = (path, new_extension) => {
|
|
|
115
91
|
const { length } = extname(path);
|
|
116
92
|
return (length === 0 ? path : path.substring(0, path.length - length)) + new_extension;
|
|
117
93
|
};
|
|
94
|
+
/**
|
|
95
|
+
* Paths for the user repo.
|
|
96
|
+
*/
|
|
97
|
+
export const paths = create_paths(process.cwd() + '/');
|
|
98
|
+
export const GRO_PACKAGE_DIR = 'gro/';
|
|
99
|
+
// TODO document these conditions with comments
|
|
100
|
+
// TODO there's probably a more robust way to do this
|
|
118
101
|
const filename = fileURLToPath(import.meta.url);
|
|
119
|
-
const
|
|
102
|
+
const gro_package_dir_path = join(filename, filename.includes('/gro/src/lib/')
|
|
120
103
|
? '../../../'
|
|
121
104
|
: filename.includes('/gro/dist/')
|
|
122
105
|
? '../../'
|
|
123
106
|
: '../');
|
|
124
|
-
export const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
export const
|
|
107
|
+
export const IS_THIS_GRO = gro_package_dir_path === paths.root;
|
|
108
|
+
/**
|
|
109
|
+
* Paths for the Gro package being used by the user repo.
|
|
110
|
+
*/
|
|
111
|
+
export const gro_paths = IS_THIS_GRO ? paths : create_paths(gro_package_dir_path);
|
|
112
|
+
export const GRO_DIST_DIR = gro_paths.root + SVELTEKIT_DIST_DIRNAME + '/';
|
package/dist/publish.task.js
CHANGED
|
@@ -5,7 +5,7 @@ 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 {
|
|
8
|
+
import { IS_THIS_GRO } from './paths.js';
|
|
9
9
|
import { has_sveltekit_library } from './gro_plugin_sveltekit_library.js';
|
|
10
10
|
import { update_changelog } from './changelog.js';
|
|
11
11
|
import { load_from_env } from './env.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 (
|
|
58
|
+
if (IS_THIS_GRO) {
|
|
59
59
|
await spawn('npm', ['run', 'build']);
|
|
60
60
|
}
|
|
61
61
|
const changelog_exists = await exists(changelog);
|
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 {
|
|
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
|
-
|
|
10
|
+
log_task_help(log, task_meta);
|
|
11
11
|
return { ok: true, output: null };
|
|
12
12
|
}
|
|
13
13
|
// Parse and validate args.
|
package/dist/task.js
CHANGED
|
@@ -3,6 +3,7 @@ import { import_id_to_lib_path } from './paths.js';
|
|
|
3
3
|
export const TASK_FILE_SUFFIX_TS = '.task.ts';
|
|
4
4
|
export const TASK_FILE_SUFFIX_JS = '.task.js';
|
|
5
5
|
export const is_task_path = (path) => path.endsWith(TASK_FILE_SUFFIX_TS) || path.endsWith(TASK_FILE_SUFFIX_JS);
|
|
6
|
+
// TODO use task root paths? what's the right behavior?
|
|
6
7
|
export const to_task_name = (id) => {
|
|
7
8
|
const lib_path = import_id_to_lib_path(id);
|
|
8
9
|
const name = strip_end(strip_end(lib_path, TASK_FILE_SUFFIX_TS), TASK_FILE_SUFFIX_JS);
|
|
@@ -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[]>, log_intro?: boolean) => Promise<void>;
|
|
6
|
+
export declare const log_gro_package_tasks: (input_path: Flavored<string, "Input_Path">, 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
|
-
|
|
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, 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
|
|
14
|
+
// Load all of the tasks so we can log their summary, and args for the `--help` flag.
|
|
11
15
|
const load_modules_result = await load_modules(source_ids_by_input_path, load_task_module);
|
|
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
|
|
17
|
-
`${
|
|
20
|
+
const logged = [
|
|
21
|
+
`${log_intro ? '\n\n' : ''}${source_ids.length} task${plural(source_ids.length)} in ${dir_label}:\n`,
|
|
18
22
|
];
|
|
19
|
-
if (
|
|
20
|
-
|
|
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
|
-
|
|
28
|
+
logged.push('\n' + cyan(pad(meta.name, longest_task_name)), ' ', meta.mod.task.summary || '');
|
|
25
29
|
}
|
|
26
|
-
log[
|
|
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, 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);
|
|
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
|
|
52
|
+
export const log_task_help = (log, meta) => {
|
|
39
53
|
const { name, mod: { task }, } = meta;
|
|
40
|
-
const
|
|
41
|
-
|
|
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
|
-
|
|
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
|
-
|
|
67
|
+
logged.push('\n' + gray('this task has no args'));
|
|
54
68
|
}
|
|
55
69
|
}
|
|
56
|
-
log.info(...
|
|
70
|
+
log.info(...logged, '\n');
|
|
57
71
|
};
|
|
58
72
|
const to_arg_properties = (def, meta) => {
|
|
59
73
|
const type_name = to_type_name(def);
|
|
@@ -97,7 +111,10 @@ const to_args_schema_type = ({ _def }) => {
|
|
|
97
111
|
case ZodFirstPartyTypeKind.ZodUnion:
|
|
98
112
|
return 'string | string[]'; // TODO support unions of arbitrary types, or more hardcoded ones as needed
|
|
99
113
|
default: {
|
|
100
|
-
if ('
|
|
114
|
+
if ('type' in _def) {
|
|
115
|
+
return to_args_schema_type(_def.type);
|
|
116
|
+
}
|
|
117
|
+
else if ('innerType' in _def) {
|
|
101
118
|
return to_args_schema_type(_def.innerType);
|
|
102
119
|
}
|
|
103
120
|
else {
|
package/dist/task_module.d.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -8,7 +9,7 @@ export interface Task_Module_Meta extends Module_Meta<Task_Module> {
|
|
|
8
9
|
}
|
|
9
10
|
export declare const validate_task_module: (mod: Record<string, any>) => mod is Task_Module;
|
|
10
11
|
export declare const load_task_module: (id: string) => Promise<Load_Module_Result<Task_Module_Meta>>;
|
|
11
|
-
export declare const find_task_modules: (input_paths
|
|
12
|
-
export declare const load_task_modules: (input_paths
|
|
12
|
+
export declare const find_task_modules: (input_paths: Input_Path[], root_dirs?: string[]) => Promise<ReturnType<typeof find_modules>>;
|
|
13
|
+
export declare const load_task_modules: (input_paths: Input_Path[], root_dirs?: string[]) => Promise<ReturnType<typeof load_modules<Task_Module, Task_Module_Meta>> | ({
|
|
13
14
|
ok: false;
|
|
14
15
|
} & Find_Modules_Failure)>;
|
package/dist/task_module.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
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
6
|
export const load_task_module = async (id) => {
|
|
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) } }; // TODO this task name needs to use task root paths or cwd
|
|
12
11
|
};
|
|
13
|
-
export const find_task_modules = async (input_paths
|
|
14
|
-
export const load_task_modules = async (input_paths,
|
|
15
|
-
const find_modules_result = await find_task_modules(input_paths,
|
|
12
|
+
export const find_task_modules = async (input_paths, root_dirs) => 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], root_dirs));
|
|
13
|
+
export const load_task_modules = async (input_paths, root_dirs) => {
|
|
14
|
+
const find_modules_result = await find_task_modules(input_paths, root_dirs);
|
|
16
15
|
if (!find_modules_result.ok)
|
|
17
16
|
return find_modules_result;
|
|
18
17
|
return load_modules(find_modules_result.source_ids_by_input_path, load_task_module);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ryanatkn/gro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.117.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
|
|
55
|
-
"prettier-plugin-svelte": "^3.2.
|
|
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.
|
|
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.
|
|
70
|
-
"@ryanatkn/moss": "^0.
|
|
71
|
-
"@sveltejs/adapter-static": "^3.0.
|
|
72
|
-
"@sveltejs/kit": "^2.5.
|
|
73
|
-
"@sveltejs/package": "^2.3.
|
|
74
|
-
"@sveltejs/vite-plugin-svelte": "^3.1.
|
|
69
|
+
"@ryanatkn/fuz": "^0.102.1",
|
|
70
|
+
"@ryanatkn/moss": "^0.4.0",
|
|
71
|
+
"@sveltejs/adapter-static": "^3.0.2",
|
|
72
|
+
"@sveltejs/kit": "^2.5.13",
|
|
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.
|
|
77
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
78
|
-
"@typescript-eslint/parser": "^7.
|
|
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.
|
|
82
|
-
"svelte": "^5.0.0-next.
|
|
83
|
-
"svelte-check": "^3.
|
|
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
|
},
|
|
@@ -318,10 +318,6 @@
|
|
|
318
318
|
"default": "./dist/plugin.js",
|
|
319
319
|
"types": "./dist/plugin.d.ts"
|
|
320
320
|
},
|
|
321
|
-
"./print_task.js": {
|
|
322
|
-
"default": "./dist/print_task.js",
|
|
323
|
-
"types": "./dist/print_task.d.ts"
|
|
324
|
-
},
|
|
325
321
|
"./publish.task.js": {
|
|
326
322
|
"default": "./dist/publish.task.js",
|
|
327
323
|
"types": "./dist/publish.task.d.ts"
|
|
@@ -398,6 +394,10 @@
|
|
|
398
394
|
"default": "./dist/sync.task.js",
|
|
399
395
|
"types": "./dist/sync.task.d.ts"
|
|
400
396
|
},
|
|
397
|
+
"./task_logging.js": {
|
|
398
|
+
"default": "./dist/task_logging.js",
|
|
399
|
+
"types": "./dist/task_logging.d.ts"
|
|
400
|
+
},
|
|
401
401
|
"./task_module.js": {
|
|
402
402
|
"default": "./dist/task_module.js",
|
|
403
403
|
"types": "./dist/task_module.d.ts"
|
package/dist/print_task.d.ts
DELETED
|
@@ -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;
|