Skip to content

Commit

Permalink
Merge pull request #1060 from garden-io/update-ansi-escapes
Browse files Browse the repository at this point in the history
fix: update ansi-escapes to fix spinner issue on macOS Terminal.app
  • Loading branch information
eysi09 committed Aug 1, 2019
2 parents 1186a7f + be9f688 commit 982ad83
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
30 changes: 20 additions & 10 deletions bin/release.ts
Expand Up @@ -6,14 +6,13 @@ import * as inquirer from "inquirer"
import chalk from "chalk"
import parseArgs = require("minimist")
import deline = require("deline")
import { join, resolve } from "path"
import { resolve } from "path"
const replace = require("replace-in-file")

type ReleaseType = "minor" | "patch" | "preminor" | "prepatch" | "prerelease"
const RELEASE_TYPES = ["minor", "patch", "preminor", "prepatch", "prerelease"]

const gardenRoot = resolve(__dirname, "..")
const gardenServiceRoot = join(gardenRoot, "garden-service")

/**
* Performs the following steps to prepare for a release:
Expand Down Expand Up @@ -45,11 +44,10 @@ async function release() {
if (!RELEASE_TYPES.includes(releaseType)) {
throw new Error(`Invalid release type ${releaseType}, available types are: ${RELEASE_TYPES.join(", ")}`)
}

// Update package.json versions
await execa.stdout("lerna", [
await execa("node_modules/.bin/lerna", [
"version", "--no-git-tag-version", "--yes", releaseType,
], { cwd: gardenServiceRoot })
], { cwd: gardenRoot })

// Read the version from garden-service/package.json after setting it (rather than parsing the lerna output)
const version = "v" + require("../garden-service/package.json").version
Expand Down Expand Up @@ -92,12 +90,24 @@ async function release() {
return
}

// Lerna doesn't update package-lock.json so we need the following workaround.
// See this issue for details: https://github.com/lerna/lerna/issues/1415
// console.log("Updating package-lock.json for all packages")
await execa("node_modules/.bin/lerna", ["clean", "--yes"], { cwd: gardenRoot })
await execa("node_modules/.bin/lerna", [
"bootstrap",
"--ignore-scripts",
"--",
"--package-lock-only",
"--no-audit",
], { cwd: gardenRoot })

// Pull remote tags
console.log("Pulling remote tags...")
await execa("git", ["fetch", "origin", "--tags", "-f"], { cwd: gardenRoot })

// Verify tag doesn't exist
const tags = (await execa.stdout("git", ["tag"], { cwd: gardenRoot })).split("\n")
const tags = (await execa("git", ["tag"], { cwd: gardenRoot })).stdout.split("\n")
if (tags.includes(version) && !force) {
await rollBack()
throw new Error(`Tag ${version} already exists. Use "--force" to override.`)
Expand Down Expand Up @@ -190,7 +200,7 @@ async function createTag(version: string, force: boolean) {
if (force) {
createTagArgs.push("-f")
}
await execa.stdout("git", createTagArgs, { cwd: gardenRoot })
await execa("git", createTagArgs, { cwd: gardenRoot })

// Push the tag
const pushTagArgs = ["push", "origin", version, "--no-verify"]
Expand All @@ -213,7 +223,7 @@ async function updateExampleLinks(version: string) {
async function rollBack() {
// Undo any file changes. This is safe since we know the branch is clean.
console.log("Undoing file changes")
await execa.stdout("git", ["checkout", "."], { cwd: gardenRoot })
await execa("git", ["checkout", "."], { cwd: gardenRoot })
}

async function prompt(version: string): Promise<boolean> {
Expand Down Expand Up @@ -246,12 +256,12 @@ async function stripPrereleaseTags(tags: string[], version: string) {
// E.g., if the current tag is v0.5.0-2 and we're releasing v0.9.0-2, we remove it.
// If the current tag is v0.9.0-0 and we're releasing v0.9.0-2, we keep it.
if (!semver.prerelease(version) || semver.diff(version, tag) !== "prerelease") {
await execa.stdout("git", ["tag", "-d", tag])
await execa("git", ["tag", "-d", tag])
}
}

// We also need to remove the "edge" tag
await execa.stdout("git", ["tag", "-d", "edge"])
await execa("git", ["tag", "-d", "edge"])
}

(async () => {
Expand Down
2 changes: 1 addition & 1 deletion dashboard/package-lock.json

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

15 changes: 11 additions & 4 deletions garden-service/package-lock.json

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

2 changes: 1 addition & 1 deletion garden-service/package.json
Expand Up @@ -27,7 +27,7 @@
"@kubernetes/client-node": "git+https://github.com/garden-io/javascript.git#client-cert-auth",
"JSONStream": "^1.3.5",
"analytics-node": "3.3.0",
"ansi-escapes": "^4.1.0",
"ansi-escapes": "^4.2.1",
"archiver": "^3.0.0",
"async-exit-hook": "^2.0.1",
"async-lock": "^1.2.0",
Expand Down

0 comments on commit 982ad83

Please sign in to comment.