@naturalcycles/dev-lib 13.39.3 → 13.40.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/tsconfig.json +16 -12
- package/dist/bin/commitlint-def.js +5 -4
- package/dist/bin/lint-staged-def.js +3 -2
- package/dist/bin/up.js +4 -4
- package/dist/cmd/eslint-all.command.js +7 -6
- package/dist/cmd/lint-all.command.js +7 -6
- package/dist/cnst/paths.cnst.js +3 -2
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +2 -2
- package/dist/testing/time.util.js +4 -3
- package/dist/util/jest.util.js +8 -7
- package/dist/util/lint.util.js +5 -4
- package/dist/util/prettier.util.js +3 -2
- package/dist/util/stylelint.util.js +5 -4
- package/dist/util/test.util.js +3 -2
- package/dist/util/tsc.util.js +5 -4
- package/package.json +2 -2
package/cfg/tsconfig.json
CHANGED
|
@@ -12,13 +12,27 @@
|
|
|
12
12
|
// Target/module
|
|
13
13
|
"target": "es2022",
|
|
14
14
|
"lib": ["esnext"], // add "dom" if needed
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
// module `nodenext` is a modern mode that auto-detects cjs/esm
|
|
16
|
+
// it also defaults `esModuleInterop` and `allowSyntheticDefaultImports` to true
|
|
17
|
+
"module": "nodenext",
|
|
18
|
+
"moduleResolution": "nodenext",
|
|
17
19
|
"moduleDetection": "force",
|
|
20
|
+
// specifying these explicitly for better IDE compatibility (but they're on by default with module=nodenext)
|
|
21
|
+
"esModuleInterop": true,
|
|
22
|
+
"allowSyntheticDefaultImports": true,
|
|
23
|
+
// Faster compilation in general
|
|
24
|
+
// Support for external compilers (e.g esbuild)
|
|
25
|
+
// Speedup in Jest by using "isolatedModules" in 'ts-jest' config
|
|
26
|
+
"isolatedModules": true,
|
|
18
27
|
|
|
19
28
|
// Emit
|
|
20
29
|
"sourceMap": false,
|
|
21
30
|
"declaration": false,
|
|
31
|
+
// Otherwise since es2022 it defaults to true
|
|
32
|
+
// and starts to produce different/unexpected behavior
|
|
33
|
+
// https://angular.schule/blog/2022-11-use-define-for-class-fields
|
|
34
|
+
"useDefineForClassFields": false,
|
|
35
|
+
"importHelpers": true,
|
|
22
36
|
|
|
23
37
|
// Strictness
|
|
24
38
|
"strict": true,
|
|
@@ -29,20 +43,11 @@
|
|
|
29
43
|
"noImplicitOverride": true,
|
|
30
44
|
"noUncheckedIndexedAccess": true,
|
|
31
45
|
"noPropertyAccessFromIndexSignature": true,
|
|
32
|
-
// Otherwise since es2022 it defaults to true
|
|
33
|
-
// and starts to produce different/unexpected behavior
|
|
34
|
-
// https://angular.schule/blog/2022-11-use-define-for-class-fields
|
|
35
|
-
"useDefineForClassFields": false,
|
|
36
46
|
|
|
37
47
|
// todo: monitor if we should have it default or not
|
|
38
48
|
// Enabled should be faster, but will catch less errors
|
|
39
49
|
// "skipLibCheck": true,
|
|
40
50
|
|
|
41
|
-
// Faster compilation in general
|
|
42
|
-
// Support for external compilers (e.g esbuild)
|
|
43
|
-
// Speedup in Jest by using "isolatedModules" in 'ts-jest' config
|
|
44
|
-
"isolatedModules": true,
|
|
45
|
-
|
|
46
51
|
// Need to be specified in the project tsconfig
|
|
47
52
|
// "typeRoots": [
|
|
48
53
|
// "node_modules/@types",
|
|
@@ -52,7 +57,6 @@
|
|
|
52
57
|
// Other
|
|
53
58
|
"pretty": true,
|
|
54
59
|
"newLine": "lf",
|
|
55
|
-
"importHelpers": true,
|
|
56
60
|
"experimentalDecorators": true
|
|
57
61
|
}
|
|
58
62
|
// Need to be specified in the project tsconfig
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_child_process_1 = tslib_1.__importDefault(require("node:child_process"));
|
|
6
|
+
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
6
7
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
7
8
|
const paths_cnst_1 = require("../cnst/paths.cnst");
|
|
8
9
|
const editMsg = process.argv[process.argv.length - 1] || '.git/COMMIT_EDITMSG';
|
|
@@ -10,7 +11,7 @@ const editMsg = process.argv[process.argv.length - 1] || '.git/COMMIT_EDITMSG';
|
|
|
10
11
|
const cwd = process.cwd();
|
|
11
12
|
const localConfig = `${cwd}/commitlint.config.js`;
|
|
12
13
|
const sharedConfig = `${paths_cnst_1.cfgDir}/commitlint.config.js`;
|
|
13
|
-
const config =
|
|
14
|
+
const config = node_fs_1.default.existsSync(localConfig) ? localConfig : sharedConfig;
|
|
14
15
|
const env = {
|
|
15
16
|
...process.env,
|
|
16
17
|
GIT_BRANCH: (0, nodejs_lib_1.gitCurrentBranchName)(),
|
|
@@ -21,7 +22,7 @@ execSync(`node ./node_modules/.bin/commitlint --edit ${editMsg} --config ${confi
|
|
|
21
22
|
});
|
|
22
23
|
function execSync(cmd, opt) {
|
|
23
24
|
try {
|
|
24
|
-
|
|
25
|
+
node_child_process_1.default.execSync(cmd, {
|
|
25
26
|
...opt,
|
|
26
27
|
encoding: 'utf8',
|
|
27
28
|
stdio: 'inherit',
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
5
6
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
6
7
|
const paths_cnst_1 = require("../cnst/paths.cnst");
|
|
7
8
|
(0, nodejs_lib_1.runScript)(async () => {
|
|
8
9
|
// const cwd = process.cwd()
|
|
9
10
|
const localConfig = `./lint-staged.config.js`;
|
|
10
11
|
const sharedConfig = `${paths_cnst_1.cfgDir}/lint-staged.config.js`;
|
|
11
|
-
const config =
|
|
12
|
+
const config = node_fs_1.default.existsSync(localConfig) ? localConfig : sharedConfig;
|
|
12
13
|
// await execWithArgs(`lint-staged`, [`--config`, config])
|
|
13
14
|
// const lintStaged = require('lint-staged')
|
|
14
15
|
// lint-staged is ESM since 12.0
|
package/dist/bin/up.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
5
6
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
6
|
-
|
|
7
|
-
(0, nodejs_lib_2.runScript)(async () => {
|
|
7
|
+
(0, nodejs_lib_1.runScript)(async () => {
|
|
8
8
|
(0, nodejs_lib_1.execVoidCommandSync)('yarn', ['upgrade']);
|
|
9
|
-
if (
|
|
9
|
+
if (node_fs_1.default.existsSync(`node_modules/patch-package`)) {
|
|
10
10
|
(0, nodejs_lib_1.execVoidCommandSync)('patch-package');
|
|
11
11
|
}
|
|
12
12
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.eslintAllCommand = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
5
6
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
6
7
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
7
|
-
const
|
|
8
|
+
const yargs_1 = tslib_1.__importDefault(require("yargs"));
|
|
8
9
|
const paths_cnst_1 = require("../cnst/paths.cnst");
|
|
9
10
|
const lint_util_1 = require("../util/lint.util");
|
|
10
11
|
/**
|
|
@@ -12,7 +13,7 @@ const lint_util_1 = require("../util/lint.util");
|
|
|
12
13
|
*/
|
|
13
14
|
async function eslintAllCommand() {
|
|
14
15
|
const started = Date.now();
|
|
15
|
-
const { ext, fix } =
|
|
16
|
+
const { ext, fix } = yargs_1.default.options({
|
|
16
17
|
ext: {
|
|
17
18
|
type: 'string',
|
|
18
19
|
default: 'ts,tsx,vue',
|
|
@@ -23,10 +24,10 @@ async function eslintAllCommand() {
|
|
|
23
24
|
},
|
|
24
25
|
}).argv;
|
|
25
26
|
const extensions = ext.split(',');
|
|
26
|
-
const eslintConfigPathRoot = ['./.eslintrc.js'].find(p =>
|
|
27
|
-
const eslintConfigPathScripts = ['./scripts/.eslintrc.js', './.eslintrc.js'].find(p =>
|
|
27
|
+
const eslintConfigPathRoot = ['./.eslintrc.js'].find(p => node_fs_1.default.existsSync(p)) || `${paths_cnst_1.cfgDir}/eslint.config.js`;
|
|
28
|
+
const eslintConfigPathScripts = ['./scripts/.eslintrc.js', './.eslintrc.js'].find(p => node_fs_1.default.existsSync(p)) ||
|
|
28
29
|
`${paths_cnst_1.cfgDir}/eslint.config.js`;
|
|
29
|
-
const eslintConfigPathE2e = ['./e2e/.eslintrc.js', './.eslintrc.js'].find(p =>
|
|
30
|
+
const eslintConfigPathE2e = ['./e2e/.eslintrc.js', './.eslintrc.js'].find(p => node_fs_1.default.existsSync(p)) ||
|
|
30
31
|
`${paths_cnst_1.cfgDir}/eslint.config.js`;
|
|
31
32
|
// const tsconfigPath = getTSConfigPath()
|
|
32
33
|
const tsconfigPathScripts = (0, lint_util_1.getTSConfigPathScripts)();
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.lintAllCommand = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
5
6
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
6
7
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
7
|
-
const
|
|
8
|
+
const yargs_1 = tslib_1.__importDefault(require("yargs"));
|
|
8
9
|
const nodejs_lib_2 = require("@naturalcycles/nodejs-lib");
|
|
9
10
|
const prettier_util_1 = require("../util/prettier.util");
|
|
10
11
|
const stylelint_util_1 = require("../util/stylelint.util");
|
|
@@ -14,7 +15,7 @@ const eslint_all_command_1 = require("./eslint-all.command");
|
|
|
14
15
|
*/
|
|
15
16
|
async function lintAllCommand() {
|
|
16
17
|
const started = Date.now();
|
|
17
|
-
const { commitOnChanges, failOnChanges } =
|
|
18
|
+
const { commitOnChanges, failOnChanges } = yargs_1.default.options({
|
|
18
19
|
commitOnChanges: {
|
|
19
20
|
type: 'boolean',
|
|
20
21
|
default: false,
|
|
@@ -26,12 +27,12 @@ async function lintAllCommand() {
|
|
|
26
27
|
}).argv;
|
|
27
28
|
const hadChangesBefore = (0, nodejs_lib_2.gitHasUncommittedChanges)();
|
|
28
29
|
await (0, eslint_all_command_1.eslintAllCommand)();
|
|
29
|
-
if (
|
|
30
|
-
|
|
30
|
+
if (node_fs_1.default.existsSync(`node_modules/stylelint`) &&
|
|
31
|
+
node_fs_1.default.existsSync(`node_modules/stylelint-config-standard-scss`)) {
|
|
31
32
|
(0, stylelint_util_1.stylelintAll)();
|
|
32
33
|
}
|
|
33
34
|
(0, prettier_util_1.runPrettier)();
|
|
34
|
-
if (
|
|
35
|
+
if (node_fs_1.default.existsSync(`node_modules/@naturalcycles/ktlint`)) {
|
|
35
36
|
const ktlintLib = require('@naturalcycles/ktlint');
|
|
36
37
|
await ktlintLib.ktlintAll();
|
|
37
38
|
}
|
package/dist/cnst/paths.cnst.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.scriptsDir = exports.cfgOverwriteDir = exports.cfgDir = exports.srcDir = exports.projectDir = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
6
|
+
exports.projectDir = node_path_1.default.join(__dirname, '../..');
|
|
6
7
|
exports.srcDir = `${exports.projectDir}/src`;
|
|
7
8
|
exports.cfgDir = `${exports.projectDir}/cfg`;
|
|
8
9
|
exports.cfgOverwriteDir = `${exports.projectDir}/cfg/overwrite`;
|
package/dist/testing/index.d.ts
CHANGED
package/dist/testing/index.js
CHANGED
|
@@ -2,8 +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
|
|
6
|
-
exports.timekeeper =
|
|
5
|
+
const timekeeper_1 = tslib_1.__importDefault(require("timekeeper"));
|
|
6
|
+
exports.timekeeper = timekeeper_1.default;
|
|
7
7
|
tslib_1.__exportStar(require("../jestOffline.util"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./expect.util"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./mockAllKindsOfThings"), exports);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resetTime = exports.mockTimeMillis = exports.mockTime = exports.MOCK_TS_2018_06_21 = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const timekeeper_1 = tslib_1.__importDefault(require("timekeeper"));
|
|
5
6
|
exports.MOCK_TS_2018_06_21 = 1529539200;
|
|
6
7
|
/**
|
|
7
8
|
* Locks time-related functions to return always same time.
|
|
@@ -12,10 +13,10 @@ function mockTime(ts = exports.MOCK_TS_2018_06_21) {
|
|
|
12
13
|
}
|
|
13
14
|
exports.mockTime = mockTime;
|
|
14
15
|
function mockTimeMillis(millis = exports.MOCK_TS_2018_06_21 * 1000) {
|
|
15
|
-
|
|
16
|
+
timekeeper_1.default.freeze(millis);
|
|
16
17
|
}
|
|
17
18
|
exports.mockTimeMillis = mockTimeMillis;
|
|
18
19
|
function resetTime() {
|
|
19
|
-
|
|
20
|
+
timekeeper_1.default.reset();
|
|
20
21
|
}
|
|
21
22
|
exports.resetTime = resetTime;
|
package/dist/util/jest.util.js
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runJest = exports.isRunningAllTests = exports.getJestManualConfigPath = exports.getJestIntegrationConfigPath = exports.getJestConfigPath = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
6
|
+
const node_os_1 = tslib_1.__importDefault(require("node:os"));
|
|
6
7
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
7
8
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
8
9
|
const nodejs_lib_2 = require("@naturalcycles/nodejs-lib");
|
|
9
10
|
const paths_cnst_1 = require("../cnst/paths.cnst");
|
|
10
11
|
const test_util_1 = require("./test.util");
|
|
11
12
|
function getJestConfigPath() {
|
|
12
|
-
return
|
|
13
|
+
return node_fs_1.default.existsSync(`./jest.config.js`) ? './jest.config.js' : `${paths_cnst_1.cfgDir}/jest.config.js`;
|
|
13
14
|
}
|
|
14
15
|
exports.getJestConfigPath = getJestConfigPath;
|
|
15
16
|
function getJestIntegrationConfigPath() {
|
|
16
|
-
return
|
|
17
|
+
return node_fs_1.default.existsSync(`./jest.integration-test.config.js`)
|
|
17
18
|
? `./jest.integration-test.config.js`
|
|
18
19
|
: `${paths_cnst_1.cfgDir}/jest.integration-test.config.js`;
|
|
19
20
|
}
|
|
20
21
|
exports.getJestIntegrationConfigPath = getJestIntegrationConfigPath;
|
|
21
22
|
function getJestManualConfigPath() {
|
|
22
|
-
return
|
|
23
|
+
return node_fs_1.default.existsSync(`./jest.manual-test.config.js`)
|
|
23
24
|
? `./jest.manual-test.config.js`
|
|
24
25
|
: `${paths_cnst_1.cfgDir}/jest.manual-test.config.js`;
|
|
25
26
|
}
|
|
@@ -113,8 +114,8 @@ function runJest(opt = {}) {
|
|
|
113
114
|
if (!JEST_NO_ALPHABETIC) {
|
|
114
115
|
args.push(`--testSequencer=${paths_cnst_1.cfgDir}/jest.alphabetic.sequencer.js`);
|
|
115
116
|
}
|
|
116
|
-
const availableParallelism =
|
|
117
|
-
const cpus =
|
|
117
|
+
const availableParallelism = node_os_1.default.availableParallelism?.();
|
|
118
|
+
const cpus = node_os_1.default.cpus().length;
|
|
118
119
|
console.log(`${(0, nodejs_lib_2.dimGrey)(Object.entries({
|
|
119
120
|
node,
|
|
120
121
|
NODE_OPTIONS,
|
package/dist/util/lint.util.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runESLintAsync = exports.runESLint = exports.getTSConfigPathScripts = exports.getTSConfigPath = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
5
6
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
6
7
|
const paths_cnst_1 = require("../cnst/paths.cnst");
|
|
7
8
|
function getTSConfigPath() {
|
|
@@ -11,17 +12,17 @@ function getTSConfigPath() {
|
|
|
11
12
|
}
|
|
12
13
|
exports.getTSConfigPath = getTSConfigPath;
|
|
13
14
|
function getTSConfigPathScripts() {
|
|
14
|
-
return [`./scripts/tsconfig.json`].find(p =>
|
|
15
|
+
return [`./scripts/tsconfig.json`].find(p => node_fs_1.default.existsSync(p)) || `${paths_cnst_1.scriptsDir}/tsconfig.json`;
|
|
15
16
|
}
|
|
16
17
|
exports.getTSConfigPathScripts = getTSConfigPathScripts;
|
|
17
18
|
function runESLint(dir, eslintConfigPath, tsconfigPath, extensions = ['ts', 'tsx', 'vue'], fix = true) {
|
|
18
|
-
if (!
|
|
19
|
+
if (!node_fs_1.default.existsSync(dir))
|
|
19
20
|
return; // faster to bail-out like this
|
|
20
21
|
(0, nodejs_lib_1.execVoidCommandSync)('eslint', getEslintArgs(dir, eslintConfigPath, tsconfigPath, extensions, fix));
|
|
21
22
|
}
|
|
22
23
|
exports.runESLint = runESLint;
|
|
23
24
|
async function runESLintAsync(dir, eslintConfigPath, tsconfigPath, extensions = ['ts', 'tsx', 'vue'], fix = true) {
|
|
24
|
-
if (!
|
|
25
|
+
if (!node_fs_1.default.existsSync(dir))
|
|
25
26
|
return; // faster to bail-out like this
|
|
26
27
|
await (0, nodejs_lib_1.execVoidCommand)('eslint', getEslintArgs(dir, eslintConfigPath, tsconfigPath, extensions, fix));
|
|
27
28
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runPrettier = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
5
6
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
6
7
|
const paths_cnst_1 = require("../cnst/paths.cnst");
|
|
7
8
|
const { prettierDirs, prettierExtensionsAll, lintExclude } = require('../../cfg/_cnst');
|
|
@@ -15,7 +16,7 @@ const prettierPaths = [
|
|
|
15
16
|
];
|
|
16
17
|
function runPrettier() {
|
|
17
18
|
// If there's no `prettier.config.js` in target project - pass `./cfg/prettier.config.js`
|
|
18
|
-
const prettierConfigPath = [`./prettier.config.js`].find(f =>
|
|
19
|
+
const prettierConfigPath = [`./prettier.config.js`].find(f => node_fs_1.default.existsSync(f)) || `${paths_cnst_1.cfgDir}/prettier.config.js`;
|
|
19
20
|
// prettier --write 'src/**/*.{js,ts,css,scss,graphql}'
|
|
20
21
|
const args = [`--write`, `--log-level=warn`, `--config`, prettierConfigPath, ...prettierPaths];
|
|
21
22
|
(0, nodejs_lib_1.execVoidCommandSync)('prettier', args);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stylelintAll = exports.stylelintPaths = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
5
6
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
6
|
-
const
|
|
7
|
+
const yargs_1 = tslib_1.__importDefault(require("yargs"));
|
|
7
8
|
const paths_cnst_1 = require("../cnst/paths.cnst");
|
|
8
9
|
const { prettierDirs, stylelintExtensions, lintExclude } = require('../../cfg/_cnst');
|
|
9
10
|
exports.stylelintPaths = [
|
|
@@ -13,13 +14,13 @@ exports.stylelintPaths = [
|
|
|
13
14
|
...lintExclude.map((s) => `!${s}`),
|
|
14
15
|
];
|
|
15
16
|
function stylelintAll() {
|
|
16
|
-
const { fix } =
|
|
17
|
+
const { fix } = yargs_1.default.options({
|
|
17
18
|
fix: {
|
|
18
19
|
type: 'boolean',
|
|
19
20
|
default: true,
|
|
20
21
|
},
|
|
21
22
|
}).argv;
|
|
22
|
-
const config = [`./stylelint.config.js`, `${paths_cnst_1.cfgDir}/stylelint.config.js`].find(f =>
|
|
23
|
+
const config = [`./stylelint.config.js`, `${paths_cnst_1.cfgDir}/stylelint.config.js`].find(f => node_fs_1.default.existsSync(f));
|
|
23
24
|
const args = [
|
|
24
25
|
fix ? `--fix` : '',
|
|
25
26
|
`--allow-empty-input`,
|
package/dist/util/test.util.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.nodeModuleExists = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
5
6
|
/**
|
|
6
7
|
* Returns true if module with given name exists in _target project's_ node_modules.
|
|
7
8
|
*/
|
|
8
9
|
function nodeModuleExists(moduleName) {
|
|
9
|
-
return
|
|
10
|
+
return node_fs_1.default.existsSync(`./node_modules/${moduleName}`);
|
|
10
11
|
}
|
|
11
12
|
exports.nodeModuleExists = nodeModuleExists;
|
package/dist/util/tsc.util.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ensureProjectTsconfigScripts = exports.tscScriptsAsync = exports.tscScripts = exports.tscAsync = exports.tsc = exports.tscMainAndScripts = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
5
6
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
6
7
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
7
8
|
const nodejs_lib_2 = require("@naturalcycles/nodejs-lib");
|
|
@@ -26,7 +27,7 @@ async function tscAsync(noEmit = false) {
|
|
|
26
27
|
}
|
|
27
28
|
exports.tscAsync = tscAsync;
|
|
28
29
|
function tscScripts() {
|
|
29
|
-
if (!
|
|
30
|
+
if (!node_fs_1.default.existsSync('./scripts')) {
|
|
30
31
|
// ./scripts folder doesn't exist, skipping
|
|
31
32
|
return;
|
|
32
33
|
}
|
|
@@ -38,7 +39,7 @@ function tscScripts() {
|
|
|
38
39
|
}
|
|
39
40
|
exports.tscScripts = tscScripts;
|
|
40
41
|
async function tscScriptsAsync() {
|
|
41
|
-
if (!
|
|
42
|
+
if (!node_fs_1.default.existsSync('./scripts')) {
|
|
42
43
|
// ./scripts folder doesn't exist, skipping
|
|
43
44
|
return;
|
|
44
45
|
}
|
|
@@ -54,7 +55,7 @@ exports.tscScriptsAsync = tscScriptsAsync;
|
|
|
54
55
|
*/
|
|
55
56
|
function ensureProjectTsconfigScripts() {
|
|
56
57
|
const projectTsconfigPath = `./scripts/tsconfig.json`;
|
|
57
|
-
if (!
|
|
58
|
+
if (!node_fs_1.default.existsSync(projectTsconfigPath)) {
|
|
58
59
|
// You cannot just use a shared `tsconfig.scripts.json` because of relative paths for `include`
|
|
59
60
|
// So, it will be copied into the project
|
|
60
61
|
(0, nodejs_lib_3.kpySync)({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/dev-lib",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.40.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky install",
|
|
6
6
|
"tsn-debug": "tsn testScript.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@commitlint/config-conventional": "^17.0.0",
|
|
34
34
|
"@naturalcycles/cli": "^1.0.0",
|
|
35
35
|
"@naturalcycles/js-lib": "^14.0.0",
|
|
36
|
-
"@naturalcycles/nodejs-lib": "^
|
|
36
|
+
"@naturalcycles/nodejs-lib": "^13.0.1",
|
|
37
37
|
"@types/jest": "^29.0.0",
|
|
38
38
|
"@types/node": "^20.1.0",
|
|
39
39
|
"@types/yargs": "^16.0.0",
|