Skip to content

Commit

Permalink
feat: initial release (#6)
Browse files Browse the repository at this point in the history
* feat: initial release

ref CORE-1846

Co-Authored-By: Shil Sinha <shil.sinha@gmail.com>
  • Loading branch information
skeggse and shils committed Jan 31, 2020
1 parent 95fbb77 commit 7e62282
Show file tree
Hide file tree
Showing 24 changed files with 11,088 additions and 7,435 deletions.
10 changes: 9 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
{
"extends": ["mixmax/node/withJest", "mixmax/node/disable-require-atomic", "mixmax/flow/strict"]
"extends": ["mixmax/node/withJest", "mixmax/node/disable-require-atomic", "mixmax/flow/strict"],
"overrides": [
{
"files": ["src/bin/**"],
"rules": {
"no-console": "off"
}
}
]
}
7 changes: 5 additions & 2 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
<PROJECT_ROOT>/node_modules/.*

[ignore]
<PROJECT_ROOT>/\(babel\|rollup\)\.config\.js
<PROJECT_ROOT>/\(babel\(\.rollup\)?\|rollup\)\.config\.js
<PROJECT_ROOT>/dist/.*
<PROJECT_ROOT>/node_modules/@babel/.*
<PROJECT_ROOT>/node_modules/nock/.*
<PROJECT_ROOT>/node_modules/lodash/.*
<PROJECT_ROOT>/node_modules/semver/.*
<PROJECT_ROOT>/node_modules/toml/.*
<PROJECT_ROOT>/node_modules/yargs/.*

[include]

Expand Down
25 changes: 25 additions & 0 deletions .huskyrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = require('./').getHooks('node dist/bin');

// Husky explicitly greps for the hook itself to determine whether to run the hook. Here are all the
// hooks, to bypass this check:
//
// - applypatch-msg
// - post-applypatch
// - post-commit
// - post-receive
// - post-update
// - pre-auto-gc
// - pre-merge-commit
// - pre-push
// - pre-receive
// - sendemail-validate
// - commit-msg
// - post-checkout
// - post-merge
// - post-rewrite
// - pre-applypatch
// - pre-commit
// - prepare-commit-msg
// - pre-rebase
// - push-to-checkout
// - update
48 changes: 35 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,42 @@
# Template: Shared Module
# Mixmax's git hooks

This repository contains the template structure and boilerplate for a new shared module. It can run
as-is to give you a sense for how everything functions, but you'll want to follow the instructions
under "How to use."
This repository contains the git hooks for Mixmax's development workflow. We use `commitlint` to
reduce friction when using `semantic-release`, and desire to tighten the feedback cycle to further
reduce friction.

## Install

```sh
$ npm i -D @mixmaxhq/git-hooks @commitlint/cli
```

## Configure

The git hooks are opt-in using the global mixmax configuration file `~/.config/mixmax/config`:

```toml
[git.hooks]
commit_msg = true
pre_push = true
pre_push_mode = "all" # Valid values: "all", "unpushed"
```

(The syntax here is [TOML](https://github.com/toml-lang/toml).)

## How to use

1. Replace all occurrences of `TEMPLATE_MODULE` in the copy of the repository with the name of the
service.
2. Remove the `private` flag from `package.json` and update the `description`.
3. If creating a new public module, change the `publishConfig.access` field in the `package.json` to
`public` - this will cause `semantic-release` to publish it for any user of `npm`. Add in the
appropriate `LICENSE` file and update the `license` field in `package.json`.
4. Remove the example code from `src/index.js`.
5. Rename the `module-template.sublime-project` file to use the name of the module.
6. Update this README to remove the setup instructions and document the modules's purpose and API.
Copy this to a `.huskyrc.js` file adjacent to the `.git` and `node_modules` directories of a
project:

```js
module.exports = require('@mixmaxhq/git-hooks');

// Husky explicitly greps for the hook itself to determine whether to run the hook. Here are the
// hooks, to bypass this check:
//
// - pre-push
// - commit-msg
```

## Building

Expand Down
10 changes: 4 additions & 6 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
module.exports = (api) => ({
// The idiom for transpiling import/export syntax for use under jest without interfering with
// rollup's module bundling process. The test will yield true under jest, and false under rollup.
plugins: api.env('test') ? ['@babel/plugin-transform-modules-commonjs'] : [],
presets: ['@babel/preset-flow'],
});
module.exports = {
...require('./babel.rollup.config.js'),
plugins: ['@babel/plugin-transform-modules-commonjs'],
};
3 changes: 3 additions & 0 deletions babel.rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: ['@babel/preset-flow'],
};
10 changes: 10 additions & 0 deletions flow-typed/misc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
declare type Pojo = { [string]: mixed };

// Workaround for https://github.com/facebook/flow/pull/8275.
declare var require: {
(id: string): any,
resolve: (id: string, options?: { paths?: string[] }) => string,
cache: any,
main: typeof module,
...
};

0 comments on commit 7e62282

Please sign in to comment.