Skip to content

Commit

Permalink
make tgz more dynamic
Browse files Browse the repository at this point in the history
Signed-off-by: zFernand0 <[email protected]>
  • Loading branch information
zFernand0 committed Feb 2, 2024
1 parent 2fe0345 commit eb2a830
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions scripts/bundleTgz.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const rootDir = path.join(__dirname, "..");
process.chdir(rootDir);
const cliPkgDir = path.join(process.cwd(), "packages", "cli");
const pkgJsonFile = path.join(cliPkgDir, "package.json");
const tempPkgJson = JSON.parse(fsE.readFileSync(pkgJsonFile, "utf-8"));
const npmInstallCmd = "npm install --ignore-scripts --workspaces=false";
const execCmd = (cmd) => childProcess.execSync(cmd, { cwd: cliPkgDir, stdio: "inherit" });
fsE.mkdirpSync("dist");

Expand All @@ -29,7 +31,9 @@ const cleanUp = () => {
if (fs.existsSync(path.join(cliPkgDir, "node_modules_old"))) {
fsE.renameSync(path.join(cliPkgDir, "node_modules_old"), path.join(cliPkgDir, "node_modules"));
}
fsE.renameSync(pkgJsonFile + ".bak", pkgJsonFile);
if (fs.existsSync(pkgJsonFile + ".bak")) {
fsE.renameSync(pkgJsonFile + ".bak", pkgJsonFile);
}
fs.rmSync(path.join(cliPkgDir, "npm-shrinkwrap.json"), { force: true });
fs.rmSync(path.join(rootDir, "npm-shrinkwrap.json"), { force: true });
}
Expand All @@ -46,8 +50,9 @@ fsE.copyFileSync(pkgJsonFile, pkgJsonFile + ".bak");
try {
// Install node_modules directly inside packages/cli
execCmd("npm run preshrinkwrap");
execCmd("npm install --ignore-scripts --workspaces=false ../../dist/zowe-cics-for-zowe-sdk-5.0.3.tgz --save-exact");
execCmd("npm install --ignore-scripts --workspaces=false");

execCmd(`${npmInstallCmd} ${path.relative(__dirname, "../dist/zowe-cics-for-zowe-sdk-" + tempPkgJson.version + ".tgz")}`);
execCmd(npmInstallCmd);
for (const zowePkgDir of fsE.readdirSync(path.join(cliPkgDir, "node_modules", "@zowe"))) {
const srcDir = path.join("node_modules", "@zowe", zowePkgDir);
const destDir = path.join(cliPkgDir, srcDir);
Expand All @@ -66,4 +71,5 @@ try {
// execCmd("npm pack --pack-destination=../../dist");
} catch (err) {
cleanUp();
throw err;
}

0 comments on commit eb2a830

Please sign in to comment.