Skip to content
This repository was archived by the owner on Sep 12, 2023. It is now read-only.

Commit a303e52

Browse files
committed
add github template and update shipjs configuration
1 parent 52120d4 commit a303e52

File tree

6 files changed

+163
-5
lines changed

6 files changed

+163
-5
lines changed

.github/CONTRIBUTING.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# rollup-plugin-vue-i18n Contributing Guide
2+
3+
- [Issue Reporting Guidelines](#issue-reporting-guidelines)
4+
- [Pull Request Guidelines](#pull-request-guidelines)
5+
- [Development Setup](#development-setup)
6+
7+
## Issue Reporting Guidelines
8+
9+
- The issue list of this repo is **exclusively** for bug reports and feature requests. Non-conforming issues will be closed immediately.
10+
11+
- Try to search for your issue, it may have already been answered or even fixed in the master branch.
12+
13+
- Check if the issue is reproducible with the latest stable version of rollup-plugin-vue-i18n. If you are using a pre-release, please indicate the specific version you are using.
14+
15+
- It is **required** that you clearly describe the steps necessary to reproduce the issue you are running into. Issues with no clear repro steps will not be triaged. If an issue labeled `Status: Need More Info` receives no further input from the issue author for more than 5 days, it will be closed.
16+
17+
- For bugs that involves build setups, you can create a reproduction repository with steps in the README.
18+
19+
- If your issue is resolved but still open, don’t hesitate to close it. In case you found a solution by yourself, it could be helpful to explain how you fixed it.
20+
21+
## Pull Request Guidelines
22+
23+
- Checkout a topic branch from the `master` branch.
24+
25+
- It's OK to have multiple small commits as you work on the PR - we will let GitHub automatically squash it before merging.
26+
27+
- Make sure `npm test` passes. (see [development setup](#development-setup))
28+
29+
- If adding new feature:
30+
- Add accompanying test case.
31+
- Provide convincing reason to add this feature. Ideally you should open a suggestion issue first and have it greenlighted before working on it.
32+
33+
- If fixing a bug:
34+
- Provide detailed description of the bug in the PR.
35+
- Add appropriate test coverage if applicable.
36+
37+
### Work Step Example
38+
- Fork the repository from [intlify/rollup-plugin-vue-i18n](https://github.com/intlify/rollup-plugin-vue-i18n) !
39+
- Create your topic branch from `master`: `git branch my-new-topic origin/master`
40+
- Add codes and pass tests !
41+
- Commit your changes: `git commit -am 'Add some topic'`
42+
- Push to the branch: `git push origin my-new-topic`
43+
- Submit a pull request to `master` branch of `intlify/rollup-plugin-vue-i18n` repository !
44+
45+
## Development Setup
46+
47+
After cloning the repo, run:
48+
49+
$ npm install
50+
51+
### Commonly used NPM scripts
52+
53+
# lint source codes
54+
$ npm run lint
55+
56+
# run the full test suite, include linting
57+
$ npm test
58+
59+
There are some other scripts available in the `scripts` section of the `package.json` file.
60+
61+
The default test script will do the following: lint with ESLint -> unit tests with coverage. **Please make sure to have this pass successfully before submitting a PR.** Although the same tests will be run against your PR on the CI server, it is better to have it working locally beforehand.
62+

.github/ISSUE_TEMPLATE.md

Whitespace-only changes.

.github/PULL_REQUEST_TEMPLATE.md

Whitespace-only changes.

.github/workflows/release.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Release
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
8+
jobs:
9+
release:
10+
name: Release
11+
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release')
12+
runs-on: Ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v1
15+
- uses: actions/setup-node@v1
16+
with:
17+
registry-url: "https://registry.npmjs.org"
18+
- run: git switch master
19+
- run: |
20+
if [ -f "yarn.lock" ]; then
21+
yarn install
22+
else
23+
npm install
24+
fi
25+
- run: npm run release:trigger
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
29+
SLACK_INCOMING_HOOK: ${{ secrets.SLACK_INCOMING_HOOK }}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@
4545
"url": "git+https://github.com/intlify/rollup-plugin-vue-i18n.git"
4646
},
4747
"scripts": {
48+
"build": "echo 'build!'",
49+
"lint": "echo 'lint!'",
4850
"release:prepare": "shipjs prepare",
4951
"release:trigger": "shipjs trigger",
50-
"test": "echo test"
52+
"test": "echo 'test!'"
5153
}
5254
}

ship.config.js

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,70 @@
1+
const execa = require(require.resolve('execa'))
2+
const { promisify } = require('util')
3+
const fs = require('fs')
4+
const path = require('path')
5+
const read = promisify(fs.readFile)
6+
const write = fs.writeFileSync
7+
8+
function extractSpecificChangelog (changelog, version) {
9+
if (!changelog) {
10+
return null
11+
}
12+
const escapedVersion = version.replace(/\./g, '\\.')
13+
const regex = new RegExp(
14+
`(#+?\\s\\[?v?${escapedVersion}\\]?[\\s\\S]*?)(#+?\\s\\[?v?\\d\\.\\d\\.\\d\\]?)`,
15+
'g'
16+
)
17+
const matches = regex.exec(changelog)
18+
return matches ? matches[1] : null
19+
}
20+
21+
async function commitChangelog (current, next) {
22+
const { stdout } = await execa('npx', ['lerna-changelog', '--next-version', `v${next}`])
23+
const escapedVersion = next.replace(/\./g, '\\.')
24+
const regex = new RegExp(
25+
`(#+?\\s\\[?v?${escapedVersion}\\]?[\\s\\S]*?)(#+?\\s\\[?v?\\d\\.\\d\\.\\d\\]?)`,
26+
'g'
27+
)
28+
const matches = regex.exec(stdout.toString())
29+
const head = matches ? matches[1] : stdout
30+
const changelog = await read('./CHANGELOG.md', 'utf8')
31+
return write('./CHANGELOG.md', `${head}\n\n${changelog}`)
32+
}
33+
134
module.exports = {
2-
publishCommand: ({ defaultCommand }) => `${defaultCommand} --access public`,
3-
mergeStrategy: { toSameBranch: ["master"] },
4-
buildCommand: () => null
5-
};
35+
mergeStrategy: { toSameBranch: ['master'] },
36+
monorepo: undefined,
37+
updateChangelog: false,
38+
beforeCommitChanges: ({ nextVersion, exec, dir }) => {
39+
return new Promise(resolve => {
40+
const pkg = require('./package.json')
41+
commitChangelog(pkg.version, nextVersion).then(resolve)
42+
})
43+
},
44+
formatCommitMessage: ({
45+
version,
46+
releaseType,
47+
mergeStrategy,
48+
baseBranch
49+
}) => `${releaseType} release v${version}`,
50+
formatPullRequestTitle: ({
51+
version,
52+
releaseType
53+
}) => `${releaseType} release v${version}`,
54+
shouldRelease: () => true,
55+
releases: {
56+
extractChangelog: ({ version, dir }) => {
57+
const changelogPath = path.resolve(dir, 'CHANGELOG.md')
58+
try {
59+
const changelogFile = fs.readFileSync(changelogPath, 'utf-8').toString()
60+
const ret = extractSpecificChangelog(changelogFile, version)
61+
return ret
62+
} catch (err) {
63+
if (err.code === 'ENOENT') {
64+
return null
65+
}
66+
throw err
67+
}
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)