Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions scripts/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
34 changes: 8 additions & 26 deletions scripts/updateRuntimeDependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const { readFileSync, writeFileSync, existsSync, mkdirSync, rmSync } = require('fs');
const tar = require('tar');
const path = require('path');
import { readFileSync, writeFileSync, existsSync, mkdirSync, rmSync } from 'fs';

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.
Expand All @@ -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}';
Expand Down