@naturalcycles/dev-lib 13.40.1 → 13.41.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/cfg/eslint-rules.js +14 -2
- package/dist/bin/bt.js +1 -2
- package/dist/bin/btl.js +1 -2
- package/dist/bin/build.js +1 -2
- package/dist/bin/update-from-dev-lib.js +1 -2
- package/dist/cmd/build-prod-esm-cjs.command.js +10 -1
- package/dist/cmd/lint-all.command.js +7 -8
- package/dist/cmd/tsc-prod.command.js +1 -2
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +2 -2
- package/dist/util/jest.util.js +3 -4
- package/dist/util/tsc.util.js +7 -9
- package/package.json +1 -1
package/cfg/eslint-rules.js
CHANGED
|
@@ -167,11 +167,23 @@ module.exports = {
|
|
|
167
167
|
'undefined',
|
|
168
168
|
],
|
|
169
169
|
'id-match': 2,
|
|
170
|
-
'import/order':
|
|
170
|
+
'import/order': [
|
|
171
|
+
2,
|
|
172
|
+
{
|
|
173
|
+
alphabetize: {
|
|
174
|
+
order: 'asc',
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
],
|
|
171
178
|
'import/no-anonymous-default-export': 2,
|
|
172
179
|
// 'import/namespace': 0, // issues with e.g globby
|
|
173
180
|
// 'import/no-unresolved': 0, // breaks for type-aliases, e.g '@/store'
|
|
174
|
-
|
|
181
|
+
'import/no-duplicates': [2, { 'prefer-inline': false }],
|
|
182
|
+
'import/export': 2,
|
|
183
|
+
'import/no-empty-named-blocks': 2,
|
|
184
|
+
'import/no-cycle': 2,
|
|
185
|
+
'import/no-useless-path-segments': 2,
|
|
186
|
+
'import/no-default-export': 2,
|
|
175
187
|
'jsdoc/check-alignment': 2,
|
|
176
188
|
// "jsdoc/check-indentation": "error",
|
|
177
189
|
// 'jsdoc/newline-after-description': 2,
|
package/dist/bin/bt.js
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
5
|
-
const nodejs_lib_2 = require("@naturalcycles/nodejs-lib");
|
|
6
5
|
const jest_util_1 = require("../util/jest.util");
|
|
7
6
|
const tsc_util_1 = require("../util/tsc.util");
|
|
8
|
-
(0,
|
|
7
|
+
(0, nodejs_lib_1.runScript)(async () => {
|
|
9
8
|
(0, nodejs_lib_1._emptyDirSync)('./dist'); // it doesn't delete the dir itself, to prevent IDE jumping
|
|
10
9
|
// fs.rmSync('./dist', { recursive: true, force: true })
|
|
11
10
|
await (0, tsc_util_1.tscMainAndScripts)(true);
|
package/dist/bin/btl.js
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
5
|
-
const nodejs_lib_2 = require("@naturalcycles/nodejs-lib");
|
|
6
5
|
const lint_all_command_1 = require("../cmd/lint-all.command");
|
|
7
6
|
const jest_util_1 = require("../util/jest.util");
|
|
8
7
|
const tsc_util_1 = require("../util/tsc.util");
|
|
9
|
-
(0,
|
|
8
|
+
(0, nodejs_lib_1.runScript)(async () => {
|
|
10
9
|
await (0, lint_all_command_1.lintAllCommand)();
|
|
11
10
|
(0, nodejs_lib_1._emptyDirSync)('./dist'); // it doesn't delete the dir itself, to prevent IDE jumping
|
|
12
11
|
// fs.rmSync('./dist', { recursive: true, force: true })
|
package/dist/bin/build.js
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
5
|
-
const nodejs_lib_2 = require("@naturalcycles/nodejs-lib");
|
|
6
5
|
const tsc_util_1 = require("../util/tsc.util");
|
|
7
|
-
(0,
|
|
6
|
+
(0, nodejs_lib_1.runScript)(async () => {
|
|
8
7
|
(0, nodejs_lib_1._emptyDirSync)('./dist'); // it doesn't delete the dir itself, to prevent IDE jumping
|
|
9
8
|
// fs.rmSync('./dist', { recursive: true, force: true })
|
|
10
9
|
await (0, tsc_util_1.tscMainAndScripts)(true);
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
5
|
-
const nodejs_lib_2 = require("@naturalcycles/nodejs-lib");
|
|
6
5
|
const paths_cnst_1 = require("../cnst/paths.cnst");
|
|
7
|
-
(0,
|
|
6
|
+
(0, nodejs_lib_1.runScript)(() => {
|
|
8
7
|
(0, nodejs_lib_1.kpySync)({
|
|
9
8
|
baseDir: paths_cnst_1.cfgOverwriteDir,
|
|
10
9
|
outputDir: './',
|
|
@@ -17,7 +17,16 @@ async function buildProdESMCJSCommand() {
|
|
|
17
17
|
const cjsPath = cjsExists ? TSCONF_CJS_PATH : TSCONF_PATH;
|
|
18
18
|
const esmPath = esmExists ? TSCONF_ESM_PATH : TSCONF_PATH;
|
|
19
19
|
await Promise.all([
|
|
20
|
-
(0, nodejs_lib_1.execVoidCommand)('tsc', [
|
|
20
|
+
(0, nodejs_lib_1.execVoidCommand)('tsc', [
|
|
21
|
+
'-P',
|
|
22
|
+
cjsPath,
|
|
23
|
+
'--outDir',
|
|
24
|
+
'./dist',
|
|
25
|
+
'--module',
|
|
26
|
+
'commonjs',
|
|
27
|
+
'--moduleResolution',
|
|
28
|
+
'node',
|
|
29
|
+
]),
|
|
21
30
|
(0, nodejs_lib_1.execVoidCommand)('tsc', [
|
|
22
31
|
'-P',
|
|
23
32
|
esmPath,
|
|
@@ -3,10 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.lintAllCommand = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
6
|
-
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
7
6
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
7
|
+
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
8
8
|
const yargs_1 = tslib_1.__importDefault(require("yargs"));
|
|
9
|
-
const nodejs_lib_2 = require("@naturalcycles/nodejs-lib");
|
|
10
9
|
const prettier_util_1 = require("../util/prettier.util");
|
|
11
10
|
const stylelint_util_1 = require("../util/stylelint.util");
|
|
12
11
|
const eslint_all_command_1 = require("./eslint-all.command");
|
|
@@ -25,7 +24,7 @@ async function lintAllCommand() {
|
|
|
25
24
|
default: false,
|
|
26
25
|
},
|
|
27
26
|
}).argv;
|
|
28
|
-
const hadChangesBefore = (0,
|
|
27
|
+
const hadChangesBefore = (0, nodejs_lib_1.gitHasUncommittedChanges)();
|
|
29
28
|
await (0, eslint_all_command_1.eslintAllCommand)();
|
|
30
29
|
if (node_fs_1.default.existsSync(`node_modules/stylelint`) &&
|
|
31
30
|
node_fs_1.default.existsSync(`node_modules/stylelint-config-standard-scss`)) {
|
|
@@ -39,17 +38,17 @@ async function lintAllCommand() {
|
|
|
39
38
|
console.log(`${(0, nodejs_lib_1.boldGrey)('lint-all')} ${(0, nodejs_lib_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
|
|
40
39
|
if (commitOnChanges || failOnChanges) {
|
|
41
40
|
// detect changes
|
|
42
|
-
const hasChanges = (0,
|
|
41
|
+
const hasChanges = (0, nodejs_lib_1.gitHasUncommittedChanges)();
|
|
43
42
|
if (hasChanges) {
|
|
44
43
|
if (hadChangesBefore) {
|
|
45
44
|
console.log(`lint-all: there are changes before running lint-all, will not commit`);
|
|
46
45
|
}
|
|
47
46
|
else {
|
|
48
|
-
const msg = 'style(ci): ' + (0, js_lib_1._truncate)((0,
|
|
47
|
+
const msg = 'style(ci): ' + (0, js_lib_1._truncate)((0, nodejs_lib_1.commitMessageToTitleMessage)((0, nodejs_lib_1.getLastGitCommitMsg)()), 60);
|
|
49
48
|
// pull, commit, push changes
|
|
50
|
-
(0,
|
|
51
|
-
(0,
|
|
52
|
-
(0,
|
|
49
|
+
(0, nodejs_lib_1.gitPull)();
|
|
50
|
+
(0, nodejs_lib_1.gitCommitAll)(msg);
|
|
51
|
+
(0, nodejs_lib_1.gitPush)();
|
|
53
52
|
}
|
|
54
53
|
// fail on changes
|
|
55
54
|
if (failOnChanges) {
|
|
@@ -3,13 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.tscProdCommand = void 0;
|
|
4
4
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
5
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
6
|
-
const nodejs_lib_2 = require("@naturalcycles/nodejs-lib");
|
|
7
6
|
function tscProdCommand() {
|
|
8
7
|
// You cannot have a shared `tsconfig.prod.json` because of relative paths for `include`
|
|
9
8
|
const projectTsconfigPath = `./tsconfig.prod.json`;
|
|
10
9
|
const args = ['-P', projectTsconfigPath];
|
|
11
10
|
const started = Date.now();
|
|
12
11
|
(0, nodejs_lib_1.execVoidCommandSync)(`tsc`, args);
|
|
13
|
-
console.log(`${(0,
|
|
12
|
+
console.log(`${(0, nodejs_lib_1.boldGrey)('tsc prod')} ${(0, nodejs_lib_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
|
|
14
13
|
}
|
|
15
14
|
exports.tscProdCommand = tscProdCommand;
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { expectTypeOf } from 'expect-type';
|
|
1
2
|
import timekeeper from 'timekeeper';
|
|
2
3
|
export * from '../jestOffline.util';
|
|
3
4
|
export * from './expect.util';
|
|
4
5
|
export * from './mockAllKindsOfThings';
|
|
5
6
|
export * from './testing.util';
|
|
6
7
|
export * from './time.util';
|
|
7
|
-
import { expectTypeOf } from 'expect-type';
|
|
8
8
|
export { timekeeper, expectTypeOf };
|
package/dist/testing/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.expectTypeOf = exports.timekeeper = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const expect_type_1 = require("expect-type");
|
|
6
|
+
Object.defineProperty(exports, "expectTypeOf", { enumerable: true, get: function () { return expect_type_1.expectTypeOf; } });
|
|
5
7
|
const timekeeper_1 = tslib_1.__importDefault(require("timekeeper"));
|
|
6
8
|
exports.timekeeper = timekeeper_1.default;
|
|
7
9
|
tslib_1.__exportStar(require("../jestOffline.util"), exports);
|
|
@@ -9,5 +11,3 @@ tslib_1.__exportStar(require("./expect.util"), exports);
|
|
|
9
11
|
tslib_1.__exportStar(require("./mockAllKindsOfThings"), exports);
|
|
10
12
|
tslib_1.__exportStar(require("./testing.util"), exports);
|
|
11
13
|
tslib_1.__exportStar(require("./time.util"), exports);
|
|
12
|
-
const expect_type_1 = require("expect-type");
|
|
13
|
-
Object.defineProperty(exports, "expectTypeOf", { enumerable: true, get: function () { return expect_type_1.expectTypeOf; } });
|
package/dist/util/jest.util.js
CHANGED
|
@@ -4,9 +4,8 @@ exports.runJest = exports.isRunningAllTests = exports.getJestManualConfigPath =
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
6
6
|
const node_os_1 = tslib_1.__importDefault(require("node:os"));
|
|
7
|
-
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
8
7
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
9
|
-
const
|
|
8
|
+
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
10
9
|
const paths_cnst_1 = require("../cnst/paths.cnst");
|
|
11
10
|
const test_util_1 = require("./test.util");
|
|
12
11
|
function getJestConfigPath() {
|
|
@@ -40,7 +39,7 @@ exports.isRunningAllTests = isRunningAllTests;
|
|
|
40
39
|
*/
|
|
41
40
|
function runJest(opt = {}) {
|
|
42
41
|
if (!(0, test_util_1.nodeModuleExists)('jest')) {
|
|
43
|
-
console.log((0,
|
|
42
|
+
console.log((0, nodejs_lib_1.dimGrey)(`node_modules/${(0, nodejs_lib_1.white)('jest')} not found, skipping tests`));
|
|
44
43
|
return;
|
|
45
44
|
}
|
|
46
45
|
const { CI, CIRCLECI, CPU_LIMIT, TZ = 'UTC', APP_ENV, JEST_NO_ALPHABETIC, JEST_SHARDS, NODE_OPTIONS = 'not defined', } = process.env;
|
|
@@ -116,7 +115,7 @@ function runJest(opt = {}) {
|
|
|
116
115
|
}
|
|
117
116
|
const availableParallelism = node_os_1.default.availableParallelism?.();
|
|
118
117
|
const cpus = node_os_1.default.cpus().length;
|
|
119
|
-
console.log(`${(0,
|
|
118
|
+
console.log(`${(0, nodejs_lib_1.dimGrey)(Object.entries({
|
|
120
119
|
node,
|
|
121
120
|
NODE_OPTIONS,
|
|
122
121
|
cpus,
|
package/dist/util/tsc.util.js
CHANGED
|
@@ -3,10 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ensureProjectTsconfigScripts = exports.tscScriptsAsync = exports.tscScripts = exports.tscAsync = exports.tsc = exports.tscMainAndScripts = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
6
|
-
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
7
6
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
8
|
-
const
|
|
9
|
-
const nodejs_lib_3 = require("@naturalcycles/nodejs-lib");
|
|
7
|
+
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
10
8
|
const paths_cnst_1 = require("../cnst/paths.cnst");
|
|
11
9
|
async function tscMainAndScripts(noEmit = false) {
|
|
12
10
|
await Promise.all([tscAsync(noEmit), tscScriptsAsync()]);
|
|
@@ -16,14 +14,14 @@ function tsc(noEmit = false) {
|
|
|
16
14
|
const started = Date.now();
|
|
17
15
|
const args = [noEmit && '--noEmit'].filter(js_lib_1._isTruthy);
|
|
18
16
|
(0, nodejs_lib_1.execVoidCommandSync)('tsc', args);
|
|
19
|
-
console.log(`${(0,
|
|
17
|
+
console.log(`${(0, nodejs_lib_1.boldGrey)('tsc')} ${(0, nodejs_lib_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
|
|
20
18
|
}
|
|
21
19
|
exports.tsc = tsc;
|
|
22
20
|
async function tscAsync(noEmit = false) {
|
|
23
21
|
const started = Date.now();
|
|
24
22
|
const args = [noEmit && '--noEmit'].filter(js_lib_1._isTruthy);
|
|
25
23
|
await (0, nodejs_lib_1.execVoidCommand)('tsc', args);
|
|
26
|
-
console.log(`${(0,
|
|
24
|
+
console.log(`${(0, nodejs_lib_1.boldGrey)('tsc')} ${(0, nodejs_lib_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
|
|
27
25
|
}
|
|
28
26
|
exports.tscAsync = tscAsync;
|
|
29
27
|
function tscScripts() {
|
|
@@ -35,7 +33,7 @@ function tscScripts() {
|
|
|
35
33
|
const args = ['-P', projectTsconfigPath, '--noEmit'];
|
|
36
34
|
const started = Date.now();
|
|
37
35
|
(0, nodejs_lib_1.execVoidCommandSync)(`tsc`, args);
|
|
38
|
-
console.log(`${(0,
|
|
36
|
+
console.log(`${(0, nodejs_lib_1.boldGrey)('tsc scripts')} ${(0, nodejs_lib_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
|
|
39
37
|
}
|
|
40
38
|
exports.tscScripts = tscScripts;
|
|
41
39
|
async function tscScriptsAsync() {
|
|
@@ -47,7 +45,7 @@ async function tscScriptsAsync() {
|
|
|
47
45
|
const args = ['-P', projectTsconfigPath, '--noEmit'];
|
|
48
46
|
const started = Date.now();
|
|
49
47
|
await (0, nodejs_lib_1.execVoidCommand)(`tsc`, args);
|
|
50
|
-
console.log(`${(0,
|
|
48
|
+
console.log(`${(0, nodejs_lib_1.boldGrey)('tsc scripts')} ${(0, nodejs_lib_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
|
|
51
49
|
}
|
|
52
50
|
exports.tscScriptsAsync = tscScriptsAsync;
|
|
53
51
|
/**
|
|
@@ -58,12 +56,12 @@ function ensureProjectTsconfigScripts() {
|
|
|
58
56
|
if (!node_fs_1.default.existsSync(projectTsconfigPath)) {
|
|
59
57
|
// You cannot just use a shared `tsconfig.scripts.json` because of relative paths for `include`
|
|
60
58
|
// So, it will be copied into the project
|
|
61
|
-
(0,
|
|
59
|
+
(0, nodejs_lib_1.kpySync)({
|
|
62
60
|
baseDir: `${paths_cnst_1.cfgDir}/init/scripts/`,
|
|
63
61
|
inputPatterns: ['tsconfig.json'],
|
|
64
62
|
outputDir: './scripts',
|
|
65
63
|
});
|
|
66
|
-
console.log(`${(0,
|
|
64
|
+
console.log(`${(0, nodejs_lib_1.boldGrey)('/scripts/tsconfig.json')} file is automatically added`);
|
|
67
65
|
}
|
|
68
66
|
return projectTsconfigPath;
|
|
69
67
|
}
|