Skip to content

Commit

Permalink
Merge pull request #93 from zowe/test-cli
Browse files Browse the repository at this point in the history
add scope to publishConfig
  • Loading branch information
zFernand0 authored Feb 6, 2024
2 parents 5bc9f86 + e7b8b64 commit d12f211
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 34 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"private": true,
"version": "4.0.8",
"publishConfig": {
"registry": "https://zowe.jfrog.io/zowe/api/npm/npm-local-release/"
"registry": "https://zowe.jfrog.io/zowe/api/npm/npm-local-release/",
"scope": "@zowe"
},
"repository": "https://github.com/zowe/cics-for-zowe-client",
"workspaces": [
Expand Down
5 changes: 3 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"lib"
],
"publishConfig": {
"registry": "https://zowe.jfrog.io/zowe/api/npm/npm-local-release/"
"registry": "https://zowe.jfrog.io/zowe/api/npm/npm-local-release/",
"scope": "@zowe"
},
"scripts": {
"build": "tsc --pretty && npm run checkTestsCompile && npm run madge",
Expand Down Expand Up @@ -62,4 +63,4 @@
"@zowe/cli": "~6.40.18",
"@zowe/imperative": "~4.18.17"
}
}
}
5 changes: 3 additions & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"lib"
],
"publishConfig": {
"registry": "https://zowe.jfrog.io/zowe/api/npm/npm-local-release/"
"registry": "https://zowe.jfrog.io/zowe/api/npm/npm-local-release/",
"scope": "@zowe"
},
"scripts": {
"build": "tsc --pretty && npm run checkTestsCompile && npm run madge",
Expand All @@ -48,4 +49,4 @@
"peerDependencies": {
"@zowe/imperative": "~4.18.17"
}
}
}
4 changes: 2 additions & 2 deletions scripts/bundleTgz.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ fsE.copyFileSync(pkgJsonFile, pkgJsonFile + ".bak");
try {
// Install node_modules directly inside packages/cli
execCmd("npm run preshrinkwrap");

execCmd(`${npmInstallCmd} ${path.relative(__dirname, "../dist/zowe-cics-for-zowe-sdk-" + tempPkgJson.version + ".tgz")}`);
const sdkTgzPath = path.relative(__dirname, "../dist/zowe-cics-for-zowe-sdk-" + tempPkgJson.version + ".tgz");
execCmd(`${npmInstallCmd} ${sdkTgzPath}`);
execCmd(npmInstallCmd);
for (const zowePkgDir of fsE.readdirSync(path.join(cliPkgDir, "node_modules", "@zowe"))) {
const srcDir = path.join("node_modules", "@zowe", zowePkgDir);
Expand Down
58 changes: 31 additions & 27 deletions scripts/rewriteShrinkwrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@ if (!fs.existsSync(rootShrinkwrapFile)) {
// Remove "file:" links from shrinkwrap
const shrinkwrap = JSON.parse(fs.readFileSync(rootShrinkwrapFile, "utf-8"));
for (const [k, v] of Object.entries(shrinkwrap.packages)) {
if (v.link) {
delete shrinkwrap.packages[k];
}
if (v.link) {
delete shrinkwrap.packages[k];
}
}
fs.writeFileSync(cliShrinkwrapFile, JSON.stringify(shrinkwrap, null, 2));

// Build deduped shrinkwrap for @zowe/cics-for-zowe-cli
const zoweRegistry = require(cliDir + "package.json").publishConfig.registry;;
getLockfile(cliShrinkwrapFile, undefined, { "@zowe:registry": zoweRegistry })
.then((lockfile) => fs.writeFileSync(cliShrinkwrapFile, lockfile))
.then(() => console.log(chalk.green("Lockfile contents written!")))
.catch((err) => {
getLockfile(cliShrinkwrapFile, undefined, { "@zowe:registry": zoweRegistry }).then((lockfile) => {
fs.writeFileSync(cliShrinkwrapFile, lockfile);
console.log(chalk.green("Lockfile contents written!"));
monorepoShrinkwrap();
}).catch((err) => {
if (err.statusCode !== 404) {
console.error(err);
process.exit(1);
Expand All @@ -51,31 +52,34 @@ getLockfile(cliShrinkwrapFile, undefined, { "@zowe:registry": zoweRegistry })
}
});

const pkgA = rootDir + "package.json";
const pkgB = rootDir + "package.json_";
try {
// Mimic non-workspaces monorepo
fs.renameSync(pkgA, pkgB);
function monorepoShrinkwrap() {
const pkgA = rootDir + "package.json";
const pkgB = rootDir + "package.json_";
try {
// Mimic non-workspaces monorepo
fs.renameSync(pkgA, pkgB);

cp.execSync("npm shrinkwrap", {cwd: cliDir});
cp.execSync("npm shrinkwrap", { cwd: cliDir });

const shrinkwrap = JSON.parse(fs.readFileSync(cliShrinkwrapFile, "utf-8"));
shrinkwrap.lockfileVersion = 2;
for (const [k, v] of Object.entries(shrinkwrap.packages)) {
if (v.link || v.extraneous || k === "../sdk") {
const shrinkwrap = JSON.parse(fs.readFileSync(cliShrinkwrapFile, "utf-8"));
shrinkwrap.lockfileVersion = 2;
for (const [k, v] of Object.entries(shrinkwrap.packages)) {
if (v.link || v.extraneous || k === "../sdk") {
delete shrinkwrap.packages[k];
}
}
}
for (const [k, v] of Object.entries(shrinkwrap?.dependencies ?? [])) {
if (v.link || v.extraneous || k === "../sdk") {
for (const [k, v] of Object.entries(shrinkwrap?.dependencies ?? [])) {
if (v.link || v.extraneous || k === "../sdk") {
delete shrinkwrap.dependencies[k];
}
}
}
fs.writeFileSync(cliShrinkwrapFile, JSON.stringify(shrinkwrap, null, 2));
fs.writeFileSync(cliShrinkwrapFile, JSON.stringify(shrinkwrap, null, 2));
console.log(chalk.green("Shrinkwrap contents written!"));

// cp.execSync(`sed -i 's#file:../sdk#${require(cliDir + "package.json").version}#g' npm-shrinkwrap.json`, {cwd: cliDir});
// cp.execSync("npm i ../sdk --install-links --package-lock-only", {cwd: cliDir});
} finally {
// revert back to workspaces monorepo
fs.renameSync(pkgB, pkgA);
// cp.execSync(`sed -i 's#file:../sdk#${require(cliDir + "package.json").version}#g' npm-shrinkwrap.json`, {cwd: cliDir});
// cp.execSync("npm i ../sdk --install-links --package-lock-only", {cwd: cliDir});
} finally {
// revert back to workspaces monorepo
fs.renameSync(pkgB, pkgA);
}
}

0 comments on commit d12f211

Please sign in to comment.