Skip to content

Commit

Permalink
review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
wardpeet committed Aug 5, 2021
1 parent eca9cc6 commit 4cfcb9c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
"publish-preminor": "node scripts/check-publish-access && node scripts/clear-package-dir preminor --verbose && lerna publish preminor --pre-dist-tag=next --preid=next --force-publish --allow-branch=master --message=\"chore(release): Publish next pre-minor\"",
"publish-rc": "node scripts/check-publish-access && node scripts/clear-package-dir prerelease --verbose && lerna publish prerelease --pre-dist-tag=rc --preid=rc --message=\"chore(release): Publish rc\"",
"publish-release": "node scripts/check-publish-access && node scripts/clear-package-dir patch --verbose && lerna publish patch",
"publish-v4": "node scripts/release-cli.js publish v4",
"publish-premajor": "node scripts/release-next-major.js publish",
"test": "npm-run-all -s lint jest test:peril",
"test:coverage": "jest --coverage",
"test:integration": "jest --config=integration-tests/jest.config.js",
Expand Down
27 changes: 19 additions & 8 deletions scripts/release-cli.js → scripts/release-next-major.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ const { spawn, execSync } = require(`child_process`)
const yargs = require(`yargs`)
const glob = require(`glob`)

const gatsbyPKG = require(`../packages/gatsby/package.json`)
const nextMajor = String(Number(gatsbyPKG.version.match(/[^.]+/)[0]) + 1)

const argv = yargs
.command(`publish v4`, `Publishes a v4 alpha release`)
.command(`publish`, `Publishes a next-major alpha release`)
.option(`registry`, {
default: `https://registry.npmjs.org`,
describe: `The NPM registry to publish to`,
Expand Down Expand Up @@ -55,10 +58,11 @@ function promiseSpawn(command, args, options) {
})
}

const patchFiles = glob.sync(`patches/v4/*.patch`, {
const patchFiles = glob.sync(`patches/v${nextMajor}/*.patch`, {
cwd: path.join(__dirname, `..`),
})
let commitCreated = false
let currentGitHash = null

;(async () => {
try {
Expand All @@ -72,8 +76,8 @@ let commitCreated = false
)

const bumpType = `major`
const tagName = `alpha-v4`
const preId = `alpha-v4`
const tagName = `alpha-v${nextMajor}`
const preId = `alpha-v${nextMajor}`

try {
await Promise.all([
Expand Down Expand Up @@ -114,6 +118,13 @@ let commitCreated = false
})

console.log(`=== COMMITING PATCH FILES ===`)
currentGitHash = execSync(`git rev-parse HEAD`)
.toString()
.replace(/[\r\n]/, ``)

if (!currentGitHash) {
throw new Error(`The current commit hash could not be determined.`)
}
try {
await promiseSpawn(
`git`,
Expand All @@ -128,10 +139,10 @@ let commitCreated = false
// no catch
}

const COMPILER_OPTIONS = `GATSBY_MAJOR=4`
const COMPILER_OPTIONS = `GATSBY_MAJOR=${nextMajor}`

console.log(` `)
console.log(`=== BUILDING V4 ALPHA ===`)
console.log(`=== BUILDING V${nextMajor} ALPHA ===`)
await promiseSpawn(`yarn`, [`bootstrap`], {
shell: true,
env: {
Expand All @@ -141,7 +152,7 @@ let commitCreated = false
})

console.log(` `)
console.log(`=== PUBLISHING V4 ALPHA ===`)
console.log(`=== PUBLISHING V${nextMajor} ALPHA ===`)
await promiseSpawn(
process.execPath,
[
Expand Down Expand Up @@ -174,7 +185,7 @@ let commitCreated = false
if (commitCreated) {
console.log(`REMOVING PATCH COMMIT`)
try {
await promiseSpawn(`git`, [`reset`, `--hard`, `HEAD~1`], {
await promiseSpawn(`git`, [`reset`, `--hard`, currentGitHash], {
cwd: path.resolve(__dirname, `../`),
stdio: [`inherit`, `inherit`, `inherit`],
})
Expand Down
3 changes: 3 additions & 0 deletions types/gatsby-monorepo/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# gatsby-monorepo types package

This is a dummy package so typescript uses global.d.ts for all packages in the monorepo. If there is a better way to do it, please change it.

0 comments on commit 4cfcb9c

Please sign in to comment.