@ryanatkn/gro 0.139.0 → 0.139.2

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;AAOvD;;;;;;;;GAQG;AACH,QAAA,MAAM,MAAM,EAAE,iBAeb,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,iBA0Bb,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -3,6 +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 { load_moss_plugin } from './moss_helpers.js';
6
7
  /**
7
8
  * This is the default config that's passed to `gro.config.ts`
8
9
  * if it exists in the current project, and if not, this is the final config.
@@ -13,14 +14,21 @@ import { gro_plugin_gen } from './gro_plugin_gen.js';
13
14
  * - if `src/lib/server/server.ts`, assumes a Node server
14
15
  */
15
16
  const config = async (cfg) => {
16
- const [has_sveltekit_library_result, has_server_result, has_sveltekit_app_result] = await Promise.all([has_sveltekit_library(), has_server(), has_sveltekit_app()]);
17
+ const [moss_plugin_result, has_sveltekit_library_result, has_server_result, has_sveltekit_app_result,] = await Promise.all([
18
+ load_moss_plugin(),
19
+ has_sveltekit_library(),
20
+ has_server(),
21
+ has_sveltekit_app(),
22
+ ]);
17
23
  cfg.plugins = () => [
18
- has_sveltekit_library_result.ok ? gro_plugin_sveltekit_library() : null,
24
+ // put things that generate files before SvelteKit so it can see them
25
+ moss_plugin_result.ok ? moss_plugin_result.gro_plugin_moss() : null,
26
+ gro_plugin_gen(),
19
27
  has_server_result.ok ? gro_plugin_server() : null,
28
+ has_sveltekit_library_result.ok ? gro_plugin_sveltekit_library() : null,
20
29
  has_sveltekit_app_result.ok
21
30
  ? gro_plugin_sveltekit_app({ host_target: has_server_result.ok ? 'node' : 'github_pages' })
22
31
  : null,
23
- gro_plugin_gen(),
24
32
  ].filter((v) => v !== null);
25
33
  return cfg;
26
34
  };
@@ -0,0 +1,9 @@
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) => Promise<Result<{
5
+ gro_plugin_moss: any;
6
+ }, {
7
+ message: string;
8
+ }>>;
9
+ //# sourceMappingURL=moss_helpers.d.ts.map
@@ -0,0 +1 @@
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;AAE7D,eAAO,MAAM,qBAAqB,mBAAmB,CAAC;AAGtD,eAAO,MAAM,gBAAgB,kBACb,YAAY,8CAGzB,OAAO,CAAC,MAAM,CAAC;IAAC,eAAe,EAAE,GAAG,CAAA;CAAC,EAAE;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAAC,CAmB3D,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { resolve } from 'node:path';
3
+ import { has_dep } from './package_json.js';
4
+ export const MOSS_PACKAGE_DEP_NAME = '@ryanatkn/moss';
5
+ // TODO plugin type?
6
+ export const load_moss_plugin = async (package_json, dep_name = MOSS_PACKAGE_DEP_NAME, plugin_path = `node_modules/${dep_name}/dist/gro_plugin_moss.js`) => {
7
+ if (!has_dep(dep_name, package_json)) {
8
+ return {
9
+ ok: false,
10
+ message: `no dependency found in package.json for ${dep_name}, install it with \`npm i -D ${dep_name}\``,
11
+ };
12
+ }
13
+ const path = resolve(plugin_path);
14
+ if (!existsSync(path)) {
15
+ return {
16
+ ok: false,
17
+ // TODO warn?
18
+ message: `dependency on ${dep_name} detected but plugin not found at ${path}`,
19
+ };
20
+ }
21
+ const mod = await import(path);
22
+ return { ok: true, gro_plugin_moss: mod.gro_plugin_moss };
23
+ };
package/dist/package.d.ts CHANGED
@@ -277,6 +277,10 @@ export declare const package_json: {
277
277
  types: string;
278
278
  default: string;
279
279
  };
280
+ './moss_helpers.js': {
281
+ types: string;
282
+ default: string;
283
+ };
280
284
  './package_json.js': {
281
285
  types: string;
282
286
  default: string;
@@ -755,6 +759,13 @@ export declare const src_json: {
755
759
  kind: string;
756
760
  }[];
757
761
  };
762
+ './moss_helpers.js': {
763
+ path: string;
764
+ declarations: {
765
+ name: string;
766
+ kind: string;
767
+ }[];
768
+ };
758
769
  './package_json.js': {
759
770
  path: string;
760
771
  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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: '0.139.0',
4
+ version: '0.139.2',
5
5
  description: 'task runner and toolkit extending SvelteKit',
6
6
  motto: 'generate, run, optimize',
7
7
  glyph: '🌰',
@@ -57,7 +57,7 @@ export const package_json = {
57
57
  '@changesets/types': '^6.0.0',
58
58
  '@ryanatkn/eslint-config': '^0.5.4',
59
59
  '@ryanatkn/fuz': '^0.129.0',
60
- '@ryanatkn/moss': '^0.16.1',
60
+ '@ryanatkn/moss': '^0.18.0',
61
61
  '@sveltejs/adapter-static': '^3.0.5',
62
62
  '@sveltejs/kit': '^2.6.1',
63
63
  '@sveltejs/package': '^2.3.5',
@@ -176,6 +176,7 @@ export const package_json = {
176
176
  './loader.js': { types: './dist/loader.d.ts', default: './dist/loader.js' },
177
177
  './module.js': { types: './dist/module.d.ts', default: './dist/module.js' },
178
178
  './modules.js': { types: './dist/modules.d.ts', default: './dist/modules.js' },
179
+ './moss_helpers.js': { types: './dist/moss_helpers.d.ts', default: './dist/moss_helpers.js' },
179
180
  './package_json.js': { types: './dist/package_json.d.ts', default: './dist/package_json.js' },
180
181
  './package_meta.js': { types: './dist/package_meta.d.ts', default: './dist/package_meta.js' },
181
182
  './package.gen.js': { types: './dist/package.gen.d.ts', default: './dist/package.gen.js' },
@@ -263,7 +264,7 @@ export const package_json = {
263
264
  };
264
265
  export const src_json = {
265
266
  name: '@ryanatkn/gro',
266
- version: '0.139.0',
267
+ version: '0.139.2',
267
268
  modules: {
268
269
  '.': {
269
270
  path: 'index.ts',
@@ -651,6 +652,13 @@ export const src_json = {
651
652
  { name: 'load_modules', kind: 'function' },
652
653
  ],
653
654
  },
655
+ './moss_helpers.js': {
656
+ path: 'moss_helpers.ts',
657
+ declarations: [
658
+ { name: 'MOSS_PACKAGE_DEP_NAME', kind: 'variable' },
659
+ { name: 'load_moss_plugin', kind: 'function' },
660
+ ],
661
+ },
654
662
  './package_json.js': {
655
663
  path: 'package_json.ts',
656
664
  declarations: [
@@ -672,6 +680,9 @@ export const src_json = {
672
680
  { name: 'update_package_json', kind: 'function' },
673
681
  { name: 'to_package_exports', kind: 'function' },
674
682
  { name: 'parse_repo_url', kind: 'function' },
683
+ { name: 'has_dep', kind: 'function' },
684
+ { name: 'Package_Json_Dep', kind: 'type' },
685
+ { name: 'extract_deps', kind: 'function' },
675
686
  ],
676
687
  },
677
688
  './package_meta.js': {
@@ -377,4 +377,10 @@ export declare const parse_repo_url: (package_json: Package_Json) => {
377
377
  owner: string;
378
378
  repo: string;
379
379
  } | undefined;
380
+ export declare const has_dep: (dep_name: string, package_json?: Package_Json) => boolean;
381
+ export interface Package_Json_Dep {
382
+ name: string;
383
+ version: string;
384
+ }
385
+ export declare const extract_deps: (package_json: Package_Json) => Package_Json_Dep[];
380
386
  //# sourceMappingURL=package_json.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"package_json.d.ts","sourceRoot":"../src/lib/","sources":["package_json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAItB,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,yBAAyB,CAAC;AAUtD,eAAO,MAAM,GAAG,aAAa,CAAC;AAC9B,MAAM,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;AAGvD,eAAO,MAAM,KAAK,aAAa,CAAC;AAChC,MAAM,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;AAG7D,eAAO,MAAM,mCAAmC,QAAS,GAAG,KAAG,GAK9D,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;kCASlC,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE9E,eAAO,MAAM,mBA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E,eAAO,MAAM,iBAAiB,yBAErB,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,KAClC,YAaF,CAAC;AAEF,eAAO,MAAM,iBAAiB,qBACX,gBAAgB,OAC7B,MAAM,0DAIT,OAAO,CAAC;IAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAC,CA2B/D,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAAO,YAAiD,CAAC;AAM3F,eAAO,MAAM,kBAAkB,4BAA6B,MAAM,KAAG,IAEpE,CAAC;AAEF,eAAO,MAAM,sBAAsB,iBAAkB,YAAY,KAAG,MACW,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,mBAAmB,oCAEvB,CAAC,YAAY,EAAE,YAAY,KAAK,YAAY,GAAG,IAAI,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,sBAExF,OAAO,CAAC;IAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAC,CAa/D,CAAC;AAIF,eAAO,MAAM,kBAAkB,UAAW,MAAM,EAAE,KAAG,oBA6CpD,CAAC;AAIF,eAAO,MAAM,cAAc,iBACZ,YAAY,KACxB;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GAAG,SAgBlC,CAAC;AA8BF,eAAO,MAAM,OAAO,aACT,MAAM,iBACF,YAAY,KACxB,OAGyC,CAAC;AAE7C,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,YAAY,iBAAkB,YAAY,KAAG,gBAAgB,EAezE,CAAC"}
@@ -260,3 +260,23 @@ const parse_or_throw_formatted_error = (name, schema, value) => {
260
260
  }
261
261
  return parsed.data;
262
262
  };
263
+ export const has_dep = (dep_name, package_json = load_package_json()) => !!package_json.devDependencies?.[dep_name] ||
264
+ !!package_json.dependencies?.[dep_name] ||
265
+ !!package_json.peerDependencies?.[dep_name];
266
+ export const extract_deps = (package_json) => {
267
+ const deps_by_name = new Map();
268
+ // Earlier versions override later ones, so peer deps goes last.
269
+ const add_deps = (deps) => {
270
+ if (!deps)
271
+ return;
272
+ for (const [name, version] of Object.entries(deps)) {
273
+ if (!deps_by_name.has(name)) {
274
+ deps_by_name.set(name, { name, version });
275
+ }
276
+ }
277
+ };
278
+ add_deps(package_json.dependencies);
279
+ add_deps(package_json.devDependencies);
280
+ add_deps(package_json.peerDependencies);
281
+ return Array.from(deps_by_name.values());
282
+ };
@@ -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) => 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) => Promise<void>;
@@ -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,MAAM,EAAC,MAAM,uBAAuB,CAAC;AAGlD,OAAO,EAAC,YAAY,EAAoB,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAA2B,KAAK,uBAAuB,EAAC,MAAM,uBAAuB,CAAC;AAE7F,OAAO,EAAmC,KAAK,GAAG,EAAC,MAAM,UAAU,CAAC;AAIpE,eAAO,MAAM,aAAa,eAAe,CAAC;AAE1C,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C,eAAO,MAAM,kBAAkB,mBAAmB,CAAC;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MAAM,GAAG,GAAG,KACzB,OAAO,CAAC,IAAI,CAUd,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,CAAC,CAAC,EAAE,OAAO,CAAC;IACZ;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,CAAC,CAAC,EAAE,MAAM,CAAC;IACX;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,CAAC,CAAC,EAAE,MAAM,CAAC;IACX;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,CAAC,CAAC,EAAE,OAAO,CAAC;IACZ;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,kBAAkB,YACrB,sBAAsB,GAAG,SAAS,OACtC,MAAM,GAAG,GAAG,OACZ,MAAM,KACT,OAAO,CAAC,IAAI,CAmBd,CAAC;AAGF;;GAEG;AACH,eAAO,MAAM,qBAAqB,cACtB,MAAM,WACR,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAC9B,MASF,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { existsSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
- import { Package_Json, load_package_json } from './package_json.js';
3
+ import { Package_Json, has_dep } from './package_json.js';
4
4
  import { default_sveltekit_config } from './sveltekit_config.js';
5
5
  import { SVELTEKIT_CONFIG_FILENAME, SVELTEKIT_DEV_DIRNAME } from './path_constants.js';
6
6
  import { find_cli, spawn_cli, to_cli_name } from './cli.js';
@@ -19,7 +19,7 @@ export const has_sveltekit_app = () => {
19
19
  // TODO check for routes?
20
20
  return { ok: true };
21
21
  };
22
- export const has_sveltekit_library = (package_json, sveltekit_config = default_sveltekit_config) => {
22
+ export const has_sveltekit_library = (package_json, sveltekit_config = default_sveltekit_config, dep_name = SVELTE_PACKAGE_DEP_NAME) => {
23
23
  const has_sveltekit_app_result = has_sveltekit_app();
24
24
  if (!has_sveltekit_app_result.ok) {
25
25
  return has_sveltekit_app_result;
@@ -27,11 +27,10 @@ export const has_sveltekit_library = (package_json, sveltekit_config = default_s
27
27
  if (!existsSync(sveltekit_config.lib_path)) {
28
28
  return { ok: false, message: `no SvelteKit lib directory found at ${sveltekit_config.lib_path}` };
29
29
  }
30
- const pkg = package_json ?? load_package_json();
31
- if (!(pkg.devDependencies?.[SVELTE_PACKAGE_DEP_NAME] || pkg.dependencies?.[SVELTE_PACKAGE_DEP_NAME])) {
30
+ if (!has_dep(dep_name, package_json)) {
32
31
  return {
33
32
  ok: false,
34
- message: `no dependency found in package.json for ${SVELTE_PACKAGE_DEP_NAME}, install it with \`npm i -D ${SVELTE_PACKAGE_DEP_NAME}\``,
33
+ message: `no dependency found in package.json for ${dep_name}, install it with \`npm i -D ${dep_name}\``,
35
34
  };
36
35
  }
37
36
  return { ok: true };
@@ -1,7 +1,7 @@
1
1
  import { spawn } from '@ryanatkn/belt/process.js';
2
2
  import { z } from 'zod';
3
3
  import { Task_Error } from './task.js';
4
- import { load_package_json } from './package_json.js';
4
+ import { extract_deps, load_package_json } from './package_json.js';
5
5
  import { Git_Origin, git_pull } from './git.js';
6
6
  import { spawn_cli } from './cli.js';
7
7
  export const Args = z
@@ -33,12 +33,12 @@ export const task = {
33
33
  await git_pull(origin);
34
34
  }
35
35
  const package_json = load_package_json();
36
- const all_deps = to_deps(package_json);
36
+ const all_deps = extract_deps(package_json);
37
37
  const deps = only.length
38
- ? all_deps.filter((d) => only.includes(d.key))
39
- : all_deps.filter((d) => !_.includes(d.key));
38
+ ? all_deps.filter((d) => only.includes(d.name))
39
+ : all_deps.filter((d) => !_.includes(d.name));
40
40
  if (only.length && only.length !== deps.length) {
41
- throw new Task_Error(`Some deps to upgrade were not found: ${only.filter((o) => !deps.find((d) => d.key === o)).join(', ')}`);
41
+ throw new Task_Error(`Some deps to upgrade were not found: ${only.filter((o) => !deps.find((d) => d.name === o)).join(', ')}`);
42
42
  }
43
43
  const upgrade_items = to_upgrade_items(deps);
44
44
  log.info(`upgrading:`, upgrade_items.join(' '));
@@ -55,26 +55,17 @@ export const task = {
55
55
  await spawn_cli('gro', ['sync', '--no-install']); // don't install because we do above
56
56
  },
57
57
  };
58
- const to_deps = (package_json) => {
59
- const prod_deps = package_json.dependencies
60
- ? Object.entries(package_json.dependencies).map(([key, value]) => ({ key, value }))
61
- : [];
62
- const dev_deps = package_json.devDependencies
63
- ? Object.entries(package_json.devDependencies).map(([key, value]) => ({ key, value }))
64
- : [];
65
- return prod_deps.concat(dev_deps);
66
- };
67
58
  const EXACT_VERSION_MATCHER = /^..*@.+/;
68
59
  const CUSTOM_TAG_MATCHER = /^[\^~><=]*.+-(.+)/;
69
60
  // TODO hacky and limited
70
61
  // TODO probably want to pass through exact deps as well, e.g. @foo/bar@1
71
62
  const to_upgrade_items = (deps) => deps.map((dep) => {
72
- if (EXACT_VERSION_MATCHER.test(dep.key)) {
73
- return dep.key;
63
+ if (EXACT_VERSION_MATCHER.test(dep.name)) {
64
+ return dep.name;
74
65
  }
75
- const custom_tag_matches = CUSTOM_TAG_MATCHER.exec(dep.value);
66
+ const custom_tag_matches = CUSTOM_TAG_MATCHER.exec(dep.version);
76
67
  if (custom_tag_matches) {
77
- return dep.key + '@' + custom_tag_matches[1].split('.')[0]; // I tried adding `\.?` to the end but doesn't work and I'm being lazy so I'm just splitting
68
+ return dep.name + '@' + custom_tag_matches[1].split('.')[0]; // I tried adding `\.?` to the end but doesn't work and I'm being lazy so I'm just splitting
78
69
  }
79
- return dep.key + '@latest';
70
+ return dep.name + '@latest';
80
71
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryanatkn/gro",
3
- "version": "0.139.0",
3
+ "version": "0.139.2",
4
4
  "description": "task runner and toolkit extending SvelteKit",
5
5
  "motto": "generate, run, optimize",
6
6
  "glyph": "🌰",
@@ -70,7 +70,7 @@
70
70
  "@changesets/types": "^6.0.0",
71
71
  "@ryanatkn/eslint-config": "^0.5.4",
72
72
  "@ryanatkn/fuz": "^0.129.0",
73
- "@ryanatkn/moss": "^0.16.1",
73
+ "@ryanatkn/moss": "^0.18.0",
74
74
  "@sveltejs/adapter-static": "^3.0.5",
75
75
  "@sveltejs/kit": "^2.6.1",
76
76
  "@sveltejs/package": "^2.3.5",
@@ -298,6 +298,10 @@
298
298
  "types": "./dist/modules.d.ts",
299
299
  "default": "./dist/modules.js"
300
300
  },
301
+ "./moss_helpers.js": {
302
+ "types": "./dist/moss_helpers.d.ts",
303
+ "default": "./dist/moss_helpers.js"
304
+ },
301
305
  "./package_json.js": {
302
306
  "types": "./dist/package_json.d.ts",
303
307
  "default": "./dist/package_json.js"
@@ -4,6 +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 {load_moss_plugin} from './moss_helpers.js';
7
8
 
8
9
  /**
9
10
  * This is the default config that's passed to `gro.config.ts`
@@ -15,17 +16,28 @@ import {gro_plugin_gen} from './gro_plugin_gen.js';
15
16
  * - if `src/lib/server/server.ts`, assumes a Node server
16
17
  */
17
18
  const config: Create_Gro_Config = async (cfg) => {
18
- const [has_sveltekit_library_result, has_server_result, has_sveltekit_app_result] =
19
- await Promise.all([has_sveltekit_library(), has_server(), has_sveltekit_app()]);
19
+ const [
20
+ moss_plugin_result,
21
+ has_sveltekit_library_result,
22
+ has_server_result,
23
+ has_sveltekit_app_result,
24
+ ] = await Promise.all([
25
+ load_moss_plugin(),
26
+ has_sveltekit_library(),
27
+ has_server(),
28
+ has_sveltekit_app(),
29
+ ]);
20
30
 
21
31
  cfg.plugins = () =>
22
32
  [
23
- has_sveltekit_library_result.ok ? gro_plugin_sveltekit_library() : null,
33
+ // put things that generate files before SvelteKit so it can see them
34
+ moss_plugin_result.ok ? moss_plugin_result.gro_plugin_moss() : null,
35
+ gro_plugin_gen(),
24
36
  has_server_result.ok ? gro_plugin_server() : null,
37
+ has_sveltekit_library_result.ok ? gro_plugin_sveltekit_library() : null,
25
38
  has_sveltekit_app_result.ok
26
39
  ? gro_plugin_sveltekit_app({host_target: has_server_result.ok ? 'node' : 'github_pages'})
27
40
  : null,
28
- gro_plugin_gen(),
29
41
  ].filter((v) => v !== null);
30
42
 
31
43
  return cfg;
@@ -0,0 +1,33 @@
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
+
7
+ export const MOSS_PACKAGE_DEP_NAME = '@ryanatkn/moss';
8
+
9
+ // TODO plugin type?
10
+ export const load_moss_plugin = async (
11
+ package_json?: Package_Json,
12
+ dep_name = MOSS_PACKAGE_DEP_NAME,
13
+ plugin_path = `node_modules/${dep_name}/dist/gro_plugin_moss.js`, // TODO maybe lookup from its `package_json.exports`? kinda unnecessary
14
+ ): Promise<Result<{gro_plugin_moss: any}, {message: string}>> => {
15
+ if (!has_dep(dep_name, package_json)) {
16
+ return {
17
+ ok: false,
18
+ message: `no dependency found in package.json for ${dep_name}, install it with \`npm i -D ${dep_name}\``,
19
+ };
20
+ }
21
+
22
+ const path = resolve(plugin_path);
23
+ if (!existsSync(path)) {
24
+ return {
25
+ ok: false,
26
+ // TODO warn?
27
+ message: `dependency on ${dep_name} detected but plugin not found at ${path}`,
28
+ };
29
+ }
30
+
31
+ const mod = await import(path);
32
+ return {ok: true, gro_plugin_moss: mod.gro_plugin_moss};
33
+ };
@@ -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.139.0',
8
+ version: '0.139.2',
9
9
  description: 'task runner and toolkit extending SvelteKit',
10
10
  motto: 'generate, run, optimize',
11
11
  glyph: '🌰',
@@ -62,7 +62,7 @@ export const package_json = {
62
62
  '@changesets/types': '^6.0.0',
63
63
  '@ryanatkn/eslint-config': '^0.5.4',
64
64
  '@ryanatkn/fuz': '^0.129.0',
65
- '@ryanatkn/moss': '^0.16.1',
65
+ '@ryanatkn/moss': '^0.18.0',
66
66
  '@sveltejs/adapter-static': '^3.0.5',
67
67
  '@sveltejs/kit': '^2.6.1',
68
68
  '@sveltejs/package': '^2.3.5',
@@ -181,6 +181,7 @@ 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'},
184
185
  './package_json.js': {types: './dist/package_json.d.ts', default: './dist/package_json.js'},
185
186
  './package_meta.js': {types: './dist/package_meta.d.ts', default: './dist/package_meta.js'},
186
187
  './package.gen.js': {types: './dist/package.gen.d.ts', default: './dist/package.gen.js'},
@@ -269,7 +270,7 @@ export const package_json = {
269
270
 
270
271
  export const src_json = {
271
272
  name: '@ryanatkn/gro',
272
- version: '0.139.0',
273
+ version: '0.139.2',
273
274
  modules: {
274
275
  '.': {
275
276
  path: 'index.ts',
@@ -657,6 +658,13 @@ export const src_json = {
657
658
  {name: 'load_modules', kind: 'function'},
658
659
  ],
659
660
  },
661
+ './moss_helpers.js': {
662
+ path: 'moss_helpers.ts',
663
+ declarations: [
664
+ {name: 'MOSS_PACKAGE_DEP_NAME', kind: 'variable'},
665
+ {name: 'load_moss_plugin', kind: 'function'},
666
+ ],
667
+ },
660
668
  './package_json.js': {
661
669
  path: 'package_json.ts',
662
670
  declarations: [
@@ -678,6 +686,9 @@ export const src_json = {
678
686
  {name: 'update_package_json', kind: 'function'},
679
687
  {name: 'to_package_exports', kind: 'function'},
680
688
  {name: 'parse_repo_url', kind: 'function'},
689
+ {name: 'has_dep', kind: 'function'},
690
+ {name: 'Package_Json_Dep', kind: 'type'},
691
+ {name: 'extract_deps', kind: 'function'},
681
692
  ],
682
693
  },
683
694
  './package_meta.js': {
@@ -328,3 +328,33 @@ const parse_or_throw_formatted_error = <T extends z.ZodTypeAny>(
328
328
  }
329
329
  return parsed.data;
330
330
  };
331
+
332
+ export const has_dep = (
333
+ dep_name: string,
334
+ package_json: Package_Json = load_package_json(),
335
+ ): boolean =>
336
+ !!package_json.devDependencies?.[dep_name] ||
337
+ !!package_json.dependencies?.[dep_name] ||
338
+ !!package_json.peerDependencies?.[dep_name];
339
+
340
+ export interface Package_Json_Dep {
341
+ name: string;
342
+ version: string;
343
+ }
344
+
345
+ export const extract_deps = (package_json: Package_Json): Package_Json_Dep[] => {
346
+ const deps_by_name: Map<string, Package_Json_Dep> = new Map();
347
+ // Earlier versions override later ones, so peer deps goes last.
348
+ const add_deps = (deps: Record<string, string> | undefined) => {
349
+ if (!deps) return;
350
+ for (const [name, version] of Object.entries(deps)) {
351
+ if (!deps_by_name.has(name)) {
352
+ deps_by_name.set(name, {name, version});
353
+ }
354
+ }
355
+ };
356
+ add_deps(package_json.dependencies);
357
+ add_deps(package_json.devDependencies);
358
+ add_deps(package_json.peerDependencies);
359
+ return Array.from(deps_by_name.values());
360
+ };
@@ -3,7 +3,7 @@ import {existsSync} from 'node:fs';
3
3
  import type {Logger} from '@ryanatkn/belt/log.js';
4
4
  import {join} from 'node:path';
5
5
 
6
- import {Package_Json, load_package_json} from './package_json.js';
6
+ import {Package_Json, has_dep} from './package_json.js';
7
7
  import {default_sveltekit_config, type Parsed_Sveltekit_Config} from './sveltekit_config.js';
8
8
  import {SVELTEKIT_CONFIG_FILENAME, SVELTEKIT_DEV_DIRNAME} from './path_constants.js';
9
9
  import {find_cli, spawn_cli, to_cli_name, type Cli} from './cli.js';
@@ -32,6 +32,7 @@ export const has_sveltekit_app = (): Result<object, {message: string}> => {
32
32
  export const has_sveltekit_library = (
33
33
  package_json?: Package_Json,
34
34
  sveltekit_config: Parsed_Sveltekit_Config = default_sveltekit_config,
35
+ dep_name = SVELTE_PACKAGE_DEP_NAME,
35
36
  ): Result<object, {message: string}> => {
36
37
  const has_sveltekit_app_result = has_sveltekit_app();
37
38
  if (!has_sveltekit_app_result.ok) {
@@ -42,13 +43,10 @@ export const has_sveltekit_library = (
42
43
  return {ok: false, message: `no SvelteKit lib directory found at ${sveltekit_config.lib_path}`};
43
44
  }
44
45
 
45
- const pkg = package_json ?? load_package_json();
46
- if (
47
- !(pkg.devDependencies?.[SVELTE_PACKAGE_DEP_NAME] || pkg.dependencies?.[SVELTE_PACKAGE_DEP_NAME])
48
- ) {
46
+ if (!has_dep(dep_name, package_json)) {
49
47
  return {
50
48
  ok: false,
51
- message: `no dependency found in package.json for ${SVELTE_PACKAGE_DEP_NAME}, install it with \`npm i -D ${SVELTE_PACKAGE_DEP_NAME}\``,
49
+ message: `no dependency found in package.json for ${dep_name}, install it with \`npm i -D ${dep_name}\``,
52
50
  };
53
51
  }
54
52
 
@@ -2,7 +2,7 @@ import {spawn} from '@ryanatkn/belt/process.js';
2
2
  import {z} from 'zod';
3
3
 
4
4
  import {Task_Error, type Task} from './task.js';
5
- import {load_package_json, type Package_Json} from './package_json.js';
5
+ import {extract_deps, load_package_json, type Package_Json_Dep} from './package_json.js';
6
6
  import {Git_Origin, git_pull} from './git.js';
7
7
  import {spawn_cli} from './cli.js';
8
8
 
@@ -41,15 +41,15 @@ export const task: Task<Args> = {
41
41
 
42
42
  const package_json = load_package_json();
43
43
 
44
- const all_deps = to_deps(package_json);
44
+ const all_deps = extract_deps(package_json);
45
45
 
46
46
  const deps = only.length
47
- ? all_deps.filter((d) => only.includes(d.key))
48
- : all_deps.filter((d) => !_.includes(d.key));
47
+ ? all_deps.filter((d) => only.includes(d.name))
48
+ : all_deps.filter((d) => !_.includes(d.name));
49
49
 
50
50
  if (only.length && only.length !== deps.length) {
51
51
  throw new Task_Error(
52
- `Some deps to upgrade were not found: ${only.filter((o) => !deps.find((d) => d.key === o)).join(', ')}`,
52
+ `Some deps to upgrade were not found: ${only.filter((o) => !deps.find((d) => d.name === o)).join(', ')}`,
53
53
  );
54
54
  }
55
55
 
@@ -72,34 +72,19 @@ export const task: Task<Args> = {
72
72
  },
73
73
  };
74
74
 
75
- interface Dep {
76
- key: string;
77
- value: string;
78
- }
79
-
80
- const to_deps = (package_json: Package_Json): Dep[] => {
81
- const prod_deps: Dep[] = package_json.dependencies
82
- ? Object.entries(package_json.dependencies).map(([key, value]) => ({key, value}))
83
- : [];
84
- const dev_deps: Dep[] = package_json.devDependencies
85
- ? Object.entries(package_json.devDependencies).map(([key, value]) => ({key, value}))
86
- : [];
87
- return prod_deps.concat(dev_deps);
88
- };
89
-
90
75
  const EXACT_VERSION_MATCHER = /^..*@.+/;
91
76
  const CUSTOM_TAG_MATCHER = /^[\^~><=]*.+-(.+)/;
92
77
 
93
78
  // TODO hacky and limited
94
79
  // TODO probably want to pass through exact deps as well, e.g. @foo/bar@1
95
- const to_upgrade_items = (deps: Dep[]): string[] =>
80
+ const to_upgrade_items = (deps: Package_Json_Dep[]): string[] =>
96
81
  deps.map((dep) => {
97
- if (EXACT_VERSION_MATCHER.test(dep.key)) {
98
- return dep.key;
82
+ if (EXACT_VERSION_MATCHER.test(dep.name)) {
83
+ return dep.name;
99
84
  }
100
- const custom_tag_matches = CUSTOM_TAG_MATCHER.exec(dep.value);
85
+ const custom_tag_matches = CUSTOM_TAG_MATCHER.exec(dep.version);
101
86
  if (custom_tag_matches) {
102
- return dep.key + '@' + custom_tag_matches[1].split('.')[0]; // I tried adding `\.?` to the end but doesn't work and I'm being lazy so I'm just splitting
87
+ return dep.name + '@' + custom_tag_matches[1].split('.')[0]; // I tried adding `\.?` to the end but doesn't work and I'm being lazy so I'm just splitting
103
88
  }
104
- return dep.key + '@latest';
89
+ return dep.name + '@latest';
105
90
  });