markuplint 4.0.0-alpha.2 → 4.0.0-alpha.3
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/api/ml-engine.js +16 -5
- package/lib/debug.js +3 -2
- package/lib/index.d.ts +1 -0
- package/package.json +13 -13
package/lib/api/ml-engine.js
CHANGED
|
@@ -11,6 +11,10 @@ const fileLog = log.extend('file');
|
|
|
11
11
|
const configLog = log.extend('config');
|
|
12
12
|
class MLEngine extends Emitter {
|
|
13
13
|
static async fromCode(sourceCode, options) {
|
|
14
|
+
if (options?.debug) {
|
|
15
|
+
verbosely();
|
|
16
|
+
}
|
|
17
|
+
log('[fromCode] Creates: %O', options);
|
|
14
18
|
const file = await MLEngine.toMLFile({
|
|
15
19
|
sourceCode,
|
|
16
20
|
name: options?.name,
|
|
@@ -19,7 +23,9 @@ class MLEngine extends Emitter {
|
|
|
19
23
|
if (!file) {
|
|
20
24
|
throw new Error('Never reach error');
|
|
21
25
|
}
|
|
22
|
-
|
|
26
|
+
log('[fromCode] Created file: %s', file.path);
|
|
27
|
+
const engine = new MLEngine(file, options);
|
|
28
|
+
return engine;
|
|
23
29
|
}
|
|
24
30
|
static async toMLFile(target) {
|
|
25
31
|
const files = await resolveFiles([target]);
|
|
@@ -32,13 +38,14 @@ class MLEngine extends Emitter {
|
|
|
32
38
|
_MLEngine_file.set(this, void 0);
|
|
33
39
|
_MLEngine_options.set(this, void 0);
|
|
34
40
|
_MLEngine_watcher.set(this, new FSWatcher());
|
|
41
|
+
if (__classPrivateFieldGet(this, _MLEngine_options, "f")?.debug) {
|
|
42
|
+
verbosely();
|
|
43
|
+
}
|
|
35
44
|
__classPrivateFieldSet(this, _MLEngine_file, file, "f");
|
|
36
45
|
__classPrivateFieldSet(this, _MLEngine_options, options, "f");
|
|
37
46
|
__classPrivateFieldSet(this, _MLEngine_configProvider, new ConfigProvider(), "f");
|
|
38
47
|
this.watchMode(!!__classPrivateFieldGet(this, _MLEngine_options, "f")?.watch);
|
|
39
|
-
|
|
40
|
-
verbosely();
|
|
41
|
-
}
|
|
48
|
+
log('[MLEngine] Initialized: %s', __classPrivateFieldGet(this, _MLEngine_file, "f").path);
|
|
42
49
|
}
|
|
43
50
|
get document() {
|
|
44
51
|
if (__classPrivateFieldGet(this, _MLEngine_core, "f")?.document instanceof Error) {
|
|
@@ -225,12 +232,16 @@ class MLEngine extends Emitter {
|
|
|
225
232
|
};
|
|
226
233
|
}
|
|
227
234
|
async resolveConfig(cache) {
|
|
235
|
+
this.emit('log', 'resolveConfig', JSON.stringify(__classPrivateFieldGet(this, _MLEngine_configProvider, "f"), null, 2));
|
|
236
|
+
configLog('configProvider: %s', __classPrivateFieldGet(this, _MLEngine_configProvider, "f"));
|
|
228
237
|
const defaultConfigKey = __classPrivateFieldGet(this, _MLEngine_options, "f")?.defaultConfig && __classPrivateFieldGet(this, _MLEngine_configProvider, "f").set(__classPrivateFieldGet(this, _MLEngine_options, "f")?.defaultConfig);
|
|
229
238
|
configLog('defaultConfigKey: %s', defaultConfigKey ?? 'N/A');
|
|
230
239
|
this.emit('log', 'defaultConfigKey', defaultConfigKey ?? 'N/A');
|
|
240
|
+
const targetConfig = await __classPrivateFieldGet(this, _MLEngine_configProvider, "f").search(__classPrivateFieldGet(this, _MLEngine_file, "f"));
|
|
241
|
+
this.emit('log', 'targetConfig', targetConfig ?? 'N/A');
|
|
231
242
|
const configFilePathsFromTarget = __classPrivateFieldGet(this, _MLEngine_options, "f")?.noSearchConfig
|
|
232
243
|
? defaultConfigKey ?? null
|
|
233
|
-
:
|
|
244
|
+
: targetConfig ?? defaultConfigKey;
|
|
234
245
|
configLog('configFilePathsFromTarget: %s', configFilePathsFromTarget ?? 'N/A');
|
|
235
246
|
this.emit('log', 'configFilePathsFromTarget', configFilePathsFromTarget ?? 'N/A');
|
|
236
247
|
const configKey = __classPrivateFieldGet(this, _MLEngine_options, "f")?.config && __classPrivateFieldGet(this, _MLEngine_configProvider, "f").set(__classPrivateFieldGet(this, _MLEngine_options, "f").config);
|
package/lib/debug.js
CHANGED
|
@@ -3,8 +3,9 @@ import debug from 'debug';
|
|
|
3
3
|
export const log = debug('markuplint-cli');
|
|
4
4
|
export function verbosely() {
|
|
5
5
|
if (!log.enabled) {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const namespace = `${log.namespace}*,ml-*`;
|
|
7
|
+
debug.enable(namespace);
|
|
8
|
+
log(`[Debug] Enable: "${namespace}"`);
|
|
8
9
|
}
|
|
9
10
|
enableDebug();
|
|
10
11
|
}
|
package/lib/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markuplint",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.3",
|
|
4
4
|
"description": "An HTML linter for all markup developers",
|
|
5
5
|
"author": "Yusuke Hirao",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,17 +28,17 @@
|
|
|
28
28
|
"execa": "^8.0.1"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@markuplint/create-rule-helper": "4.0.0-alpha.
|
|
32
|
-
"@markuplint/file-resolver": "4.0.0-alpha.
|
|
33
|
-
"@markuplint/html-parser": "4.0.0-alpha.
|
|
34
|
-
"@markuplint/html-spec": "4.0.0-alpha.
|
|
35
|
-
"@markuplint/i18n": "4.0.0-alpha.
|
|
36
|
-
"@markuplint/ml-ast": "4.0.0-alpha.
|
|
37
|
-
"@markuplint/ml-config": "4.0.0-alpha.
|
|
38
|
-
"@markuplint/ml-core": "4.0.0-alpha.
|
|
39
|
-
"@markuplint/ml-spec": "4.0.0-alpha.
|
|
40
|
-
"@markuplint/rules": "4.0.0-alpha.
|
|
41
|
-
"@markuplint/shared": "4.0.0-alpha.
|
|
31
|
+
"@markuplint/create-rule-helper": "4.0.0-alpha.3",
|
|
32
|
+
"@markuplint/file-resolver": "4.0.0-alpha.3",
|
|
33
|
+
"@markuplint/html-parser": "4.0.0-alpha.3",
|
|
34
|
+
"@markuplint/html-spec": "4.0.0-alpha.3",
|
|
35
|
+
"@markuplint/i18n": "4.0.0-alpha.3",
|
|
36
|
+
"@markuplint/ml-ast": "4.0.0-alpha.3",
|
|
37
|
+
"@markuplint/ml-config": "4.0.0-alpha.3",
|
|
38
|
+
"@markuplint/ml-core": "4.0.0-alpha.3",
|
|
39
|
+
"@markuplint/ml-spec": "4.0.0-alpha.3",
|
|
40
|
+
"@markuplint/rules": "4.0.0-alpha.3",
|
|
41
|
+
"@markuplint/shared": "4.0.0-alpha.3",
|
|
42
42
|
"@types/cli-color": "^2.0.3",
|
|
43
43
|
"@types/debug": "^4.1.9",
|
|
44
44
|
"@types/has-yarn": "^1.0.1",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"type-fest": "^4.3.1",
|
|
63
63
|
"uuid": "^9.0.1"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "380836f7adc1ff7e8eaf9d869e68d29eee8f3b7e"
|
|
66
66
|
}
|