@naturalcycles/dev-lib 17.2.1 → 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.
Files changed (48) hide show
  1. package/cfg/_cnst.d.ts +7 -0
  2. package/cfg/_cnst.js +21 -12
  3. package/cfg/commitlint.config.js +1 -1
  4. package/cfg/eslint-biome-rules.js +1 -1
  5. package/cfg/eslint-prettier-rules.js +1 -1
  6. package/cfg/eslint-rules.js +1 -1
  7. package/cfg/eslint-vue-rules.js +1 -1
  8. package/cfg/eslint.config.js +27 -23
  9. package/cfg/init/commitlint.config.js +4 -2
  10. package/cfg/init/eslint.config.js +5 -4
  11. package/cfg/init/lint-staged.config.js +4 -2
  12. package/cfg/init/prettier.config.js +3 -3
  13. package/cfg/init/{vitest.config.mts → vitest.config.ts} +1 -1
  14. package/cfg/lint-staged.config.js +8 -8
  15. package/cfg/prettier.config.js +1 -1
  16. package/cfg/stylelint.config.js +1 -1
  17. package/cfg/tsconfig.json +3 -2
  18. package/cfg/{vitest.config.mjs → vitest.config.js} +1 -1
  19. package/dist/bin/dev-lib.js +41 -48
  20. package/dist/bin/up.js +4 -6
  21. package/dist/bin/upnc.js +4 -6
  22. package/dist/build.util.d.ts +0 -1
  23. package/dist/build.util.js +12 -70
  24. package/dist/index.js +1 -2
  25. package/dist/init-from-dev-lib.command.js +5 -8
  26. package/dist/lint.util.js +56 -76
  27. package/dist/paths.js +10 -10
  28. package/dist/test.util.js +8 -127
  29. package/dist/testing/index.d.ts +2 -4
  30. package/dist/testing/index.js +5 -7
  31. package/dist/testing/mockAllKindsOfThings.js +3 -7
  32. package/dist/testing/{testOffline.util.js → testOffline.js} +3 -7
  33. package/dist/testing/testing.util.js +7 -11
  34. package/dist/testing/time.js +12 -0
  35. package/dist/yarn.util.js +12 -16
  36. package/package.json +5 -3
  37. package/readme.md +9 -24
  38. package/cfg/eslint-jest-rules.js +0 -14
  39. package/cfg/jest.alphabetic.sequencer.js +0 -13
  40. package/cfg/jest.config.js +0 -139
  41. package/cfg/jest.esbuild.transformer.js +0 -37
  42. package/cfg/jest.integration-test.config.js +0 -41
  43. package/cfg/jest.manual-test.config.js +0 -25
  44. package/dist/testing/time.util.js +0 -18
  45. /package/cfg/{vitest.config.d.mts → vitest.config.d.ts} +0 -0
  46. /package/cfg/{vitestAlphabeticSequencer.mjs → vitestAlphabeticSequencer.js} +0 -0
  47. /package/dist/testing/{testOffline.util.d.ts → testOffline.d.ts} +0 -0
  48. /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
- module.exports = {
2
- prettierDirs: [
3
- 'src,scripts,e2e,docs,cfg,resources,.github,public,static,components,content,layouts,pages,plugins,middleware,store,blocks',
4
- ],
5
- // ts,tsx,css,scss excluded, cause they need to run in special order (overlap between >1 tool):
6
- prettierExtensionsExclusive: 'js,jsx,json,md,graphql,yml,yaml,html',
7
- // everything that prettier supports:
8
- prettierExtensionsAll: 'ts,tsx,cts,mts,css,scss,js,jsx,cjs,mjs,json,md,graphql,yml,yaml,html,vue',
9
- eslintExtensions: 'ts,tsx,cts,mts,vue,html',
10
- stylelintExtensions: 'css,scss',
11
- lintExclude: ['./**/__exclude/**', './**/dist/**', './**/cache/**', './CHANGELOG.md'],
12
- minActionlintVersion: '1.7.4',
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
  }
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  extends: ['@commitlint/config-conventional'],
3
3
  rules: {
4
4
  // Overriding to allow 'start-case', 'upper-case', 'sentense-case', 'pascal-case'
@@ -1,5 +1,5 @@
1
1
  // Copy-pasted from https://github.com/SrBrahma/eslint-config-biome/blob/main/index.js
2
- module.exports = {
2
+ export default {
3
3
  rules: {
4
4
  'constructor-super': 0,
5
5
  'default-case-last': 0,
@@ -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
- module.exports = {
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
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  rules: {
3
3
  '@typescript-eslint/adjacent-overload-signatures': 2,
4
4
  '@typescript-eslint/ban-ts-comment': 0,
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  rules: {
3
3
  // non-default vue rules
4
4
  'vue/block-order': [
@@ -4,19 +4,23 @@
4
4
  * Shared eslint FLAT config.
5
5
  */
6
6
 
7
- const globals = require('globals')
8
- const eslint = require('@eslint/js')
9
- const tseslint = require('typescript-eslint')
10
-
11
- // detect if jest is installed
12
- const fs = require('node:fs')
13
- const hasJest =
14
- fs.existsSync('./node_modules/jest') && fs.existsSync('./node_modules/eslint-plugin-jest')
15
- // console.log({ hasJest })
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
- module.exports = [
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
- ...require('eslint-plugin-unicorn').default.configs.recommended,
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
- ...require('eslint-plugin-vue').configs['flat/recommended'].map(c => ({
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': require('eslint-plugin-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': require('eslint-plugin-simple-import-sort'),
61
- jsdoc: require('eslint-plugin-jsdoc'),
62
- '@stylistic': require('@stylistic/eslint-plugin'),
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
- ...require('./eslint-rules').rules,
86
- ...require('./eslint-vue-rules').rules,
87
- ...(hasJest ? require('./eslint-jest-rules').rules : {}),
88
- ...require('./eslint-prettier-rules').rules, // disable eslint rules already covered by prettier
89
- ...require('./eslint-biome-rules').rules, // disable eslint rules already covered by biome
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,3 +1,5 @@
1
- module.exports = {
2
- ...require('@naturalcycles/dev-lib/cfg/commitlint.config'),
1
+ import sharedConfig from '@naturalcycles/dev-lib/cfg/commitlint.config.js'
2
+
3
+ export default {
4
+ ...sharedConfig,
3
5
  }
@@ -1,4 +1,5 @@
1
- // prettier-ignore
2
- module.exports = [
3
- ...require('@naturalcycles/dev-lib/cfg/eslint.config'),
4
- ]
1
+ import sharedConfig from '@naturalcycles/dev-lib/cfg/eslint.config.js'
2
+
3
+ export default {
4
+ ...sharedConfig,
5
+ }
@@ -1,3 +1,5 @@
1
- module.exports = {
2
- ...require('@naturalcycles/dev-lib/cfg/lint-staged.config'),
1
+ import sharedConfig from '@naturalcycles/dev-lib/cfg/lint-staged.config.js'
2
+
3
+ export default {
4
+ ...sharedConfig,
3
5
  }
@@ -1,3 +1,3 @@
1
- module.exports = {
2
- ...require('@naturalcycles/dev-lib/cfg/prettier.config'),
3
- }
1
+ import sharedConfig from '@naturalcycles/dev-lib/cfg/prettier.config.js'
2
+
3
+ export default sharedConfig
@@ -1,5 +1,5 @@
1
1
  import { defineConfig } from 'vitest/config'
2
- import { sharedConfig } from '@naturalcycles/dev-lib/cfg/vitest.config.mjs'
2
+ import { sharedConfig } from '@naturalcycles/dev-lib/cfg/vitest.config.js'
3
3
 
4
4
  export default defineConfig({
5
5
  test: {
@@ -12,20 +12,20 @@ const {
12
12
 
13
13
  console.log(`lint-staged.config.js runs on node ${node} ${platform} ${arch}`)
14
14
 
15
- const fs = require('node:fs')
16
- const micromatch = require('micromatch')
17
- const { execSync } = require('node:child_process')
18
- const { _assert, semver2 } = require('@naturalcycles/js-lib')
19
- const { exec2 } = require('@naturalcycles/nodejs-lib')
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
- const {
21
+ import {
22
22
  prettierDirs,
23
23
  prettierExtensionsExclusive,
24
24
  prettierExtensionsAll,
25
25
  stylelintExtensions,
26
26
  lintExclude,
27
27
  minActionlintVersion,
28
- } = require('./_cnst')
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
- module.exports = linters
224
+ export default linters
@@ -3,7 +3,7 @@
3
3
  * Extendable.
4
4
  */
5
5
 
6
- module.exports = {
6
+ export default {
7
7
  printWidth: 100,
8
8
  tabWidth: 2,
9
9
  useTabs: false,
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  extends: ['stylelint-config-standard-scss'],
3
3
  rules: {
4
4
  'no-empty-source': null,
package/cfg/tsconfig.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "outDir": "${configDir}/dist",
11
11
 
12
12
  // Target/module
13
- "target": "es2022", // todo: es2023 when all consumers are on ts5.6+
13
+ "target": "es2023",
14
14
  "lib": ["esnext"], // add "dom" if needed
15
15
  // module `nodenext` is a modern mode that auto-detects cjs/esm
16
16
  // it also defaults `esModuleInterop` and `allowSyntheticDefaultImports` to true
@@ -32,7 +32,7 @@
32
32
  // Otherwise since es2022 it defaults to true
33
33
  // and starts to produce different/unexpected behavior
34
34
  // https://angular.schule/blog/2022-11-use-define-for-class-fields
35
- "useDefineForClassFields": false,
35
+ "useDefineForClassFields": true,
36
36
  "importHelpers": true,
37
37
 
38
38
  // Strictness
@@ -42,6 +42,7 @@
42
42
  "resolveJsonModule": true,
43
43
  "noImplicitOverride": true,
44
44
  "noUncheckedIndexedAccess": true,
45
+ "noUncheckedSideEffectImports": true,
45
46
  "noPropertyAccessFromIndexSignature": true,
46
47
 
47
48
  // todo: monitor if we should have it default or not
@@ -1,6 +1,6 @@
1
1
  import fs from 'node:fs'
2
2
 
3
- import { VitestAlphabeticSequencer } from './vitestAlphabeticSequencer.mjs'
3
+ import { VitestAlphabeticSequencer } from './vitestAlphabeticSequencer.js'
4
4
  const runsInIDE = doesItRunInIDE()
5
5
  const testType = getTestType(runsInIDE)
6
6
  const silent = shouldBeSilent(runsInIDE)
@@ -1,15 +1,13 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const prompts_1 = require("@inquirer/prompts");
5
- const js_lib_1 = require("@naturalcycles/js-lib");
6
- const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
7
- const build_util_1 = require("../build.util");
8
- const lint_util_1 = require("../lint.util");
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 prompts_1.Separator(), // build
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: build_util_1.buildProd,
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: build_util_1.buildCopy,
25
+ fn: buildCopy,
28
26
  desc: 'Copy the non-ts files from ./src to ./dist',
29
27
  },
30
- {
31
- name: 'build-esm-cjs',
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: () => (0, test_util_1.runTest)({ integration: true }),
40
- desc: 'Run vitest/jest for *.integration.test.ts files.',
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: () => (0, test_util_1.runTest)({ manual: true }),
45
- desc: 'Run vitest/jest for *.manual.test.ts files.',
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: () => (0, test_util_1.runTest)({ leaks: true }),
50
- desc: 'Run vitest/jest --detectLeaks for *.test.ts files.',
42
+ fn: () => runTest({ leaks: true }),
43
+ desc: 'Run vitest --detectLeaks for *.test.ts files.',
51
44
  },
52
- new prompts_1.Separator(), // lint
45
+ new Separator(), // lint
53
46
  {
54
47
  name: 'lint',
55
- fn: lint_util_1.lintAllCommand,
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: lint_util_1.lintStagedCommand,
53
+ fn: lintStagedCommand,
61
54
  desc: 'Run "lint-staged", which runs linter on git staged files.',
62
55
  },
63
- { name: 'eslint', fn: lint_util_1.eslintAll, desc: 'Run eslint on all files.' },
56
+ { name: 'eslint', fn: eslintAll, desc: 'Run eslint on all files.' },
64
57
  {
65
58
  name: 'eslint --no-fix',
66
- fn: async () => await (0, lint_util_1.eslintAll)({ fix: false }),
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: () => (0, lint_util_1.runBiome)(),
65
+ fn: () => runBiome(),
73
66
  desc: 'Run biome linter on all files.',
74
67
  },
75
68
  {
76
69
  name: 'biome --no-fix',
77
- fn: () => (0, lint_util_1.runBiome)(false),
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: lint_util_1.runPrettier, desc: 'Run prettier on all files.' },
82
- { name: 'stylelint', fn: lint_util_1.stylelintAll, desc: 'Run stylelint on all files.' },
83
- { name: 'commitlint', fn: lint_util_1.runCommitlintCommand, desc: 'Run commitlint.', cliOnly: true },
84
- new prompts_1.Separator(), // yarn
85
- { name: 'up', fn: yarn_util_1.up, desc: 'Shortcut for "yarn upgrade". Also runs yarn-deduplicate.' },
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: yarn_util_1.upnc,
81
+ fn: upnc,
89
82
  desc: 'Shortcut for "yarn upgrade --pattern @naturalcycles". Also runs yarn-deduplicate.',
90
83
  },
91
- new prompts_1.Separator(), // interactive-only
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 = (0, js_lib_1._by)(commands.filter(c => !(c instanceof prompts_1.Separator)), c => c.name);
104
+ const commandMap = _by(commands.filter(c => !(c instanceof Separator)), c => c.name);
112
105
  const { CI } = process.env;
113
- (0, nodejs_lib_1.runScript)(async () => {
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
- (0, js_lib_1._assert)(!CI, 'interactive dev-lib should not be run in CI');
118
- cmd = await (0, prompts_1.select)({
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 prompts_1.Separator || !c.cliOnly)
115
+ .filter(c => c instanceof Separator || !c.cliOnly)
123
116
  .map(c => {
124
- if (c instanceof prompts_1.Separator)
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 (0, lint_util_1.lintAllCommand)();
129
+ await lintAllCommand();
137
130
  await bt();
138
131
  }
139
132
  async function bt() {
140
133
  await tscAll();
141
- (0, test_util_1.runTest)();
134
+ runTest();
142
135
  }
143
136
  async function tscAll() {
144
- await (0, build_util_1.runTSCInFolders)(['.', 'scripts', 'e2e'], ['--noEmit']);
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
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
5
- const yarn_util_1 = require("../yarn.util");
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
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
5
- const yarn_util_1 = require("../yarn.util");
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
  });
@@ -1,4 +1,3 @@
1
- export declare function buildEsmCjs(): Promise<void>;
2
1
  export declare function buildProd(): Promise<void>;
3
2
  /**
4
3
  * Use '.' to indicate root.
@@ -1,71 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildEsmCjs = buildEsmCjs;
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 (!nodejs_lib_1.fs2.pathExists(tsconfigPath)) {
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 nodejs_lib_1.exec2.spawnAsync(`tsc`, {
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 => nodejs_lib_1.fs2.pathExists(p)) || 'tsconfig.json';
93
- await nodejs_lib_1.exec2.spawnAsync(`tsc`, {
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
- (0, nodejs_lib_1.kpySync)({
51
+ kpySync({
110
52
  baseDir,
111
53
  inputPatterns,
112
54
  outputDir,
package/dist/index.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};