@naturalcycles/dev-lib 13.42.1 → 13.43.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.js CHANGED
@@ -7,5 +7,10 @@ module.exports = {
7
7
  // everything that prettier supports:
8
8
  prettierExtensionsAll: 'ts,tsx,css,scss,js,jsx,json,md,graphql,yml,yaml,html,vue',
9
9
  stylelintExtensions: 'css,scss',
10
- lintExclude: ['./**/__exclude/**', './docs/.vuepress/dist/**', './CHANGELOG.md'],
10
+ lintExclude: [
11
+ './**/__exclude/**',
12
+ './docs/.vitepress/dist/**',
13
+ './docs/.vitepress/cache/**',
14
+ './CHANGELOG.md',
15
+ ],
11
16
  }
@@ -31,7 +31,11 @@ const eslintConfigPathRoot =
31
31
 
32
32
  const prettierCmd = `prettier --write --config ${prettierConfigPath}`
33
33
  const eslintCmd = `eslint --fix`
34
- const styleLintCmd = `stylelint --fix --config ${stylelintConfigPath}`
34
+
35
+ const stylelintExists =
36
+ fs.existsSync('node_modules/stylelint') &&
37
+ fs.existsSync('node_modules/stylelint-config-standard-scss')
38
+ const stylelintCmd = stylelintExists ? `stylelint --fix --config ${stylelintConfigPath}` : undefined
35
39
 
36
40
  const linters = {
37
41
  // *.{ts,tsx,vue} files: eslint, prettier
@@ -64,7 +68,7 @@ const linters = {
64
68
  [`./{${prettierDirs}}/**/*.{${stylelintExtensions}}`]: match => {
65
69
  const filesList = micromatch.not(match, lintExclude).join(' ')
66
70
  if (!filesList) return []
67
- return [styleLintCmd, prettierCmd].map(s => `${s} ${filesList}`)
71
+ return [stylelintCmd, prettierCmd].filter(Boolean).map(s => `${s} ${filesList}`)
68
72
  },
69
73
 
70
74
  // Files in root dir
@@ -25,14 +25,6 @@ async function lintAllCommand() {
25
25
  default: false,
26
26
  },
27
27
  }).argv;
28
- if (canRunBinary('actionlint')) {
29
- const st = Date.now();
30
- (0, nodejs_lib_1.execVoidCommandSync)(`actionlint`);
31
- console.log(`${(0, nodejs_lib_1.boldGrey)('actionlint')} ${(0, nodejs_lib_1.dimGrey)(`took ` + (0, js_lib_1._since)(st))}`);
32
- }
33
- else {
34
- console.log(`actionlint is not installed and won't be run.\nThis is how to install it: https://github.com/rhysd/actionlint/blob/main/docs/install.md`);
35
- }
36
28
  const hadChangesBefore = (0, nodejs_lib_1.gitHasUncommittedChanges)();
37
29
  // We run eslint BEFORE Prettier, because eslint can delete e.g unused imports.
38
30
  await (0, eslint_all_command_1.eslintAllCommand)();
@@ -41,10 +33,8 @@ async function lintAllCommand() {
41
33
  (0, stylelint_util_1.stylelintAll)();
42
34
  }
43
35
  (0, prettier_util_1.runPrettier)();
44
- if (node_fs_1.default.existsSync(`node_modules/@naturalcycles/ktlint`)) {
45
- const ktlintLib = require('@naturalcycles/ktlint');
46
- await ktlintLib.ktlintAll();
47
- }
36
+ runActionLint();
37
+ await runKTLint();
48
38
  console.log(`${(0, nodejs_lib_1.boldGrey)('lint-all')} ${(0, nodejs_lib_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
49
39
  if (commitOnChanges || failOnChanges) {
50
40
  // detect changes
@@ -69,6 +59,22 @@ async function lintAllCommand() {
69
59
  }
70
60
  }
71
61
  exports.lintAllCommand = lintAllCommand;
62
+ async function runKTLint() {
63
+ if (node_fs_1.default.existsSync(`node_modules/@naturalcycles/ktlint`)) {
64
+ const ktlintLib = require('@naturalcycles/ktlint');
65
+ await ktlintLib.ktlintAll();
66
+ }
67
+ }
68
+ function runActionLint() {
69
+ if (canRunBinary('actionlint')) {
70
+ const started = Date.now();
71
+ (0, nodejs_lib_1.execVoidCommandSync)(`actionlint`);
72
+ console.log(`${(0, nodejs_lib_1.boldGrey)('actionlint')} ${(0, nodejs_lib_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
73
+ }
74
+ else {
75
+ console.log(`actionlint is not installed and won't be run.\nThis is how to install it: https://github.com/rhysd/actionlint/blob/main/docs/install.md`);
76
+ }
77
+ }
72
78
  function canRunBinary(name) {
73
79
  try {
74
80
  (0, node_child_process_1.execSync)(`which ${name}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/dev-lib",
3
- "version": "13.42.1",
3
+ "version": "13.43.0",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "tsn-debug": "tsn testScript.ts",
package/readme.md CHANGED
@@ -52,7 +52,7 @@ All files are linted and _prettified_ upon commit (using `husky`, `lint-staged`
52
52
  - `/jest/unit.xml`
53
53
  - `/jest/integration.xml`
54
54
  - `/coverage-integration`
55
- - `/docs` for Docs (convention followed by Github Pages, Conventional commits, Vuepress, etc)
55
+ - `/docs` for Docs (convention followed by Github Pages, Conventional commits, Vitepress, etc)
56
56
 
57
57
  ### Yarn commands
58
58