-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4adf17b
commit 844ca18
Showing
76 changed files
with
15,432 additions
and
1,815 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* eslint-disable import/no-dynamic-require,global-require */ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const spawn = require('child_process').spawnSync; | ||
|
||
const type = process.env.type || 'upgrade'; // yarn update types | ||
const logTask = msg => console.log(`👍 ${msg}`); | ||
|
||
const installPackage = (at) => { | ||
const result = spawn('yarn', [type], { stdio: 'inherit', cwd: at }); | ||
if (result.error) { | ||
console.log(result.error); | ||
process.exit(1); | ||
} | ||
logTask(`installed ${at}\n`); | ||
}; | ||
|
||
const packages = fs.readdirSync('packages').reduce((pkgs, pkg) => { | ||
const packagePath = path.join(process.cwd(), 'packages', pkg); | ||
const packageJSON = path.join(packagePath, 'package.json'); | ||
try { | ||
if (fs.statSync(packagePath).isDirectory() && fs.statSync(packageJSON).isFile()) { | ||
pkgs.push({ path: packagePath, name: require(packageJSON).name }); | ||
} | ||
} catch (e) { return pkgs; } | ||
return pkgs; | ||
}, []); | ||
|
||
console.log(`\n🔥 Bootstrapping\n`); | ||
|
||
// Install the root package.json first so that we can use shelljs. | ||
installPackage(process.cwd()); | ||
const shell = require('shelljs'); | ||
|
||
// Install all of the monorepo packages. | ||
packages.forEach(pkg => installPackage(pkg.path)); | ||
|
||
// Symlink monorepo package dependencies to local packages. | ||
packages.forEach((pkg) => { | ||
const packageJSON = require(path.join(pkg.path, 'package.json')); | ||
const dependencies = Object.assign({}, packageJSON.dependencies, packageJSON.devDependencies); | ||
packages.forEach((spkg) => { | ||
if (dependencies.hasOwnProperty(spkg.name)) { // eslint-disable-line no-prototype-builtins | ||
const to = path.join(spkg.path, 'node_modules', spkg.name); | ||
shell.rm('-rf', to); | ||
shell.ln('-sf', spkg.path, to); | ||
logTask(`symlinked:\n${to} -> ${spkg.path}\n`); | ||
} | ||
}); | ||
}); | ||
|
||
// npm link kyt-cli and kyt | ||
shell.exec('npm link', { cwd: path.join(process.cwd(), 'packages', 'kyt-cli') }); | ||
logTask('npm-linked kyt-cli\n'); | ||
shell.exec('npm link', { cwd: path.join(process.cwd(), 'packages', 'kyt-core') }); | ||
logTask('npm-linked kyt'); | ||
|
||
console.log(`\n✅ strapped\n`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.