From 62ab83c13d26f062e785971c616aa60198cdb8f1 Mon Sep 17 00:00:00 2001 From: Santiago Date: Sat, 3 Oct 2020 12:44:53 -0300 Subject: [PATCH 1/4] :book: Improves Contributing documentation --- README.md | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 70105f4..9a3ab63 100644 --- a/README.md +++ b/README.md @@ -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:* @@ -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` @@ -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.

-```bash -mkdir models -mkdir output -``` + ```bash + mkdir models + mkdir output + ``` -#### 2. Run the global npm bin script +2. Run the global npm bin script.

-```bash -fake-data-generator example 10 example.json -``` + ```bash + fake-data-generator example 10 example.json + ``` ## Models Format @@ -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 @@ -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 From db1e31f2921382d0ba5e93f3b6fc5de646f52313 Mon Sep 17 00:00:00 2001 From: Santiago Date: Sat, 3 Oct 2020 12:46:40 -0300 Subject: [PATCH 2/4] :book: Adds release guidelines --- .github/CONTRIBUTING.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 9222589..5fbc485 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -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 ` 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: +``` + +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]. From d0bca9d7ae7f914aadb9d690ce00be79fc816414 Mon Sep 17 00:00:00 2001 From: Santiago Date: Sat, 3 Oct 2020 12:48:03 -0300 Subject: [PATCH 3/4] :wrench: Updates changelog generation script with a dockerized one --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c26e552..e4be6cd 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,8 @@ "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", From bf59f686f5d7e4173e8b5f706ea0198ef17bcc89 Mon Sep 17 00:00:00 2001 From: Santiago Date: Sat, 3 Oct 2020 12:53:06 -0300 Subject: [PATCH 4/4] :wrench: Adds a package.json script to run both test scripts --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index e4be6cd..c0f6032 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,7 @@ "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" },