From 15bd37712b0c7a75b9b993f56cd4b0b1f3a36d9d Mon Sep 17 00:00:00 2001 From: Akash-bajpai Date: Fri, 20 Mar 2026 21:38:35 +0530 Subject: [PATCH 1/2] fix: convert require() to ESM imports in scripts and fix unused expressions Signed-off-by: Akash-bajpai --- scripts/tag.js | 10 ++------ scripts/updateRuntimeDependencies.js | 34 +++++++--------------------- 2 files changed, 10 insertions(+), 34 deletions(-) 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..6627926 100644 --- a/scripts/updateRuntimeDependencies.js +++ b/scripts/updateRuntimeDependencies.js @@ -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. @@ -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}'; From 02e845b9c5ed626eda5fba317aef74d212bfc4e6 Mon Sep 17 00:00:00 2001 From: Akash <92707808+Akash-bajpai@users.noreply.github.com> Date: Sun, 24 May 2026 08:48:04 +0530 Subject: [PATCH 2/2] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- scripts/updateRuntimeDependencies.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/updateRuntimeDependencies.js b/scripts/updateRuntimeDependencies.js index 6627926..784be80 100644 --- a/scripts/updateRuntimeDependencies.js +++ b/scripts/updateRuntimeDependencies.js @@ -11,7 +11,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { readFileSync, writeFileSync, existsSync, mkdirSync, rmSync } from 'fs'; +const { readFileSync, writeFileSync, existsSync, mkdirSync, rmSync } = require('fs'); function ensureDirSync(dirPath) { if (!existsSync(dirPath)) { mkdirSync(dirPath, { recursive: true }); }