From f7f37c560601e7f45a848f25949992f8ad987631 Mon Sep 17 00:00:00 2001 From: SrGooglo Date: Tue, 28 Nov 2023 18:59:43 +0000 Subject: [PATCH] improve installations scripts --- scripts/post-install.js | 46 +++++++++++++++++++++++++----------- scripts/utils/getPackages.js | 20 +++++++++------- 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/scripts/post-install.js b/scripts/post-install.js index 9563cb00..34b631af 100644 --- a/scripts/post-install.js +++ b/scripts/post-install.js @@ -56,17 +56,11 @@ async function linkSharedResources(pkgJSON, packagePath) { } } -async function initializeEvite() { +async function linkInternalSubmodules(packages) { const appPath = path.resolve(rootPath, pkgjson._web_app_path) + const evitePath = path.resolve(rootPath, "evite") - - console.log("📦 Initializing Evite...") - - // console.log(`Intalling Evite dependencies...`) - // await child_process.execSync("yarn install", { - // cwd: evitePath, - // stdio: "inherit", - // }) + const linebridePath = path.resolve(rootPath, "linebridge") console.log(`Linking Evite to app...`) await child_process.execSync("yarn link", { @@ -79,6 +73,30 @@ async function initializeEvite() { stdio: "inherit", }) + console.log(`Linking Linebride to servers...`) + + await child_process.execSync(`yarn link`, { + cwd: linebridePath, + stdio: "inherit", + }) + + for await (const packageName of packages) { + const packagePath = path.resolve(packagesPath, packageName) + + const packageJsonPath = path.resolve(packagePath, "package.json") + + if (!fs.existsSync(packageJsonPath)) { + continue + } + + await child_process.execSync(`yarn link "linebridge"`, { + cwd: packagePath, + stdio: "inherit", + }) + + console.log(`Linking Linebride to package [${packageName}]...`) + } + console.log(`✅ Evite dependencies installed`) return true @@ -87,18 +105,18 @@ async function initializeEvite() { async function main() { console.time("✅ post-install tooks:") - await initializeEvite() + // read dir with absolute paths + let packages = await getPackages() + + await linkInternalSubmodules(packages) console.log("Rebuilding TFJS...") - await child_process.execSync("npm rebuild @tensorflow/tfjs-node --build-from-source &&", { + await child_process.execSync("npm rebuild @tensorflow/tfjs-node --build-from-source", { cwd: rootPath, stdio: "inherit", }) - // read dir with absolute paths - let packages = await getPackages() - for (const packageName of packages) { const packagePath = path.resolve(packagesPath, packageName) diff --git a/scripts/utils/getPackages.js b/scripts/utils/getPackages.js index 45e75c15..6e7858f9 100644 --- a/scripts/utils/getPackages.js +++ b/scripts/utils/getPackages.js @@ -4,9 +4,13 @@ const path = require("path") const rootPath = process.cwd() const packagesPath = path.resolve(rootPath, "packages") -const excludedPackages = ["comty.js"] +async function readIgnoredPackages() { + const packages = await fs.promises.readFile(path.resolve(rootPath, ".ignorepackages"), "utf-8").catch(() => "") -function filterPackages(packages, ignore = []) { + return packages.split("\n") +} + +async function filterPackages(packages, ignore = []) { const gitIgnore = fs.readFileSync(path.resolve(rootPath, ".gitignore"), "utf-8") // create a regex to match all packages that are in the gitignore file @@ -19,11 +23,6 @@ function filterPackages(packages, ignore = []) { // filter packages that are in the gitignore file packages = packages.filter((packageName) => { - // filter excluded packages - if (excludedPackages.includes(packageName)) { - return false - } - // filter ignored packages if (ignore.includes(packageName)) { return false @@ -46,7 +45,12 @@ function filterPackages(packages, ignore = []) { async function getPackages({ ignore = [] } = {}) { let packages = await fs.promises.readdir(packagesPath) - packages = filterPackages(packages, ignore) + const ignoredPackages = await readIgnoredPackages() + + packages = filterPackages(packages, [ + ...ignore, + ...ignoredPackages, + ]) return packages }