From fff4fb7593a04acf46829372203059f02b6b7830 Mon Sep 17 00:00:00 2001 From: chrisli30 Date: Tue, 5 Dec 2023 17:36:41 -0800 Subject: [PATCH 1/2] docs(changeset): SDK and adapter upgrades with automationPrice support --- .changeset/shaggy-ladybugs-vanish.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/shaggy-ladybugs-vanish.md diff --git a/.changeset/shaggy-ladybugs-vanish.md b/.changeset/shaggy-ladybugs-vanish.md new file mode 100644 index 0000000..5724968 --- /dev/null +++ b/.changeset/shaggy-ladybugs-vanish.md @@ -0,0 +1,6 @@ +--- +"@oak-network/adapter": minor +"@oak-network/sdk": minor +--- + +SDK and adapter upgrades with automationPrice support From cd7587f6ef9f793f868031646e439f7bed971c7b Mon Sep 17 00:00:00 2001 From: chrisli30 Date: Tue, 5 Dec 2023 17:39:38 -0800 Subject: [PATCH 2/2] Update package-setup.js --- scripts/package-setup.js | 92 +++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 49 deletions(-) diff --git a/scripts/package-setup.js b/scripts/package-setup.js index 230e7ba..0571218 100755 --- a/scripts/package-setup.js +++ b/scripts/package-setup.js @@ -1,52 +1,46 @@ #!/usr/bin/env node const fs = require("fs"); -process.chdir("packages"); - -console.log("postbuild script starts: setting up build folders of packages ..."); - -process.chdir(`api-augment/build`); -const aaPkg = JSON.parse(fs.readFileSync("../package.json")); -aaPkg.scripts = {}; -aaPkg.main = "./index.cjs"; -aaPkg.module = "./index.js"; -aaPkg.types = "./index.d.ts"; -fs.writeFileSync("./package.json", JSON.stringify(aaPkg, null, 2)); -fs.copyFileSync("../../../templates/index.cjs", "./index.cjs"); - -process.chdir("../.."); -process.chdir(`types/build`); -const tPkg = JSON.parse(fs.readFileSync("../package.json")); -tPkg.scripts = {}; -tPkg.main = "./index.js"; -tPkg.types = "./index.d.ts"; -fs.writeFileSync("./package.json", JSON.stringify(tPkg, null, 2)); - -process.chdir("../.."); -process.chdir(`config/build`); -const configPkg = JSON.parse(fs.readFileSync("../package.json")); -configPkg.scripts = {}; -configPkg.main = "./index.js"; -configPkg.types = "./index.d.ts"; -fs.writeFileSync("./package.json", JSON.stringify(configPkg, null, 2)); -fs.copyFileSync("../../../templates/index.cjs", "./index.cjs"); - -process.chdir("../.."); -process.chdir(`sdk/build`); -const sdkPkg = JSON.parse(fs.readFileSync("../package.json")); -sdkPkg.scripts = {}; -sdkPkg.main = "./index.js"; -sdkPkg.types = "./index.d.ts"; -fs.writeFileSync("./package.json", JSON.stringify(sdkPkg, null, 2)); -fs.copyFileSync("../../../templates/index.cjs", "./index.cjs"); - -process.chdir("../.."); -process.chdir(`adapter/build`); -const adapterPkg = JSON.parse(fs.readFileSync("../package.json")); -adapterPkg.scripts = {}; -adapterPkg.main = "./index.js"; -adapterPkg.types = "./index.d.ts"; -fs.writeFileSync("./package.json", JSON.stringify(adapterPkg, null, 2)); -fs.copyFileSync("../../../templates/index.cjs", "./index.cjs"); - -process.chdir("../.."); +console.log("Postbuild script starts: setting up build folders of packages..."); + +/* eslint-disable sort-keys */ +const packages = [ + { name: "api-augment", main: "./index.cjs", module: "./index.js", types: "./index.d.ts", copyFile: true }, + { name: "types", main: "./index.js", module: null, types: "./index.d.ts", copyFile: false }, + { name: "config", main: "./index.js", module: null, types: "./index.d.ts", copyFile: true }, + { name: "sdk", main: "./index.js", module: null, types: "./index.d.ts", copyFile: true }, + { name: "adapter", main: "./index.js", module: null, types: "./index.d.ts", copyFile: true }, +]; + +packages.forEach((pkg) => { + const pkgPath = `packages/${pkg.name}/build`; + process.chdir(pkgPath); + + const packageJson = JSON.parse(fs.readFileSync("../package.json")); + packageJson.scripts = {}; + packageJson.main = pkg.main; + if (pkg.module) packageJson.module = pkg.module; + packageJson.types = pkg.types; + + // Remove the 'workspace:' protocol if exists in dependencies + // Only config and adapter packages are depended by others + if (packageJson.dependencies && packageJson.dependencies["@oak-network/config"]) { + const version = packageJson.dependencies["@oak-network/config"].replace("workspace:", ""); + packageJson.dependencies["@oak-network/config"] = version; + } + + if (packageJson.dependencies && packageJson.dependencies["@oak-network/adapter"]) { + const version = packageJson.dependencies["@oak-network/adapter"].replace("workspace:", ""); + packageJson.dependencies["@oak-network/adapter"] = version; + } + + fs.writeFileSync("./package.json", JSON.stringify(packageJson, null, 2)); + + if (pkg.copyFile) { + fs.copyFileSync("../../../templates/index.cjs", "./index.cjs"); + } + + process.chdir("../../.."); // Going back to the root directory +}); + +console.log("Postbuild setup completed.");