Created
February 21, 2022 17:15
-
-
Save mkczarkowski/9b9d0658442ff8c87b60d09768f5d1a0 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env zx | |
try { | |
const projectsDir = 'code' | |
const projectName = argv.n | |
if (!projectName) { | |
console.error(chalk.red('Please provide argument -n with project name')) | |
process.exit(1) | |
} | |
cd(`${os.homedir()}/${projectsDir}`) | |
await $`mkdir -p ${projectName}` | |
cd(projectName) | |
await $`npm init -y` | |
await $`git init -q` | |
if (await $`volta list | grep lerna`.exitCode === 1) { | |
await $`volta install lerna` | |
} | |
if (await $`lerna init --independent --exact`.exitCode === 126) { | |
console.info(chalk.blue('Lerna already initalized')) | |
} | |
await $`npm install` | |
await $`ls node_modules` | |
await $`cat lerna.json` | |
const lernaConfig = await fs.readJson('lerna.json') | |
lernaConfig.command.publish = { | |
registry: "http://localhost:4873", | |
ignoreChanges: ["*.md"], | |
message: "chore(release): publish" | |
} | |
await fs.writeJson('lerna.json', lernaConfig) | |
await $`cat lerna.json` | |
} catch (err) { | |
console.log(chalk.red(err)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment