Skip to content

v1.3.0

Choose a tag to compare

@mmiller42 mmiller42 released this 18 Sep 22:45
· 13 commits to master since this release

This is a summary of the differences between v1.3.0 and v1.2.1.

Commits

Show commits
SHA Author Committed Message
2af81ea mmiller42 2017-9-18 typo in js
71f8b1b mmiller42 2017-9-18 add ability to preview instead of publish
28f8cac mmiller42 2017-9-18 regenerate package-lock.json
d9699cf mmiller42 2017-9-18 1.3.0

Changed files

Show changed files

README.md

@@ -15,13 +15,15 @@ npm install --save-dev create-github-release
 ## CLI
 
 \`\`\`
-create-github-release [--config=<configPath>] <tag1> [<tag2>...]
+create-github-release [--config=<configPath>] [--preview=true] <tag1> [<tag2>...]
 \`\`\`
 
 The CLI tool requires you to define a configuration file in your repository. By default, it will look for a file in your repository root called \`github-release.config.js\`.
 
 You may also specify a different path by using the \`--config\` option.
 
+If you provide the \`--preview=true\` option, the release notes will be echoed to stdout instead of saved.
+
 ### Configuration
 
 The configuration file must export an object, which can have the following properties:
@@ -62,11 +64,12 @@ You can also use create-github-release programmatically by importing it into you
 
 ### Configuration
 
-This module exports a function which accepts all the same arguments as the configuration file detailed above, in addition to the \`tag\` property:
+This module exports a function which accepts all the same arguments as the configuration file detailed above, in addition to the \`tag\` and \`preview\` properties:
 
-| Property | Type   | Description         | Default    |
-| -------- | ------ | ------------------- | ---------- |
-| \`tag\`    | string | The tag to release. | *Required* |
+| Property  | Type    | Description                                                         | Default    |
+| --------- | ------- | ------------------------------------------------------------------- | ---------- |
+| \`tag\`     | string  | The tag to release.                                                 | *Required* |
+| \`preview\` | boolean | If true, resolves with the release notes and does not publish them. | \`false\`    |
 
 ### Example
 

github-release.config.js

@@ -1,7 +1,7 @@
 const path = require('path')
 
 const MAX_LINES_TO_SHOW = 80
-const EXTS_TO_SHOW = ['.css', '.html', 'js', '.json', '.jsx', '.md', '.scss', '.yml']
+const EXTS_TO_SHOW = ['.css', '.html', '.js', '.json', '.jsx', '.md', '.scss', '.yml']
 
 module.exports = {
   authenticateOptions: {

package-lock.json

@@ -1,6 +1,6 @@
 {
   "name": "create-github-release",
-  "version": "1.2.1",
+  "version": "1.3.0",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {

package.json

@@ -1,6 +1,6 @@
 {
   "name": "create-github-release",
-  "version": "1.2.1",
+  "version": "1.3.0",
   "description": "Tool for generating GitHub releases after publishing a module.",
   "keywords": [
     "github",

src/cli.js

@@ -9,6 +9,9 @@ const run = async () => {
   const [, , ...argv] = process.argv
   const args = parseArgs(argv)
   const configPath = args.config ? path.resolve(args.config) : null
+  const preview = Boolean(
+    args.preview && !['false', '0', 'off', 'no'].includes(args.preview.toLowerCase())
+  )
   const tags = args._
   if (tags.length === 0) {
     throw new Error('No tags provided')
@@ -36,8 +39,8 @@ const run = async () => {
   return await Promise.all(
     tags.map(async tag => {
       try {
-        const url = await createRelease({ ...config, tag })
-        console.log(\`Release ${tag} published at ${url}\`)
+        const result = await createRelease({ ...config, preview, tag })
+        console.log(preview ? result : \`Release ${tag} published at ${result}\`)
       } catch (err) {
         if (err === NO_PREVIOUS_RELEASE) {
           process.emitWarning(err)

src/index.js

@@ -33,6 +33,7 @@ const createGitHubRelease = async config => {
       templateProps: 'object',
       showDiff: 'function',
       apiOptions: 'object',
+      preview: 'boolean',
     },
     (type, property) => {
       const value = config[property]
@@ -54,6 +55,7 @@ const createGitHubRelease = async config => {
     templateProps = {},
     showDiff = () => true,
     apiOptions = {},
+    preview = false,
   } = config
 
   let render
@@ -94,6 +96,10 @@ const createGitHubRelease = async config => {
     pullRequests,
   })
 
+  if (preview) {
+    return body
+  }
+
   return await createRelease(gitHub, { owner, repo, newTag, body })
 }