ko-lints 1.0.0-alpha.2 → 3.0.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/README.md CHANGED
@@ -1,5 +1,3 @@
1
1
  # ko-lint
2
2
 
3
- This package is a lint cli used by [ko](https://github.com/DTStack/ko)
4
-
5
- ## Usage Outside of ko
3
+ This package is used by [ko](https://github.com/DTStack/ko)
package/index.d.ts CHANGED
@@ -1,3 +1,19 @@
1
- import { Command } from 'commander';
1
+ import { Pattern } from 'fast-glob';
2
2
 
3
- export default function initKoLintCli(p: Command): void
3
+ export type IOpts = {
4
+ write: boolean;
5
+ configPath: string;
6
+ patterns: Pattern[];
7
+ };
8
+
9
+ export type IKeys = 'eslint' | 'prettier' | 'stylelint';
10
+
11
+ declare class Lints {
12
+ private runner;
13
+ private opts;
14
+ state: 0 | 1;
15
+ constructor(opts: IOpts);
16
+ run(key: IKeys): Promise<true | string[]>;
17
+ }
18
+
19
+ export default Lints;
package/lib/eslint.js CHANGED
@@ -1,47 +1,70 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatFilesWithEslint = void 0;
4
- const utils_1 = require("./utils");
5
- const eslint_1 = require("eslint");
6
- const constants_1 = require("./constants");
7
- async function formatFilesWithEslint(opts) {
8
- const { targetFiles, configPath, fix } = opts;
9
- const config = configPath ? require(utils_1.findRealPath(configPath)) : require('ko-config/eslint');
10
- const extensions = [constants_1.Extensions.JS, constants_1.Extensions.JSX, constants_1.Extensions.TS, constants_1.Extensions.TSX];
11
- const eslint = new eslint_1.ESLint({ fix, overrideConfig: config, useEslintrc: false, extensions });
12
- const formatter = await eslint.loadFormatter();
13
- const eslintFilesPromises = targetFiles.map(async (file) => {
14
- try {
15
- const result = await eslint.lintFiles(file);
16
- if (result[0].errorCount) {
17
- const resultText = formatter.format(result);
18
- console.log(resultText);
19
- return false;
6
+ const ko_lint_config_1 = require("ko-lint-config");
7
+ const factory_1 = __importDefault(require("./factory"));
8
+ const { ESLint } = ko_lint_config_1.eslint;
9
+ class ESlintRunner extends factory_1.default {
10
+ constructor(opts) {
11
+ super();
12
+ this.stdout = [];
13
+ this.opts = opts;
14
+ this.generateConfig();
15
+ }
16
+ generateConfig() {
17
+ if (this.opts.configPath) {
18
+ this.config = this.getConfigFromFile(this.opts.configPath);
19
+ }
20
+ else {
21
+ const localConfigPath = this.detectLocalRunnerConfig('eslint');
22
+ if (localConfigPath) {
23
+ this.config = this.getConfigFromFile(localConfigPath);
20
24
  }
21
- return true;
22
25
  }
23
- catch (ex) {
24
- throw ex;
26
+ }
27
+ async start() {
28
+ const { write, patterns } = this.opts;
29
+ const entries = await this.getEntries(patterns, [
30
+ ...ESlintRunner.IGNORE_FILES,
31
+ ]);
32
+ if (entries.length === 0) {
33
+ console.log(`No files matched with pattern:${patterns} via ${ESlintRunner.NAME}`);
34
+ process.exit(0);
25
35
  }
26
- });
27
- try {
28
- let stdout = '';
29
- const result = await Promise.all(eslintFilesPromises);
30
- if (!fix) {
36
+ const eslintInstance = new ESLint({
37
+ fix: write,
38
+ overrideConfig: this.config,
39
+ useEslintrc: false,
40
+ extensions: ESlintRunner.EXTENSIONS,
41
+ });
42
+ try {
43
+ const formatter = await eslintInstance.loadFormatter();
44
+ const eslintFilesPromises = entries.map(async (file) => {
45
+ const result = await eslintInstance.lintFiles(file);
46
+ if (result[0].errorCount) {
47
+ const resultText = formatter.format(result);
48
+ this.stdout.push(resultText);
49
+ return false;
50
+ }
51
+ return true;
52
+ });
53
+ const result = await Promise.all(eslintFilesPromises);
31
54
  if (result.includes(false)) {
32
- stdout = 'Not all matched files are linted';
55
+ return this.stdout;
33
56
  }
34
57
  else {
35
- stdout = 'All matched files are linted';
58
+ return true;
36
59
  }
37
60
  }
38
- else {
39
- stdout = 'All matched files has been fixed successfully!';
61
+ catch (ex) {
62
+ console.error(ex);
63
+ process.exit(1);
40
64
  }
41
- console.log(stdout);
42
- }
43
- catch (ex) {
44
- console.log('eslint failed: ', ex);
45
65
  }
46
66
  }
47
- exports.formatFilesWithEslint = formatFilesWithEslint;
67
+ ESlintRunner.EXTENSIONS = ['ts', 'tsx', 'js', 'jsx'];
68
+ ESlintRunner.IGNORE_FILES = ['.eslintignore'];
69
+ ESlintRunner.NAME = 'eslint';
70
+ exports.default = ESlintRunner;
package/lib/factory.js ADDED
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const path_1 = require("path");
7
+ const fs_1 = require("fs");
8
+ const assert_1 = __importDefault(require("assert"));
9
+ const fast_glob_1 = __importDefault(require("fast-glob"));
10
+ class LintRunnerFactory {
11
+ constructor() {
12
+ this.cwd = process.cwd();
13
+ }
14
+ async getEntries(patterns, ignoreFiles) {
15
+ return (0, fast_glob_1.default)(patterns, {
16
+ dot: true,
17
+ ignore: this.getIgnorePatterns(...ignoreFiles),
18
+ });
19
+ }
20
+ getIgnorePatterns(...ignoreFiles) {
21
+ return ['.gitignore', ...ignoreFiles]
22
+ .map(fileName => {
23
+ const filePath = (0, path_1.join)(this.cwd, fileName);
24
+ if ((0, fs_1.existsSync)(filePath)) {
25
+ return (0, fs_1.readFileSync)(filePath, 'utf-8')
26
+ .split('\n')
27
+ .filter(str => str && !str.startsWith('#'));
28
+ }
29
+ return [];
30
+ })
31
+ .reduce((acc, current) => {
32
+ current.forEach(p => {
33
+ if (!acc.includes(p)) {
34
+ acc.push(p);
35
+ }
36
+ });
37
+ return acc;
38
+ }, []);
39
+ }
40
+ getConfigFromFile(filepath) {
41
+ (0, assert_1.default)((0, path_1.isAbsolute)(filepath), 'only accept absolute config filepath');
42
+ return require(filepath);
43
+ }
44
+ detectLocalRunnerConfig(name) {
45
+ const cwd = process.cwd();
46
+ const files = (0, fs_1.readdirSync)(cwd).filter(path => !(0, fs_1.statSync)(path).isDirectory());
47
+ let ret = '';
48
+ for (let file of files) {
49
+ if (file.includes(name) && !file.includes('ignore')) {
50
+ ret = file;
51
+ break;
52
+ }
53
+ }
54
+ return ret ? (0, path_1.join)(cwd, ret) : ret;
55
+ }
56
+ }
57
+ exports.default = LintRunnerFactory;
package/lib/index.js CHANGED
@@ -1,32 +1,30 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const constants_1 = require("./constants");
4
- const utils_1 = require("./utils");
5
- const prettier_1 = require("./prettier");
6
- const eslint_1 = require("./eslint");
7
- function initKoLintCli(program) {
8
- program
9
- .command('prettier [patterns]')
10
- .alias('pr')
11
- .description('use prettier to format your codes')
12
- .option('-w, --write', 'Edit files in-place. (Beware!)')
13
- .option('-c, --config <configPath>', 'specify prettier config path')
14
- .option('--ignore-path <ignorePath>', 'specify prettier ignore path')
15
- .action((patterns = constants_1.defaultPatterns, opts) => {
16
- const { write, configPath, ignorePath } = opts;
17
- const targetFiles = utils_1.getTargetFiles(patterns, ignorePath);
18
- prettier_1.formatFilesWithPrettier(targetFiles, !write, configPath);
19
- });
20
- program
21
- .command('eslint [patterns]')
22
- .alias('es')
23
- .description('use eslint to format your codes')
24
- .option('-f, --fix', 'Automatically fix problems')
25
- .option('-c, --config <configPath>', 'specify eslint config path')
26
- .option('--ignore-path <ignorePath>', 'specify prettier ignore path')
27
- .action((patterns = constants_1.defaultPatterns, opts) => {
28
- const targetFiles = utils_1.getTargetFiles(patterns, opts.ignorePath);
29
- eslint_1.formatFilesWithEslint({ targetFiles, ...opts });
30
- });
6
+ const eslint_1 = __importDefault(require("./eslint"));
7
+ const prettier_1 = __importDefault(require("./prettier"));
8
+ const stylelint_1 = __importDefault(require("./stylelint"));
9
+ class Lints {
10
+ constructor(opts) {
11
+ this.opts = opts;
12
+ }
13
+ async run(key) {
14
+ switch (key) {
15
+ case 'eslint':
16
+ this.runner = new eslint_1.default(this.opts);
17
+ break;
18
+ case 'prettier':
19
+ this.runner = new prettier_1.default(this.opts);
20
+ break;
21
+ case 'stylelint':
22
+ this.runner = new stylelint_1.default(this.opts);
23
+ break;
24
+ }
25
+ this.runner.generateConfig();
26
+ const result = await this.runner.start();
27
+ return result;
28
+ }
31
29
  }
32
- exports.default = initKoLintCli;
30
+ exports.default = Lints;
package/lib/prettier.js CHANGED
@@ -1,48 +1,73 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatFilesWithPrettier = void 0;
4
- const fs_1 = require("fs");
5
- const prettier_1 = require("prettier");
6
- const utils_1 = require("./utils");
7
- async function formatFilesWithPrettier(files, isCheck, configPath) {
8
- const prettierConfig = configPath
9
- ? require(utils_1.findRealPath(configPath))
10
- : require('ko-config/prettier');
11
- console.log('prettier process starting...');
12
- const formatFilesPromises = files.map(async (file) => {
13
- try {
14
- const source = await fs_1.promises.readFile(file, 'utf-8');
15
- const opts = { ...prettierConfig, filepath: file };
16
- if (isCheck) {
17
- return prettier_1.check(source, opts);
18
- }
19
- else {
20
- const formatContent = prettier_1.format(source, opts);
21
- return fs_1.promises.writeFile(file, formatContent, 'utf-8');
6
+ const promises_1 = require("fs/promises");
7
+ const ko_lint_config_1 = require("ko-lint-config");
8
+ const factory_1 = __importDefault(require("./factory"));
9
+ const { format, check } = ko_lint_config_1.prettier;
10
+ class PrettierRunner extends factory_1.default {
11
+ constructor(opts) {
12
+ super();
13
+ this.stdout = [];
14
+ this.opts = opts;
15
+ this.generateConfig();
16
+ }
17
+ generateConfig() {
18
+ if (this.opts.configPath) {
19
+ this.config = this.getConfigFromFile(this.opts.configPath);
20
+ }
21
+ else {
22
+ const localConfigPath = this.detectLocalRunnerConfig('prettier');
23
+ if (localConfigPath) {
24
+ this.config = this.getConfigFromFile(localConfigPath);
22
25
  }
23
26
  }
24
- catch (ex) {
25
- throw ex;
27
+ }
28
+ async start() {
29
+ const { write, patterns } = this.opts;
30
+ const entries = await this.getEntries(patterns, [
31
+ ...PrettierRunner.IGNORE_FILES,
32
+ ]);
33
+ if (entries.length === 0) {
34
+ console.log(`No files matched with pattern:${patterns} via ${PrettierRunner.NAME}`);
35
+ process.exit(0);
26
36
  }
27
- });
28
- try {
29
- let stdout = '';
30
- const result = await Promise.all(formatFilesPromises);
31
- if (isCheck) {
37
+ try {
38
+ const formatFilesPromises = entries.map(async (file) => {
39
+ const source = await (0, promises_1.readFile)(file, 'utf-8');
40
+ const opts = { ...this.config, filepath: file };
41
+ if (write) {
42
+ const formatContent = format(source, opts);
43
+ await (0, promises_1.writeFile)(file, formatContent, 'utf-8');
44
+ return true;
45
+ }
46
+ else {
47
+ if (check(source, opts)) {
48
+ return true;
49
+ }
50
+ else {
51
+ this.stdout.push(`file ${opts.filepath} doesn't match prettier config`);
52
+ return false;
53
+ }
54
+ }
55
+ });
56
+ const result = await Promise.all(formatFilesPromises);
32
57
  if (result.includes(false)) {
33
- stdout = 'Not all matched files are formatted';
58
+ return this.stdout;
34
59
  }
35
60
  else {
36
- stdout = 'All matched files are formatted';
61
+ return true;
37
62
  }
38
63
  }
39
- else {
40
- stdout = 'All matched files are rewrited successfully!';
64
+ catch (ex) {
65
+ console.error(ex);
66
+ process.exit(1);
41
67
  }
42
- console.log(stdout);
43
- }
44
- catch (ex) {
45
- console.error('prettier failed:', ex);
46
68
  }
47
69
  }
48
- exports.formatFilesWithPrettier = formatFilesWithPrettier;
70
+ PrettierRunner.EXTENSIONS = ['ts', 'tsx', 'js', 'jsx', 'json'];
71
+ PrettierRunner.IGNORE_FILES = ['.prettierignore'];
72
+ PrettierRunner.NAME = 'prettier';
73
+ exports.default = PrettierRunner;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const ko_lint_config_1 = require("ko-lint-config");
7
+ const factory_1 = __importDefault(require("./factory"));
8
+ const { lint, formatters } = ko_lint_config_1.stylelint;
9
+ class StyleLintRunner extends factory_1.default {
10
+ constructor(opts) {
11
+ super();
12
+ this.stdout = [];
13
+ this.opts = opts;
14
+ this.generateConfig();
15
+ }
16
+ generateConfig() {
17
+ if (this.opts.configPath) {
18
+ this.config = this.getConfigFromFile(this.opts.configPath);
19
+ }
20
+ else {
21
+ const localConfigPath = this.detectLocalRunnerConfig(StyleLintRunner.NAME);
22
+ if (localConfigPath) {
23
+ this.config = this.getConfigFromFile(localConfigPath);
24
+ }
25
+ }
26
+ }
27
+ async start() {
28
+ const { write, patterns } = this.opts;
29
+ const entries = await this.getEntries(patterns, [
30
+ ...StyleLintRunner.IGNORE_FILES,
31
+ ]);
32
+ if (entries.length === 0) {
33
+ console.log(`No files matched with pattern:${patterns} via ${StyleLintRunner.NAME}`);
34
+ process.exit(0);
35
+ }
36
+ try {
37
+ const result = await lint({
38
+ fix: write,
39
+ config: this.config,
40
+ files: entries,
41
+ });
42
+ if (result.errored) {
43
+ this.stdout = [formatters.string(result.results)];
44
+ return this.stdout;
45
+ }
46
+ else {
47
+ return true;
48
+ }
49
+ }
50
+ catch (ex) {
51
+ console.error(ex);
52
+ process.exit(1);
53
+ }
54
+ }
55
+ }
56
+ StyleLintRunner.EXTENSIONS = ['css', 'less', 'sass', 'scss'];
57
+ StyleLintRunner.IGNORE_FILES = ['.stylelintignore'];
58
+ StyleLintRunner.NAME = 'stylelint';
59
+ exports.default = StyleLintRunner;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ko-lints",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "3.0.0",
4
4
  "description": "lint tools used by ko",
5
5
  "keywords": [
6
6
  "ko",
@@ -16,31 +16,28 @@
16
16
  "repository": {
17
17
  "type": "git",
18
18
  "url": "https://github.com/DTStack/ko",
19
- "directory": "packages/ko-lint"
19
+ "directory": "packages/ko-lints"
20
20
  },
21
21
  "license": "MIT",
22
- "main": "./lib/index.js",
23
- "typings": "./index.d.ts",
24
- "bin": {
25
- "ko-lints": "./lib/cli.js"
26
- },
22
+ "typings": "index.d.ts",
23
+ "main": "lib/index.js",
27
24
  "files": [
28
25
  "lib/*",
29
26
  "index.d.ts"
30
27
  ],
31
- "scripts": {
32
- "prepublishOnly": "tsc",
33
- "build": "tsc",
34
- "debug": "tsc --sourcemap -w"
35
- },
36
28
  "dependencies": {
37
- "@types/prettier": "^2.3.2",
38
- "commander": "^8.1.0",
39
- "fast-glob": "^3.2.7",
40
- "ko-config": "^1.0.0-alpha.2"
29
+ "fast-glob": "^3.2.11"
30
+ },
31
+ "peerDependencies": {
32
+ "ko-lint-config": "2.0.0"
41
33
  },
42
34
  "devDependencies": {
43
- "typescript": "^4.3.5"
35
+ "typescript": "^4.6.4",
36
+ "ko-lint-config": "2.0.0"
37
+ },
38
+ "scripts": {
39
+ "build": "tsc",
40
+ "debug": "tsc --sourcemap -w"
44
41
  },
45
- "gitHead": "3475f6b659fbde6d6149c34e75678c37ecad6345"
46
- }
42
+ "readme": "# ko-lint\n\nThis package is used by [ko](https://github.com/DTStack/ko)\n"
43
+ }
package/lib/cli.js DELETED
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const commander_1 = require("commander");
8
- const index_1 = __importDefault(require("./index"));
9
- const pkg = require('../package.json');
10
- const program = new commander_1.Command();
11
- program.description('ko lint tools').version(pkg.version, '-v --version');
12
- index_1.default(program);
13
- program.parse();
package/lib/cli.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,YAAY,CAAC;;;;;AAEb,yCAAoC;AACpC,oDAAoC;AAEpC,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACvC,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;AAE1E,eAAa,CAAC,OAAO,CAAC,CAAC;AAEvB,OAAO,CAAC,KAAK,EAAE,CAAC"}
package/lib/constants.js DELETED
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Extensions = exports.defaultPatterns = exports.defaultIgnoreFile = void 0;
4
- exports.defaultIgnoreFile = '.koignore';
5
- exports.defaultPatterns = '*';
6
- var Extensions;
7
- (function (Extensions) {
8
- Extensions["JS"] = "js";
9
- Extensions["TS"] = "ts";
10
- Extensions["JSX"] = "jsx";
11
- Extensions["TSX"] = "tsx";
12
- })(Extensions = exports.Extensions || (exports.Extensions = {}));
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG,WAAW,CAAC;AAEhC,QAAA,eAAe,GAAG,GAAG,CAAC;AAEnC,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,uBAAS,CAAA;IACT,uBAAS,CAAA;IACT,yBAAW,CAAA;IACX,yBAAW,CAAA;AACb,CAAC,EALW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAKrB"}
package/lib/eslint.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"eslint.js","sourceRoot":"","sources":["../src/eslint.ts"],"names":[],"mappings":";;;AAAA,mCAAuC;AACvC,mCAAgC;AAChC,2CAAyC;AAGl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M,CAAC,2BAA2B,EAAE,4BAA4B,CAAC;SACjE,MAAM,CAAC,4BAA4B,EAAE,8BAA8B,CAAC;SACpE,MAAM,CAAC,CAAC,WAAoB,2BAAe,EAAE,IAAmB,EAAE,EAAE;QACnE,MAAM,WAAW,GAAG,sBAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC9D,8BAAqB,CAAC,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,CAAC,CAAA;IACjD,CAAC,CAAC,CAAC;AACP,CAAC;AAED,kBAAe,aAAa,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"prettier.js","sourceRoot":"","sources":["../src/prettier.ts"],"names":[],"mappings":";;;AAAA,2BAA8B;AAC9B,uCAAyC;AACzC,mCAAuC;AAEhC,KAAK,UAAU,uBAAuB,CAC3C,KAAe,EACf,OAAgB,EAChB,UAAmB;IAEnB,MAAM,cAAc,GAAG,UAAU;QAC/B,CAAC,CAAC,OAAO,CAAC,oBAAY,CAAC,UAAU,CAAC,CAAC;QACnC,CAAC,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAClC,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;IAC5C,MAAM,mBAAmB,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACnD,IAAI;YACF,MAAM,MAAM,GAAG,MAAM,aAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACtD,MAAM,IAAI,GAAG,EAAE,GAAG,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YACnD,IAAI,OAAO,EAAE;gBACX,OAAO,gBAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;aAC5B;iBAAM;gBACL,MAAM,aAAa,GAAG,iBAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;gBAC3C,OAAO,aAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;aACzD;SACF;QAAC,OAAO,EAAE,EAAE;YACX,MAAM,EAAE,CAAC;SACV;IACH,CAAC,CAAC,CAAC;IACH,IAAI;QACF,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QACtD,IAAI,OAAO,EAAE;YACX,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;gBAC1B,MAAM,GAAG,qCAAqC,CAAC;aAChD;iBAAM;gBACL,MAAM,GAAG,iCAAiC,CAAC;aAC5C;SACF;aAAM;YACL,MAAM,GAAG,8CAA8C,CAAC;SACzD;QACD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;KACrB;IAAC,OAAO,EAAE,EAAE;QACX,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;KACvC;AACH,CAAC;AAvCD,0DAuCC"}
package/lib/utils.js DELETED
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTargetFiles = exports.findRealPath = void 0;
4
- const fs_1 = require("fs");
5
- const path_1 = require("path");
6
- const fast_glob_1 = require("fast-glob");
7
- const constants_1 = require("./constants");
8
- function findRealPath(configPath) {
9
- if (!fs_1.realpathSync(configPath)) {
10
- configPath = path_1.join(process.cwd(), configPath);
11
- }
12
- if (fs_1.existsSync(configPath)) {
13
- return configPath;
14
- }
15
- throw new Error('config file is not exist, please checkout config file path!');
16
- }
17
- exports.findRealPath = findRealPath;
18
- /**
19
- * @link Pattern syntax: https://github.com/mrmlnc/fast-glob#pattern-syntax
20
- */
21
- function getTargetFiles(patterns, ignoreFile) {
22
- if (!ignoreFile) {
23
- ignoreFile = path_1.join(process.cwd(), constants_1.defaultIgnoreFile);
24
- }
25
- return fast_glob_1.sync(patterns, {
26
- ignore: getIgnorePatterns(ignoreFile),
27
- });
28
- }
29
- exports.getTargetFiles = getTargetFiles;
30
- function getIgnorePatterns(ignoreFile) {
31
- const gitIgnorePath = path_1.join(process.cwd(), '.gitignore');
32
- const gitIgnorePatterns = getFilePatterns(gitIgnorePath);
33
- const ignorePatterns = getFilePatterns(ignoreFile);
34
- return ignorePatterns.reduce((accumlator, currentValue) => {
35
- if (!accumlator.includes(currentValue)) {
36
- accumlator.push(currentValue);
37
- }
38
- return accumlator;
39
- }, gitIgnorePatterns);
40
- }
41
- function getFilePatterns(filePath) {
42
- let patterns = [];
43
- if (fs_1.existsSync(filePath)) {
44
- patterns = fs_1.readFileSync(filePath, 'utf-8').split('\n').filter(Boolean);
45
- }
46
- return patterns;
47
- }
package/lib/utils.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA,2BAA4D;AAC5D,+BAA4B;AAC5B,yCAA0C;AAC1C,2CAAgD;AAEhD,SAAgB,YAAY,CAAC,UAAkB;IAC7C,IAAI,CAAC,iBAAY,CAAC,UAAU,CAAC,EAAE;QAC7B,UAAU,GAAG,WAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;KAC9C;IACD,IAAI,eAAU,CAAC,UAAU,CAAC,EAAE;QAC1B,OAAO,UAAU,CAAC;KACnB;IACD,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;AACJ,CAAC;AAVD,oCAUC;AAED;;GAEG;AACH,SAAgB,cAAc,CAC5B,QAAiB,EACjB,UAAmB;IAEnB,IAAI,CAAC,UAAU,EAAE;QACf,UAAU,GAAG,WAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,6BAAiB,CAAC,CAAC;KACrD;IACD,OAAO,gBAAI,CAAC,QAAQ,EAAE;QACpB,MAAM,EAAE,iBAAiB,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