Skip to content

Commit

Permalink
Dev/build (#77)
Browse files Browse the repository at this point in the history
* 👷 Build >> Changing build process.
  • Loading branch information
borsTiHD authored Aug 5, 2021
1 parent 6387b27 commit baceead
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"passport": "^0.4.1",
"passport-jwt": "^4.0.0",
"passport-local": "^1.0.0",
"prompts": "^2.4.1",
"release-it": "^14.10.1",
"socket.io": "^4.1.3",
"socket.io-client": "^4.1.3",
Expand Down
27 changes: 26 additions & 1 deletion src/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import NuxtApp from 'nuxt'
import dotenv from 'dotenv'
import release from 'release-it'
import minimist from 'minimist'
import prompts from 'prompts'
import webpackConfig from '../webpack.config.js'
import releaseItConfig from '../.release-it-config.js'
import nuxtConfig from './client/nuxt.config.js'
Expand Down Expand Up @@ -52,13 +53,35 @@ if (BUNDLE_ONLY) {

// Controlls building
async function init() {
const loader = createLoader()
let loader = createLoader()
try {
// If we want to release our build,
// ask the user if the changelog got edited,
// if not, we script will stop and remind to do that
if (RELEASE_IT) {
clearInterval(loader)
logState('(ℹ) YOU WANT TO RELEASE THE APP')
const response = await prompts({
type: 'text',
name: 'answer',
message: 'Did you remember to adjust the changelog? (y/n)'
// validate: (value) => value < 18 ? 'Nightclub is 18+ only' : true
})

// If the answer wasn't 'y' or 'yes' the script will stop
if (!/(yes|y)/gmi.test(response.answer)) {
throw new Error('Question was not answered correclty. The user forgot to adjust the changelog.')
}
loader = createLoader()
}

logState('(ℹ) DELETING OLD FILES')
await deleteOldFiles()

clearInterval(loader)
logState('(ℹ) BUILDING CLIENT')
await buildNuxt()
loader = createLoader()

logState('(ℹ) BUILDING BACKEND')
await buildWebpack()
Expand All @@ -71,6 +94,7 @@ async function init() {
await archiveProject()
}

clearInterval(loader)
logState('(ℹ) RELEASE HELPER')
await releaseHelper()

Expand All @@ -79,6 +103,7 @@ async function init() {
return true
} catch (error) {
clearInterval(loader)
console.error(`${colors.FgRed}%s${colors.Reset}`, `(❌) ${error.message}`)
console.error(`${colors.FgRed}%s${colors.Reset}`, '(❌) ERROR IN BUILD PROCESS')
console.error(`${colors.FgRed}%s${colors.Reset}`, '(❌) STOP EXECUTION OF CODE')
return false
Expand Down
18 changes: 18 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6577,6 +6577,11 @@ kind-of@^6.0.0, kind-of@^6.0.2:
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==

kleur@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"
integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==

klona@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/klona/-/klona-2.0.4.tgz#7bb1e3affb0cb8624547ef7e8f6708ea2e39dfc0"
Expand Down Expand Up @@ -8741,6 +8746,14 @@ promise-inflight@^1.0.1:
resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3"
integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM=

prompts@^2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.1.tgz#befd3b1195ba052f9fd2fde8a486c4e82ee77f61"
integrity sha512-EQyfIuO2hPDsX1L/blblV+H7I0knhgAd82cVneCwcdND9B8AuCDuRcBH6yIcG4dFzlOUqbazQqwGjx5xmsNLuQ==
dependencies:
kleur "^3.0.3"
sisteransi "^1.0.5"

proper-lockfile@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/proper-lockfile/-/proper-lockfile-4.1.2.tgz#c8b9de2af6b2f1601067f98e01ac66baa223141f"
Expand Down Expand Up @@ -9631,6 +9644,11 @@ sirv@^1.0.7:
mime "^2.3.1"
totalist "^1.0.0"

sisteransi@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed"
integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==

slash@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
Expand Down

0 comments on commit baceead

Please sign in to comment.