Skip to content
This repository has been archived by the owner on Apr 5, 2021. It is now read-only.

v3.5.1

Compare
Choose a tag to compare
@mmiller42 mmiller42 released this 16 Sep 01:50
· 27 commits to master since this release

What's New in v3.5.1

This is a summary of the differences between v3.5.1 and v3.5.0.

Commits

Show commits
SHA Author Message
221db49 mmiller42 Adding release notes generator
2089f39 mmiller42 stop prettifying package.json
3dde4d5 greenkeeper[bot] fix(package): update html-webpack-include-assets-plugin to version 1.0.0
6715986 mmiller42 relaxing requirement
d165b1e mmiller42 Merge pull request #20 from mmiller42/greenkeeper/html-webpack-include-assets-plugin-1.0.0
Update html-webpack-include-assets-plugin to the latest version 🚀
9fe0983 mmiller42 3.5.1

Changed files

.circleci/config.yml

Show changes
@@ -43,8 +43,11 @@ jobs:
       - deploy:
           name: Publish
           command: |
-            if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; then
+            export TAG="v$(git log -1 --pretty=%B)"
+            if echo $TAG | grep "^v[0-9]\+\.[0-9]\+\.[0-9]\+$"; then
               npm publish
+              npm run build:scripts
+              node .circleci/lib/index.js
             else
               echo "No tag pushed, skipping deploy"
             fi

.circleci/scripts/createRelease.js

Show changes
@@ -0,0 +1,173 @@
+import 'babel-core/register'
+import 'babel-polyfill'
+
+import GitHubApi from 'github'
+import { render } from 'mustache'
+import { asc as sortVersions } from 'semver-sort'
+
+const TEMPLATE = \`
+# [What's New in {{newTag.name}}]({{{compareUrl}}})
+
+This is a summary of the differences between [{{newTag.name}}]({{{newTag.url}}}) and [{{previousTag.name}}]({{{previousTag.url}}}).
+
+## Commits
+
+<details>
+<summary><strong>Show commits</strong></summary>
+
+| SHA | Author | Message |
+| --- | ------ | ------- |
+{{#commits}}
+| [\\`{{{id}}}\\`]({{{url}}}) | [{{author.name}}]({{{author.url}}}) | {{{message}}} |
+{{/commits}}
+</details>
+
+## Changed files
+
+{{#files}}
+#### {{icon}} [\\`{{{filename}}}\\`]({{{url}}})
+
+{{#diff}}
+<details>
+<summary><strong>Show changes</strong></summary>
+
+\\`\\`\\`diff
+{{{.}}}
+\\`\\`\\`
+</details>
+{{/diff}}
+{{^diff}}
+*Inline diff not displayed. [View the whole file]({{{url}}})*
+{{/diff}}
+
+{{/files}}
+\`.trim()
+
+export const NO_PREVIOUS_RELEASE = new Error('No previous release found')
+
+export default async ({
+  token,
+  owner,
+  repo,
+  tag,
+  showDiff,
+  apiOptions = {},
+}) => {
+  const gitHub = new GitHubApi(apiOptions)
+  gitHub.authenticate({ type: 'oauth', token })
+
+  const { newTag, previousTag } = await fetchTags(gitHub, { owner, repo, tag })
+  const { compareUrl, commits, files } = await fetchDiff(gitHub, {
+    owner,
+    repo,
+    newTag,
+    previousTag,
+  })
+  const body = await renderBody({
+    owner,
+    repo,
+    showDiff,
+    newTag,
+    previousTag,
+    compareUrl,
+    commits,
+    files,
+  })
+
+  return await createRelease(gitHub, { owner, repo, newTag, body })
+}
+
+const fetchTags = async (gitHub, { owner, repo, tag }) => {
+  const { data } = await gitHub.gitdata.getTags({ owner, repo })
+  const tags = sortVersions(data.map(_tag => _tag.ref.split('/').pop()))
+
+  const newTagIndex = tags.findIndex(_tag => _tag === tag)
+
+  if (newTagIndex < 0) {
+    throw new Error(\`Could not find tag ${tag}\`)
+  }
+
+  if (newTagIndex === 0) {
+    throw NO_PREVIOUS_RELEASE
+  }
+
+  return {
+    newTag: tags[newTagIndex],
+    previousTag: tags[newTagIndex - 1],
+  }
+}
+
+const fetchDiff = async (gitHub, { owner, repo, newTag, previousTag }) => {
+  const { data } = await gitHub.repos.compareCommits({
+    owner,
+    repo,
+    base: previousTag,
+    head: newTag,
+  })
+  return {
+    compareUrl: data.html_url,
+    commits: data.commits.map(commit => ({
+      id: commit.sha.substr(0, 7),
+      url: commit.html_url,
+      author: {
+        name: commit.author.login,
+        url: commit.author.html_url,
+      },
+      message: commit.commit.message,
+    })),
+    files: data.files.map(file => ({
+      filename: file.filename,
+      url: file.blob_url,
+      status: file.status,
+      diff: file.patch || null,
+    })),
+  }
+}
+
+const renderBody = async ({
+  owner,
+  repo,
+  showDiff = () => true,
+  newTag,
+  previousTag,
+  compareUrl,
+  commits,
+  files,
+}) =>
+  render(TEMPLATE, {
+    compareUrl,
+    newTag: {
+      name: newTag,
+      url: \`https://github.com/${owner}/${repo}/tree/${newTag}\`,
+    },
+    previousTag: {
+      name: previousTag,
+      url: \`https://github.com/${owner}/${repo}/tree/${previousTag}\`,
+    },
+    commits: commits.map(commit => ({
+      ...commit,
+      message: commit.message.replace(/[\r\n]+/g, '<br>'),
+    })),
+    files: files.map(file => ({
+      ...file,
+      diff: file.diff && showDiff(file) && file.diff.replace(/\`/g, '\\\`'),
+    })),
+    icon() {
+      return {
+        added: ':heavy_plus_sign:',
+        modified: '',
+        removed: ':heavy_minus_sign:',
+      }[this.status]
+    },
+  })
+
+const createRelease = async (gitHub, { owner, repo, newTag, body }) => {
+  const { data } = await gitHub.repos.createRelease({
+    owner,
+    repo,
+    tag_name: newTag,
+    name: newTag,
+    body,
+  })
+  return data.html_url
+}

.circleci/scripts/index.js

Show changes
@@ -0,0 +1,28 @@
+import createRelease from './createRelease'
+
+process.on('unhandledRejection', err => {
+  throw err
+})
+
+const {
+  CIRCLE_PROJECT_USERNAME: OWNER,
+  CIRCLE_PROJECT_REPONAME: REPO,
+  GH_TOKEN: TOKEN,
+  TAG,
+} = process.env
+
+createRelease({
+  token: TOKEN,
+  owner: OWNER,
+  repo: REPO,
+  tag: TAG,
+  showDiff: file => file.filename !== 'package-lock.json',
+})
+  .then(url => console.log(\`Release ${TAG} published at ${url}\`))
+  .catch(err => {
+    if (err === createRelease.NO_PREVIOUS_RELEASE) {
+      console.warn(err)
+    } else {
+      throw err
+    }
+  })

package-lock.json

Inline diff not displayed. View the whole file

package.json

Show changes
@@ -1,19 +1,24 @@
 {
   "name": "html-webpack-externals-plugin",
-  "version": "3.5.0",
-  "description":
-    "Webpack plugin that works alongside html-webpack-plugin to use pre-packaged vendor bundles.",
-  "keywords": ["htmlwebpackplugin", "webpack", "html", "externals"],
+  "version": "3.5.1",
+  "description": "Webpack plugin that works alongside html-webpack-plugin to use pre-packaged vendor bundles.",
+  "keywords": [
+    "htmlwebpackplugin",
+    "webpack",
+    "html",
+    "externals"
+  ],
   "main": "lib/index.js",
   "scripts": {
     "precommit": "lint-staged",
     "test": "mocha --require babel-register",
     "build": "rm -rf lib && babel src --out-dir lib --source-maps --copy-files",
+    "build:scripts": "rm -rf .circleci/lib && babel .circleci/scripts --out-dir .circleci/lib --source-maps",
     "watch": "npm run build -- --watch"
   },
   "lint-staged": {
-    "*.{js,json}": [
-      "prettier --write --no-semi --single-quote --trailing-comma es5 '{src/**/*.{js,json},test/**/*.js,*.json}'",
+    "{src,test,.circleci/scripts}.{js,json}": [
+      "prettier --write --no-semi --single-quote --trailing-comma es5",
       "git add"
     ]
   },
@@ -29,28 +34,31 @@
   "bugs": {
     "url": "https://github.com/mmiller42/html-webpack-externals-plugin/issues"
   },
-  "homepage":
-    "https://github.com/mmiller42/html-webpack-externals-plugin#readme",
+  "homepage": "https://github.com/mmiller42/html-webpack-externals-plugin#readme",
   "devDependencies": {
     "assertion-error": "^1.0.2",
     "babel-cli": "^6.24.1",
     "babel-core": "^6.25.0",
     "babel-plugin-add-module-exports": "^0.2.1",
     "babel-plugin-transform-class-properties": "^6.24.1",
     "babel-plugin-transform-object-rest-spread": "^6.23.0",
+    "babel-polyfill": "^6.26.0",
     "babel-preset-env": "^1.6.0",
     "babel-register": "^6.24.1",
     "bootstrap": "^3.3.7",
     "css-loader": "^0.28.4",
     "escape-string-regexp": "^1.0.5",
     "extract-text-webpack-plugin": "^3.0.0",
+    "github": "^11.0.0",
     "html-webpack-plugin": "^2.0.0",
     "husky": "^0.14.3",
     "jquery": "^3.2.1",
     "lint-staged": "^4.0.2",
     "mocha": "^3.4.2",
+    "mustache": "^2.3.0",
     "prettier": "^1.5.3",
     "rimraf": "^2.6.1",
+    "semver-sort": "0.0.4",
     "webpack": "^3.3.0"
   },
   "peerDependencies": {
@@ -59,6 +67,6 @@
   "dependencies": {
     "ajv": "^5.2.2",
     "copy-webpack-plugin": "^4.0.1",
-    "html-webpack-include-assets-plugin": "0.0.8"
+    "html-webpack-include-assets-plugin": "^1.0.0"
   }
 }