Skip to content

Commit

Permalink
improve installations scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
srgooglo committed Nov 28, 2023
1 parent 84c84a4 commit e8e4212
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 22 deletions.
46 changes: 32 additions & 14 deletions scripts/post-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 evitePath = path.resolve(rootPath, "evite")
const linebridePath = path.resolve(rootPath, "linebridge")

console.log(`Linking Evite to app...`)
await child_process.execSync("yarn link", {
Expand All @@ -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
Expand All @@ -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)

Expand Down
20 changes: 12 additions & 8 deletions scripts/utils/getPackages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
}
Expand Down

0 comments on commit e8e4212

Please sign in to comment.