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 5eef34c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 20 deletions.
12 changes: 12 additions & 0 deletions README.md
Expand Up @@ -319,5 +319,17 @@ 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
npm run release
git push --follow-tags origin master
npm publish
```

----
Markdown generated from [README_js.md](README_js.md) by [![RunMD Logo](http://i.imgur.com/h0FVyzU.png)](https://github.com/broofa/runmd)
12 changes: 12 additions & 0 deletions README_js.md
Expand Up @@ -297,3 +297,15 @@ 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
npm run release
git push --follow-tags origin master
npm publish
```
20 changes: 16 additions & 4 deletions package.json
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",
"posttag": "npm run build"
}
}
}
17 changes: 1 addition & 16 deletions scripts/build.sh
@@ -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 5eef34c

Please sign in to comment.