@ryanatkn/gro 0.144.1 → 0.146.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.
@@ -1 +1 @@
1
- {"version":3,"file":"gro.config.default.d.ts","sourceRoot":"../src/lib/","sources":["gro.config.default.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAQvD;;;;;;;;GAQG;AACH,QAAA,MAAM,MAAM,EAAE,iBA0Bb,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"gro.config.default.d.ts","sourceRoot":"../src/lib/","sources":["gro.config.default.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAQvD;;;;;;;;GAQG;AACH,QAAA,MAAM,MAAM,EAAE,iBAwBb,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -3,7 +3,7 @@ import { has_server, gro_plugin_server } from './gro_plugin_server.js';
3
3
  import { gro_plugin_sveltekit_app } from './gro_plugin_sveltekit_app.js';
4
4
  import { has_sveltekit_app, has_sveltekit_library } from './sveltekit_helpers.js';
5
5
  import { gro_plugin_gen } from './gro_plugin_gen.js';
6
- import { gro_plugin_moss, has_moss_dep } from './gro_plugin_moss.js';
6
+ import { has_dep, load_package_json } from './package_json.js';
7
7
  /**
8
8
  * This is the default config that's passed to `gro.config.ts`
9
9
  * if it exists in the current project, and if not, this is the final config.
@@ -14,15 +14,16 @@ import { gro_plugin_moss, has_moss_dep } from './gro_plugin_moss.js';
14
14
  * - if `src/lib/server/server.ts`, assumes a Node server
15
15
  */
16
16
  const config = async (cfg) => {
17
- const [moss_plugin_result, has_server_result, has_sveltekit_library_result, has_sveltekit_app_result,] = await Promise.all([
18
- has_moss_dep(),
17
+ const package_json = load_package_json(); // TODO gets wastefully loaded by some plugins, maybe put in plugin/task context? how does that interact with `map_package_json`?
18
+ const [has_moss_dep, has_server_result, has_sveltekit_library_result, has_sveltekit_app_result] = await Promise.all([
19
+ has_dep('@ryanatkn/moss', package_json),
19
20
  has_server(),
20
- has_sveltekit_library(),
21
+ has_sveltekit_library(package_json),
21
22
  has_sveltekit_app(),
22
23
  ]);
23
- cfg.plugins = () => [
24
+ cfg.plugins = async () => [
24
25
  // put things that generate files before SvelteKit so it can see them
25
- moss_plugin_result.ok ? gro_plugin_moss() : null,
26
+ has_moss_dep ? (await import('./gro_plugin_moss.js')).gro_plugin_moss() : null, // lazy load to avoid errors if it's not installed
26
27
  gro_plugin_gen(),
27
28
  has_server_result.ok ? gro_plugin_server() : null,
28
29
  has_sveltekit_library_result.ok ? gro_plugin_sveltekit_library() : null,
@@ -1,22 +1,15 @@
1
- import type { Result } from '@ryanatkn/belt/result.js';
2
1
  import type { Plugin } from './plugin.js';
3
2
  import type { Args } from './args.js';
4
3
  import type { File_Filter } from './path.js';
5
- import { type Package_Json } from './package_json.js';
6
- export declare const MOSS_PACKAGE_DEP_NAME = "@ryanatkn/moss";
7
- export declare const has_moss_dep: (package_json?: Package_Json, dep_name?: string) => Result<object, {
8
- message: string;
9
- }>;
10
- export declare const generate_classes_css: (classes: Iterable<string>) => string;
11
4
  export interface Task_Args extends Args {
12
5
  watch?: boolean;
13
6
  }
14
- export interface Options {
7
+ export interface Gro_Plugin_Moss_Options {
15
8
  include_classes?: string[] | Set<string> | null;
16
9
  outfile?: string;
17
10
  filter_file?: File_Filter | null;
18
11
  flush_debounce_delay?: number;
19
12
  banner?: string;
20
13
  }
21
- export declare const gro_plugin_moss: ({ include_classes, outfile, filter_file, flush_debounce_delay, banner, }?: Options) => Plugin;
14
+ export declare const gro_plugin_moss: ({ include_classes, outfile, filter_file, flush_debounce_delay, banner, }?: Gro_Plugin_Moss_Options) => Plugin;
22
15
  //# sourceMappingURL=gro_plugin_moss.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gro_plugin_moss.d.ts","sourceRoot":"../src/lib/","sources":["gro_plugin_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Q,IAAI;IACtC,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,uBAAuB;IACvC,eAAe,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACjC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,eAAe,8EAMzB,uBAAuB,KAAkB,MAmE3C,CAAC"}
@@ -2,40 +2,9 @@ import { EMPTY_OBJECT } from '@ryanatkn/belt/object.js';
2
2
  import { throttle } from '@ryanatkn/belt/throttle.js';
3
3
  import { Unreachable_Error } from '@ryanatkn/belt/error.js';
4
4
  import { writeFileSync } from 'node:fs';
5
- import { collect_css_classes, Css_Classes } from '@ryanatkn/moss/css_class_helpers.js';
5
+ import { collect_css_classes, Css_Classes, generate_classes_css, } from '@ryanatkn/moss/css_class_helpers.js';
6
6
  import { css_classes_by_name } from '@ryanatkn/moss/css_classes.js';
7
7
  import { format_file } from './format_file.js';
8
- import { has_dep } from './package_json.js';
9
- export const MOSS_PACKAGE_DEP_NAME = '@ryanatkn/moss';
10
- export const has_moss_dep = (package_json, dep_name = MOSS_PACKAGE_DEP_NAME) => {
11
- if (!has_dep(dep_name, package_json)) {
12
- return {
13
- ok: false,
14
- message: `no dependency found in package.json for ${dep_name}`,
15
- };
16
- }
17
- return { ok: true };
18
- };
19
- export const generate_classes_css = (classes) => {
20
- let css = '';
21
- for (const c of classes) {
22
- const v = css_classes_by_name[c];
23
- if (!v) {
24
- // diagnostic
25
- // if (!/^[a-z_0-9]+$/.test(c)) {
26
- // console.error('invalid class detected, fix the regexps', c);
27
- // }
28
- continue;
29
- }
30
- if ('declaration' in v) {
31
- css += `.${c} { ${v.declaration} }\n`;
32
- }
33
- else {
34
- css += v.ruleset + '\n';
35
- }
36
- }
37
- return css;
38
- };
39
8
  const FLUSH_DEBOUNCE_DELAY = 500;
40
9
  export const gro_plugin_moss = ({ include_classes = null, outfile = 'src/routes/moss.css', // TODO maybe support multiple files using file filters to check where to collect them?
41
10
  filter_file = (p) => !p.includes('.test.') && !p.includes('/test/'), flush_debounce_delay = FLUSH_DEBOUNCE_DELAY, banner = 'generated by gro_plugin_moss', } = EMPTY_OBJECT) => {
@@ -51,7 +20,7 @@ filter_file = (p) => !p.includes('.test.') && !p.includes('/test/'), flush_debou
51
20
  }
52
21
  };
53
22
  const flush_gen_queue = throttle(async () => {
54
- const css = generate_classes_css(css_classes.get_sorted_array());
23
+ const css = generate_classes_css(css_classes.get_sorted_array(), css_classes_by_name);
55
24
  const contents = `/* ${banner} */\n\n${css}\n\n/* ${banner} */`;
56
25
  const output = await format_file(contents, { filepath: outfile });
57
26
  // TODO think about using gen to implement this, would have some nice benefits like automatic change detection
@@ -1 +1 @@
1
- {"version":3,"file":"gro_plugin_sveltekit_library.d.ts","sourceRoot":"../src/lib/","sources":["gro_plugin_sveltekit_library.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAGxC,OAAO,EAGN,KAAK,sBAAsB,EAC3B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,oCAAoC;IACpD;;;OAGG;IACH,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;IAChD;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,4BAA4B,qDAGtC,oCAAoC,KAAQ,MA8B9C,CAAC"}
1
+ {"version":3,"file":"gro_plugin_sveltekit_library.d.ts","sourceRoot":"../src/lib/","sources":["gro_plugin_sveltekit_library.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAGxC,OAAO,EAGN,KAAK,sBAAsB,EAC3B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,oCAAoC;IACpD;;;OAGG;IACH,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;IAChD;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,4BAA4B,qDAGtC,oCAAoC,KAAQ,MAoC9C,CAAC"}
@@ -3,15 +3,15 @@ import { Task_Error } from './task.js';
3
3
  import { load_package_json } from './package_json.js';
4
4
  import { SVELTE_PACKAGE_CLI, run_svelte_package, } from './sveltekit_helpers.js';
5
5
  export const gro_plugin_sveltekit_library = ({ svelte_package_options, svelte_package_cli = SVELTE_PACKAGE_CLI, } = {}) => {
6
+ const package_json = load_package_json();
6
7
  return {
7
8
  name: 'gro_plugin_sveltekit_library',
8
9
  setup: async ({ dev, log, config }) => {
9
10
  if (!dev) {
10
- await run_svelte_package(svelte_package_options, svelte_package_cli, log, config.pm_cli);
11
+ await run_svelte_package(package_json, svelte_package_options, svelte_package_cli, log, config.pm_cli);
11
12
  }
12
13
  },
13
14
  adapt: async ({ log, timings, config }) => {
14
- const package_json = load_package_json();
15
15
  // link the CLI binaries if they exist
16
16
  if (package_json.bin) {
17
17
  const timing_to_link = timings.start(`${config.pm_cli} link`);
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"../src/lib/","sources":["loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,QAAQ,EAAE,WAAW,EAAC,MAAM,aAAa,CAAC;AAgFvD,eAAO,MAAM,IAAI,EAAE,QAwFlB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,WA4DrB,CAAC"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"../src/lib/","sources":["loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,QAAQ,EAAE,WAAW,EAAC,MAAM,aAAa,CAAC;AAgFvD,eAAO,MAAM,IAAI,EAAE,QAwFlB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,WA6DrB,CAAC"}
package/dist/loader.js CHANGED
@@ -148,6 +148,7 @@ export const resolve = async (specifier, context, nextResolve) => {
148
148
  }
149
149
  // Special case for Gro's dependencies that import into Gro.
150
150
  // Without this, we'd need to add a dev dep to Gro for Gro, which causes problems.
151
+ // TODO maybe make this generic, checking `package_json.name` against `s` and map it, possibly need to export `resolve_exported_value`
151
152
  if (IS_THIS_GRO && s.startsWith('@ryanatkn/gro')) {
152
153
  s = join(dir, 'dist', s.substring(13));
153
154
  }
package/dist/package.d.ts CHANGED
@@ -285,10 +285,6 @@ export declare const package_json: {
285
285
  types: string;
286
286
  default: string;
287
287
  };
288
- './moss_helpers.js': {
289
- types: string;
290
- default: string;
291
- };
292
288
  './package_json.js': {
293
289
  types: string;
294
290
  default: string;
@@ -746,13 +742,10 @@ export declare const src_json: {
746
742
  path: string;
747
743
  declarations: ({
748
744
  name: string;
749
- kind: "variable";
745
+ kind: "type";
750
746
  } | {
751
747
  name: string;
752
748
  kind: "function";
753
- } | {
754
- name: string;
755
- kind: "type";
756
749
  })[];
757
750
  };
758
751
  './gro_plugin_server.js': {
@@ -864,16 +857,6 @@ export declare const src_json: {
864
857
  kind: "function";
865
858
  })[];
866
859
  };
867
- './moss_helpers.js': {
868
- path: string;
869
- declarations: ({
870
- name: string;
871
- kind: "variable";
872
- } | {
873
- name: string;
874
- kind: "function";
875
- })[];
876
- };
877
860
  './package_json.js': {
878
861
  path: string;
879
862
  declarations: ({
@@ -1 +1 @@
1
- {"version":3,"file":"package.d.ts","sourceRoot":"../src/lib/","sources":["package.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2wBD,CAAC"}
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.144.1',
4
+ version: '0.146.0',
5
5
  description: 'task runner and toolkit extending SvelteKit',
6
6
  motto: 'generate, run, optimize',
7
7
  glyph: '🌰',
@@ -55,22 +55,22 @@ export const package_json = {
55
55
  devDependencies: {
56
56
  '@changesets/changelog-git': '^0.2.0',
57
57
  '@changesets/types': '^6.0.0',
58
- '@ryanatkn/eslint-config': '^0.5.5',
58
+ '@ryanatkn/eslint-config': '^0.5.6',
59
59
  '@ryanatkn/fuz': '^0.130.3',
60
- '@ryanatkn/moss': '^0.19.0',
60
+ '@ryanatkn/moss': '^0.20.0',
61
61
  '@sveltejs/adapter-static': '^3.0.6',
62
62
  '@sveltejs/kit': '^2.7.3',
63
63
  '@sveltejs/package': '^2.3.7',
64
64
  '@sveltejs/vite-plugin-svelte': '^4.0.0',
65
65
  '@types/fs-extra': '^11.0.4',
66
- '@types/node': '^22.8.4',
66
+ '@types/node': '^22.8.5',
67
67
  esbuild: '^0.21.5',
68
68
  eslint: '^9.13.0',
69
69
  'eslint-plugin-svelte': '^2.46.0',
70
- svelte: '^5.1.5',
70
+ svelte: '^5.1.6',
71
71
  'svelte-check': '^4.0.5',
72
72
  typescript: '^5.6.3',
73
- 'typescript-eslint': '^8.12.1',
73
+ 'typescript-eslint': '^8.12.2',
74
74
  uvu: '^0.5.6',
75
75
  },
76
76
  prettier: {
@@ -181,7 +181,6 @@ export const package_json = {
181
181
  './loader.js': { types: './dist/loader.d.ts', default: './dist/loader.js' },
182
182
  './module.js': { types: './dist/module.d.ts', default: './dist/module.js' },
183
183
  './modules.js': { types: './dist/modules.d.ts', default: './dist/modules.js' },
184
- './moss_helpers.js': { types: './dist/moss_helpers.d.ts', default: './dist/moss_helpers.js' },
185
184
  './package_json.js': { types: './dist/package_json.d.ts', default: './dist/package_json.js' },
186
185
  './package_meta.js': { types: './dist/package_meta.d.ts', default: './dist/package_meta.js' },
187
186
  './package.gen.js': { types: './dist/package.gen.d.ts', default: './dist/package.gen.js' },
@@ -265,7 +264,7 @@ export const package_json = {
265
264
  };
266
265
  export const src_json = {
267
266
  name: '@ryanatkn/gro',
268
- version: '0.144.1',
267
+ version: '0.146.0',
269
268
  modules: {
270
269
  '.': {
271
270
  path: 'index.ts',
@@ -600,11 +599,8 @@ export const src_json = {
600
599
  './gro_plugin_moss.js': {
601
600
  path: 'gro_plugin_moss.ts',
602
601
  declarations: [
603
- { name: 'MOSS_PACKAGE_DEP_NAME', kind: 'variable' },
604
- { name: 'has_moss_dep', kind: 'function' },
605
- { name: 'generate_classes_css', kind: 'function' },
606
602
  { name: 'Task_Args', kind: 'type' },
607
- { name: 'Options', kind: 'type' },
603
+ { name: 'Gro_Plugin_Moss_Options', kind: 'type' },
608
604
  { name: 'gro_plugin_moss', kind: 'function' },
609
605
  ],
610
606
  },
@@ -697,13 +693,6 @@ export const src_json = {
697
693
  { name: 'load_modules', kind: 'function' },
698
694
  ],
699
695
  },
700
- './moss_helpers.js': {
701
- path: 'moss_helpers.ts',
702
- declarations: [
703
- { name: 'MOSS_PACKAGE_DEP_NAME', kind: 'variable' },
704
- { name: 'load_moss_plugin', kind: 'function' },
705
- ],
706
- },
707
696
  './package_json.js': {
708
697
  path: 'package_json.ts',
709
698
  declarations: [
@@ -1 +1 @@
1
- {"version":3,"file":"publish.task.d.ts","sourceRoot":"../src/lib/","sources":["publish.task.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAItB,OAAO,EAAa,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAgBhD,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBP,CAAC;AACX,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CA0I3B,CAAC"}
1
+ {"version":3,"file":"publish.task.d.ts","sourceRoot":"../src/lib/","sources":["publish.task.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAItB,OAAO,EAAa,KAAK,IAAI,EAAC,MAAM,WAAW,CAAC;AAgBhD,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBP,CAAC;AACX,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CA2I3B,CAAC"}
@@ -43,7 +43,8 @@ export const task = {
43
43
  if (dry) {
44
44
  log.info(st('green', 'dry run!'));
45
45
  }
46
- const has_sveltekit_library_result = has_sveltekit_library();
46
+ const package_json = load_package_json();
47
+ const has_sveltekit_library_result = has_sveltekit_library(package_json);
47
48
  if (!has_sveltekit_library_result.ok) {
48
49
  throw new Task_Error('Failed to find SvelteKit library: ' + has_sveltekit_library_result.message);
49
50
  }
@@ -76,11 +77,10 @@ export const task = {
76
77
  log.info('dry run, skipping changeset version');
77
78
  }
78
79
  else {
79
- const package_json_before = load_package_json();
80
- if (typeof package_json_before.version !== 'string') {
80
+ if (typeof package_json.version !== 'string') {
81
81
  throw new Task_Error('Failed to find package.json version');
82
82
  }
83
- const parsed_repo_url = parse_repo_url(package_json_before);
83
+ const parsed_repo_url = parse_repo_url(package_json);
84
84
  if (!parsed_repo_url) {
85
85
  throw new Task_Error('package.json `repository` must contain a repo url (and GitHub only for now, sorry),' +
86
86
  ' like `git+https://github.com/ryanatkn/gro.git` or `https://github.com/ryanatkn/gro`' +
@@ -98,9 +98,9 @@ export const task = {
98
98
  }
99
99
  await update_changelog(parsed_repo_url.owner, parsed_repo_url.repo, changelog, token, log);
100
100
  }
101
- const package_json_after = load_package_json();
102
- version = package_json_after.version;
103
- if (package_json_before.version === version) {
101
+ const package_json_after_versioning = load_package_json();
102
+ version = package_json_after_versioning.version;
103
+ if (package_json.version === version) {
104
104
  // The version didn't change.
105
105
  // For now this is the best detection we have for a no-op `changeset version`.
106
106
  if (optional) {
@@ -1 +1 @@
1
- {"version":3,"file":"release.task.d.ts","sourceRoot":"../src/lib/","sources":["release.task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAGpC,eAAO,MAAM,IAAI,iDAAwB,CAAC;AAC1C,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CAY3B,CAAC"}
1
+ {"version":3,"file":"release.task.d.ts","sourceRoot":"../src/lib/","sources":["release.task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAIpC,eAAO,MAAM,IAAI,iDAAwB,CAAC;AAC1C,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAExC,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CAc3B,CAAC"}
@@ -1,11 +1,13 @@
1
1
  import { z } from 'zod';
2
2
  import { has_sveltekit_library, has_sveltekit_app } from './sveltekit_helpers.js';
3
+ import { load_package_json } from './package_json.js';
3
4
  export const Args = z.object({}).strict();
4
5
  export const task = {
5
6
  summary: 'publish and deploy',
6
7
  Args,
7
8
  run: async ({ invoke_task }) => {
8
- const publish = has_sveltekit_library().ok;
9
+ const package_json = load_package_json();
10
+ const publish = has_sveltekit_library(package_json).ok;
9
11
  if (publish) {
10
12
  await invoke_task('publish', { optional: true });
11
13
  }
@@ -1,7 +1,9 @@
1
1
  import { Package_Json } from './package_json.js';
2
2
  import type { Resolved_Specifier } from './resolve_specifier.js';
3
3
  /**
4
+ * Ideally Gro would just use `import.meta.resolve`, but it can't be used in custom loaders,
5
+ * which Gro relies on for TypeScript.
4
6
  * This likely has differences from Node - they should be fixed on a case-by-case basis.
5
7
  */
6
- export declare const resolve_node_specifier: (specifier: string, dir?: string, parent_path?: string, cache?: Record<string, Package_Json>, throw_on_missing_package?: boolean, exports_conditions?: string[]) => Resolved_Specifier | null;
8
+ export declare const resolve_node_specifier: (specifier: string, dir?: string, parent_path?: string, package_json_cache?: Record<string, Package_Json>, throw_on_missing_package?: boolean, exports_conditions?: string[]) => Resolved_Specifier | null;
7
9
  //# sourceMappingURL=resolve_node_specifier.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolve_node_specifier.d.ts","sourceRoot":"../src/lib/","sources":["resolve_node_specifier.ts"],"names":[],"mappings":"AAIA,OAAO,EAAe,YAAY,EAAoB,MAAM,mBAAmB,CAAC;AAGhF,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAG/D;;GAEG;AACH,eAAO,MAAM,sBAAsB,cACvB,MAAM,8BAEH,MAAM,UACZ,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,wEAGlC,kBAAkB,GAAG,IA6FvB,CAAC"}
1
+ {"version":3,"file":"resolve_node_specifier.d.ts","sourceRoot":"../src/lib/","sources":["resolve_node_specifier.ts"],"names":[],"mappings":"AAKA,OAAO,EAAe,YAAY,EAAoB,MAAM,mBAAmB,CAAC;AAGhF,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAE/D;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,cACvB,MAAM,8BAEH,MAAM,uBACC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,wEAG/C,kBAAkB,GAAG,IAsFvB,CAAC"}
@@ -1,40 +1,31 @@
1
1
  import { join, extname } from 'node:path';
2
2
  import { existsSync } from 'node:fs';
3
3
  import { DEV } from 'esm-env';
4
+ import { escape_regexp } from '@ryanatkn/belt/regexp.js';
4
5
  import { Export_Value, Package_Json, load_package_json } from './package_json.js';
5
6
  import { paths } from './paths.js';
6
7
  import { NODE_MODULES_DIRNAME } from './constants.js';
7
- import { escape_regexp } from '@ryanatkn/belt/regexp.js';
8
8
  /**
9
+ * Ideally Gro would just use `import.meta.resolve`, but it can't be used in custom loaders,
10
+ * which Gro relies on for TypeScript.
9
11
  * This likely has differences from Node - they should be fixed on a case-by-case basis.
10
12
  */
11
- export const resolve_node_specifier = (specifier, dir = paths.root, parent_path, cache, throw_on_missing_package = true, exports_conditions = DEV ? ['development', 'node', 'import'] : ['production', 'node', 'import']) => {
13
+ export const resolve_node_specifier = (specifier, dir = paths.root, parent_path, package_json_cache, throw_on_missing_package = true, exports_conditions = DEV ? ['development', 'node', 'import'] : ['production', 'node', 'import']) => {
12
14
  const raw = specifier.endsWith('?raw');
13
15
  const mapped_specifier = raw ? specifier.substring(0, specifier.length - 4) : specifier;
14
- // Parse the specifier
15
- let idx = -1;
16
- if (mapped_specifier[0] === '@') {
17
- let count = 0;
18
- for (let i = 0; i < mapped_specifier.length; i++) {
19
- if (mapped_specifier[i] === '/')
20
- count++;
21
- if (count === 2) {
22
- idx = i;
23
- break;
24
- }
25
- }
26
- }
27
- else {
28
- idx = mapped_specifier.indexOf('/');
29
- }
30
- const pkg_name = idx === -1 ? mapped_specifier : mapped_specifier.substring(0, idx);
31
- const module_path = idx === -1 ? '' : mapped_specifier.substring(idx + 1);
16
+ const specifier_slash_path_index = get_specifier_slash_path_index(mapped_specifier);
17
+ const pkg_name = specifier_slash_path_index === -1
18
+ ? mapped_specifier
19
+ : mapped_specifier.substring(0, specifier_slash_path_index);
20
+ const module_path = specifier_slash_path_index === -1
21
+ ? ''
22
+ : mapped_specifier.substring(specifier_slash_path_index + 1);
32
23
  const subpath = module_path ? './' + module_path : '.';
33
24
  const package_dir = join(dir, NODE_MODULES_DIRNAME, pkg_name);
34
- // Check cache first
25
+ // Check package_json cache first
35
26
  let package_json;
36
- if (cache?.[pkg_name]) {
37
- package_json = cache[pkg_name];
27
+ if (package_json_cache?.[pkg_name]) {
28
+ package_json = package_json_cache[pkg_name];
38
29
  }
39
30
  else if (!existsSync(package_dir)) {
40
31
  if (throw_on_missing_package) {
@@ -46,7 +37,7 @@ export const resolve_node_specifier = (specifier, dir = paths.root, parent_path,
46
37
  }
47
38
  }
48
39
  else {
49
- package_json = load_package_json(package_dir, cache, false);
40
+ package_json = load_package_json(package_dir, package_json_cache, false);
50
41
  }
51
42
  // Handle self-referencing
52
43
  if (parent_path?.startsWith(package_dir)) {
@@ -117,6 +108,7 @@ const resolve_subpath = (package_json, subpath) => {
117
108
  if (subpath in exports) {
118
109
  return exports[subpath];
119
110
  }
111
+ // TODO some of this may be wrong, will just need to patch as we go
120
112
  // Sort patterns by specificity
121
113
  const patterns = Object.entries(exports)
122
114
  .filter(([pattern]) => pattern.includes('*'))
@@ -207,8 +199,7 @@ const resolve_exported_value = (exported, conditions) => {
207
199
  return undefined;
208
200
  }
209
201
  const exported_obj = exported;
210
- // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
211
- let default_value;
202
+ let default_value; // eslint-disable-line @typescript-eslint/no-redundant-type-constituents
212
203
  // For each key in exported_obj, in order
213
204
  for (const [condition, value] of Object.entries(exported_obj)) {
214
205
  // Skip invalid conditions
@@ -295,3 +286,21 @@ const validate_export_target = (target, throw_on_missing_package) => {
295
286
  }
296
287
  }
297
288
  };
289
+ const get_specifier_slash_path_index = (mapped_specifier) => {
290
+ let index = -1;
291
+ if (mapped_specifier[0] === '@') {
292
+ let count = 0;
293
+ for (let i = 0; i < mapped_specifier.length; i++) {
294
+ if (mapped_specifier[i] === '/')
295
+ count++;
296
+ if (count === 2) {
297
+ index = i;
298
+ break;
299
+ }
300
+ }
301
+ }
302
+ else {
303
+ index = mapped_specifier.indexOf('/');
304
+ }
305
+ return index;
306
+ };
@@ -12,7 +12,7 @@ export declare const SVELTEKIT_ENV_MATCHER: RegExp;
12
12
  export declare const has_sveltekit_app: () => Result<object, {
13
13
  message: string;
14
14
  }>;
15
- export declare const has_sveltekit_library: (package_json?: Package_Json, sveltekit_config?: Parsed_Sveltekit_Config, dep_name?: string) => Result<object, {
15
+ export declare const has_sveltekit_library: (package_json: Package_Json, sveltekit_config?: Parsed_Sveltekit_Config, dep_name?: string) => Result<object, {
16
16
  message: string;
17
17
  }>;
18
18
  export declare const sveltekit_sync: (sveltekit_cli?: string | Cli, pm_cli?: string) => Promise<void>;
@@ -73,7 +73,7 @@ export interface Svelte_Package_Options {
73
73
  */
74
74
  tsconfig?: string;
75
75
  }
76
- export declare const run_svelte_package: (options: Svelte_Package_Options | undefined, cli: string | Cli, log: Logger, pm_cli: string) => Promise<void>;
76
+ export declare const run_svelte_package: (package_json: Package_Json, options: Svelte_Package_Options | undefined, cli: string | Cli, log: Logger, pm_cli: string) => Promise<void>;
77
77
  /**
78
78
  * Map an import specifier with the SvelteKit aliases.
79
79
  */
@@ -1 +1 @@
1
- {"version":3,"file":"sveltekit_helpers.d.ts","sourceRoot":"../src/lib/","sources":["sveltekit_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAErD,OAAO,KAAK,EAAC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
  return sveltekit_sync(found_sveltekit_cli);
69
69
  };
70
- export const run_svelte_package = async (options, cli, log, pm_cli) => {
71
- const has_sveltekit_library_result = has_sveltekit_library();
70
+ export const run_svelte_package = async (package_json, options, cli, log, pm_cli) => {
71
+ const has_sveltekit_library_result = has_sveltekit_library(package_json);
72
72
  if (!has_sveltekit_library_result.ok) {
73
73
  throw new Task_Error('Failed to find SvelteKit library: ' + has_sveltekit_library_result.message);
74
74
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryanatkn/gro",
3
- "version": "0.144.1",
3
+ "version": "0.146.0",
4
4
  "description": "task runner and toolkit extending SvelteKit",
5
5
  "motto": "generate, run, optimize",
6
6
  "glyph": "🌰",
@@ -68,22 +68,22 @@
68
68
  "devDependencies": {
69
69
  "@changesets/changelog-git": "^0.2.0",
70
70
  "@changesets/types": "^6.0.0",
71
- "@ryanatkn/eslint-config": "^0.5.5",
71
+ "@ryanatkn/eslint-config": "^0.5.6",
72
72
  "@ryanatkn/fuz": "^0.130.3",
73
- "@ryanatkn/moss": "^0.19.0",
73
+ "@ryanatkn/moss": "^0.20.0",
74
74
  "@sveltejs/adapter-static": "^3.0.6",
75
75
  "@sveltejs/kit": "^2.7.3",
76
76
  "@sveltejs/package": "^2.3.7",
77
77
  "@sveltejs/vite-plugin-svelte": "^4.0.0",
78
78
  "@types/fs-extra": "^11.0.4",
79
- "@types/node": "^22.8.4",
79
+ "@types/node": "^22.8.5",
80
80
  "esbuild": "^0.21.5",
81
81
  "eslint": "^9.13.0",
82
82
  "eslint-plugin-svelte": "^2.46.0",
83
- "svelte": "^5.1.5",
83
+ "svelte": "^5.1.6",
84
84
  "svelte-check": "^4.0.5",
85
85
  "typescript": "^5.6.3",
86
- "typescript-eslint": "^8.12.1",
86
+ "typescript-eslint": "^8.12.2",
87
87
  "uvu": "^0.5.6"
88
88
  },
89
89
  "prettier": {
@@ -306,10 +306,6 @@
306
306
  "types": "./dist/modules.d.ts",
307
307
  "default": "./dist/modules.js"
308
308
  },
309
- "./moss_helpers.js": {
310
- "types": "./dist/moss_helpers.d.ts",
311
- "default": "./dist/moss_helpers.js"
312
- },
313
309
  "./package_json.js": {
314
310
  "types": "./dist/package_json.d.ts",
315
311
  "default": "./dist/package_json.js"
@@ -4,7 +4,7 @@ import {has_server, gro_plugin_server} from './gro_plugin_server.js';
4
4
  import {gro_plugin_sveltekit_app} from './gro_plugin_sveltekit_app.js';
5
5
  import {has_sveltekit_app, has_sveltekit_library} from './sveltekit_helpers.js';
6
6
  import {gro_plugin_gen} from './gro_plugin_gen.js';
7
- import {gro_plugin_moss, has_moss_dep} from './gro_plugin_moss.js';
7
+ import {has_dep, load_package_json} from './package_json.js';
8
8
 
9
9
  /**
10
10
  * This is the default config that's passed to `gro.config.ts`
@@ -16,22 +16,20 @@ import {gro_plugin_moss, has_moss_dep} from './gro_plugin_moss.js';
16
16
  * - if `src/lib/server/server.ts`, assumes a Node server
17
17
  */
18
18
  const config: Create_Gro_Config = async (cfg) => {
19
- const [
20
- moss_plugin_result,
21
- has_server_result,
22
- has_sveltekit_library_result,
23
- has_sveltekit_app_result,
24
- ] = await Promise.all([
25
- has_moss_dep(),
26
- has_server(),
27
- has_sveltekit_library(),
28
- has_sveltekit_app(),
29
- ]);
19
+ const package_json = load_package_json(); // TODO gets wastefully loaded by some plugins, maybe put in plugin/task context? how does that interact with `map_package_json`?
30
20
 
31
- cfg.plugins = () =>
21
+ const [has_moss_dep, has_server_result, has_sveltekit_library_result, has_sveltekit_app_result] =
22
+ await Promise.all([
23
+ has_dep('@ryanatkn/moss', package_json),
24
+ has_server(),
25
+ has_sveltekit_library(package_json),
26
+ has_sveltekit_app(),
27
+ ]);
28
+
29
+ cfg.plugins = async () =>
32
30
  [
33
31
  // put things that generate files before SvelteKit so it can see them
34
- moss_plugin_result.ok ? gro_plugin_moss() : null,
32
+ has_moss_dep ? (await import('./gro_plugin_moss.js')).gro_plugin_moss() : null, // lazy load to avoid errors if it's not installed
35
33
  gro_plugin_gen(),
36
34
  has_server_result.ok ? gro_plugin_server() : null,
37
35
  has_sveltekit_library_result.ok ? gro_plugin_sveltekit_library() : null,
@@ -2,53 +2,18 @@ import {EMPTY_OBJECT} from '@ryanatkn/belt/object.js';
2
2
  import {throttle} from '@ryanatkn/belt/throttle.js';
3
3
  import {Unreachable_Error} from '@ryanatkn/belt/error.js';
4
4
  import {writeFileSync} from 'node:fs';
5
- import {collect_css_classes, Css_Classes} from '@ryanatkn/moss/css_class_helpers.js';
5
+ import {
6
+ collect_css_classes,
7
+ Css_Classes,
8
+ generate_classes_css,
9
+ } from '@ryanatkn/moss/css_class_helpers.js';
6
10
  import {css_classes_by_name} from '@ryanatkn/moss/css_classes.js';
7
- import type {Result} from '@ryanatkn/belt/result.js';
8
11
 
9
12
  import type {Plugin} from './plugin.js';
10
13
  import type {Args} from './args.js';
11
14
  import type {Cleanup_Watch} from './filer.js';
12
15
  import {format_file} from './format_file.js';
13
16
  import type {File_Filter} from './path.js';
14
- import {has_dep, type Package_Json} from './package_json.js';
15
-
16
- export const MOSS_PACKAGE_DEP_NAME = '@ryanatkn/moss';
17
-
18
- export const has_moss_dep = (
19
- package_json?: Package_Json,
20
- dep_name = MOSS_PACKAGE_DEP_NAME,
21
- ): Result<object, {message: string}> => {
22
- if (!has_dep(dep_name, package_json)) {
23
- return {
24
- ok: false,
25
- message: `no dependency found in package.json for ${dep_name}`,
26
- };
27
- }
28
-
29
- return {ok: true};
30
- };
31
-
32
- export const generate_classes_css = (classes: Iterable<string>): string => {
33
- let css = '';
34
- for (const c of classes) {
35
- const v = css_classes_by_name[c];
36
- if (!v) {
37
- // diagnostic
38
- // if (!/^[a-z_0-9]+$/.test(c)) {
39
- // console.error('invalid class detected, fix the regexps', c);
40
- // }
41
- continue;
42
- }
43
- if ('declaration' in v) {
44
- css += `.${c} { ${v.declaration} }\n`;
45
- } else {
46
- css += v.ruleset + '\n';
47
- }
48
- }
49
-
50
- return css;
51
- };
52
17
 
53
18
  const FLUSH_DEBOUNCE_DELAY = 500;
54
19
 
@@ -56,7 +21,7 @@ export interface Task_Args extends Args {
56
21
  watch?: boolean;
57
22
  }
58
23
 
59
- export interface Options {
24
+ export interface Gro_Plugin_Moss_Options {
60
25
  include_classes?: string[] | Set<string> | null;
61
26
  outfile?: string;
62
27
  filter_file?: File_Filter | null;
@@ -70,7 +35,7 @@ export const gro_plugin_moss = ({
70
35
  filter_file = (p) => !p.includes('.test.') && !p.includes('/test/'),
71
36
  flush_debounce_delay = FLUSH_DEBOUNCE_DELAY,
72
37
  banner = 'generated by gro_plugin_moss',
73
- }: Options = EMPTY_OBJECT): Plugin => {
38
+ }: Gro_Plugin_Moss_Options = EMPTY_OBJECT): Plugin => {
74
39
  const css_classes = new Css_Classes(
75
40
  Array.isArray(include_classes) ? new Set(include_classes) : include_classes,
76
41
  );
@@ -88,7 +53,7 @@ export const gro_plugin_moss = ({
88
53
  };
89
54
  const flush_gen_queue = throttle(
90
55
  async () => {
91
- const css = generate_classes_css(css_classes.get_sorted_array());
56
+ const css = generate_classes_css(css_classes.get_sorted_array(), css_classes_by_name);
92
57
  const contents = `/* ${banner} */\n\n${css}\n\n/* ${banner} */`;
93
58
  const output = await format_file(contents, {filepath: outfile});
94
59
  // TODO think about using gen to implement this, would have some nice benefits like automatic change detection
@@ -26,16 +26,22 @@ export const gro_plugin_sveltekit_library = ({
26
26
  svelte_package_options,
27
27
  svelte_package_cli = SVELTE_PACKAGE_CLI,
28
28
  }: Gro_Plugin_Sveltekit_Library_Options = {}): Plugin => {
29
+ const package_json = load_package_json();
30
+
29
31
  return {
30
32
  name: 'gro_plugin_sveltekit_library',
31
33
  setup: async ({dev, log, config}) => {
32
34
  if (!dev) {
33
- await run_svelte_package(svelte_package_options, svelte_package_cli, log, config.pm_cli);
35
+ await run_svelte_package(
36
+ package_json,
37
+ svelte_package_options,
38
+ svelte_package_cli,
39
+ log,
40
+ config.pm_cli,
41
+ );
34
42
  }
35
43
  },
36
44
  adapt: async ({log, timings, config}) => {
37
- const package_json = load_package_json();
38
-
39
45
  // link the CLI binaries if they exist
40
46
  if (package_json.bin) {
41
47
  const timing_to_link = timings.start(`${config.pm_cli} link`);
package/src/lib/loader.ts CHANGED
@@ -193,6 +193,7 @@ export const resolve: ResolveHook = async (specifier, context, nextResolve) => {
193
193
 
194
194
  // Special case for Gro's dependencies that import into Gro.
195
195
  // Without this, we'd need to add a dev dep to Gro for Gro, which causes problems.
196
+ // TODO maybe make this generic, checking `package_json.name` against `s` and map it, possibly need to export `resolve_exported_value`
196
197
  if (IS_THIS_GRO && s.startsWith('@ryanatkn/gro')) {
197
198
  s = join(dir, 'dist', s.substring(13));
198
199
  }
@@ -5,7 +5,7 @@ import type {Src_Json} from './src_json.js';
5
5
 
6
6
  export const package_json = {
7
7
  name: '@ryanatkn/gro',
8
- version: '0.144.1',
8
+ version: '0.146.0',
9
9
  description: 'task runner and toolkit extending SvelteKit',
10
10
  motto: 'generate, run, optimize',
11
11
  glyph: '🌰',
@@ -60,22 +60,22 @@ export const package_json = {
60
60
  devDependencies: {
61
61
  '@changesets/changelog-git': '^0.2.0',
62
62
  '@changesets/types': '^6.0.0',
63
- '@ryanatkn/eslint-config': '^0.5.5',
63
+ '@ryanatkn/eslint-config': '^0.5.6',
64
64
  '@ryanatkn/fuz': '^0.130.3',
65
- '@ryanatkn/moss': '^0.19.0',
65
+ '@ryanatkn/moss': '^0.20.0',
66
66
  '@sveltejs/adapter-static': '^3.0.6',
67
67
  '@sveltejs/kit': '^2.7.3',
68
68
  '@sveltejs/package': '^2.3.7',
69
69
  '@sveltejs/vite-plugin-svelte': '^4.0.0',
70
70
  '@types/fs-extra': '^11.0.4',
71
- '@types/node': '^22.8.4',
71
+ '@types/node': '^22.8.5',
72
72
  esbuild: '^0.21.5',
73
73
  eslint: '^9.13.0',
74
74
  'eslint-plugin-svelte': '^2.46.0',
75
- svelte: '^5.1.5',
75
+ svelte: '^5.1.6',
76
76
  'svelte-check': '^4.0.5',
77
77
  typescript: '^5.6.3',
78
- 'typescript-eslint': '^8.12.1',
78
+ 'typescript-eslint': '^8.12.2',
79
79
  uvu: '^0.5.6',
80
80
  },
81
81
  prettier: {
@@ -186,7 +186,6 @@ export const package_json = {
186
186
  './loader.js': {types: './dist/loader.d.ts', default: './dist/loader.js'},
187
187
  './module.js': {types: './dist/module.d.ts', default: './dist/module.js'},
188
188
  './modules.js': {types: './dist/modules.d.ts', default: './dist/modules.js'},
189
- './moss_helpers.js': {types: './dist/moss_helpers.d.ts', default: './dist/moss_helpers.js'},
190
189
  './package_json.js': {types: './dist/package_json.d.ts', default: './dist/package_json.js'},
191
190
  './package_meta.js': {types: './dist/package_meta.d.ts', default: './dist/package_meta.js'},
192
191
  './package.gen.js': {types: './dist/package.gen.d.ts', default: './dist/package.gen.js'},
@@ -271,7 +270,7 @@ export const package_json = {
271
270
 
272
271
  export const src_json = {
273
272
  name: '@ryanatkn/gro',
274
- version: '0.144.1',
273
+ version: '0.146.0',
275
274
  modules: {
276
275
  '.': {
277
276
  path: 'index.ts',
@@ -606,11 +605,8 @@ export const src_json = {
606
605
  './gro_plugin_moss.js': {
607
606
  path: 'gro_plugin_moss.ts',
608
607
  declarations: [
609
- {name: 'MOSS_PACKAGE_DEP_NAME', kind: 'variable'},
610
- {name: 'has_moss_dep', kind: 'function'},
611
- {name: 'generate_classes_css', kind: 'function'},
612
608
  {name: 'Task_Args', kind: 'type'},
613
- {name: 'Options', kind: 'type'},
609
+ {name: 'Gro_Plugin_Moss_Options', kind: 'type'},
614
610
  {name: 'gro_plugin_moss', kind: 'function'},
615
611
  ],
616
612
  },
@@ -703,13 +699,6 @@ export const src_json = {
703
699
  {name: 'load_modules', kind: 'function'},
704
700
  ],
705
701
  },
706
- './moss_helpers.js': {
707
- path: 'moss_helpers.ts',
708
- declarations: [
709
- {name: 'MOSS_PACKAGE_DEP_NAME', kind: 'variable'},
710
- {name: 'load_moss_plugin', kind: 'function'},
711
- ],
712
- },
713
702
  './package_json.js': {
714
703
  path: 'package_json.ts',
715
704
  declarations: [
@@ -67,7 +67,9 @@ export const task: Task<Args> = {
67
67
  log.info(st('green', 'dry run!'));
68
68
  }
69
69
 
70
- const has_sveltekit_library_result = has_sveltekit_library();
70
+ const package_json = load_package_json();
71
+
72
+ const has_sveltekit_library_result = has_sveltekit_library(package_json);
71
73
  if (!has_sveltekit_library_result.ok) {
72
74
  throw new Task_Error(
73
75
  'Failed to find SvelteKit library: ' + has_sveltekit_library_result.message,
@@ -109,11 +111,10 @@ export const task: Task<Args> = {
109
111
  if (dry) {
110
112
  log.info('dry run, skipping changeset version');
111
113
  } else {
112
- const package_json_before = load_package_json();
113
- if (typeof package_json_before.version !== 'string') {
114
+ if (typeof package_json.version !== 'string') {
114
115
  throw new Task_Error('Failed to find package.json version');
115
116
  }
116
- const parsed_repo_url = parse_repo_url(package_json_before);
117
+ const parsed_repo_url = parse_repo_url(package_json);
117
118
  if (!parsed_repo_url) {
118
119
  throw new Task_Error(
119
120
  'package.json `repository` must contain a repo url (and GitHub only for now, sorry),' +
@@ -139,9 +140,9 @@ export const task: Task<Args> = {
139
140
  await update_changelog(parsed_repo_url.owner, parsed_repo_url.repo, changelog, token, log);
140
141
  }
141
142
 
142
- const package_json_after = load_package_json();
143
- version = package_json_after.version!;
144
- if (package_json_before.version === version) {
143
+ const package_json_after_versioning = load_package_json();
144
+ version = package_json_after_versioning.version!;
145
+ if (package_json.version === version) {
145
146
  // The version didn't change.
146
147
  // For now this is the best detection we have for a no-op `changeset version`.
147
148
  if (optional) {
@@ -2,6 +2,7 @@ import {z} from 'zod';
2
2
 
3
3
  import type {Task} from './task.js';
4
4
  import {has_sveltekit_library, has_sveltekit_app} from './sveltekit_helpers.js';
5
+ import {load_package_json} from './package_json.js';
5
6
 
6
7
  export const Args = z.object({}).strict();
7
8
  export type Args = z.infer<typeof Args>;
@@ -10,7 +11,9 @@ export const task: Task<Args> = {
10
11
  summary: 'publish and deploy',
11
12
  Args,
12
13
  run: async ({invoke_task}) => {
13
- const publish = has_sveltekit_library().ok;
14
+ const package_json = load_package_json();
15
+
16
+ const publish = has_sveltekit_library(package_json).ok;
14
17
  if (publish) {
15
18
  await invoke_task('publish', {optional: true});
16
19
  }
@@ -1,51 +1,46 @@
1
1
  import {join, extname} from 'node:path';
2
2
  import {existsSync} from 'node:fs';
3
3
  import {DEV} from 'esm-env';
4
+ import {escape_regexp} from '@ryanatkn/belt/regexp.js';
4
5
 
5
6
  import {Export_Value, Package_Json, load_package_json} from './package_json.js';
6
7
  import {paths} from './paths.js';
7
8
  import {NODE_MODULES_DIRNAME} from './constants.js';
8
9
  import type {Resolved_Specifier} from './resolve_specifier.js';
9
- import {escape_regexp} from '@ryanatkn/belt/regexp.js';
10
10
 
11
11
  /**
12
+ * Ideally Gro would just use `import.meta.resolve`, but it can't be used in custom loaders,
13
+ * which Gro relies on for TypeScript.
12
14
  * This likely has differences from Node - they should be fixed on a case-by-case basis.
13
15
  */
14
16
  export const resolve_node_specifier = (
15
17
  specifier: string,
16
18
  dir = paths.root,
17
19
  parent_path?: string,
18
- cache?: Record<string, Package_Json>,
20
+ package_json_cache?: Record<string, Package_Json>,
19
21
  throw_on_missing_package = true,
20
22
  exports_conditions = DEV ? ['development', 'node', 'import'] : ['production', 'node', 'import'],
21
23
  ): Resolved_Specifier | null => {
22
24
  const raw = specifier.endsWith('?raw');
23
25
  const mapped_specifier = raw ? specifier.substring(0, specifier.length - 4) : specifier;
24
26
 
25
- // Parse the specifier
26
- let idx: number = -1;
27
- if (mapped_specifier[0] === '@') {
28
- let count = 0;
29
- for (let i = 0; i < mapped_specifier.length; i++) {
30
- if (mapped_specifier[i] === '/') count++;
31
- if (count === 2) {
32
- idx = i;
33
- break;
34
- }
35
- }
36
- } else {
37
- idx = mapped_specifier.indexOf('/');
38
- }
27
+ const specifier_slash_path_index = get_specifier_slash_path_index(mapped_specifier);
39
28
 
40
- const pkg_name = idx === -1 ? mapped_specifier : mapped_specifier.substring(0, idx);
41
- const module_path = idx === -1 ? '' : mapped_specifier.substring(idx + 1);
29
+ const pkg_name =
30
+ specifier_slash_path_index === -1
31
+ ? mapped_specifier
32
+ : mapped_specifier.substring(0, specifier_slash_path_index);
33
+ const module_path =
34
+ specifier_slash_path_index === -1
35
+ ? ''
36
+ : mapped_specifier.substring(specifier_slash_path_index + 1);
42
37
  const subpath = module_path ? './' + module_path : '.';
43
38
  const package_dir = join(dir, NODE_MODULES_DIRNAME, pkg_name);
44
39
 
45
- // Check cache first
40
+ // Check package_json cache first
46
41
  let package_json: Package_Json | undefined;
47
- if (cache?.[pkg_name]) {
48
- package_json = cache[pkg_name];
42
+ if (package_json_cache?.[pkg_name]) {
43
+ package_json = package_json_cache[pkg_name];
49
44
  } else if (!existsSync(package_dir)) {
50
45
  if (throw_on_missing_package) {
51
46
  throw Error(
@@ -56,7 +51,7 @@ export const resolve_node_specifier = (
56
51
  return null;
57
52
  }
58
53
  } else {
59
- package_json = load_package_json(package_dir, cache, false);
54
+ package_json = load_package_json(package_dir, package_json_cache, false);
60
55
  }
61
56
 
62
57
  // Handle self-referencing
@@ -144,6 +139,7 @@ const resolve_subpath = (package_json: Package_Json, subpath: string): unknown =
144
139
  return exports[subpath];
145
140
  }
146
141
 
142
+ // TODO some of this may be wrong, will just need to patch as we go
147
143
  // Sort patterns by specificity
148
144
  const patterns = Object.entries(exports)
149
145
  .filter(([pattern]) => pattern.includes('*'))
@@ -255,8 +251,7 @@ const resolve_exported_value = (
255
251
 
256
252
  const exported_obj = exported as Record<string, unknown>;
257
253
 
258
- // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
259
- let default_value: Export_Value | undefined;
254
+ let default_value: Export_Value | undefined; // eslint-disable-line @typescript-eslint/no-redundant-type-constituents
260
255
 
261
256
  // For each key in exported_obj, in order
262
257
  for (const [condition, value] of Object.entries(exported_obj)) {
@@ -354,3 +349,21 @@ const validate_export_target = (target: string, throw_on_missing_package: boolea
354
349
  }
355
350
  }
356
351
  };
352
+
353
+ const get_specifier_slash_path_index = (mapped_specifier: string): number => {
354
+ let index: number = -1;
355
+ if (mapped_specifier[0] === '@') {
356
+ let count = 0;
357
+ for (let i = 0; i < mapped_specifier.length; i++) {
358
+ if (mapped_specifier[i] === '/') count++;
359
+ if (count === 2) {
360
+ index = i;
361
+ break;
362
+ }
363
+ }
364
+ } else {
365
+ index = mapped_specifier.indexOf('/');
366
+ }
367
+
368
+ return index;
369
+ };
@@ -30,7 +30,7 @@ export const has_sveltekit_app = (): Result<object, {message: string}> => {
30
30
  };
31
31
 
32
32
  export const has_sveltekit_library = (
33
- package_json?: Package_Json,
33
+ package_json: Package_Json,
34
34
  sveltekit_config: Parsed_Sveltekit_Config = default_sveltekit_config,
35
35
  dep_name = SVELTE_PACKAGE_DEP_NAME,
36
36
  ): Result<object, {message: string}> => {
@@ -149,12 +149,13 @@ export interface Svelte_Package_Options {
149
149
  }
150
150
 
151
151
  export const run_svelte_package = async (
152
+ package_json: Package_Json,
152
153
  options: Svelte_Package_Options | undefined,
153
154
  cli: string | Cli,
154
155
  log: Logger,
155
156
  pm_cli: string,
156
157
  ): Promise<void> => {
157
- const has_sveltekit_library_result = has_sveltekit_library();
158
+ const has_sveltekit_library_result = has_sveltekit_library(package_json);
158
159
  if (!has_sveltekit_library_result.ok) {
159
160
  throw new Task_Error(
160
161
  'Failed to find SvelteKit library: ' + has_sveltekit_library_result.message,
@@ -1,9 +0,0 @@
1
- import type { Result } from '@ryanatkn/belt/result.js';
2
- import { type Package_Json } from './package_json.js';
3
- export declare const MOSS_PACKAGE_DEP_NAME = "@ryanatkn/moss";
4
- export declare const load_moss_plugin: (package_json?: Package_Json, dep_name?: string, plugin_path?: string, local_plugin_path?: string) => Promise<Result<{
5
- gro_plugin_moss: any;
6
- }, {
7
- message: string;
8
- }>>;
9
- //# sourceMappingURL=moss_helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"moss_helpers.d.ts","sourceRoot":"../src/lib/","sources":["moss_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAIrD,OAAO,EAAU,KAAK,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAG7D,eAAO,MAAM,qBAAqB,mBAAmB,CAAC;AAGtD,eAAO,MAAM,gBAAgB,kBACb,YAAY,0EAIzB,OAAO,CAAC,MAAM,CAAC;IAAC,eAAe,EAAE,GAAG,CAAA;CAAC,EAAE;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAAC,CA4B3D,CAAC"}
@@ -1,32 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import { resolve } from 'node:path';
3
- import { has_dep } from './package_json.js';
4
- import { NODE_MODULES_DIRNAME } from './constants.js';
5
- export const MOSS_PACKAGE_DEP_NAME = '@ryanatkn/moss';
6
- // TODO plugin type?
7
- export const load_moss_plugin = async (package_json, dep_name = MOSS_PACKAGE_DEP_NAME, plugin_path = `${NODE_MODULES_DIRNAME}/${dep_name}/dist/gro_plugin_moss.js`, // TODO maybe lookup from its `package_json.exports`? kinda unnecessary
8
- local_plugin_path = 'src/lib/gro_plugin_moss.ts') => {
9
- if (!has_dep(dep_name, package_json)) {
10
- return {
11
- ok: false,
12
- message: `no dependency found in package.json for ${dep_name}`,
13
- };
14
- }
15
- let path = undefined;
16
- const resolved_local_plugin_path = resolve(local_plugin_path);
17
- if (existsSync(resolved_local_plugin_path)) {
18
- path = resolved_local_plugin_path;
19
- }
20
- if (path === undefined) {
21
- path = resolve(plugin_path);
22
- if (!existsSync(path)) {
23
- return {
24
- ok: false,
25
- // TODO warn?
26
- message: `dependency on ${dep_name} detected but plugin not found at ${path}`,
27
- };
28
- }
29
- }
30
- const mod = await import(path);
31
- return { ok: true, gro_plugin_moss: mod.gro_plugin_moss };
32
- };
@@ -1,44 +0,0 @@
1
- import type {Result} from '@ryanatkn/belt/result.js';
2
- import {existsSync} from 'node:fs';
3
- import {resolve} from 'node:path';
4
-
5
- import {has_dep, type Package_Json} from './package_json.js';
6
- import {NODE_MODULES_DIRNAME} from './constants.js';
7
-
8
- export const MOSS_PACKAGE_DEP_NAME = '@ryanatkn/moss';
9
-
10
- // TODO plugin type?
11
- export const load_moss_plugin = async (
12
- package_json?: Package_Json,
13
- dep_name = MOSS_PACKAGE_DEP_NAME,
14
- plugin_path = `${NODE_MODULES_DIRNAME}/${dep_name}/dist/gro_plugin_moss.js`, // TODO maybe lookup from its `package_json.exports`? kinda unnecessary
15
- local_plugin_path = 'src/lib/gro_plugin_moss.ts',
16
- ): Promise<Result<{gro_plugin_moss: any}, {message: string}>> => {
17
- if (!has_dep(dep_name, package_json)) {
18
- return {
19
- ok: false,
20
- message: `no dependency found in package.json for ${dep_name}`,
21
- };
22
- }
23
-
24
- let path: string | undefined = undefined;
25
-
26
- const resolved_local_plugin_path = resolve(local_plugin_path);
27
- if (existsSync(resolved_local_plugin_path)) {
28
- path = resolved_local_plugin_path;
29
- }
30
-
31
- if (path === undefined) {
32
- path = resolve(plugin_path);
33
- if (!existsSync(path)) {
34
- return {
35
- ok: false,
36
- // TODO warn?
37
- message: `dependency on ${dep_name} detected but plugin not found at ${path}`,
38
- };
39
- }
40
- }
41
-
42
- const mod = await import(path);
43
- return {ok: true, gro_plugin_moss: mod.gro_plugin_moss};
44
- };