sdc-build-wp 3.1.0 → 3.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.
@@ -0,0 +1,26 @@
1
+ {
2
+ "plugins": [
3
+ "@stylistic/stylelint-plugin"
4
+ ],
5
+ "rules": {
6
+ "@stylistic/indentation": "tab",
7
+ "@stylistic/max-empty-lines": 1,
8
+ "rule-empty-line-before": [
9
+ "always",
10
+ {
11
+ "ignore": [ "after-comment" ]
12
+ }
13
+ ],
14
+ "@stylistic/block-opening-brace-space-before": "always-multi-line",
15
+ "@stylistic/block-opening-brace-newline-after": "always-multi-line",
16
+ "@stylistic/no-empty-first-line": true,
17
+ "@stylistic/selector-max-empty-lines": 0,
18
+ "color-function-notation": "modern",
19
+ "color-hex-length": "long",
20
+ "color-no-invalid-hex": true,
21
+ "color-named": "never",
22
+ "shorthand-property-no-redundant-values": true,
23
+ "@stylistic/number-leading-zero": "always",
24
+ "@stylistic/no-eol-whitespace": true
25
+ }
26
+ }
package/index.js CHANGED
@@ -4,10 +4,10 @@ import project from './lib/project.js';
4
4
  import parseArgs from 'minimist';
5
5
  const argv = parseArgs(process.argv.slice(2));
6
6
  import chokidar from 'chokidar';
7
- import glob from 'glob';
7
+ import { glob } from 'glob';
8
8
 
9
9
  import bustCache from './lib/bustCache.js';
10
- import buildSass from './lib/style.js';
10
+ import { buildSass, buildSassTheme } from './lib/style.js';
11
11
  import buildJS from './lib/scripts.js';
12
12
  import buildBlock from './lib/blocks.js';
13
13
  import buildImages from './lib/images.js';
@@ -97,6 +97,7 @@ if (argv.watch) {
97
97
  }
98
98
 
99
99
  function runSass() {
100
+ buildSassTheme();
100
101
  for (var block of filesSass) {
101
102
  buildSass(block.file, block.name, sassGlob);
102
103
  bustFunctionsCache();
package/lib/scripts.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import path from 'path';
2
2
  import project from '../lib/project.js';
3
3
  import log from './logging.js';
4
- import esbuild from 'esbuild';
4
+ import * as esbuild from 'esbuild';
5
5
  import { ESLint } from 'eslint';
6
6
  import { readFile } from 'fs/promises';
7
7
 
package/lib/style.js CHANGED
@@ -10,12 +10,25 @@ import sortMQ from 'postcss-sort-media-queries';
10
10
  import stylelint from 'stylelint';
11
11
  import { promises } from 'fs';
12
12
 
13
- const buildColors = async () => {
13
+ function camelToDash(camel) {
14
+ return camel.replace(/[A-Z]/g, m => '-' + m.toLowerCase());
15
+ }
16
+
17
+ const buildSassTheme = async () => {
14
18
  try {
15
19
  let theme = JSON.parse(await promises.readFile(project.path + '/theme.json'));
16
20
  let themeFileData = `// This file is automatically generated from theme.json. Do not edit.\n`;
17
- if (theme.settings.custom && theme.settings.custom['dirDist']) {
18
- themeFileData += `$themeDirDist: "${theme.settings.custom['dirDist']}";\n`;
21
+ if (theme.settings?.custom) {
22
+ for (var customAttribute in theme.settings.custom) {
23
+ if (customAttribute == 'dirDist') {
24
+ themeFileData += `$themeDirDist: "${theme.settings.custom[customAttribute]}"; // --wp--custom--${camelToDash(customAttribute)}\n`;
25
+ } else if (['breakpoints-rem', 'breakpoint-mobile'].includes(customAttribute)) {
26
+ // handled later in file - see 'fontSizeBase'
27
+ } else {
28
+ themeFileData += `$${customAttribute}: "${theme.settings.custom[customAttribute]}"; // --wp--custom--${camelToDash(customAttribute)}\n`;
29
+ //
30
+ }
31
+ }
19
32
  }
20
33
  if (theme.styles?.typography) {
21
34
  if (theme.styles.typography.fontSize) {
@@ -61,7 +74,6 @@ const buildColors = async () => {
61
74
  };
62
75
 
63
76
  const buildSass = async (entry, name, entriesToLint) => {
64
- await buildColors();
65
77
  let timerStart = Date.now();
66
78
  let outFile = project.path + '/dist/' + name + '.min.css';
67
79
  if (name.startsWith('blocks/')) {
@@ -69,7 +81,7 @@ const buildSass = async (entry, name, entriesToLint) => {
69
81
  }
70
82
  let entryLabel = outFile.replace(project.path, '');
71
83
  stylelint.lint({
72
- configFile: path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../.stylelintrc'),
84
+ configFile: path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../.stylelintrc.json'),
73
85
  formatter: 'string',
74
86
  files: entriesToLint || [entry],
75
87
  customSyntax: 'postcss-scss',
@@ -120,4 +132,4 @@ const buildSass = async (entry, name, entriesToLint) => {
120
132
  });
121
133
  };
122
134
 
123
- export default buildSass;
135
+ export { buildSass, buildSassTheme };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdc-build-wp",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "Custom WordPress build process.",
5
5
  "author": {
6
6
  "name": "Robert Sefer",
@@ -19,24 +19,25 @@
19
19
  "sdc-build-wp": "./index.js"
20
20
  },
21
21
  "dependencies": {
22
- "@wordpress/scripts": "^26.6.0",
23
- "autoprefixer": "^10.4.13",
24
- "browser-sync": "^2.27.11",
25
- "chalk": "^5.2.0",
26
- "chokidar": "^3.5.3",
27
- "esbuild": "^0.16.10",
28
- "eslint": "^8.30.0",
29
- "fs-extra": "^11.1.0",
30
- "glob": "^8.0.3",
22
+ "@stylistic/stylelint-plugin": "^2.1.1",
23
+ "@wordpress/scripts": "^27.5.0",
24
+ "autoprefixer": "^10.4.19",
25
+ "browser-sync": "^3.0.2",
26
+ "chalk": "^5.3.0",
27
+ "chokidar": "^3.6.0",
28
+ "esbuild": "^0.20.2",
29
+ "eslint": "^8.57.0",
30
+ "fs-extra": "^11.2.0",
31
+ "glob": "^10.3.12",
31
32
  "imagemin": "^8.0.1",
32
33
  "imagemin-jpegtran": "^7.0.0",
33
34
  "imagemin-pngquant": "^9.0.2",
34
35
  "imagemin-svgo": "^10.0.1",
35
- "minimist": "^1.2.7",
36
- "postcss": "^8.4.20",
37
- "postcss-scss": "^4.0.6",
38
- "postcss-sort-media-queries": "^4.3.0",
39
- "sass": "^1.63.4",
40
- "stylelint": "^14.16.0"
36
+ "minimist": "^1.2.8",
37
+ "postcss": "^8.4.38",
38
+ "postcss-scss": "^4.0.9",
39
+ "postcss-sort-media-queries": "^5.2.0",
40
+ "sass": "^1.72.0",
41
+ "stylelint": "^16.3.1"
41
42
  }
42
43
  }
package/.stylelintrc DELETED
@@ -1,23 +0,0 @@
1
- {
2
- "rules": {
3
- "indentation": "tab",
4
- "max-empty-lines": 1,
5
- "rule-empty-line-before": [
6
- "always",
7
- {
8
- "ignore": [ "after-comment" ]
9
- }
10
- ],
11
- "block-opening-brace-space-before": "always-multi-line",
12
- "block-opening-brace-newline-after": "always-multi-line",
13
- "no-empty-first-line": true,
14
- "selector-max-empty-lines": 0,
15
- "color-function-notation": "modern",
16
- "color-hex-length": "long",
17
- "color-no-invalid-hex": true,
18
- "color-named": "never",
19
- "shorthand-property-no-redundant-values": true,
20
- "number-leading-zero": "always",
21
- "no-eol-whitespace": true
22
- }
23
- }