@ryanatkn/gro 0.140.4 → 0.140.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,7 +9,6 @@
9
9
  [Windows won't be supported](https://github.com/ryanatkn/gro/issues/319), I chose Bash instead.
10
10
 
11
11
  Feel free to open issues with anything you'd like to discuss or report.
12
- I also run [a Discord community](https://discord.gg/YU5tyeK72X) that includes channels for Gro.
13
12
 
14
13
  ## about
15
14
 
package/dist/filer.d.ts CHANGED
@@ -19,7 +19,8 @@ export interface Options {
19
19
  }
20
20
  export declare class Filer {
21
21
  #private;
22
- files: Map<Path_Id, Source_File>;
22
+ readonly root_dir: Path_Id;
23
+ readonly files: Map<Path_Id, Source_File>;
23
24
  constructor(options?: Options);
24
25
  get_by_id: (id: Path_Id) => Source_File | undefined;
25
26
  get_or_create: (id: Path_Id) => Source_File;
@@ -1 +1 @@
1
- {"version":3,"file":"filer.d.ts","sourceRoot":"../src/lib/","sources":["filer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAGzD,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,EACN,SAAS,EAET,KAAK,cAAc,EACnB,KAAK,OAAO,IAAI,iBAAiB,EAEjC,MAAM,gBAAgB,CAAC;AAWxB,MAAM,WAAW,WAAW;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IACtC,YAAY,EAAE,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;CACxC;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;AAEhD,MAAM,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,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AW,OAAO;IACvB,SAAS,CAAC,EAAE,OAAO,SAAS,CAAC;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC,CAAC;CACzE;AAED,qBAAa,KAAK;;IACjB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAa;gBAK1C,OAAO,GAAE,OAAsB;IAW3C,SAAS,OAAQ,OAAO,KAAG,WAAW,GAAG,SAAS,CAEhD;IAEF,aAAa,OAAQ,OAAO,KAAG,WAAW,CAWxC;IAyII,KAAK,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAKxD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ5B"}
package/dist/filer.js CHANGED
@@ -9,15 +9,18 @@ import { resolve_specifier } from './resolve_specifier.js';
9
9
  import { default_sveltekit_config } from './sveltekit_config.js';
10
10
  import { map_sveltekit_aliases } from './sveltekit_helpers.js';
11
11
  import { Unreachable_Error } from '@ryanatkn/belt/error.js';
12
- import { resolve_node_specifier } from './resolve_node_specifier.js';
12
+ // TODO see below
13
+ // import {resolve_node_specifier} from './resolve_node_specifier.js';
13
14
  const aliases = Object.entries(default_sveltekit_config.alias);
14
15
  export class Filer {
16
+ root_dir;
15
17
  files = new Map();
16
18
  #watch_dir;
17
19
  #watch_dir_options;
18
20
  constructor(options = EMPTY_OBJECT) {
19
21
  this.#watch_dir = options.watch_dir ?? watch_dir;
20
22
  this.#watch_dir_options = options.watch_dir_options ?? EMPTY_OBJECT;
23
+ this.root_dir = resolve(options.watch_dir_options?.dir ?? paths.source);
21
24
  }
22
25
  #watching;
23
26
  #listeners = new Set();
@@ -53,16 +56,27 @@ export class Filer {
53
56
  // TODO logic is duplicated from loader
54
57
  const path = map_sveltekit_aliases(specifier, aliases);
55
58
  // The specifier `path` has now been mapped to its final form, so we can inspect it.
56
- const resolved = path[0] === '.' || path[0] === '/'
57
- ? resolve_specifier(path, dir)
58
- : resolve_node_specifier(path);
59
- const { path_id } = resolved;
60
- dependencies_removed.delete(path_id);
61
- if (!dependencies_before.has(path_id)) {
62
- const d = this.get_or_create(path_id);
63
- file.dependencies.set(d.id, d);
64
- d.dependents.set(file.id, file);
59
+ if (path[0] === '.' || path[0] === '/') {
60
+ const { path_id } = resolve_specifier(path, dir);
61
+ dependencies_removed.delete(path_id);
62
+ if (!dependencies_before.has(path_id)) {
63
+ const d = this.get_or_create(path_id);
64
+ file.dependencies.set(d.id, d);
65
+ d.dependents.set(file.id, file);
66
+ }
65
67
  }
68
+ // TODO this doesn't work
69
+ // const resolved =
70
+ // path[0] === '.' || path[0] === '/'
71
+ // ? resolve_specifier(path, dir)
72
+ // : resolve_node_specifier(path, dir);
73
+ // const {path_id} = resolved;
74
+ // dependencies_removed.delete(path_id);
75
+ // if (!dependencies_before.has(path_id)) {
76
+ // const d = this.get_or_create(path_id);
77
+ // file.dependencies.set(d.id, d);
78
+ // d.dependents.set(file.id, file);
79
+ // }
66
80
  }
67
81
  // update any removed dependencies
68
82
  for (const dependency_removed of dependencies_removed) {
@@ -118,7 +132,7 @@ export class Filer {
118
132
  this.#watching = this.#watch_dir({
119
133
  filter: (path, is_directory) => (is_directory ? true : default_file_filter(path)),
120
134
  ...this.#watch_dir_options,
121
- dir: resolve(this.#watch_dir_options.dir ?? paths.source),
135
+ dir: this.root_dir,
122
136
  on_change: this.#on_change,
123
137
  });
124
138
  await this.#watching.init();
@@ -1,7 +1,7 @@
1
1
  import type { Result } from '@ryanatkn/belt/result.js';
2
2
  import { type Package_Json } from './package_json.js';
3
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<{
4
+ export declare const load_moss_plugin: (package_json?: Package_Json, dep_name?: string, plugin_path?: string, local_plugin_path?: string) => Promise<Result<{
5
5
  gro_plugin_moss: any;
6
6
  }, {
7
7
  message: string;
@@ -1 +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"}
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,0EAIzB,OAAO,CAAC,MAAM,CAAC;IAAC,eAAe,EAAE,GAAG,CAAA;CAAC,EAAE;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAAC,CA4B3D,CAAC"}
@@ -3,20 +3,28 @@ import { resolve } from 'node:path';
3
3
  import { has_dep } from './package_json.js';
4
4
  export const MOSS_PACKAGE_DEP_NAME = '@ryanatkn/moss';
5
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`) => {
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`, // TODO maybe lookup from its `package_json.exports`? kinda unnecessary
7
+ local_plugin_path = 'src/lib/gro_plugin_moss.ts') => {
7
8
  if (!has_dep(dep_name, package_json)) {
8
9
  return {
9
10
  ok: false,
10
11
  message: `no dependency found in package.json for ${dep_name}, install it with \`npm i -D ${dep_name}\``,
11
12
  };
12
13
  }
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
- };
14
+ let path = undefined;
15
+ const resolved_local_plugin_path = resolve(local_plugin_path);
16
+ if (existsSync(resolved_local_plugin_path)) {
17
+ path = resolved_local_plugin_path;
18
+ }
19
+ if (path === undefined) {
20
+ path = resolve(plugin_path);
21
+ if (!existsSync(path)) {
22
+ return {
23
+ ok: false,
24
+ // TODO warn?
25
+ message: `dependency on ${dep_name} detected but plugin not found at ${path}`,
26
+ };
27
+ }
20
28
  }
21
29
  const mod = await import(path);
22
30
  return { ok: true, gro_plugin_moss: mod.gro_plugin_moss };
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.140.4',
4
+ version: '0.140.6',
5
5
  description: 'task runner and toolkit extending SvelteKit',
6
6
  motto: 'generate, run, optimize',
7
7
  glyph: '🌰',
@@ -264,7 +264,7 @@ export const package_json = {
264
264
  };
265
265
  export const src_json = {
266
266
  name: '@ryanatkn/gro',
267
- version: '0.140.4',
267
+ version: '0.140.6',
268
268
  modules: {
269
269
  '.': {
270
270
  path: 'index.ts',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryanatkn/gro",
3
- "version": "0.140.4",
3
+ "version": "0.140.6",
4
4
  "description": "task runner and toolkit extending SvelteKit",
5
5
  "motto": "generate, run, optimize",
6
6
  "glyph": "🌰",
package/src/lib/filer.ts CHANGED
@@ -18,12 +18,14 @@ import {resolve_specifier} from './resolve_specifier.js';
18
18
  import {default_sveltekit_config} from './sveltekit_config.js';
19
19
  import {map_sveltekit_aliases} from './sveltekit_helpers.js';
20
20
  import {Unreachable_Error} from '@ryanatkn/belt/error.js';
21
- import {resolve_node_specifier} from './resolve_node_specifier.js';
21
+ // TODO see below
22
+ // import {resolve_node_specifier} from './resolve_node_specifier.js';
22
23
 
23
24
  const aliases = Object.entries(default_sveltekit_config.alias);
24
25
 
25
26
  export interface Source_File {
26
27
  id: Path_Id;
28
+ // TODO add // mtime: number;
27
29
  /**
28
30
  * `null` contents means it doesn't exist.
29
31
  * We create the file in memory to track its dependents regardless of its existence on disk.
@@ -43,7 +45,9 @@ export interface Options {
43
45
  }
44
46
 
45
47
  export class Filer {
46
- files: Map<Path_Id, Source_File> = new Map();
48
+ readonly root_dir: Path_Id;
49
+
50
+ readonly files: Map<Path_Id, Source_File> = new Map();
47
51
 
48
52
  #watch_dir: typeof watch_dir;
49
53
  #watch_dir_options: Partial<Watch_Dir_Options>;
@@ -51,6 +55,7 @@ export class Filer {
51
55
  constructor(options: Options = EMPTY_OBJECT) {
52
56
  this.#watch_dir = options.watch_dir ?? watch_dir;
53
57
  this.#watch_dir_options = options.watch_dir_options ?? EMPTY_OBJECT;
58
+ this.root_dir = resolve(options.watch_dir_options?.dir ?? paths.source);
54
59
  }
55
60
 
56
61
  #watching: Watch_Node_Fs | undefined;
@@ -95,18 +100,27 @@ export class Filer {
95
100
  const path = map_sveltekit_aliases(specifier, aliases);
96
101
 
97
102
  // The specifier `path` has now been mapped to its final form, so we can inspect it.
98
- const resolved =
99
- path[0] === '.' || path[0] === '/'
100
- ? resolve_specifier(path, dir)
101
- : resolve_node_specifier(path);
102
- const {path_id} = resolved;
103
-
104
- dependencies_removed.delete(path_id);
105
- if (!dependencies_before.has(path_id)) {
106
- const d = this.get_or_create(path_id);
107
- file.dependencies.set(d.id, d);
108
- d.dependents.set(file.id, file);
103
+ if (path[0] === '.' || path[0] === '/') {
104
+ const {path_id} = resolve_specifier(path, dir);
105
+ dependencies_removed.delete(path_id);
106
+ if (!dependencies_before.has(path_id)) {
107
+ const d = this.get_or_create(path_id);
108
+ file.dependencies.set(d.id, d);
109
+ d.dependents.set(file.id, file);
110
+ }
109
111
  }
112
+ // TODO this doesn't work
113
+ // const resolved =
114
+ // path[0] === '.' || path[0] === '/'
115
+ // ? resolve_specifier(path, dir)
116
+ // : resolve_node_specifier(path, dir);
117
+ // const {path_id} = resolved;
118
+ // dependencies_removed.delete(path_id);
119
+ // if (!dependencies_before.has(path_id)) {
120
+ // const d = this.get_or_create(path_id);
121
+ // file.dependencies.set(d.id, d);
122
+ // d.dependents.set(file.id, file);
123
+ // }
110
124
  }
111
125
 
112
126
  // update any removed dependencies
@@ -165,7 +179,7 @@ export class Filer {
165
179
  this.#watching = this.#watch_dir({
166
180
  filter: (path, is_directory) => (is_directory ? true : default_file_filter(path)),
167
181
  ...this.#watch_dir_options,
168
- dir: resolve(this.#watch_dir_options.dir ?? paths.source),
182
+ dir: this.root_dir,
169
183
  on_change: this.#on_change,
170
184
  });
171
185
  await this.#watching.init();
@@ -11,6 +11,7 @@ export const load_moss_plugin = async (
11
11
  package_json?: Package_Json,
12
12
  dep_name = MOSS_PACKAGE_DEP_NAME,
13
13
  plugin_path = `node_modules/${dep_name}/dist/gro_plugin_moss.js`, // TODO maybe lookup from its `package_json.exports`? kinda unnecessary
14
+ local_plugin_path = 'src/lib/gro_plugin_moss.ts',
14
15
  ): Promise<Result<{gro_plugin_moss: any}, {message: string}>> => {
15
16
  if (!has_dep(dep_name, package_json)) {
16
17
  return {
@@ -19,13 +20,22 @@ export const load_moss_plugin = async (
19
20
  };
20
21
  }
21
22
 
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
- };
23
+ let path: string | undefined = undefined;
24
+
25
+ const resolved_local_plugin_path = resolve(local_plugin_path);
26
+ if (existsSync(resolved_local_plugin_path)) {
27
+ path = resolved_local_plugin_path;
28
+ }
29
+
30
+ if (path === undefined) {
31
+ path = resolve(plugin_path);
32
+ if (!existsSync(path)) {
33
+ return {
34
+ ok: false,
35
+ // TODO warn?
36
+ message: `dependency on ${dep_name} detected but plugin not found at ${path}`,
37
+ };
38
+ }
29
39
  }
30
40
 
31
41
  const mod = await import(path);
@@ -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.140.4',
8
+ version: '0.140.6',
9
9
  description: 'task runner and toolkit extending SvelteKit',
10
10
  motto: 'generate, run, optimize',
11
11
  glyph: '🌰',
@@ -270,7 +270,7 @@ export const package_json = {
270
270
 
271
271
  export const src_json = {
272
272
  name: '@ryanatkn/gro',
273
- version: '0.140.4',
273
+ version: '0.140.6',
274
274
  modules: {
275
275
  '.': {
276
276
  path: 'index.ts',