Skip to content

Commit

Permalink
build: add manifest.json in third-party folders (#1325)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conrad Chan authored Feb 10, 2021
1 parent 2fcae6a commit b2e64d8
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 10 deletions.
18 changes: 18 additions & 0 deletions build/updateManifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env node
/* eslint-disable no-console */
const fs = require('fs');

// eslint-disable-next-line no-unused-vars
const [node, script, assetsVersion, libName, libVersion, manifestPath] = process.argv;

if (!(assetsVersion && libName && libVersion && manifestPath)) {
console.log('Missing required arguments');
process.exit(1);
}

const manifestStr = fs.readFileSync(manifestPath);
const parsedManifest = JSON.parse(manifestStr);
parsedManifest.version = assetsVersion;
parsedManifest.dependencies[libName] = libVersion;

fs.writeFileSync(manifestPath, JSON.stringify(parsedManifest, null, 4));
39 changes: 29 additions & 10 deletions build/upgrade_highlightjs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ build_custom_highlightjs() {
(cd ${HIGHLIGHTJS_SRC_DIR} && yarn install --frozen-lockfile && node tools/build -t browser ${HIGHLIGHTJS_LANGUAGES}) || return 1
}

bump_highlightjs_version() {
echo "-----------------------------------------------------------------------------------"
echo "Bumping highlightjs version in manifest.json"
echo "-----------------------------------------------------------------------------------"
HIGHLIGHTJS_VERSION=$(cd ${HIGHLIGHTJS_SRC_DIR} && ../build/current_version.sh) || return 1

echo "Bumping highlightjs version to ${HIGHLIGHTJS_VERSION}"
node build/updateManifest.js ${TEXT_STATIC_ASSETS_VERSION} highlightjs ${HIGHLIGHTJS_VERSION} ${TEXT_STATIC_ASSETS_PATH}/manifest.json || return 1
}

cleanup_custom_highlightjs() {
echo "-----------------------------------------------------------------------------------"
echo "Cleaning up highlightjs repo"
Expand All @@ -32,16 +42,22 @@ cleanup_custom_highlightjs() {
}

prepare_target_directory() {
echo "-----------------------------------------------------------------------------------"
echo "Creating target directory at $TEXT_STATIC_ASSETS_PATH..."
echo "-----------------------------------------------------------------------------------"

rm -rf ${TEXT_STATIC_ASSETS_PATH}
TEXT_CURRENT_ASSETS_VERSIONS=`ls ${TEXT_BASE_PATH} | sort -t "." -k1,1n -k2,2n -k3,3n | tail -1`

echo "Using base version from $TEXT_CURRENT_ASSETS_VERSIONS"
mkdir -v ${TEXT_STATIC_ASSETS_PATH}
cp -pv ${TEXT_BASE_PATH}/${TEXT_CURRENT_ASSETS_VERSIONS}/* ${TEXT_STATIC_ASSETS_PATH}/
if [ ! -d $TEXT_STATIC_ASSETS_PATH ]
then
echo "-----------------------------------------------------------------------------------"
echo "Creating target directory at $TEXT_STATIC_ASSETS_PATH..."
echo "-----------------------------------------------------------------------------------"

TEXT_CURRENT_ASSETS_VERSIONS=`ls ${TEXT_BASE_PATH} | sort -t "." -k1,1n -k2,2n -k3,3n | tail -1`

echo "Using base version from $TEXT_CURRENT_ASSETS_VERSIONS"
mkdir -v ${TEXT_STATIC_ASSETS_PATH}
cp -pv ${TEXT_BASE_PATH}/${TEXT_CURRENT_ASSETS_VERSIONS}/* ${TEXT_STATIC_ASSETS_PATH}/
else
echo "-----------------------------------------------------------------------------------"
echo "Directory already exists at $TEXT_STATIC_ASSETS_PATH, using it as is..."
echo "-----------------------------------------------------------------------------------"
fi
}

process_highlightjs_assets() {
Expand Down Expand Up @@ -69,6 +85,9 @@ upgrade_highlightjs() {
# Copy over built assets to target directory
process_highlightjs_assets || return 1

# Bump highlightjs version in package.json thirdparty-dependencies
bump_highlightjs_version || return 1

# Cleanup highlightjs
cleanup_custom_highlightjs || return 1

Expand Down
10 changes: 10 additions & 0 deletions src/third-party/text/0.114.0/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "text",
"description": "Third-party static assets used for the Preview text viewers",
"version": "0.114.0",
"dependencies": {
"highlightjs": "9.7.0",
"papaparse": "4.1.2",
"remarkable": "1.7.1"
}
}

0 comments on commit b2e64d8

Please sign in to comment.