@naturalcycles/dev-lib 17.3.0 → 18.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/cfg/_cnst.d.ts +7 -0
- package/cfg/_cnst.js +21 -12
- package/cfg/commitlint.config.js +1 -1
- package/cfg/eslint-biome-rules.js +1 -1
- package/cfg/eslint-prettier-rules.js +1 -1
- package/cfg/eslint-rules.js +1 -1
- package/cfg/eslint-vue-rules.js +1 -1
- package/cfg/eslint.config.js +27 -23
- package/cfg/init/commitlint.config.js +4 -2
- package/cfg/init/eslint.config.js +5 -4
- package/cfg/init/lint-staged.config.js +4 -2
- package/cfg/init/prettier.config.js +3 -3
- package/cfg/init/{vitest.config.mts → vitest.config.ts} +1 -1
- package/cfg/lint-staged.config.js +8 -8
- package/cfg/prettier.config.js +1 -1
- package/cfg/stylelint.config.js +1 -1
- package/cfg/{vitest.config.mjs → vitest.config.js} +1 -1
- package/dist/bin/dev-lib.js +41 -48
- package/dist/bin/up.js +4 -6
- package/dist/bin/upnc.js +4 -6
- package/dist/build.util.d.ts +0 -1
- package/dist/build.util.js +12 -70
- package/dist/index.js +1 -2
- package/dist/init-from-dev-lib.command.js +5 -8
- package/dist/lint.util.js +56 -76
- package/dist/paths.js +10 -10
- package/dist/test.util.js +8 -127
- package/dist/testing/index.d.ts +2 -4
- package/dist/testing/index.js +5 -7
- package/dist/testing/mockAllKindsOfThings.js +3 -7
- package/dist/testing/{testOffline.util.js → testOffline.js} +3 -7
- package/dist/testing/testing.util.js +7 -11
- package/dist/testing/time.js +12 -0
- package/dist/yarn.util.js +12 -16
- package/package.json +5 -3
- package/readme.md +9 -24
- package/cfg/eslint-jest-rules.js +0 -14
- package/cfg/jest.alphabetic.sequencer.js +0 -13
- package/cfg/jest.config.js +0 -139
- package/cfg/jest.esbuild.transformer.js +0 -37
- package/cfg/jest.integration-test.config.js +0 -41
- package/cfg/jest.manual-test.config.js +0 -25
- package/dist/testing/time.util.js +0 -18
- /package/cfg/{vitest.config.d.mts → vitest.config.d.ts} +0 -0
- /package/cfg/{vitestAlphabeticSequencer.mjs → vitestAlphabeticSequencer.js} +0 -0
- /package/dist/testing/{testOffline.util.d.ts → testOffline.d.ts} +0 -0
- /package/dist/testing/{time.util.d.ts → time.d.ts} +0 -0
package/cfg/_cnst.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const prettierDirs: string[]
|
|
2
|
+
export declare const prettierExtensionsExclusive: string
|
|
3
|
+
export declare const prettierExtensionsAll: string
|
|
4
|
+
export declare const eslintExtensions: string
|
|
5
|
+
export declare const stylelintExtensions: string
|
|
6
|
+
export declare const lintExclude: string[]
|
|
7
|
+
export declare const minActionlintVersion: string
|
package/cfg/_cnst.js
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
const prettierDirs = [
|
|
2
|
+
'src,scripts,e2e,docs,cfg,resources,.github,public,static,components,content,layouts,pages,plugins,middleware,store,blocks',
|
|
3
|
+
]
|
|
4
|
+
// ts,tsx,css,scss excluded, cause they need to run in special order (overlap between >1 tool):
|
|
5
|
+
const prettierExtensionsExclusive = 'js,jsx,json,md,graphql,yml,yaml,html'
|
|
6
|
+
// everything that prettier supports:
|
|
7
|
+
const prettierExtensionsAll =
|
|
8
|
+
'ts,tsx,cts,mts,css,scss,js,jsx,cjs,mjs,json,md,graphql,yml,yaml,html,vue'
|
|
9
|
+
const eslintExtensions = 'ts,tsx,cts,mts,vue,html'
|
|
10
|
+
const stylelintExtensions = 'css,scss'
|
|
11
|
+
const lintExclude = ['./**/__exclude/**', './**/dist/**', './**/cache/**', './CHANGELOG.md']
|
|
12
|
+
const minActionlintVersion = '1.7.4'
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
prettierDirs,
|
|
16
|
+
prettierExtensionsExclusive,
|
|
17
|
+
prettierExtensionsAll,
|
|
18
|
+
eslintExtensions,
|
|
19
|
+
stylelintExtensions,
|
|
20
|
+
lintExclude,
|
|
21
|
+
minActionlintVersion,
|
|
13
22
|
}
|
package/cfg/commitlint.config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// These rules are disabled, because prettier handles it
|
|
2
2
|
// Copy-pasted from https://github.com/prettier/eslint-config-prettier
|
|
3
|
-
|
|
3
|
+
export default {
|
|
4
4
|
rules: {
|
|
5
5
|
// The following rules can be used in some cases. See the README for more
|
|
6
6
|
// information. These are marked with `0` instead of `0` so that a
|
package/cfg/eslint-rules.js
CHANGED
package/cfg/eslint-vue-rules.js
CHANGED
package/cfg/eslint.config.js
CHANGED
|
@@ -4,19 +4,23 @@
|
|
|
4
4
|
* Shared eslint FLAT config.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
import globals from 'globals'
|
|
8
|
+
import eslint from '@eslint/js'
|
|
9
|
+
import tseslint from 'typescript-eslint'
|
|
10
|
+
import eslintPluginUnicorn from 'eslint-plugin-unicorn'
|
|
11
|
+
import eslintPluginVue from 'eslint-plugin-vue'
|
|
12
|
+
import eslintPluginImportX from 'eslint-plugin-import-x'
|
|
13
|
+
import eslintPluginSimpleImportSort from 'eslint-plugin-simple-import-sort'
|
|
14
|
+
import eslintPluginJsdoc from 'eslint-plugin-jsdoc'
|
|
15
|
+
import eslintPluginStylistic from '@stylistic/eslint-plugin'
|
|
16
|
+
import eslintRules from './eslint-rules.js'
|
|
17
|
+
import eslintVueRules from './eslint-vue-rules.js'
|
|
18
|
+
import eslintPrettierRules from './eslint-prettier-rules.js'
|
|
19
|
+
import eslintBiomeRules from './eslint-biome-rules.js'
|
|
16
20
|
|
|
17
21
|
const defaultFiles = ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts']
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
export default [
|
|
20
24
|
{
|
|
21
25
|
...eslint.configs.recommended,
|
|
22
26
|
files: defaultFiles,
|
|
@@ -33,12 +37,12 @@ module.exports = [
|
|
|
33
37
|
})),
|
|
34
38
|
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/configs/recommended.js
|
|
35
39
|
{
|
|
36
|
-
...
|
|
40
|
+
...eslintPluginUnicorn.configs.recommended,
|
|
37
41
|
files: defaultFiles,
|
|
38
42
|
},
|
|
39
43
|
// https://eslint.vuejs.org/user-guide/#user-guide
|
|
40
44
|
// ...require('eslint-plugin-vue').configs['flat/recommended'],
|
|
41
|
-
...
|
|
45
|
+
...eslintPluginVue.configs['flat/recommended'].map(c => ({
|
|
42
46
|
...c,
|
|
43
47
|
files: defaultFiles,
|
|
44
48
|
})),
|
|
@@ -55,19 +59,19 @@ function getConfig() {
|
|
|
55
59
|
return {
|
|
56
60
|
plugins: {
|
|
57
61
|
'@typescript-eslint': tseslint.plugin,
|
|
58
|
-
'import-x':
|
|
62
|
+
'import-x': eslintPluginImportX,
|
|
59
63
|
// 'unused-imports': require('eslint-plugin-unused-imports'), // disabled in favor of biome rules
|
|
60
|
-
'simple-import-sort':
|
|
61
|
-
jsdoc:
|
|
62
|
-
'@stylistic':
|
|
63
|
-
...(hasJest ? { jest: require('eslint-plugin-jest') } : {}),
|
|
64
|
+
'simple-import-sort': eslintPluginSimpleImportSort,
|
|
65
|
+
jsdoc: eslintPluginJsdoc,
|
|
66
|
+
'@stylistic': eslintPluginStylistic,
|
|
67
|
+
// ...(hasJest ? { jest: require('eslint-plugin-jest') } : {}), // todo: eslint-plugin-vitest
|
|
64
68
|
},
|
|
65
69
|
languageOptions: {
|
|
66
70
|
ecmaVersion: 'latest',
|
|
67
71
|
globals: {
|
|
68
72
|
...globals.browser,
|
|
69
73
|
...globals.node,
|
|
70
|
-
...globals.jest,
|
|
74
|
+
// ...globals.jest,
|
|
71
75
|
...globals.vitest,
|
|
72
76
|
NodeJS: 'readonly',
|
|
73
77
|
},
|
|
@@ -82,11 +86,11 @@ function getConfig() {
|
|
|
82
86
|
reportUnusedDisableDirectives: 'error',
|
|
83
87
|
},
|
|
84
88
|
rules: {
|
|
85
|
-
...
|
|
86
|
-
...
|
|
87
|
-
...(hasJest ? require('./eslint-jest-rules').rules : {}),
|
|
88
|
-
...
|
|
89
|
-
...
|
|
89
|
+
...eslintRules.rules,
|
|
90
|
+
...eslintVueRules.rules,
|
|
91
|
+
// ...(hasJest ? require('./eslint-jest-rules').rules : {}), // todo: vitest-rules
|
|
92
|
+
...eslintPrettierRules.rules, // disable eslint rules already covered by prettier
|
|
93
|
+
...eslintBiomeRules.rules, // disable eslint rules already covered by biome
|
|
90
94
|
},
|
|
91
95
|
}
|
|
92
96
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import sharedConfig from '@naturalcycles/dev-lib/cfg/eslint.config.js'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...sharedConfig,
|
|
5
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import sharedConfig from '@naturalcycles/dev-lib/cfg/prettier.config.js'
|
|
2
|
+
|
|
3
|
+
export default sharedConfig
|
|
@@ -12,20 +12,20 @@ const {
|
|
|
12
12
|
|
|
13
13
|
console.log(`lint-staged.config.js runs on node ${node} ${platform} ${arch}`)
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
import fs from 'node:fs'
|
|
16
|
+
import micromatch from 'micromatch'
|
|
17
|
+
import { execSync } from 'node:child_process'
|
|
18
|
+
import { _assert, semver2 } from '@naturalcycles/js-lib'
|
|
19
|
+
import { exec2 } from '@naturalcycles/nodejs-lib'
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
import {
|
|
22
22
|
prettierDirs,
|
|
23
23
|
prettierExtensionsExclusive,
|
|
24
24
|
prettierExtensionsAll,
|
|
25
25
|
stylelintExtensions,
|
|
26
26
|
lintExclude,
|
|
27
27
|
minActionlintVersion,
|
|
28
|
-
}
|
|
28
|
+
} from './_cnst.js'
|
|
29
29
|
|
|
30
30
|
const prettierConfigPath = [`prettier.config.js`].find(fs.existsSync)
|
|
31
31
|
|
|
@@ -221,4 +221,4 @@ function getActionLintVersion() {
|
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
|
|
224
|
+
export default linters
|
package/cfg/prettier.config.js
CHANGED
package/cfg/stylelint.config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
2
|
|
|
3
|
-
import { VitestAlphabeticSequencer } from './vitestAlphabeticSequencer.
|
|
3
|
+
import { VitestAlphabeticSequencer } from './vitestAlphabeticSequencer.js'
|
|
4
4
|
const runsInIDE = doesItRunInIDE()
|
|
5
5
|
const testType = getTestType(runsInIDE)
|
|
6
6
|
const silent = shouldBeSilent(runsInIDE)
|
package/dist/bin/dev-lib.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const test_util_1 = require("../test.util");
|
|
10
|
-
const yarn_util_1 = require("../yarn.util");
|
|
2
|
+
import { select, Separator } from '@inquirer/prompts';
|
|
3
|
+
import { _assert, _by } from '@naturalcycles/js-lib';
|
|
4
|
+
import { runScript } from '@naturalcycles/nodejs-lib';
|
|
5
|
+
import { buildCopy, buildProd, runTSCInFolders } from '../build.util.js';
|
|
6
|
+
import { eslintAll, lintAllCommand, lintStagedCommand, runBiome, runCommitlintCommand, runPrettier, stylelintAll, } from '../lint.util.js';
|
|
7
|
+
import { runTest } from '../test.util.js';
|
|
8
|
+
import { up, upnc } from '../yarn.util.js';
|
|
11
9
|
const commands = [
|
|
12
|
-
new
|
|
10
|
+
new Separator(), // build
|
|
13
11
|
{
|
|
14
12
|
name: 'tsc',
|
|
15
13
|
fn: tscAll,
|
|
@@ -19,76 +17,71 @@ const commands = [
|
|
|
19
17
|
{ name: 'lbt', fn: lbt, desc: 'Lint/Build/Test: run "lint", then "tsc", then "test".' },
|
|
20
18
|
{
|
|
21
19
|
name: 'build',
|
|
22
|
-
fn:
|
|
20
|
+
fn: buildProd,
|
|
23
21
|
desc: 'Clean ./dist, run "build-copy" then tsc with --emit and --noCheck, using tsconfig.prod.json',
|
|
24
22
|
},
|
|
25
23
|
{
|
|
26
24
|
name: 'build-copy',
|
|
27
|
-
fn:
|
|
25
|
+
fn: buildCopy,
|
|
28
26
|
desc: 'Copy the non-ts files from ./src to ./dist',
|
|
29
27
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
fn: build_util_1.buildEsmCjs,
|
|
33
|
-
desc: 'Clean ./dist and ./dist-esm, then run "tsc" in CJS and ESM modes, with --emit and --noCheck',
|
|
34
|
-
},
|
|
35
|
-
new prompts_1.Separator(), // test
|
|
36
|
-
{ name: 'test', fn: test_util_1.runTest, desc: 'Run vitest/jest for *.test.ts files.' },
|
|
28
|
+
new Separator(), // test
|
|
29
|
+
{ name: 'test', fn: runTest, desc: 'Run vitest for *.test.ts files.' },
|
|
37
30
|
{
|
|
38
31
|
name: 'test-integration',
|
|
39
|
-
fn: () =>
|
|
40
|
-
desc: 'Run vitest
|
|
32
|
+
fn: () => runTest({ integration: true }),
|
|
33
|
+
desc: 'Run vitest for *.integration.test.ts files.',
|
|
41
34
|
},
|
|
42
35
|
{
|
|
43
36
|
name: 'test-manual',
|
|
44
|
-
fn: () =>
|
|
45
|
-
desc: 'Run vitest
|
|
37
|
+
fn: () => runTest({ manual: true }),
|
|
38
|
+
desc: 'Run vitest for *.manual.test.ts files.',
|
|
46
39
|
},
|
|
47
40
|
{
|
|
48
41
|
name: 'test-leaks',
|
|
49
|
-
fn: () =>
|
|
50
|
-
desc: 'Run vitest
|
|
42
|
+
fn: () => runTest({ leaks: true }),
|
|
43
|
+
desc: 'Run vitest --detectLeaks for *.test.ts files.',
|
|
51
44
|
},
|
|
52
|
-
new
|
|
45
|
+
new Separator(), // lint
|
|
53
46
|
{
|
|
54
47
|
name: 'lint',
|
|
55
|
-
fn:
|
|
48
|
+
fn: lintAllCommand,
|
|
56
49
|
desc: 'Run all linters: eslint, prettier, stylelint, ktlint, actionlint.',
|
|
57
50
|
},
|
|
58
51
|
{
|
|
59
52
|
name: 'lint-staged',
|
|
60
|
-
fn:
|
|
53
|
+
fn: lintStagedCommand,
|
|
61
54
|
desc: 'Run "lint-staged", which runs linter on git staged files.',
|
|
62
55
|
},
|
|
63
|
-
{ name: 'eslint', fn:
|
|
56
|
+
{ name: 'eslint', fn: eslintAll, desc: 'Run eslint on all files.' },
|
|
64
57
|
{
|
|
65
58
|
name: 'eslint --no-fix',
|
|
66
|
-
fn: async () => await
|
|
59
|
+
fn: async () => await eslintAll({ fix: false }),
|
|
67
60
|
desc: 'Run eslint on all files with "auto-fix" disabled. Useful for debugging.',
|
|
68
61
|
interactiveOnly: true,
|
|
69
62
|
},
|
|
70
63
|
{
|
|
71
64
|
name: 'biome',
|
|
72
|
-
fn: () =>
|
|
65
|
+
fn: () => runBiome(),
|
|
73
66
|
desc: 'Run biome linter on all files.',
|
|
74
67
|
},
|
|
75
68
|
{
|
|
76
69
|
name: 'biome --no-fix',
|
|
77
|
-
fn: () =>
|
|
70
|
+
fn: () => runBiome(false),
|
|
78
71
|
desc: 'Run biome linter on all files with "auto-fix" disabled. Useful for debugging.',
|
|
79
72
|
interactiveOnly: true,
|
|
80
73
|
},
|
|
81
|
-
{ name: 'prettier', fn:
|
|
82
|
-
{ name: 'stylelint', fn:
|
|
83
|
-
{ name: 'commitlint', fn:
|
|
84
|
-
new
|
|
85
|
-
{ name: 'up', fn:
|
|
74
|
+
{ name: 'prettier', fn: runPrettier, desc: 'Run prettier on all files.' },
|
|
75
|
+
{ name: 'stylelint', fn: stylelintAll, desc: 'Run stylelint on all files.' },
|
|
76
|
+
{ name: 'commitlint', fn: runCommitlintCommand, desc: 'Run commitlint.', cliOnly: true },
|
|
77
|
+
new Separator(), // yarn
|
|
78
|
+
{ name: 'up', fn: up, desc: 'Shortcut for "yarn upgrade". Also runs yarn-deduplicate.' },
|
|
86
79
|
{
|
|
87
80
|
name: 'upnc',
|
|
88
|
-
fn:
|
|
81
|
+
fn: upnc,
|
|
89
82
|
desc: 'Shortcut for "yarn upgrade --pattern @naturalcycles". Also runs yarn-deduplicate.',
|
|
90
83
|
},
|
|
91
|
-
new
|
|
84
|
+
new Separator(), // interactive-only
|
|
92
85
|
{
|
|
93
86
|
name: 'exit',
|
|
94
87
|
fn: () => console.log('see you!'),
|
|
@@ -108,20 +101,20 @@ const commands = [
|
|
|
108
101
|
// })
|
|
109
102
|
// },
|
|
110
103
|
];
|
|
111
|
-
const commandMap =
|
|
104
|
+
const commandMap = _by(commands.filter(c => !(c instanceof Separator)), c => c.name);
|
|
112
105
|
const { CI } = process.env;
|
|
113
|
-
|
|
106
|
+
runScript(async () => {
|
|
114
107
|
let cmd = process.argv.find(s => commandMap[s] && !commandMap[s].interactiveOnly);
|
|
115
108
|
if (!cmd) {
|
|
116
109
|
// interactive mode
|
|
117
|
-
|
|
118
|
-
cmd = await
|
|
110
|
+
_assert(!CI, 'interactive dev-lib should not be run in CI');
|
|
111
|
+
cmd = await select({
|
|
119
112
|
message: 'Select command',
|
|
120
113
|
pageSize: 30,
|
|
121
114
|
choices: commands
|
|
122
|
-
.filter(c => c instanceof
|
|
115
|
+
.filter(c => c instanceof Separator || !c.cliOnly)
|
|
123
116
|
.map(c => {
|
|
124
|
-
if (c instanceof
|
|
117
|
+
if (c instanceof Separator)
|
|
125
118
|
return c;
|
|
126
119
|
return {
|
|
127
120
|
value: c.name,
|
|
@@ -133,13 +126,13 @@ const { CI } = process.env;
|
|
|
133
126
|
await commandMap[cmd].fn();
|
|
134
127
|
});
|
|
135
128
|
async function lbt() {
|
|
136
|
-
await
|
|
129
|
+
await lintAllCommand();
|
|
137
130
|
await bt();
|
|
138
131
|
}
|
|
139
132
|
async function bt() {
|
|
140
133
|
await tscAll();
|
|
141
|
-
|
|
134
|
+
runTest();
|
|
142
135
|
}
|
|
143
136
|
async function tscAll() {
|
|
144
|
-
await
|
|
137
|
+
await runTSCInFolders(['.', 'scripts', 'e2e'], ['--noEmit']);
|
|
145
138
|
}
|
package/dist/bin/up.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
(0, nodejs_lib_1.runScript)(async () => {
|
|
7
|
-
(0, yarn_util_1.up)();
|
|
2
|
+
import { runScript } from '@naturalcycles/nodejs-lib';
|
|
3
|
+
import { up } from '../yarn.util.js';
|
|
4
|
+
runScript(async () => {
|
|
5
|
+
up();
|
|
8
6
|
});
|
package/dist/bin/upnc.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
(0, nodejs_lib_1.runScript)(async () => {
|
|
7
|
-
(0, yarn_util_1.upnc)();
|
|
2
|
+
import { runScript } from '@naturalcycles/nodejs-lib';
|
|
3
|
+
import { upnc } from '../yarn.util.js';
|
|
4
|
+
runScript(async () => {
|
|
5
|
+
upnc();
|
|
8
6
|
});
|
package/dist/build.util.d.ts
CHANGED
package/dist/build.util.js
CHANGED
|
@@ -1,71 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.buildProd = buildProd;
|
|
5
|
-
exports.runTSCInFolders = runTSCInFolders;
|
|
6
|
-
exports.runTSCInFolder = runTSCInFolder;
|
|
7
|
-
exports.runTSCProd = runTSCProd;
|
|
8
|
-
exports.buildCopy = buildCopy;
|
|
9
|
-
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
10
|
-
async function buildEsmCjs() {
|
|
11
|
-
// You cannot have a shared `tsconfig.prod.json` because of relative paths for `include`
|
|
12
|
-
const TSCONF_CJS_PATH = `./tsconfig.cjs.prod.json`;
|
|
13
|
-
const TSCONF_ESM_PATH = `./tsconfig.esm.prod.json`;
|
|
14
|
-
const TSCONF_PROD_PATH = `./tsconfig.prod.json`;
|
|
15
|
-
const cjsExists = nodejs_lib_1.fs2.pathExists(TSCONF_CJS_PATH);
|
|
16
|
-
const esmExists = nodejs_lib_1.fs2.pathExists(TSCONF_ESM_PATH);
|
|
17
|
-
// it doesn't delete the dir itself, to prevent IDE jumping
|
|
18
|
-
nodejs_lib_1.fs2.emptyDir('./dist');
|
|
19
|
-
nodejs_lib_1.fs2.emptyDir('./dist-esm');
|
|
20
|
-
buildCopy();
|
|
21
|
-
const cjsPath = cjsExists ? TSCONF_CJS_PATH : TSCONF_PROD_PATH;
|
|
22
|
-
const esmPath = esmExists ? TSCONF_ESM_PATH : TSCONF_PROD_PATH;
|
|
23
|
-
await Promise.all([
|
|
24
|
-
nodejs_lib_1.exec2.spawnAsync('tsc', {
|
|
25
|
-
args: [
|
|
26
|
-
'-P',
|
|
27
|
-
cjsPath,
|
|
28
|
-
'--outDir',
|
|
29
|
-
'./dist',
|
|
30
|
-
'--module',
|
|
31
|
-
'nodenext',
|
|
32
|
-
'--moduleResolution',
|
|
33
|
-
'nodenext',
|
|
34
|
-
'--noEmit',
|
|
35
|
-
'false',
|
|
36
|
-
'--noCheck',
|
|
37
|
-
],
|
|
38
|
-
shell: false,
|
|
39
|
-
}),
|
|
40
|
-
nodejs_lib_1.exec2.spawnAsync('tsc', {
|
|
41
|
-
args: [
|
|
42
|
-
'-P',
|
|
43
|
-
esmPath,
|
|
44
|
-
'--outDir',
|
|
45
|
-
'./dist-esm',
|
|
46
|
-
'--module',
|
|
47
|
-
'esnext',
|
|
48
|
-
'--moduleResolution',
|
|
49
|
-
'bundler',
|
|
50
|
-
'--declaration',
|
|
51
|
-
'false',
|
|
52
|
-
'--noEmit',
|
|
53
|
-
'false',
|
|
54
|
-
'--noCheck',
|
|
55
|
-
],
|
|
56
|
-
shell: false,
|
|
57
|
-
}),
|
|
58
|
-
]);
|
|
59
|
-
}
|
|
60
|
-
async function buildProd() {
|
|
61
|
-
nodejs_lib_1.fs2.emptyDir('./dist'); // it doesn't delete the dir itself, to prevent IDE jumping
|
|
1
|
+
import { exec2, fs2, kpySync } from '@naturalcycles/nodejs-lib';
|
|
2
|
+
export async function buildProd() {
|
|
3
|
+
fs2.emptyDir('./dist'); // it doesn't delete the dir itself, to prevent IDE jumping
|
|
62
4
|
buildCopy();
|
|
63
5
|
await runTSCProd();
|
|
64
6
|
}
|
|
65
7
|
/**
|
|
66
8
|
* Use '.' to indicate root.
|
|
67
9
|
*/
|
|
68
|
-
async function runTSCInFolders(tsconfigPaths, args = [], parallel = true) {
|
|
10
|
+
export async function runTSCInFolders(tsconfigPaths, args = [], parallel = true) {
|
|
69
11
|
if (parallel) {
|
|
70
12
|
await Promise.all(tsconfigPaths.map(p => runTSCInFolder(p, args)));
|
|
71
13
|
}
|
|
@@ -78,24 +20,24 @@ async function runTSCInFolders(tsconfigPaths, args = [], parallel = true) {
|
|
|
78
20
|
/**
|
|
79
21
|
* Pass '.' to run in root.
|
|
80
22
|
*/
|
|
81
|
-
async function runTSCInFolder(tsconfigPath, args = []) {
|
|
82
|
-
if (!
|
|
23
|
+
export async function runTSCInFolder(tsconfigPath, args = []) {
|
|
24
|
+
if (!fs2.pathExists(tsconfigPath)) {
|
|
83
25
|
console.log(`Skipping to run tsc for ${tsconfigPath}, as it doesn't exist`);
|
|
84
26
|
return;
|
|
85
27
|
}
|
|
86
|
-
await
|
|
28
|
+
await exec2.spawnAsync(`tsc`, {
|
|
87
29
|
args: ['-P', tsconfigPath, ...args],
|
|
88
30
|
shell: false,
|
|
89
31
|
});
|
|
90
32
|
}
|
|
91
|
-
async function runTSCProd(args = []) {
|
|
92
|
-
const tsconfigPath = [`./tsconfig.prod.json`].find(p =>
|
|
93
|
-
await
|
|
33
|
+
export async function runTSCProd(args = []) {
|
|
34
|
+
const tsconfigPath = [`./tsconfig.prod.json`].find(p => fs2.pathExists(p)) || 'tsconfig.json';
|
|
35
|
+
await exec2.spawnAsync(`tsc`, {
|
|
94
36
|
args: ['-P', tsconfigPath, '--noEmit', 'false', '--noCheck', ...args],
|
|
95
37
|
shell: false,
|
|
96
38
|
});
|
|
97
39
|
}
|
|
98
|
-
function buildCopy() {
|
|
40
|
+
export function buildCopy() {
|
|
99
41
|
const baseDir = 'src';
|
|
100
42
|
const inputPatterns = [
|
|
101
43
|
'**',
|
|
@@ -106,7 +48,7 @@ function buildCopy() {
|
|
|
106
48
|
'!**/*.test.js',
|
|
107
49
|
];
|
|
108
50
|
const outputDir = 'dist';
|
|
109
|
-
|
|
51
|
+
kpySync({
|
|
110
52
|
baseDir,
|
|
111
53
|
inputPatterns,
|
|
112
54
|
outputDir,
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function initFromDevLibCommand() {
|
|
7
|
-
(0, nodejs_lib_1.kpySync)({
|
|
8
|
-
baseDir: paths_1.cfgOverwriteDir,
|
|
1
|
+
import { kpySync } from '@naturalcycles/nodejs-lib';
|
|
2
|
+
import { cfgOverwriteDir } from './paths.js';
|
|
3
|
+
export function initFromDevLibCommand() {
|
|
4
|
+
kpySync({
|
|
5
|
+
baseDir: cfgOverwriteDir,
|
|
9
6
|
outputDir: './',
|
|
10
7
|
dotfiles: true,
|
|
11
8
|
verbose: true,
|