Skip to content

Commit

Permalink
Merge pull request #28 from upfrontIO/refactoring-to-node-release-tools
Browse files Browse the repository at this point in the history
Refactor create-release-branch script to a node executable
  • Loading branch information
DaRaFF authored May 22, 2018
2 parents bf04ebc + 54d1047 commit 43a7735
Show file tree
Hide file tree
Showing 29 changed files with 291 additions and 392 deletions.
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "standard"
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
npm-debug.log
.DS_Store
node_modules
package-lock.json
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,26 @@ The release tools are a bunch of command line tools to maintain a release. These

## Usage

These utilities are provided by this [NPM package](https://www.npmjs.com/package/@livingdocs/release-tools).
#### Preconditions
Have [`npx`](https://www.npmjs.com/package/npx) installed with `npm install -g npx`

After adding it as dev-dependency to the NPM package you are working on, you will be able to execute `li-release` on the command line to see all available commands. Every command shows some help about a function executed without arguments, e.g. `li-release init-release`.
#### List of available commands
`npx release-tools`


#### Create Release Branch

**Introduction**
When you want to manage a product with different releases and support old version with patches, you can not just use semver on master. You also have to work with release branches to support old versions. A more detailed explanation with an example can be found [here](./doc/how-to-handle-a-product-release-on-github.md)

**Commands**
* Help: `npx release-tools create-release-branch`
* Command (simple example): `npx release-tools create-release-branch --base-tag=v1.0.1 --release-branch-name=release-2017-10 --npm-token=<token>`


## Examples

- [How to Handle a Customer Release on Github](./doc/how-to-handle-a-release-on-github.md)
- [How to Handle a Product Release on Github](./doc/how-to-handle-a-product-release-on-github.md)


## Run the tests
```bash
Expand All @@ -27,6 +35,6 @@ npm test

## Copyright

Copyright (c) 2017 Livingdocs AG, all rights reserved
Copyright (c) 2018 Livingdocs AG, all rights reserved

It is not permitted to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of this Software ('release-tools'), except when explicitly stated otherwise by Livingdocs AG.
10 changes: 10 additions & 0 deletions bin/cmd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env node
const yargs = require('yargs')
const commands = require('./cmd_init')

// Init CLI commands and options
commands.forEach(cmd => yargs.command(cmd.command, cmd.desc, cmd.builder, cmd.handler))
yargs
.help()
.demand(1)
.argv
36 changes: 36 additions & 0 deletions bin/cmd_init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const camelCase = require('camelcase')
const requireDir = require('require-dir')
const colors = require('chalk')
const shell = require('shelljs')
shell.set('-e')
const { join, resolve } = require('path')
const pkg = require(join(__dirname, '../package.json'))

// External dependencies to pass to the commands
let dep = {
join,
resolve,
console,
colors,
shell,
process,
releaseConfig: pkg.release
}

// Internal dependencies (modules)
const inDepFns = requireDir(join(__dirname, '..', 'lib', 'modules'))
Object.keys(inDepFns).forEach(name => {
dep[camelCase(name)] = inDepFns[name](dep)
})

// Internal dependencies (shell)
const shellFns = requireDir(join(__dirname, '..', 'lib', 'shell'))
Object.keys(shellFns).forEach(name => {
dep[camelCase(name)] = shellFns[name](dep)
})

// Load commands from folder and pass dependencies
const commandsFn = requireDir(join(__dirname, '..', 'lib', 'commands'))
const commands = Object.keys(commandsFn).map((i) => commandsFn[i](dep))

module.exports = commands
188 changes: 0 additions & 188 deletions bin/create-release-branch

This file was deleted.

70 changes: 0 additions & 70 deletions bin/finish-release

This file was deleted.

Loading

0 comments on commit 43a7735

Please sign in to comment.