@naturalcycles/dev-lib 13.27.1 → 13.28.1

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 (42) hide show
  1. package/dist/bin/bt.js +4 -4
  2. package/dist/bin/btl.js +3 -3
  3. package/dist/bin/build.js +3 -3
  4. package/dist/bin/prettier-all.js +2 -2
  5. package/dist/bin/stylelint-all.js +1 -1
  6. package/dist/bin/test-ci.js +1 -1
  7. package/dist/bin/test-integration-ci.js +1 -1
  8. package/dist/bin/test-integration.js +1 -1
  9. package/dist/bin/test-leaks.js +1 -1
  10. package/dist/bin/test-manual.js +1 -1
  11. package/dist/bin/test.js +1 -1
  12. package/dist/cmd/build-prod-esm-cjs.command.js +12 -3
  13. package/dist/cmd/build-prod.command.d.ts +1 -1
  14. package/dist/cmd/build-prod.command.js +2 -2
  15. package/dist/cmd/eslint-all.command.d.ts +1 -1
  16. package/dist/cmd/eslint-all.command.js +4 -4
  17. package/dist/cmd/generate-build-info.command.d.ts +1 -1
  18. package/dist/cmd/generate-build-info.command.js +1 -1
  19. package/dist/cmd/lint-all.command.js +3 -3
  20. package/dist/cmd/tsc-prod.command.d.ts +1 -1
  21. package/dist/cmd/tsc-prod.command.js +3 -3
  22. package/dist/cmd/tsc-scripts.command.d.ts +1 -1
  23. package/dist/cmd/tsc-scripts.command.js +3 -3
  24. package/dist/index.d.ts +1 -2
  25. package/dist/index.js +1 -0
  26. package/dist/util/buildInfo.model.d.ts +15 -5
  27. package/dist/util/buildInfo.util.d.ts +1 -1
  28. package/dist/util/buildInfo.util.js +7 -5
  29. package/dist/util/exec.util.d.ts +4 -0
  30. package/dist/util/exec.util.js +56 -0
  31. package/dist/util/git.util.js +1 -0
  32. package/dist/util/jest.util.d.ts +1 -1
  33. package/dist/util/jest.util.js +5 -5
  34. package/dist/util/lint.util.d.ts +1 -1
  35. package/dist/util/lint.util.js +3 -3
  36. package/dist/util/prettier.util.d.ts +1 -1
  37. package/dist/util/prettier.util.js +3 -3
  38. package/dist/util/stylelint.util.d.ts +1 -1
  39. package/dist/util/stylelint.util.js +3 -3
  40. package/dist/util/tsc.util.d.ts +1 -1
  41. package/dist/util/tsc.util.js +4 -4
  42. package/package.json +1 -1
package/dist/bin/bt.js CHANGED
@@ -6,10 +6,10 @@ const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
6
6
  const tsc_scripts_command_1 = require("../cmd/tsc-scripts.command");
7
7
  const jest_util_1 = require("../util/jest.util");
8
8
  const tsc_util_1 = require("../util/tsc.util");
9
- (0, script_1.runScript)(async () => {
9
+ (0, script_1.runScript)(() => {
10
10
  (0, nodejs_lib_1._emptyDirSync)('./dist'); // it doesn't delete the dir itself, to prevent IDE jumping
11
11
  // fs.rmSync('./dist', { recursive: true, force: true })
12
- await (0, tsc_util_1.tsc)(true);
13
- await (0, tsc_scripts_command_1.tscScriptsCommand)();
14
- await (0, jest_util_1.runJest)();
12
+ (0, tsc_util_1.tsc)(true);
13
+ (0, tsc_scripts_command_1.tscScriptsCommand)();
14
+ (0, jest_util_1.runJest)();
15
15
  });
package/dist/bin/btl.js CHANGED
@@ -11,7 +11,7 @@ const tsc_util_1 = require("../util/tsc.util");
11
11
  await (0, lint_all_command_1.lintAllCommand)();
12
12
  (0, nodejs_lib_1._emptyDirSync)('./dist'); // it doesn't delete the dir itself, to prevent IDE jumping
13
13
  // fs.rmSync('./dist', { recursive: true, force: true })
14
- await (0, tsc_util_1.tsc)(true);
15
- await (0, tsc_scripts_command_1.tscScriptsCommand)();
16
- await (0, jest_util_1.runJest)();
14
+ (0, tsc_util_1.tsc)(true);
15
+ (0, tsc_scripts_command_1.tscScriptsCommand)();
16
+ (0, jest_util_1.runJest)();
17
17
  });
package/dist/bin/build.js CHANGED
@@ -5,9 +5,9 @@ const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
5
5
  const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
6
6
  const tsc_scripts_command_1 = require("../cmd/tsc-scripts.command");
7
7
  const tsc_util_1 = require("../util/tsc.util");
8
- (0, script_1.runScript)(async () => {
8
+ (0, script_1.runScript)(() => {
9
9
  (0, nodejs_lib_1._emptyDirSync)('./dist'); // it doesn't delete the dir itself, to prevent IDE jumping
10
10
  // fs.rmSync('./dist', { recursive: true, force: true })
11
- await (0, tsc_util_1.tsc)(true);
12
- await (0, tsc_scripts_command_1.tscScriptsCommand)();
11
+ (0, tsc_util_1.tsc)(true);
12
+ (0, tsc_scripts_command_1.tscScriptsCommand)();
13
13
  });
@@ -3,6 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
5
5
  const prettier_util_1 = require("../util/prettier.util");
6
- (0, script_1.runScript)(async () => {
7
- await (0, prettier_util_1.runPrettier)();
6
+ (0, script_1.runScript)(() => {
7
+ (0, prettier_util_1.runPrettier)();
8
8
  });
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
5
5
  const stylelint_util_1 = require("../util/stylelint.util");
6
6
  (0, script_1.runScript)(async () => {
7
- await (0, stylelint_util_1.stylelintAll)();
7
+ (0, stylelint_util_1.stylelintAll)();
8
8
  });
@@ -5,5 +5,5 @@ const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
5
5
  const jest_util_1 = require("../util/jest.util");
6
6
  (0, script_1.runScript)(async () => {
7
7
  console.log('! "yarn test-ci" is deprecated, use plain `yarn test` instead !');
8
- await (0, jest_util_1.runJest)();
8
+ (0, jest_util_1.runJest)();
9
9
  });
@@ -5,5 +5,5 @@ const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
5
5
  const jest_util_1 = require("../util/jest.util");
6
6
  (0, script_1.runScript)(async () => {
7
7
  console.log('! "yarn test-integration-ci" is deprecated, use plain `yarn test-integration` instead !');
8
- await (0, jest_util_1.runJest)({ integration: true });
8
+ (0, jest_util_1.runJest)({ integration: true });
9
9
  });
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
5
5
  const jest_util_1 = require("../util/jest.util");
6
6
  (0, script_1.runScript)(async () => {
7
- await (0, jest_util_1.runJest)({ integration: true });
7
+ (0, jest_util_1.runJest)({ integration: true });
8
8
  });
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
5
5
  const jest_util_1 = require("../util/jest.util");
6
6
  (0, script_1.runScript)(async () => {
7
- await (0, jest_util_1.runJest)({ leaks: true });
7
+ (0, jest_util_1.runJest)({ leaks: true });
8
8
  });
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
5
5
  const jest_util_1 = require("../util/jest.util");
6
6
  (0, script_1.runScript)(async () => {
7
- await (0, jest_util_1.runJest)({ manual: true });
7
+ (0, jest_util_1.runJest)({ manual: true });
8
8
  });
package/dist/bin/test.js CHANGED
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const script_1 = require("@naturalcycles/nodejs-lib/dist/script");
5
5
  const jest_util_1 = require("../util/jest.util");
6
6
  (0, script_1.runScript)(async () => {
7
- await (0, jest_util_1.runJest)();
7
+ (0, jest_util_1.runJest)();
8
8
  });
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildProdESMCJSCommand = void 0;
4
4
  const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
5
- const exec_1 = require("@naturalcycles/nodejs-lib/dist/exec");
5
+ const exec_util_1 = require("../util/exec.util");
6
6
  // You cannot have a shared `tsconfig.prod.json` because of relative paths for `include`
7
7
  const TSCONF_CJS_PATH = `./tsconfig.cjs.prod.json`;
8
8
  const TSCONF_ESM_PATH = `./tsconfig.esm.prod.json`;
@@ -20,8 +20,17 @@ async function buildProdESMCJSCommand() {
20
20
  const cjsPath = cjsExists ? TSCONF_CJS_PATH : TSCONF_PATH;
21
21
  const esmPath = esmExists ? TSCONF_ESM_PATH : TSCONF_PATH;
22
22
  await Promise.all([
23
- (0, exec_1.execCommand)(`tsc -P ${cjsPath} --outDir ./dist --module commonjs`),
24
- (0, exec_1.execCommand)(`tsc -P ${esmPath} --outDir ./dist-esm --module esnext --declaration false`),
23
+ (0, exec_util_1.execVoidCommand)('tsc', ['-P', cjsPath, '--outDir', './dist', '--module', 'commonjs']),
24
+ (0, exec_util_1.execVoidCommand)('tsc', [
25
+ '-P',
26
+ esmPath,
27
+ '--outDir',
28
+ './dist-esm',
29
+ '--module',
30
+ 'esnext',
31
+ '--declaration',
32
+ 'false',
33
+ ]),
25
34
  ]);
26
35
  }
27
36
  exports.buildProdESMCJSCommand = buildProdESMCJSCommand;
@@ -1 +1 @@
1
- export declare function buildProdCommand(): Promise<void>;
1
+ export declare function buildProdCommand(): void;
@@ -4,10 +4,10 @@ exports.buildProdCommand = void 0;
4
4
  const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
5
5
  const build_copy_command_1 = require("./build-copy.command");
6
6
  const tsc_prod_command_1 = require("./tsc-prod.command");
7
- async function buildProdCommand() {
7
+ function buildProdCommand() {
8
8
  (0, nodejs_lib_1._emptyDirSync)('./dist'); // it doesn't delete the dir itself, to prevent IDE jumping
9
9
  // fs.rmSync('./dist', { recursive: true, force: true })
10
10
  (0, build_copy_command_1.buildCopyCommand)();
11
- await (0, tsc_prod_command_1.tscProdCommand)();
11
+ (0, tsc_prod_command_1.tscProdCommand)();
12
12
  }
13
13
  exports.buildProdCommand = buildProdCommand;
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Runs `eslint` command for all predefined paths (e.g /src, /scripts, etc).
3
3
  */
4
- export declare function eslintAllCommand(): Promise<void>;
4
+ export declare function eslintAllCommand(): void;
@@ -8,7 +8,7 @@ const lint_util_1 = require("../util/lint.util");
8
8
  /**
9
9
  * Runs `eslint` command for all predefined paths (e.g /src, /scripts, etc).
10
10
  */
11
- async function eslintAllCommand() {
11
+ function eslintAllCommand() {
12
12
  const { ext, fix } = yargs.options({
13
13
  ext: {
14
14
  type: 'string',
@@ -31,10 +31,10 @@ async function eslintAllCommand() {
31
31
  // todo: run on other dirs too, e.g pages, components, layouts
32
32
  // /src
33
33
  // await runESLint(`./src`, eslintConfigPathRoot, tsconfigPath, extensions)
34
- await (0, lint_util_1.runESLint)(`./src`, eslintConfigPathRoot, undefined, extensions, fix);
34
+ (0, lint_util_1.runESLint)(`./src`, eslintConfigPathRoot, undefined, extensions, fix);
35
35
  // /scripts
36
- await (0, lint_util_1.runESLint)(`./scripts`, eslintConfigPathScripts, tsconfigPathScripts, undefined, fix);
36
+ (0, lint_util_1.runESLint)(`./scripts`, eslintConfigPathScripts, tsconfigPathScripts, undefined, fix);
37
37
  // /e2e
38
- await (0, lint_util_1.runESLint)(`./e2e`, eslintConfigPathE2e, tsconfigPathE2e, undefined, fix);
38
+ (0, lint_util_1.runESLint)(`./e2e`, eslintConfigPathE2e, tsconfigPathE2e, undefined, fix);
39
39
  }
40
40
  exports.eslintAllCommand = eslintAllCommand;
@@ -1 +1 @@
1
- export declare function generateBuildInfoCommand(): Promise<void>;
1
+ export declare function generateBuildInfoCommand(): void;
@@ -5,7 +5,7 @@ const fs = require("node:fs");
5
5
  const path = require("node:path");
6
6
  const yargs = require("yargs");
7
7
  const __1 = require("..");
8
- async function generateBuildInfoCommand() {
8
+ function generateBuildInfoCommand() {
9
9
  const { dir } = yargs.options({
10
10
  dir: {
11
11
  type: 'string',
@@ -23,12 +23,12 @@ async function lintAllCommand() {
23
23
  },
24
24
  }).argv;
25
25
  const hadChangesBefore = (0, git_util_1.gitHasUncommittedChanges)();
26
- await (0, eslint_all_command_1.eslintAllCommand)();
26
+ (0, eslint_all_command_1.eslintAllCommand)();
27
27
  if (fs.existsSync(`node_modules/stylelint`) &&
28
28
  fs.existsSync(`node_modules/stylelint-config-standard-scss`)) {
29
- await (0, stylelint_util_1.stylelintAll)();
29
+ (0, stylelint_util_1.stylelintAll)();
30
30
  }
31
- await (0, prettier_util_1.runPrettier)();
31
+ (0, prettier_util_1.runPrettier)();
32
32
  if (fs.existsSync(`node_modules/@naturalcycles/ktlint`)) {
33
33
  const ktlintLib = require('@naturalcycles/ktlint');
34
34
  await ktlintLib.ktlintAll();
@@ -1 +1 @@
1
- export declare function tscProdCommand(): Promise<void>;
1
+ export declare function tscProdCommand(): void;
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tscProdCommand = void 0;
4
4
  const js_lib_1 = require("@naturalcycles/js-lib");
5
5
  const colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
6
- const exec_1 = require("@naturalcycles/nodejs-lib/dist/exec");
7
- async function tscProdCommand() {
6
+ const exec_util_1 = require("../util/exec.util");
7
+ function tscProdCommand() {
8
8
  // You cannot have a shared `tsconfig.prod.json` because of relative paths for `include`
9
9
  const projectTsconfigPath = `./tsconfig.prod.json`;
10
10
  const args = ['-P', projectTsconfigPath];
11
11
  const started = Date.now();
12
- await (0, exec_1.execWithArgs)(`tsc`, args);
12
+ (0, exec_util_1.execVoidCommandSync)(`tsc`, args);
13
13
  console.log(`${(0, colors_1.boldGrey)('tsc prod')} ${(0, colors_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
14
14
  }
15
15
  exports.tscProdCommand = tscProdCommand;
@@ -1 +1 @@
1
- export declare function tscScriptsCommand(): Promise<void>;
1
+ export declare function tscScriptsCommand(): void;
@@ -4,9 +4,9 @@ exports.tscScriptsCommand = void 0;
4
4
  const fs = require("node:fs");
5
5
  const js_lib_1 = require("@naturalcycles/js-lib");
6
6
  const colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
7
- const exec_1 = require("@naturalcycles/nodejs-lib/dist/exec");
7
+ const exec_util_1 = require("../util/exec.util");
8
8
  const tsc_util_1 = require("../util/tsc.util");
9
- async function tscScriptsCommand() {
9
+ function tscScriptsCommand() {
10
10
  if (!fs.existsSync('./scripts')) {
11
11
  // ./scripts folder doesn't exist, skipping
12
12
  return;
@@ -14,7 +14,7 @@ async function tscScriptsCommand() {
14
14
  const projectTsconfigPath = (0, tsc_util_1.ensureProjectTsconfigScripts)();
15
15
  const args = ['-P', projectTsconfigPath, '--noEmit'];
16
16
  const started = Date.now();
17
- await (0, exec_1.execWithArgs)(`tsc`, args);
17
+ (0, exec_util_1.execVoidCommandSync)(`tsc`, args);
18
18
  console.log(`${(0, colors_1.boldGrey)('tsc scripts')} ${(0, colors_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
19
19
  }
20
20
  exports.tscScriptsCommand = tscScriptsCommand;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from './cmd/build-prod.command';
2
- import type { BuildInfo } from './util/buildInfo.model';
2
+ export * from './util/buildInfo.model';
3
3
  export * from './util/buildInfo.util';
4
4
  export * from './util/git.util';
5
- export type { BuildInfo };
package/dist/index.js CHANGED
@@ -2,5 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./cmd/build-prod.command"), exports);
5
+ tslib_1.__exportStar(require("./util/buildInfo.model"), exports);
5
6
  tslib_1.__exportStar(require("./util/buildInfo.util"), exports);
6
7
  tslib_1.__exportStar(require("./util/git.util"), exports);
@@ -1,5 +1,13 @@
1
+ import { UnixTimestampNumber } from '@naturalcycles/js-lib';
1
2
  export interface BuildInfo {
2
- ts: number;
3
+ /**
4
+ * Unix timestamp of when the build was made.
5
+ */
6
+ ts: UnixTimestampNumber;
7
+ /**
8
+ * Unix timestamp of commit ("committer date", not "author date")
9
+ */
10
+ tsCommit: UnixTimestampNumber;
3
11
  /**
4
12
  * Human-readable time of the build. E.g:
5
13
  * 2019-06-21 18:35:19
@@ -11,10 +19,6 @@ export interface BuildInfo {
11
19
  * GIT sha revision (first 7 characters)
12
20
  */
13
21
  rev: string;
14
- /**
15
- * Unix timestamp of commit ("committer date", not "author date")
16
- */
17
- tsCommit: number;
18
22
  /**
19
23
  * "Version string" in the following format:
20
24
  * yyyyMMdd_HHmm_$repoName_$branch_$rev
@@ -27,4 +31,10 @@ export interface BuildInfo {
27
31
  * Build during development.
28
32
  */
29
33
  dev?: boolean;
34
+ /**
35
+ * Build "environment".
36
+ * Normally taken from process.env.APP_ENV
37
+ * Can be undefined.
38
+ */
39
+ env?: string;
30
40
  }
@@ -1,2 +1,2 @@
1
1
  import type { BuildInfo } from './buildInfo.model';
2
- export declare function generateBuildInfo(dev?: boolean): BuildInfo;
2
+ export declare function generateBuildInfo(): BuildInfo;
@@ -3,14 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateBuildInfo = void 0;
4
4
  const js_lib_1 = require("@naturalcycles/js-lib");
5
5
  const git_util_1 = require("./git.util");
6
- function generateBuildInfo(dev = false) {
6
+ function generateBuildInfo() {
7
+ const { APP_ENV } = process.env;
7
8
  const now = (0, js_lib_1.localTime)();
8
9
  const ts = now.unix();
9
10
  const tsStr = now.toPretty();
10
- const rev = dev ? 'devRev' : (0, git_util_1.gitCurrentCommitSha)();
11
- const branchName = dev ? 'devBranch' : (0, git_util_1.gitCurrentBranchName)();
12
- const repoName = dev ? 'devRepo' : (0, git_util_1.gitCurrentRepoName)();
13
- const tsCommit = dev ? now.unix() : (0, git_util_1.gitCurrentCommitTimestamp)();
11
+ const rev = (0, git_util_1.gitCurrentCommitSha)();
12
+ const branchName = (0, git_util_1.gitCurrentBranchName)();
13
+ const repoName = (0, git_util_1.gitCurrentRepoName)();
14
+ const tsCommit = (0, git_util_1.gitCurrentCommitTimestamp)();
14
15
  const ver = [now.toStringCompact(), repoName, branchName, rev].join('_');
15
16
  return {
16
17
  ts,
@@ -20,6 +21,7 @@ function generateBuildInfo(dev = false) {
20
21
  branchName,
21
22
  rev,
22
23
  ver,
24
+ env: APP_ENV,
23
25
  };
24
26
  }
25
27
  exports.generateBuildInfo = generateBuildInfo;
@@ -0,0 +1,4 @@
1
+ /// <reference types="node" />
2
+ import { SpawnOptions } from 'node:child_process';
3
+ export declare function execVoidCommand(cmd: string, args?: string[], opt?: SpawnOptions): Promise<void>;
4
+ export declare function execVoidCommandSync(cmd: string, args?: string[], opt?: SpawnOptions): void;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.execVoidCommandSync = exports.execVoidCommand = void 0;
4
+ const cp = require("node:child_process");
5
+ const colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
6
+ async function execVoidCommand(cmd, args = [], opt = {}) {
7
+ logExec(cmd, args, opt);
8
+ await new Promise(resolve => {
9
+ const p = cp.spawn(cmd, [...args], {
10
+ stdio: 'inherit',
11
+ // shell: true,
12
+ ...opt,
13
+ env: {
14
+ ...process.env,
15
+ ...opt.env,
16
+ },
17
+ });
18
+ p.on('close', code => {
19
+ if (!code)
20
+ return resolve();
21
+ console.log(`${cmd} exited with code ${code}`);
22
+ process.exit(code);
23
+ });
24
+ });
25
+ }
26
+ exports.execVoidCommand = execVoidCommand;
27
+ function execVoidCommandSync(cmd, args = [], opt = {}) {
28
+ logExec(cmd, args, opt);
29
+ const r = cp.spawnSync(cmd, [...args], {
30
+ encoding: 'utf8',
31
+ stdio: 'inherit',
32
+ // shell: true, // removing shell breaks executing `tsc`
33
+ ...opt,
34
+ env: {
35
+ ...process.env,
36
+ ...opt.env,
37
+ },
38
+ });
39
+ if (r.status) {
40
+ console.log(`${cmd} exited with code ${r.status}`);
41
+ process.exit(r.status);
42
+ }
43
+ if (r.error) {
44
+ console.log(r.error);
45
+ process.exit(r.error.errno || 1);
46
+ }
47
+ }
48
+ exports.execVoidCommandSync = execVoidCommandSync;
49
+ function logExec(cmd, args = [], opt = {}) {
50
+ const cmdline = [
51
+ ...Object.entries(opt.env || {}).map(([k, v]) => [k, v].join('=')),
52
+ cmd,
53
+ ...args,
54
+ ].join(' ');
55
+ console.log((0, colors_1.grey)(cmdline));
56
+ }
@@ -103,6 +103,7 @@ function execSync(cmd) {
103
103
  return cp
104
104
  .execSync(cmd, {
105
105
  encoding: 'utf8',
106
+ // stdio: 'inherit', // no, otherwise we don't get the output returned
106
107
  })
107
108
  .trim();
108
109
  }
@@ -13,5 +13,5 @@ interface RunJestOpt {
13
13
  /**
14
14
  * 1. Adds `--silent` if running all tests at once.
15
15
  */
16
- export declare function runJest(opt?: RunJestOpt): Promise<void>;
16
+ export declare function runJest(opt?: RunJestOpt): void;
17
17
  export {};
@@ -5,8 +5,8 @@ const fs = require("node:fs");
5
5
  const os = require("node:os");
6
6
  const js_lib_1 = require("@naturalcycles/js-lib");
7
7
  const colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
8
- const exec_1 = require("@naturalcycles/nodejs-lib/dist/exec");
9
8
  const paths_cnst_1 = require("../cnst/paths.cnst");
9
+ const exec_util_1 = require("./exec.util");
10
10
  const test_util_1 = require("./test.util");
11
11
  function getJestConfigPath() {
12
12
  return fs.existsSync(`./jest.config.js`) ? './jest.config.js' : `${paths_cnst_1.cfgDir}/jest.config.js`;
@@ -37,7 +37,7 @@ exports.isRunningAllTests = isRunningAllTests;
37
37
  /**
38
38
  * 1. Adds `--silent` if running all tests at once.
39
39
  */
40
- async function runJest(opt = {}) {
40
+ function runJest(opt = {}) {
41
41
  if (!(0, test_util_1.nodeModuleExists)('jest')) {
42
42
  console.log((0, colors_1.dimGrey)(`node_modules/${(0, colors_1.white)('jest')} not found, skipping tests`));
43
43
  return;
@@ -127,14 +127,14 @@ async function runJest(opt = {}) {
127
127
  if (JEST_SHARDS) {
128
128
  const totalShards = Number(JEST_SHARDS);
129
129
  const shards = (0, js_lib_1._range)(1, totalShards + 1);
130
- for await (const shard of shards) {
131
- await (0, exec_1.execWithArgs)('jest', (0, js_lib_1._uniq)([...args, `--shard=${shard}/${totalShards}`]), {
130
+ for (const shard of shards) {
131
+ (0, exec_util_1.execVoidCommandSync)('jest', (0, js_lib_1._uniq)([...args, `--shard=${shard}/${totalShards}`]), {
132
132
  env,
133
133
  });
134
134
  }
135
135
  }
136
136
  else {
137
- await (0, exec_1.execWithArgs)('jest', (0, js_lib_1._uniq)(args), {
137
+ (0, exec_util_1.execVoidCommandSync)('jest', (0, js_lib_1._uniq)(args), {
138
138
  env,
139
139
  });
140
140
  }
@@ -1,3 +1,3 @@
1
1
  export declare function getTSConfigPath(): string;
2
2
  export declare function getTSConfigPathScripts(): string;
3
- export declare function runESLint(dir: string, eslintConfigPath: string, tsconfigPath: string | undefined, extensions?: string[], fix?: boolean): Promise<void>;
3
+ export declare function runESLint(dir: string, eslintConfigPath: string, tsconfigPath: string | undefined, extensions?: string[], fix?: boolean): void;
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runESLint = exports.getTSConfigPathScripts = exports.getTSConfigPath = void 0;
4
4
  const fs = require("node:fs");
5
- const exec_1 = require("@naturalcycles/nodejs-lib/dist/exec");
6
5
  const paths_cnst_1 = require("../cnst/paths.cnst");
6
+ const exec_util_1 = require("./exec.util");
7
7
  function getTSConfigPath() {
8
8
  // this is to support "Solution style tsconfig.json" (as used in Angular10, for example)
9
9
  // return [`./tsconfig.base.json`].find(p => fs.existsSync(p)) || `./tsconfig.json`
@@ -14,7 +14,7 @@ function getTSConfigPathScripts() {
14
14
  return [`./scripts/tsconfig.json`].find(p => fs.existsSync(p)) || `${paths_cnst_1.scriptsDir}/tsconfig.json`;
15
15
  }
16
16
  exports.getTSConfigPathScripts = getTSConfigPathScripts;
17
- async function runESLint(dir, eslintConfigPath, tsconfigPath, extensions = ['ts', 'tsx', 'vue'], fix = true) {
17
+ function runESLint(dir, eslintConfigPath, tsconfigPath, extensions = ['ts', 'tsx', 'vue'], fix = true) {
18
18
  if (!fs.existsSync(dir))
19
19
  return; // faster to bail-out like this
20
20
  const args = [
@@ -26,6 +26,6 @@ async function runESLint(dir, eslintConfigPath, tsconfigPath, extensions = ['ts'
26
26
  `--report-unused-disable-directives`,
27
27
  fix ? `--fix` : '',
28
28
  ].filter(Boolean);
29
- await (0, exec_1.execWithArgs)('eslint', args);
29
+ (0, exec_util_1.execVoidCommandSync)('eslint', args);
30
30
  }
31
31
  exports.runESLint = runESLint;
@@ -1 +1 @@
1
- export declare function runPrettier(): Promise<void>;
1
+ export declare function runPrettier(): void;
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runPrettier = void 0;
4
4
  const fs = require("node:fs");
5
- const exec_1 = require("@naturalcycles/nodejs-lib/dist/exec");
6
5
  const paths_cnst_1 = require("../cnst/paths.cnst");
6
+ const exec_util_1 = require("./exec.util");
7
7
  const { prettierDirs, prettierExtensionsAll, lintExclude } = require('../../cfg/_cnst');
8
8
  const prettierPaths = [
9
9
  // Everything inside these folders
@@ -13,11 +13,11 @@ const prettierPaths = [
13
13
  // Exclude
14
14
  ...lintExclude.map((s) => `!${s}`),
15
15
  ];
16
- async function runPrettier() {
16
+ function runPrettier() {
17
17
  // If there's no `prettier.config.js` in target project - pass `./cfg/prettier.config.js`
18
18
  const prettierConfigPath = [`./prettier.config.js`].find(f => fs.existsSync(f)) || `${paths_cnst_1.cfgDir}/prettier.config.js`;
19
19
  // prettier --write 'src/**/*.{js,ts,css,scss,graphql}'
20
20
  const args = [`--write`, `--loglevel=warn`, `--config`, prettierConfigPath, ...prettierPaths];
21
- await (0, exec_1.execWithArgs)('prettier', args);
21
+ (0, exec_util_1.execVoidCommandSync)('prettier', args);
22
22
  }
23
23
  exports.runPrettier = runPrettier;
@@ -1,2 +1,2 @@
1
1
  export declare const stylelintPaths: any[];
2
- export declare function stylelintAll(): Promise<void>;
2
+ export declare function stylelintAll(): void;
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.stylelintAll = exports.stylelintPaths = void 0;
4
4
  const fs = require("node:fs");
5
- const exec_1 = require("@naturalcycles/nodejs-lib/dist/exec");
6
5
  const yargs = require("yargs");
7
6
  const paths_cnst_1 = require("../cnst/paths.cnst");
7
+ const exec_util_1 = require("./exec.util");
8
8
  const { prettierDirs, stylelintExtensions, lintExclude } = require('../../cfg/_cnst');
9
9
  exports.stylelintPaths = [
10
10
  // Everything inside these folders
@@ -12,7 +12,7 @@ exports.stylelintPaths = [
12
12
  // Exclude
13
13
  ...lintExclude.map((s) => `!${s}`),
14
14
  ];
15
- async function stylelintAll() {
15
+ function stylelintAll() {
16
16
  const { fix } = yargs.options({
17
17
  fix: {
18
18
  type: 'boolean',
@@ -27,6 +27,6 @@ async function stylelintAll() {
27
27
  config,
28
28
  ...exports.stylelintPaths,
29
29
  ].filter(Boolean);
30
- await (0, exec_1.execWithArgs)('stylelint', args);
30
+ (0, exec_util_1.execVoidCommandSync)('stylelint', args);
31
31
  }
32
32
  exports.stylelintAll = stylelintAll;
@@ -1,4 +1,4 @@
1
- export declare function tsc(noEmit?: boolean): Promise<void>;
1
+ export declare function tsc(noEmit?: boolean): void;
2
2
  /**
3
3
  * Returns path to /scripts/tsconfig.json
4
4
  */
@@ -4,13 +4,13 @@ exports.ensureProjectTsconfigScripts = exports.tsc = void 0;
4
4
  const fs = require("node:fs");
5
5
  const js_lib_1 = require("@naturalcycles/js-lib");
6
6
  const colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
7
- const exec_1 = require("@naturalcycles/nodejs-lib/dist/exec");
8
7
  const fs_1 = require("@naturalcycles/nodejs-lib/dist/fs");
9
8
  const paths_cnst_1 = require("../cnst/paths.cnst");
10
- async function tsc(noEmit = false) {
9
+ const exec_util_1 = require("./exec.util");
10
+ function tsc(noEmit = false) {
11
11
  const started = Date.now();
12
- const cmd = ['tsc', noEmit && '--noEmit'].filter(Boolean).join(' ');
13
- await (0, exec_1.execCommand)(cmd);
12
+ const args = [noEmit && '--noEmit'].filter(js_lib_1._isTruthy);
13
+ (0, exec_util_1.execVoidCommandSync)('tsc', args);
14
14
  console.log(`${(0, colors_1.boldGrey)('tsc')} ${(0, colors_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
15
15
  }
16
16
  exports.tsc = tsc;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
- "version": "13.27.1",
3
+ "version": "13.28.1",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "tsn-debug": "tsn testScript.ts",