Skip to content

Commit

Permalink
build: set up and document build and release scripts
Browse files Browse the repository at this point in the history
Since we have a build step now we must point the package.json file
reference to the dist folder and must explicitly list all files that we
want to be included in the npm tarball.

Also instructions for relasing a new version have not yet been
documented which is finally done here.
  • Loading branch information
ctavan committed Jan 20, 2020
1 parent c3de8bc commit 3660de9
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,5 +319,15 @@ Type `uuid --help` for usage details
npm test
```

## Releasing

Releases are supposed to be done from master, version bumping is automated through
[`standard-version`](https://github.com/conventional-changelog/standard-version):

```shell
npm run release -- --dry-run # verify output manually
npm run release # follow the instructions from the output of this command
```

----
Markdown generated from [README_js.md](README_js.md) by [![RunMD Logo](http://i.imgur.com/h0FVyzU.png)](https://github.com/broofa/runmd)
10 changes: 10 additions & 0 deletions README_js.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,13 @@ Type `uuid --help` for usage details
```shell
npm test
```

## Releasing

Releases are supposed to be done from master, version bumping is automated through
[`standard-version`](https://github.com/conventional-changelog/standard-version):

```shell
npm run release -- --dry-run # verify output manually
npm run release # follow the instructions from the output of this command
```
20 changes: 16 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@
],
"license": "MIT",
"bin": {
"uuid": "./bin/uuid"
"uuid": "dist/bin/uuid"
},
"sideEffects": false,
"main": "index.js",
"module": "esm-browser/index.js",
"main": "dist/index.js",
"module": "dist/esm-browser/index.js",
"files": [
"CHANGELOG.md",
"LICENSE.md",
"README.md",
"dist"
],
"devDependencies": {
"@babel/cli": "^7.8.3",
"@babel/core": "^7.8.3",
Expand Down Expand Up @@ -59,7 +65,7 @@
"docs": "( node --version | grep -q 'v12' ) && ( npm run build && runmd --output=README.md README_js.md )",
"docs:diff": "( node --version | grep -vq 'v12' ) || ( npm run docs && git diff --quiet README.md )",
"build": "./scripts/build.sh",
"release": "standard-version"
"release": "standard-version --no-verify"
},
"repository": {
"type": "git",
Expand All @@ -78,5 +84,11 @@
"*.{js,jsx}": [
"eslint --fix"
]
},
"standard-version": {
"scripts": {
"postchangelog": "prettier --write CHANGELOG.md",
"postcommit": "npm run build"
}
}
}
17 changes: 1 addition & 16 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
#!/bin/bash -eu

# Mostly taken from:
# https://github.com/date-fns/date-fns/blob/master/scripts/build/package.sh
# and
# https://medium.com/@iamstan/tips-for-writing-es-modules-in-node-js-96ec688615a4

# cd to the root dir
ROOT="$(pwd)/$(dirname "$0")/.."
cd "$ROOT" || exit 1

PATH="$(npm bin):$PATH"
# XXX: $PACKAGE_OUTPUT_PATH must be an absolute path!
DIR=${PACKAGE_OUTPUT_PATH:-"$ROOT/dist"}
DIR="$ROOT/dist"

# Clean up output dir
rm -rf "$DIR"
Expand All @@ -35,12 +29,3 @@ done

echo "Removing browser-specific files from esm-node"
rm -f "$DIR"/*-browser.js

# Copy basic files
for PATTERN in package.json \
CHANGELOG.md \
LICENSE.md \
README.md
do
cp -r "$PATTERN" "$DIR"
done

0 comments on commit 3660de9

Please sign in to comment.