Skip to content

Commit

Permalink
Switch to fixed versioning (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 authored Sep 24, 2018
1 parent 9aad233 commit 53a6124
Show file tree
Hide file tree
Showing 26 changed files with 2,035 additions and 347 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ yarn-error.log
dist/
build/
packages/demo-api/static/
.changelog
34 changes: 17 additions & 17 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ This small guide is intended for anyone contributing code to this project.
- We are using `commitizen` to keep commit messages as consistent as possible.
- Use `yarn commit` to author a commit.
- Try to include only the files related to the scope you were working on in your commit.
- Always enter a package you were working on as a scope when prompted by `commitizen` (if applicable)

## Tests
To keep the project as stable as possible and maintain high code quality, always include tests for the features or bugs you are working on.
There are plenty of examples on how to write tests, just look for `tests` folder inside each package in this repository.
There are plenty of examples on how to write tests, just look for `tests` folder inside each package in this repository.

## Code Documentation
The better the docs, the easier it is for everyone to get involved and contribute instead of decyphering what the original author intention was.
## Working on an issue
- create an issue branch
- commit your changes
- open a PR
- try to keep your PRs small in scope (try to only work on 1 issue in a single PR)
- you can add as many commits as you wish to your PR

This is a very important topic so please do spend a couple more minutes of your time to complete your code with [JSDoc comments](http://usejsdoc.org/).
We generate library documentation using [documentationjs](http://documentation.js.org/).

Here are some rules to follow:
* Everything must be documented with JSDoc comments. Things that are not public must be tagged as `@private` (it will be skipped by the docs generator).
* Text within JSDoc comments may use markdown formatting. Code identifiers must be surrounded by \`backticks\`.
* Documentation must be written in grammatically correct sentences ending with periods.
* Documentation descriptions must contain more information than what is obvious from the identifier and JSDoc metadata.
* Class descriptions should describe what the class *is*, or what its instances *are*. Examples: `Entities are the main units of the business logic.` `A class used for data extraction.`
* Function descriptions should begin with a third person singular present tense verb, as if completing a sentence beginning with "This function..." If the primary purpose of the function is to return a value, the description should begin with "Returns..." Examples: "Returns the data model of this attribute." "Sets the parent entity model."
* `@param`, `@property`, and `@returns` descriptions should be capitalized and end with a period. They should begin as if completing a sentence beginning with "This is..." or "This..."
* Functions that do not return a value (return `undefined`), should not have a `@returns` annotation.
* Member descriptions should document what a member represents or gets and sets.
IMPORTANT:
- the only commit message that matters is the PR merge commit
- PRs are merged using Squash Merge to only create 1 commit in the base branch
- a PR reference in the commit message is mandatory (important for changelog)
- add Github labels to PR stating what kind of change it is (important for changelog)
- eg: `tag: bug fix` or `tag: new feature`
- when merging a PR make sure you write a clear CONVENTIONAL COMMIT message:
- this is the key to semantic versioning
- it is best to use the Issue title as a PR merge commit message including a reference to the PR
- eg. 1: `fix: Handle API call exceptions (#165)`
13 changes: 13 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"changelog": {
"repo": "webiny/webiny-js",
"labels": {
"tag: new feature": ":rocket: New Feature",
"tag: breaking change": ":boom: Breaking Change",
"tag: bug fix": ":bug: Bug Fix",
"tag: enhancement": ":nail_care: Enhancement",
"tag: documentation": ":memo: Documentation",
"tag: internal": ":house: Internal"
}
}
}
17 changes: 14 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@octokit/rest": "^15.12.0",
"@semantic-release/commit-analyzer": "^6.0.1",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^9.0.0-beta.3",
"babel-jest": "^23.4.2",
"bottleneck": "^2.11.0",
"chalk": "^2.4.1",
"child-process-promise": "^2.2.1",
"commitizen": "^2.10.1",
Expand All @@ -47,30 +50,38 @@
"flow-bin": "^0.80.0",
"flow-copy-source": "^1.3.0",
"flow-typed": "^2.4.0",
"fs-extra": "^7.0.0",
"get-stream": "^3.0.0",
"get-yarn-workspaces": "^1.0.2",
"git-cz": "^1.7.1",
"git-log-parser": "^1.2.0",
"globby": "^8.0.1",
"hook-std": "^1.1.0",
"inquirer": "^6.2.0",
"inquirer-autocomplete-prompt": "^1.0.1",
"inquirer-maxlength-input-prompt": "^1.0.0",
"jest": "^23.1.0",
"jest-extended": "^0.7.2",
"lerna-changelog": "^0.8.0",
"lint-staged": "^7.2.2",
"lodash": "^4.17.11",
"longest": "^2.0.1",
"minimatch": "^3.0.4",
"mkdirp": "^0.5.1",
"ncp": "^2.0.0",
"p-locate": "^3.0.0",
"p-retry": "^2.0.0",
"parse-github-url": "^1.0.2",
"pre-commit": "^1.2.2",
"prettier": "^1.14.2",
"random-color": "^1.0.1",
"read-pkg": "^4.0.1",
"rimraf": "^2.6.2",
"rxjs": "^6.3.0",
"rxjs-compat": "^6.3.0",
"semver": "^5.5.1",
"source-map-support": "^0.5.0",
"targz": "^1.0.1",
"webiny-semantic-release": "^1.1.2",
"write-pkg": "^3.2.0",
"yargs": "^12.0.1"
},
Expand All @@ -85,8 +96,8 @@
"commit:check": "yarn lint-staged",
"lint-staged": "lint-staged",
"prettier": "prettier --config .prettierrc.js --write",
"release": "node scripts/release.js",
"release:dry": "node scripts/release.js --preview",
"release": "node scripts/release",
"release:dry": "node scripts/release --preview",
"webiny-ui-build-storybook": "cd packages/webiny-ui && cross-env OUT=../../netlify-static yarn build-storybook"
},
"pre-commit": [
Expand Down
78 changes: 0 additions & 78 deletions scripts/cz-adapter/index.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,19 @@
// @flowIgnore
/* eslint-disable */
const path = require("path");
const execa = require("execa");
const buildCommit = require("cz-customizable/buildCommit");
const getPackages = require("get-yarn-workspaces");
const chalk = require("chalk");
const commitAnalyzer = require("@semantic-release/commit-analyzer");
const autocomplete = require("inquirer-autocomplete-prompt");
const maxLengthInput = require("inquirer-maxlength-input-prompt");
const commitTypes = require("./types");
const rightPad = require("right-pad");
const { map } = require("lodash");
const longest = require("longest");

// Create default prompter
function makeAffectsLine({ packages = [] }) {
if (packages.length) {
return `affects: ${packages.join(", ")}`;
}
}

function getCommitTypeMessage(type) {
if (!type || type === "no") {
return "This commit does not indicate any release.";
}
return {
patch: "🛠 This commit indicates a patch release (0.0.X)",
minor: "✨ This commit indicates a minor release (0.X.0)",
major: "💥 This commit indicates a major release (X.0.0)"
}[type];
}

function getAllPackages() {
return getPackages(process.cwd()).map(dir => {
return {
name: path.basename(dir),
location: dir
};
});
}

function getStagedFiles() {
return execa.sync("git", ["diff", "--cached", "--name-only"]).stdout.split("\n");
}

function getChangedPackages(stagedFiles) {
return getAllPackages()
.filter(pkg => {
const packagePrefix = path.relative(".", pkg.location) + path.sep;
for (let stagedFile of stagedFiles) {
if (stagedFile.indexOf(packagePrefix) === 0) {
return true;
}
}
})
.map(pkg => pkg.name);
}

function formatTypes(types) {
const length = longest(Object.keys(types)).length + 1;
return map(types, (type, key) => {
Expand All @@ -73,8 +30,6 @@ module.exports = {
cz.registerPrompt("maxlength-input", maxLengthInput);

const stagedFiles = getStagedFiles();
const allPackages = getAllPackages().map(pkg => pkg.name);
const changedPackages = getChangedPackages(stagedFiles);

const types = formatTypes(commitTypes);

Expand All @@ -99,11 +54,6 @@ module.exports = {
);
}
},
/*{
type: "input",
name: "scope",
message: "Denote the scope of this change ($location, $browser, $compile, etc.):\n"
},*/
{
type: "maxlength-input",
maxLength: 60,
Expand All @@ -120,41 +70,13 @@ module.exports = {
type: "input",
name: "breaking",
message: "List any breaking changes:\n"
},
{
type: "input",
name: "footer",
message: "List any issues closed by this change (for multiple issues: closes #123, fixes #534):\n"
},
{
type: "checkbox",
name: "packages",
default: changedPackages,
choices: allPackages,
message: `The packages that this commit has affected (${
changedPackages.length
} detected)\n`
}
]).then(async answers => {
// Add emoji to commit message
answers.subject = commitTypes[answers.type].emoji + " " + answers.subject;

// Add list of affected packages
const affectsLine = makeAffectsLine(answers);
if (affectsLine) {
answers.body = `${affectsLine}\n` + answers.body;
}

// Build commit message
const message = buildCommit(answers);

// Run commit-analyzer to detect the type of this commit
const type = await commitAnalyzer(
{},
{ commits: [{ hash: "", message }], logger: { log: () => {} } }
);

console.log(chalk.green(`\n${getCommitTypeMessage(type)}\n`));
console.log("\n\nCommit message:");
console.log(chalk.blue(`\n\n${message}\n`));
commitCb(message);
Expand Down
119 changes: 0 additions & 119 deletions scripts/private.js

This file was deleted.

Loading

0 comments on commit 53a6124

Please sign in to comment.