@ryanatkn/gro 0.173.1 → 0.174.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 (117) hide show
  1. package/dist/build.task.d.ts +2 -0
  2. package/dist/build.task.d.ts.map +1 -1
  3. package/dist/build.task.js +2 -0
  4. package/dist/changeset.task.d.ts +4 -1
  5. package/dist/changeset.task.d.ts.map +1 -1
  6. package/dist/changeset.task.js +3 -0
  7. package/dist/check.task.d.ts +2 -0
  8. package/dist/check.task.d.ts.map +1 -1
  9. package/dist/check.task.js +2 -0
  10. package/dist/clean.task.d.ts +3 -1
  11. package/dist/clean.task.d.ts.map +1 -1
  12. package/dist/clean.task.js +2 -0
  13. package/dist/commit.task.d.ts +3 -1
  14. package/dist/commit.task.d.ts.map +1 -1
  15. package/dist/commit.task.js +2 -0
  16. package/dist/deploy.task.d.ts +5 -3
  17. package/dist/deploy.task.d.ts.map +1 -1
  18. package/dist/deploy.task.js +2 -0
  19. package/dist/dev.task.d.ts +2 -0
  20. package/dist/dev.task.d.ts.map +1 -1
  21. package/dist/dev.task.js +2 -0
  22. package/dist/filer.d.ts.map +1 -1
  23. package/dist/filer.js +13 -3
  24. package/dist/format.task.d.ts +2 -0
  25. package/dist/format.task.d.ts.map +1 -1
  26. package/dist/format.task.js +2 -0
  27. package/dist/gen.task.d.ts +2 -0
  28. package/dist/gen.task.d.ts.map +1 -1
  29. package/dist/gen.task.js +2 -0
  30. package/dist/gro_config.d.ts +3 -3
  31. package/dist/gro_config.d.ts.map +1 -1
  32. package/dist/gro_plugin_server.d.ts +1 -0
  33. package/dist/gro_plugin_server.d.ts.map +1 -1
  34. package/dist/gro_plugin_sveltekit_app.d.ts +4 -4
  35. package/dist/gro_plugin_sveltekit_app.d.ts.map +1 -1
  36. package/dist/gro_plugin_sveltekit_app.js +4 -4
  37. package/dist/index.d.ts +4 -0
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +2 -0
  40. package/dist/lint.task.d.ts +2 -0
  41. package/dist/lint.task.d.ts.map +1 -1
  42. package/dist/lint.task.js +2 -0
  43. package/dist/loader.d.ts +2 -0
  44. package/dist/loader.d.ts.map +1 -1
  45. package/dist/loader.js +2 -0
  46. package/dist/package_json.d.ts +2 -2
  47. package/dist/package_json.d.ts.map +1 -1
  48. package/dist/parse_exports.d.ts +2 -2
  49. package/dist/parse_exports.d.ts.map +1 -1
  50. package/dist/parse_exports_context.d.ts.map +1 -1
  51. package/dist/publish.task.d.ts +8 -2
  52. package/dist/publish.task.d.ts.map +1 -1
  53. package/dist/publish.task.js +19 -2
  54. package/dist/reinstall.task.d.ts +2 -0
  55. package/dist/reinstall.task.d.ts.map +1 -1
  56. package/dist/reinstall.task.js +2 -0
  57. package/dist/release.task.d.ts +2 -0
  58. package/dist/release.task.d.ts.map +1 -1
  59. package/dist/release.task.js +2 -0
  60. package/dist/resolve.task.d.ts +2 -0
  61. package/dist/resolve.task.d.ts.map +1 -1
  62. package/dist/resolve.task.js +2 -0
  63. package/dist/run.task.d.ts +2 -0
  64. package/dist/run.task.d.ts.map +1 -1
  65. package/dist/run.task.js +2 -0
  66. package/dist/src_json.d.ts +5 -5
  67. package/dist/src_json.d.ts.map +1 -1
  68. package/dist/src_json.js +14 -15
  69. package/dist/sync.task.d.ts +2 -0
  70. package/dist/sync.task.d.ts.map +1 -1
  71. package/dist/sync.task.js +2 -0
  72. package/dist/test.task.d.ts +2 -0
  73. package/dist/test.task.d.ts.map +1 -1
  74. package/dist/test.task.js +2 -0
  75. package/dist/typecheck.task.d.ts +2 -0
  76. package/dist/typecheck.task.d.ts.map +1 -1
  77. package/dist/typecheck.task.js +2 -0
  78. package/dist/upgrade.task.d.ts +3 -1
  79. package/dist/upgrade.task.d.ts.map +1 -1
  80. package/dist/upgrade.task.js +2 -0
  81. package/package.json +5 -5
  82. package/src/lib/build.task.ts +2 -0
  83. package/src/lib/changeset.task.ts +3 -0
  84. package/src/lib/check.task.ts +2 -0
  85. package/src/lib/clean.task.ts +2 -0
  86. package/src/lib/commit.task.ts +2 -0
  87. package/src/lib/deploy.task.ts +2 -0
  88. package/src/lib/dev.task.ts +2 -0
  89. package/src/lib/filer.ts +14 -4
  90. package/src/lib/format.task.ts +2 -0
  91. package/src/lib/gen.task.ts +2 -0
  92. package/src/lib/gro_config.ts +3 -3
  93. package/src/lib/gro_plugin_sveltekit_app.ts +10 -6
  94. package/src/lib/index.ts +4 -0
  95. package/src/lib/lint.task.ts +2 -0
  96. package/src/lib/loader.ts +2 -0
  97. package/src/lib/package_json.ts +2 -2
  98. package/src/lib/parse_exports.ts +2 -2
  99. package/src/lib/parse_exports_context.ts +5 -8
  100. package/src/lib/publish.task.ts +20 -1
  101. package/src/lib/reinstall.task.ts +2 -0
  102. package/src/lib/release.task.ts +2 -0
  103. package/src/lib/resolve.task.ts +2 -0
  104. package/src/lib/run.task.ts +2 -0
  105. package/src/lib/src_json.ts +23 -22
  106. package/src/lib/sync.task.ts +2 -0
  107. package/src/lib/test.task.ts +2 -0
  108. package/src/lib/typecheck.task.ts +2 -0
  109. package/src/lib/upgrade.task.ts +2 -0
  110. package/dist/package.d.ts +0 -5
  111. package/dist/package.d.ts.map +0 -1
  112. package/dist/package.gen.d.ts +0 -8
  113. package/dist/package.gen.d.ts.map +0 -1
  114. package/dist/package.gen.js +0 -30
  115. package/dist/package.js +0 -876
  116. package/src/lib/package.gen.ts +0 -38
  117. package/src/lib/package.ts +0 -883
@@ -4,6 +4,7 @@ import type {Task} from './task.ts';
4
4
  import {Plugins, type Plugin_Context} from './plugin.ts';
5
5
  import {clean_fs} from './clean_fs.ts';
6
6
 
7
+ /** @nodocs */
7
8
  export const Args = z.strictObject({
8
9
  watch: z.boolean().meta({description: 'dual of no-watch'}).default(true),
9
10
  'no-watch': z
@@ -20,6 +21,7 @@ export type Args = z.infer<typeof Args>;
20
21
 
21
22
  export type DevTask_Context = Plugin_Context<Args>;
22
23
 
24
+ /** @nodocs */
23
25
  export const task: Task<Args> = {
24
26
  summary: 'start SvelteKit and other dev plugins',
25
27
  Args,
package/src/lib/filer.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import {EMPTY_OBJECT} from '@ryanatkn/belt/object.js';
2
- import {existsSync, readFileSync, statSync} from 'node:fs';
2
+ import {readFileSync, statSync} from 'node:fs';
3
3
  import {dirname, resolve} from 'node:path';
4
4
  import type {Omit_Strict} from '@ryanatkn/belt/types.js';
5
5
  import {isBuiltin} from 'node:module';
@@ -217,13 +217,23 @@ export class Filer {
217
217
  #update(id: Path_Id): Disknode | null {
218
218
  const file = this.get_or_create(id);
219
219
 
220
- const stats = existsSync(id) ? statSync(id) : null;
220
+ let stats: ReturnType<typeof statSync> | null = null;
221
+ let new_contents: string | null = null; // TODO need to lazily load contents, probably turn `Disknode` into a class
222
+
223
+ try {
224
+ stats = statSync(id);
225
+ new_contents = readFileSync(id, 'utf8');
226
+ } catch (err) {
227
+ if ((err as NodeJS.ErrnoException).code !== 'ENOENT') {
228
+ throw err;
229
+ }
230
+ // ENOENT: file doesn't exist, treat as deleted
231
+ }
232
+
221
233
  const old_mtime = file.mtime;
222
234
  file.ctime = stats?.ctimeMs ?? null;
223
235
  file.mtime = stats?.mtimeMs ?? null;
224
236
 
225
- const new_contents = stats ? readFileSync(id, 'utf8') : null; // TODO need to lazily load contents, probably turn `Disknode` into a class
226
-
227
237
  if (file.mtime === old_mtime && file.contents === new_contents) {
228
238
  return null;
229
239
  }
@@ -5,6 +5,7 @@ import {Task_Error, type Task} from './task.ts';
5
5
  import {format_directory} from './format_directory.ts';
6
6
  import {paths} from './paths.ts';
7
7
 
8
+ /** @nodocs */
8
9
  export const Args = z.strictObject({
9
10
  check: z
10
11
  .boolean()
@@ -13,6 +14,7 @@ export const Args = z.strictObject({
13
14
  });
14
15
  export type Args = z.infer<typeof Args>;
15
16
 
17
+ /** @nodocs */
16
18
  export const task: Task<Args> = {
17
19
  summary: 'format source files',
18
20
  Args,
@@ -19,6 +19,7 @@ import {
19
19
  } from './gen.ts';
20
20
  import {SOURCE_DIRNAME} from './constants.ts';
21
21
 
22
+ /** @nodocs */
22
23
  export const Args = z.strictObject({
23
24
  _: z
24
25
  .array(Raw_Input_Path)
@@ -35,6 +36,7 @@ export const Args = z.strictObject({
35
36
  });
36
37
  export type Args = z.infer<typeof Args>;
37
38
 
39
+ /** @nodocs */
38
40
  export const task: Task<Args> = {
39
41
  summary: 'run code generation scripts',
40
42
  Args,
@@ -16,7 +16,7 @@ import {
16
16
  } from './constants.ts';
17
17
  import create_default_config from './gro.config.default.ts';
18
18
  import type {Create_Config_Plugins} from './plugin.ts';
19
- import type {Map_Package_Json} from './package_json.ts';
19
+ import type {Package_Json_Mapper} from './package_json.ts';
20
20
  import type {Parsed_Svelte_Config} from './svelte_config.ts';
21
21
  import {to_hash} from './hash.ts';
22
22
 
@@ -42,7 +42,7 @@ export interface Gro_Config extends Raw_Gro_Config {
42
42
  * The `package_json` argument may be mutated, but the return value is what's used by the caller.
43
43
  * Returning `null` is a no-op for the caller.
44
44
  */
45
- map_package_json: Map_Package_Json | null;
45
+ map_package_json: Package_Json_Mapper | null;
46
46
  /**
47
47
  * The root directories to search for tasks given implicit relative input paths.
48
48
  * Defaults to `./src/lib`, then the cwd, then the Gro package dist.
@@ -79,7 +79,7 @@ export interface Gro_Config extends Raw_Gro_Config {
79
79
  */
80
80
  export interface Raw_Gro_Config {
81
81
  plugins?: Create_Config_Plugins;
82
- map_package_json?: Map_Package_Json | null;
82
+ map_package_json?: Package_Json_Mapper | null;
83
83
  task_root_dirs?: Array<string>;
84
84
  search_filters?: Path_Filter | Array<Path_Filter> | null;
85
85
  js_cli?: string;
@@ -4,10 +4,14 @@ import {dirname, join} from 'node:path';
4
4
 
5
5
  import type {Plugin} from './plugin.ts';
6
6
  import {serialize_args, to_forwarded_args} from './args.ts';
7
- import {serialize_package_json, type Map_Package_Json, load_package_json} from './package_json.ts';
7
+ import {
8
+ serialize_package_json,
9
+ type Package_Json_Mapper,
10
+ load_package_json,
11
+ } from './package_json.ts';
8
12
  import {Task_Error} from './task.ts';
9
13
  import {find_cli, spawn_cli, spawn_cli_process} from './cli.ts';
10
- import {type Map_Src_Json, serialize_src_json, create_src_json} from './src_json.ts';
14
+ import {type Src_Json_Mapper, src_json_serialize, src_json_create} from './src_json.ts';
11
15
  import {EXPORTS_EXCLUDER_DEFAULT} from './gro_config.ts';
12
16
  import {default_svelte_config} from './svelte_config.ts';
13
17
  import {SOURCE_DIRNAME, VITE_CLI} from './constants.ts';
@@ -23,13 +27,13 @@ export interface Gro_Plugin_Sveltekit_App_Options {
23
27
  * If truthy, adds `/.well-known/package.json` to the static output.
24
28
  * If a function, maps the value.
25
29
  */
26
- well_known_package_json?: boolean | Map_Package_Json;
30
+ well_known_package_json?: boolean | Package_Json_Mapper;
27
31
 
28
32
  /**
29
33
  * If truthy, adds `/.well-known/src.json` and `/.well-known/src/` to the static output.
30
34
  * If a function, maps the value.
31
35
  */
32
- well_known_src_json?: boolean | Map_Src_Json;
36
+ well_known_src_json?: boolean | Src_Json_Mapper;
33
37
 
34
38
  /**
35
39
  * If truthy, copies `src/` to `/.well-known/src/` to the static output.
@@ -91,7 +95,7 @@ export const gro_plugin_sveltekit_app = ({
91
95
 
92
96
  // `.well-known/src.json` and `.well-known/src/`
93
97
  const final_package_json = mapped_package_json ?? package_json;
94
- const src_json = create_src_json(final_package_json, undefined, log);
98
+ const src_json = src_json_create(final_package_json, undefined, log);
95
99
  if (well_known_src_json === undefined) {
96
100
  well_known_src_json = final_package_json.public; // eslint-disable-line no-param-reassign
97
101
  }
@@ -100,7 +104,7 @@ export const gro_plugin_sveltekit_app = ({
100
104
  : well_known_src_json === true
101
105
  ? src_json
102
106
  : await well_known_src_json(src_json);
103
- const serialized_src_json = mapped_src_json && serialize_src_json(mapped_src_json);
107
+ const serialized_src_json = mapped_src_json && src_json_serialize(mapped_src_json);
104
108
 
105
109
  // TODO this strategy means the files aren't available during development --
106
110
  // maybe a Vite middleware is best? what if this plugin added its plugin to your `vite.config.ts`?
package/src/lib/index.ts CHANGED
@@ -1,4 +1,8 @@
1
+ /** @nodocs */
1
2
  export type {Gro_Config, Create_Gro_Config, Raw_Gro_Config} from './gro_config.ts';
3
+ /** @nodocs */
2
4
  export {type Plugin, replace_plugin} from './plugin.ts';
5
+ /** @nodocs */
3
6
  export type {Gen, Gen_Context} from './gen.ts';
7
+ /** @nodocs */
4
8
  export {type Task, type Task_Context, Task_Error} from './task.ts';
@@ -7,12 +7,14 @@ import {find_cli, spawn_cli} from './cli.ts';
7
7
 
8
8
  const ESLINT_CLI = 'eslint';
9
9
 
10
+ /** @nodocs */
10
11
  export const Args = z.strictObject({
11
12
  _: z.array(z.string()).meta({description: 'paths to serve'}).default([]),
12
13
  eslint_cli: z.string().meta({description: 'the ESLint CLI to use'}).default(ESLINT_CLI),
13
14
  });
14
15
  export type Args = z.infer<typeof Args>;
15
16
 
17
+ /** @nodocs */
16
18
  export const task: Task<Args> = {
17
19
  summary: 'run eslint',
18
20
  Args,
package/src/lib/loader.ts CHANGED
@@ -76,6 +76,7 @@ const aliases = Object.entries(alias);
76
76
  const RAW_MATCHER = /(%3Fraw|\.css|\.svg)$/; // TODO others? configurable?
77
77
  const NODE_MODULES_MATCHER = new RegExp(escape_regexp('/' + NODE_MODULES_DIRNAME + '/'), 'u');
78
78
 
79
+ /** @nodocs */
79
80
  export const load: LoadHook = async (url, context, nextLoad) => {
80
81
  // console.log(`url`, url);
81
82
  if (SVELTEKIT_SHIM_APP_PATHS_MATCHER.test(url)) {
@@ -184,6 +185,7 @@ export const load: LoadHook = async (url, context, nextLoad) => {
184
185
  return nextLoad(url, context);
185
186
  };
186
187
 
188
+ /** @nodocs */
187
189
  export const resolve: ResolveHook = async (specifier, context, nextResolve) => {
188
190
  let s = specifier;
189
191
 
@@ -20,7 +20,7 @@ import {search_fs} from './search_fs.ts';
20
20
  import {has_sveltekit_library} from './sveltekit_helpers.ts';
21
21
  import {GITHUB_REPO_MATCHER} from './github.ts';
22
22
 
23
- export type Map_Package_Json = (
23
+ export type Package_Json_Mapper = (
24
24
  package_json: Package_Json,
25
25
  ) => Package_Json | null | Promise<Package_Json | null>;
26
26
 
@@ -52,7 +52,7 @@ export const load_package_json = (
52
52
  };
53
53
 
54
54
  export const sync_package_json = async (
55
- map_package_json: Map_Package_Json,
55
+ map_package_json: Package_Json_Mapper,
56
56
  log: Logger,
57
57
  write = true,
58
58
  dir = paths.root,
@@ -2,7 +2,7 @@ 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
+ import type {Identifier_Kind} from '@ryanatkn/belt/src_json.js';
6
6
  import type {Path_Id} from '@ryanatkn/belt/path.js';
7
7
 
8
8
  import {TS_MATCHER} from './constants.ts';
@@ -10,7 +10,7 @@ import {Parse_Exports_Context} from './parse_exports_context.ts';
10
10
 
11
11
  export interface Declaration {
12
12
  name: string;
13
- kind: Src_Module_Declaration_Kind | null;
13
+ kind: Identifier_Kind | null;
14
14
  }
15
15
 
16
16
  export type Export_Declaration = Flavored<Declaration, 'Export_Declaration'>;
@@ -1,6 +1,6 @@
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
+ import type {Identifier_Kind} from '@ryanatkn/belt/src_json.js';
4
4
 
5
5
  import type {Export_Declaration} from './parse_exports.ts';
6
6
 
@@ -13,7 +13,7 @@ export class Parse_Exports_Context {
13
13
  // Map of source file paths to their symbols
14
14
  readonly #file_symbols: Map<string, ts.Symbol> = new Map();
15
15
  // Cache for resolved symbols to avoid repeated resolution
16
- readonly #symbol_kind_cache: Map<ts.Symbol, Src_Module_Declaration_Kind> = new Map();
16
+ readonly #symbol_kind_cache: Map<ts.Symbol, Identifier_Kind> = new Map();
17
17
 
18
18
  readonly log: Logger | undefined;
19
19
  debug = process.env.DEBUG_EXPORTS === 'true';
@@ -75,10 +75,7 @@ export class Parse_Exports_Context {
75
75
  /**
76
76
  * Determine the kind of an export based on its symbol.
77
77
  */
78
- #determine_export_kind(
79
- source_file: ts.SourceFile,
80
- symbol: ts.Symbol,
81
- ): Src_Module_Declaration_Kind {
78
+ #determine_export_kind(source_file: ts.SourceFile, symbol: ts.Symbol): Identifier_Kind {
82
79
  // Check if this is a type-only export (no value export)
83
80
  if (this.#is_type_only_export(source_file, symbol)) {
84
81
  return 'type';
@@ -118,7 +115,7 @@ export class Parse_Exports_Context {
118
115
  /**
119
116
  * Infer the declaration kind from a symbol's declaration and type information.
120
117
  */
121
- #infer_declaration_kind(symbol: ts.Symbol): Src_Module_Declaration_Kind {
118
+ #infer_declaration_kind(symbol: ts.Symbol): Identifier_Kind {
122
119
  // Check symbol flags first for direct type matching
123
120
  if (this.#is_class_symbol(symbol)) {
124
121
  return 'class';
@@ -185,7 +182,7 @@ export class Parse_Exports_Context {
185
182
  /**
186
183
  * Infer the declaration kind from a specific declaration node.
187
184
  */
188
- #infer_kind_from_declaration(decl: ts.Declaration): Src_Module_Declaration_Kind | null {
185
+ #infer_kind_from_declaration(decl: ts.Declaration): Identifier_Kind | null {
189
186
  if (ts.isFunctionDeclaration(decl)) {
190
187
  return 'function';
191
188
  }
@@ -19,6 +19,7 @@ import {update_changelog} from './changelog.ts';
19
19
  import {load_from_env} from './env.ts';
20
20
  import {CHANGESET_CLI} from './changeset_helpers.ts';
21
21
 
22
+ /** @nodocs */
22
23
  export const Args = z.strictObject({
23
24
  branch: Git_Branch.describe('branch to publish from').default('main'),
24
25
  origin: Git_Origin.describe('git origin to publish from').default('origin'),
@@ -50,10 +51,18 @@ export const Args = z.strictObject({
50
51
  'no-build': z.boolean().meta({description: 'opt out of building'}).default(false),
51
52
  pull: z.boolean().meta({description: 'dual of no-pull'}).default(true),
52
53
  'no-pull': z.boolean().meta({description: 'opt out of git pull'}).default(false),
54
+ sync: z.boolean().meta({description: 'dual of no-sync'}).default(true),
55
+ 'no-sync': z.boolean().meta({description: 'opt out of gro sync'}).default(false),
56
+ install: z.boolean().meta({description: 'dual of no-install'}).default(true),
57
+ 'no-install': z
58
+ .boolean()
59
+ .meta({description: 'opt out of installing packages before publishing'})
60
+ .default(false),
53
61
  changeset_cli: z.string().meta({description: 'the changeset CLI to use'}).default(CHANGESET_CLI),
54
62
  });
55
63
  export type Args = z.infer<typeof Args>;
56
64
 
65
+ /** @nodocs */
57
66
  export const task: Task<Args> = {
58
67
  summary: 'bump version, publish to the configured registry, and git push',
59
68
  Args,
@@ -67,6 +76,8 @@ export const task: Task<Args> = {
67
76
  check,
68
77
  build,
69
78
  pull,
79
+ sync,
80
+ install,
70
81
  optional,
71
82
  changeset_cli,
72
83
  } = args;
@@ -104,7 +115,11 @@ export const task: Task<Args> = {
104
115
 
105
116
  // Install packages to ensure deps are current.
106
117
  // Handles cases like branch switches where package.json changed.
107
- await invoke_task('sync', {install: true});
118
+ // Skip gen because it will run after version bump.
119
+ if (sync || install) {
120
+ if (!sync) log.warn('sync is false but install is true, so running sync for install only');
121
+ await invoke_task('sync', {install, gen: false});
122
+ }
108
123
 
109
124
  // Check before proceeding, defaults to true.
110
125
  if (check) {
@@ -151,6 +166,10 @@ export const task: Task<Args> = {
151
166
  await update_changelog(parsed_repo_url.owner, parsed_repo_url.repo, changelog, token, log);
152
167
  }
153
168
 
169
+ // Regenerate files that depend on package.json version.
170
+ // The check above ensures gen is updated.
171
+ await invoke_task('gen');
172
+
154
173
  const package_json_after_versioning = load_package_json();
155
174
  version = package_json_after_versioning.version!;
156
175
  if (package_json.version === version) {
@@ -5,9 +5,11 @@ 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
+ /** @nodocs */
8
9
  export const Args = z.strictObject({});
9
10
  export type Args = z.infer<typeof Args>;
10
11
 
12
+ /** @nodocs */
11
13
  export const task: Task<Args> = {
12
14
  summary: `refreshes ${LOCKFILE_FILENAME} with the latest and cleanest deps`,
13
15
  Args,
@@ -4,9 +4,11 @@ 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
+ /** @nodocs */
7
8
  export const Args = z.strictObject({});
8
9
  export type Args = z.infer<typeof Args>;
9
10
 
11
+ /** @nodocs */
10
12
  export const task: Task<Args> = {
11
13
  summary: 'publish and deploy',
12
14
  Args,
@@ -4,12 +4,14 @@ 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
+ /** @nodocs */
7
8
  export const Args = z.strictObject({
8
9
  _: z.array(z.string()).meta({description: 'the input paths to resolve'}).default(['']),
9
10
  verbose: z.boolean().meta({description: 'log diagnostics'}).default(false),
10
11
  });
11
12
  export type Args = z.infer<typeof Args>;
12
13
 
14
+ /** @nodocs */
13
15
  export const task: Task<Args> = {
14
16
  summary: 'diagnostic that logs resolved filesystem info for the given input paths',
15
17
  Args,
@@ -9,6 +9,7 @@ import {resolve_gro_module_path, spawn_with_loader} from './gro_helpers.ts';
9
9
  // and I'm not using it for anything that couldn't be done with Node directly atm.
10
10
  // It could potentially be more useful if I keep building on the task system.
11
11
 
12
+ /** @nodocs */
12
13
  export const Args = z.strictObject({
13
14
  _: z
14
15
  .array(z.string())
@@ -17,6 +18,7 @@ export const Args = z.strictObject({
17
18
  });
18
19
  export type Args = z.infer<typeof Args>;
19
20
 
21
+ /** @nodocs */
20
22
  export const task: Task<Args> = {
21
23
  summary: 'execute a file with the loader, like `node` but works for TypeScript',
22
24
  Args,
@@ -3,7 +3,7 @@ import {ensure_end, strip_start} from '@ryanatkn/belt/string.js';
3
3
  import {existsSync} from 'node:fs';
4
4
  import ts from 'typescript';
5
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
+ import {Src_Json, type Module_Json, type Identifier_Kind} from '@ryanatkn/belt/src_json.js';
7
7
  import type {Logger} from '@ryanatkn/belt/log.js';
8
8
 
9
9
  import {paths, replace_extension} from './paths.ts';
@@ -11,9 +11,9 @@ import {parse_exports} from './parse_exports.ts';
11
11
  import {TS_MATCHER, SVELTE_MATCHER, JSON_MATCHER, CSS_MATCHER} from './constants.ts';
12
12
  import {search_fs} from './search_fs.ts';
13
13
 
14
- export type Map_Src_Json = (src_json: Src_Json) => Src_Json | null | Promise<Src_Json | null>;
14
+ export type Src_Json_Mapper = (src_json: Src_Json) => Src_Json | null | Promise<Src_Json | null>;
15
15
 
16
- export const create_src_json = (
16
+ export const src_json_create = (
17
17
  package_json: Package_Json,
18
18
  lib_path?: string,
19
19
  log?: Logger,
@@ -21,19 +21,19 @@ export const create_src_json = (
21
21
  Src_Json.parse({
22
22
  name: package_json.name,
23
23
  version: package_json.version,
24
- modules: to_src_modules(package_json.exports, lib_path, log),
24
+ modules: src_modules_create(package_json.exports, lib_path, log),
25
25
  });
26
26
 
27
- export const serialize_src_json = (src_json: Src_Json): string => {
28
- const parsed = Src_Json.parse(src_json); // TODO can parse do the logic that normalize does? see `.transform`
27
+ export const src_json_serialize = (src_json: Src_Json): string => {
28
+ const parsed = Src_Json.parse(src_json);
29
29
  return JSON.stringify(parsed, null, 2) + '\n';
30
30
  };
31
31
 
32
- export const to_src_modules = (
32
+ export const src_modules_create = (
33
33
  exports: Package_Json_Exports | undefined,
34
34
  lib_path = paths.lib,
35
35
  log?: Logger,
36
- ): Src_Modules | undefined => {
36
+ ): Array<Module_Json> | undefined => {
37
37
  if (!exports) return;
38
38
 
39
39
  const file_paths = collect_file_paths(exports, lib_path);
@@ -58,25 +58,26 @@ export const to_src_modules = (
58
58
  );
59
59
  }
60
60
 
61
- const result: Src_Modules = {};
61
+ const result: Array<Module_Json> = [];
62
62
 
63
63
  // Process each file
64
- for (const {export_key, file_path} of file_paths) {
64
+ for (const {file_path} of file_paths) {
65
65
  const relative_path = file_path.replace(ensure_end(lib_path, '/'), '');
66
66
 
67
- const declarations = parse_exports(file_path, program, undefined, log).map(({name, kind}) => ({
68
- name,
69
- kind,
70
- }));
67
+ const identifiers = parse_exports(file_path, program, undefined, log)
68
+ .filter((d): d is {name: string; kind: Identifier_Kind} => d.kind !== null) // TODO maybe dont filter out?
69
+ .map(({name, kind}) => ({name, kind}));
71
70
 
72
- result[export_key] = declarations.length
73
- ? {
74
- path: relative_path,
75
- declarations,
76
- }
77
- : {
78
- path: relative_path,
79
- };
71
+ result.push(
72
+ identifiers.length
73
+ ? {
74
+ path: relative_path,
75
+ identifiers,
76
+ }
77
+ : {
78
+ path: relative_path,
79
+ },
80
+ );
80
81
  }
81
82
 
82
83
  return result;
@@ -5,6 +5,7 @@ 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
+ /** @nodocs */
8
9
  export const Args = z.strictObject({
9
10
  sveltekit: z.boolean().meta({description: 'dual of no-sveltekit'}).default(true),
10
11
  'no-sveltekit': z.boolean().meta({description: 'opt out of svelte-kit sync'}).default(false),
@@ -16,6 +17,7 @@ export const Args = z.strictObject({
16
17
  });
17
18
  export type Args = z.infer<typeof Args>;
18
19
 
20
+ /** @nodocs */
19
21
  export const task: Task<Args> = {
20
22
  summary: 'run `gro gen`, update `package.json`, and optionally install packages to sync up',
21
23
  Args,
@@ -8,6 +8,7 @@ import {serialize_args, to_implicit_forwarded_args} from './args.ts';
8
8
  import {VITEST_CLI} from './constants.ts';
9
9
  import {paths} from './paths.ts';
10
10
 
11
+ /** @nodocs */
11
12
  export const Args = z.strictObject({
12
13
  _: z.array(z.string()).meta({description: 'file patterns to filter tests'}).default(['.test.']),
13
14
  dir: z.string().meta({description: 'working directory for tests'}).default(paths.source),
@@ -22,6 +23,7 @@ export const Args = z.strictObject({
22
23
  });
23
24
  export type Args = z.infer<typeof Args>;
24
25
 
26
+ /** @nodocs */
25
27
  export const task: Task<Args> = {
26
28
  summary: 'run tests with vitest',
27
29
  Args,
@@ -9,6 +9,7 @@ import {configure_colored_output_with_path_replacement} from './child_process_lo
9
9
  import {paths} from './paths.ts';
10
10
  import {SVELTE_CHECK_CLI} from './constants.ts';
11
11
 
12
+ /** @nodocs */
12
13
  export const Args = z.strictObject({
13
14
  svelte_check_cli: z
14
15
  .string()
@@ -26,6 +27,7 @@ export const Args = z.strictObject({
26
27
  });
27
28
  export type Args = z.infer<typeof Args>;
28
29
 
30
+ /** @nodocs */
29
31
  export const task: Task<Args> = {
30
32
  summary: 'run svelte-check or tsc on the project without emitting any files',
31
33
  Args,
@@ -9,6 +9,7 @@ import {spawn_cli} from './cli.ts';
9
9
  import {serialize_args, to_forwarded_args} from './args.ts';
10
10
  import {NODE_MODULES_DIRNAME} from './constants.ts';
11
11
 
12
+ /** @nodocs */
12
13
  export const Args = z.strictObject({
13
14
  _: z
14
15
  .array(z.string())
@@ -45,6 +46,7 @@ export const Args = z.strictObject({
45
46
  });
46
47
  export type Args = z.infer<typeof Args>;
47
48
 
49
+ /** @nodocs */
48
50
  export const task: Task<Args> = {
49
51
  summary: 'upgrade deps',
50
52
  Args,
package/dist/package.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import type { Package_Json } from '@ryanatkn/belt/package_json.js';
2
- import type { Src_Json } from '@ryanatkn/belt/src_json.js';
3
- export declare const package_json: Package_Json;
4
- export declare const src_json: Src_Json;
5
- //# sourceMappingURL=package.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"package.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/package.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,4BAA4B,CAAC;AAEzD,eAAO,MAAM,YAAY,EAAE,YAkGnB,CAAC;AAET,eAAO,MAAM,QAAQ,EAAE,QAuwBf,CAAC"}
@@ -1,8 +0,0 @@
1
- import type { Gen } from './gen.ts';
2
- /**
3
- * A convenience `gen` file that outputs `$lib/package.ts`,
4
- * which mirrors `package.json` but in TypeScript,
5
- * allowing apps to import typesafe data from their own `package.json`.
6
- */
7
- export declare const gen: Gen;
8
- //# sourceMappingURL=package.gen.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"package.gen.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/package.gen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,UAAU,CAAC;AAMlC;;;;GAIG;AACH,eAAO,MAAM,GAAG,EAAE,GAwBjB,CAAC"}
@@ -1,30 +0,0 @@
1
- import { load_package_json } from "./package_json.js";
2
- import { create_src_json } from "./src_json.js";
3
- // TODO rename? `Package_Json + Src_Json = package.ts` currently, idk
4
- // TODO consider an api that uses magic imports like SvelteKit's `$app`, like `$repo/package.json`
5
- /**
6
- * A convenience `gen` file that outputs `$lib/package.ts`,
7
- * which mirrors `package.json` but in TypeScript,
8
- * allowing apps to import typesafe data from their own `package.json`.
9
- */
10
- export const gen = ({ origin_path, log }) => {
11
- const package_json = load_package_json();
12
- // TODO this can error with bad json data, do we need to update the package.json here first?
13
- // similarly do this in other places too?
14
- // part of the problem is that the package_json actually has a dependency on each of its exports and their deps,
15
- // but only when they're added/removed right? see gro_plugin_gen for details
16
- const src_json = create_src_json(package_json, undefined, log);
17
- const is_this_belt = package_json.name === '@ryanatkn/belt'; // TODO more robust?
18
- return `
19
- // generated by ${origin_path}
20
-
21
- import type {Package_Json} from '${is_this_belt ? '$lib/package_json.js' : '@ryanatkn/belt/package_json.js'}';
22
- import type {Src_Json} from '${is_this_belt ? '$lib/src_json.js' : '@ryanatkn/belt/src_json.js'}';
23
-
24
- export const package_json: Package_Json = ${JSON.stringify(package_json)} as any;
25
-
26
- export const src_json: Src_Json = ${JSON.stringify(src_json)} as any;
27
-
28
- // generated by ${origin_path}
29
- `;
30
- };