Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jazz-Man committed May 8, 2020
2 parents a224f45 + e65a224 commit 20a74b9
Show file tree
Hide file tree
Showing 63 changed files with 8,212 additions and 3,133 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
"php": ">=7.2",
"ext-ctype": "*",
"ext-mbstring": "*",
"composer/installers": "^1.8",
"composer/installers": "^1.9",
"jazzman/custom-post-type": "^2.2",
"jazzman/wp-app-config": "^2.0",
"jazzman/wp-mail": "^1.2",
"jazzman/wp-performance": "^1.6",
"jazzman/wp-performance": "^1.9",
"oscarotero/env": "^1.2",
"roots/wordpress": "^5.3",
"roots/wordpress": "^5.4",
"roots/wp-config": "^1.0",
"roots/wp-password-bcrypt": "^1.0",
"vlucas/phpdotenv": "^4.1"
Expand Down
97 changes: 78 additions & 19 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions copy-block-styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
const mix = require("laravel-mix");
const File = require("laravel-mix/src/File");
const { resolve, dirname, basename } = require("path");
const fs = require("fs");
const { themeDir } = require("./webpack.mix.config");
const baseStylesDir = resolve(__dirname, "node_modules/@wordpress/base-styles");
const baseBlockLibraryDir = resolve(
__dirname,
"node_modules/@wordpress/block-library/src/"
);

const wpBlocksDir = `${themeDir}/src/scss/wp-blocks`;

fs.readdir(baseStylesDir, (err, files) => {
files.forEach(file => {
const style = new File(`${baseStylesDir}/${file}`);
let destination = `${wpBlocksDir}/core/${style.name()}`;

if (style.extension() === ".scss" && !fs.existsSync(destination)) {
try {
style.copyTo(destination);
} catch (err) {
console.error(err);
}
}
});
});

const getAllFiles = (dirPath, arrayOfFiles = []) => {
const files = fs.readdirSync(dirPath);

files.forEach(file => {
let _file = `${dirPath}/${file}`;

if (fs.statSync(_file).isDirectory()) {
arrayOfFiles = getAllFiles(_file, arrayOfFiles);
} else {
arrayOfFiles.push(_file);
}
});

return arrayOfFiles;
};

const blockLibrary = getAllFiles(baseBlockLibraryDir);

if (blockLibrary.length) {
blockLibrary.forEach(file => {
const style = new File(file);

let reqaredName = ["style.scss", "theme.scss"];

if (reqaredName.includes(style.name())) {
let styleDirName = basename(dirname(file));
let newFileName =
styleDirName === "src"
? style.name()
: `${styleDirName}/${style.name()}`;
let destination = `${wpBlocksDir}/blocks/${newFileName}`;

if (!fs.existsSync(destination)) {
try {
style.copyTo(destination);
} catch (err) {
console.error(err);
}
}
}
});
}
Loading

0 comments on commit 20a74b9

Please sign in to comment.