From 5a9d55e6ea2692dccf57ac0ba15263969e95435e Mon Sep 17 00:00:00 2001 From: akash-aman Date: Thu, 5 Oct 2023 10:18:28 +0530 Subject: [PATCH 1/4] fix: Prod build command. --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c567c21..95ff390 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "license": "MIT", "private": true, "scripts": { - "prod": "NODE_ENV=production webpack --progress && npm run pot", + "prod": "cross-env NODE_ENV=production webpack --progress && npm run pot", "dev": "webpack --watch --progress", "clean": "rm -rf assets/build/*", "init": "./bin/init.js && npm run pot", @@ -30,6 +30,7 @@ "@wordpress/eslint-plugin": "^9.0.6", "@wordpress/stylelint-config": "^19.0.5", "babel-loader": "^8.2.2", + "cross-env": "^7.0.3", "css-loader": "^5.2.6", "eslint": "^7.27.0", "eslint-webpack-plugin": "^2.5.4", From 9d2a548aaadc2921f48a237cf8d3b6a027dde688 Mon Sep 17 00:00:00 2001 From: akash-aman Date: Fri, 6 Oct 2023 17:20:20 +0530 Subject: [PATCH 2/4] fix: init command. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 95ff390..b7f0ece 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "prod": "cross-env NODE_ENV=production webpack --progress && npm run pot", "dev": "webpack --watch --progress", "clean": "rm -rf assets/build/*", - "init": "./bin/init.js && npm run pot", + "init": "node ./bin/init.js && npm run pot", "lint:css": "stylelint assets/src/sass/**/*.scss --syntax scss", "lint:js": "eslint assets/src/js/", "lint:php": "./vendor/bin/phpcs", From ab748f9b904a0ef081d498807648d34beafe5c75 Mon Sep 17 00:00:00 2001 From: akash-aman Date: Fri, 6 Oct 2023 17:21:16 +0530 Subject: [PATCH 3/4] fix: remove language folder from clean folder list --- bin/init.js | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/init.js b/bin/init.js index a62a69b..15ff6f7 100755 --- a/bin/init.js +++ b/bin/init.js @@ -352,7 +352,6 @@ const runThemeCleanup = () => { '.git', '.github', 'bin', - 'languages', ]; deleteDirs.forEach((dir) => { From 571d27cb0a40d0158a5c9ba1d713e9344ca1cf38 Mon Sep 17 00:00:00 2001 From: akash-aman Date: Thu, 12 Oct 2023 18:19:29 +0530 Subject: [PATCH 4/4] fix: Convert PHPCBF to NodeJS Script. --- bin/phpcbf.js | 30 ++++++++++++++++++++++++++++++ package.json | 6 ++++-- 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 bin/phpcbf.js diff --git a/bin/phpcbf.js b/bin/phpcbf.js new file mode 100644 index 0000000..b974ed2 --- /dev/null +++ b/bin/phpcbf.js @@ -0,0 +1,30 @@ +const { spawn } = require('cross-spawn'); + +// Get the command-line arguments excluding the first two (node and script.js) +const args = process.argv.slice(2); + +// Define the main command you want to run. +const command = './vendor/bin/phpcbf'; + +// Combine the command and arguments. +const fullCommand = [command, ...args]; + +// Spawn the process. +const child = spawn(fullCommand[0], fullCommand.slice(1)); + +// Handle process events. +child.stdout.on('data', (data) => { + console.log(`stdout: ${data}`); +}); + +child.stderr.on('data', (data) => { + console.error(`stderr: ${data}`); +}); + +child.on('error', (error) => { + console.error(`Error: ${error.message}`); +}); + +child.on('close', (code) => { + console.log(`Child process exited with code ${code}`); +}); diff --git a/package.json b/package.json index b7f0ece..896efbe 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,10 @@ "clean": "rm -rf assets/build/*", "init": "node ./bin/init.js && npm run pot", "lint:css": "stylelint assets/src/sass/**/*.scss --syntax scss", + "lint:js:fix": "eslint assets/src/js/ --fix", "lint:js": "eslint assets/src/js/", - "lint:php": "./vendor/bin/phpcs", - "lint:php:fix": "./bin/phpcbf.sh", + "lint:php": "php ./vendor/bin/phpcs", + "lint:php:fix": "node ./bin/phpcbf.js", "lint:staged": "lint-staged", "pot": "wp-pot --src './**/*.php' --dest-file './languages/blank-theme.pot' --domain 'blank-theme' --package 'Blank Theme' ", "precommit": "npm-run-all lint:* pot", @@ -24,6 +25,7 @@ "webfontloader": "^1.6.28" }, "devDependencies": { + "cross-spawn": "^7.0.3", "@wordpress/babel-preset-default": "^6.2.0", "@wordpress/browserslist-config": "^4.0.1", "@wordpress/dependency-extraction-webpack-plugin": "^3.1.4",