@naturalcycles/dev-lib 12.14.0 → 12.15.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/cfg/jest.config.js +3 -1
- package/cfg/jest.integration-test.config.js +3 -3
- package/cfg/jest.manual-test.config.js +0 -2
- package/cfg/lint-staged.config.js +8 -1
- package/cfg/overwrite/.editorconfig +15 -11
- package/dist/cmd/lint-all.command.js +7 -4
- package/dist/util/jest.util.js +8 -2
- package/package.json +2 -2
- package/readme.md +3 -4
package/cfg/jest.config.js
CHANGED
|
@@ -107,10 +107,12 @@ module.exports = {
|
|
|
107
107
|
'!**/*.component.ts',
|
|
108
108
|
'!**/*.modal.ts',
|
|
109
109
|
],
|
|
110
|
+
// default: ["clover", "json", "lcov", "text"]
|
|
111
|
+
coverageReporters: ['clover', 'json', 'lcov', !CI && 'text'].filter(Boolean),
|
|
110
112
|
// CI: only jest-junit reporter (no default)
|
|
111
113
|
// not-CI: only default reporter, but not jest-junit
|
|
112
114
|
reporters: [
|
|
113
|
-
|
|
115
|
+
'default',
|
|
114
116
|
CI && [
|
|
115
117
|
'jest-junit',
|
|
116
118
|
{
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const fs = require('fs')
|
|
7
|
+
const { CI } = process.env
|
|
7
8
|
const cwd = process.cwd()
|
|
8
9
|
|
|
9
10
|
// Set 'setupFilesAfterEnv' only if it exists
|
|
@@ -21,10 +22,9 @@ module.exports = {
|
|
|
21
22
|
testMatch: ['<rootDir>/src/**/*.integration.test.ts'],
|
|
22
23
|
testPathIgnorePatterns: ['<rootDir>/.*/__exclude/'],
|
|
23
24
|
setupFilesAfterEnv,
|
|
24
|
-
coverageDirectory: 'tmp/coverage-integration',
|
|
25
25
|
reporters: [
|
|
26
26
|
'default',
|
|
27
|
-
[
|
|
27
|
+
CI && [
|
|
28
28
|
'jest-junit',
|
|
29
29
|
{
|
|
30
30
|
suiteName: 'jest tests',
|
|
@@ -36,5 +36,5 @@ module.exports = {
|
|
|
36
36
|
ancestorSeparator: ' ',
|
|
37
37
|
},
|
|
38
38
|
],
|
|
39
|
-
],
|
|
39
|
+
].filter(Boolean),
|
|
40
40
|
}
|
|
@@ -21,7 +21,5 @@ module.exports = {
|
|
|
21
21
|
testMatch: ['<rootDir>/src/**/*.manual.test.ts'],
|
|
22
22
|
testPathIgnorePatterns: ['<rootDir>/.*/__exclude/'],
|
|
23
23
|
setupFilesAfterEnv,
|
|
24
|
-
// Should never need coverage or reporters, but anyway
|
|
25
|
-
coverageDirectory: 'tmp/coverage-manual',
|
|
26
24
|
reporters: ['default'],
|
|
27
25
|
}
|
|
@@ -79,7 +79,14 @@ const linters = {
|
|
|
79
79
|
'**/*.{kt,kts}': match => {
|
|
80
80
|
const filesList = micromatch.not(match, lintExclude).join(' ')
|
|
81
81
|
if (!filesList) return []
|
|
82
|
-
|
|
82
|
+
const dir = './node_modules/@naturalcycles/ktlint'
|
|
83
|
+
|
|
84
|
+
if (!fs.existsSync(dir)) {
|
|
85
|
+
console.log(`!!\n!! Please install @naturalcycles/ktlint to lint *.kt files\n!!\n`, filesList)
|
|
86
|
+
return []
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return [`${dir}/resources/ktlint -F ${filesList}`]
|
|
83
90
|
},
|
|
84
91
|
}
|
|
85
92
|
|
|
@@ -14,35 +14,39 @@ end_of_line = lf
|
|
|
14
14
|
trim_trailing_whitespace = true
|
|
15
15
|
insert_final_newline = true
|
|
16
16
|
|
|
17
|
-
[
|
|
17
|
+
[*.md]
|
|
18
18
|
trim_trailing_whitespace = false
|
|
19
19
|
indent_size = 4
|
|
20
20
|
|
|
21
|
-
[
|
|
21
|
+
[*.html]
|
|
22
22
|
indent_size = 2
|
|
23
23
|
|
|
24
|
-
[
|
|
24
|
+
[*.{css,scss}]
|
|
25
25
|
indent_size = 2
|
|
26
26
|
|
|
27
|
-
[
|
|
27
|
+
[*.{js,ts}]
|
|
28
28
|
indent_size = 2
|
|
29
29
|
|
|
30
|
-
[
|
|
30
|
+
[*.json]
|
|
31
31
|
indent_size = 2
|
|
32
32
|
|
|
33
|
-
[
|
|
34
|
-
indent_size = 2
|
|
35
|
-
|
|
36
|
-
[**.java]
|
|
33
|
+
[*.java]
|
|
37
34
|
indent_size = 4
|
|
38
35
|
|
|
39
|
-
[
|
|
36
|
+
[*.{kt,kts}]
|
|
37
|
+
disabled_rules=no-wildcard-imports
|
|
38
|
+
ij_kotlin_imports_layout=*,java.**,javax.**,kotlin.**,^ # default IntelliJ IDEA style, same as alphabetical, but with "java", "javax", "kotlin" and alias imports in the end of the imports list
|
|
39
|
+
|
|
40
|
+
[*.xml]
|
|
41
|
+
indent_size = 2
|
|
42
|
+
|
|
43
|
+
[*.sql]
|
|
40
44
|
indent_size = 2
|
|
41
45
|
|
|
42
46
|
[.eslintrc]
|
|
43
47
|
indent_size = 2
|
|
44
48
|
|
|
45
|
-
[
|
|
49
|
+
[*.min.*]
|
|
46
50
|
indent_style = ignore
|
|
47
51
|
trim_trailing_whitespace = false
|
|
48
52
|
insert_final_newline = ignore
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.lintAllCommand = void 0;
|
|
4
|
+
const fs = require("fs");
|
|
4
5
|
const yargs = require("yargs");
|
|
5
6
|
const git_util_1 = require("../util/git.util");
|
|
6
7
|
const prettier_util_1 = require("../util/prettier.util");
|
|
@@ -21,10 +22,14 @@ async function lintAllCommand() {
|
|
|
21
22
|
},
|
|
22
23
|
}).argv;
|
|
23
24
|
const hadChangesBefore = await (0, git_util_1.gitHasUncommittedChanges)();
|
|
24
|
-
// Currently we position ESLint before TSLint, but let's monitor if it's ok
|
|
25
25
|
await (0, eslint_all_command_1.eslintAllCommand)();
|
|
26
26
|
await (0, stylelint_util_1.stylelintAll)();
|
|
27
27
|
await (0, prettier_util_1.runPrettier)();
|
|
28
|
+
// Running ktlintAll (experimental!)
|
|
29
|
+
if (fs.existsSync(`node_modules/@naturalcycles/ktlint`)) {
|
|
30
|
+
const ktlintLib = require('@naturalcycles/ktlint');
|
|
31
|
+
await ktlintLib.ktlintAll();
|
|
32
|
+
}
|
|
28
33
|
if (commitOnChanges || failOnChanges) {
|
|
29
34
|
// detect changes
|
|
30
35
|
const hasChanges = await (0, git_util_1.gitHasUncommittedChanges)();
|
|
@@ -33,9 +38,7 @@ async function lintAllCommand() {
|
|
|
33
38
|
console.log(`lint-all: there are changes before running lint-all, will not commit`);
|
|
34
39
|
}
|
|
35
40
|
else {
|
|
36
|
-
const msg = 'style(
|
|
37
|
-
(0, git_util_1.commitMessageToTitleMessage)(await (0, git_util_1.getLastGitCommitMsg)()) +
|
|
38
|
-
'\n\n[skip ci]';
|
|
41
|
+
const msg = 'style(ci): ' + (0, git_util_1.commitMessageToTitleMessage)(await (0, git_util_1.getLastGitCommitMsg)()) + '\n\n[skip ci]';
|
|
39
42
|
// pull, commit, push changes
|
|
40
43
|
await (0, git_util_1.gitPull)();
|
|
41
44
|
await (0, git_util_1.gitCommitAll)(msg);
|
package/dist/util/jest.util.js
CHANGED
|
@@ -67,8 +67,14 @@ async function runJest(opt = {}) {
|
|
|
67
67
|
DEBUG_COLORS: '1',
|
|
68
68
|
};
|
|
69
69
|
if (CI) {
|
|
70
|
-
args.push('--ci'
|
|
71
|
-
|
|
70
|
+
args.push('--ci');
|
|
71
|
+
if (!integration && !manual) {
|
|
72
|
+
// Coverage only makes sense for unit tests, not for integration/manual
|
|
73
|
+
args.push('--coverage');
|
|
74
|
+
}
|
|
75
|
+
// We used to default to 2, but due to memory being an issue for Jest - now we default to 1,
|
|
76
|
+
// as it's the most memory-efficient way
|
|
77
|
+
maxWorkers || (maxWorkers = '--maxWorkers=1');
|
|
72
78
|
}
|
|
73
79
|
// Running all tests - will use `--silent` to suppress console-logs, will also set process.env.JEST_SILENT=1
|
|
74
80
|
if (CI || isRunningAllTests()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/dev-lib",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.15.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky install",
|
|
6
6
|
"tsn-debug": "tsn testScript.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@naturalcycles/time-lib": "^3.0.1",
|
|
39
39
|
"@types/fs-extra": "^9.0.0",
|
|
40
40
|
"@types/jest": "^27.0.0",
|
|
41
|
-
"@types/node": "^
|
|
41
|
+
"@types/node": "^17.0.0",
|
|
42
42
|
"@types/yargs": "^16.0.0",
|
|
43
43
|
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
44
44
|
"@typescript-eslint/parser": "^5.0.0",
|
package/readme.md
CHANGED
|
@@ -149,11 +149,10 @@ Pass `--ext` (e.g `--ext ts,html`) to override the list of ESLint extensions (de
|
|
|
149
149
|
|
|
150
150
|
`ktlint` will be used by lint-staged for all `**/*.{kt,kts}` files.
|
|
151
151
|
|
|
152
|
-
Please install it with `brew install ktlint
|
|
152
|
+
~~Please install it with `brew install ktlint`.~~
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
[
|
|
156
|
-
install a working version.
|
|
154
|
+
Install it **locally** in you project by adding
|
|
155
|
+
[`@naturalcycles/ktlint`](https://github.com/NaturalCycles/ktlint) to your **dev**Dependencies.
|
|
157
156
|
|
|
158
157
|
#### Other commands
|
|
159
158
|
|