sku 12.0.0 → 12.0.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # sku
2
2
 
3
+ ## 12.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Ensure `sku pre-commit` lints the same files as `sku lint` ([#821](https://github.com/seek-oss/sku/pull/821))
8
+
9
+ ## 12.0.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Check that paths exist before looking for `*.less` files in them ([#817](https://github.com/seek-oss/sku/pull/817))
14
+
3
15
  ## 12.0.0
4
16
 
5
17
  ### Major Changes
package/bin/sku.js CHANGED
@@ -3,6 +3,7 @@ const fs = require('fs');
3
3
  const debug = require('debug');
4
4
  const args = require('../config/args');
5
5
  const _validatePeerDeps = require('../lib/validatePeerDeps');
6
+ const validateLessFiles = require('../lib/validateLessFiles');
6
7
  const { getPathFromCwd } = require('../lib/cwd');
7
8
  const log = debug('sku:bin');
8
9
 
@@ -62,8 +63,10 @@ log(`Starting script: ${script}`);
62
63
  case 'setup-hosts':
63
64
  case 'init':
64
65
  case 'configure': {
65
- runScript(script);
66
- break;
66
+ if (script !== 'init') {
67
+ validateLessFiles();
68
+ }
69
+ return runScript(script);
67
70
  }
68
71
 
69
72
  case 'test':
@@ -72,8 +75,8 @@ log(`Starting script: ${script}`);
72
75
  case 'pre-commit':
73
76
  case 'translations': {
74
77
  await configureProject();
75
- runScript(script);
76
- break;
78
+ validateLessFiles();
79
+ return runScript(script);
77
80
  }
78
81
 
79
82
  case 'start':
@@ -84,10 +87,9 @@ log(`Starting script: ${script}`);
84
87
  case 'build-ssr':
85
88
  case 'serve': {
86
89
  await configureProject();
87
-
90
+ validateLessFiles();
88
91
  validatePeerDeps();
89
- runScript(script);
90
- break;
92
+ return runScript(script);
91
93
  }
92
94
 
93
95
  default: {
@@ -1,13 +1,14 @@
1
1
  const isYarn = require('../../lib/isYarn');
2
+ const { lintExtensions } = require('../../lib/lint');
2
3
 
3
4
  const steps = {};
4
5
 
5
6
  // Yarn lock integrity check
6
7
  if (isYarn) {
7
- steps['+(package.json|yarn.lock)'] = [() => 'yarn check --integrity'];
8
+ steps['+(package.json|yarn.lock)'] = [() => 'yarn install --check-files'];
8
9
  }
9
10
 
10
11
  // Format & lint
11
- steps['**/*.{js,ts,tsx,md,less}'] = ['sku format', 'sku lint'];
12
+ steps[`**/*.{${lintExtensions},md,less}`] = ['sku format', 'sku lint'];
12
13
 
13
14
  module.exports = steps;
package/lib/configure.js CHANGED
@@ -1,8 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  const { writeFile, rm } = require('fs/promises');
3
3
  const path = require('path');
4
- const glob = require('fast-glob');
5
- const fs = require('fs');
6
4
 
7
5
  const ensureGitignore = require('ensure-gitignore');
8
6
  const { cwd, getPathFromCwd } = require('./cwd');
@@ -11,8 +9,6 @@ const { paths, httpsDevServer, languages } = require('../context');
11
9
  const {
12
10
  bundleReportFolder,
13
11
  } = require('../config/webpack/plugins/bundleAnalyzer');
14
- const printBanner = require('../lib/banner');
15
- const chalk = require('chalk');
16
12
  const prettierConfig = require('../config/prettier/prettierConfig');
17
13
  const eslintConfig = require('../config/eslint/eslintConfig');
18
14
  const createTSConfig = require('../config/typescript/tsconfig.js');
@@ -32,12 +28,7 @@ const writeFileToCWD = async (fileName, content, { banner = true } = {}) => {
32
28
  await writeFile(outPath, contentStr);
33
29
  };
34
30
 
35
- /**
36
- * @typedef {object} Options
37
- * @property {boolean | undefined} isPostInit
38
- * @param {Options}
39
- */
40
- module.exports = async ({ isPostInit } = {}) => {
31
+ module.exports = async () => {
41
32
  // Ignore webpack bundle report output
42
33
  const gitIgnorePatterns = [
43
34
  addSep(bundleReportFolder),
@@ -118,32 +109,4 @@ module.exports = async ({ isPostInit } = {}) => {
118
109
  comment: 'managed by sku',
119
110
  patterns: gitIgnorePatterns.map(convertToForwardSlashPaths),
120
111
  });
121
-
122
- // Check for `.less` files only if we haven't just done an init
123
- if (!isPostInit) {
124
- const lessFileGlobResults = await Promise.all(
125
- paths.src
126
- .filter((srcPath) => fs.statSync(srcPath).isDirectory())
127
- .map(async (srcPath) => await glob(path.join(srcPath, '**/*.less'))),
128
- );
129
- const srcHasLessFiles = lessFileGlobResults.some(
130
- (fileArray) => fileArray.length > 0,
131
- );
132
- if (srcHasLessFiles) {
133
- printBanner('warning', 'LESS styles detected', [
134
- `Support for ${chalk.bold('LESS')} has been deprecated.`,
135
- `${chalk.bold(
136
- 'Vanilla Extract',
137
- )} is the preferred styling solution supported by ${chalk.bold(
138
- 'sku',
139
- )}, and support for ${chalk.bold(
140
- 'LESS',
141
- )} will be removed in a future release.`,
142
- `Consumers are encouraged to migrate to ${chalk.bold(
143
- 'Vanilla Extract',
144
- )} at the earliest opportunity.`,
145
- 'https://seek-oss.github.io/sku/#/./docs/styling?id=vanilla-extract',
146
- ]);
147
- }
148
- }
149
112
  };
package/lib/lint.js ADDED
@@ -0,0 +1,8 @@
1
+ const {
2
+ js: jsExtensions,
3
+ ts: tsExtensions,
4
+ } = require('eslint-config-seek/extensions');
5
+
6
+ const lintExtensions = [...tsExtensions, ...jsExtensions];
7
+
8
+ module.exports = { lintExtensions };
package/lib/runESLint.js CHANGED
@@ -1,12 +1,9 @@
1
1
  const { yellow, cyan, gray } = require('chalk');
2
2
  const { ESLint } = require('eslint');
3
3
  const eslintConfig = require('../config/eslint/eslintConfig');
4
- const {
5
- js: jsExtensions,
6
- ts: tsExtensions,
7
- } = require('eslint-config-seek/extensions');
4
+ const { lintExtensions } = require('./lint');
8
5
 
9
- const extensions = [...tsExtensions, ...jsExtensions].map((ext) => `.${ext}`);
6
+ const extensions = lintExtensions.map((ext) => `.${ext}`);
10
7
 
11
8
  /**
12
9
  * @param {{ fix?: boolean, paths?: string[] }}
@@ -0,0 +1,38 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const glob = require('fast-glob');
4
+ const chalk = require('chalk');
5
+
6
+ const printBanner = require('./banner');
7
+ const exists = require('./exists');
8
+ const { paths } = require('../context');
9
+
10
+ module.exports = async () => {
11
+ const srcPathsExist = await Promise.all(
12
+ paths.src.map(async (srcPath) => (await exists(srcPath)) && srcPath),
13
+ );
14
+ const lessFileGlobResults = await Promise.all(
15
+ srcPathsExist
16
+ .filter((srcPath) => srcPath && fs.statSync(srcPath).isDirectory())
17
+ .map(async (srcPath) => await glob(path.join(srcPath, '**/*.less'))),
18
+ );
19
+ const srcHasLessFiles = lessFileGlobResults.some(
20
+ (fileArray) => fileArray.length > 0,
21
+ );
22
+ if (srcHasLessFiles) {
23
+ printBanner('warning', 'LESS styles detected', [
24
+ `Support for ${chalk.bold('LESS')} has been deprecated.`,
25
+ `${chalk.bold(
26
+ 'Vanilla Extract',
27
+ )} is the preferred styling solution supported by ${chalk.bold(
28
+ 'sku',
29
+ )}, and support for ${chalk.bold(
30
+ 'LESS',
31
+ )} will be removed in a future release.`,
32
+ `Consumers are encouraged to migrate to ${chalk.bold(
33
+ 'Vanilla Extract',
34
+ )} at the earliest opportunity.`,
35
+ 'https://seek-oss.github.io/sku/#/./docs/styling?id=vanilla-extract',
36
+ ]);
37
+ }
38
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sku",
3
- "version": "12.0.0",
3
+ "version": "12.0.2",
4
4
  "description": "Front-end development toolkit, powered by Webpack, Babel, CSS Modules, Less and Jest",
5
5
  "main": "index.js",
6
6
  "bin": {
package/scripts/init.js CHANGED
@@ -214,7 +214,7 @@ const getTemplateFileDestinationFromRoot =
214
214
  await install({ deps, verbose, useYarn });
215
215
  await install({ deps: devDeps, type: 'dev', exact: false, verbose, useYarn });
216
216
 
217
- await configure({ isPostInit: true });
217
+ await configure();
218
218
  await esLintFix();
219
219
  await prettierWrite();
220
220