@naturalcycles/dev-lib 19.0.3 → 19.2.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.
@@ -1,20 +1,31 @@
1
1
  #!/usr/bin/env node
2
2
  import { select, Separator } from '@inquirer/prompts';
3
3
  import { _assert, _by } from '@naturalcycles/js-lib';
4
- import { runScript } from '@naturalcycles/nodejs-lib';
4
+ import { fs2, runScript } from '@naturalcycles/nodejs-lib';
5
5
  import { buildCopy, buildProd, runTSCInFolders } from '../build.util.js';
6
6
  import { eslintAll, lintAllCommand, lintStagedCommand, runBiome, runCommitlintCommand, runPrettier, stylelintAll, } from '../lint.util.js';
7
7
  import { runTest } from '../test.util.js';
8
- import { up, upnc } from '../yarn.util.js';
9
8
  const commands = [
10
9
  new Separator(), // build
10
+ {
11
+ name: 'typecheck',
12
+ fn: typecheck,
13
+ desc: 'Run typecheck (tsc) in folders (src, scripts, e2e) if there is tsconfig.json present',
14
+ },
11
15
  {
12
16
  name: 'tsc',
13
17
  fn: tscAll,
14
18
  desc: 'Run tsc in folders (src, scripts, e2e) if there is tsconfig.json present',
19
+ deprecated: true,
20
+ },
21
+ { name: 'bt', fn: bt, desc: 'Build & Test: run "typecheck" (tsc) and then "test".' },
22
+ { name: 'check', fn: lbt, desc: '"Run all possible checks": lint, typecheck, then test.' },
23
+ {
24
+ name: 'lbt',
25
+ fn: lbtDeprecated,
26
+ desc: 'Lint/Build/Test: run "lint", then "tsc", then "test".',
27
+ deprecated: true,
15
28
  },
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
29
  {
19
30
  name: 'build',
20
31
  fn: buildProd,
@@ -25,6 +36,11 @@ const commands = [
25
36
  fn: buildCopy,
26
37
  desc: 'Copy the non-ts files from ./src to ./dist',
27
38
  },
39
+ {
40
+ name: 'clean',
41
+ fn: cleanDist,
42
+ desc: 'Clean ./dist',
43
+ },
28
44
  new Separator(), // test
29
45
  { name: 'test', fn: runTest, desc: 'Run vitest for *.test.ts files.' },
30
46
  {
@@ -74,13 +90,6 @@ const commands = [
74
90
  { name: 'prettier', fn: runPrettier, desc: 'Run prettier on all files.' },
75
91
  { name: 'stylelint', fn: stylelintAll, desc: 'Run stylelint on all files.' },
76
92
  { 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.' },
79
- {
80
- name: 'upnc',
81
- fn: upnc,
82
- desc: 'Shortcut for "yarn upgrade --pattern @naturalcycles". Also runs yarn-deduplicate.',
83
- },
84
93
  new Separator(), // interactive-only
85
94
  {
86
95
  name: 'exit',
@@ -133,6 +142,17 @@ async function bt() {
133
142
  await tscAll();
134
143
  runTest();
135
144
  }
136
- async function tscAll() {
145
+ async function typecheck() {
137
146
  await runTSCInFolders(['.', 'scripts', 'e2e'], ['--noEmit']);
138
147
  }
148
+ async function tscAll() {
149
+ console.log(`"dev-lib tsc" is deprecated, use "dev-lib typecheck" instead`);
150
+ await typecheck();
151
+ }
152
+ async function lbtDeprecated() {
153
+ console.log(`"dev-lib lbt" is deprecated, use "dev-lib check" instead`);
154
+ await lbt();
155
+ }
156
+ async function cleanDist() {
157
+ fs2.emptyDir('./dist'); // it doesn't delete the dir itself, to prevent IDE jumping
158
+ }
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 { default: ktlintLib } = await import('@naturalcycles/ktlint');
200
- await ktlintLib.ktlintAll();
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
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
3
  "type": "module",
4
- "version": "19.0.3",
4
+ "version": "19.2.0",
5
5
  "dependencies": {
6
6
  "@commitlint/cli": "^19",
7
7
  "@commitlint/config-conventional": "^19",
@@ -55,9 +55,7 @@
55
55
  "main": "dist/index.js",
56
56
  "types": "dist/index.d.ts",
57
57
  "bin": {
58
- "dev-lib": "dist/bin/dev-lib.js",
59
- "up": "dist/bin/up.js",
60
- "upnc": "dist/bin/upnc.js"
58
+ "dev-lib": "dist/bin/dev-lib.js"
61
59
  },
62
60
  "engines": {
63
61
  "node": ">=22.12.0"
@@ -78,15 +76,15 @@
78
76
  "tsx-debug": "tsx scripts/testScript.ts",
79
77
  "dev-lib": "tsx ./src/bin/dev-lib.ts",
80
78
  "bt": "tsx ./src/bin/dev-lib.ts bt && tsx scripts/eslintPrintConfig.script.ts",
81
- "lbt": "tsx ./src/bin/dev-lib.ts lbt && tsx scripts/eslintPrintConfig.script.ts",
79
+ "check": "tsx ./src/bin/dev-lib.ts check && tsx scripts/eslintPrintConfig.script.ts",
80
+ "typecheck": "tsx ./src/bin/dev-lib.ts typecheck",
81
+ "clean": "tsx ./src/bin/dev-lib.ts clean",
82
82
  "build": "tsx ./src/bin/dev-lib.ts build",
83
83
  "test": "tsx ./src/bin/dev-lib.ts test",
84
84
  "test-leaks": "tsx ./src/bin/dev-lib.ts test-leaks",
85
85
  "test-integration": "tsx ./src/bin/dev-lib.ts test-integration",
86
86
  "test-manual": "tsx ./src/bin/dev-lib.ts test-manual",
87
87
  "lint": "tsx ./src/bin/dev-lib.ts lint",
88
- "lint-staged-debug": "tsx ./src/bin/dev-lib.ts lint-staged",
89
- "up": "tsx ./src/bin/up.ts",
90
- "upnc": "tsx ./src/bin/upnc.ts"
88
+ "lint-staged-debug": "tsx ./src/bin/dev-lib.ts lint-staged"
91
89
  }
92
90
  }
package/readme.md CHANGED
@@ -87,10 +87,8 @@ These commands are available to be called as `yarn dev-lib <command>`.
87
87
 
88
88
  - `build`: "Production build". Does `del ./dist && build-copy && tsc-prod`
89
89
  - `bt`: "Build & Test". Does `del ./dist && tsc && tsc-scripts && test`
90
- - `lbt`: "Lint, Build & Test". Does `lint && tsc && test`
91
- - `build-esm-cjs`: "Production build" for browser-lib, will produce CJS output in `./dist` and ESM
92
- output in `./dist-esm`. Will use `./tsconfig.{cjs|esm}.prod.json` if exists, otherwise
93
- `tsconfig.prod.json`, which allows to override e.g compilation target.
90
+ - `typecheck`: Runs `tsc` in all folders (src, scripts, e2e).
91
+ - `check`: "Lint, Build & Test". Does `lint && typecheck && test`
94
92
 
95
93
  #### Test commands
96
94
 
package/dist/bin/up.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/dist/bin/up.js DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import { runScript } from '@naturalcycles/nodejs-lib';
3
- import { up } from '../yarn.util.js';
4
- runScript(async () => {
5
- up();
6
- });
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/dist/bin/upnc.js DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import { runScript } from '@naturalcycles/nodejs-lib';
3
- import { upnc } from '../yarn.util.js';
4
- runScript(async () => {
5
- upnc();
6
- });
@@ -1,2 +0,0 @@
1
- export declare function up(): void;
2
- export declare function upnc(): void;
package/dist/yarn.util.js DELETED
@@ -1,15 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import { exec2 } from '@naturalcycles/nodejs-lib';
3
- export function up() {
4
- exec2.spawn('yarn upgrade');
5
- exec2.spawn('yarn-deduplicate');
6
- exec2.spawn('yarn');
7
- if (existsSync(`node_modules/patch-package`)) {
8
- exec2.spawn('patch-package');
9
- }
10
- }
11
- export function upnc() {
12
- exec2.spawn('yarn upgrade --pattern @naturalcycles');
13
- exec2.spawn('yarn-deduplicate');
14
- exec2.spawn('yarn');
15
- }