PromucFlow_constructor/app/shared/build-shared-dep.js
Aman Agarwal 3b00508c1e
feat: ast mono repo poc (#15610)
* POC for Shared AST Logic using Yarn Symlinks

* fix: preinstall script for bundling shared packages

* Merge commit

* fix: updated the script to link, unlink the package as shared dep

* fix: updated dependencies

* Add a post-install script and fix yarn.lock file

* Remove commented code

* fix: added verification script, readme, moved scripts to shared

Co-authored-by: Ayangade Adeoluwa <adeoluayangade@yahoo.com>
2022-08-11 20:59:26 +05:30

65 lines
2.0 KiB
JavaScript

const { exec } = require("child_process");
const path = require("path");
const sharedJSON = require("./shared-dependencies.json");
const CURRENT_DIRECTORY = path.join(__dirname, '..');
const SCOPE_DIRECTORY = process.env.CURRENT_SCOPE;
async function main() {
console.log("\x1b[33m", "*******************************************");
console.log("\x1b[33m", "Bundling Shared Dependencies");
console.log("\x1b[33m", "*******************************************");
const dependencies = sharedJSON[SCOPE_DIRECTORY];
if ((dependencies && dependencies.length > 0) || !SCOPE_DIRECTORY) {
try {
await Promise.all(
dependencies.map(
(dependencyFolder) =>
new Promise((resolve, reject) => {
console.log(
"\x1b[0m",
`Bundling Dependency for \x1b[34m${dependencyFolder}`
);
exec(
`
cd ${CURRENT_DIRECTORY}/${dependencyFolder.replace("@", "")};
yarn unlink;
yarn run link-package;
`,
(err) => {
if (err) {
reject(err);
}
console.log(
"\x1b[0m",
`Bundled Dependency for \x1b[34m${dependencyFolder}`
);
resolve();
}
);
})
)
);
} catch (error) {
console.log(
"\x1b[31m",
"Error in Bundling Shared Dependencies ❌",
error
);
}
console.log("\x1b[32m", "*******************************************");
console.log("\x1b[32m", "Done Bundling Shared Dependencies ✔");
console.log("\x1b[32m", "*******************************************");
} else {
console.log("\x1b[34m", "*******************************************");
console.log("\x1b[34m", "No Shared Dependency to bundle");
console.log("\x1b[34m", "*******************************************");
}
}
main();