Skip to content

Commit

Permalink
feat: export library version number
Browse files Browse the repository at this point in the history
  • Loading branch information
kswenson committed Feb 21, 2024
1 parent 185484c commit 09a4205
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
35 changes: 35 additions & 0 deletions bin/build-library.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# Developed with the help of ChatGPT

# Set the locale for the script to the C locale
export LC_ALL=C

# Path to your package.json file
PACKAGE_JSON_PATH="./package.json"

# Path to TypeScript command
TSC="./node_modules/.bin/tsc"

# Directory containing the files for replacement
DIST_DIR="./dist"

# Use grep with a regular expression to extract the version number
VERSION=$(grep '"version":' "$PACKAGE_JSON_PATH" | sed -E 's/.*"version": "([^"]+)",?/\1/')

if [ -z "$VERSION" ]; then
echo "Version number not found."
exit 1
fi

echo -e "\nBuilding the CommonJS library folder..."
$TSC -p tsconfig-cjs.json

echo -e "\nBuilding the ES6 library folder..."
$TSC -p tsconfig-esm.json

# Replace all occurrences of __PACKAGE_VERSION__ in files within the dist directory
echo -e "\nSetting the version number to '$VERSION'..."
find "$DIST_DIR" -type f -exec sed -i '' -e "s/__PACKAGE_VERSION__/$VERSION/g" {} +

echo -e "\nBuild complete\n"
4 changes: 2 additions & 2 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@concord-consortium/cloud-file-manager",
"description": "Wrapper for providing file management for web applications",
"author": "The Concord Consortium",
"version": "2.0.0-pre.2",
"version": "2.0.0-pre.3",
"repository": {
"type": "git",
"url": "https://github.com/concord-consortium/cloud-file-manager"
Expand Down Expand Up @@ -97,7 +97,7 @@
"clean": "rimraf dist",
"build": "npm run clean && NODE_ENV=development webpack",
"build:all": "npm run build:production && npm run build:library",
"build:library": "tsc -p tsconfig-cjs.json && tsc -p tsconfig-esm.json",
"build:library": "./bin/build-library.sh",
"build:production": "npm run clean && NODE_ENV=production webpack",
"build:codap": "npm run clean && cross-env-shell NODE_ENV=production dest=../codap/apps/dg/resources/cloud-file-manager codap=1 noGlobals=1 noMap=1 'webpack && mv $dest/js/app.js $dest/js/app.js.ignore'",
"build:codap:development": "npm run clean && cross-env-shell NODE_ENV=development dest=../codap/apps/dg/resources/cloud-file-manager codap=1 noGlobals=1 noMap=1 'webpack && mv $dest/js/app.js $dest/js/app.js.ignore'",
Expand Down

0 comments on commit 09a4205

Please sign in to comment.