Revert "Ignore build.js file (Prettier)"

This reverts commit c2befaee46.
This commit is contained in:
Dmitry Yankowski
2020-02-24 14:54:32 -05:00
parent c2befaee46
commit 19c9c5491b
5 changed files with 11391 additions and 1912 deletions

View File

@@ -1,4 +1,3 @@
build.js
.dependabot .dependabot
.github .github
.nuxt .nuxt

View File

@@ -1,63 +1,59 @@
const axios = require("axios"); const axios = require('axios')
const fs = require("fs"); const fs = require('fs')
const { spawnSync } = require("child_process"); const { spawnSync } = require('child_process')
const runCommand = (command, args) => const runCommand = (command, args) =>
spawnSync(command, args) spawnSync(command, args)
.stdout.toString() .stdout.toString()
.replace(/\n/g, ""); .replace(/\n/g, '')
const FAIL_ON_ERROR = false; const FAIL_ON_ERROR = false
const PW_BUILD_DATA_DIR = "./.postwoman"; const PW_BUILD_DATA_DIR = './.postwoman'
const IS_DEV_MODE = process.argv.includes("--dev"); const IS_DEV_MODE = process.argv.includes('--dev')
try { try {
(async () => { ;(async () => {
// Create the build data directory if it does not exist. // Create the build data directory if it does not exist.
if (!fs.existsSync(PW_BUILD_DATA_DIR)) { if (!fs.existsSync(PW_BUILD_DATA_DIR)) {
fs.mkdirSync(PW_BUILD_DATA_DIR); fs.mkdirSync(PW_BUILD_DATA_DIR)
} }
let version = {}; let version = {}
// Get the current version name as the tag from Git. // Get the current version name as the tag from Git.
version.name = version.name =
process.env.TRAVIS_TAG || process.env.TRAVIS_TAG || runCommand('git', ['tag --sort=committerdate | tail -1'])
runCommand("git", ["tag --sort=committerdate | tail -1"]);
// FALLBACK: If version.name was unset, let's grab it from GitHub. // FALLBACK: If version.name was unset, let's grab it from GitHub.
if (!version.name) { if (!version.name) {
version.name = ( version.name = (
await axios await axios
.get("https://api.github.com/repos/liyasthomas/postwoman/releases") .get('https://api.github.com/repos/liyasthomas/postwoman/releases')
// If we can't get it from GitHub, we'll resort to getting it from package.json // If we can't get it from GitHub, we'll resort to getting it from package.json
.catch(ex => ({ .catch(ex => ({
data: [ data: [
{ {
tag_name: require("./package.json").version tag_name: require('./package.json').version,
} },
] ],
})) }))
).data[0]["tag_name"]; ).data[0]['tag_name']
} }
// Get the current version hash as the short hash from Git. // Get the current version hash as the short hash from Git.
version.hash = runCommand("git", ["rev-parse", "--short", "HEAD"]); version.hash = runCommand('git', ['rev-parse', '--short', 'HEAD'])
// Get the 'variant' name as the branch, if it's not master. // Get the 'variant' name as the branch, if it's not master.
version.variant = version.variant =
process.env.TRAVIS_BRANCH || process.env.TRAVIS_BRANCH ||
runCommand("git", ["branch"]) runCommand('git', ['branch'])
.split("* ")[1] .split('* ')[1]
.split(" ")[0] + (IS_DEV_MODE ? " - DEV MODE" : ""); .split(' ')[0] + (IS_DEV_MODE ? ' - DEV MODE' : '')
if (["", "master"].includes(version.variant)) { if (['', 'master'].includes(version.variant)) {
delete version.variant; delete version.variant
} }
// Write version data into a file // Write version data into a file
fs.writeFileSync( fs.writeFileSync(`${PW_BUILD_DATA_DIR}/version.json`, JSON.stringify(version))
`${PW_BUILD_DATA_DIR}/version.json`, })()
JSON.stringify(version)
);
})();
} catch (ex) { } catch (ex) {
console.error(ex); console.error(ex)
process.exit(FAIL_ON_ERROR ? 1 : 0); process.exit(FAIL_ON_ERROR ? 1 : 0)
} }

3320
package-lock.json generated

File diff suppressed because it is too large Load Diff

9922
yarn.lock Normal file

File diff suppressed because it is too large Load Diff