├── .editorconfig ├── .ember-cli ├── .eslintignore ├── .eslintrc.js ├── .github └── workflows │ ├── ci.yml │ └── publish.yml ├── .gitignore ├── .npmignore ├── .prettierignore ├── .prettierrc.js ├── .stylelintignore ├── .stylelintrc.js ├── .template-lintrc.js ├── .watchmanconfig ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── RELEASE.md ├── addon ├── initializer-factory.js └── utils │ └── regexp.js ├── app ├── helpers │ └── app-version.js └── initializers │ └── app-version.js ├── ember-cli-build.js ├── index.js ├── package.json ├── testem.js ├── tests ├── acceptance │ └── index-test.js ├── dummy │ ├── app │ │ ├── app.js │ │ ├── components │ │ │ └── .gitkeep │ │ ├── controllers │ │ │ └── .gitkeep │ │ ├── helpers │ │ │ └── .gitkeep │ │ ├── index.html │ │ ├── models │ │ │ └── .gitkeep │ │ ├── router.js │ │ ├── routes │ │ │ └── .gitkeep │ │ ├── styles │ │ │ └── app.css │ │ └── templates │ │ │ └── application.hbs │ ├── config │ │ ├── ember-cli-update.json │ │ ├── ember-try.js │ │ ├── environment.js │ │ ├── optional-features.json │ │ └── targets.js │ └── public │ │ └── robots.txt ├── helpers │ └── index.js ├── index.html ├── integration │ └── helpers │ │ └── app-version-test.js ├── test-helper.js └── unit │ ├── helpers │ └── app-version-test.js │ ├── libraries-test.js │ └── utils │ └── regexp-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 | end_of_line = lf 9 | charset = utf-8 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | indent_style = space 13 | indent_size = 2 14 | 15 | [*.hbs] 16 | insert_final_newline = false 17 | 18 | [*.{diff,md}] 19 | trim_trailing_whitespace = false 20 | -------------------------------------------------------------------------------- /.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 | /** 11 | Setting `isTypeScriptProject` to true will force the blueprint generators to generate TypeScript 12 | rather than JavaScript by default, when a TypeScript version of a given blueprint is available. 13 | */ 14 | "isTypeScriptProject": false 15 | } 16 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | # unconventional js 2 | /blueprints/*/files/ 3 | 4 | # compiled output 5 | /dist/ 6 | 7 | # misc 8 | /coverage/ 9 | !.* 10 | .*/ 11 | 12 | # ember-try 13 | /.node_modules.ember-try/ 14 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | root: true, 5 | parser: '@babel/eslint-parser', 6 | parserOptions: { 7 | ecmaVersion: 'latest', 8 | sourceType: 'module', 9 | requireConfigFile: false, 10 | babelOptions: { 11 | plugins: [ 12 | ['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }], 13 | ], 14 | }, 15 | }, 16 | plugins: ['ember'], 17 | extends: [ 18 | 'eslint:recommended', 19 | 'plugin:ember/recommended', 20 | 'plugin:prettier/recommended', 21 | ], 22 | env: { 23 | browser: true, 24 | }, 25 | rules: {}, 26 | overrides: [ 27 | // node files 28 | { 29 | files: [ 30 | './.eslintrc.js', 31 | './.prettierrc.js', 32 | './.stylelintrc.js', 33 | './.template-lintrc.js', 34 | './ember-cli-build.js', 35 | './index.js', 36 | './testem.js', 37 | './blueprints/*/index.js', 38 | './config/**/*.js', 39 | './tests/dummy/config/**/*.js', 40 | ], 41 | parserOptions: { 42 | sourceType: 'script', 43 | }, 44 | env: { 45 | browser: false, 46 | node: true, 47 | }, 48 | }, 49 | { 50 | // test files 51 | files: ['tests/**/*-test.{js,ts}'], 52 | extends: ['plugin:qunit/recommended'], 53 | }, 54 | ], 55 | }; 56 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - master 8 | pull_request: {} 9 | 10 | concurrency: 11 | group: ci-${{ github.head_ref || github.ref }} 12 | cancel-in-progress: true 13 | 14 | jobs: 15 | test: 16 | name: "Tests" 17 | runs-on: ubuntu-latest 18 | timeout-minutes: 10 19 | 20 | steps: 21 | - uses: actions/checkout@v3 22 | - name: Install Node 23 | uses: actions/setup-node@v3 24 | with: 25 | node-version: 18 26 | cache: yarn 27 | - name: Install Dependencies 28 | run: yarn install --frozen-lockfile 29 | - name: Lint 30 | run: yarn lint 31 | - name: Run Tests 32 | run: yarn test:ember 33 | 34 | floating: 35 | name: "Floating Dependencies" 36 | runs-on: ubuntu-latest 37 | timeout-minutes: 10 38 | 39 | steps: 40 | - uses: actions/checkout@v3 41 | - uses: actions/setup-node@v3 42 | with: 43 | node-version: 18 44 | cache: yarn 45 | - name: Install Dependencies 46 | run: yarn install --no-lockfile 47 | - name: Run Tests 48 | run: yarn test:ember 49 | 50 | try-scenarios: 51 | name: ${{ matrix.try-scenario }} 52 | runs-on: ubuntu-latest 53 | needs: "test" 54 | timeout-minutes: 10 55 | 56 | strategy: 57 | fail-fast: false 58 | matrix: 59 | try-scenario: 60 | - ember-lts-3.28 61 | - ember-lts-4.4 62 | - ember-lts-4.8 63 | - ember-lts-4.12 64 | - ember-lts-5.4 65 | - ember-lts-5.8 66 | - ember-release 67 | - ember-beta 68 | - ember-canary 69 | - ember-classic 70 | - embroider-safe 71 | # - embroider-optimized 72 | 73 | steps: 74 | - uses: actions/checkout@v3 75 | - name: Install Node 76 | uses: actions/setup-node@v3 77 | with: 78 | node-version: 18 79 | cache: yarn 80 | - name: Install Dependencies 81 | run: yarn install --frozen-lockfile 82 | - name: Run Tests 83 | run: ./node_modules/.bin/ember try:one ${{ matrix.try-scenario }} 84 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | push: 5 | tags: 6 | - v* 7 | 8 | jobs: 9 | publish: 10 | name: Publish to npm 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout 14 | uses: actions/checkout@v3 15 | 16 | - name: Install node 17 | uses: actions/setup-node@v3 18 | with: 19 | node-version: 18.x 20 | registry-url: 'https://registry.npmjs.org' 21 | 22 | - name: install dependencies 23 | run: yarn install --frozen-lockfile 24 | 25 | - name: auto-dist-tag 26 | run: npx auto-dist-tag --write 27 | 28 | - name: publish to npm 29 | run: npm publish 30 | env: 31 | NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist/ 3 | 4 | # dependencies 5 | /node_modules/ 6 | 7 | # misc 8 | /.eslintcache 9 | /.env* 10 | /.pnp* 11 | /.eslintcache 12 | /coverage/ 13 | /npm-debug.log* 14 | /testem.log 15 | /yarn-error.log 16 | 17 | # ember-try 18 | /.node_modules.ember-try/ 19 | /npm-shrinkwrap.json.ember-try 20 | /package.json.ember-try 21 | /package-lock.json.ember-try 22 | /yarn.lock.ember-try 23 | 24 | # broccoli-debug 25 | /DEBUG/ 26 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist/ 3 | /tmp/ 4 | 5 | # misc 6 | /.editorconfig 7 | /.ember-cli 8 | /.env* 9 | /.eslintcache 10 | /.eslintignore 11 | /.eslintrc.js 12 | /.git/ 13 | /.github/ 14 | /.gitignore 15 | /.prettierignore 16 | /.prettierrc.js 17 | /.stylelintignore 18 | /.stylelintrc.js 19 | /.template-lintrc.js 20 | /.travis.yml 21 | /.watchmanconfig 22 | /CONTRIBUTING.md 23 | /ember-cli-build.js 24 | /testem.js 25 | /tests/ 26 | /yarn-error.log 27 | /yarn.lock 28 | .gitkeep 29 | 30 | # ember-try 31 | /.node_modules.ember-try/ 32 | /npm-shrinkwrap.json.ember-try 33 | /package.json.ember-try 34 | /package-lock.json.ember-try 35 | /yarn.lock.ember-try 36 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # unconventional js 2 | /blueprints/*/files/ 3 | 4 | # compiled output 5 | /dist/ 6 | 7 | # misc 8 | /coverage/ 9 | !.* 10 | .*/ 11 | 12 | # ember-try 13 | /.node_modules.ember-try/ 14 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | overrides: [ 5 | { 6 | files: '*.{js,ts}', 7 | options: { 8 | singleQuote: true, 9 | }, 10 | }, 11 | ], 12 | }; 13 | -------------------------------------------------------------------------------- /.stylelintignore: -------------------------------------------------------------------------------- 1 | # unconventional files 2 | /blueprints/*/files/ 3 | 4 | # compiled output 5 | /dist/ 6 | 7 | # addons 8 | /.node_modules.ember-try/ 9 | -------------------------------------------------------------------------------- /.stylelintrc.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: ['stylelint-config-standard', 'stylelint-prettier/recommended'], 5 | }; 6 | -------------------------------------------------------------------------------- /.template-lintrc.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: 'recommended', 5 | 6 | rules: { 7 | 'no-implicit-this': { allow: ['app-version'] }, 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | { 2 | "ignore_dirs": ["dist"] 3 | } 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | 4 | 5 | 6 | ## v7.0.0 (2024-06-10) 7 | 8 | #### :boom: Breaking Change 9 | * [#415](https://github.com/ember-cli/ember-cli-app-version/pull/415) Drop node < 18, unblocks 'Floating Dependencies' on #414 ([@NullVoxPopuli](https://github.com/NullVoxPopuli)) 10 | 11 | #### :rocket: Enhancement 12 | * [#416](https://github.com/ember-cli/ember-cli-app-version/pull/416) Do not use Ember Barrel file import ([@NullVoxPopuli](https://github.com/NullVoxPopuli)) 13 | 14 | #### :house: Internal 15 | * [#414](https://github.com/ember-cli/ember-cli-app-version/pull/414) Expand ember-try matrix ([@NullVoxPopuli](https://github.com/NullVoxPopuli)) 16 | 17 | #### Committers: 1 18 | - [@NullVoxPopuli](https://github.com/NullVoxPopuli) 19 | 20 | ## v6.0.1 (2023-06-15) 21 | 22 | #### :bug: Bug Fix 23 | * [#410](https://github.com/ember-cli/ember-cli-app-version/pull/410) Loosen peer dependency to indicate support for ember 5 ([@jacobnlsn](https://github.com/jacobnlsn)) 24 | 25 | #### :house: Internal 26 | * [#411](https://github.com/ember-cli/ember-cli-app-version/pull/411) Update addon blueprint ([@NullVoxPopuli](https://github.com/NullVoxPopuli)) 27 | 28 | #### Committers: 2 29 | - Jacob Nelson ([@jacobnlsn](https://github.com/jacobnlsn)) 30 | - [@NullVoxPopuli](https://github.com/NullVoxPopuli) 31 | 32 | 33 | ## v6.0.0 (2023-02-02) 34 | 35 | #### :boom: Breaking Change 36 | * [#388](https://github.com/ember-cli/ember-cli-app-version/pull/388) Drop support for Ember versions below v3.28, Drop support for Node versions below v14 ([@rpemberton](https://github.com/rpemberton)) 37 | 38 | #### :rocket: Enhancement 39 | * [#398](https://github.com/ember-cli/ember-cli-app-version/pull/398) Remove use of `@ember/string` to avoid `ember-string.add-package` deprecation ([@bertdeblock](https://github.com/bertdeblock)) 40 | 41 | #### :house: Internal 42 | * [#392](https://github.com/ember-cli/ember-cli-app-version/pull/392) Remove `config/environment.js` entry from `files` in `package.json` file ([@bertdeblock](https://github.com/bertdeblock)) 43 | 44 | #### Committers: 3 45 | - Bert De Block ([@bertdeblock](https://github.com/bertdeblock)) 46 | - Katie Gengler ([@kategengler](https://github.com/kategengler)) 47 | - rpemberton ([@rpemberton](https://github.com/rpemberton)) 48 | 49 | 50 | ## v5.0.0 (2021-03-08) 51 | 52 | #### :boom: Breaking Change 53 | * [#331](https://github.com/ember-cli/ember-cli-app-version/pull/331) Drop support for Node 13 ([@loganrosen](https://github.com/loganrosen)) 54 | * [#331](https://github.com/ember-cli/ember-cli-app-version/pull/331) Drop support for Ember < 3.12 ([@loganrosen](https://github.com/loganrosen)) 55 | 56 | #### :house: Internal 57 | * [#331](https://github.com/ember-cli/ember-cli-app-version/pull/331) Update ember-cli blueprint to latest ([@loganrosen](https://github.com/loganrosen)) 58 | 59 | #### Committers: 2 60 | - Logan Rosen ([@loganrosen](https://github.com/loganrosen)) 61 | - [@dependabot-preview[bot]](https://github.com/apps/dependabot-preview) 62 | 63 | 64 | ## v4.0.0 (2020-10-09) 65 | 66 | #### :boom: Breaking Change 67 | * [#295](https://github.com/ember-cli/ember-cli-app-version/pull/295) Drop Node < 10 support; Upgrade ember-cli-babel to ^7.0.0. ([@nlfurniss](https://github.com/nlfurniss)) 68 | * [#105](https://github.com/ember-cli/ember-cli-app-version/pull/105) Drop support for Node 4 ([@Turbo87](https://github.com/Turbo87)) 69 | 70 | #### :rocket: Enhancement 71 | * [#68](https://github.com/ember-cli/ember-cli-app-version/pull/68) Replace `git-repo-version` dependency with `git-repo-info` ([@luxferresum](https://github.com/luxferresum)) 72 | 73 | #### :house: Internal 74 | * [#104](https://github.com/ember-cli/ember-cli-app-version/pull/104) Replace `ember-cli-eslint` with raw ESLint ([@Turbo87](https://github.com/Turbo87)) 75 | 76 | #### Committers: 4 77 | - Lukas Kohler ([@luxferresum](https://github.com/luxferresum)) 78 | - Nathaniel Furniss ([@nlfurniss](https://github.com/nlfurniss)) 79 | - Tobias Bieniek ([@Turbo87](https://github.com/Turbo87)) 80 | - [@dependabot-preview[bot]](https://github.com/apps/dependabot-preview) 81 | 82 | 83 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How To Contribute 2 | 3 | ## Installation 4 | 5 | * `git clone https://github.com/ember-cli/ember-addon-output.git` 6 | * `cd ember-cli-app-version` 7 | * `yarn install` 8 | 9 | ## Linting 10 | 11 | * `yarn lint` 12 | * `yarn lint:fix` 13 | 14 | ## Running tests 15 | 16 | * `ember test` – Runs the test suite on the current Ember version 17 | * `ember test --server` – Runs the test suite in "watch mode" 18 | * `ember try:each` – Runs the test suite against multiple Ember versions 19 | 20 | ## Running the dummy application 21 | 22 | * `ember serve` 23 | * Visit the dummy application at [http://localhost:4200](http://localhost:4200). 24 | 25 | For more information on using ember-cli, visit [https://cli.emberjs.com/release/](https://cli.emberjs.com/release/). 26 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 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-app-version 2 | 3 | [![CI](https://github.com/ember-cli/ember-cli-app-version/workflows/CI/badge.svg)](https://github.com/ember-cli/ember-cli-app-version/actions?query=workflow%3ACI) 4 | [![NPM Version](https://badge.fury.io/js/ember-cli-app-version.svg)](https://badge.fury.io/js/ember-cli-app-version) 5 | [![Ember Observer Score](https://emberobserver.com/badges/ember-cli-app-version.svg)](https://emberobserver.com/addons/ember-cli-app-version) 6 | 7 | Adds your Ember App's version to Info tab in Ember Inspector. The version is taken from your project's package.json#version. 8 | If you add build metadata to the version, this addon will automatically append SHA to the end of the version. 9 | 10 | ## Compatibility 11 | 12 | - Ember.js v3.28 or above 13 | - Ember CLI v3.28 or above 14 | - Node.js v18 or above 15 | 16 | ## Installation 17 | 18 | ``` 19 | ember install ember-cli-app-version 20 | ``` 21 | 22 | ## Usage 23 | 24 | ![Ember Inspector Info Tab](https://www.evernote.com/shard/s51/sh/c2f52608-bc17-4d5c-ac76-dec044eeb2e2/2f08de0cfb77217502cfc3a9188d84bf/res/3fb1d3d9-d809-48f6-9d3b-6e9a4af29892/skitch.png?resizeSmall&width=832) 25 | 26 | ## {{app-version}} helper 27 | 28 | This addon provides `{{app-version}}` helper that allows you to show your current app version in your app. 29 | 30 | The addon has flags to display parts of the version: 31 | 32 | - `{{app-version versionOnly=true}} // => 2.0.1` 33 | - `{{app-version versionOnly=true showExtended=true}} // => 2.0.1-alpha.1` 34 | - `{{app-version shaOnly=true}} // => ` 35 | 36 | Flags are `false` by default. 37 | 38 | ## Heroku 39 | 40 | When running on Heroku the `.git` folder is not present, making it impossible to fetch the `git SHA`. A workaround for this is adding the below in your `config/environment.js`: 41 | 42 | ```js 43 | // Heroku Git Hash support 44 | if (process.env.SOURCE_VERSION) { 45 | const pkg = require('../package.json'); 46 | const hash = process.env.SOURCE_VERSION.substr(0, 7); 47 | ENV['ember-cli-app-version'] = { 48 | version: `${pkg.version}+${hash}`, 49 | }; 50 | } 51 | ``` 52 | 53 | ## Contributing 54 | 55 | See the [Contributing](CONTRIBUTING.md) guide for details. 56 | 57 | ## License 58 | 59 | This project is licensed under the [MIT License](LICENSE.md). 60 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /addon/initializer-factory.js: -------------------------------------------------------------------------------- 1 | import { libraries } from '@ember/-internals/metal'; 2 | 3 | export default function initializerFactory(name, version) { 4 | let registered = false; 5 | 6 | return function () { 7 | if (!registered && name && version) { 8 | libraries.register(name, version); 9 | registered = true; 10 | } 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /addon/utils/regexp.js: -------------------------------------------------------------------------------- 1 | export const versionRegExp = /\d+[.]\d+[.]\d+/; // Match any number of 3 sections of digits separated by . 2 | export const versionExtendedRegExp = /\d+[.]\d+[.]\d+-[a-z]*([.]\d+)?/; // Match the above but also hyphen followed by any number of lowercase letters, then optionally period and digits 3 | export const shaRegExp = /[a-z\d]{8}$/; // Match 8 lowercase letters and digits, at the end of the string only (to avoid matching with version extended part) 4 | -------------------------------------------------------------------------------- /app/helpers/app-version.js: -------------------------------------------------------------------------------- 1 | import { helper } from '@ember/component/helper'; 2 | import config from '../config/environment'; 3 | import { 4 | shaRegExp, 5 | versionRegExp, 6 | versionExtendedRegExp, 7 | } from 'ember-cli-app-version/utils/regexp'; 8 | 9 | export function appVersion(_, hash = {}) { 10 | const version = config.APP.version; 11 | // e.g. 1.0.0-alpha.1+4jds75hf 12 | 13 | // Allow use of 'hideSha' and 'hideVersion' For backwards compatibility 14 | let versionOnly = hash.versionOnly || hash.hideSha; 15 | let shaOnly = hash.shaOnly || hash.hideVersion; 16 | 17 | let match = null; 18 | 19 | if (versionOnly) { 20 | if (hash.showExtended) { 21 | match = version.match(versionExtendedRegExp); // 1.0.0-alpha.1 22 | } 23 | // Fallback to just version 24 | if (!match) { 25 | match = version.match(versionRegExp); // 1.0.0 26 | } 27 | } 28 | 29 | if (shaOnly) { 30 | match = version.match(shaRegExp); // 4jds75hf 31 | } 32 | 33 | return match ? match[0] : version; 34 | } 35 | 36 | export default helper(appVersion); 37 | -------------------------------------------------------------------------------- /app/initializers/app-version.js: -------------------------------------------------------------------------------- 1 | import initializerFactory from 'ember-cli-app-version/initializer-factory'; 2 | import config from '../config/environment'; 3 | 4 | let name, version; 5 | if (config.APP) { 6 | name = config.APP.name; 7 | version = config.APP.version; 8 | } 9 | 10 | export default { 11 | name: 'App Version', 12 | initialize: initializerFactory(name, version), 13 | }; 14 | -------------------------------------------------------------------------------- /ember-cli-build.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); 4 | 5 | module.exports = function (defaults) { 6 | const app = new EmberAddon(defaults, { 7 | // Add options here 8 | }); 9 | 10 | /* 11 | This build file specifies the options for the dummy test app of this 12 | addon, located in `/tests/dummy` 13 | This build file does *not* influence how the addon or the app using it 14 | behave. You most likely want to be modifying `./index.js` or app's build file 15 | */ 16 | 17 | const { maybeEmbroider } = require('@embroider/test-setup'); 18 | return maybeEmbroider(app, { 19 | skipBabel: [ 20 | { 21 | package: 'qunit', 22 | }, 23 | ], 24 | }); 25 | }; 26 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const getGitInfo = require('git-repo-info'); 4 | const path = require('path'); 5 | 6 | function gitRepoVersion(options) { 7 | options = options || {}; 8 | let shaLength = options.shaLength != null ? options.shaLength : 8; 9 | let includeDate = options.includeDate || false; 10 | let projectPath = options.projectPath || process.cwd(); 11 | let info = getGitInfo(projectPath); 12 | let packageVersion = require(path.join(projectPath, 'package.json')).version; 13 | 14 | let prefix; 15 | if (info.tag && !(packageVersion && info.tag.includes(packageVersion))) { 16 | prefix = info.tag; 17 | } else if (packageVersion) { 18 | prefix = packageVersion; 19 | } else if (info.branch) { 20 | prefix = info.branch; 21 | } else { 22 | prefix = 'DETACHED_HEAD'; 23 | } 24 | 25 | let sha = ''; 26 | if (shaLength > 0 && info.sha) { 27 | sha = '+' + info.sha.substring(0, shaLength); 28 | } 29 | 30 | let authorDate = includeDate ? ' ' + info.authorDate : ''; 31 | 32 | return prefix + sha + authorDate; 33 | } 34 | 35 | module.exports = { 36 | name: require('./package').name, 37 | config(env, baseConfig) { 38 | let config = this._super.config.apply(this, arguments); 39 | 40 | if (!baseConfig.APP) { 41 | return config; 42 | } 43 | 44 | baseConfig.APP.name = this.project.pkg.name; 45 | 46 | if (baseConfig[this.name] && baseConfig[this.name].version) { 47 | baseConfig.APP.version = baseConfig[this.name].version; 48 | return config; 49 | } 50 | 51 | let version = gitRepoVersion(null, this.project.root); 52 | if (version && baseConfig.APP) { 53 | baseConfig.APP.version = version; 54 | } 55 | 56 | return config; 57 | }, 58 | }; 59 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-cli-app-version", 3 | "version": "7.0.0", 4 | "description": "Adds App version number to Ember Inspector Info Tab", 5 | "keywords": [ 6 | "ember-addon" 7 | ], 8 | "repository": "https://github.com/ember-cli/ember-cli-app-version.git", 9 | "license": "MIT", 10 | "author": "Taras Mankovski ", 11 | "directories": { 12 | "doc": "doc", 13 | "test": "tests" 14 | }, 15 | "files": [ 16 | "addon/", 17 | "app/", 18 | "index.js" 19 | ], 20 | "scripts": { 21 | "build": "ember build --environment=production", 22 | "lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"", 23 | "lint:css": "stylelint \"**/*.css\"", 24 | "lint:css:fix": "concurrently \"npm:lint:css -- --fix\"", 25 | "lint:fix": "concurrently \"npm:lint:*:fix\" --names \"fix:\"", 26 | "lint:hbs": "ember-template-lint .", 27 | "lint:hbs:fix": "ember-template-lint . --fix", 28 | "lint:js": "eslint . --cache", 29 | "lint:js:fix": "eslint . --fix", 30 | "start": "ember serve", 31 | "test": "concurrently \"npm:lint\" \"npm:test:*\" --names \"lint,test:\"", 32 | "test:ember": "ember test", 33 | "test:ember-compatibility": "ember try:each" 34 | }, 35 | "dependencies": { 36 | "ember-cli-babel": "^7.26.11", 37 | "git-repo-info": "^2.1.1" 38 | }, 39 | "devDependencies": { 40 | "@babel/eslint-parser": "^7.22.5", 41 | "@babel/plugin-proposal-decorators": "^7.22.5", 42 | "@ember/optional-features": "^2.0.0", 43 | "@ember/string": "^3.1.1", 44 | "@ember/test-helpers": "^2.7.0", 45 | "@embroider/test-setup": "^3.0.1", 46 | "@glimmer/component": "^1.1.2", 47 | "@glimmer/tracking": "^1.1.2", 48 | "@release-it-plugins/lerna-changelog": "^5.0.0", 49 | "concurrently": "^8.2.0", 50 | "ember-auto-import": "^2.6.3", 51 | "ember-cli": "^4.12.0", 52 | "ember-cli-dependency-checker": "^3.3.1", 53 | "ember-cli-htmlbars": "^6.2.0", 54 | "ember-cli-inject-live-reload": "^2.1.0", 55 | "ember-load-initializers": "^2.1.2", 56 | "ember-page-title": "^7.0.0", 57 | "ember-qunit": "^6.0.0", 58 | "ember-resolver": "^10.1.0", 59 | "ember-source": "^4.12.0", 60 | "ember-source-channel-url": "^3.0.0", 61 | "ember-template-lint": "^5.10.1", 62 | "ember-try": "^2.0.0", 63 | "eslint": "^8.42.0", 64 | "eslint-config-prettier": "^8.8.0", 65 | "eslint-plugin-ember": "^11.8.0", 66 | "eslint-plugin-prettier": "^4.2.1", 67 | "eslint-plugin-qunit": "^7.3.4", 68 | "loader.js": "^4.7.0", 69 | "prettier": "^2.8.8", 70 | "qunit": "^2.19.4", 71 | "qunit-dom": "^2.0.0", 72 | "release-it": "^15.6.0", 73 | "stylelint": "^15.7.0", 74 | "stylelint-config-standard": "^33.0.0", 75 | "stylelint-prettier": "^3.0.0", 76 | "webpack": "^5.86.0" 77 | }, 78 | "peerDependencies": { 79 | "ember-source": "^3.28.0 || >= 4.0.0" 80 | }, 81 | "engines": { 82 | "node": ">= 18" 83 | }, 84 | "publishConfig": { 85 | "registry": "https://registry.npmjs.org" 86 | }, 87 | "ember": { 88 | "edition": "octane" 89 | }, 90 | "ember-addon": { 91 | "configPath": "tests/dummy/config" 92 | }, 93 | "release-it": { 94 | "plugins": { 95 | "@release-it-plugins/lerna-changelog": { 96 | "infile": "CHANGELOG.md", 97 | "launchEditor": true 98 | } 99 | }, 100 | "git": { 101 | "tagName": "v${version}" 102 | }, 103 | "github": { 104 | "release": true, 105 | "tokenRef": "GITHUB_AUTH" 106 | }, 107 | "npm": { 108 | "publish": false 109 | } 110 | }, 111 | "volta": { 112 | "node": "18.16.0", 113 | "yarn": "1.22.19" 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /testem.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | test_page: 'tests/index.html?hidepassed', 5 | disable_watching: true, 6 | launch_in_ci: ['Chrome'], 7 | launch_in_dev: ['Chrome'], 8 | browser_start_timeout: 120, 9 | browser_args: { 10 | Chrome: { 11 | ci: [ 12 | // --no-sandbox is needed when running Chrome inside a container 13 | process.env.CI ? '--no-sandbox' : null, 14 | '--headless', 15 | '--disable-dev-shm-usage', 16 | '--disable-software-rasterizer', 17 | '--mute-audio', 18 | '--remote-debugging-port=0', 19 | '--window-size=1440,900', 20 | ].filter(Boolean), 21 | }, 22 | }, 23 | }; 24 | -------------------------------------------------------------------------------- /tests/acceptance/index-test.js: -------------------------------------------------------------------------------- 1 | import { module, test } from 'qunit'; 2 | import { visit, currentURL } from '@ember/test-helpers'; 3 | import { setupApplicationTest } from 'ember-qunit'; 4 | import config from 'dummy/config/environment'; 5 | 6 | module('Acceptance | index', function (hooks) { 7 | setupApplicationTest(hooks); 8 | 9 | test('visiting /', async function (assert) { 10 | await visit('/'); 11 | 12 | assert.strictEqual(currentURL(), '/'); 13 | 14 | assert.ok(config.APP.version, 'app version is present'); 15 | 16 | assert 17 | .dom('p.message') 18 | .hasText(`Your app version is ${config.APP.version}`); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /tests/dummy/app/app.js: -------------------------------------------------------------------------------- 1 | import Application from '@ember/application'; 2 | import Resolver from 'ember-resolver'; 3 | import loadInitializers from 'ember-load-initializers'; 4 | import config from 'dummy/config/environment'; 5 | 6 | export default class App extends Application { 7 | modulePrefix = config.modulePrefix; 8 | podModulePrefix = config.podModulePrefix; 9 | Resolver = Resolver; 10 | } 11 | 12 | loadInitializers(App, config.modulePrefix); 13 | -------------------------------------------------------------------------------- /tests/dummy/app/components/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli/ember-cli-app-version/9ca6dd52dbec1570b434b6fc16f7e2a62b95b366/tests/dummy/app/components/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/controllers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli/ember-cli-app-version/9ca6dd52dbec1570b434b6fc16f7e2a62b95b366/tests/dummy/app/controllers/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/helpers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli/ember-cli-app-version/9ca6dd52dbec1570b434b6fc16f7e2a62b95b366/tests/dummy/app/helpers/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Dummy 6 | 7 | 8 | 9 | {{content-for "head"}} 10 | 11 | 12 | 13 | 14 | {{content-for "head-footer"}} 15 | 16 | 17 | {{content-for "body"}} 18 | 19 | 20 | 21 | 22 | {{content-for "body-footer"}} 23 | 24 | 25 | -------------------------------------------------------------------------------- /tests/dummy/app/models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli/ember-cli-app-version/9ca6dd52dbec1570b434b6fc16f7e2a62b95b366/tests/dummy/app/models/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/router.js: -------------------------------------------------------------------------------- 1 | import EmberRouter from '@ember/routing/router'; 2 | import config from 'dummy/config/environment'; 3 | 4 | export default class Router extends EmberRouter { 5 | location = config.locationType; 6 | rootURL = config.rootURL; 7 | } 8 | 9 | Router.map(function () {}); 10 | -------------------------------------------------------------------------------- /tests/dummy/app/routes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ember-cli/ember-cli-app-version/9ca6dd52dbec1570b434b6fc16f7e2a62b95b366/tests/dummy/app/routes/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/styles/app.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | margin: 20px; 4 | } 5 | -------------------------------------------------------------------------------- /tests/dummy/app/templates/application.hbs: -------------------------------------------------------------------------------- 1 | {{page-title "Dummy"}} 2 | 3 |

EmberCLI App Version

4 | 5 |

Your app version is {{app-version}}

6 | -------------------------------------------------------------------------------- /tests/dummy/config/ember-cli-update.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": "1.0.0", 3 | "packages": [ 4 | { 5 | "name": "ember-cli", 6 | "version": "5.0.0", 7 | "blueprints": [ 8 | { 9 | "name": "addon", 10 | "outputRepo": "https://github.com/ember-cli/ember-addon-output", 11 | "codemodsSource": "ember-addon-codemods-manifest@1", 12 | "isBaseBlueprint": true, 13 | "options": [ 14 | "--yarn", 15 | "--no-welcome" 16 | ] 17 | } 18 | ] 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /tests/dummy/config/ember-try.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const getChannelURL = require('ember-source-channel-url'); 4 | const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup'); 5 | 6 | module.exports = async function () { 7 | return { 8 | useYarn: true, 9 | scenarios: [ 10 | { 11 | name: 'ember-lts-3.28', 12 | npm: { 13 | devDependencies: { 14 | 'ember-source': '~3.28.0', 15 | }, 16 | }, 17 | }, 18 | { 19 | name: 'ember-lts-4.4', 20 | npm: { 21 | devDependencies: { 22 | 'ember-source': '~4.4.0', 23 | }, 24 | }, 25 | }, 26 | { 27 | name: 'ember-lts-4.8', 28 | npm: { 29 | devDependencies: { 30 | 'ember-source': '~4.8.0', 31 | }, 32 | }, 33 | }, 34 | { 35 | name: 'ember-lts-4.12', 36 | npm: { 37 | devDependencies: { 38 | 'ember-source': '~4.12.0', 39 | }, 40 | }, 41 | }, 42 | { 43 | name: 'ember-lts-5.4', 44 | npm: { 45 | devDependencies: { 46 | 'ember-source': '~5.4.0', 47 | }, 48 | }, 49 | }, 50 | { 51 | name: 'ember-lts-5.8', 52 | npm: { 53 | devDependencies: { 54 | 'ember-source': '~5.8.0', 55 | }, 56 | }, 57 | }, 58 | { 59 | name: 'ember-release', 60 | npm: { 61 | devDependencies: { 62 | 'ember-source': await getChannelURL('release'), 63 | }, 64 | }, 65 | }, 66 | { 67 | name: 'ember-beta', 68 | npm: { 69 | devDependencies: { 70 | 'ember-source': await getChannelURL('beta'), 71 | }, 72 | }, 73 | }, 74 | { 75 | name: 'ember-canary', 76 | npm: { 77 | devDependencies: { 78 | 'ember-source': await getChannelURL('canary'), 79 | }, 80 | }, 81 | }, 82 | { 83 | name: 'ember-classic', 84 | env: { 85 | EMBER_OPTIONAL_FEATURES: JSON.stringify({ 86 | 'application-template-wrapper': true, 87 | 'default-async-observers': false, 88 | 'template-only-glimmer-components': false, 89 | }), 90 | }, 91 | npm: { 92 | devDependencies: { 93 | 'ember-source': '~3.28.0', 94 | }, 95 | ember: { 96 | edition: 'classic', 97 | }, 98 | }, 99 | }, 100 | embroiderSafe(), 101 | embroiderOptimized(), 102 | ], 103 | }; 104 | }; 105 | -------------------------------------------------------------------------------- /tests/dummy/config/environment.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function (environment) { 4 | const ENV = { 5 | modulePrefix: 'dummy', 6 | environment, 7 | rootURL: '/', 8 | locationType: 'history', 9 | EmberENV: { 10 | EXTEND_PROTOTYPES: false, 11 | FEATURES: { 12 | // Here you can enable experimental features on an ember canary build 13 | // e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true 14 | }, 15 | }, 16 | 17 | APP: { 18 | // Here you can pass flags/options to your application instance 19 | // when it is created 20 | }, 21 | }; 22 | 23 | if (environment === 'development') { 24 | // ENV.APP.LOG_RESOLVER = true; 25 | // ENV.APP.LOG_ACTIVE_GENERATION = true; 26 | // ENV.APP.LOG_TRANSITIONS = true; 27 | // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; 28 | // ENV.APP.LOG_VIEW_LOOKUPS = true; 29 | } 30 | 31 | if (environment === 'test') { 32 | // Testem prefers this... 33 | ENV.locationType = 'none'; 34 | 35 | // keep test console output quieter 36 | ENV.APP.LOG_ACTIVE_GENERATION = false; 37 | ENV.APP.LOG_VIEW_LOOKUPS = false; 38 | 39 | ENV.APP.rootElement = '#ember-testing'; 40 | ENV.APP.autoboot = false; 41 | } 42 | 43 | if (environment === 'production') { 44 | // here you can enable a production-specific feature 45 | } 46 | 47 | return ENV; 48 | }; 49 | -------------------------------------------------------------------------------- /tests/dummy/config/optional-features.json: -------------------------------------------------------------------------------- 1 | { 2 | "application-template-wrapper": false, 3 | "default-async-observers": true, 4 | "jquery-integration": false, 5 | "template-only-glimmer-components": true 6 | } 7 | -------------------------------------------------------------------------------- /tests/dummy/config/targets.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const browsers = [ 4 | 'last 1 Chrome versions', 5 | 'last 1 Firefox versions', 6 | 'last 1 Safari versions', 7 | ]; 8 | 9 | module.exports = { 10 | browsers, 11 | }; 12 | -------------------------------------------------------------------------------- /tests/dummy/public/robots.txt: -------------------------------------------------------------------------------- 1 | # http://www.robotstxt.org 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /tests/helpers/index.js: -------------------------------------------------------------------------------- 1 | import { 2 | setupApplicationTest as upstreamSetupApplicationTest, 3 | setupRenderingTest as upstreamSetupRenderingTest, 4 | setupTest as upstreamSetupTest, 5 | } from 'ember-qunit'; 6 | 7 | // This file exists to provide wrappers around ember-qunit's / ember-mocha's 8 | // test setup functions. This way, you can easily extend the setup that is 9 | // needed per test type. 10 | 11 | function setupApplicationTest(hooks, options) { 12 | upstreamSetupApplicationTest(hooks, options); 13 | 14 | // Additional setup for application tests can be done here. 15 | // 16 | // For example, if you need an authenticated session for each 17 | // application test, you could do: 18 | // 19 | // hooks.beforeEach(async function () { 20 | // await authenticateSession(); // ember-simple-auth 21 | // }); 22 | // 23 | // This is also a good place to call test setup functions coming 24 | // from other addons: 25 | // 26 | // setupIntl(hooks); // ember-intl 27 | // setupMirage(hooks); // ember-cli-mirage 28 | } 29 | 30 | function setupRenderingTest(hooks, options) { 31 | upstreamSetupRenderingTest(hooks, options); 32 | 33 | // Additional setup for rendering tests can be done here. 34 | } 35 | 36 | function setupTest(hooks, options) { 37 | upstreamSetupTest(hooks, options); 38 | 39 | // Additional setup for unit tests can be done here. 40 | } 41 | 42 | export { setupApplicationTest, setupRenderingTest, setupTest }; 43 | -------------------------------------------------------------------------------- /tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Dummy Tests 6 | 7 | 8 | 9 | {{content-for "head"}} 10 | {{content-for "test-head"}} 11 | 12 | 13 | 14 | 15 | 16 | {{content-for "head-footer"}} 17 | {{content-for "test-head-footer"}} 18 | 19 | 20 | {{content-for "body"}} 21 | {{content-for "test-body"}} 22 | 23 |
24 |
25 |
26 |
27 |
28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | {{content-for "body-footer"}} 37 | {{content-for "test-body-footer"}} 38 | 39 | 40 | -------------------------------------------------------------------------------- /tests/integration/helpers/app-version-test.js: -------------------------------------------------------------------------------- 1 | import { module, test } from 'qunit'; 2 | import { setupRenderingTest } from 'ember-qunit'; 3 | import { render } from '@ember/test-helpers'; 4 | import { hbs } from 'ember-cli-htmlbars'; 5 | 6 | module('Integration | Helper | {{app-version}}', function (hooks) { 7 | setupRenderingTest(hooks); 8 | 9 | test('it displays entire version', async function (assert) { 10 | assert.expect(1); 11 | 12 | await render(hbs`{{app-version}}`); 13 | 14 | assert.ok(this.element.textContent, 'Version not empty'); 15 | }); 16 | 17 | test('it displays only app version (backwards compatible)', async function (assert) { 18 | assert.expect(1); 19 | 20 | await render(hbs`{{app-version hideSha=true}}`); 21 | 22 | assert.ok(this.element.textContent, 'Version not empty'); 23 | }); 24 | 25 | test('it displays only app version', async function (assert) { 26 | assert.expect(1); 27 | 28 | await render(hbs`{{app-version versionOnly=true}}`); 29 | 30 | assert.ok(this.element.textContent, 'Version not empty'); 31 | }); 32 | 33 | test('it displays only app version extended', async function (assert) { 34 | assert.expect(1); 35 | 36 | await render(hbs`{{app-version versionOnly=true showExtended=true}}`); 37 | 38 | assert.ok(this.element.textContent, 'Version not empty'); 39 | }); 40 | 41 | test('it displays only git sha (backwards compatible)', async function (assert) { 42 | assert.expect(1); 43 | 44 | await render(hbs`{{app-version hideVersion=true}}`); 45 | 46 | assert.ok(this.element.textContent, 'Version not empty'); 47 | }); 48 | 49 | test('it displays only git sha', async function (assert) { 50 | assert.expect(1); 51 | 52 | await render(hbs`{{app-version shaOnly=true}}`); 53 | 54 | assert.ok(this.element.textContent, 'Version not empty'); 55 | }); 56 | }); 57 | -------------------------------------------------------------------------------- /tests/test-helper.js: -------------------------------------------------------------------------------- 1 | import Application from 'dummy/app'; 2 | import config from 'dummy/config/environment'; 3 | import * as QUnit from 'qunit'; 4 | import { setApplication } from '@ember/test-helpers'; 5 | import { setup } from 'qunit-dom'; 6 | import { start } from 'ember-qunit'; 7 | 8 | setApplication(Application.create(config.APP)); 9 | 10 | setup(QUnit.assert); 11 | 12 | start(); 13 | -------------------------------------------------------------------------------- /tests/unit/helpers/app-version-test.js: -------------------------------------------------------------------------------- 1 | import { appVersion } from 'dummy/helpers/app-version'; 2 | import config from 'dummy/config/environment'; 3 | import { module, test } from 'qunit'; 4 | 5 | const versionOnlyString = '10.20.3'; 6 | const extendedTagOnlyString = 'alpha.15'; 7 | const shaOnlyString = 'deadb33f'; 8 | 9 | const versionString = 10 | versionOnlyString + '-' + extendedTagOnlyString + '+' + shaOnlyString; 11 | const standardVersionString = versionOnlyString + '+' + shaOnlyString; 12 | const oldVersion = config.APP.version; 13 | 14 | module('Unit | Helper | app version', function (hooks) { 15 | hooks.afterEach(function () { 16 | config.APP.version = oldVersion; 17 | }); 18 | 19 | test('it returns app version', function (assert) { 20 | assert.expect(1); 21 | config.APP.version = versionString; 22 | 23 | assert.strictEqual(appVersion(), versionString, 'Returns app version.'); 24 | }); 25 | 26 | test('it returns only app version (backwards compatible)', function (assert) { 27 | assert.expect(1); 28 | 29 | config.APP.version = versionString; 30 | let result = appVersion([], { hideSha: true }); 31 | 32 | assert.strictEqual( 33 | result, 34 | versionOnlyString, 35 | 'Returns app version without git sha.' 36 | ); 37 | }); 38 | 39 | test('it returns only app version', function (assert) { 40 | assert.expect(1); 41 | 42 | config.APP.version = versionString; 43 | let result = appVersion([], { versionOnly: true }); 44 | 45 | assert.strictEqual( 46 | result, 47 | versionOnlyString, 48 | 'Returns app version without git sha.' 49 | ); 50 | }); 51 | 52 | test('it returns only app version extended', function (assert) { 53 | assert.expect(1); 54 | 55 | config.APP.version = versionString; 56 | let result = appVersion([], { versionOnly: true, showExtended: true }); 57 | 58 | assert.strictEqual( 59 | result, 60 | versionOnlyString + '-' + extendedTagOnlyString, 61 | 'Returns app version extended without git sha.' 62 | ); 63 | }); 64 | 65 | test('it returns only app version (falls back when no extended)', function (assert) { 66 | assert.expect(1); 67 | 68 | config.APP.version = standardVersionString; 69 | let result = appVersion([], { versionOnly: true, showExtended: true }); 70 | 71 | assert.strictEqual( 72 | result, 73 | versionOnlyString, 74 | 'Returns app version without git sha.' 75 | ); 76 | }); 77 | 78 | test('it returns only git sha (backwards compatible)', function (assert) { 79 | assert.expect(1); 80 | 81 | config.APP.version = versionString; 82 | let result = appVersion([], { hideVersion: true }); 83 | 84 | assert.strictEqual( 85 | result, 86 | shaOnlyString, 87 | 'Returns git sha without app version.' 88 | ); 89 | }); 90 | 91 | test('it returns only git sha', function (assert) { 92 | assert.expect(1); 93 | 94 | config.APP.version = versionString; 95 | let result = appVersion([], { shaOnly: true }); 96 | 97 | assert.strictEqual( 98 | result, 99 | shaOnlyString, 100 | 'Returns git sha without app version.' 101 | ); 102 | }); 103 | }); 104 | -------------------------------------------------------------------------------- /tests/unit/libraries-test.js: -------------------------------------------------------------------------------- 1 | import config from 'dummy/config/environment'; 2 | import { module, test } from 'qunit'; 3 | 4 | module('App Version', function () { 5 | test('version is available in config', function (assert) { 6 | assert.ok(config.APP.version); 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /tests/unit/utils/regexp-test.js: -------------------------------------------------------------------------------- 1 | import { module, test } from 'qunit'; 2 | import { 3 | shaRegExp, 4 | versionRegExp, 5 | versionExtendedRegExp, 6 | } from 'ember-cli-app-version/utils/regexp'; 7 | 8 | module('Unit | Utility | regexp', function () { 9 | test('version reg ex matches expected strings', function (assert) { 10 | assert.expect(4); 11 | 12 | assert.ok('2.0.1'.match(versionRegExp), 'Matches expected pattern.'); 13 | assert.ok('2.20.1'.match(versionRegExp), 'Matches expected pattern.'); 14 | assert.notOk('a.b.c'.match(versionRegExp), 'Does not match letters.'); 15 | assert.notOk('git12sha'.match(versionRegExp), 'Does not match sha.'); 16 | }); 17 | 18 | test('version extended reg ex matches expected strings', function (assert) { 19 | assert.expect(4); 20 | 21 | assert.ok( 22 | '2.0.1-alpha'.match(versionExtendedRegExp), 23 | 'Matches expected pattern.' 24 | ); 25 | assert.ok( 26 | '2.20.1-alpha.15'.match(versionExtendedRegExp), 27 | 'Matches expected pattern.' 28 | ); 29 | assert.notOk( 30 | 'a.b.c-alpha.15'.match(versionExtendedRegExp), 31 | 'Does not match letters.' 32 | ); 33 | assert.notOk( 34 | 'git12sha'.match(versionExtendedRegExp), 35 | 'Does not match sha.' 36 | ); 37 | }); 38 | 39 | test('git sha reg ex matches expected strings', function (assert) { 40 | assert.expect(4); 41 | 42 | assert.ok('git12sha'.match(shaRegExp), 'Matches expected pattern.'); 43 | assert.notOk('2.0.1'.match(shaRegExp), 'Does not match version pattern.'); 44 | assert.notOk( 45 | '2.0.1-alpha.15'.match(shaRegExp), 46 | 'Does not match version extended pattern.' 47 | ); 48 | assert.notOk( 49 | '2.0.1-alphaabc.15'.match(shaRegExp), 50 | 'Does not match version extended pattern (with 8 chars in tag name).' 51 | ); 52 | }); 53 | }); 54 | --------------------------------------------------------------------------------