sdc-build-wp 3.2.3 → 3.3.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,23 @@
1
+ export default [
2
+ {
3
+ languageOptions: {
4
+ parserOptions: {
5
+ ecmaVersion: 6,
6
+ sourceType: "module",
7
+ ecmaFeatures: {
8
+ jsx: true,
9
+ },
10
+ },
11
+ },
12
+ rules: {
13
+ semi: 1,
14
+ indent: [1, "tab"],
15
+ "no-multiple-empty-lines": [
16
+ 1,
17
+ {
18
+ max: 1,
19
+ },
20
+ ],
21
+ },
22
+ }
23
+ ];
package/index.js CHANGED
@@ -4,7 +4,7 @@ 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, globSync } from 'glob';
8
8
 
9
9
  import bustCache from './lib/bustCache.js';
10
10
  import { buildSass, buildSassTheme } from './lib/style.js';
@@ -22,28 +22,30 @@ let chokidarOpts = {
22
22
  };
23
23
 
24
24
  let sassGlobPath = project.package?.sdc?.sassGlobPath || project.path + '{/_src/style,/blocks}/**/*.scss';
25
- let sassGlob = glob.sync(sassGlobPath, {
25
+ let sassGlob = globSync(sassGlobPath, {
26
26
  ignore: [
27
27
  project.path + '/_src/style/partials/_theme.scss'
28
28
  ]
29
29
  });
30
30
  let jsGlobPath = project.package?.sdc?.jsGlobPath || project.path + '/_src/scripts/**/*.js';
31
- let jsGlob = glob.sync(jsGlobPath, {
31
+ let jsGlob = globSync(jsGlobPath, {
32
32
  ignore: []
33
33
  });
34
34
  let blockGlobPath = project.package?.sdc?.blockGlobPath || project.path + '/blocks/*';
35
- let blockGlob = glob.sync(blockGlobPath);
35
+ let blockGlob = globSync(blockGlobPath);
36
36
 
37
37
  function bustFunctionsCache() {
38
38
  bustCache(project.path + '/functions.php');
39
39
  }
40
40
 
41
41
  function frontrunImages() {
42
- [project.path + '/_src/images/', project.path + '/_src/images/**/*/'].forEach((block) => {
43
- glob(block, {}, function(err, directory) {
44
- directory.forEach((dir) => {
45
- buildImages(dir);
46
- });
42
+ [
43
+ project.path + '/_src/images/',
44
+ project.path + '/_src/images/**/*/'
45
+ ].forEach((block) => {
46
+ const imageDirectories = globSync(block);
47
+ imageDirectories.forEach((dir) => {
48
+ buildImages(dir);
47
49
  });
48
50
  });
49
51
  }
@@ -55,7 +57,7 @@ for (const [name, files] of Object.entries(project.package.sdc.entries)) {
55
57
  entries[name].push(project.path + file);
56
58
  });
57
59
  }
58
- let sassBlocksGlob = glob.sync(project.path + '/blocks/*/*.scss');
60
+ let sassBlocksGlob = globSync(project.path + '/blocks/*/*.scss');
59
61
  for (var filename of sassBlocksGlob) {
60
62
  entries[`blocks/${path.basename(path.dirname(filename))}/style`] = [ filename ];
61
63
  }
package/lib/images.js CHANGED
@@ -7,15 +7,16 @@ import imageminSvgo from 'imagemin-svgo';
7
7
 
8
8
  const buildImages = async (images) => {
9
9
  let timerStart = Date.now();
10
- const files = await imagemin([images + '*'], {
11
- destination: project.path + '/dist/images/' + (images.replace(project.path + '/_src/images/', '')),
10
+ let dest = images.replace('_src/images', 'dist/images');
11
+ const files = await imagemin([images + '/*'], {
12
+ destination: dest,
12
13
  plugins: [
13
14
  imageminJpegtran(),
14
15
  imageminPngquant(),
15
16
  imageminSvgo()
16
17
  ]
17
18
  });
18
- log('success', `Built /dist/images/${images.replace(project.path + '/_src/images/', '')} in ${Date.now() - timerStart}ms`);
19
+ log('success', `Built ${dest.replace(project.path, '')} (${files.length} image${files.length == 1 ? '' : 's'}) in ${Date.now() - timerStart}ms`);
19
20
  };
20
21
 
21
22
  export default buildImages;
package/lib/scripts.js CHANGED
@@ -3,15 +3,16 @@ import project from '../lib/project.js';
3
3
  import log from './logging.js';
4
4
  import * as esbuild from 'esbuild';
5
5
  import { ESLint } from 'eslint';
6
- import { readFile } from 'fs/promises';
6
+ import * as eslintConfig from '../eslint.config.js';
7
7
 
8
8
  const buildJS = async (entry, name, entriesToLint) => {
9
9
  let entryLabel = `/dist/scripts/${path.parse(entry).base.replace('.js', '.min.js')}`;
10
10
  let timerStart = Date.now();
11
11
  try {
12
12
  const eslint = new ESLint({
13
- baseConfig: JSON.parse(await readFile(new URL('../.eslintrc', import.meta.url))),
14
- fix: true
13
+ fix: true,
14
+ overrideConfigFile: true,
15
+ overrideConfig: eslintConfig.default[0]
15
16
  });
16
17
  const lintresults = await eslint.lintFiles(entriesToLint || [entry]);
17
18
  await ESLint.outputFixes(lintresults);
package/lib/style.js CHANGED
@@ -79,6 +79,12 @@ export const buildSassTheme = async () => {
79
79
 
80
80
  export const buildSass = async (entry, name, entriesToLint) => {
81
81
  let timerStart = Date.now();
82
+ if (!fs.existsSync(project.path + '/dist')) {
83
+ fs.mkdirSync(project.path + '/dist');
84
+ }
85
+ if (!fs.existsSync(project.path + '/dist/style')) {
86
+ fs.mkdirSync(project.path + '/dist/style');
87
+ }
82
88
  let outFile = project.path + '/dist/' + name + '.min.css';
83
89
  if (name.startsWith('blocks/')) {
84
90
  outFile = project.path + '/' + name + '.min.css';
@@ -92,8 +98,8 @@ export const buildSass = async (entry, name, entriesToLint) => {
92
98
  fix: true
93
99
  }).then((data) => {
94
100
  if (data.errored) {
95
- console.error(data.output);
96
- log('error', `Failed linting ${entry.replace(project.path + '/_src/style/', '')} - See above error.`);
101
+ console.error(data.report);
102
+ log('error', `Failed linting ${entry.replace(project.path + '/_src/style/', '')} - See above linting error.`);
97
103
  return false;
98
104
  }
99
105
  try {
@@ -102,16 +108,11 @@ export const buildSass = async (entry, name, entriesToLint) => {
102
108
  });
103
109
  fs.writeFile(outFile, result.css, function(err) {
104
110
  if (err) {
105
- // console.error(err);
106
- // log('error', `Failed compiling ${entryLabel} - See above error.`);
107
- // return false;
111
+ console.error(err);
112
+ log('error', `Failed compiling ${entryLabel} - See above file writing error.`);
113
+ return false;
108
114
  } else {
109
- if (!fs.existsSync(project.path + '/dist')) {
110
- fs.mkdirSync(project.path + '/dist');
111
- }
112
- if (!fs.existsSync(project.path + '/dist/style')) {
113
- fs.mkdirSync(project.path + '/dist/style');
114
- }
115
+
115
116
  postcss([
116
117
  autoprefixer(),
117
118
  sortMQ()
@@ -119,7 +120,7 @@ export const buildSass = async (entry, name, entriesToLint) => {
119
120
  fs.writeFile(outFile, resultPost.css, function(err) {
120
121
  if (err) {
121
122
  console.log(err);
122
- log('error', `Failed saving ${entryLabel} - See above error.`);
123
+ log('error', `Failed saving ${entryLabel} - See above postcss error.`);
123
124
  return false;
124
125
  } else {
125
126
  log('success', `Built ${entryLabel} in ${Date.now() - timerStart}ms`);
@@ -130,7 +131,7 @@ export const buildSass = async (entry, name, entriesToLint) => {
130
131
  });
131
132
  } catch(error) {
132
133
  console.error(error);
133
- log('error', `Failed building ${entryLabel} - See above error.`);
134
+ log('error', `Failed building ${entryLabel} - See above sass error.`);
134
135
  return false;
135
136
  }
136
137
  });
package/package.json CHANGED
@@ -1,43 +1,46 @@
1
1
  {
2
- "name": "sdc-build-wp",
3
- "version": "3.2.3",
4
- "description": "Custom WordPress build process.",
5
- "author": {
6
- "name": "Robert Sefer",
7
- "email": "rob@seferdesign.com",
8
- "url": "https://seferdesign.com"
9
- },
10
- "repository": {
11
- "type": "git",
12
- "url": "git://github.com/SeferDesign/sdc-build-wp.git"
13
- },
14
- "type": "module",
15
- "scripts": {
16
- "test": "echo \"Skipping tests.\""
17
- },
18
- "bin": {
19
- "sdc-build-wp": "./index.js"
20
- },
21
- "dependencies": {
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",
32
- "imagemin": "^8.0.1",
33
- "imagemin-jpegtran": "^7.0.0",
34
- "imagemin-pngquant": "^9.0.2",
35
- "imagemin-svgo": "^10.0.1",
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"
42
- }
2
+ "name": "sdc-build-wp",
3
+ "version": "3.3.0",
4
+ "description": "Custom WordPress build process.",
5
+ "engines": {
6
+ "node": "^20"
7
+ },
8
+ "author": {
9
+ "name": "Robert Sefer",
10
+ "email": "rob@seferdesign.com",
11
+ "url": "https://seferdesign.com"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git://github.com/SeferDesign/sdc-build-wp.git"
16
+ },
17
+ "type": "module",
18
+ "scripts": {
19
+ "test": "echo \"Skipping tests.\""
20
+ },
21
+ "bin": {
22
+ "sdc-build-wp": "./index.js"
23
+ },
24
+ "dependencies": {
25
+ "@stylistic/stylelint-plugin": "^2.1.1",
26
+ "@wordpress/scripts": "^27.7.0",
27
+ "autoprefixer": "^10.4.19",
28
+ "browser-sync": "^3.0.2",
29
+ "chalk": "^5.3.0",
30
+ "chokidar": "^3.6.0",
31
+ "esbuild": "^0.20.2",
32
+ "eslint": "^9.1.1",
33
+ "fs-extra": "^11.2.0",
34
+ "glob": "^10.3.12",
35
+ "imagemin": "^8.0.1",
36
+ "imagemin-jpegtran": "^7.0.0",
37
+ "imagemin-pngquant": "^9.0.2",
38
+ "imagemin-svgo": "^10.0.1",
39
+ "minimist": "^1.2.8",
40
+ "postcss": "^8.4.38",
41
+ "postcss-scss": "^4.0.9",
42
+ "postcss-sort-media-queries": "^5.2.0",
43
+ "sass": "^1.75.0",
44
+ "stylelint": "^16.4.0"
45
+ }
43
46
  }
package/.eslintrc DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "parserOptions": {
3
- "ecmaVersion": 6,
4
- "sourceType": "module",
5
- "ecmaFeatures": {
6
- "jsx": true
7
- }
8
- },
9
- "rules": {
10
- "semi": 1,
11
- "indent": [1, "tab"],
12
- "no-multiple-empty-lines": [
13
- 1,
14
- {
15
- "max": 1
16
- }
17
- ]
18
- }
19
- }