diff --git a/package.json b/package.json index 4800204..addaabb 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,8 @@ "build:config": "yarn workspace @oak-network/config build", "build:adapter": "yarn workspace @oak-network/adapter build", "build:rest": "yarn workspace @oak-network/types build && yarn workspace @oak-network/api-augment build && yarn workspace @oak-network/sdk build", - "build": "yarn run build:config && yarn run build:adapter && yarn run build:rest", - "postbuild": "scripts/package-setup", + "build": "yarn run build:config && yarn run build:adapter && yarn run build:rest && yarn run postbuild", + "postbuild": "node scripts/package-setup.js", "clean": "yarn workspaces foreach --all run clean", "test": "yarn build && jest --verbose --forceExit --runInBand ./test/functional", "test:sdk": "yarn build && jest --verbose --runInBand ./test/sdk", diff --git a/scripts/package-setup b/scripts/package-setup.js similarity index 78% rename from scripts/package-setup rename to scripts/package-setup.js index d5da199..230e7ba 100755 --- a/scripts/package-setup +++ b/scripts/package-setup.js @@ -1,13 +1,12 @@ #!/usr/bin/env node const fs = require("fs"); - process.chdir("packages"); -const dirs = fs.readdirSync(".") -process.chdir(`api-augment/build`); -const aaPkg = JSON.parse(fs.readFileSync('../package.json')); +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"; @@ -17,8 +16,7 @@ fs.copyFileSync("../../../templates/index.cjs", "./index.cjs"); process.chdir("../.."); process.chdir(`types/build`); -const tPkg = JSON.parse(fs.readFileSync('../package.json')); - +const tPkg = JSON.parse(fs.readFileSync("../package.json")); tPkg.scripts = {}; tPkg.main = "./index.js"; tPkg.types = "./index.d.ts"; @@ -26,8 +24,7 @@ fs.writeFileSync("./package.json", JSON.stringify(tPkg, null, 2)); process.chdir("../.."); process.chdir(`config/build`); -const configPkg = JSON.parse(fs.readFileSync('../package.json')); - +const configPkg = JSON.parse(fs.readFileSync("../package.json")); configPkg.scripts = {}; configPkg.main = "./index.js"; configPkg.types = "./index.d.ts"; @@ -36,8 +33,7 @@ fs.copyFileSync("../../../templates/index.cjs", "./index.cjs"); process.chdir("../.."); process.chdir(`sdk/build`); -const sdkPkg = JSON.parse(fs.readFileSync('../package.json')); - +const sdkPkg = JSON.parse(fs.readFileSync("../package.json")); sdkPkg.scripts = {}; sdkPkg.main = "./index.js"; sdkPkg.types = "./index.d.ts"; @@ -46,8 +42,7 @@ fs.copyFileSync("../../../templates/index.cjs", "./index.cjs"); process.chdir("../.."); process.chdir(`adapter/build`); -const adapterPkg = JSON.parse(fs.readFileSync('../package.json')); - +const adapterPkg = JSON.parse(fs.readFileSync("../package.json")); adapterPkg.scripts = {}; adapterPkg.main = "./index.js"; adapterPkg.types = "./index.d.ts";