Add a build script to help create the package.
authorRobert Sesek <rsesek@bluestatic.org>
Mon, 23 Mar 2020 04:10:55 +0000 (00:10 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Mon, 23 Mar 2020 04:18:58 +0000 (00:18 -0400)
NPM "helpfully" uses .gitignore, which excludes dist/, but dist/ needs
to make it into the NPM tarball. Rewrite a line in the copied
package.json to explicitly include the dist/ files.

build.sh [new file with mode: 0755]
package.json

diff --git a/build.sh b/build.sh
new file mode 100755 (executable)
index 0000000..c8d5a53
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+# Copyright 2020 Blue Static <https://www.bluestatic.org>
+# This program is free software licensed under the GNU General Public License,
+# version 3.0. The full text of the license can be found in LICENSE.txt.
+# SPDX-License-Identifier: GPL-3.0-only
+
+OUTDIR=./dist
+
+set -ex
+
+# Clean.
+rm -rf $OUTDIR
+
+# Compile.
+tsc
+
+# Drop tests from the compiled output.
+find $OUTDIR -type f -name '*.test.*' -exec rm {} +
+
+# "Preprocess" the dist package.json.
+cp ./package.json $OUTDIR
+sed -i '' -e s@\"dist/@\"@ $OUTDIR/package.json
index a1aaab5352efc77e31f297028b5433d6ae1d6f3b..71f498c2139e65c7f029a85addefd6c01e5c513e 100644 (file)
@@ -1,20 +1,23 @@
 {
   "name": "ustaxlib",
-  "version": "0.1.0",
+  "version": "1.0.0",
   "description": "A library for modeling individual US tax returns.",
   "scripts": {
     "dev": "jest --watch",
     "test": "jest",
     "check": "tsc --noEmit",
     "debug": "node --inspect-brk --stack-trace-limit=1000 node_modules/.bin/jest --coverage=false",
-    "prepublish": "tsc",
-    "build": "tsc && cp package.json dist"
+    "prepare": "./build.sh"
   },
   "author": "Robert Sesek",
   "license": "GPL-3.0-only",
   "dependencies": {
     "typescript": "^3.8.2"
   },
+  "files": [
+    "dist/**/*",
+    "src/**/*"
+  ],
   "devDependencies": {
     "@types/jest": "^25.1.2",
     "jest": "^25.1.0",