├── .editorconfig ├── .ember-cli ├── .eslintrc.js ├── .github ├── PULL_REQUEST_TEMPLATE └── workflows │ └── ci.yml ├── .gitignore ├── .npmignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── RELEASE.md ├── index.js ├── lib ├── data-generators │ ├── file-hash.js │ ├── git-commit.js │ ├── git-tag-commit.js │ ├── index.js │ └── version-commit.js └── scm-data-generators │ ├── git.js │ └── index.js ├── package.json ├── tests ├── .eslintrc.js ├── fixtures │ ├── index.html │ ├── not-a-repo │ │ └── package.json │ ├── repo │ │ ├── dotgit-branch-only │ │ │ ├── HEAD │ │ │ ├── config │ │ │ ├── index │ │ │ ├── objects │ │ │ │ ├── 41 │ │ │ │ │ └── d41f081b45ad50935c08b1203220737d9739b4 │ │ │ │ ├── 77 │ │ │ │ │ └── 06f9e51d51a2f357b2c2078cdd04e4acf48f93 │ │ │ │ ├── a5 │ │ │ │ │ └── 10e8069cc7eaa8b8262a9c071a702fbd52dbea │ │ │ │ └── d4 │ │ │ │ │ └── 6bba1991f218165a93efe79024e16da2a213fc │ │ │ └── refs │ │ │ │ └── heads │ │ │ │ └── master │ │ ├── dotgit │ │ │ ├── HEAD │ │ │ ├── config │ │ │ ├── index │ │ │ ├── objects │ │ │ │ ├── 41 │ │ │ │ │ └── d41f081b45ad50935c08b1203220737d9739b4 │ │ │ │ ├── 77 │ │ │ │ │ └── 06f9e51d51a2f357b2c2078cdd04e4acf48f93 │ │ │ │ ├── a5 │ │ │ │ │ └── 10e8069cc7eaa8b8262a9c071a702fbd52dbea │ │ │ │ └── d4 │ │ │ │ │ └── 6bba1991f218165a93efe79024e16da2a213fc │ │ │ └── refs │ │ │ │ ├── heads │ │ │ │ └── master │ │ │ │ └── tags │ │ │ │ └── 2.3.4 │ │ ├── file │ │ ├── package.json │ │ └── version.json │ ├── tagged-ancestor-repo │ │ ├── dotgit │ │ │ ├── COMMIT_EDITMSG │ │ │ ├── HEAD │ │ │ ├── config │ │ │ ├── index │ │ │ ├── logs │ │ │ │ ├── HEAD │ │ │ │ └── refs │ │ │ │ │ └── heads │ │ │ │ │ └── master │ │ │ ├── objects │ │ │ │ ├── 41 │ │ │ │ │ └── d41f081b45ad50935c08b1203220737d9739b4 │ │ │ │ ├── 48 │ │ │ │ │ └── 3354f68439a3ff2306276b211e7a9c1678d4a6 │ │ │ │ ├── 77 │ │ │ │ │ └── 06f9e51d51a2f357b2c2078cdd04e4acf48f93 │ │ │ │ ├── a5 │ │ │ │ │ └── 10e8069cc7eaa8b8262a9c071a702fbd52dbea │ │ │ │ ├── c4 │ │ │ │ │ └── a7f225a660b6eeb6cb40695388ce19b92badc3 │ │ │ │ ├── d4 │ │ │ │ │ └── 6bba1991f218165a93efe79024e16da2a213fc │ │ │ │ └── e6 │ │ │ │ │ └── 9de29bb2d1d6434b8b29ae775ad8c2e48c5391 │ │ │ └── refs │ │ │ │ ├── heads │ │ │ │ └── master │ │ │ │ └── tags │ │ │ │ └── 2.3.4 │ │ ├── file │ │ ├── package.json │ │ └── version.json │ └── tagless-repo │ │ ├── dotgit │ │ ├── HEAD │ │ ├── config │ │ ├── index │ │ ├── objects │ │ │ ├── 77 │ │ │ │ └── 06f9e51d51a2f357b2c2078cdd04e4acf48f93 │ │ │ ├── 91 │ │ │ │ └── 38ef996f3c7680aedcba68b0371d828b6dbb0b │ │ │ └── 5e │ │ │ │ └── 29d0ad64c0132a1fc27416a0af2c05511c3e99 │ │ └── refs │ │ │ └── heads │ │ │ └── master │ │ └── package.json ├── helpers │ └── assert.js ├── runner.js └── unit │ ├── .gitkeep │ ├── index-test.js │ └── lib │ ├── data-generators │ ├── file-hash-test.js │ ├── git-commit-test.js │ ├── git-tag-commit-test.js │ └── version-commit-test.js │ └── scm-data-generators │ └── git-test.js └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | end_of_line = lf 10 | charset = utf-8 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | indent_style = space 14 | indent_size = 2 15 | 16 | [*.js] 17 | indent_style = space 18 | indent_size = 2 19 | 20 | [*.hbs] 21 | insert_final_newline = false 22 | indent_style = space 23 | indent_size = 2 24 | 25 | [*.css] 26 | indent_style = space 27 | indent_size = 2 28 | 29 | [*.html] 30 | indent_style = space 31 | indent_size = 2 32 | 33 | [*.{diff,md}] 34 | trim_trailing_whitespace = false 35 | -------------------------------------------------------------------------------- /.ember-cli: -------------------------------------------------------------------------------- 1 | { 2 | /** 3 | Ember CLI sends analytics information by default. The data is completely 4 | anonymous, but there are times when you might want to disable this behavior. 5 | 6 | Setting `disableAnalytics` to true will prevent any data from being sent. 7 | */ 8 | "disableAnalytics": false 9 | } 10 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parserOptions: { 4 | ecmaVersion: 6, 5 | sourceType: 'module' 6 | }, 7 | extends: 'eslint:recommended', 8 | env: { 9 | node: true 10 | }, 11 | rules: { 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE: -------------------------------------------------------------------------------- 1 | ## What Changed & Why 2 | Explain what changed and why. 3 | 4 | ## Related issues 5 | Link to related issues in this or other repositories (if any) 6 | 7 | ## PR Checklist 8 | - [ ] Add tests 9 | - [ ] Add documentation 10 | - [ ] Prefix documentation-only commits with [DOC] 11 | 12 | ## People 13 | Mention people who would be interested in the changeset (if any) 14 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Continuous Integration 2 | 3 | on: 4 | pull_request: 5 | branches: [master] 6 | 7 | jobs: 8 | test: 9 | name: Test 10 | runs-on: ubuntu-latest 11 | strategy: 12 | matrix: 13 | node-version: [14.x, 16.x, 18.x, 20.x] 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Use Node.js ${{ matrix.node-version }} 17 | uses: actions/setup-node@v3 18 | with: 19 | node-version: ${{ matrix.node-version }} 20 | cache: 'yarn' 21 | - run: yarn install 22 | - run: yarn test 23 | 24 | test-floating: 25 | name: Floating Dependencies 26 | runs-on: ubuntu-latest 27 | strategy: 28 | matrix: 29 | node-version: [14.x, 16.x, 18.x, 20.x] 30 | steps: 31 | - uses: actions/checkout@v2 32 | - name: Use Node.js ${{ matrix.node-version }} 33 | uses: actions/setup-node@v3 34 | with: 35 | node-version: ${{ matrix.node-version }} 36 | cache: 'yarn' 37 | - name: install dependencies 38 | run: yarn install --no-lockfile 39 | - name: test 40 | run: yarn test 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | 7 | # dependencies 8 | /node_modules 9 | /bower_components 10 | 11 | # misc 12 | /.sass-cache 13 | /connect.lock 14 | /coverage/* 15 | /libpeerconnection.log 16 | npm-debug.log* 17 | testem.log 18 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | bower_components/ 2 | tests/ 3 | tmp/ 4 | 5 | .bowerrc 6 | .editorconfig 7 | .ember-cli 8 | .travis.yml 9 | .npmignore 10 | **/.gitkeep 11 | bower.json 12 | Brocfile.js 13 | testem.json 14 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | ## v3.0.0 (2023-06-04) 3 | 4 | #### :boom: Breaking Change 5 | * [#97](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/97) [BREAKING] update deps and node version requirements # Do not modify or remove the line above. # Everything below it will be ignored. ([@lukemelia](https://github.com/lukemelia)) 6 | 7 | #### Committers: 2 8 | - Floyd ([@fhightower](https://github.com/fhightower)) 9 | - Luke Melia ([@lukemelia](https://github.com/lukemelia)) 10 | 11 | ## v2.0.0 (2022-03-25) 12 | 13 | #### :rocket: Enhancement 14 | * [#66](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/66) Change git-tag-commit data generator to use most recent ancestor tag ([@courajs](https://github.com/courajs)) 15 | 16 | #### Committers: 1 17 | - Aaron Sikes ([@courajs](https://github.com/courajs)) 18 | 19 | ## v2.0.0-beta.0 (2021-05-02) 20 | 21 | #### :rocket: Enhancement 22 | * [#71](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/71) Allow custom commit hash length when constructing revisionKey ([@HeroicEric](https://github.com/HeroicEric)) 23 | 24 | #### :house: Internal 25 | * [#75](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/75) Bump js-yaml from 3.8.2 to 3.14.1 ([@dependabot[bot]](https://github.com/apps/dependabot)) 26 | * [#74](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/74) Bump websocket-extensions from 0.1.1 to 0.1.4 ([@dependabot[bot]](https://github.com/apps/dependabot)) 27 | * [#73](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/73) Upgrade deps ([@lukemelia](https://github.com/lukemelia)) 28 | 29 | #### Committers: 5 30 | - Ed Fricker ([@beastawakens](https://github.com/beastawakens)) 31 | - Eric Kelly ([@HeroicEric](https://github.com/HeroicEric)) 32 | - Luke Melia ([@lukemelia](https://github.com/lukemelia)) 33 | - Michal Bryxí ([@MichalBryxi](https://github.com/MichalBryxi)) 34 | - Pepijn Schoen ([@duizendnegen](https://github.com/duizendnegen)) 35 | 36 | ## [v1.0.0](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/tree/v1.0.0) (2017-03-25) 37 | [Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/compare/v1.0.0-beta.0...v1.0.0) 38 | 39 | No changes from 1.0.0-beta.0 40 | 41 | ## [v1.0.0-beta.0](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/tree/v1.0.0-beta.0) (2017-03-25) 42 | [Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/compare/v0.3.3...v1.0.0-beta.0) 43 | 44 | **Merged pull requests:** 45 | 46 | - Upgrade ember-cli & embrace being a node-only ember-cli addon [\#56](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/56) ([lukemelia](https://github.com/lukemelia)) 47 | - Replace deprecated `ember-cli/ext/promise` with `rsvp` [\#55](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/55) ([leizhao4](https://github.com/leizhao4)) 48 | - Allow configuration of the separator character \(`+`\) in git-tag-commit and version-commit [\#54](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/54) ([reidab](https://github.com/reidab)) 49 | 50 | ## [v0.3.3](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/tree/v0.3.3) (2017-01-12) 51 | [Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/compare/v0.3.2...v0.3.3) 52 | 53 | **Merged pull requests:** 54 | 55 | - remove pinning for simple-git and git-repo-info [\#46](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/46) ([ghedamat](https://github.com/ghedamat)) 56 | - Use public interface for git-repo-info [\#40](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/40) ([kkumler](https://github.com/kkumler)) 57 | 58 | ## [v0.3.2](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/tree/v0.3.2) (2016-11-01) 59 | [Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/compare/v0.3.1...v0.3.2) 60 | 61 | **Merged pull requests:** 62 | 63 | - Pass path string to SCM instead of object [\#45](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/45) ([kpfefferle](https://github.com/kpfefferle)) 64 | 65 | ## [v0.3.1](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/tree/v0.3.1) (2016-10-20) 66 | [Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/compare/v0.3.0...v0.3.1) 67 | 68 | **Merged pull requests:** 69 | 70 | - README: Fix link to plugin documentation. [\#42](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/42) ([archit](https://github.com/archit)) 71 | - lock git-repo-info to 1.2.0 [\#41](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/41) ([ghedamat](https://github.com/ghedamat)) 72 | 73 | ## [v0.3.0](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/tree/v0.3.0) (2016-08-19) 74 | [Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/compare/v0.2.3...v0.3.0) 75 | 76 | **Merged pull requests:** 77 | 78 | - Update dependencies and remove unnecessary files. [\#38](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/38) ([lukemelia](https://github.com/lukemelia)) 79 | - Getting git-commit to work again with CircleCI [\#36](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/36) ([nathanpalmer](https://github.com/nathanpalmer)) 80 | 81 | ## [v0.2.3](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/tree/v0.2.3) (2016-04-28) 82 | [Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/compare/v0.2.2...v0.2.3) 83 | 84 | **Merged pull requests:** 85 | 86 | - Dont use log as a local variable. [\#35](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/35) ([cball](https://github.com/cball)) 87 | 88 | ## [v0.2.2](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/tree/v0.2.2) (2016-04-28) 89 | [Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/compare/v0.2.1...v0.2.2) 90 | 91 | **Merged pull requests:** 92 | 93 | - Gracefully handle partial git info. [\#33](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/33) ([cball](https://github.com/cball)) 94 | - add 'v' to full changelog links [\#32](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/32) ([ibroadfo](https://github.com/ibroadfo)) 95 | 96 | ## [v0.2.1](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/tree/v0.2.1) (2016-04-06) 97 | [Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/compare/v0.2.0...v0.2.1) 98 | 99 | **Merged pull requests:** 100 | 101 | - \[BUGFIX\] Remove ' from commit hash if needed [\#31](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/31) ([ghedamat](https://github.com/ghedamat)) 102 | 103 | ## [v0.2.0](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/tree/v0.2.0) (2016-04-01) 104 | [Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/compare/v0.1.1...v0.2.0) 105 | 106 | **Merged pull requests:** 107 | 108 | - add scm-data-generators and git scm generator [\#29](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/29) ([ghedamat](https://github.com/ghedamat)) 109 | 110 | ## [v0.1.1](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/tree/v0.1.1) (2016-02-06) 111 | [Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/compare/v0.1.0...v0.1.1) 112 | 113 | **Merged pull requests:** 114 | 115 | - update ember-cli-deploy-plugin [\#26](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/26) ([ghedamat](https://github.com/ghedamat)) 116 | - Update README.md [\#25](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/25) ([lcpriest](https://github.com/lcpriest)) 117 | 118 | ## [v0.1.0](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/tree/v0.1.0) (2015-10-25) 119 | [Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/compare/v0.1.0-beta.4...v0.1.0) 120 | 121 | **Merged pull requests:** 122 | 123 | - Update to use new verbose option for logging [\#20](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/20) ([lukemelia](https://github.com/lukemelia)) 124 | 125 | ## [v0.1.0-beta.4](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/tree/v0.1.0-beta.4) (2015-10-23) 126 | [Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/compare/v0.1.0-beta.3...v0.1.0-beta.4) 127 | 128 | **Merged pull requests:** 129 | 130 | - Add git-commit data generator [\#19](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/19) ([jrowlingson](https://github.com/jrowlingson)) 131 | - Update repo url [\#18](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/18) ([achambers](https://github.com/achambers)) 132 | - Update repository [\#17](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/17) ([achambers](https://github.com/achambers)) 133 | 134 | ## [v0.1.0-beta.3](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/tree/v0.1.0-beta.3) (2015-09-13) 135 | [Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/compare/v0.1.0-beta.2...v0.1.0-beta.3) 136 | 137 | **Merged pull requests:** 138 | 139 | - Return revision metadata instead of just revisionKey [\#16](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/16) ([achambers](https://github.com/achambers)) 140 | 141 | ## [v0.1.0-beta.2](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/tree/v0.1.0-beta.2) (2015-08-28) 142 | [Full Changelog](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/compare/v0.1.0-beta.1...v0.1.0-beta.2) 143 | 144 | **Merged pull requests:** 145 | 146 | - Remove dependency on broccoli-asset-rev [\#15](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/15) ([achambers](https://github.com/achambers)) 147 | - Add git-tag-commit and version-commit key generators [\#13](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/13) ([alisdair](https://github.com/alisdair)) 148 | 149 | ## [v0.1.0-beta.1](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/tree/v0.1.0-beta.1) (2015-08-08) 150 | **Merged pull requests:** 151 | 152 | - Update README for v0.5.0 [\#12](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/12) ([achambers](https://github.com/achambers)) 153 | - Restructure to use ember-cli-deploy-plugin, and complete rename to em… [\#10](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/10) ([lukemelia](https://github.com/lukemelia)) 154 | - `configure` primes the config with data from the deployment context [\#9](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/9) ([achambers](https://github.com/achambers)) 155 | - Renamed project and all references to `tags` [\#8](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/8) ([achambers](https://github.com/achambers)) 156 | - Change to use `configure` hook instead of `willDeploy` [\#7](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/7) ([achambers](https://github.com/achambers)) 157 | - Rename index-hash to file-hash [\#6](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/6) ([lukemelia](https://github.com/lukemelia)) 158 | - Now filePattern is relative to the dist dir stored in `context.distDir` [\#5](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/5) ([achambers](https://github.com/achambers)) 159 | - Remove dependency on index path [\#4](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/4) ([achambers](https://github.com/achambers)) 160 | - Updated to be in line with how ember-cli-deploy handles context data [\#3](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/3) ([achambers](https://github.com/achambers)) 161 | - Create a tag form the hash of the index.html [\#1](https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data/pull/1) ([achambers](https://github.com/achambers)) 162 | 163 | 164 | 165 | \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* 166 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ember-cli-deploy-revision-data 2 | 3 | > An ember-cli-deploy plugin to generate data about this deploy revision including a unique revision key based on the current build 4 | 5 | [![](https://ember-cli-deploy.github.io/ember-cli-deploy-version-badges/plugins/ember-cli-deploy-revision-data.svg)](http://ember-cli-deploy.github.io/ember-cli-deploy-version-badges/) 6 | 7 | This plugin will generate revison data for the current build. This data can be used by other plugins to understand more about the current revision being deployed. 8 | The revision key included in the revison data can be used to uniquely identify the particular version of the application. 9 | 10 | ## What is an ember-cli-deploy plugin? 11 | 12 | A plugin is an addon that can be executed as a part of the ember-cli-deploy pipeline. A plugin will implement one or more of the ember-cli-deploy's pipeline hooks. 13 | 14 | For more information on what plugins are and how they work, please refer to the [Plugin Documentation][1]. 15 | 16 | ## Quick Start 17 | To get up and running quickly, do the following: 18 | 19 | - Ensure [ember-cli-deploy-build][2] is installed and configured 20 | 21 | - Install this plugin 22 | 23 | ```bash 24 | $ ember install ember-cli-deploy-revision-data 25 | ``` 26 | 27 | - Run the pipeline 28 | 29 | ```bash 30 | $ ember deploy 31 | ``` 32 | 33 | ## Installation 34 | Run the following command in your terminal: 35 | 36 | ```bash 37 | ember install ember-cli-deploy-revision-data 38 | ``` 39 | 40 | ## ember-cli-deploy Hooks Implemented 41 | 42 | For detailed information on what plugin hooks are and how they work, please refer to the [Plugin Documentation][1]. 43 | 44 | - `configure` 45 | - `prepare` 46 | 47 | ## Configuration Options 48 | 49 | For detailed information on how configuration of plugins works, please refer to the [Plugin Documentation][1]. 50 | 51 | ### Defaults 52 | ``` 53 | ENV["revision-data"] = { 54 | type: 'file-hash', 55 | scm: function(context) { 56 | return require('./lib/scm-data-generators')['git']; 57 | } 58 | } 59 | ``` 60 | ### type 61 | 62 | The type of [Data Generator](#data-generators) to be used. 63 | 64 | *Default:* `'file-hash'` 65 | *Alternatives:* `'git-tag-commit'`, `'git-commit'`, `'version-commit'` 66 | 67 | ### scm 68 | 69 | The type of the [SCM Data Generator](#scm-data-generators) to be used 70 | 71 | *Default:* GitScmDataGenerator 72 | 73 | You can set this to `null` if you don't want any Scm Data Generator to be used. 74 | 75 | You can also pass your own custom scm generator class. 76 | 77 | ## Data Generators 78 | 79 | Data generators are the strategies used to generate information about the revision being deployed. A data generator must return an object which contains a property called `revisionKey` which uniquely identifies the current revision. A generator can add any other data that it deems relevant to the data object that it returns. 80 | 81 | ### File Hash generator (`file-hash`) 82 | 83 | This generator contructs a revisionKey from the fingerprint of the `index.html` file. 84 | 85 | #### Data fields returned 86 | 87 | ##### revisionKey 88 | 89 | The unique identifier of this build based on the MD5 fingerprint of the `index.html` file. This key is guaranteed to be idempotent. That is, the same revision key will be generated for the same set of project files. If the project files change in any way, this will be reflected by a change in the revision key. 90 | 91 | ##### timestamp 92 | 93 | The timestamp of the current deploy 94 | 95 | #### Configuration Options 96 | 97 | ##### filePattern 98 | 99 | A pattern that matches the file you would like to be fingerprinted. This pattern should be relative to `distDir`. 100 | 101 | *Default:* `index.html` 102 | 103 | ##### distDir 104 | 105 | The root directory where the file matching `filePattern` will be searched for. By default, this option will use the `distDir` property of the deployment context, provided by [ember-cli-deploy-build][2]. 106 | 107 | *Default:* `context.distDir` 108 | 109 | ##### distFiles 110 | 111 | The list of built project files. This option should be relative to `distDir` and should include the file that matches `filePattern`. By default, this option will use the `distFiles` property of the deployment context, provided by [ember-cli-deploy-build][2]. 112 | 113 | *Default:* `context.distFiles` 114 | 115 | ### Git Tag Commit generator (`git-tag-commit`) 116 | 117 | Constructs a revision key based on the most recent git tag and the currently checked-out commit. 118 | 119 | #### Data fields returned 120 | 121 | ##### revisionKey 122 | 123 | The unique identifier of this build based on the git tag, followed by the separator symbol (`+` by default), followed by the first 8 characters of the current commit hash. 124 | 125 | For example, if your most recent git tag is `v2.0.3`, and the current commit is `0993043d49f9e0[...]`, this generator will return a revision of `v2.0.3+0993043d`. 126 | 127 | ##### timestamp 128 | 129 | The timestamp of the current deploy 130 | 131 | #### Configuration Options 132 | 133 | ##### commitHashLength 134 | 135 | The length of the commit hash that is used when constructing the `revisionKey`. 136 | 137 | ##### separator 138 | 139 | The text used to separate the tag name from the commit sha. By default, `+` is used. 140 | 141 | ### Git Commit generator (`git-commit`) 142 | 143 | Constructs a revision key based on the most recent git commit. 144 | 145 | #### Data fields returned 146 | 147 | ##### revisionKey 148 | 149 | The unique identifier of this build based on the first 7 characters of the current commit hash. 150 | 151 | For example, if the current commit is `0993043d49f9e0[...]`, this generator will return a revision of `0993043`. 152 | 153 | ##### timestamp 154 | 155 | The timestamp of the current deploy 156 | 157 | #### Configuration Options 158 | 159 | ##### commitHashLength 160 | 161 | The length of the commit hash that is used as the `revisionKey`. 162 | 163 | ### Version Commit generator 164 | 165 | Similar to the Git Tag Commit generator but uses the `package.json` version string to construct the revision key instead of the git tag. 166 | 167 | #### Data fields returned 168 | 169 | ##### revisionKey 170 | 171 | The unique identifier of this build based on the version in the `package.json`, followed by a the separator symbol (`+` by default), followed by the first 8 characters of the current commit hash. 172 | 173 | For example, if your package.json version is `v2.0.3`, and the current commit is `0993043d49f9e0[...]`, this generator will return a revision of `v2.0.3+0993043d`. 174 | 175 | `Note:` Some environments (like CircleCI) may return partial git information. If the current commit hash cannot be determined, the generator will return only the package.json version (`v2.0.3`) as the `revisionKey`. 176 | 177 | ##### timestamp 178 | 179 | The timestamp of the current deploy 180 | 181 | #### Configuration Options 182 | 183 | ##### commitHashLength 184 | 185 | The length of the commit hash that is used when constructing the `revisionKey`. 186 | 187 | ##### separator 188 | 189 | The text used to separate the tag name from the commit sha. By default, `+` is used. 190 | 191 | ##### versionFile 192 | 193 | The file containing your project's version number. Must be a JSON file with a top-level `version` key. 194 | 195 | *Default:* `package.json` 196 | 197 | ## SCM Data Generators 198 | 199 | SCM Data generators are the strategies used to collect extra information about the revision being deployed. An scm data generator must return an object which contains properties that it deems relevant to the revision being deployed . 200 | 201 | ### Git generator 202 | 203 | This generator uses the information available from the git repository of your ember-cli application. 204 | 205 | #### Data fields returned 206 | 207 | ##### sha 208 | 209 | The SHA of the commit being deployed 210 | 211 | ##### email 212 | 213 | Committer's email 214 | 215 | ##### name 216 | 217 | Committer's name 218 | 219 | ##### message 220 | 221 | The commit message 222 | 223 | ##### branch 224 | 225 | Git branch being deployed 226 | 227 | ##### timestamp 228 | 229 | Commit's timestamp 230 | 231 | ## Prerequisites 232 | 233 | The following properties are expected to be present on the deployment `context` object: 234 | 235 | - `distDir` (provided by [ember-cli-deploy-build][2]) 236 | - `distFiles` (provided by [ember-cli-deploy-build][2]) 237 | 238 | ## Plugins known to work well with this one 239 | 240 | [ember-cli-deploy-redis](https://github.com/ember-cli-deploy/ember-cli-deploy-redis) 241 | 242 | ## Running Tests 243 | 244 | * yarn test 245 | 246 | ## Why `ember build` and `ember test` don't work 247 | 248 | Since this is a node-only ember-cli addon, this package does not include many files and dependencies which are part of ember-cli's typical `ember build` and `ember test` processes. 249 | 250 | [1]: http://ember-cli-deploy.com/ "Plugin Documentation" 251 | [2]: https://github.com/ember-cli-deploy/ember-cli-deploy-build "ember-cli-deploy-build" 252 | [3]: https://github.com/ember-cli/ember-cli-deploy "ember-cli-deploy" 253 | -------------------------------------------------------------------------------- /RELEASE.md: -------------------------------------------------------------------------------- 1 | # Release Process 2 | 3 | Releases are mostly automated using 4 | [release-it](https://github.com/release-it/release-it/) and 5 | [lerna-changelog](https://github.com/lerna/lerna-changelog/). 6 | 7 | ## Preparation 8 | 9 | Since the majority of the actual release process is automated, the primary 10 | remaining task prior to releasing is confirming that all pull requests that 11 | have been merged since the last release have been labeled with the appropriate 12 | `lerna-changelog` labels and the titles have been updated to ensure they 13 | represent something that would make sense to our users. Some great information 14 | on why this is important can be found at 15 | [keepachangelog.com](https://keepachangelog.com/en/1.0.0/), but the overall 16 | guiding principle here is that changelogs are for humans, not machines. 17 | 18 | When reviewing merged PR's the labels to be used are: 19 | 20 | * breaking - Used when the PR is considered a breaking change. 21 | * enhancement - Used when the PR adds a new feature or enhancement. 22 | * bug - Used when the PR fixes a bug included in a previous release. 23 | * documentation - Used when the PR adds or updates documentation. 24 | * internal - Used for internal changes that still require a mention in the 25 | changelog/release notes. 26 | 27 | ## Release 28 | 29 | Once the prep work is completed, the actual release is straight forward: 30 | 31 | * First, ensure that you have installed your projects dependencies: 32 | 33 | ```sh 34 | yarn install 35 | ``` 36 | 37 | * Second, ensure that you have obtained a 38 | [GitHub personal access token][generate-token] with the `repo` scope (no 39 | other permissions are needed). Make sure the token is available as the 40 | `GITHUB_AUTH` environment variable. 41 | 42 | For instance: 43 | 44 | ```bash 45 | export GITHUB_AUTH=abc123def456 46 | ``` 47 | 48 | [generate-token]: https://github.com/settings/tokens/new?scopes=repo&description=GITHUB_AUTH+env+variable 49 | 50 | * And last (but not least 😁) do your release. 51 | 52 | ```sh 53 | npx release-it 54 | ``` 55 | 56 | [release-it](https://github.com/release-it/release-it/) manages the actual 57 | release process. It will prompt you to to choose the version number after which 58 | you will have the chance to hand tweak the changelog to be used (for the 59 | `CHANGELOG.md` and GitHub release), then `release-it` continues on to tagging, 60 | pushing the tag and commits, etc. 61 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var RSVP = require('rsvp'); 4 | 5 | var DeployPluginBase = require('ember-cli-deploy-plugin'); 6 | 7 | module.exports = { 8 | name: 'ember-cli-deploy-revision-data', 9 | 10 | createDeployPlugin: function(options) { 11 | var DeployPlugin = DeployPluginBase.extend({ 12 | name: options.name, 13 | defaultConfig: { 14 | type: 'file-hash', 15 | separator: '+', 16 | filePattern: 'index.html', 17 | versionFile: 'package.json', 18 | 19 | commitHashLength: function() { 20 | if (this.type === 'git-commit') { 21 | return 7; 22 | } else { 23 | return 8; 24 | } 25 | }, 26 | 27 | distDir: function(context) { 28 | return context.distDir; 29 | }, 30 | 31 | distFiles: function(context) { 32 | return context.distFiles; 33 | }, 34 | 35 | scm: function(/* context */) { 36 | return require('./lib/scm-data-generators')['git']; 37 | } 38 | }, 39 | 40 | prepare: function(/*context*/) { 41 | var self = this; 42 | 43 | var promises = { 44 | data: this._getData(), 45 | scm: this._getScmData() 46 | }; 47 | 48 | return RSVP.hash(promises) 49 | .then(function(results) { 50 | var data = results.data; 51 | data.scm = results.scm; 52 | self.log('generated revision data for revision: `' + data.revisionKey + '`', { verbose: true }); 53 | return data; 54 | }) 55 | .then(function(data) { 56 | return { revisionData: data }; 57 | }) 58 | .catch(this._errorMessage.bind(this)); 59 | }, 60 | 61 | _getData: function() { 62 | var type = this.readConfig('type'); 63 | this.log('creating revision data using `' + type + '`', { verbose: true }); 64 | var DataGenerator = require('./lib/data-generators')[type]; 65 | return new DataGenerator({ 66 | plugin: this 67 | }).generate(); 68 | }, 69 | 70 | _getScmData: function() { 71 | var ScmDataGenerator = this.readConfig('scm'); 72 | if (ScmDataGenerator) { 73 | var path = this.readConfig('distDir'); 74 | return new ScmDataGenerator(path).generate(); 75 | } else { 76 | return RSVP.resolve(); 77 | } 78 | }, 79 | 80 | _errorMessage: function(error) { 81 | this.log(error, { color: 'red' }); 82 | return RSVP.reject(error); 83 | } 84 | }); 85 | return new DeployPlugin(); 86 | } 87 | }; 88 | -------------------------------------------------------------------------------- /lib/data-generators/file-hash.js: -------------------------------------------------------------------------------- 1 | var CoreObject = require('core-object'); 2 | var fs = require('fs'); 3 | var path = require('path'); 4 | var minimatch = require('minimatch'); 5 | var crypto = require('crypto'); 6 | var RSVP = require('rsvp'); 7 | 8 | var denodeify = require('rsvp').denodeify; 9 | var readFile = denodeify(fs.readFile); 10 | 11 | module.exports = CoreObject.extend({ 12 | init: function(options) { 13 | this._super(); 14 | this._plugin = options.plugin; 15 | }, 16 | 17 | generate: function() { 18 | var filePattern = this._plugin.readConfig('filePattern'); 19 | var distDir = this._plugin.readConfig('distDir'); 20 | var distFiles = this._plugin.readConfig('distFiles'); 21 | 22 | var filePaths = distFiles.filter(minimatch.filter(filePattern, { matchBase: true })); 23 | 24 | if (!filePaths.length) { 25 | return RSVP.reject('`' + filePattern + '` does not exist in distDir `' + distDir + '`'); 26 | } 27 | 28 | var filePath = path.join(distDir, filePaths[0]); 29 | 30 | return readFile(filePath) 31 | .then(function(contents) { 32 | return { 33 | revisionKey: md5Hash(contents.toString()), 34 | timestamp: new Date().toISOString() 35 | }; 36 | }) 37 | } 38 | }); 39 | 40 | function md5Hash(buf) { 41 | var md5 = crypto.createHash('md5'); 42 | md5.update(buf); 43 | return md5.digest('hex'); 44 | } 45 | -------------------------------------------------------------------------------- /lib/data-generators/git-commit.js: -------------------------------------------------------------------------------- 1 | var CoreObject = require('core-object'); 2 | var gitRepoInfo = require('git-repo-info'); 3 | var RSVP = require('rsvp'); 4 | 5 | module.exports = CoreObject.extend({ 6 | init: function(options) { 7 | this._super(); 8 | this._plugin = options.plugin; 9 | }, 10 | 11 | generate: function() { 12 | var commitHashLength = this._plugin.readConfig('commitHashLength'); 13 | var info = gitRepoInfo(); 14 | 15 | if (info === null || info.root === null) { 16 | return RSVP.reject('Could not find git repository'); 17 | } 18 | 19 | var sha = info.sha.slice(0, commitHashLength); 20 | 21 | if (!sha) { 22 | return RSVP.reject('Could not build revision with commit hash `' + sha + '`'); 23 | } 24 | 25 | return RSVP.resolve({ 26 | revisionKey: sha, 27 | timestamp: new Date().toISOString() 28 | }); 29 | } 30 | }); 31 | -------------------------------------------------------------------------------- /lib/data-generators/git-tag-commit.js: -------------------------------------------------------------------------------- 1 | var CoreObject = require('core-object'); 2 | var gitRepoInfo = require('git-repo-info'); 3 | var RSVP = require('rsvp'); 4 | 5 | module.exports = CoreObject.extend({ 6 | init: function(options) { 7 | this._super(); 8 | this._plugin = options.plugin; 9 | }, 10 | 11 | generate: function() { 12 | var commitHashLength = this._plugin.readConfig('commitHashLength'); 13 | var separator = this._plugin.readConfig('separator'); 14 | var info = gitRepoInfo(); 15 | 16 | if (info === null || info.root === null) { 17 | return RSVP.reject('Could not find git repository'); 18 | } 19 | 20 | var tag = info.lastTag; 21 | var sha = info.sha.slice(0, commitHashLength); 22 | 23 | if (!tag || !sha) { 24 | return RSVP.reject('Could not build revision with tag `' + tag + '` and commit hash `' + sha + '`'); 25 | } 26 | 27 | return RSVP.resolve({ 28 | revisionKey: tag + separator + sha, 29 | timestamp: new Date().toISOString() 30 | }); 31 | } 32 | }); 33 | -------------------------------------------------------------------------------- /lib/data-generators/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "file-hash": require('./file-hash'), 3 | "git-tag-commit": require('./git-tag-commit'), 4 | "git-commit": require('./git-commit'), 5 | "version-commit": require('./version-commit') 6 | }; 7 | -------------------------------------------------------------------------------- /lib/data-generators/version-commit.js: -------------------------------------------------------------------------------- 1 | var CoreObject = require('core-object'); 2 | var gitRepoInfo = require('git-repo-info'); 3 | var fs = require('fs'); 4 | var RSVP = require('rsvp'); 5 | 6 | var denodeify = require('rsvp').denodeify; 7 | var readFile = denodeify(fs.readFile); 8 | 9 | module.exports = CoreObject.extend({ 10 | init: function(options) { 11 | this._super(); 12 | this._plugin = options.plugin; 13 | }, 14 | 15 | generate: function() { 16 | var commitHashLength = this._plugin.readConfig('commitHashLength'); 17 | var separator = this._plugin.readConfig('separator'); 18 | var versionFile = this._plugin.readConfig('versionFile'); 19 | 20 | var info = gitRepoInfo(); 21 | 22 | if (info === null || info.root === null) { 23 | return RSVP.reject('Could not find git repository'); 24 | } 25 | 26 | var sha = (info.sha || '').slice(0, commitHashLength); 27 | var plugin = this._plugin; 28 | 29 | return readFile(versionFile) 30 | .then(function(contents) { 31 | var json = JSON.parse(contents); 32 | 33 | if (!json.version) { 34 | return RSVP.reject('Could not build revision with version `' + json.version + '` and commit hash `' + sha + '`'); 35 | } 36 | 37 | var versionString = json.version; 38 | if (sha) { 39 | versionString = versionString + separator + sha; 40 | } else { 41 | plugin.log('Missing git commit sha, using package version as revisionKey', { color: 'yellow', verbose: true }); 42 | } 43 | 44 | return { 45 | revisionKey: versionString, 46 | timestamp: new Date().toISOString() 47 | }; 48 | }); 49 | } 50 | }); 51 | -------------------------------------------------------------------------------- /lib/scm-data-generators/git.js: -------------------------------------------------------------------------------- 1 | var CoreObject = require('core-object'); 2 | var RSVP = require('rsvp'); 3 | var gitRepoInfo = require('git-repo-info'); 4 | var simpleGit = require('simple-git'); 5 | 6 | module.exports = CoreObject.extend({ 7 | init: function(path) { 8 | this._super(); 9 | this.path = path; 10 | }, 11 | 12 | generate: function() { 13 | var _this = this; 14 | return new RSVP.Promise(function(resolve/*, reject */) { 15 | simpleGit(_this.path).log({ 16 | format: { 17 | hash: '%H', 18 | date: '%ai', 19 | commit_message: '%s', 20 | author_name: '%aN', 21 | author_email: '%ae' 22 | } 23 | }, function(err, log) { 24 | if(!log || !log.latest) { 25 | resolve(); 26 | } else { 27 | var info = log.latest; 28 | 29 | resolve({ 30 | sha: info.hash.replace("'",''), 31 | email: info.author_email.replace("'",''), 32 | name: info.author_name, 33 | message: info.commit_message, 34 | timestamp: new Date(info.date).toISOString(), 35 | branch: gitRepoInfo().branch, 36 | tag: gitRepoInfo().tag 37 | }); 38 | } 39 | }); 40 | }); 41 | } 42 | }); 43 | -------------------------------------------------------------------------------- /lib/scm-data-generators/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "git": require('./git'), 3 | }; 4 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-cli-deploy-revision-data", 3 | "version": "3.0.0", 4 | "description": "An ember-cli-deploy plugin to generate data about this deploy revision including a unique revision key based on the current build", 5 | "keywords": [ 6 | "ember-addon", 7 | "ember-cli-deploy-plugin" 8 | ], 9 | "repository": "https://github.com/ember-cli-deploy/ember-cli-deploy-revision-data", 10 | "license": "MIT", 11 | "author": "Aaron Chambers and the ember-cli-deploy team", 12 | "directories": { 13 | "doc": "doc", 14 | "test": "tests" 15 | }, 16 | "scripts": { 17 | "test": "eslint index.js lib/**/*.js tests/**/*.js && node ./tests/runner.js" 18 | }, 19 | "dependencies": { 20 | "chalk": "^4.1.1", 21 | "core-object": "^3.1.5", 22 | "ember-cli-deploy-plugin": "^0.2.9", 23 | "git-repo-info": "^2.1.1", 24 | "minimatch": "^3.1.2", 25 | "rsvp": "^4.8.5", 26 | "simple-git": "^3.19.0" 27 | }, 28 | "devDependencies": { 29 | "@octokit/rest": "^18.12.0", 30 | "chai": "^4.3.7", 31 | "chai-as-promised": "^7.1.1", 32 | "ember-cli": "^3.28.6", 33 | "eslint": "^8.42.0", 34 | "glob": "^10.2.6", 35 | "mocha": "^8.3.2", 36 | "release-it": "^14.6.1", 37 | "release-it-lerna-changelog": "^3.1.0" 38 | }, 39 | "engines": { 40 | "node": "14.x || 16.x || 18.x || >= 20" 41 | }, 42 | "publishConfig": { 43 | "registry": "https://registry.npmjs.org" 44 | }, 45 | "release-it": { 46 | "plugins": { 47 | "release-it-lerna-changelog": { 48 | "infile": "CHANGELOG.md", 49 | "launchEditor": false 50 | } 51 | }, 52 | "git": { 53 | "tagName": "v${version}" 54 | }, 55 | "github": { 56 | "release": true, 57 | "tokenRef": "GITHUB_AUTH" 58 | } 59 | }, 60 | "volta": { 61 | "node": "14.21.3", 62 | "yarn": "1.22.18" 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /tests/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | globals: { 3 | "describe": true, 4 | "beforeEach": true, 5 | "it": true 6 | }, 7 | env: { 8 | mocha: true 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /tests/fixtures/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /tests/fixtures/not-a-repo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "3.2.1" 3 | } 4 | -------------------------------------------------------------------------------- /tests/fixtures/repo/dotgit-branch-only/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /tests/fixtures/repo/dotgit-branch-only/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = false 5 | logallrefupdates = true 6 | ignorecase = true 7 | precomposeunicode = true 8 | -------------------------------------------------------------------------------- /tests/fixtures/repo/dotgit-branch-only/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/repo/dotgit-branch-only/index -------------------------------------------------------------------------------- /tests/fixtures/repo/dotgit-branch-only/objects/41/d41f081b45ad50935c08b1203220737d9739b4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/repo/dotgit-branch-only/objects/41/d41f081b45ad50935c08b1203220737d9739b4 -------------------------------------------------------------------------------- /tests/fixtures/repo/dotgit-branch-only/objects/77/06f9e51d51a2f357b2c2078cdd04e4acf48f93: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/repo/dotgit-branch-only/objects/77/06f9e51d51a2f357b2c2078cdd04e4acf48f93 -------------------------------------------------------------------------------- /tests/fixtures/repo/dotgit-branch-only/objects/a5/10e8069cc7eaa8b8262a9c071a702fbd52dbea: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/repo/dotgit-branch-only/objects/a5/10e8069cc7eaa8b8262a9c071a702fbd52dbea -------------------------------------------------------------------------------- /tests/fixtures/repo/dotgit-branch-only/objects/d4/6bba1991f218165a93efe79024e16da2a213fc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/repo/dotgit-branch-only/objects/d4/6bba1991f218165a93efe79024e16da2a213fc -------------------------------------------------------------------------------- /tests/fixtures/repo/dotgit-branch-only/refs/heads/master: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/repo/dotgit-branch-only/refs/heads/master -------------------------------------------------------------------------------- /tests/fixtures/repo/dotgit/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /tests/fixtures/repo/dotgit/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = false 5 | logallrefupdates = true 6 | ignorecase = true 7 | precomposeunicode = true 8 | -------------------------------------------------------------------------------- /tests/fixtures/repo/dotgit/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/repo/dotgit/index -------------------------------------------------------------------------------- /tests/fixtures/repo/dotgit/objects/41/d41f081b45ad50935c08b1203220737d9739b4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/repo/dotgit/objects/41/d41f081b45ad50935c08b1203220737d9739b4 -------------------------------------------------------------------------------- /tests/fixtures/repo/dotgit/objects/77/06f9e51d51a2f357b2c2078cdd04e4acf48f93: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/repo/dotgit/objects/77/06f9e51d51a2f357b2c2078cdd04e4acf48f93 -------------------------------------------------------------------------------- /tests/fixtures/repo/dotgit/objects/a5/10e8069cc7eaa8b8262a9c071a702fbd52dbea: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/repo/dotgit/objects/a5/10e8069cc7eaa8b8262a9c071a702fbd52dbea -------------------------------------------------------------------------------- /tests/fixtures/repo/dotgit/objects/d4/6bba1991f218165a93efe79024e16da2a213fc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/repo/dotgit/objects/d4/6bba1991f218165a93efe79024e16da2a213fc -------------------------------------------------------------------------------- /tests/fixtures/repo/dotgit/refs/heads/master: -------------------------------------------------------------------------------- 1 | 41d41f081b45ad50935c08b1203220737d9739b4 2 | -------------------------------------------------------------------------------- /tests/fixtures/repo/dotgit/refs/tags/2.3.4: -------------------------------------------------------------------------------- 1 | 41d41f081b45ad50935c08b1203220737d9739b4 2 | -------------------------------------------------------------------------------- /tests/fixtures/repo/file: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/repo/file -------------------------------------------------------------------------------- /tests/fixtures/repo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "3.2.1" 3 | } 4 | -------------------------------------------------------------------------------- /tests/fixtures/repo/version.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.2.3" 3 | } 4 | -------------------------------------------------------------------------------- /tests/fixtures/tagged-ancestor-repo/dotgit/COMMIT_EDITMSG: -------------------------------------------------------------------------------- 1 | Not worth releasing a new version for this 2 | # Please enter the commit message for your changes. Lines starting 3 | # with '#' will be ignored, and an empty message aborts the commit. 4 | # 5 | # On branch master 6 | # Changes to be committed: 7 | # new file: file 8 | # 9 | -------------------------------------------------------------------------------- /tests/fixtures/tagged-ancestor-repo/dotgit/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /tests/fixtures/tagged-ancestor-repo/dotgit/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = false 5 | logallrefupdates = true 6 | ignorecase = true 7 | precomposeunicode = true 8 | -------------------------------------------------------------------------------- /tests/fixtures/tagged-ancestor-repo/dotgit/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/tagged-ancestor-repo/dotgit/index -------------------------------------------------------------------------------- /tests/fixtures/tagged-ancestor-repo/dotgit/logs/HEAD: -------------------------------------------------------------------------------- 1 | 41d41f081b45ad50935c08b1203220737d9739b4 483354f68439a3ff2306276b211e7a9c1678d4a6 Aaron Sikes 1522436612 -0400 commit: Not worth releasing a new version for this 2 | -------------------------------------------------------------------------------- /tests/fixtures/tagged-ancestor-repo/dotgit/logs/refs/heads/master: -------------------------------------------------------------------------------- 1 | 41d41f081b45ad50935c08b1203220737d9739b4 483354f68439a3ff2306276b211e7a9c1678d4a6 Aaron Sikes 1522436612 -0400 commit: Not worth releasing a new version for this 2 | -------------------------------------------------------------------------------- /tests/fixtures/tagged-ancestor-repo/dotgit/objects/41/d41f081b45ad50935c08b1203220737d9739b4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/tagged-ancestor-repo/dotgit/objects/41/d41f081b45ad50935c08b1203220737d9739b4 -------------------------------------------------------------------------------- /tests/fixtures/tagged-ancestor-repo/dotgit/objects/48/3354f68439a3ff2306276b211e7a9c1678d4a6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/tagged-ancestor-repo/dotgit/objects/48/3354f68439a3ff2306276b211e7a9c1678d4a6 -------------------------------------------------------------------------------- /tests/fixtures/tagged-ancestor-repo/dotgit/objects/77/06f9e51d51a2f357b2c2078cdd04e4acf48f93: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/tagged-ancestor-repo/dotgit/objects/77/06f9e51d51a2f357b2c2078cdd04e4acf48f93 -------------------------------------------------------------------------------- /tests/fixtures/tagged-ancestor-repo/dotgit/objects/a5/10e8069cc7eaa8b8262a9c071a702fbd52dbea: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/tagged-ancestor-repo/dotgit/objects/a5/10e8069cc7eaa8b8262a9c071a702fbd52dbea -------------------------------------------------------------------------------- /tests/fixtures/tagged-ancestor-repo/dotgit/objects/c4/a7f225a660b6eeb6cb40695388ce19b92badc3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/tagged-ancestor-repo/dotgit/objects/c4/a7f225a660b6eeb6cb40695388ce19b92badc3 -------------------------------------------------------------------------------- /tests/fixtures/tagged-ancestor-repo/dotgit/objects/d4/6bba1991f218165a93efe79024e16da2a213fc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/tagged-ancestor-repo/dotgit/objects/d4/6bba1991f218165a93efe79024e16da2a213fc -------------------------------------------------------------------------------- /tests/fixtures/tagged-ancestor-repo/dotgit/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/tagged-ancestor-repo/dotgit/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 -------------------------------------------------------------------------------- /tests/fixtures/tagged-ancestor-repo/dotgit/refs/heads/master: -------------------------------------------------------------------------------- 1 | 483354f68439a3ff2306276b211e7a9c1678d4a6 2 | -------------------------------------------------------------------------------- /tests/fixtures/tagged-ancestor-repo/dotgit/refs/tags/2.3.4: -------------------------------------------------------------------------------- 1 | 41d41f081b45ad50935c08b1203220737d9739b4 2 | -------------------------------------------------------------------------------- /tests/fixtures/tagged-ancestor-repo/file: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/tagged-ancestor-repo/file -------------------------------------------------------------------------------- /tests/fixtures/tagged-ancestor-repo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "3.2.1" 3 | } 4 | -------------------------------------------------------------------------------- /tests/fixtures/tagged-ancestor-repo/version.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.2.3" 3 | } 4 | -------------------------------------------------------------------------------- /tests/fixtures/tagless-repo/dotgit/HEAD: -------------------------------------------------------------------------------- 1 | ref: refs/heads/master 2 | -------------------------------------------------------------------------------- /tests/fixtures/tagless-repo/dotgit/config: -------------------------------------------------------------------------------- 1 | [core] 2 | repositoryformatversion = 0 3 | filemode = true 4 | bare = false 5 | logallrefupdates = true 6 | ignorecase = true 7 | precomposeunicode = true 8 | -------------------------------------------------------------------------------- /tests/fixtures/tagless-repo/dotgit/index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/tagless-repo/dotgit/index -------------------------------------------------------------------------------- /tests/fixtures/tagless-repo/dotgit/objects/5e/29d0ad64c0132a1fc27416a0af2c05511c3e99: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/tagless-repo/dotgit/objects/5e/29d0ad64c0132a1fc27416a0af2c05511c3e99 -------------------------------------------------------------------------------- /tests/fixtures/tagless-repo/dotgit/objects/77/06f9e51d51a2f357b2c2078cdd04e4acf48f93: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/tagless-repo/dotgit/objects/77/06f9e51d51a2f357b2c2078cdd04e4acf48f93 -------------------------------------------------------------------------------- /tests/fixtures/tagless-repo/dotgit/objects/91/38ef996f3c7680aedcba68b0371d828b6dbb0b: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/fixtures/tagless-repo/dotgit/objects/91/38ef996f3c7680aedcba68b0371d828b6dbb0b -------------------------------------------------------------------------------- /tests/fixtures/tagless-repo/dotgit/refs/heads/master: -------------------------------------------------------------------------------- 1 | 9138ef996f3c7680aedcba68b0371d828b6dbb0b 2 | -------------------------------------------------------------------------------- /tests/fixtures/tagless-repo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "3.2.1" 3 | } 4 | -------------------------------------------------------------------------------- /tests/helpers/assert.js: -------------------------------------------------------------------------------- 1 | var chai = require('chai'); 2 | var chaiAsPromised = require("chai-as-promised"); 3 | chai.use(chaiAsPromised); 4 | 5 | module.exports = chai.assert; -------------------------------------------------------------------------------- /tests/runner.js: -------------------------------------------------------------------------------- 1 | /*eslint-env node*/ 2 | 'use strict'; 3 | 4 | var glob = require('glob'); 5 | var Mocha = require('mocha'); 6 | 7 | var mocha = new Mocha({ 8 | reporter: 'spec' 9 | }); 10 | 11 | var arg = process.argv[2]; 12 | var root = 'tests/'; 13 | 14 | function addFiles(mocha, files) { 15 | glob.sync(root + files).forEach(mocha.addFile.bind(mocha)); 16 | } 17 | 18 | addFiles(mocha, '/**/*-test.js'); 19 | 20 | if (arg === 'all') { 21 | addFiles(mocha, '/**/*-test-slow.js'); 22 | } 23 | 24 | mocha.run(function(failures) { 25 | process.on('exit', function() { 26 | process.exit(failures); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /tests/unit/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli-deploy/ember-cli-deploy-revision-data/5066690345535018973c25deae05e98f3c7c66b2/tests/unit/.gitkeep -------------------------------------------------------------------------------- /tests/unit/index-test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var assert = require('../helpers/assert'); 4 | 5 | describe('the index', function() { 6 | var subject, mockUi; 7 | 8 | beforeEach(function() { 9 | subject = require('../../index'); 10 | mockUi = { 11 | verbose: true, 12 | messages: [], 13 | write: function() { }, 14 | writeLine: function(message) { 15 | this.messages.push(message); 16 | } 17 | }; 18 | }); 19 | 20 | it('has a name', function() { 21 | var result = subject.createDeployPlugin({ 22 | name: 'test-plugin' 23 | }); 24 | 25 | assert.equal(result.name, 'test-plugin'); 26 | }); 27 | 28 | it('implements the correct hooks', function() { 29 | var plugin = subject.createDeployPlugin({ 30 | name: 'test-plugin' 31 | }); 32 | 33 | assert.typeOf(plugin.configure, 'function'); 34 | assert.typeOf(plugin.prepare, 'function'); 35 | }); 36 | 37 | describe('configure hook', function() { 38 | it('resolves if config is ok', function() { 39 | var plugin = subject.createDeployPlugin({ 40 | name: 'revision-data' 41 | }); 42 | 43 | var context = { 44 | ui: mockUi, 45 | config: { 46 | "revision-data": { 47 | type: 'file-hash', 48 | filePattern: 'eeee' 49 | } 50 | } 51 | }; 52 | 53 | plugin.beforeHook(context); 54 | plugin.configure(context); 55 | assert.ok(true); // it didn't throw 56 | }); 57 | 58 | it('warns about missing optional config', function() { 59 | var plugin = subject.createDeployPlugin({ 60 | name: 'revision-data' 61 | }); 62 | 63 | var context = { 64 | ui: mockUi, 65 | config: { 66 | "revision-data": { 67 | } 68 | } 69 | }; 70 | 71 | plugin.beforeHook(context); 72 | plugin.configure(context); 73 | 74 | var messages = mockUi.messages.reduce(function(previous, current) { 75 | if (/- Missing config:\s.*, using default:\s/.test(current)) { 76 | previous.push(current); 77 | } 78 | 79 | return previous; 80 | }, []); 81 | 82 | assert.equal(messages.length, 8); 83 | }); 84 | 85 | it('adds default config to the config object', function() { 86 | var plugin = subject.createDeployPlugin({ 87 | name: 'revision-data' 88 | }); 89 | 90 | var context = { 91 | ui: mockUi, 92 | config: { 93 | "revision-data": { 94 | } 95 | } 96 | }; 97 | 98 | plugin.beforeHook(context); 99 | plugin.configure(context); 100 | 101 | assert.isDefined(context.config['revision-data'].type); 102 | assert.isDefined(context.config['revision-data'].filePattern); 103 | assert.isDefined(context.config['revision-data'].scm); 104 | }); 105 | 106 | it('defaults commitHashLength to 7 when type is git-commit', function() { 107 | var plugin = subject.createDeployPlugin({ name: 'revision-data' }); 108 | 109 | var context = { 110 | ui: mockUi, 111 | config: { 112 | 'revision-data': { 113 | type: 'git-commit' 114 | } 115 | } 116 | }; 117 | 118 | plugin.beforeHook(context); 119 | plugin.configure(context); 120 | 121 | assert.equal(context.config['revision-data'].commitHashLength(), 7); 122 | }); 123 | 124 | it('defaults commitHashLength to 8 when type is git-tag-commit', function() { 125 | var plugin = subject.createDeployPlugin({ name: 'revision-data' }); 126 | 127 | var context = { 128 | ui: mockUi, 129 | config: { 130 | 'revision-data': { 131 | type: 'git-tag-commit' 132 | } 133 | } 134 | }; 135 | 136 | plugin.beforeHook(context); 137 | plugin.configure(context); 138 | 139 | assert.equal(context.config['revision-data'].commitHashLength(), 8); 140 | }); 141 | 142 | it('defaults commitHashLength to 8 when type is version-commit', function() { 143 | var plugin = subject.createDeployPlugin({ name: 'revision-data' }); 144 | 145 | var context = { 146 | ui: mockUi, 147 | config: { 148 | 'revision-data': { 149 | type: 'version-commit' 150 | } 151 | } 152 | }; 153 | 154 | plugin.beforeHook(context); 155 | plugin.configure(context); 156 | 157 | assert.equal(context.config['revision-data'].commitHashLength(), 8); 158 | }); 159 | }); 160 | 161 | describe('prepare hook', function() { 162 | it('returns the revisionData', function() { 163 | var plugin = subject.createDeployPlugin({ 164 | name: 'revision-data' 165 | }); 166 | 167 | var context = { 168 | distDir: 'tests/fixtures', 169 | distFiles: ['index.html'], 170 | ui: mockUi, 171 | config: { 172 | "revision-data": { 173 | type: 'file-hash', 174 | filePattern: 'index.html', 175 | scm: function(/* context */) { 176 | return require('../../lib/scm-data-generators')['git']; 177 | }, 178 | distDir: function(context) { 179 | return context.distDir; 180 | }, 181 | distFiles: function(context) { 182 | return context.distFiles; 183 | } 184 | }, 185 | } 186 | }; 187 | plugin.beforeHook(context); 188 | 189 | return assert.isFulfilled(plugin.prepare(context)) 190 | .then(function(result) { 191 | assert.equal(result.revisionData.revisionKey, 'ae1569f72495012cd5e8588e0f2f5d49'); 192 | assert.isNotNull(result.revisionData.timestamp); 193 | assert.isNotNull(result.revisionData.scm.email); 194 | }); 195 | }); 196 | }); 197 | }); 198 | -------------------------------------------------------------------------------- /tests/unit/lib/data-generators/file-hash-test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var assert = require('../../../helpers/assert'); 4 | 5 | describe('the file-hash data generator', function() { 6 | var DataGenerator; 7 | 8 | before(function() { 9 | DataGenerator = require('../../../../lib/data-generators/file-hash'); 10 | }); 11 | 12 | describe('#generate', function() { 13 | describe('revisionData', function() { 14 | var subject; 15 | 16 | before(function() { 17 | var plugin = { 18 | stubConfig: { 19 | distDir: 'tests/fixtures', 20 | distFiles: ['index.html'], 21 | filePattern: 'index.html' 22 | }, 23 | readConfig: function(key) { return this.stubConfig[key]; } 24 | }; 25 | 26 | subject = new DataGenerator({ 27 | plugin: plugin 28 | }); 29 | }); 30 | 31 | it('includes the revisonKey', function() { 32 | return assert.isFulfilled(subject.generate()) 33 | .then(function(revisionData) { 34 | assert.equal(revisionData.revisionKey, 'ae1569f72495012cd5e8588e0f2f5d49'); 35 | }); 36 | }); 37 | 38 | it('includes a timestamp', function() { 39 | return assert.isFulfilled(subject.generate()) 40 | .then(function(revisionData) { 41 | assert.isNotNull(revisionData.timestamp); 42 | }); 43 | }); 44 | }); 45 | 46 | it('rejects when the filePattern doesn\'t exist in distFiles', function() { 47 | var plugin = { 48 | stubConfig: { 49 | distDir: 'tests/fixtures', 50 | distFiles: ['index.html'], 51 | filePattern: 'some-file-that-does-not-exist' 52 | }, 53 | readConfig: function(key) { return this.stubConfig[key]; } 54 | }; 55 | 56 | var subject = new DataGenerator({ 57 | plugin: plugin 58 | }); 59 | 60 | return assert.isRejected(subject.generate()) 61 | .then(function(error) { 62 | assert.equal(error, '`some-file-that-does-not-exist` does not exist in distDir `tests/fixtures`'); 63 | }); 64 | }); 65 | 66 | it('rejects when the file doesn\'t exist', function() { 67 | var plugin = { 68 | stubConfig: { 69 | distDir: 'tests/fixtures', 70 | distFiles: ['index.xxx'], 71 | filePattern: 'index.xxx' 72 | }, 73 | readConfig: function(key) { return this.stubConfig[key]; } 74 | }; 75 | 76 | var subject = new DataGenerator({ 77 | plugin: plugin 78 | }); 79 | 80 | return assert.isRejected(subject.generate()); 81 | }); 82 | }); 83 | }); 84 | -------------------------------------------------------------------------------- /tests/unit/lib/data-generators/git-commit-test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var assert = require('../../../helpers/assert'); 4 | var gitRepoInfo = require('git-repo-info'); 5 | 6 | describe('the git-commit data generator', function() { 7 | var DataGenerator; 8 | var cwd; 9 | 10 | var stubbedPlugin = function(options = {}) { 11 | let defaultConfig = { commitHashLength: 7 }; 12 | 13 | return { 14 | stubbedConfig: Object.assign(defaultConfig, options), 15 | readConfig: function(key) { return this.stubbedConfig[key]; } 16 | }; 17 | }; 18 | 19 | before(function() { 20 | DataGenerator = require('../../../../lib/data-generators/git-commit'); 21 | gitRepoInfo._changeGitDir('dotgit'); 22 | }); 23 | 24 | beforeEach(function() { 25 | cwd = process.cwd(); 26 | }); 27 | 28 | afterEach(function() { 29 | process.chdir(cwd); 30 | }); 31 | 32 | describe('#generate', function() { 33 | it('sets revision key to first 7 characters of git commit hash', function() { 34 | process.chdir('tests/fixtures/repo'); 35 | 36 | var subject = new DataGenerator({ plugin: stubbedPlugin() }); 37 | 38 | return assert.isFulfilled(subject.generate()) 39 | .then(function(data) { 40 | assert.equal(data.revisionKey, '41d41f0'); 41 | }); 42 | }); 43 | 44 | it('sets revision key to git commit hash of custom length', function() { 45 | process.chdir('tests/fixtures/repo'); 46 | 47 | var subject = new DataGenerator({ 48 | plugin: stubbedPlugin({ commitHashLength: 40 }) 49 | }); 50 | 51 | return assert.isFulfilled(subject.generate()) 52 | .then(function(data) { 53 | assert.equal(data.revisionKey, '41d41f081b45ad50935c08b1203220737d9739b4'); 54 | }); 55 | }); 56 | 57 | it('returns a timestamp', function() { 58 | process.chdir('tests/fixtures/repo'); 59 | 60 | var subject = new DataGenerator({ plugin: stubbedPlugin() }); 61 | 62 | return assert.isFulfilled(subject.generate()) 63 | .then(function(data) { 64 | assert.isNotNull(data.timestamp); 65 | }); 66 | }); 67 | 68 | it('rejects if no repository found', function() { 69 | process.chdir('tests/fixtures/not-a-repo'); 70 | 71 | var subject = new DataGenerator({ plugin: stubbedPlugin() }); 72 | 73 | return assert.isRejected(subject.generate()) 74 | .then(function(error) { 75 | assert.equal(error, 'Could not find git repository'); 76 | }); 77 | }); 78 | }); 79 | }); 80 | -------------------------------------------------------------------------------- /tests/unit/lib/data-generators/git-tag-commit-test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var assert = require('../../../helpers/assert'); 4 | var gitRepoInfo = require('git-repo-info'); 5 | 6 | describe('the git-tag-commit data generator', function() { 7 | var DataGenerator; 8 | var cwd; 9 | 10 | var plugin = { 11 | stubConfig: { 12 | commitHashLength: 8, 13 | separator: '+' 14 | }, 15 | readConfig: function(key) { return this.stubConfig[key]; }, 16 | }; 17 | 18 | before(function() { 19 | DataGenerator = require('../../../../lib/data-generators/git-tag-commit'); 20 | gitRepoInfo._changeGitDir('dotgit'); 21 | }); 22 | 23 | beforeEach(function() { 24 | cwd = process.cwd(); 25 | }); 26 | 27 | afterEach(function() { 28 | process.chdir(cwd); 29 | }); 30 | 31 | describe('#generate', function() { 32 | it('concatenates the current git tag and the git commit hash', function() { 33 | process.chdir('tests/fixtures/repo'); 34 | 35 | var subject = new DataGenerator({ plugin: plugin }); 36 | 37 | return assert.isFulfilled(subject.generate()) 38 | .then(function(data) { 39 | assert.equal(data.revisionKey, '2.3.4+41d41f08'); 40 | }); 41 | }); 42 | 43 | it('concatenates an ancestor tag and the current git commit hash', function() { 44 | process.chdir('tests/fixtures/tagged-ancestor-repo'); 45 | 46 | var subject = new DataGenerator({ plugin: plugin }); 47 | 48 | return assert.isFulfilled(subject.generate()) 49 | .then(function(data) { 50 | assert.equal(data.revisionKey, '2.3.4+483354f6'); 51 | }); 52 | }); 53 | 54 | it('concatenates the git tag and the git commit hash of custom length', function() { 55 | process.chdir('tests/fixtures/repo'); 56 | 57 | var plugin = { 58 | stubConfig: { 59 | commitHashLength: 40, 60 | separator: '+' 61 | }, 62 | readConfig: function(key) { return this.stubConfig[key]; }, 63 | }; 64 | 65 | var subject = new DataGenerator({ plugin: plugin }); 66 | 67 | return assert.isFulfilled(subject.generate()) 68 | .then(function(data) { 69 | assert.equal(data.revisionKey, '2.3.4+41d41f081b45ad50935c08b1203220737d9739b4'); 70 | }); 71 | }); 72 | 73 | it('concatenates the git tag and the git commit hash with a custom separator', function() { 74 | process.chdir('tests/fixtures/repo'); 75 | 76 | var plugin = { 77 | stubConfig: { 78 | commitHashLength: 8, 79 | separator: '--' 80 | }, 81 | readConfig: function(key) { return this.stubConfig[key]; }, 82 | }; 83 | 84 | var subject = new DataGenerator({ plugin: plugin }); 85 | 86 | return assert.isFulfilled(subject.generate()) 87 | .then(function(data) { 88 | assert.equal(data.revisionKey, '2.3.4--41d41f08'); 89 | }); 90 | }); 91 | 92 | it('rejects if no repository found', function() { 93 | process.chdir('tests/fixtures/not-a-repo'); 94 | 95 | var subject = new DataGenerator({ plugin: plugin }); 96 | 97 | return assert.isRejected(subject.generate()) 98 | .then(function(error) { 99 | assert.equal(error, 'Could not find git repository'); 100 | }); 101 | }); 102 | 103 | it('rejects if no git tag found', function() { 104 | process.chdir('tests/fixtures/tagless-repo'); 105 | 106 | var subject = new DataGenerator({ plugin: plugin }); 107 | 108 | return assert.isRejected(subject.generate()) 109 | .then(function(error) { 110 | assert.equal(error, 'Could not build revision with tag `null` and commit hash `9138ef99`'); 111 | }); 112 | }); 113 | }); 114 | }); 115 | -------------------------------------------------------------------------------- /tests/unit/lib/data-generators/version-commit-test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var assert = require('../../../helpers/assert'); 4 | var gitRepoInfo = require('git-repo-info'); 5 | 6 | describe('the version-commit data generator', function() { 7 | var DataGenerator; 8 | var cwd; 9 | 10 | before(function() { 11 | DataGenerator = require('../../../../lib/data-generators/version-commit'); 12 | gitRepoInfo._changeGitDir('dotgit'); 13 | }); 14 | 15 | beforeEach(function() { 16 | cwd = process.cwd(); 17 | }); 18 | 19 | afterEach(function() { 20 | process.chdir(cwd); 21 | }); 22 | 23 | describe('#generate', function() { 24 | describe('with partial commit data', function() { 25 | before(function() { 26 | gitRepoInfo._changeGitDir('dotgit-branch-only'); 27 | }); 28 | 29 | after(function() { 30 | gitRepoInfo._changeGitDir('dotgit'); 31 | }); 32 | 33 | it('only adds `+revision` if it can be read', function() { 34 | process.chdir('tests/fixtures/repo'); 35 | 36 | var plugin = { 37 | stubConfig: { 38 | commitHashLength: 8, 39 | versionFile: 'package.json', 40 | separator: '+' 41 | }, 42 | readConfig: function(key) { return this.stubConfig[key]; }, 43 | log: function() {} 44 | }; 45 | 46 | var subject = new DataGenerator({ 47 | plugin: plugin 48 | }); 49 | 50 | return assert.isFulfilled(subject.generate()) 51 | .then(function(data) { 52 | assert.equal(data.revisionKey, '3.2.1'); 53 | }); 54 | }); 55 | 56 | it('logs a warning if no git sha found', function() { 57 | process.chdir('tests/fixtures/repo'); 58 | 59 | var expectedMessage = /missing git commit sha/i; 60 | var plugin = { 61 | stubConfig: { 62 | commitHashLength: 8, 63 | versionFile: 'package.json', 64 | separator: '+' 65 | }, 66 | readConfig: function(key) { return this.stubConfig[key]; }, 67 | log: function(message) { 68 | assert.ok(message.match(expectedMessage)); 69 | } 70 | }; 71 | 72 | var subject = new DataGenerator({ 73 | plugin: plugin 74 | }); 75 | 76 | return assert.isFulfilled(subject.generate()) 77 | }) 78 | }); 79 | 80 | it('concatenates the package version and the git commit hash', function() { 81 | process.chdir('tests/fixtures/repo'); 82 | 83 | var plugin = { 84 | stubConfig: { 85 | commitHashLength: 8, 86 | versionFile: 'package.json', 87 | separator: '+' 88 | }, 89 | readConfig: function(key) { return this.stubConfig[key]; } 90 | }; 91 | 92 | var subject = new DataGenerator({ 93 | plugin: plugin 94 | }); 95 | 96 | return assert.isFulfilled(subject.generate()) 97 | .then(function(data) { 98 | assert.equal(data.revisionKey, '3.2.1+41d41f08'); 99 | }); 100 | }); 101 | 102 | it('concatenates the package version and the git commit hash of custom length', function() { 103 | process.chdir('tests/fixtures/repo'); 104 | 105 | var plugin = { 106 | stubConfig: { 107 | commitHashLength: 40, 108 | versionFile: 'package.json', 109 | separator: '+' 110 | }, 111 | readConfig: function(key) { return this.stubConfig[key]; } 112 | }; 113 | 114 | var subject = new DataGenerator({ 115 | plugin: plugin 116 | }); 117 | 118 | return assert.isFulfilled(subject.generate()) 119 | .then(function(data) { 120 | assert.equal(data.revisionKey, '3.2.1+41d41f081b45ad50935c08b1203220737d9739b4'); 121 | }); 122 | }); 123 | 124 | it('concatenates the package version and the git commit hash with a custom separator', function() { 125 | process.chdir('tests/fixtures/repo'); 126 | 127 | var plugin = { 128 | stubConfig: { 129 | commitHashLength: 8, 130 | versionFile: 'package.json', 131 | separator: '--' 132 | }, 133 | readConfig: function(key) { return this.stubConfig[key]; } 134 | }; 135 | 136 | var subject = new DataGenerator({ 137 | plugin: plugin 138 | }); 139 | 140 | return assert.isFulfilled(subject.generate()) 141 | .then(function(data) { 142 | assert.equal(data.revisionKey, '3.2.1--41d41f08'); 143 | }); 144 | }); 145 | 146 | it('has version source file option', function() { 147 | process.chdir('tests/fixtures/repo'); 148 | 149 | var plugin = { 150 | stubConfig: { 151 | commitHashLength: 8, 152 | versionFile: 'version.json', 153 | separator: '+' 154 | }, 155 | readConfig: function(key) { return this.stubConfig[key]; } 156 | }; 157 | 158 | var subject = new DataGenerator({ 159 | plugin: plugin 160 | }); 161 | 162 | return assert.isFulfilled(subject.generate()) 163 | .then(function(data) { 164 | assert.equal(data.revisionKey, '1.2.3+41d41f08'); 165 | }); 166 | }); 167 | 168 | it('returns a timestamp', function() { 169 | process.chdir('tests/fixtures/repo'); 170 | 171 | var plugin = { 172 | stubConfig: { 173 | commitHashLength: 8, 174 | versionFile: 'package.json', 175 | separator: '+' 176 | }, 177 | readConfig: function(key) { return this.stubConfig[key]; } 178 | }; 179 | 180 | var subject = new DataGenerator({ 181 | plugin: plugin 182 | }); 183 | 184 | return assert.isFulfilled(subject.generate()) 185 | .then(function(data) { 186 | assert.isNotNull(data.timestamp); 187 | }); 188 | }); 189 | 190 | it('rejects if no repository found', function() { 191 | process.chdir('tests/fixtures/not-a-repo'); 192 | 193 | var plugin = { 194 | stubConfig: { 195 | commitHashLength: 8, 196 | versionFile: 'package.json', 197 | separator: '+' 198 | }, 199 | readConfig: function(key) { return this.stubConfig[key]; } 200 | }; 201 | 202 | var subject = new DataGenerator({ 203 | plugin: plugin 204 | }); 205 | 206 | return assert.isRejected(subject.generate()) 207 | .then(function(error) { 208 | assert.equal(error, 'Could not find git repository'); 209 | }); 210 | }); 211 | 212 | it('rejects when the version source file doesn\'t exist', function() { 213 | process.chdir('tests/fixtures/repo'); 214 | 215 | var plugin = { 216 | stubConfig: { 217 | commitHashLength: 8, 218 | versionFile: 'tests/fixtures/missing-version.json', 219 | separator: '+' 220 | }, 221 | readConfig: function(key) { return this.stubConfig[key]; } 222 | }; 223 | 224 | var subject = new DataGenerator({ 225 | plugin: plugin 226 | }); 227 | 228 | return assert.isRejected(subject.generate()); 229 | }); 230 | }); 231 | }); 232 | -------------------------------------------------------------------------------- /tests/unit/lib/scm-data-generators/git-test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var assert = require('../../../helpers/assert'); 4 | var gitRepoInfo = require('git-repo-info'); 5 | var ScmDataGenerator = require('../../../../lib/scm-data-generators/git'); 6 | 7 | describe('the git scm data generator', function() { 8 | var cwd; 9 | 10 | before(function() { 11 | gitRepoInfo._changeGitDir('dotgit'); 12 | }); 13 | 14 | beforeEach(function() { 15 | cwd = process.cwd(); 16 | }); 17 | 18 | afterEach(function() { 19 | process.chdir(cwd); 20 | }); 21 | 22 | describe('#generate', function() { 23 | it('returns the correct data', function() { 24 | process.chdir('tests/fixtures/repo'); 25 | 26 | var subject = new ScmDataGenerator('dotgit'); 27 | 28 | return assert.isFulfilled(subject.generate()) 29 | .then(function(data) { 30 | assert.equal(data.sha, '41d41f081b45ad50935c08b1203220737d9739b4'); 31 | assert.equal(data.email, 'alisdair@mcdiarmid.org'); 32 | assert.equal(data.name, 'Alisdair McDiarmid'); 33 | assert.equal(data.message, 'Initial commit') 34 | assert.isNotNull(data.timestamp); 35 | assert.equal(data.branch, 'master'); 36 | assert.equal(data.tag, '2.3.4'); 37 | }); 38 | }); 39 | }); 40 | }); 41 | --------------------------------------------------------------------------------