Skip to content

Commit

Permalink
Merge pull request #72 from Cambalab/dockerized-changelog-generation
Browse files Browse the repository at this point in the history
Dockerized changelog generation
  • Loading branch information
sgobotta authored Oct 3, 2020
2 parents b0ca2b8 + bf59f68 commit 3c35d4c
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 20 deletions.
32 changes: 32 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,38 @@ The test:unit script will run the unit tests. **Please make sure to have this pa

+ **`helpers`**: utility functions shared by the main source code.

## Release

There are scripts available to publish npm releases: `release:major`, `release:minor`, `release:patch`. Each of them run a build, create tags, generates a changelog, commit changes and pushes everything to github.

### Pre-requisites

The changelog is generated using the [dockerized version](https://github.com/github-changelog-generator/docker-github-changelog-generator) of the [github changelog generator](https://github.com/github-changelog-generator/github-changelog-generator) ruby program. Docker is a pre-requisite to run this script. You'll also have to provide an auth token to run this program. This can be easily done by exporting the next from your `.bashrc`, `.zshrc` or whatever runtime configuration file you use. Remember to run `source <your-runtime-configuration-file>` after declaring the auth token.

```bash
export CHANGELOG_GITHUB_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
```

### Releasing a version

When your workspace is clean and you're ready to release, checkout a new branch with the new version name.

```bash
VERSION=x.x.x
git checkout -b $VERSION
git push origin $VERSION
```

Then run the proper release script.

```bash
npm run release:<type>
```

After the release is done, we open a PR from the `$VERSION` branch to the `master` branch and update the `develop` branch with the new version.

> *In the future we'd likely want to do this automatically and add a CI pipeline that triggers tests before releasig a given version type (major, minor, patch)*.
## Attribution

This Contributing Guidelines were adapted from the [Vue.js Contributing Guide][vue-js-contributing-guide].
Expand Down
37 changes: 18 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ npm install -g fake-data-generator

### Usage from a forked or cloned repository

#### 1. Write a `.json` model in the `models` directory
1. Write a `.json` model in the `models` directory. [**Article Example**](/models/example.json)

[***Article Example***](/models/example.json)

#### 2. Run the generate script from a terminal
2. Run the `generate` script from a terminal

*The following command writes a .json file with an array of 50 elements to the output directory, where:*

Expand All @@ -79,9 +77,10 @@ npm run generate example 50 example.json

### Usage as an npm dependency

#### 1. Write a simple model as explained before. It can be a `.json` file or a javascript `Object`
1. Write a model as explained before. It can be a `.json` file or a javascript `Object`
2. Use it in your own module

#### 2. Use it in your own module
#### Params description

**amountArg:**
+ **Type:** `Number`
Expand Down Expand Up @@ -119,23 +118,23 @@ const inputType = 'object'
const outputType = 'object'
const generatedModel = generateModel({ amountArg, modelArg, inputType, outputType })
```
> Note that when using `required` or `import` on a `.json` file the returned value behaves like a javascript Object.

> Note that when using `required` or `import` on a `.json` file the returned value behaves like a javascript Object.
### Usage as a global npm dependency

#### 1. Create a `models` directory, an `output` directory and write a `.json` model as explained before
1. Create a `models` directory, an `output` directory and write a `.json` model as explained before. <br /><br />

```bash
mkdir models
mkdir output
```
```bash
mkdir models
mkdir output
```

#### 2. Run the global npm bin script
2. Run the global npm bin script. <br /><br />

```bash
fake-data-generator example 10 example.json
```
```bash
fake-data-generator example 10 example.json
```

## Models Format

Expand All @@ -154,7 +153,7 @@ fake-data-generator example 10 example.json

+ **Details:** an amount of objects to generate.

> ***When this value is present, the amount value given from a cli or the generateModel function from the npm package is overwritten.***
> *When this value is present, the amount value given from a cli or the generateModel function from the npm package is overwritten.*


### model
Expand Down Expand Up @@ -520,9 +519,9 @@ Adds a fixed `String` at the back of another dynamic value generated by one of t
## Contribution
Please make sure to read the [**Contributing Guide**](https://github.com/Cambalab/fake-data-generator/blob/master/.github/CONTRIBUTING.md) before making a pull request.
Please make sure to read the [**Contributing Guide**](https://github.com/Cambalab/fake-data-generator/blob/master/.github/CONTRIBUTING.md) before submitting pull requests. There you'll find development environment instructions, common scripts and the project structure summary.

> We plan to keep improving this script. We'd at least like to give support to all faker methods and *(why not?)* to any other fake data module from npm.
Feel free to open an issue if any faker method is not working as expcected or if you would like support for another data generator module.

## License

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@
"scripts": {
"start": "node dist/cli.js",
"build": "node_modules/.bin/rimraf dist/ && node_modules/.bin/babel ./ --out-dir dist/ --ignore ./node_modules,./.babelrc,./npm-debug.log --copy-files",
"changelog": "github_changelog_generator && git add CHANGELOG.md && git commit -am \"Updates changelog\"",
"changelog": "npm run docker:changelog && git add CHANGELOG.md && git commit -am \"Updates changelog\"",
"docker:changelog": "docker run --env CHANGELOG_GITHUB_TOKEN=$CHANGELOG_GITHUB_TOKEN -it --rm -v $(pwd):/usr/local/src/your-app ferrarimarco/github-changelog-generator --user Cambalab --project fake-data-generator",
"generate": "npm run build && npm start",
"prepare": "npm run build",
"publish": "git push origin --tags && npm run changelog && git push origin",
"release:major": "npm version major && npm publish",
"release:minor": "npm version minor && npm publish",
"release:patch": "npm version patch && npm publish",
"test": "npm run test:unit && npm run test:coverage",
"test:unit": "./node_modules/.bin/mocha --require babel-core/register -R spec ./test/unit/**",
"test:coverage": "./node_modules/.bin/nyc --reporter=lcov --include=**/lib/**/*.js --exclude=**/*.spec.js --report-dir=./test/unit/coverage npm run test:unit"
},
Expand Down

0 comments on commit 3c35d4c

Please sign in to comment.