-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #243 from studiopress/develop
Genesis Sample 2.10.0
- Loading branch information
Showing
25 changed files
with
642 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,9 +14,7 @@ wpi18n.makepot( | |
potHeaders: { | ||
'poedit': true, | ||
'x-poedit-basepath': '..', | ||
'report-msgid-bugs-to': 'StudioPress <[email protected]>', | ||
'last-translator': 'StudioPress <[email protected]>', | ||
'language-team': 'StudioPress <[email protected]>' | ||
'report-msgid-bugs-to': 'StudioPress <[email protected]>' | ||
} | ||
} | ||
).then( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#!/usr/bin/env node | ||
|
||
// Creates a zip file for distribution, excluding development and system files. | ||
// Using this instead of `git archive` for greater control, and to avoid an | ||
// issue with some applications (such as Path Finder) incorrectly decompressing | ||
// archives created by git archive with the `--prefix` flag. | ||
// | ||
// Also renames some .md files to .txt to reduce support requests. | ||
|
||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
const chalk = require("chalk"); | ||
const archiver = require("archiver"); | ||
const recursive = require("recursive-readdir"); | ||
const prettyBytes = require("pretty-bytes"); | ||
|
||
const excludes = [ | ||
".DS_Store", | ||
".editorconfig", | ||
".eslintignore", | ||
".eslintrc.js", | ||
".git", | ||
".gitattributes", | ||
".github", | ||
".gitignore", | ||
".scripts", | ||
".stylelintrc.json", | ||
"*.zip", | ||
"composer.json", | ||
"composer.lock", | ||
"node_modules", | ||
"package-lock.json", | ||
"package.json", | ||
"phpcs.xml.dist", | ||
"vendor" | ||
]; | ||
|
||
// Creates a file to stream archive data to. | ||
// Uses the name in package.json, such as 'child-theme.zip'. | ||
let output = fs.createWriteStream(`${process.env.npm_package_name}.zip`); | ||
|
||
let archive = archiver("zip", { | ||
zlib: { level: 9 } // Best compression. | ||
}); | ||
|
||
/** | ||
* Sets up the file output stream and archive. | ||
*/ | ||
const setupZipArchive = function() { | ||
// Listens for all archive data to be written. | ||
// Report the zip name and size, and rename *.txt files back to *.md again. | ||
output.on("close", function() { | ||
let fileSize = prettyBytes(archive.pointer()); | ||
console.log( | ||
chalk`{cyan Created ${process.env.npm_package_name}.zip, ${fileSize}}` | ||
); | ||
|
||
renameTxtFilesToMarkdown(); | ||
}); | ||
|
||
// Displays warnings during archiving. | ||
archive.on("warning", function(err) { | ||
if (err.code === "ENOENT") { | ||
console.log(err); | ||
} else { | ||
throw err; | ||
} | ||
}); | ||
|
||
// Catches errors during archiving. | ||
archive.on("error", function(err) { | ||
throw err; | ||
}); | ||
|
||
// Pipes archive data to the file. | ||
archive.pipe(output); | ||
}; | ||
|
||
/** | ||
* Rename files from *.md to *.txt. | ||
* Returns a promise so zip can be done once rename is complete. | ||
*/ | ||
const renameMarkdownFilesToTxt = new Promise(function(resolve, reject) { | ||
console.log(chalk`{cyan Renaming .md files to .txt}`); | ||
["CHANGELOG.md", "README.md", "CONTRIBUTING.md"].forEach(function(file) { | ||
if (fs.existsSync(file)) { | ||
fs.renameSync(file, file.replace(".md", ".txt")); | ||
} | ||
}); | ||
resolve("Success"); | ||
}); | ||
|
||
/** | ||
* Loops through theme directory, omitting files in the `exclude` array. | ||
* Adds each file to the zip archive. | ||
*/ | ||
const zipFiles = function() { | ||
recursive(process.cwd(), excludes, function(err, files) { | ||
let relativePath; | ||
|
||
console.log(chalk`{cyan Making zip file}`); | ||
files.forEach(function(filePath) { | ||
relativePath = path.relative(process.cwd(), filePath); | ||
archive.file(filePath, { | ||
name: `${process.env.npm_package_name}/${relativePath}` | ||
}); | ||
}); | ||
|
||
archive.finalize(); | ||
}); | ||
}; | ||
|
||
/** | ||
* Renames txt file to markdown. | ||
* Executed in the output stream close event. | ||
*/ | ||
const renameTxtFilesToMarkdown = function() { | ||
console.log(chalk`{cyan Renaming .txt files to .md}`); | ||
["CHANGELOG.txt", "README.txt", "CONTRIBUTING.txt"].forEach(function(file) { | ||
if (fs.existsSync(file)) { | ||
fs.renameSync(file, file.replace(".txt", ".md")); | ||
} | ||
}); | ||
}; | ||
|
||
setupZipArchive(); | ||
renameMarkdownFilesToTxt.then(zipFiles); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.