-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Manage repo with new API. Add semantic-release support
- Loading branch information
Romain Lenzotti
committed
Jun 6, 2020
1 parent
1ae7a3a
commit 1d854ac
Showing
62 changed files
with
8,924 additions
and
851 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,19 @@ | ||
{ | ||
"flow": "gflow", | ||
"remote": "origin", | ||
"develop": "master", | ||
"production": "master", | ||
"ignores": [], | ||
"syncAfterFinish": false, | ||
"postFinish": "", | ||
"skipTest": false, | ||
"charReplacement": "-", | ||
"charBranchNameSeparator": "-", | ||
"branchTypes": { | ||
"feat": "feat", | ||
"fix": "fix", | ||
"chore": "chore", | ||
"docs": "docs" | ||
}, | ||
"refs": {} | ||
} |
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 |
---|---|---|
|
@@ -33,6 +33,7 @@ node_modules | |
.npmrc | ||
.vscode | ||
/.nyc_output/ | ||
dist | ||
|
||
# Typings | ||
typings/ | ||
|
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,11 @@ | ||
language: node_js | ||
cache: yarn | ||
|
||
node_js: | ||
- '12' | ||
|
||
script: yarn test && yarn release | ||
|
||
branches: | ||
except: | ||
- /^v\d+\.\d+\.\d+$/ |
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,15 @@ | ||
{ | ||
"npmClient": "yarn", | ||
"useWorkspaces": true, | ||
"packages": [ | ||
"packages/*" | ||
], | ||
"version": "1.3.3", | ||
"command": { | ||
"bootstrap": { | ||
"npmClientArgs": [ | ||
"--no-package-lock" | ||
] | ||
} | ||
} | ||
} |
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
Empty file.
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,10 @@ | ||
#!/usr/bin/env node | ||
const commander = require('commander') | ||
const { commands, runCommand } = require('../src') | ||
|
||
commander | ||
.usage('monorepo build [options]') | ||
.option('-v, --verbose', 'Enable verbose log', (v, t) => t + 1, 0) | ||
.parse(process.argv) | ||
|
||
runCommand(commands.BuildCmd, commander) |
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,11 @@ | ||
#!/usr/bin/env node | ||
const commander = require('commander') | ||
const { commands, runCommand } = require('../src') | ||
|
||
commander | ||
.usage('monorepo publish [options]') | ||
.option('-v, --verbose', 'Enable verbose log', (v, t) => t + 1, 0) | ||
.option('-d, --dry-run', 'Run publish in dryRun mode', (v, t) => t + 1, 0) | ||
.parse(process.argv) | ||
|
||
runCommand(commands.PublishCmd, commander) |
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,17 @@ | ||
#!/usr/bin/env node | ||
const commander = require('commander') | ||
const { commands, runCommand } = require('../src') | ||
|
||
commander | ||
.usage('monorepo version <version>') | ||
.arguments('<version>') | ||
.option('-v, --verbose', 'Enable verbose log', (v, t) => t + 1, 0) | ||
.action((version) => { | ||
runCommand(commands.VersionCmd, { | ||
version, | ||
verbose: !!commander.verbose | ||
}) | ||
}) | ||
.parse(process.argv) | ||
|
||
|
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,11 @@ | ||
#!/usr/bin/env node | ||
|
||
const commander = require('commander') | ||
const cliPkg = require('../../../package.json') | ||
|
||
commander | ||
.version(cliPkg.version) | ||
.command('build', 'Build packages') | ||
.command('publish', 'Publish packages') | ||
.command('publish', 'Publish packages') | ||
.parse(process.argv) |
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,45 @@ | ||
{ | ||
"name": "@tsed/monorepo-utils", | ||
"version": "1.3.3", | ||
"description": "Mono repo utils", | ||
"private": false, | ||
"main": "./src/index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/TypedProject/tsed-monorepo-utils.git" | ||
}, | ||
"keywords": [], | ||
"author": "Romain Lenzotti", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/TypedProject/tsed-monorepo-utils/issues" | ||
}, | ||
"homepage": "http://tsed.io/", | ||
"dependencies": { | ||
"axios": "0.19.2", | ||
"listr": "0.14.3", | ||
"figures": "3.2.0", | ||
"inquirer": "7.1.0", | ||
"commander": "5.1.0", | ||
"lodash": "4.17.15", | ||
"chalk": "3.0.0", | ||
"esm": "3.2.25", | ||
"execa": "4.0.0", | ||
"fancy-log": "1.3.3", | ||
"fs-extra": "9.0.0", | ||
"globby": "11.0.0", | ||
"has-yarn": "^2.1.0", | ||
"normalize-path": "3.0.0", | ||
"read-package-json": "2.1.1", | ||
"semver": "7.3.2" | ||
}, | ||
"directories": { | ||
"src": "./src", | ||
"bin": "./bin" | ||
}, | ||
"bin": { | ||
"monorepo": "./bin/monorepo.js" | ||
}, | ||
"devDependencies": {}, | ||
"peerDependencies": {} | ||
} |
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,61 @@ | ||
# @tsed/monorepo-utils | ||
|
||
A tool to build and publish packages (Typescript or Javascript) on npm for projects based on | ||
mono repository (lerna). | ||
|
||
## Installation | ||
|
||
Run: | ||
```bash | ||
npm install --save-dev @tsed/monorepo-utils | ||
``` | ||
|
||
### Configuration without Semantic-release | ||
|
||
Add these tasks to your package.json: | ||
|
||
``` | ||
{ | ||
"scripts": { | ||
"test": "", | ||
"version:patch": "monorepo version patch", // update version | ||
"version:minor": "monorepo version minor", | ||
"version:major": "monorepo version major", | ||
"build": "monorepo build", // build packages | ||
"test:e2e: "", | ||
"publish": "monorepo publish" // publish on NPM | ||
} | ||
} | ||
``` | ||
|
||
### Configuration with Semantic-release | ||
|
||
MonoRepoUtils is also compatible with semantic-release. | ||
|
||
Install semantic-release and add repo.config.js file and add these lines: | ||
|
||
```javascript | ||
module.exports = { | ||
branch: 'master', | ||
verifyConditions: ['@semantic-release/github', '@semantic-release/npm', '@tsed/monorepo-utils/semantic-release'], | ||
analyzeCommits: ['@semantic-release/commit-analyzer'], | ||
verifyRelease: [], | ||
generateNotes: ['@semantic-release/release-notes-generator'], | ||
prepare: ['@semantic-release/npm', '@tsed/monorepo-utils/semantic-release'], | ||
publish: ['@tsed/monorepo-utils/semantic-release', '@semantic-release/github'], | ||
success: ['@semantic-release/github', '@tsed/monorepo-utils/semantic-release'], | ||
fail: ['@semantic-release/github'], | ||
npmPublish: false | ||
} | ||
``` | ||
|
||
Add these tasks to your package.json: | ||
|
||
``` | ||
{ | ||
"scripts": { | ||
"build": "monorepo build", // Will be called automatically semantic-release | ||
"release": "semantic-release" | ||
} | ||
} | ||
``` |
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,34 @@ | ||
const { MonoRepo } = require('./src') | ||
|
||
let monoRepo | ||
|
||
module.exports = { | ||
async verifyConditions (pluginConfig, context) { | ||
monoRepo = new MonoRepo({ | ||
...pluginConfig, | ||
rootDir: context.cwd | ||
}) | ||
|
||
await monoRepo.configureWorkspace({ branchName: context.branch.name }) | ||
}, | ||
|
||
async prepare (pluginConfig, context) { | ||
const { | ||
nextRelease: { version } | ||
} = context | ||
|
||
await monoRepo.newVersion({ version }) | ||
await monoRepo.buildWorkspace() | ||
await monoRepo.commitChanges({ version }) | ||
}, | ||
|
||
async publish (pluginConfig) { | ||
return monoRepo.publish({ dryRun: pluginConfig.dryRun }) | ||
}, | ||
|
||
async success (pluginConfig) { | ||
if (!pluginConfig.dryRun) { | ||
return monoRepo.syncRepository() | ||
} | ||
} | ||
} |
Oops, something went wrong.