diff --git a/scripts/tag.js b/scripts/tag.js index 01fc4d1..f2e1f28 100755 --- a/scripts/tag.js +++ b/scripts/tag.js @@ -12,18 +12,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -'use strict'; - -const semver = require('semver'); +import semver from "semver"; const targetVersion = process.argv[2]; - if (!semver.valid(targetVersion)) { console.error(`Error: the version "${targetVersion}" is invalid!`); process.exit(1); } - const prerelease = semver.prerelease(targetVersion); -const tag = prerelease ? 'unstable' : 'latest'; - +const tag = prerelease ? "unstable" : "latest"; console.log(`::set-output name=tag::--tag=${tag}`); diff --git a/scripts/updateRuntimeDependencies.js b/scripts/updateRuntimeDependencies.js index 4c63a7d..784be80 100644 --- a/scripts/updateRuntimeDependencies.js +++ b/scripts/updateRuntimeDependencies.js @@ -12,17 +12,13 @@ * limitations under the License. */ const { readFileSync, writeFileSync, existsSync, mkdirSync, rmSync } = require('fs'); -const tar = require('tar'); -const path = require('path'); -function ensureDirSync(path) { - !existsSync(path) && mkdirSync(path, { recursive: true }); +function ensureDirSync(dirPath) { + if (!existsSync(dirPath)) { mkdirSync(dirPath, { recursive: true }); } } - -function removeSync(path) { - rmSync(path, { recursive: true, force: true }); +function removeSync(dirPath) { + rmSync(dirPath, { recursive: true, force: true }); } - const HEADER = `/* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,32 +32,18 @@ const HEADER = `/* * See the License for the specific language governing permissions and * limitations under the License. */ - /* eslint-disable quotes */ // file generated by ./scripts/updateRuntimeDependencies.js `; - -/** - * Package the TypeScript declarations for dayjs, jsonpath and SmartLegalContract - * These are needed at runtime to compile user TypeScript code and template logic to JS - */ -const dayjs = readFileSync('./node_modules/dayjs/index.d.ts').toString( - 'base64' -); -const jsonpath = readFileSync( - './node_modules/@types/jsonpath/index.d.ts' -).toString('base64'); -const smartLegalContract = readFileSync( - './src/slc/SmartLegalContract.d.ts' -).toString('base64'); - +const dayjs = readFileSync('./node_modules/dayjs/index.d.ts').toString('base64'); +const jsonpath = readFileSync('./node_modules/@types/jsonpath/index.d.ts').toString('base64'); +const smartLegalContract = readFileSync('./src/slc/SmartLegalContract.d.ts').toString('base64'); removeSync('./src/runtime/'); ensureDirSync('./src/runtime/'); writeFileSync( './src/runtime/declarations.ts', ` ${HEADER} - export const DAYJS_BASE64 = '${dayjs}'; export const JSONPATH_BASE64 = '${jsonpath}'; export const SMART_LEGAL_CONTRACT_BASE64 = '${smartLegalContract}';