@ryanatkn/gro 0.160.0 → 0.161.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 (137) hide show
  1. package/README.md +2 -2
  2. package/dist/args.d.ts +1 -1
  3. package/dist/args.d.ts.map +1 -1
  4. package/dist/build.task.d.ts +1 -11
  5. package/dist/build.task.d.ts.map +1 -1
  6. package/dist/build.task.js +7 -8
  7. package/dist/changeset.task.d.ts +6 -25
  8. package/dist/changeset.task.d.ts.map +1 -1
  9. package/dist/changeset.task.js +13 -12
  10. package/dist/changeset_helpers.d.ts +10 -2
  11. package/dist/changeset_helpers.d.ts.map +1 -1
  12. package/dist/check.task.d.ts +1 -37
  13. package/dist/check.task.d.ts.map +1 -1
  14. package/dist/check.task.js +24 -21
  15. package/dist/clean.task.d.ts +1 -15
  16. package/dist/clean.task.d.ts.map +1 -1
  17. package/dist/clean.task.js +9 -9
  18. package/dist/commit.task.d.ts +2 -8
  19. package/dist/commit.task.d.ts.map +1 -1
  20. package/dist/commit.task.js +4 -5
  21. package/dist/deploy.task.d.ts +1 -25
  22. package/dist/deploy.task.d.ts.map +1 -1
  23. package/dist/deploy.task.js +15 -12
  24. package/dist/dev.task.d.ts +1 -15
  25. package/dist/dev.task.d.ts.map +1 -1
  26. package/dist/dev.task.js +10 -10
  27. package/dist/filer.d.ts +1 -1
  28. package/dist/filer.d.ts.map +1 -1
  29. package/dist/format.task.d.ts +1 -5
  30. package/dist/format.task.d.ts.map +1 -1
  31. package/dist/format.task.js +4 -5
  32. package/dist/gen.d.ts +0 -9
  33. package/dist/gen.d.ts.map +1 -1
  34. package/dist/gen.js +0 -4
  35. package/dist/gen.task.d.ts +3 -11
  36. package/dist/gen.task.d.ts.map +1 -1
  37. package/dist/gen.task.js +10 -7
  38. package/dist/github.d.ts +2 -22
  39. package/dist/github.d.ts.map +1 -1
  40. package/dist/github.js +2 -2
  41. package/dist/gro.js +0 -0
  42. package/dist/lint.task.d.ts +2 -8
  43. package/dist/lint.task.d.ts.map +1 -1
  44. package/dist/lint.task.js +4 -6
  45. package/dist/package.d.ts +4 -1212
  46. package/dist/package.d.ts.map +1 -1
  47. package/dist/package.gen.d.ts.map +1 -1
  48. package/dist/package.gen.js +5 -5
  49. package/dist/package.js +7 -32
  50. package/dist/package_json.d.ts +1 -361
  51. package/dist/package_json.d.ts.map +1 -1
  52. package/dist/package_json.js +2 -114
  53. package/dist/parse_exports.d.ts +2 -2
  54. package/dist/parse_exports.d.ts.map +1 -1
  55. package/dist/parse_exports_context.d.ts.map +1 -1
  56. package/dist/publish.task.d.ts +1 -29
  57. package/dist/publish.task.d.ts.map +1 -1
  58. package/dist/publish.task.js +22 -15
  59. package/dist/reinstall.task.d.ts +1 -1
  60. package/dist/reinstall.task.d.ts.map +1 -1
  61. package/dist/reinstall.task.js +2 -1
  62. package/dist/release.task.d.ts +1 -1
  63. package/dist/release.task.d.ts.map +1 -1
  64. package/dist/release.task.js +1 -1
  65. package/dist/resolve.task.d.ts +2 -8
  66. package/dist/resolve.task.d.ts.map +1 -1
  67. package/dist/resolve.task.js +4 -6
  68. package/dist/run.task.d.ts +2 -6
  69. package/dist/run.task.d.ts.map +1 -1
  70. package/dist/run.task.js +7 -5
  71. package/dist/run_task.d.ts.map +1 -1
  72. package/dist/run_task.js +2 -2
  73. package/dist/src_json.d.ts +2 -288
  74. package/dist/src_json.d.ts.map +1 -1
  75. package/dist/src_json.js +2 -45
  76. package/dist/sveltekit_helpers.d.ts +1 -1
  77. package/dist/sveltekit_helpers.d.ts.map +1 -1
  78. package/dist/sveltekit_helpers.js +1 -1
  79. package/dist/sveltekit_shim_app_paths.d.ts +4 -1
  80. package/dist/sveltekit_shim_app_paths.d.ts.map +1 -1
  81. package/dist/sveltekit_shim_app_paths.js +4 -1
  82. package/dist/sync.task.d.ts +1 -19
  83. package/dist/sync.task.d.ts.map +1 -1
  84. package/dist/sync.task.js +10 -12
  85. package/dist/task.d.ts +2 -2
  86. package/dist/task.d.ts.map +1 -1
  87. package/dist/task_logging.js +114 -47
  88. package/dist/test.task.d.ts +3 -13
  89. package/dist/test.task.d.ts.map +1 -1
  90. package/dist/test.task.js +8 -8
  91. package/dist/typecheck.task.d.ts +1 -11
  92. package/dist/typecheck.task.d.ts.map +1 -1
  93. package/dist/typecheck.task.js +10 -9
  94. package/dist/upgrade.task.d.ts +3 -27
  95. package/dist/upgrade.task.d.ts.map +1 -1
  96. package/dist/upgrade.task.js +20 -14
  97. package/package.json +9 -13
  98. package/src/lib/args.ts +5 -5
  99. package/src/lib/build.task.ts +9 -10
  100. package/src/lib/changeset.task.ts +27 -26
  101. package/src/lib/changeset_helpers.ts +1 -0
  102. package/src/lib/check.task.ts +28 -25
  103. package/src/lib/clean.task.ts +17 -17
  104. package/src/lib/commit.task.ts +9 -10
  105. package/src/lib/deploy.task.ts +32 -31
  106. package/src/lib/dev.task.ts +16 -17
  107. package/src/lib/filer.ts +1 -1
  108. package/src/lib/format.task.ts +6 -7
  109. package/src/lib/gen.task.ts +14 -11
  110. package/src/lib/gen.ts +0 -6
  111. package/src/lib/github.ts +2 -2
  112. package/src/lib/lint.task.ts +4 -6
  113. package/src/lib/package.gen.ts +7 -6
  114. package/src/lib/package.ts +13 -38
  115. package/src/lib/package_json.ts +3 -140
  116. package/src/lib/parse_exports.ts +2 -10
  117. package/src/lib/parse_exports_context.ts +9 -5
  118. package/src/lib/publish.task.ts +33 -26
  119. package/src/lib/reinstall.task.ts +2 -1
  120. package/src/lib/release.task.ts +1 -1
  121. package/src/lib/resolve.task.ts +4 -6
  122. package/src/lib/run.task.ts +10 -7
  123. package/src/lib/run_task.ts +4 -2
  124. package/src/lib/src_json.ts +3 -59
  125. package/src/lib/sveltekit_helpers.ts +2 -1
  126. package/src/lib/sveltekit_shim_app_paths.ts +5 -2
  127. package/src/lib/sveltekit_shim_app_state.ts +1 -1
  128. package/src/lib/sync.task.ts +10 -12
  129. package/src/lib/task.ts +2 -2
  130. package/src/lib/task_logging.ts +127 -49
  131. package/src/lib/test.task.ts +12 -12
  132. package/src/lib/typecheck.task.ts +16 -15
  133. package/src/lib/upgrade.task.ts +34 -28
  134. package/dist/package_meta.d.ts +0 -23
  135. package/dist/package_meta.d.ts.map +0 -1
  136. package/dist/package_meta.js +0 -56
  137. package/src/lib/package_meta.ts +0 -97
@@ -1,10 +1,10 @@
1
1
  import {z} from 'zod';
2
2
  import {join} from 'node:path';
3
3
  import {readFileSync, writeFileSync} from 'node:fs';
4
- import {count_graphemes, plural, strip_end} from '@ryanatkn/belt/string.js';
4
+ import {plural, strip_end} from '@ryanatkn/belt/string.js';
5
5
  import type {Logger} from '@ryanatkn/belt/log.js';
6
- import type {Flavored} from '@ryanatkn/belt/types.js';
7
6
  import {styleText as st} from 'node:util';
7
+ import {Package_Json, Package_Json_Exports} from '@ryanatkn/belt/package_json.js';
8
8
 
9
9
  import {paths, gro_paths, IS_THIS_GRO, replace_extension} from './paths.ts';
10
10
  import {SVELTEKIT_DIST_DIRNAME} from './constants.ts';
@@ -12,143 +12,6 @@ import {search_fs} from './search_fs.ts';
12
12
  import {has_sveltekit_library} from './sveltekit_helpers.ts';
13
13
  import {GITHUB_REPO_MATCHER} from './github.ts';
14
14
 
15
- // TODO @many belongs elsewhere
16
- export const Url = z.string();
17
- export type Url = Flavored<z.infer<typeof Url>, 'Url'>;
18
-
19
- // TODO @many belongs elsewhere
20
- export const Email = z.string();
21
- export type Email = Flavored<z.infer<typeof Email>, 'Email'>;
22
-
23
- // TODO move this where?
24
- export const transform_empty_object_to_undefined = <T>(val: T): T | undefined => {
25
- if (val && Object.keys(val).length === 0) {
26
- return;
27
- }
28
- return val;
29
- };
30
-
31
- export const Package_Json_Repository = z.union([
32
- z.string(),
33
- z
34
- .object({
35
- type: z.string(),
36
- url: Url,
37
- directory: z.string().optional(),
38
- })
39
- .passthrough(),
40
- ]);
41
- export type Package_Json_Repository = z.infer<typeof Package_Json_Repository>;
42
-
43
- export const Package_Json_Author = z.union([
44
- z.string(),
45
- z
46
- .object({
47
- name: z.string(),
48
- email: Email.optional(),
49
- url: Url.optional(),
50
- })
51
- .passthrough(),
52
- ]);
53
- export type Package_Json_Author = z.infer<typeof Package_Json_Author>;
54
-
55
- export const Package_Json_Funding = z.union([
56
- z.string(),
57
- z
58
- .object({
59
- type: z.string(),
60
- url: Url,
61
- })
62
- .passthrough(),
63
- ]);
64
- export type Package_Json_Funding = z.infer<typeof Package_Json_Funding>;
65
-
66
- // Helper to create a recursive type that represents export conditions and values
67
- const create_export_value_schema = (): z.ZodType => {
68
- return z.lazy(() => z.union([z.string(), z.null(), z.record(z.lazy(() => export_value_schema))]));
69
- };
70
-
71
- // The base export value schema that can be a string, null, or nested conditions
72
- const export_value_schema = create_export_value_schema();
73
- export const Export_Value = export_value_schema;
74
- export type Export_Value = z.infer<typeof Export_Value>;
75
-
76
- // Package exports can be:
77
- // 1. A string (shorthand for main export)
78
- // 2. null (to block exports)
79
- // 3. A record of export conditions/paths
80
- export const Package_Json_Exports = z.union([z.string(), z.null(), z.record(export_value_schema)]);
81
- export type Package_Json_Exports = z.infer<typeof Package_Json_Exports>;
82
-
83
- /**
84
- * @see https://docs.npmjs.com/cli/v10/configuring-npm/package-json
85
- */
86
- export const Package_Json = z
87
- .object({
88
- // according to the npm docs, `name` and `version` are the only required properties
89
- name: z.string(),
90
- version: z.string(),
91
- private: z.boolean({description: 'disallow publishing to the configured registry'}).optional(),
92
- public: z
93
- .boolean({
94
- description:
95
- 'a Gro extension that enables publishing `.well-known/package.json` and `.well-known/src`',
96
- })
97
- .optional(),
98
- description: z.string().optional(),
99
- motto: z
100
- .string({description: "a Gro extension that's a short phrase that represents this project"})
101
- .optional(),
102
- glyph: z
103
- .string({
104
- description:
105
- "a Gro extension that's a single unicode character that represents this project",
106
- })
107
- .refine((v) => count_graphemes(v) === 1, 'must be a single unicode character')
108
- .optional(),
109
- logo: z
110
- .string({
111
- description:
112
- "a Gro extension that's a link relative to the `homepage` to an image that represents this project",
113
- })
114
- .optional(),
115
- logo_alt: z
116
- .string({description: "a Gro extension that's the alt text for the `logo`"})
117
- .optional(),
118
- license: z.string().optional(),
119
- scripts: z.record(z.string()).optional(),
120
- homepage: Url.optional(),
121
- author: z.union([z.string(), Package_Json_Author.optional()]),
122
- repository: z.union([z.string(), Url, Package_Json_Repository]).optional(),
123
- contributors: z.array(z.union([z.string(), Package_Json_Author])).optional(),
124
- bugs: z
125
- .union([z.string(), z.object({url: Url.optional(), email: Email.optional()}).passthrough()])
126
- .optional(),
127
- funding: z
128
- .union([Url, Package_Json_Funding, z.array(z.union([Url, Package_Json_Funding]))])
129
- .optional(),
130
- keywords: z.array(z.string()).optional(),
131
-
132
- type: z.string().optional(),
133
- engines: z.record(z.string()).optional(),
134
- os: z.array(z.string()).optional(),
135
- cpu: z.array(z.string()).optional(),
136
-
137
- dependencies: z.record(z.string()).optional(),
138
- devDependencies: z.record(z.string()).optional(),
139
- peerDependencies: z.record(z.string()).optional(),
140
- peerDependenciesMeta: z.record(z.object({optional: z.boolean()})).optional(),
141
- optionalDependencies: z.record(z.string()).optional(),
142
-
143
- bin: z.record(z.string()).optional(),
144
- sideEffects: z.array(z.string()).optional(),
145
- files: z.array(z.string()).optional(),
146
- main: z.string().optional(),
147
- exports: Package_Json_Exports.transform(transform_empty_object_to_undefined).optional(),
148
- })
149
- .passthrough();
150
- export type Package_Json = z.infer<typeof Package_Json>;
151
-
152
15
  export type Map_Package_Json = (
153
16
  package_json: Package_Json,
154
17
  ) => Package_Json | null | Promise<Package_Json | null>;
@@ -331,7 +194,7 @@ const parse_package_json = (schema: typeof Package_Json, value: any): Package_Js
331
194
  };
332
195
 
333
196
  // TODO maybe extract to zod helpers? see also everything in `task_logging.ts`
334
- const parse_or_throw_formatted_error = <T extends z.ZodTypeAny>(
197
+ const parse_or_throw_formatted_error = <T extends z.ZodType>(
335
198
  name: string,
336
199
  schema: T,
337
200
  value: any,
@@ -2,23 +2,15 @@ import ts from 'typescript';
2
2
  import {extname} from 'node:path';
3
3
  import type {Flavored} from '@ryanatkn/belt/types.js';
4
4
  import type {Logger} from '@ryanatkn/belt/log.js';
5
+ import type {Src_Module_Declaration_Kind} from '@ryanatkn/belt/src_json.js';
5
6
 
6
7
  import type {Path_Id} from './path.ts';
7
8
  import {TS_MATCHER} from './constants.ts';
8
9
  import {Parse_Exports_Context} from './parse_exports_context.ts';
9
10
 
10
- export type Declaration_Kind =
11
- | 'type'
12
- | 'function'
13
- | 'variable' // TODO maybe expand this to have literals/primitives?
14
- | 'class'
15
- | 'component'
16
- | 'json'
17
- | 'css';
18
-
19
11
  export interface Declaration {
20
12
  name: string;
21
- kind: Declaration_Kind | null;
13
+ kind: Src_Module_Declaration_Kind | null;
22
14
  }
23
15
 
24
16
  export type Export_Declaration = Flavored<Declaration, 'Export_Declaration'>;
@@ -1,7 +1,8 @@
1
1
  import ts from 'typescript';
2
2
  import type {Logger} from '@ryanatkn/belt/log.js';
3
+ import type {Src_Module_Declaration_Kind} from '@ryanatkn/belt/src_json.js';
3
4
 
4
- import type {Declaration_Kind, Export_Declaration} from './parse_exports.ts';
5
+ import type {Export_Declaration} from './parse_exports.ts';
5
6
 
6
7
  /**
7
8
  * A class to track export context and determine export kinds.
@@ -12,7 +13,7 @@ export class Parse_Exports_Context {
12
13
  // Map of source file paths to their symbols
13
14
  readonly #file_symbols: Map<string, ts.Symbol> = new Map();
14
15
  // Cache for resolved symbols to avoid repeated resolution
15
- readonly #symbol_kind_cache: Map<ts.Symbol, Declaration_Kind> = new Map();
16
+ readonly #symbol_kind_cache: Map<ts.Symbol, Src_Module_Declaration_Kind> = new Map();
16
17
 
17
18
  readonly log: Logger | undefined;
18
19
  debug = process.env.DEBUG_EXPORTS === 'true';
@@ -74,7 +75,10 @@ export class Parse_Exports_Context {
74
75
  /**
75
76
  * Determine the kind of an export based on its symbol.
76
77
  */
77
- #determine_export_kind(source_file: ts.SourceFile, symbol: ts.Symbol): Declaration_Kind {
78
+ #determine_export_kind(
79
+ source_file: ts.SourceFile,
80
+ symbol: ts.Symbol,
81
+ ): Src_Module_Declaration_Kind {
78
82
  // Check if this is a type-only export (no value export)
79
83
  if (this.#is_type_only_export(source_file, symbol)) {
80
84
  return 'type';
@@ -114,7 +118,7 @@ export class Parse_Exports_Context {
114
118
  /**
115
119
  * Infer the declaration kind from a symbol's declaration and type information.
116
120
  */
117
- #infer_declaration_kind(symbol: ts.Symbol): Declaration_Kind {
121
+ #infer_declaration_kind(symbol: ts.Symbol): Src_Module_Declaration_Kind {
118
122
  // Check symbol flags first for direct type matching
119
123
  if (this.#is_class_symbol(symbol)) {
120
124
  return 'class';
@@ -181,7 +185,7 @@ export class Parse_Exports_Context {
181
185
  /**
182
186
  * Infer the declaration kind from a specific declaration node.
183
187
  */
184
- #infer_kind_from_declaration(decl: ts.Declaration): Declaration_Kind | null {
188
+ #infer_kind_from_declaration(decl: ts.Declaration): Src_Module_Declaration_Kind | null {
185
189
  if (ts.isFunctionDeclaration(decl)) {
186
190
  return 'function';
187
191
  }
@@ -19,32 +19,39 @@ import {
19
19
  } from './git.ts';
20
20
  import {CHANGESET_CLI} from './changeset_helpers.ts';
21
21
 
22
- export const Args = z
23
- .object({
24
- branch: Git_Branch.describe('branch to publish from').default('main'),
25
- origin: Git_Origin.describe('git origin to publish from').default('origin'),
26
- changelog: z
27
- .string({description: 'file name and path of the changelog'})
28
- .default('CHANGELOG.md'),
29
- preserve_changelog: z
30
- .boolean({
31
- description:
32
- 'opt out of linkifying and formatting the changelog from @changesets/changelog-git',
33
- })
34
- .default(false),
35
- optional: z.boolean({description: 'exit gracefully if there are no changesets'}).default(false),
36
- dry: z
37
- .boolean({description: 'build and prepare to publish without actually publishing'})
38
- .default(false),
39
- check: z.boolean({description: 'dual of no-check'}).default(true),
40
- 'no-check': z.boolean({description: 'opt out of checking before publishing'}).default(false),
41
- build: z.boolean({description: 'dual of no-build'}).default(true),
42
- 'no-build': z.boolean({description: 'opt out of building'}).default(false),
43
- pull: z.boolean({description: 'dual of no-pull'}).default(true),
44
- 'no-pull': z.boolean({description: 'opt out of git pull'}).default(false),
45
- changeset_cli: z.string({description: 'the changeset CLI to use'}).default(CHANGESET_CLI),
46
- })
47
- .strict();
22
+ export const Args = z.strictObject({
23
+ branch: Git_Branch.describe('branch to publish from').default('main'),
24
+ origin: Git_Origin.describe('git origin to publish from').default('origin'),
25
+ changelog: z
26
+ .string()
27
+ .meta({description: 'file name and path of the changelog'})
28
+ .default('CHANGELOG.md'),
29
+ preserve_changelog: z
30
+ .boolean()
31
+ .meta({
32
+ description:
33
+ 'opt out of linkifying and formatting the changelog from @changesets/changelog-git',
34
+ })
35
+ .default(false),
36
+ optional: z
37
+ .boolean()
38
+ .meta({description: 'exit gracefully if there are no changesets'})
39
+ .default(false),
40
+ dry: z
41
+ .boolean()
42
+ .meta({description: 'build and prepare to publish without actually publishing'})
43
+ .default(false),
44
+ check: z.boolean().meta({description: 'dual of no-check'}).default(true),
45
+ 'no-check': z
46
+ .boolean()
47
+ .meta({description: 'opt out of checking before publishing'})
48
+ .default(false),
49
+ build: z.boolean().meta({description: 'dual of no-build'}).default(true),
50
+ 'no-build': z.boolean().meta({description: 'opt out of building'}).default(false),
51
+ pull: z.boolean().meta({description: 'dual of no-pull'}).default(true),
52
+ 'no-pull': z.boolean().meta({description: 'opt out of git pull'}).default(false),
53
+ changeset_cli: z.string().meta({description: 'the changeset CLI to use'}).default(CHANGESET_CLI),
54
+ });
48
55
  export type Args = z.infer<typeof Args>;
49
56
 
50
57
  export const task: Task<Args> = {
@@ -5,7 +5,7 @@ import {rm} from 'node:fs/promises';
5
5
  import {Task_Error, type Task} from './task.ts';
6
6
  import {LOCKFILE_FILENAME, NODE_MODULES_DIRNAME} from './constants.ts';
7
7
 
8
- export const Args = z.object({}).strict();
8
+ export const Args = z.strictObject({});
9
9
  export type Args = z.infer<typeof Args>;
10
10
 
11
11
  export const task: Task<Args> = {
@@ -30,6 +30,7 @@ export const task: Task<Args> = {
30
30
  );
31
31
  }
32
32
 
33
+ // TODO this relies on npm behavior that changed in v11
33
34
  // Deleting the lockfile and reinstalling cleans the lockfile of unnecessary dep noise,
34
35
  // like esbuild's many packages for each platform.
35
36
  await rm(LOCKFILE_FILENAME);
@@ -4,7 +4,7 @@ import type {Task} from './task.ts';
4
4
  import {has_sveltekit_library, has_sveltekit_app} from './sveltekit_helpers.ts';
5
5
  import {load_package_json} from './package_json.ts';
6
6
 
7
- export const Args = z.object({}).strict();
7
+ export const Args = z.strictObject({});
8
8
  export type Args = z.infer<typeof Args>;
9
9
 
10
10
  export const task: Task<Args> = {
@@ -4,12 +4,10 @@ import {styleText as st} from 'node:util';
4
4
  import {TASK_FILE_SUFFIXES, type Task} from './task.ts';
5
5
  import {resolve_input_paths, to_input_paths} from './input_path.ts';
6
6
 
7
- export const Args = z
8
- .object({
9
- _: z.array(z.string(), {description: 'the input paths to resolve'}).default(['']),
10
- verbose: z.boolean({description: 'log diagnostics'}).default(false),
11
- })
12
- .strict();
7
+ export const Args = z.strictObject({
8
+ _: z.array(z.string()).meta({description: 'the input paths to resolve'}).default(['']),
9
+ verbose: z.boolean().meta({description: 'log diagnostics'}).default(false),
10
+ });
13
11
  export type Args = z.infer<typeof Args>;
14
12
 
15
13
  export const task: Task<Args> = {
@@ -5,13 +5,16 @@ import {existsSync} from 'node:fs';
5
5
  import {Task_Error, type Task} from './task.ts';
6
6
  import {resolve_gro_module_path, spawn_with_loader} from './gro_helpers.ts';
7
7
 
8
- export const Args = z
9
- .object({
10
- _: z
11
- .array(z.string(), {description: 'the file path to run and other node CLI args'})
12
- .default([]),
13
- })
14
- .strict();
8
+ // TODO maybe delete this? if misused is a security risk,
9
+ // and I'm not using it for anything that couldn't be done with Node directly atm.
10
+ // It could potentially be more useful if I keep building on the task system.
11
+
12
+ export const Args = z.strictObject({
13
+ _: z
14
+ .array(z.string())
15
+ .meta({description: 'the file path to run and other node CLI args'})
16
+ .default([]),
17
+ });
15
18
  export type Args = z.infer<typeof Args>;
16
19
 
17
20
  export const task: Task<Args> = {
@@ -2,6 +2,7 @@ import {styleText as st} from 'node:util';
2
2
  import {print_log_label} from '@ryanatkn/belt/print.js';
3
3
  import {System_Logger} from '@ryanatkn/belt/log.js';
4
4
  import type {Timings} from '@ryanatkn/belt/timings.js';
5
+ import z from 'zod';
5
6
 
6
7
  import {parse_args, type Args} from './args.ts';
7
8
  import type {invoke_task as base_invoke_task} from './invoke_task.ts';
@@ -43,8 +44,9 @@ export const run_task = async (
43
44
  if (task.Args) {
44
45
  const parsed = parse_args(unparsed_args, task.Args);
45
46
  if (!parsed.success) {
46
- log.error(st('red', `Args validation failed:`), '\n', parsed.error.format());
47
- throw new Task_Error(`Task args failed validation`);
47
+ throw new Task_Error(
48
+ `Failed task args validation for task '${task_meta.name}':\n${z.prettifyError(parsed.error)}`,
49
+ );
48
50
  }
49
51
  args = parsed.data;
50
52
  }
@@ -1,65 +1,13 @@
1
- import {z} from 'zod';
2
1
  import {join, extname} from 'node:path';
3
2
  import {ensure_end, strip_start} from '@ryanatkn/belt/string.js';
4
3
  import {existsSync} from 'node:fs';
5
4
  import ts from 'typescript';
5
+ import type {Package_Json, Package_Json_Exports} from '@ryanatkn/belt/package_json.js';
6
+ import {Src_Json, Src_Modules} from '@ryanatkn/belt/src_json.js';
6
7
 
7
8
  import {paths, replace_extension} from './paths.ts';
8
- import {
9
- transform_empty_object_to_undefined,
10
- type Package_Json,
11
- type Package_Json_Exports,
12
- } from './package_json.ts';
13
9
  import {parse_exports} from './parse_exports.ts';
14
10
 
15
- export const Src_Module_Declaration_Kind = z.enum([
16
- 'type',
17
- 'function',
18
- 'variable',
19
- 'class',
20
- 'component',
21
- 'json',
22
- 'css',
23
- ]);
24
- export type Src_Module_Declaration_Kind = z.infer<typeof Src_Module_Declaration_Kind>;
25
-
26
- // TODO @many rename to prefix with `Src_Json_`?
27
- export const Src_Module_Declaration = z
28
- .object({
29
- name: z.string(), // the export identifier
30
- // TODO these are poorly named, and they're somewhat redundant with `kind`,
31
- // they were added to distinguish `VariableDeclaration` functions and non-functions
32
- kind: Src_Module_Declaration_Kind.nullable(),
33
- // code: z.string(), // TODO experiment with `getType().getText()`, some of them return the same as `name`
34
- })
35
- .passthrough();
36
- export type Src_Module_Declaration = z.infer<typeof Src_Module_Declaration>;
37
-
38
- // TODO @many rename to prefix with `Src_Json_`?
39
- export const Src_Module = z
40
- .object({
41
- path: z.string(),
42
- declarations: z.array(Src_Module_Declaration).optional(),
43
- })
44
- .passthrough();
45
- export type Src_Module = z.infer<typeof Src_Module>;
46
-
47
- // TODO @many rename to prefix with `Src_Json_`?
48
- export const Src_Modules = z.record(Src_Module);
49
- export type Src_Modules = z.infer<typeof Src_Modules>;
50
-
51
- /**
52
- * @see https://github.com/ryanatkn/gro/blob/main/src/docs/gro_plugin_sveltekit_app.md#well-known-src
53
- */
54
- export const Src_Json = z
55
- .object({
56
- name: z.string(), // same as Package_Json
57
- version: z.string(), // same as Package_Json
58
- modules: Src_Modules.transform(transform_empty_object_to_undefined).optional(),
59
- })
60
- .passthrough();
61
- export type Src_Json = z.infer<typeof Src_Json>;
62
-
63
11
  export type Map_Src_Json = (src_json: Src_Json) => Src_Json | null | Promise<Src_Json | null>;
64
12
 
65
13
  export const create_src_json = (package_json: Package_Json, lib_path?: string): Src_Json =>
@@ -134,11 +82,7 @@ export const to_src_modules = (
134
82
  for (const {export_key, file_path} of file_paths) {
135
83
  const relative_path = file_path.replace(ensure_end(lib_path, '/'), '');
136
84
 
137
- // Use parse_exports for all file types
138
- const declarations = parse_exports(file_path, program).map(({name, kind}) => ({
139
- name,
140
- kind: kind as Src_Module_Declaration_Kind | null,
141
- }));
85
+ const declarations = parse_exports(file_path, program).map(({name, kind}) => ({name, kind}));
142
86
 
143
87
  result[export_key] = declarations.length
144
88
  ? {
@@ -2,8 +2,9 @@ import type {Result} from '@ryanatkn/belt/result.js';
2
2
  import {existsSync} from 'node:fs';
3
3
  import type {Logger} from '@ryanatkn/belt/log.js';
4
4
  import {join} from 'node:path';
5
+ import type {Package_Json} from '@ryanatkn/belt/package_json.js';
5
6
 
6
- import {Package_Json, has_dep} from './package_json.ts';
7
+ import {has_dep} from './package_json.ts';
7
8
  import {default_svelte_config, type Parsed_Svelte_Config} from './svelte_config.ts';
8
9
  import {SVELTE_CONFIG_FILENAME, SVELTEKIT_DEV_DIRNAME, PM_CLI_DEFAULT} from './constants.ts';
9
10
  import {find_cli, spawn_cli, to_cli_name, type Cli} from './cli.ts';
@@ -8,9 +8,12 @@
8
8
  * @see https://github.com/nodejs/loaders for details about the forthcoming virtual file support
9
9
  */
10
10
 
11
- import type {resolveRoute as base_resolveRoute} from '$app/paths';
11
+ import type {resolve as base_resolve, resolveRoute as base_resolveRoute} from '$app/paths';
12
12
  import {noop} from '@ryanatkn/belt/function.js';
13
13
 
14
14
  export const assets = '';
15
+ /** @deprecated */
15
16
  export const base = '';
16
- export const resolveRoute: typeof base_resolveRoute = noop;
17
+ export const resolve: typeof base_resolve = (v) => ('/' + v.replace(/^\//, '')) as any; // TODO needs to use SvelteKit config base, should we just import it?
18
+ /** @deprecated */
19
+ export const resolveRoute: typeof base_resolveRoute = noop; // eslint-disable-line @typescript-eslint/no-deprecated
@@ -24,7 +24,7 @@ export const page: typeof base_page = {
24
24
  route: {id: null},
25
25
  state: {},
26
26
  status: -1,
27
- url: new URL('https://github.com/ryanatkn/gro'),
27
+ url: new URL('https://github.com/ryanatkn/gro') as any,
28
28
  };
29
29
 
30
30
  export const updated: typeof base_updated = {
@@ -5,18 +5,16 @@ import {Task_Error, type Task} from './task.ts';
5
5
  import {sync_package_json} from './package_json.ts';
6
6
  import {sveltekit_sync} from './sveltekit_helpers.ts';
7
7
 
8
- export const Args = z
9
- .object({
10
- sveltekit: z.boolean({description: 'dual of no-sveltekit'}).default(true),
11
- 'no-sveltekit': z.boolean({description: 'opt out of svelte-kit sync'}).default(false),
12
- package_json: z.boolean({description: 'dual of no-package_json'}).default(true),
13
- 'no-package_json': z.boolean({description: 'opt out of package.json sync'}).default(false),
14
- gen: z.boolean({description: 'dual of no-gen'}).default(true),
15
- 'no-gen': z.boolean({description: 'opt out of running gen'}).default(false),
16
- install: z.boolean({description: 'dual of no-install'}).default(true),
17
- 'no-install': z.boolean({description: 'opt out of installing packages'}).default(false),
18
- })
19
- .strict();
8
+ export const Args = z.strictObject({
9
+ sveltekit: z.boolean().meta({description: 'dual of no-sveltekit'}).default(true),
10
+ 'no-sveltekit': z.boolean().meta({description: 'opt out of svelte-kit sync'}).default(false),
11
+ package_json: z.boolean().meta({description: 'dual of no-package_json'}).default(true),
12
+ 'no-package_json': z.boolean().meta({description: 'opt out of package.json sync'}).default(false),
13
+ gen: z.boolean().meta({description: 'dual of no-gen'}).default(true),
14
+ 'no-gen': z.boolean().meta({description: 'opt out of running gen'}).default(false),
15
+ install: z.boolean().meta({description: 'dual of no-install'}).default(true),
16
+ 'no-install': z.boolean().meta({description: 'opt out of installing packages'}).default(false),
17
+ });
20
18
  export type Args = z.infer<typeof Args>;
21
19
 
22
20
  export const task: Task<Args> = {
package/src/lib/task.ts CHANGED
@@ -23,8 +23,8 @@ import {load_modules, type Load_Modules_Failure, type Module_Meta} from './modul
23
23
  import type {Filer} from './filer.ts';
24
24
 
25
25
  export interface Task<
26
- T_Args = Args, // same as `z.infer<typeof Args>`
27
- T_Args_Schema extends z.ZodType = z.ZodType,
26
+ T_Args = Args,
27
+ T_Args_Schema extends z.ZodType<Args, Args> = z.ZodType<Args, Args>, // TODO improve type? separate input/output?
28
28
  T_Return = unknown,
29
29
  > {
30
30
  run: (ctx: Task_Context<T_Args>) => T_Return | Promise<T_Return>; // TODO unused return value