@naturalcycles/dev-lib 19.0.2 → 19.1.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/dist/bin/dev-lib.js +23 -3
- package/dist/build.util.js +5 -2
- package/dist/lint.util.d.ts +1 -0
- package/dist/lint.util.js +4 -4
- package/package.json +3 -2
package/dist/bin/dev-lib.js
CHANGED
|
@@ -8,13 +8,25 @@ import { runTest } from '../test.util.js';
|
|
|
8
8
|
import { up, upnc } from '../yarn.util.js';
|
|
9
9
|
const commands = [
|
|
10
10
|
new Separator(), // build
|
|
11
|
+
{
|
|
12
|
+
name: 'typecheck',
|
|
13
|
+
fn: typecheck,
|
|
14
|
+
desc: 'Run typecheck (tsc) in folders (src, scripts, e2e) if there is tsconfig.json present',
|
|
15
|
+
},
|
|
11
16
|
{
|
|
12
17
|
name: 'tsc',
|
|
13
18
|
fn: tscAll,
|
|
14
19
|
desc: 'Run tsc in folders (src, scripts, e2e) if there is tsconfig.json present',
|
|
20
|
+
deprecated: true,
|
|
21
|
+
},
|
|
22
|
+
{ name: 'bt', fn: bt, desc: 'Build & Test: run "typecheck" (tsc) and then "test".' },
|
|
23
|
+
{ name: 'check', fn: lbt, desc: '"Run all possible checks": lint, typecheck, then test.' },
|
|
24
|
+
{
|
|
25
|
+
name: 'lbt',
|
|
26
|
+
fn: lbtDeprecated,
|
|
27
|
+
desc: 'Lint/Build/Test: run "lint", then "tsc", then "test".',
|
|
28
|
+
deprecated: true,
|
|
15
29
|
},
|
|
16
|
-
{ name: 'bt', fn: bt, desc: 'Build & Test: run "tsc" and then "test".' },
|
|
17
|
-
{ name: 'lbt', fn: lbt, desc: 'Lint/Build/Test: run "lint", then "tsc", then "test".' },
|
|
18
30
|
{
|
|
19
31
|
name: 'build',
|
|
20
32
|
fn: buildProd,
|
|
@@ -133,6 +145,14 @@ async function bt() {
|
|
|
133
145
|
await tscAll();
|
|
134
146
|
runTest();
|
|
135
147
|
}
|
|
136
|
-
async function
|
|
148
|
+
async function typecheck() {
|
|
137
149
|
await runTSCInFolders(['.', 'scripts', 'e2e'], ['--noEmit']);
|
|
138
150
|
}
|
|
151
|
+
async function tscAll() {
|
|
152
|
+
console.log(`"dev-lib tsc" is deprecated, use "dev-lib typecheck" instead`);
|
|
153
|
+
await typecheck();
|
|
154
|
+
}
|
|
155
|
+
async function lbtDeprecated() {
|
|
156
|
+
console.log(`"dev-lib lbt" is deprecated, use "dev-lib check" instead`);
|
|
157
|
+
await lbt();
|
|
158
|
+
}
|
package/dist/build.util.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { exec2, fs2, kpySync } from '@naturalcycles/nodejs-lib';
|
|
2
|
+
import { findPackageBinPath } from './lint.util.js';
|
|
2
3
|
export async function buildProd() {
|
|
3
4
|
fs2.emptyDir('./dist'); // it doesn't delete the dir itself, to prevent IDE jumping
|
|
4
5
|
buildCopy();
|
|
@@ -25,14 +26,16 @@ export async function runTSCInFolder(tsconfigPath, args = []) {
|
|
|
25
26
|
// console.log(`Skipping to run tsc for ${tsconfigPath}, as it doesn't exist`)
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
+
const tscPath = findPackageBinPath('typescript', 'tsc');
|
|
30
|
+
await exec2.spawnAsync(tscPath, {
|
|
29
31
|
args: ['-P', tsconfigPath, ...args],
|
|
30
32
|
shell: false,
|
|
31
33
|
});
|
|
32
34
|
}
|
|
33
35
|
export async function runTSCProd(args = []) {
|
|
34
36
|
const tsconfigPath = [`./tsconfig.prod.json`].find(p => fs2.pathExists(p)) || 'tsconfig.json';
|
|
35
|
-
|
|
37
|
+
const tscPath = findPackageBinPath('typescript', 'tsc');
|
|
38
|
+
await exec2.spawnAsync(tscPath, {
|
|
36
39
|
args: ['-P', tsconfigPath, '--noEmit', 'false', '--noCheck', ...args],
|
|
37
40
|
shell: false,
|
|
38
41
|
});
|
package/dist/lint.util.d.ts
CHANGED
|
@@ -18,4 +18,5 @@ export declare function runCommitlintCommand(): void;
|
|
|
18
18
|
export declare function requireActionlintVersion(): void;
|
|
19
19
|
export declare function getActionLintVersion(): SemVerString | undefined;
|
|
20
20
|
export declare function runBiome(fix?: boolean): void;
|
|
21
|
+
export declare function findPackageBinPath(pkg: string, cmd: string): string;
|
|
21
22
|
export {};
|
package/dist/lint.util.js
CHANGED
|
@@ -195,9 +195,9 @@ export function runCommitlintCommand() {
|
|
|
195
195
|
async function runKTLint() {
|
|
196
196
|
if (!existsSync(`node_modules/@naturalcycles/ktlint`))
|
|
197
197
|
return;
|
|
198
|
-
// @ts-expect-error ktlint is not installed, but it's ok
|
|
199
|
-
const {
|
|
200
|
-
await
|
|
198
|
+
// @ts-expect-error ktlint is not installed (due to size in node_modules), but it's ok
|
|
199
|
+
const { ktlintAll } = await import('@naturalcycles/ktlint');
|
|
200
|
+
await ktlintAll();
|
|
201
201
|
}
|
|
202
202
|
function runActionLint() {
|
|
203
203
|
// Only run if there is a folder of `.github/workflows`, otherwise actionlint will fail
|
|
@@ -261,7 +261,7 @@ function gitStatus() {
|
|
|
261
261
|
catch { }
|
|
262
262
|
}
|
|
263
263
|
const require = createRequire(import.meta.url);
|
|
264
|
-
function findPackageBinPath(pkg, cmd) {
|
|
264
|
+
export function findPackageBinPath(pkg, cmd) {
|
|
265
265
|
const packageJsonPath = require.resolve(`${pkg}/package.json`);
|
|
266
266
|
const { bin } = fs2.readJson(packageJsonPath);
|
|
267
267
|
return path.join(path.dirname(packageJsonPath), typeof bin === 'string' ? bin : bin[cmd]);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/dev-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "19.0
|
|
4
|
+
"version": "19.1.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@commitlint/cli": "^19",
|
|
7
7
|
"@commitlint/config-conventional": "^19",
|
|
@@ -78,7 +78,8 @@
|
|
|
78
78
|
"tsx-debug": "tsx scripts/testScript.ts",
|
|
79
79
|
"dev-lib": "tsx ./src/bin/dev-lib.ts",
|
|
80
80
|
"bt": "tsx ./src/bin/dev-lib.ts bt && tsx scripts/eslintPrintConfig.script.ts",
|
|
81
|
-
"
|
|
81
|
+
"check": "tsx ./src/bin/dev-lib.ts check && tsx scripts/eslintPrintConfig.script.ts",
|
|
82
|
+
"typecheck": "tsx ./src/bin/dev-lib.ts typecheck",
|
|
82
83
|
"build": "tsx ./src/bin/dev-lib.ts build",
|
|
83
84
|
"test": "tsx ./src/bin/dev-lib.ts test",
|
|
84
85
|
"test-leaks": "tsx ./src/bin/dev-lib.ts test-leaks",
|