-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from amoskyalo/amos/projectInit
Feat: Added ability to choose preferred architecture.
- Loading branch information
Showing
5 changed files
with
134 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const { spawn } = require('child_process'); | ||
const { join } = require('path'); | ||
const { logger } = require('../utils/logger'); | ||
const { mkdir, writeFile } = require('fs').promises; | ||
|
||
const lernaJsonContent = `{ | ||
"$schema": "node_modules/lerna/schemas/lerna-schema.json", | ||
"version": "0.1.0", | ||
"npmClient": "yarn" | ||
}` | ||
|
||
function monorepoInit(monorepoName, next) { | ||
logger.info("Setting your project with lerna init..."); | ||
|
||
async function createMonorepoApp() { | ||
try { | ||
await mkdir(monorepoName); | ||
} catch (error) { | ||
throw new Error(error); | ||
} | ||
} | ||
|
||
Promise.all([createMonorepoApp()]).then(() => { | ||
process.chdir(monorepoName); | ||
|
||
const lerna_child_process = spawn('lerna', ['init'], { shell: true, stdio: 'inherit' }); | ||
|
||
lerna_child_process.on('close', async () => { | ||
async function createPackagesFolder() { | ||
try { | ||
await mkdir(join(process.cwd(), "packages")); | ||
} catch (error) { | ||
throw error; | ||
} | ||
} | ||
|
||
async function updateLernaJson() { | ||
try { | ||
await writeFile(join(process.cwd(), "lerna.json"), lernaJsonContent); | ||
} catch (error) { | ||
throw error; | ||
} | ||
} | ||
|
||
Promise.all([createPackagesFolder(), updateLernaJson()]).then(() => { | ||
process.chdir('packages'); | ||
|
||
next(); | ||
}).catch((error) => { throw error }); | ||
}) | ||
}).catch((error) => { throw error }); | ||
}; | ||
|
||
module.exports = monorepoInit; |
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
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