Skip to content

Commit

Permalink
chore: simplify build flows
Browse files Browse the repository at this point in the history
This removes the separate "dist" build flow, and simplifies the
structure of the build output. Incidentally, this fixes the issues
we had with `npm pack`, so we no longer need `yarn` in the publishing
flow, and that also fixes issues I found when working on making a
`homebrew` tap.
  • Loading branch information
edvald committed Jun 18, 2018
1 parent ab285c6 commit 74bdead
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 3,734 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ node_modules

# Runtime files
.garden
.garden-version
tmp/

# TS cache on the CI
Expand Down
9 changes: 0 additions & 9 deletions .release-it.json

This file was deleted.

5 changes: 1 addition & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ automatically checked during CI. You can run the check with `npm run check-licen
### Release process

We use [Lerna](https://github.com/lerna/lerna) to automate the release process.

To set it up, first make sure you have [yarn](https://yarnpkg.com/lang/en/docs/install/#mac-stable) installed
(we rely on `yarn` for publishing because of some issues with `npm`) and you're logged in to yarn (`yarn login`).
Then install lerna using `npm install -g lerna` or `yarn global add lerna`.
Install lerna using `npm install -g lerna`.

Depending on what type of release you're making, you can use one of the following commands:

Expand Down
2 changes: 1 addition & 1 deletion bin/bootstrap-osx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

# install/update homebrew dependencies
BREW_DEPS="cmake git kubectl kubernetes-helm stern rsync watchman icu4c pkg-config yarn"
BREW_DEPS="cmake git kubectl kubernetes-helm stern rsync watchman icu4c pkg-config"

brew update
brew install ${BREW_DEPS}
Expand Down
2 changes: 1 addition & 1 deletion bin/garden
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

garden_root=$(cd `dirname $0` && cd $(git rev-parse --show-toplevel) && pwd)
node ${garden_root}/build/static/bin/garden.js "$@"
node ${garden_root}/static/bin/garden "$@"
2 changes: 1 addition & 1 deletion bin/garden-debug
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

garden_root=$(cd `dirname $0` && cd $(git rev-parse --show-toplevel) && pwd)
node --inspect ${garden_root}/build/static/bin/garden.js "$@"
node --inspect ${garden_root}/static/bin/garden "$@"
35 changes: 8 additions & 27 deletions gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { generateDocs } from "./src/docs/generate"
const gulp = require("gulp")
const cached = require("gulp-cached")
const checkLicense = require("gulp-license-check")
const excludeGitIgnore = require("gulp-exclude-gitignore")
// const debug = require("gulp-debug")
// const exec = require("gulp-exec")
const pegjs = require("gulp-pegjs")
Expand All @@ -30,21 +29,16 @@ const tsSources = "src/**/*.ts"
const testTsSources = "test/**/*.ts"
const pegjsSources = "src/*.pegjs"

const staticFiles = ["package.json", "package-lock.json", "static/**/*", ".snyk"]
const licenseHeaderPath = "static/license-header.txt"

let destDir = "build"
const destDir = "build"

class TaskError extends Error {
toString() {
return this.message
}
}

function setDestDir(path) {
destDir = path
}

const children: ChildProcess[] = []

process.env.FORCE_COLOR = "true"
Expand Down Expand Up @@ -80,7 +74,7 @@ process.on("SIGINT", die)
process.on("SIGTERM", die)

gulp.task("add-version-files", (cb) => {
const gardenBinPath = join(destDir, "static", "bin", "garden")
const gardenBinPath = join("static", "bin", "garden")
const proc = _spawn("node", [gardenBinPath, "scan", "--output=json"])

proc.on("error", err => cb(err))
Expand All @@ -105,7 +99,7 @@ gulp.task("add-version-files", (cb) => {

for (const module of <any>results.result) {
const relPath = relative(__dirname, module.path)
const versionFilePath = join(__dirname, destDir, relPath, ".garden-version")
const versionFilePath = join(__dirname, relPath, ".garden-version")
writeFileSync(versionFilePath, JSON.stringify(module.version))
}

Expand Down Expand Up @@ -135,31 +129,20 @@ gulp.task("mocha", (cb) =>
gulp.task("pegjs", () =>
gulp.src(pegjsSources)
.pipe(pegjs({ format: "commonjs" }))
.pipe(gulp.dest(join(destDir, "src"))),
.pipe(gulp.dest(destDir)),
)

gulp.task("pegjs-watch", () =>
gulp.watch(pegjsSources, gulp.parallel("pegjs")),
)

gulp.task("static", () => {
return gulp.src(staticFiles, { base: "./" })
.pipe(excludeGitIgnore())
.pipe(cached("static"))
.pipe(gulp.dest(destDir))
})

gulp.task("static-watch", () => {
return gulp.watch(staticFiles, gulp.series("static", "add-version-files"))
})

gulp.task("tsc", () =>
tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject(reporter))
.on("error", die)
.pipe(sourcemaps.write())
.pipe(gulp.dest(join(destDir, "src"))),
.pipe(gulp.dest(destDir)),
)

gulp.task("tsc-watch", () =>
Expand All @@ -168,7 +151,7 @@ gulp.task("tsc-watch", () =>
"--pretty",
"--declaration",
"-p", __dirname,
"--outDir", join(destDir, "src"),
"--outDir", destDir,
],
{ stdio: "inherit" },
),
Expand Down Expand Up @@ -211,14 +194,12 @@ gulp.task("watch-code", () => {

gulp.task("lint", gulp.parallel("check-licenses", "tslint", "tslint-tests", "tsfmt"))
gulp.task("build", gulp.series(
gulp.parallel("generate-docs", "pegjs", "static", "tsc"),
gulp.parallel("generate-docs", "pegjs", "tsc"),
"add-version-files",
))
gulp.task("dist", gulp.series((done) => { setDestDir("dist"); done() }, "lint", "build"))
gulp.task("test", gulp.parallel("build", "lint", "mocha"))
gulp.task("watch", gulp.series(
"build",
gulp.parallel("pegjs-watch", "static-watch", "tsc-watch", "watch-code"),
gulp.parallel("pegjs-watch", "tsc-watch", "watch-code"),
))
gulp.task("watch-dist", gulp.series((done) => { setDestDir("dist"); done() }, "watch"))
gulp.task("default", gulp.series("watch"))
2 changes: 0 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"lerna": "2.11.0",
"npmClient": "yarn",
"command": {
"publish": {
"message": "chore(release): publish %s"
Expand Down
Loading

0 comments on commit 74bdead

Please sign in to comment.