@naturalcycles/dev-lib 13.28.0 → 13.28.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/dist/bin/bt.js +4 -4
- package/dist/bin/btl.js +3 -3
- package/dist/bin/build.js +3 -3
- package/dist/bin/prettier-all.js +2 -2
- package/dist/bin/stylelint-all.js +1 -1
- package/dist/bin/test-ci.js +1 -1
- package/dist/bin/test-integration-ci.js +1 -1
- package/dist/bin/test-integration.js +1 -1
- package/dist/bin/test-leaks.js +1 -1
- package/dist/bin/test-manual.js +1 -1
- package/dist/bin/test.js +1 -1
- package/dist/cmd/build-prod-esm-cjs.command.js +12 -3
- package/dist/cmd/build-prod.command.d.ts +1 -1
- package/dist/cmd/build-prod.command.js +2 -2
- package/dist/cmd/eslint-all.command.d.ts +1 -1
- package/dist/cmd/eslint-all.command.js +4 -4
- package/dist/cmd/lint-all.command.js +3 -3
- package/dist/cmd/tsc-prod.command.d.ts +1 -1
- package/dist/cmd/tsc-prod.command.js +3 -3
- package/dist/cmd/tsc-scripts.command.d.ts +1 -1
- package/dist/cmd/tsc-scripts.command.js +3 -3
- package/dist/util/buildInfo.util.d.ts +0 -1
- package/dist/util/buildInfo.util.js +1 -22
- package/dist/util/exec.util.d.ts +4 -0
- package/dist/util/exec.util.js +56 -0
- package/dist/util/git.util.js +1 -0
- package/dist/util/jest.util.d.ts +1 -1
- package/dist/util/jest.util.js +5 -5
- package/dist/util/lint.util.d.ts +1 -1
- package/dist/util/lint.util.js +3 -3
- package/dist/util/prettier.util.d.ts +1 -1
- package/dist/util/prettier.util.js +3 -3
- package/dist/util/stylelint.util.d.ts +1 -1
- package/dist/util/stylelint.util.js +3 -3
- package/dist/util/tsc.util.d.ts +1 -1
- package/dist/util/tsc.util.js +4 -4
- package/package.json +1 -1
package/dist/bin/bt.js
CHANGED
|
@@ -6,10 +6,10 @@ const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
|
|
|
6
6
|
const tsc_scripts_command_1 = require("../cmd/tsc-scripts.command");
|
|
7
7
|
const jest_util_1 = require("../util/jest.util");
|
|
8
8
|
const tsc_util_1 = require("../util/tsc.util");
|
|
9
|
-
(0, script_1.runScript)(
|
|
9
|
+
(0, script_1.runScript)(() => {
|
|
10
10
|
(0, nodejs_lib_1._emptyDirSync)('./dist'); // it doesn't delete the dir itself, to prevent IDE jumping
|
|
11
11
|
// fs.rmSync('./dist', { recursive: true, force: true })
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
(0, tsc_util_1.tsc)(true);
|
|
13
|
+
(0, tsc_scripts_command_1.tscScriptsCommand)();
|
|
14
|
+
(0, jest_util_1.runJest)();
|
|
15
15
|
});
|
package/dist/bin/btl.js
CHANGED
|
@@ -11,7 +11,7 @@ const tsc_util_1 = require("../util/tsc.util");
|
|
|
11
11
|
await (0, lint_all_command_1.lintAllCommand)();
|
|
12
12
|
(0, nodejs_lib_1._emptyDirSync)('./dist'); // it doesn't delete the dir itself, to prevent IDE jumping
|
|
13
13
|
// fs.rmSync('./dist', { recursive: true, force: true })
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
(0, tsc_util_1.tsc)(true);
|
|
15
|
+
(0, tsc_scripts_command_1.tscScriptsCommand)();
|
|
16
|
+
(0, jest_util_1.runJest)();
|
|
17
17
|
});
|
package/dist/bin/build.js
CHANGED
|
@@ -5,9 +5,9 @@ const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
|
5
5
|
const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
|
|
6
6
|
const tsc_scripts_command_1 = require("../cmd/tsc-scripts.command");
|
|
7
7
|
const tsc_util_1 = require("../util/tsc.util");
|
|
8
|
-
(0, script_1.runScript)(
|
|
8
|
+
(0, script_1.runScript)(() => {
|
|
9
9
|
(0, nodejs_lib_1._emptyDirSync)('./dist'); // it doesn't delete the dir itself, to prevent IDE jumping
|
|
10
10
|
// fs.rmSync('./dist', { recursive: true, force: true })
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
(0, tsc_util_1.tsc)(true);
|
|
12
|
+
(0, tsc_scripts_command_1.tscScriptsCommand)();
|
|
13
13
|
});
|
package/dist/bin/prettier-all.js
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
|
|
5
5
|
const prettier_util_1 = require("../util/prettier.util");
|
|
6
|
-
(0, script_1.runScript)(
|
|
7
|
-
|
|
6
|
+
(0, script_1.runScript)(() => {
|
|
7
|
+
(0, prettier_util_1.runPrettier)();
|
|
8
8
|
});
|
|
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
|
|
5
5
|
const stylelint_util_1 = require("../util/stylelint.util");
|
|
6
6
|
(0, script_1.runScript)(async () => {
|
|
7
|
-
|
|
7
|
+
(0, stylelint_util_1.stylelintAll)();
|
|
8
8
|
});
|
package/dist/bin/test-ci.js
CHANGED
|
@@ -5,5 +5,5 @@ const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
|
|
|
5
5
|
const jest_util_1 = require("../util/jest.util");
|
|
6
6
|
(0, script_1.runScript)(async () => {
|
|
7
7
|
console.log('! "yarn test-ci" is deprecated, use plain `yarn test` instead !');
|
|
8
|
-
|
|
8
|
+
(0, jest_util_1.runJest)();
|
|
9
9
|
});
|
|
@@ -5,5 +5,5 @@ const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
|
|
|
5
5
|
const jest_util_1 = require("../util/jest.util");
|
|
6
6
|
(0, script_1.runScript)(async () => {
|
|
7
7
|
console.log('! "yarn test-integration-ci" is deprecated, use plain `yarn test-integration` instead !');
|
|
8
|
-
|
|
8
|
+
(0, jest_util_1.runJest)({ integration: true });
|
|
9
9
|
});
|
|
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
|
|
5
5
|
const jest_util_1 = require("../util/jest.util");
|
|
6
6
|
(0, script_1.runScript)(async () => {
|
|
7
|
-
|
|
7
|
+
(0, jest_util_1.runJest)({ integration: true });
|
|
8
8
|
});
|
package/dist/bin/test-leaks.js
CHANGED
|
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
|
|
5
5
|
const jest_util_1 = require("../util/jest.util");
|
|
6
6
|
(0, script_1.runScript)(async () => {
|
|
7
|
-
|
|
7
|
+
(0, jest_util_1.runJest)({ leaks: true });
|
|
8
8
|
});
|
package/dist/bin/test-manual.js
CHANGED
|
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
|
|
5
5
|
const jest_util_1 = require("../util/jest.util");
|
|
6
6
|
(0, script_1.runScript)(async () => {
|
|
7
|
-
|
|
7
|
+
(0, jest_util_1.runJest)({ manual: true });
|
|
8
8
|
});
|
package/dist/bin/test.js
CHANGED
|
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
|
|
5
5
|
const jest_util_1 = require("../util/jest.util");
|
|
6
6
|
(0, script_1.runScript)(async () => {
|
|
7
|
-
|
|
7
|
+
(0, jest_util_1.runJest)();
|
|
8
8
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildProdESMCJSCommand = void 0;
|
|
4
4
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
5
|
-
const
|
|
5
|
+
const exec_util_1 = require("../util/exec.util");
|
|
6
6
|
// You cannot have a shared `tsconfig.prod.json` because of relative paths for `include`
|
|
7
7
|
const TSCONF_CJS_PATH = `./tsconfig.cjs.prod.json`;
|
|
8
8
|
const TSCONF_ESM_PATH = `./tsconfig.esm.prod.json`;
|
|
@@ -20,8 +20,17 @@ async function buildProdESMCJSCommand() {
|
|
|
20
20
|
const cjsPath = cjsExists ? TSCONF_CJS_PATH : TSCONF_PATH;
|
|
21
21
|
const esmPath = esmExists ? TSCONF_ESM_PATH : TSCONF_PATH;
|
|
22
22
|
await Promise.all([
|
|
23
|
-
(0,
|
|
24
|
-
(0,
|
|
23
|
+
(0, exec_util_1.execVoidCommand)('tsc', ['-P', cjsPath, '--outDir', './dist', '--module', 'commonjs']),
|
|
24
|
+
(0, exec_util_1.execVoidCommand)('tsc', [
|
|
25
|
+
'-P',
|
|
26
|
+
esmPath,
|
|
27
|
+
'--outDir',
|
|
28
|
+
'./dist-esm',
|
|
29
|
+
'--module',
|
|
30
|
+
'esnext',
|
|
31
|
+
'--declaration',
|
|
32
|
+
'false',
|
|
33
|
+
]),
|
|
25
34
|
]);
|
|
26
35
|
}
|
|
27
36
|
exports.buildProdESMCJSCommand = buildProdESMCJSCommand;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function buildProdCommand():
|
|
1
|
+
export declare function buildProdCommand(): void;
|
|
@@ -4,10 +4,10 @@ exports.buildProdCommand = void 0;
|
|
|
4
4
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
5
5
|
const build_copy_command_1 = require("./build-copy.command");
|
|
6
6
|
const tsc_prod_command_1 = require("./tsc-prod.command");
|
|
7
|
-
|
|
7
|
+
function buildProdCommand() {
|
|
8
8
|
(0, nodejs_lib_1._emptyDirSync)('./dist'); // it doesn't delete the dir itself, to prevent IDE jumping
|
|
9
9
|
// fs.rmSync('./dist', { recursive: true, force: true })
|
|
10
10
|
(0, build_copy_command_1.buildCopyCommand)();
|
|
11
|
-
|
|
11
|
+
(0, tsc_prod_command_1.tscProdCommand)();
|
|
12
12
|
}
|
|
13
13
|
exports.buildProdCommand = buildProdCommand;
|
|
@@ -8,7 +8,7 @@ const lint_util_1 = require("../util/lint.util");
|
|
|
8
8
|
/**
|
|
9
9
|
* Runs `eslint` command for all predefined paths (e.g /src, /scripts, etc).
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
function eslintAllCommand() {
|
|
12
12
|
const { ext, fix } = yargs.options({
|
|
13
13
|
ext: {
|
|
14
14
|
type: 'string',
|
|
@@ -31,10 +31,10 @@ async function eslintAllCommand() {
|
|
|
31
31
|
// todo: run on other dirs too, e.g pages, components, layouts
|
|
32
32
|
// /src
|
|
33
33
|
// await runESLint(`./src`, eslintConfigPathRoot, tsconfigPath, extensions)
|
|
34
|
-
|
|
34
|
+
(0, lint_util_1.runESLint)(`./src`, eslintConfigPathRoot, undefined, extensions, fix);
|
|
35
35
|
// /scripts
|
|
36
|
-
|
|
36
|
+
(0, lint_util_1.runESLint)(`./scripts`, eslintConfigPathScripts, tsconfigPathScripts, undefined, fix);
|
|
37
37
|
// /e2e
|
|
38
|
-
|
|
38
|
+
(0, lint_util_1.runESLint)(`./e2e`, eslintConfigPathE2e, tsconfigPathE2e, undefined, fix);
|
|
39
39
|
}
|
|
40
40
|
exports.eslintAllCommand = eslintAllCommand;
|
|
@@ -23,12 +23,12 @@ async function lintAllCommand() {
|
|
|
23
23
|
},
|
|
24
24
|
}).argv;
|
|
25
25
|
const hadChangesBefore = (0, git_util_1.gitHasUncommittedChanges)();
|
|
26
|
-
|
|
26
|
+
(0, eslint_all_command_1.eslintAllCommand)();
|
|
27
27
|
if (fs.existsSync(`node_modules/stylelint`) &&
|
|
28
28
|
fs.existsSync(`node_modules/stylelint-config-standard-scss`)) {
|
|
29
|
-
|
|
29
|
+
(0, stylelint_util_1.stylelintAll)();
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
(0, prettier_util_1.runPrettier)();
|
|
32
32
|
if (fs.existsSync(`node_modules/@naturalcycles/ktlint`)) {
|
|
33
33
|
const ktlintLib = require('@naturalcycles/ktlint');
|
|
34
34
|
await ktlintLib.ktlintAll();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function tscProdCommand():
|
|
1
|
+
export declare function tscProdCommand(): void;
|
|
@@ -3,13 +3,13 @@ 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 colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const exec_util_1 = require("../util/exec.util");
|
|
7
|
+
function tscProdCommand() {
|
|
8
8
|
// You cannot have a shared `tsconfig.prod.json` because of relative paths for `include`
|
|
9
9
|
const projectTsconfigPath = `./tsconfig.prod.json`;
|
|
10
10
|
const args = ['-P', projectTsconfigPath];
|
|
11
11
|
const started = Date.now();
|
|
12
|
-
|
|
12
|
+
(0, exec_util_1.execVoidCommandSync)(`tsc`, args);
|
|
13
13
|
console.log(`${(0, colors_1.boldGrey)('tsc prod')} ${(0, colors_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
|
|
14
14
|
}
|
|
15
15
|
exports.tscProdCommand = tscProdCommand;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function tscScriptsCommand():
|
|
1
|
+
export declare function tscScriptsCommand(): void;
|
|
@@ -4,9 +4,9 @@ exports.tscScriptsCommand = void 0;
|
|
|
4
4
|
const fs = require("node:fs");
|
|
5
5
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
6
6
|
const colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
|
|
7
|
-
const
|
|
7
|
+
const exec_util_1 = require("../util/exec.util");
|
|
8
8
|
const tsc_util_1 = require("../util/tsc.util");
|
|
9
|
-
|
|
9
|
+
function tscScriptsCommand() {
|
|
10
10
|
if (!fs.existsSync('./scripts')) {
|
|
11
11
|
// ./scripts folder doesn't exist, skipping
|
|
12
12
|
return;
|
|
@@ -14,7 +14,7 @@ async function tscScriptsCommand() {
|
|
|
14
14
|
const projectTsconfigPath = (0, tsc_util_1.ensureProjectTsconfigScripts)();
|
|
15
15
|
const args = ['-P', projectTsconfigPath, '--noEmit'];
|
|
16
16
|
const started = Date.now();
|
|
17
|
-
|
|
17
|
+
(0, exec_util_1.execVoidCommandSync)(`tsc`, args);
|
|
18
18
|
console.log(`${(0, colors_1.boldGrey)('tsc scripts')} ${(0, colors_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
|
|
19
19
|
}
|
|
20
20
|
exports.tscScriptsCommand = tscScriptsCommand;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.generateBuildInfo = void 0;
|
|
4
4
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
5
|
const git_util_1 = require("./git.util");
|
|
6
6
|
function generateBuildInfo() {
|
|
@@ -25,24 +25,3 @@ function generateBuildInfo() {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
exports.generateBuildInfo = generateBuildInfo;
|
|
28
|
-
function generateBuildInfoDev() {
|
|
29
|
-
const now = (0, js_lib_1.localTime)();
|
|
30
|
-
const ts = now.unix();
|
|
31
|
-
const tsStr = now.toPretty();
|
|
32
|
-
const rev = 'devRev';
|
|
33
|
-
const branchName = 'devBranch';
|
|
34
|
-
const repoName = 'devRepo';
|
|
35
|
-
const tsCommit = now.unix();
|
|
36
|
-
const ver = [now.toStringCompact(), repoName, branchName, rev].join('_');
|
|
37
|
-
return {
|
|
38
|
-
ts,
|
|
39
|
-
tsCommit,
|
|
40
|
-
tsStr,
|
|
41
|
-
repoName,
|
|
42
|
-
branchName,
|
|
43
|
-
rev,
|
|
44
|
-
ver,
|
|
45
|
-
env: 'dev',
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
exports.generateBuildInfoDev = generateBuildInfoDev;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { SpawnOptions } from 'node:child_process';
|
|
3
|
+
export declare function execVoidCommand(cmd: string, args?: string[], opt?: SpawnOptions): Promise<void>;
|
|
4
|
+
export declare function execVoidCommandSync(cmd: string, args?: string[], opt?: SpawnOptions): void;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.execVoidCommandSync = exports.execVoidCommand = void 0;
|
|
4
|
+
const cp = require("node:child_process");
|
|
5
|
+
const colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
|
|
6
|
+
async function execVoidCommand(cmd, args = [], opt = {}) {
|
|
7
|
+
logExec(cmd, args, opt);
|
|
8
|
+
await new Promise(resolve => {
|
|
9
|
+
const p = cp.spawn(cmd, [...args], {
|
|
10
|
+
stdio: 'inherit',
|
|
11
|
+
// shell: true,
|
|
12
|
+
...opt,
|
|
13
|
+
env: {
|
|
14
|
+
...process.env,
|
|
15
|
+
...opt.env,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
p.on('close', code => {
|
|
19
|
+
if (!code)
|
|
20
|
+
return resolve();
|
|
21
|
+
console.log(`${cmd} exited with code ${code}`);
|
|
22
|
+
process.exit(code);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.execVoidCommand = execVoidCommand;
|
|
27
|
+
function execVoidCommandSync(cmd, args = [], opt = {}) {
|
|
28
|
+
logExec(cmd, args, opt);
|
|
29
|
+
const r = cp.spawnSync(cmd, [...args], {
|
|
30
|
+
encoding: 'utf8',
|
|
31
|
+
stdio: 'inherit',
|
|
32
|
+
// shell: true, // removing shell breaks executing `tsc`
|
|
33
|
+
...opt,
|
|
34
|
+
env: {
|
|
35
|
+
...process.env,
|
|
36
|
+
...opt.env,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
if (r.status) {
|
|
40
|
+
console.log(`${cmd} exited with code ${r.status}`);
|
|
41
|
+
process.exit(r.status);
|
|
42
|
+
}
|
|
43
|
+
if (r.error) {
|
|
44
|
+
console.log(r.error);
|
|
45
|
+
process.exit(r.error.errno || 1);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.execVoidCommandSync = execVoidCommandSync;
|
|
49
|
+
function logExec(cmd, args = [], opt = {}) {
|
|
50
|
+
const cmdline = [
|
|
51
|
+
...Object.entries(opt.env || {}).map(([k, v]) => [k, v].join('=')),
|
|
52
|
+
cmd,
|
|
53
|
+
...args,
|
|
54
|
+
].join(' ');
|
|
55
|
+
console.log((0, colors_1.grey)(cmdline));
|
|
56
|
+
}
|
package/dist/util/git.util.js
CHANGED
package/dist/util/jest.util.d.ts
CHANGED
package/dist/util/jest.util.js
CHANGED
|
@@ -5,8 +5,8 @@ const fs = require("node:fs");
|
|
|
5
5
|
const os = require("node:os");
|
|
6
6
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
7
7
|
const colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
|
|
8
|
-
const exec_1 = require("@naturalcycles/nodejs-lib/dist/exec");
|
|
9
8
|
const paths_cnst_1 = require("../cnst/paths.cnst");
|
|
9
|
+
const exec_util_1 = require("./exec.util");
|
|
10
10
|
const test_util_1 = require("./test.util");
|
|
11
11
|
function getJestConfigPath() {
|
|
12
12
|
return fs.existsSync(`./jest.config.js`) ? './jest.config.js' : `${paths_cnst_1.cfgDir}/jest.config.js`;
|
|
@@ -37,7 +37,7 @@ exports.isRunningAllTests = isRunningAllTests;
|
|
|
37
37
|
/**
|
|
38
38
|
* 1. Adds `--silent` if running all tests at once.
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
function runJest(opt = {}) {
|
|
41
41
|
if (!(0, test_util_1.nodeModuleExists)('jest')) {
|
|
42
42
|
console.log((0, colors_1.dimGrey)(`node_modules/${(0, colors_1.white)('jest')} not found, skipping tests`));
|
|
43
43
|
return;
|
|
@@ -127,14 +127,14 @@ async function runJest(opt = {}) {
|
|
|
127
127
|
if (JEST_SHARDS) {
|
|
128
128
|
const totalShards = Number(JEST_SHARDS);
|
|
129
129
|
const shards = (0, js_lib_1._range)(1, totalShards + 1);
|
|
130
|
-
for
|
|
131
|
-
|
|
130
|
+
for (const shard of shards) {
|
|
131
|
+
(0, exec_util_1.execVoidCommandSync)('jest', (0, js_lib_1._uniq)([...args, `--shard=${shard}/${totalShards}`]), {
|
|
132
132
|
env,
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
else {
|
|
137
|
-
|
|
137
|
+
(0, exec_util_1.execVoidCommandSync)('jest', (0, js_lib_1._uniq)(args), {
|
|
138
138
|
env,
|
|
139
139
|
});
|
|
140
140
|
}
|
package/dist/util/lint.util.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare function getTSConfigPath(): string;
|
|
2
2
|
export declare function getTSConfigPathScripts(): string;
|
|
3
|
-
export declare function runESLint(dir: string, eslintConfigPath: string, tsconfigPath: string | undefined, extensions?: string[], fix?: boolean):
|
|
3
|
+
export declare function runESLint(dir: string, eslintConfigPath: string, tsconfigPath: string | undefined, extensions?: string[], fix?: boolean): void;
|
package/dist/util/lint.util.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runESLint = exports.getTSConfigPathScripts = exports.getTSConfigPath = void 0;
|
|
4
4
|
const fs = require("node:fs");
|
|
5
|
-
const exec_1 = require("@naturalcycles/nodejs-lib/dist/exec");
|
|
6
5
|
const paths_cnst_1 = require("../cnst/paths.cnst");
|
|
6
|
+
const exec_util_1 = require("./exec.util");
|
|
7
7
|
function getTSConfigPath() {
|
|
8
8
|
// this is to support "Solution style tsconfig.json" (as used in Angular10, for example)
|
|
9
9
|
// return [`./tsconfig.base.json`].find(p => fs.existsSync(p)) || `./tsconfig.json`
|
|
@@ -14,7 +14,7 @@ function getTSConfigPathScripts() {
|
|
|
14
14
|
return [`./scripts/tsconfig.json`].find(p => fs.existsSync(p)) || `${paths_cnst_1.scriptsDir}/tsconfig.json`;
|
|
15
15
|
}
|
|
16
16
|
exports.getTSConfigPathScripts = getTSConfigPathScripts;
|
|
17
|
-
|
|
17
|
+
function runESLint(dir, eslintConfigPath, tsconfigPath, extensions = ['ts', 'tsx', 'vue'], fix = true) {
|
|
18
18
|
if (!fs.existsSync(dir))
|
|
19
19
|
return; // faster to bail-out like this
|
|
20
20
|
const args = [
|
|
@@ -26,6 +26,6 @@ async function runESLint(dir, eslintConfigPath, tsconfigPath, extensions = ['ts'
|
|
|
26
26
|
`--report-unused-disable-directives`,
|
|
27
27
|
fix ? `--fix` : '',
|
|
28
28
|
].filter(Boolean);
|
|
29
|
-
|
|
29
|
+
(0, exec_util_1.execVoidCommandSync)('eslint', args);
|
|
30
30
|
}
|
|
31
31
|
exports.runESLint = runESLint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function runPrettier():
|
|
1
|
+
export declare function runPrettier(): void;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runPrettier = void 0;
|
|
4
4
|
const fs = require("node:fs");
|
|
5
|
-
const exec_1 = require("@naturalcycles/nodejs-lib/dist/exec");
|
|
6
5
|
const paths_cnst_1 = require("../cnst/paths.cnst");
|
|
6
|
+
const exec_util_1 = require("./exec.util");
|
|
7
7
|
const { prettierDirs, prettierExtensionsAll, lintExclude } = require('../../cfg/_cnst');
|
|
8
8
|
const prettierPaths = [
|
|
9
9
|
// Everything inside these folders
|
|
@@ -13,11 +13,11 @@ const prettierPaths = [
|
|
|
13
13
|
// Exclude
|
|
14
14
|
...lintExclude.map((s) => `!${s}`),
|
|
15
15
|
];
|
|
16
|
-
|
|
16
|
+
function runPrettier() {
|
|
17
17
|
// If there's no `prettier.config.js` in target project - pass `./cfg/prettier.config.js`
|
|
18
18
|
const prettierConfigPath = [`./prettier.config.js`].find(f => fs.existsSync(f)) || `${paths_cnst_1.cfgDir}/prettier.config.js`;
|
|
19
19
|
// prettier --write 'src/**/*.{js,ts,css,scss,graphql}'
|
|
20
20
|
const args = [`--write`, `--loglevel=warn`, `--config`, prettierConfigPath, ...prettierPaths];
|
|
21
|
-
|
|
21
|
+
(0, exec_util_1.execVoidCommandSync)('prettier', args);
|
|
22
22
|
}
|
|
23
23
|
exports.runPrettier = runPrettier;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const stylelintPaths: any[];
|
|
2
|
-
export declare function stylelintAll():
|
|
2
|
+
export declare function stylelintAll(): void;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stylelintAll = exports.stylelintPaths = void 0;
|
|
4
4
|
const fs = require("node:fs");
|
|
5
|
-
const exec_1 = require("@naturalcycles/nodejs-lib/dist/exec");
|
|
6
5
|
const yargs = require("yargs");
|
|
7
6
|
const paths_cnst_1 = require("../cnst/paths.cnst");
|
|
7
|
+
const exec_util_1 = require("./exec.util");
|
|
8
8
|
const { prettierDirs, stylelintExtensions, lintExclude } = require('../../cfg/_cnst');
|
|
9
9
|
exports.stylelintPaths = [
|
|
10
10
|
// Everything inside these folders
|
|
@@ -12,7 +12,7 @@ exports.stylelintPaths = [
|
|
|
12
12
|
// Exclude
|
|
13
13
|
...lintExclude.map((s) => `!${s}`),
|
|
14
14
|
];
|
|
15
|
-
|
|
15
|
+
function stylelintAll() {
|
|
16
16
|
const { fix } = yargs.options({
|
|
17
17
|
fix: {
|
|
18
18
|
type: 'boolean',
|
|
@@ -27,6 +27,6 @@ async function stylelintAll() {
|
|
|
27
27
|
config,
|
|
28
28
|
...exports.stylelintPaths,
|
|
29
29
|
].filter(Boolean);
|
|
30
|
-
|
|
30
|
+
(0, exec_util_1.execVoidCommandSync)('stylelint', args);
|
|
31
31
|
}
|
|
32
32
|
exports.stylelintAll = stylelintAll;
|
package/dist/util/tsc.util.d.ts
CHANGED
package/dist/util/tsc.util.js
CHANGED
|
@@ -4,13 +4,13 @@ exports.ensureProjectTsconfigScripts = exports.tsc = void 0;
|
|
|
4
4
|
const fs = require("node:fs");
|
|
5
5
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
6
6
|
const colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
|
|
7
|
-
const exec_1 = require("@naturalcycles/nodejs-lib/dist/exec");
|
|
8
7
|
const fs_1 = require("@naturalcycles/nodejs-lib/dist/fs");
|
|
9
8
|
const paths_cnst_1 = require("../cnst/paths.cnst");
|
|
10
|
-
|
|
9
|
+
const exec_util_1 = require("./exec.util");
|
|
10
|
+
function tsc(noEmit = false) {
|
|
11
11
|
const started = Date.now();
|
|
12
|
-
const
|
|
13
|
-
|
|
12
|
+
const args = [noEmit && '--noEmit'].filter(js_lib_1._isTruthy);
|
|
13
|
+
(0, exec_util_1.execVoidCommandSync)('tsc', args);
|
|
14
14
|
console.log(`${(0, colors_1.boldGrey)('tsc')} ${(0, colors_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
|
|
15
15
|
}
|
|
16
16
|
exports.tsc = tsc;
|