@markuplint/file-resolver 3.3.0 → 3.4.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.
- package/lib/auto-load-rules.d.ts +2 -2
- package/lib/config-provider.d.ts +8 -8
- package/lib/config-provider.js +5 -4
- package/lib/cosmiconfig.d.ts +12 -6
- package/lib/ml-file/ml-file.d.ts +20 -20
- package/lib/resolve-parser.d.ts +9 -5
- package/lib/resolve-parser.js +5 -1
- package/lib/resolve-rules.d.ts +9 -5
- package/lib/resolve-specs.d.ts +5 -2
- package/lib/resolve-specs.js +3 -0
- package/lib/types.d.ts +20 -18
- package/lib/utils.js +1 -1
- package/package.json +6 -6
package/lib/auto-load-rules.d.ts
CHANGED
package/lib/config-provider.d.ts
CHANGED
|
@@ -2,12 +2,12 @@ import type { MLFile } from './ml-file';
|
|
|
2
2
|
import type { ConfigSet, Nullable } from './types';
|
|
3
3
|
import type { Config } from '@markuplint/ml-config';
|
|
4
4
|
export declare class ConfigProvider {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
#private;
|
|
6
|
+
resolve(targetFile: MLFile, names: Nullable<string>[], cache?: boolean): Promise<ConfigSet>;
|
|
7
|
+
search(targetFile: MLFile): Promise<string | null>;
|
|
8
|
+
set(config: Config, key?: string): string;
|
|
9
|
+
private _load;
|
|
10
|
+
private _mergeConfigs;
|
|
11
|
+
private _pathResolve;
|
|
12
|
+
private _recursiveLoad;
|
|
13
13
|
}
|
package/lib/config-provider.js
CHANGED
|
@@ -39,7 +39,7 @@ class ConfigProvider {
|
|
|
39
39
|
switch (prefix) {
|
|
40
40
|
case 'plugin:': {
|
|
41
41
|
const plugin = plugins.find(plugin => plugin.name === namespace);
|
|
42
|
-
const config = (_a = plugin === null || plugin === void 0 ? void 0 : plugin.configs) === null || _a === void 0 ? void 0 : _a[name];
|
|
42
|
+
const config = name && ((_a = plugin === null || plugin === void 0 ? void 0 : plugin.configs) === null || _a === void 0 ? void 0 : _a[name]);
|
|
43
43
|
if (config) {
|
|
44
44
|
this.set(config, held);
|
|
45
45
|
}
|
|
@@ -56,9 +56,10 @@ class ConfigProvider {
|
|
|
56
56
|
const globs = Object.keys(overrides);
|
|
57
57
|
for (const glob of globs) {
|
|
58
58
|
const isMatched = targetFile.matches(glob);
|
|
59
|
-
|
|
59
|
+
const config = overrides[glob];
|
|
60
|
+
if (isMatched && config) {
|
|
60
61
|
// Note: Original config disappears
|
|
61
|
-
configSet.config =
|
|
62
|
+
configSet.config = config;
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
}
|
|
@@ -94,7 +95,7 @@ class ConfigProvider {
|
|
|
94
95
|
}
|
|
95
96
|
if (isPreset(filePath)) {
|
|
96
97
|
const [, name] = filePath.match(/^markuplint:(.+)$/i) || [];
|
|
97
|
-
const config = await (0, ml_core_1.getPreset)(name);
|
|
98
|
+
const config = await (0, ml_core_1.getPreset)(name !== null && name !== void 0 ? name : filePath);
|
|
98
99
|
const pathResolvedConfig = this._pathResolve(config, filePath);
|
|
99
100
|
tslib_1.__classPrivateFieldGet(this, _ConfigProvider_store, "f").set(filePath, pathResolvedConfig);
|
|
100
101
|
return pathResolvedConfig;
|
package/lib/cosmiconfig.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import type { LoaderSync } from 'cosmiconfig';
|
|
2
2
|
type CosmiConfig = ReturnType<LoaderSync>;
|
|
3
|
-
export declare function search<T = CosmiConfig>(
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export declare function search<T = CosmiConfig>(
|
|
4
|
+
dir: string,
|
|
5
|
+
cacheClear: boolean,
|
|
6
|
+
): Promise<{
|
|
7
|
+
filePath: string;
|
|
8
|
+
config: T;
|
|
6
9
|
} | null>;
|
|
7
|
-
export declare function load<T = CosmiConfig>(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
export declare function load<T = CosmiConfig>(
|
|
11
|
+
filePath: string,
|
|
12
|
+
cacheClear: boolean,
|
|
13
|
+
): Promise<{
|
|
14
|
+
filePath: string;
|
|
15
|
+
config: T;
|
|
10
16
|
} | null>;
|
|
11
17
|
export {};
|
package/lib/ml-file/ml-file.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import type { Target } from '../types';
|
|
2
2
|
export declare class MLFile {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
3
|
+
#private;
|
|
4
|
+
constructor(target: Target);
|
|
5
|
+
get dirname(): string;
|
|
6
|
+
/**
|
|
7
|
+
* Normalized `MLFile.dirname`
|
|
8
|
+
*/
|
|
9
|
+
get nDirname(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Normalized `MLFile.path`
|
|
12
|
+
*/
|
|
13
|
+
get nPath(): string;
|
|
14
|
+
get path(): string;
|
|
15
|
+
dirExists(): Promise<boolean>;
|
|
16
|
+
getCode(): Promise<string>;
|
|
17
|
+
isExist(): Promise<boolean>;
|
|
18
|
+
isFile(): Promise<boolean>;
|
|
19
|
+
matches(globPath: string): boolean;
|
|
20
|
+
setCode(code: string): void;
|
|
21
|
+
private _fetch;
|
|
22
|
+
private _stat;
|
|
23
23
|
}
|
package/lib/resolve-parser.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { MLFile } from './ml-file';
|
|
2
2
|
import type { MLMarkupLanguageParser, ParserOptions } from '@markuplint/ml-ast';
|
|
3
3
|
import type { ParserConfig } from '@markuplint/ml-config';
|
|
4
|
-
export declare function resolveParser(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export declare function resolveParser(
|
|
5
|
+
file: MLFile,
|
|
6
|
+
parserConfig?: ParserConfig,
|
|
7
|
+
parserOptions?: ParserOptions,
|
|
8
|
+
): Promise<{
|
|
9
|
+
parserModName: string;
|
|
10
|
+
parser: MLMarkupLanguageParser;
|
|
11
|
+
parserOptions: ParserOptions;
|
|
12
|
+
matched: boolean;
|
|
9
13
|
}>;
|
package/lib/resolve-parser.js
CHANGED
|
@@ -16,7 +16,11 @@ async function resolveParser(file, parserConfig, parserOptions) {
|
|
|
16
16
|
if (parserConfig) {
|
|
17
17
|
for (const pattern of Object.keys(parserConfig)) {
|
|
18
18
|
if (path_1.default.basename(file.path).match((0, utils_1.toRegexp)(pattern))) {
|
|
19
|
-
|
|
19
|
+
const modName = parserConfig[pattern];
|
|
20
|
+
if (!modName) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
parserModName = modName;
|
|
20
24
|
matched = true;
|
|
21
25
|
break;
|
|
22
26
|
}
|
package/lib/resolve-rules.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { AnyMLRule, Ruleset, Plugin } from '@markuplint/ml-core';
|
|
2
2
|
import { MLRule } from '@markuplint/ml-core';
|
|
3
|
-
export declare function resolveRules(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
export declare function resolveRules(
|
|
4
|
+
plugins: Plugin[],
|
|
5
|
+
ruleset: Ruleset,
|
|
6
|
+
importPreset: boolean,
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated
|
|
9
|
+
*/
|
|
10
|
+
autoLoad: boolean,
|
|
11
|
+
): Promise<AnyMLRule[] | MLRule<any, any>[]>;
|
package/lib/resolve-specs.d.ts
CHANGED
|
@@ -30,6 +30,9 @@ import type { ExtendedSpec, MLMLSpec } from '@markuplint/ml-spec';
|
|
|
30
30
|
* @param specConfig The `spec` property part of the config
|
|
31
31
|
* @returns
|
|
32
32
|
*/
|
|
33
|
-
export declare function resolveSpecs(
|
|
34
|
-
|
|
33
|
+
export declare function resolveSpecs(
|
|
34
|
+
filePath: string,
|
|
35
|
+
specConfig?: SpecConfig,
|
|
36
|
+
): Promise<{
|
|
37
|
+
schemas: readonly [MLMLSpec, ...ExtendedSpec[]];
|
|
35
38
|
}>;
|
package/lib/resolve-specs.js
CHANGED
|
@@ -53,6 +53,9 @@ async function resolveSpecs(filePath, specConfig) {
|
|
|
53
53
|
for (const pattern of Object.keys(specConfig)) {
|
|
54
54
|
if (path_1.default.basename(filePath).match((0, utils_1.toRegexp)(pattern))) {
|
|
55
55
|
const specModName = specConfig[pattern];
|
|
56
|
+
if (!specModName) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
56
59
|
const spec = await importSpecs(specModName);
|
|
57
60
|
extendedSpecs.push(spec);
|
|
58
61
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -2,22 +2,24 @@ import type { Config } from '@markuplint/ml-config';
|
|
|
2
2
|
import type { Plugin } from '@markuplint/ml-core';
|
|
3
3
|
export type Nullable<T> = T | null | undefined;
|
|
4
4
|
export interface ConfigSet {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
config: Config;
|
|
6
|
+
plugins: Plugin[];
|
|
7
|
+
files: Set<string>;
|
|
8
|
+
errs: Error[];
|
|
9
9
|
}
|
|
10
|
-
export type Target =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
export type Target =
|
|
11
|
+
| string
|
|
12
|
+
| {
|
|
13
|
+
/**
|
|
14
|
+
* Target source code of evaluation
|
|
15
|
+
*/
|
|
16
|
+
sourceCode: string;
|
|
17
|
+
/**
|
|
18
|
+
* File names when `sourceCodes`
|
|
19
|
+
*/
|
|
20
|
+
name?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Workspace path when `sourceCodes`
|
|
23
|
+
*/
|
|
24
|
+
workspace?: string;
|
|
25
|
+
};
|
package/lib/utils.js
CHANGED
|
@@ -20,7 +20,7 @@ function fileExists(filePath) {
|
|
|
20
20
|
exports.fileExists = fileExists;
|
|
21
21
|
function toRegexp(pattern) {
|
|
22
22
|
const matched = pattern.match(/^\/(.+)\/([ig]*)$/i);
|
|
23
|
-
if (matched) {
|
|
23
|
+
if (matched && matched[1]) {
|
|
24
24
|
return new RegExp(matched[1], matched[2]);
|
|
25
25
|
}
|
|
26
26
|
return pattern;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/file-resolver",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
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,16 +24,16 @@
|
|
|
24
24
|
"@types/node": "latest"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@markuplint/html-parser": "3.
|
|
27
|
+
"@markuplint/html-parser": "3.4.0",
|
|
28
28
|
"@markuplint/ml-ast": "3.0.0",
|
|
29
|
-
"@markuplint/ml-config": "3.
|
|
30
|
-
"@markuplint/ml-core": "3.
|
|
31
|
-
"@markuplint/ml-spec": "3.
|
|
29
|
+
"@markuplint/ml-config": "3.4.0",
|
|
30
|
+
"@markuplint/ml-core": "3.4.0",
|
|
31
|
+
"@markuplint/ml-spec": "3.4.0",
|
|
32
32
|
"cosmiconfig": "^8.0.0",
|
|
33
33
|
"glob": "^8.0.3",
|
|
34
34
|
"jsonc": "^2.0.0",
|
|
35
35
|
"minimatch": "^5.1.1",
|
|
36
36
|
"tslib": "^2.4.1"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "a83e0f5f214a9bbcc0286b9e269074ddca6189e7"
|
|
39
39
|
}
|