@markuplint/file-resolver 4.8.1 → 4.9.1

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/CHANGELOG.md CHANGED
@@ -3,16 +3,29 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [4.8.1](https://github.com/markuplint/markuplint/compare/@markuplint/file-resolver@4.8.0...@markuplint/file-resolver@4.8.1) (2024-06-09)
6
+ ## [4.9.1](https://github.com/markuplint/markuplint/compare/@markuplint/file-resolver@4.9.0...@markuplint/file-resolver@4.9.1) (2024-09-02)
7
+
8
+ **Note:** Version bump only for package @markuplint/file-resolver
9
+
10
+
11
+
7
12
 
8
13
 
14
+ # [4.9.0](https://github.com/markuplint/markuplint/compare/@markuplint/file-resolver@4.8.1...@markuplint/file-resolver@4.9.0) (2024-06-25)
15
+
9
16
  ### Bug Fixes
10
17
 
11
- * fix to export type files ([eff4bbf](https://github.com/markuplint/markuplint/commit/eff4bbfd127574809dc5e15d7cafe87699758ee0))
18
+ - **file-resolver:** catch errors on resolve plugins ([34f4775](https://github.com/markuplint/markuplint/commit/34f47754f2b470c31b9f1215f4072e72b2af6e2a))
12
19
 
20
+ ### Features
13
21
 
22
+ - **file-resolver:** expose errors within resolving plugins ([35ac3d4](https://github.com/markuplint/markuplint/commit/35ac3d46d0aa8e3483defa66c1239e739c57e060))
14
23
 
24
+ ## [4.8.1](https://github.com/markuplint/markuplint/compare/@markuplint/file-resolver@4.8.0...@markuplint/file-resolver@4.8.1) (2024-06-09)
25
+
26
+ ### Bug Fixes
15
27
 
28
+ - fix to export type files ([eff4bbf](https://github.com/markuplint/markuplint/commit/eff4bbfd127574809dc5e15d7cafe87699758ee0))
16
29
 
17
30
  # [4.8.0](https://github.com/markuplint/markuplint/compare/@markuplint/file-resolver@4.7.2...@markuplint/file-resolver@4.8.0) (2024-05-28)
18
31
 
@@ -88,7 +88,8 @@ export class ConfigProvider {
88
88
  }
89
89
  const errors = this._validateConfig(configSet.config, filePath);
90
90
  configSet.errs.push(...errors);
91
- const plugins = await resolvePlugins(configSet.config.plugins);
91
+ const { plugins, errors: pluginErrors } = await resolvePlugins(configSet.config.plugins);
92
+ configSet.errs.push(...pluginErrors);
92
93
  if (__classPrivateFieldGet(this, _ConfigProvider_held, "f").size > 0) {
93
94
  const extendHelds = [...__classPrivateFieldGet(this, _ConfigProvider_held, "f").values()];
94
95
  for (const held of extendHelds) {
@@ -1,4 +1,7 @@
1
1
  import type { PluginConfig } from '@markuplint/ml-config';
2
2
  import type { Plugin } from '@markuplint/ml-core';
3
- export declare function resolvePlugins(pluginPaths?: readonly (string | PluginConfig)[]): Promise<Plugin[]>;
3
+ export declare function resolvePlugins(pluginPaths?: readonly (string | PluginConfig)[]): Promise<{
4
+ plugins: Plugin[];
5
+ errors: ReferenceError[];
6
+ }>;
4
7
  export declare function cacheClear(): void;
@@ -4,11 +4,26 @@ const pLog = log.extend('resolve-plugins');
4
4
  const cache = new Map();
5
5
  export async function resolvePlugins(pluginPaths) {
6
6
  if (!pluginPaths) {
7
- return [];
7
+ return {
8
+ plugins: [],
9
+ errors: [],
10
+ };
11
+ }
12
+ const imported = await Promise.all(pluginPaths.map(p => importPlugin(p)));
13
+ const plugins = [];
14
+ const errors = [];
15
+ for (const item of imported) {
16
+ if (item instanceof ReferenceError) {
17
+ errors.push(item);
18
+ }
19
+ else {
20
+ plugins.push(item);
21
+ }
8
22
  }
9
- const plugins = await Promise.all(pluginPaths.map(p => importPlugin(p)));
10
- // Clone
11
- return [...plugins];
23
+ return {
24
+ plugins,
25
+ errors,
26
+ };
12
27
  }
13
28
  export function cacheClear() {
14
29
  cache.clear();
@@ -21,16 +36,22 @@ async function importPlugin(pluginPath) {
21
36
  return cached;
22
37
  }
23
38
  const pluginCreator = await generalImport(config.name);
39
+ if (!pluginCreator) {
40
+ const error = new ReferenceError(`Plugin not found: ${config.name}`);
41
+ pLog('Error: %s', error.message);
42
+ cache.set(config.name, error);
43
+ return error;
44
+ }
24
45
  let name = config.name;
25
46
  let plugin = null;
26
- if (typeof pluginCreator?.create === 'function' || pluginCreator?.name) {
47
+ if (typeof pluginCreator.create === 'function' || pluginCreator?.name) {
27
48
  plugin = {
28
49
  name: pluginCreator.name,
29
50
  ...pluginCreator.create(config.settings),
30
51
  };
31
52
  name = plugin.name ?? name;
32
53
  }
33
- else if (pluginCreator) {
54
+ else {
34
55
  pLog('Invalid plugin: %s', config.name);
35
56
  }
36
57
  name = name
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/file-resolver",
3
- "version": "4.8.1",
3
+ "version": "4.9.1",
4
4
  "description": "The file resolver of markuplint",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -24,24 +24,24 @@
24
24
  "clean": "tsc --build --clean"
25
25
  },
26
26
  "devDependencies": {
27
- "@types/node": "20.14.2"
27
+ "@types/node": "22.5.2"
28
28
  },
29
29
  "dependencies": {
30
- "@markuplint/html-parser": "4.6.4",
31
- "@markuplint/ml-ast": "4.4.1",
32
- "@markuplint/ml-config": "4.7.1",
33
- "@markuplint/ml-core": "4.8.1",
34
- "@markuplint/ml-spec": "4.6.2",
35
- "@markuplint/parser-utils": "4.6.4",
36
- "@markuplint/selector": "4.6.4",
37
- "@markuplint/shared": "4.4.2",
30
+ "@markuplint/html-parser": "4.6.6",
31
+ "@markuplint/ml-ast": "4.4.3",
32
+ "@markuplint/ml-config": "4.7.3",
33
+ "@markuplint/ml-core": "4.8.3",
34
+ "@markuplint/ml-spec": "4.6.4",
35
+ "@markuplint/parser-utils": "4.6.6",
36
+ "@markuplint/selector": "4.6.6",
37
+ "@markuplint/shared": "4.4.4",
38
38
  "cosmiconfig": "9.0.0",
39
- "debug": "4.3.5",
40
- "glob": "10.4.1",
41
- "ignore": "5.3.1",
39
+ "debug": "4.3.6",
40
+ "glob": "11.0.0",
41
+ "ignore": "5.3.2",
42
42
  "import-meta-resolve": "4.1.0",
43
43
  "jsonc": "2.0.0",
44
- "minimatch": "9.0.4"
44
+ "minimatch": "10.0.1"
45
45
  },
46
- "gitHead": "0200dc1f7b1ffa7455b889696153e25dbae8241f"
46
+ "gitHead": "77cd5a25d5cf28c83253b7bfe02cd25b54e236b0"
47
47
  }