markuplint 2.0.0 → 2.1.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/api/index.d.mts +2 -0
- package/lib/api/index.mjs +2 -0
- package/lib/api/lint.d.mts +4 -0
- package/lib/api/lint.mjs +15 -0
- package/lib/api/ml-engine.d.mts +27 -0
- package/lib/api/ml-engine.d.ts +18 -18
- package/lib/api/ml-engine.mjs +232 -0
- package/lib/api/types.d.mts +43 -0
- package/lib/api/types.d.ts +32 -39
- package/lib/api/types.mjs +1 -0
- package/lib/api/v1.d.mts +51 -0
- package/lib/api/v1.d.ts +43 -43
- package/lib/api/v1.mjs +39 -0
- package/lib/cli/bootstrap.d.mts +52 -0
- package/lib/cli/bootstrap.d.ts +49 -50
- package/lib/cli/bootstrap.mjs +81 -0
- package/lib/cli/command.d.mts +3 -0
- package/lib/cli/command.mjs +50 -0
- package/lib/cli/create-rule/index.d.mts +1 -0
- package/lib/cli/create-rule/index.mjs +51 -0
- package/lib/cli/index.d.mts +1 -0
- package/lib/cli/index.mjs +64 -0
- package/lib/cli/index.spec.d.mts +1 -0
- package/lib/cli/index.spec.mjs +48 -0
- package/lib/cli/init/index.d.mts +1 -0
- package/lib/cli/init/index.mjs +266 -0
- package/lib/cli/init/install-module.d.mts +5 -0
- package/lib/cli/init/install-module.d.ts +2 -2
- package/lib/cli/init/install-module.mjs +61 -0
- package/lib/cli/output.d.mts +3 -0
- package/lib/cli/output.mjs +31 -0
- package/lib/cli/prompt.d.mts +18 -0
- package/lib/cli/prompt.d.ts +12 -17
- package/lib/cli/prompt.mjs +68 -0
- package/lib/debug.d.mts +3 -0
- package/lib/debug.mjs +10 -0
- package/lib/global-settings.d.mts +5 -0
- package/lib/global-settings.d.ts +1 -1
- package/lib/global-settings.mjs +10 -0
- package/lib/i18n.d.mts +6 -0
- package/lib/i18n.d.ts +4 -4
- package/lib/i18n.mjs +19 -0
- package/lib/index.d.mts +8 -0
- package/lib/index.mjs +8 -0
- package/lib/reporter/index.d.mts +2 -0
- package/lib/reporter/index.mjs +2 -0
- package/lib/reporter/simple-reporter.d.mts +3 -0
- package/lib/reporter/simple-reporter.mjs +30 -0
- package/lib/reporter/standard-reporter.d.mts +3 -0
- package/lib/reporter/standard-reporter.mjs +43 -0
- package/lib/testing-tool/index.d.mts +35 -0
- package/lib/testing-tool/index.d.ts +25 -43
- package/lib/testing-tool/index.mjs +83 -0
- package/lib/types.d.mts +27 -0
- package/lib/types.d.ts +17 -17
- package/lib/types.mjs +1 -0
- package/lib/util.d.mts +19 -0
- package/lib/util.d.ts +3 -3
- package/lib/util.mjs +73 -0
- package/lib/v1.d.mts +4 -0
- package/lib/v1.mjs +4 -0
- package/package.json +4 -4
- package/lib/cli/head.d.ts +0 -1
- package/lib/cli/head.js +0 -31
- package/lib/reporter/utils.d.ts +0 -6
- package/lib/reporter/utils.js +0 -40
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export declare const help = "\nUsage\n\t$ markuplint <HTML file pathes (glob format)>\n\t$ <stdout> | markuplint\n\nOptions\n\t--config, -c FILE_PATH A configuration file path.\n\t--fix, Fix HTML.\n\t--format, -f FORMAT Output format. Support \"JSON\", \"Simple\" and \"Standard\". Default: \"Standard\".\n\t--no-search-config No search a configure file automatically.\n\t--ignore-ext Evaluate files that are received even though the type of extension.\n\t--no-import-preset-rules No import preset rules.\n\t--locale Locale of the message of violation. Default is an OS setting.\n\t--no-color, Output no color.\n\t--problem-only, -p Output only problems, without passeds.\n\t--verbose Output with detailed information.\n\n\t--init Initialize settings interactively.\n\t--create-rule Add the scaffold of a custom rule.\n\n\t--help, -h Show help.\n\t--version, -v Show version.\n\nExamples\n\t$ markuplint verifyee.html --config path/to/.markuplintrc\n\t$ cat verifyee.html | markuplint\n";
|
|
2
|
+
export declare const cli: import("meow").Result<{
|
|
3
|
+
config: {
|
|
4
|
+
type: "string";
|
|
5
|
+
alias: string;
|
|
6
|
+
};
|
|
7
|
+
fix: {
|
|
8
|
+
type: "boolean";
|
|
9
|
+
default: false;
|
|
10
|
+
};
|
|
11
|
+
format: {
|
|
12
|
+
type: "string";
|
|
13
|
+
alias: string;
|
|
14
|
+
};
|
|
15
|
+
searchConfig: {
|
|
16
|
+
type: "boolean";
|
|
17
|
+
default: true;
|
|
18
|
+
};
|
|
19
|
+
ignoreExt: {
|
|
20
|
+
type: "boolean";
|
|
21
|
+
default: false;
|
|
22
|
+
};
|
|
23
|
+
importPresetRules: {
|
|
24
|
+
type: "boolean";
|
|
25
|
+
default: true;
|
|
26
|
+
};
|
|
27
|
+
locale: {
|
|
28
|
+
type: "string";
|
|
29
|
+
};
|
|
30
|
+
color: {
|
|
31
|
+
type: "boolean";
|
|
32
|
+
default: true;
|
|
33
|
+
};
|
|
34
|
+
problemOnly: {
|
|
35
|
+
type: "boolean";
|
|
36
|
+
alias: string;
|
|
37
|
+
default: false;
|
|
38
|
+
};
|
|
39
|
+
verbose: {
|
|
40
|
+
type: "boolean";
|
|
41
|
+
default: false;
|
|
42
|
+
};
|
|
43
|
+
init: {
|
|
44
|
+
type: "boolean";
|
|
45
|
+
default: false;
|
|
46
|
+
};
|
|
47
|
+
createRule: {
|
|
48
|
+
type: "boolean";
|
|
49
|
+
default: false;
|
|
50
|
+
};
|
|
51
|
+
}>;
|
|
52
|
+
export declare type CLIOptions = typeof cli.flags;
|
package/lib/cli/bootstrap.d.ts
CHANGED
|
@@ -1,54 +1,53 @@
|
|
|
1
1
|
import meow from 'meow';
|
|
2
|
-
export declare const help =
|
|
3
|
-
'\nUsage\n\t$ markuplint <HTML file pathes (glob format)>\n\t$ <stdout> | markuplint\n\nOptions\n\t--config, -c FILE_PATH A configuration file path.\n\t--fix, Fix HTML.\n\t--format, -f FORMAT Output format. Support "JSON", "Simple" and "Standard". Default: "Standard".\n\t--no-search-config No search a configure file automatically.\n\t--ignore-ext Evaluate files that are received even though the type of extension.\n\t--no-import-preset-rules No import preset rules.\n\t--locale Locale of the message of violation. Default is an OS setting.\n\t--no-color, Output no color.\n\t--problem-only, -p Output only problems, without passeds.\n\t--verbose Output with detailed information.\n\n\t--init Initialize settings interactively.\n\t--create-rule Add the scaffold of a custom rule.\n\n\t--help, -h Show help.\n\t--version, -v Show version.\n\nExamples\n\t$ markuplint verifyee.html --config path/to/.markuplintrc\n\t$ cat verifyee.html | markuplint\n';
|
|
2
|
+
export declare const help = "\nUsage\n\t$ markuplint <HTML file pathes (glob format)>\n\t$ <stdout> | markuplint\n\nOptions\n\t--config, -c FILE_PATH A configuration file path.\n\t--fix, Fix HTML.\n\t--format, -f FORMAT Output format. Support \"JSON\", \"Simple\" and \"Standard\". Default: \"Standard\".\n\t--no-search-config No search a configure file automatically.\n\t--ignore-ext Evaluate files that are received even though the type of extension.\n\t--no-import-preset-rules No import preset rules.\n\t--locale Locale of the message of violation. Default is an OS setting.\n\t--no-color, Output no color.\n\t--problem-only, -p Output only problems, without passeds.\n\t--verbose Output with detailed information.\n\n\t--init Initialize settings interactively.\n\t--create-rule Add the scaffold of a custom rule.\n\n\t--help, -h Show help.\n\t--version, -v Show version.\n\nExamples\n\t$ markuplint verifyee.html --config path/to/.markuplintrc\n\t$ cat verifyee.html | markuplint\n";
|
|
4
3
|
export declare const cli: meow.Result<{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
4
|
+
config: {
|
|
5
|
+
type: "string";
|
|
6
|
+
alias: string;
|
|
7
|
+
};
|
|
8
|
+
fix: {
|
|
9
|
+
type: "boolean";
|
|
10
|
+
default: false;
|
|
11
|
+
};
|
|
12
|
+
format: {
|
|
13
|
+
type: "string";
|
|
14
|
+
alias: string;
|
|
15
|
+
};
|
|
16
|
+
searchConfig: {
|
|
17
|
+
type: "boolean";
|
|
18
|
+
default: true;
|
|
19
|
+
};
|
|
20
|
+
ignoreExt: {
|
|
21
|
+
type: "boolean";
|
|
22
|
+
default: false;
|
|
23
|
+
};
|
|
24
|
+
importPresetRules: {
|
|
25
|
+
type: "boolean";
|
|
26
|
+
default: true;
|
|
27
|
+
};
|
|
28
|
+
locale: {
|
|
29
|
+
type: "string";
|
|
30
|
+
};
|
|
31
|
+
color: {
|
|
32
|
+
type: "boolean";
|
|
33
|
+
default: true;
|
|
34
|
+
};
|
|
35
|
+
problemOnly: {
|
|
36
|
+
type: "boolean";
|
|
37
|
+
alias: string;
|
|
38
|
+
default: false;
|
|
39
|
+
};
|
|
40
|
+
verbose: {
|
|
41
|
+
type: "boolean";
|
|
42
|
+
default: false;
|
|
43
|
+
};
|
|
44
|
+
init: {
|
|
45
|
+
type: "boolean";
|
|
46
|
+
default: false;
|
|
47
|
+
};
|
|
48
|
+
createRule: {
|
|
49
|
+
type: "boolean";
|
|
50
|
+
default: false;
|
|
51
|
+
};
|
|
53
52
|
}>;
|
|
54
53
|
export declare type CLIOptions = typeof cli.flags;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import meow from 'meow';
|
|
2
|
+
export const help = `
|
|
3
|
+
Usage
|
|
4
|
+
$ markuplint <HTML file pathes (glob format)>
|
|
5
|
+
$ <stdout> | markuplint
|
|
6
|
+
|
|
7
|
+
Options
|
|
8
|
+
--config, -c FILE_PATH A configuration file path.
|
|
9
|
+
--fix, Fix HTML.
|
|
10
|
+
--format, -f FORMAT Output format. Support "JSON", "Simple" and "Standard". Default: "Standard".
|
|
11
|
+
--no-search-config No search a configure file automatically.
|
|
12
|
+
--ignore-ext Evaluate files that are received even though the type of extension.
|
|
13
|
+
--no-import-preset-rules No import preset rules.
|
|
14
|
+
--locale Locale of the message of violation. Default is an OS setting.
|
|
15
|
+
--no-color, Output no color.
|
|
16
|
+
--problem-only, -p Output only problems, without passeds.
|
|
17
|
+
--verbose Output with detailed information.
|
|
18
|
+
|
|
19
|
+
--init Initialize settings interactively.
|
|
20
|
+
--create-rule Add the scaffold of a custom rule.
|
|
21
|
+
|
|
22
|
+
--help, -h Show help.
|
|
23
|
+
--version, -v Show version.
|
|
24
|
+
|
|
25
|
+
Examples
|
|
26
|
+
$ markuplint verifyee.html --config path/to/.markuplintrc
|
|
27
|
+
$ cat verifyee.html | markuplint
|
|
28
|
+
`;
|
|
29
|
+
export const cli = meow(help, {
|
|
30
|
+
importMeta: import.meta,
|
|
31
|
+
flags: {
|
|
32
|
+
config: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
alias: 'c',
|
|
35
|
+
},
|
|
36
|
+
fix: {
|
|
37
|
+
type: 'boolean',
|
|
38
|
+
default: false,
|
|
39
|
+
},
|
|
40
|
+
format: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
alias: 'f',
|
|
43
|
+
},
|
|
44
|
+
searchConfig: {
|
|
45
|
+
type: 'boolean',
|
|
46
|
+
default: true,
|
|
47
|
+
},
|
|
48
|
+
ignoreExt: {
|
|
49
|
+
type: 'boolean',
|
|
50
|
+
default: false,
|
|
51
|
+
},
|
|
52
|
+
importPresetRules: {
|
|
53
|
+
type: 'boolean',
|
|
54
|
+
default: true,
|
|
55
|
+
},
|
|
56
|
+
locale: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
},
|
|
59
|
+
color: {
|
|
60
|
+
type: 'boolean',
|
|
61
|
+
default: true,
|
|
62
|
+
},
|
|
63
|
+
problemOnly: {
|
|
64
|
+
type: 'boolean',
|
|
65
|
+
alias: 'p',
|
|
66
|
+
default: false,
|
|
67
|
+
},
|
|
68
|
+
verbose: {
|
|
69
|
+
type: 'boolean',
|
|
70
|
+
default: false,
|
|
71
|
+
},
|
|
72
|
+
init: {
|
|
73
|
+
type: 'boolean',
|
|
74
|
+
default: false,
|
|
75
|
+
},
|
|
76
|
+
createRule: {
|
|
77
|
+
type: 'boolean',
|
|
78
|
+
default: false,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { resolveFiles } from '@markuplint/file-resolver';
|
|
4
|
+
import { MLEngine } from '../api/index.mjs';
|
|
5
|
+
import { log } from '../debug.mjs';
|
|
6
|
+
import { output } from './output.mjs';
|
|
7
|
+
export async function command(files, options) {
|
|
8
|
+
const fix = options.fix;
|
|
9
|
+
const configFile = options.config && path.join(process.cwd(), options.config);
|
|
10
|
+
const locale = options.locale;
|
|
11
|
+
const searchConfig = options.searchConfig;
|
|
12
|
+
const ignoreExt = options.ignoreExt;
|
|
13
|
+
const importPresetRules = options.importPresetRules;
|
|
14
|
+
const verbose = options.verbose;
|
|
15
|
+
const fileList = await resolveFiles(files);
|
|
16
|
+
if (log.enabled) {
|
|
17
|
+
log('File list: %O', fileList.map(f => f.path));
|
|
18
|
+
log('Config: %s', configFile || 'N/A');
|
|
19
|
+
log('Fix option: %s', fix);
|
|
20
|
+
}
|
|
21
|
+
let hasError = false;
|
|
22
|
+
for (const file of fileList) {
|
|
23
|
+
const engine = new MLEngine(file, {
|
|
24
|
+
configFile,
|
|
25
|
+
fix,
|
|
26
|
+
locale,
|
|
27
|
+
noSearchConfig: !searchConfig,
|
|
28
|
+
ignoreExt,
|
|
29
|
+
importPresetRules,
|
|
30
|
+
debug: verbose,
|
|
31
|
+
});
|
|
32
|
+
const result = await engine.exec();
|
|
33
|
+
if (!result) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (!hasError && result.violations.length) {
|
|
37
|
+
hasError = true;
|
|
38
|
+
}
|
|
39
|
+
if (fix) {
|
|
40
|
+
log('Overwrite file: %s', result.filePath);
|
|
41
|
+
await fs.writeFile(result.filePath, result.fixedCode, { encoding: 'utf8' });
|
|
42
|
+
process.stdout.write(`markuplint: Fix "${result.filePath}"\n`);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
log('Output reports');
|
|
46
|
+
await output(result, options);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return hasError;
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createRule(): Promise<void>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as createRuleHelper from '@markuplint/create-rule-helper';
|
|
2
|
+
import c from 'cli-color';
|
|
3
|
+
import { write, head } from '../../util.mjs';
|
|
4
|
+
import { installModule } from '../init/install-module.mjs';
|
|
5
|
+
import { input, select, confirm } from '../prompt.mjs';
|
|
6
|
+
export async function createRule() {
|
|
7
|
+
write(head('Create a rule'));
|
|
8
|
+
write.break();
|
|
9
|
+
const purpose = await select({
|
|
10
|
+
message: 'What purpose do you create the rule for?',
|
|
11
|
+
choices: [
|
|
12
|
+
{ name: 'Add the rule to this project', value: 'ADD_TO_PROJECT' },
|
|
13
|
+
{ name: 'Create the rule and publish it as a package', value: 'PUBLISH_AS_PACKAGE' },
|
|
14
|
+
{ name: 'Contribute the new rule to markuplint core rules', value: 'CONTRIBUTE_TO_CORE' },
|
|
15
|
+
],
|
|
16
|
+
});
|
|
17
|
+
const name = await input('What is the name?', /^[a-z][a-z0-9]*(?:-[a-z][a-z0-9]*)*$/i);
|
|
18
|
+
const lang = purpose === 'CONTRIBUTE_TO_CORE'
|
|
19
|
+
? 'TYPESCRIPT'
|
|
20
|
+
: await select({
|
|
21
|
+
message: 'Which language will you implement?',
|
|
22
|
+
choices: [
|
|
23
|
+
{ name: 'TypeScript', value: 'TYPESCRIPT' },
|
|
24
|
+
{ name: 'JavaScript', value: 'JAVASCRIPT' },
|
|
25
|
+
],
|
|
26
|
+
});
|
|
27
|
+
const needTest = purpose === 'CONTRIBUTE_TO_CORE' ? true : await confirm('Do you need the test?', { initial: true });
|
|
28
|
+
const result = await createRuleHelper.createRuleHelper({ purpose, name, lang, needTest });
|
|
29
|
+
output(name, '📝', 'README.md', result.readme);
|
|
30
|
+
output(name, '📜', 'index', result.main);
|
|
31
|
+
if (result.test) {
|
|
32
|
+
output(name, '🖍 ', 'index.spec', result.test);
|
|
33
|
+
}
|
|
34
|
+
if (result.schemaJson) {
|
|
35
|
+
output(name, '⚙️ ', 'schema.json', result.schemaJson);
|
|
36
|
+
}
|
|
37
|
+
if (result.packageJson) {
|
|
38
|
+
output(name, '🎁 ', 'package.json', result.packageJson);
|
|
39
|
+
if (result.tsConfig) {
|
|
40
|
+
output(name, '💎 ', 'tsconfig.json', result.tsConfig);
|
|
41
|
+
}
|
|
42
|
+
await installModule(result.dependencies);
|
|
43
|
+
await installModule(result.devDependencies, true);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function output(name, icon, title, path) {
|
|
47
|
+
const _marker = c.xterm(39)('✔') + ' ';
|
|
48
|
+
const _title = (icon, title) => `${icon} ` + c.bold(`${name}/${title}`);
|
|
49
|
+
const _file = (path) => ' ' + c.cyanBright(path);
|
|
50
|
+
write(_marker + _title(icon, title) + _file(path));
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import getStdin from 'get-stdin';
|
|
2
|
+
import { verbosely } from '../debug.mjs';
|
|
3
|
+
import { cli } from './bootstrap.mjs';
|
|
4
|
+
import { command } from './command.mjs';
|
|
5
|
+
import { createRule } from './create-rule/index.mjs';
|
|
6
|
+
import { initialize } from './init/index.mjs';
|
|
7
|
+
(async () => {
|
|
8
|
+
if (cli.flags.v) {
|
|
9
|
+
cli.showVersion(); // And exit successfully.
|
|
10
|
+
}
|
|
11
|
+
if (cli.flags.h) {
|
|
12
|
+
cli.showHelp(0); // And exit successfully.
|
|
13
|
+
}
|
|
14
|
+
if (cli.flags.verbose) {
|
|
15
|
+
verbosely();
|
|
16
|
+
}
|
|
17
|
+
if (cli.flags.init) {
|
|
18
|
+
await initialize().catch(err => {
|
|
19
|
+
process.stderr.write(err + '\n');
|
|
20
|
+
process.exit(1);
|
|
21
|
+
});
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (cli.flags.createRule) {
|
|
25
|
+
await createRule().catch(err => {
|
|
26
|
+
process.stderr.write(err + '\n');
|
|
27
|
+
process.exit(1);
|
|
28
|
+
});
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const files = cli.input;
|
|
32
|
+
if (files.length) {
|
|
33
|
+
const hasError = await command(files, cli.flags).catch(err => {
|
|
34
|
+
throw err;
|
|
35
|
+
// process.exit(1);
|
|
36
|
+
});
|
|
37
|
+
process.exit(hasError ? 1 : 0);
|
|
38
|
+
}
|
|
39
|
+
if (usePipe()) {
|
|
40
|
+
getStdin()
|
|
41
|
+
.then(async (stdin) => {
|
|
42
|
+
if (stdin) {
|
|
43
|
+
const hasError = await command([{ sourceCode: stdin }], cli.flags).catch(err => {
|
|
44
|
+
process.stderr.write(err + '\n');
|
|
45
|
+
process.exit(1);
|
|
46
|
+
});
|
|
47
|
+
process.exit(hasError ? 1 : 0);
|
|
48
|
+
}
|
|
49
|
+
// result is empty
|
|
50
|
+
cli.showHelp(1);
|
|
51
|
+
})
|
|
52
|
+
.catch(reason => {
|
|
53
|
+
// eslint-disable-next-line no-console
|
|
54
|
+
console.warn(reason);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
cli.showHelp(1);
|
|
60
|
+
}
|
|
61
|
+
})();
|
|
62
|
+
function usePipe() {
|
|
63
|
+
return !process.stdin.isTTY && process.stdout.isTTY;
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { execa } from 'execa';
|
|
3
|
+
import { cli } from './bootstrap.mjs';
|
|
4
|
+
const entryFilePath = path.resolve(__dirname, '../../bin/markuplint');
|
|
5
|
+
describe('STDOUT Test', () => {
|
|
6
|
+
it('empty', async () => {
|
|
7
|
+
const resultPromise = execa(entryFilePath, []);
|
|
8
|
+
await expect(resultPromise).rejects.toThrow(cli.help);
|
|
9
|
+
});
|
|
10
|
+
it('version', async () => {
|
|
11
|
+
const { stdout } = await execa(entryFilePath, ['--version']);
|
|
12
|
+
expect(stdout).toBe(cli.pkg.version);
|
|
13
|
+
});
|
|
14
|
+
it('version', async () => {
|
|
15
|
+
const { stdout } = await execa(entryFilePath, ['-v']);
|
|
16
|
+
expect(stdout).toBe(cli.pkg.version);
|
|
17
|
+
});
|
|
18
|
+
it('version', async () => {
|
|
19
|
+
const { stdout } = await execa(entryFilePath, ['--help']);
|
|
20
|
+
const { stdout: stdoutShort } = await execa(entryFilePath, ['-h']);
|
|
21
|
+
expect(stdout).toBe(stdoutShort);
|
|
22
|
+
});
|
|
23
|
+
it('verify', async () => {
|
|
24
|
+
const targetFilePath = path.resolve(__dirname, '../../../../test/fixture/001.html');
|
|
25
|
+
const { stdout, exitCode } = await execa(entryFilePath, ['--no-color', targetFilePath]);
|
|
26
|
+
expect(stdout).toBe(`<markuplint> passed ${targetFilePath}`);
|
|
27
|
+
expect(exitCode).toBe(0);
|
|
28
|
+
});
|
|
29
|
+
it('verify --problem-only', async () => {
|
|
30
|
+
const targetFilePath = path.resolve(__dirname, '../../../../test/fixture/001.html');
|
|
31
|
+
const { stdout } = await execa(entryFilePath, ['--problem-only', targetFilePath]);
|
|
32
|
+
expect(stdout).toBe('');
|
|
33
|
+
});
|
|
34
|
+
it('verify and feilure', async () => {
|
|
35
|
+
const targetFilePath = path.resolve(__dirname, '../../../../test/fixture/002.html');
|
|
36
|
+
const { stdout, stderr, exitCode } = await execa(entryFilePath, ['--no-color', targetFilePath], {
|
|
37
|
+
reject: false,
|
|
38
|
+
});
|
|
39
|
+
expect(stdout).toBe('');
|
|
40
|
+
expect(stderr.split('\n').length).toBe(34);
|
|
41
|
+
expect(exitCode).toBe(1);
|
|
42
|
+
});
|
|
43
|
+
it('format', async () => {
|
|
44
|
+
const targetFilePath = path.resolve(__dirname, '../../../../test/fixture/001.html');
|
|
45
|
+
const { stdout } = await execa(entryFilePath, ['--format', 'JSON', targetFilePath]);
|
|
46
|
+
expect(stdout).toBe('[]');
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function initialize(): Promise<void>;
|