Skip to content

Commit

Permalink
feat: migrate from dot to lodash.template
Browse files Browse the repository at this point in the history
BREAKING CHANGE: dot syntax is no longer supported 
closes #99
  • Loading branch information
oljekechoro authored Sep 24, 2020
1 parent 53d2642 commit fbf3902
Show file tree
Hide file tree
Showing 7 changed files with 866 additions and 600 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ node_js:

before_install:
- npm install -g yarn
- npm install -g greenkeeper-lockfile

before_script:
- yarn link || true && yarn link @qiwi/semantic-release-gh-pages-plugin
- greenkeeper-lockfile-update
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build

after_script:
- greenkeeper-lockfile-upload
- ./cc-test-reporter format-coverage -t lcov ./coverage/lcov.info
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
[![dependencyStatus](https://img.shields.io/david/qiwi/semantic-release-gh-pages-plugin.svg?maxAge=300)](https://david-dm.org/qiwi/semantic-release-gh-pages-plugin)
[![Test Coverage](https://api.codeclimate.com/v1/badges/c149b0666dda28813aa4/test_coverage)](https://codeclimate.com/github/qiwi/semantic-release-gh-pages-plugin/test_coverage)
[![Maintainability](https://api.codeclimate.com/v1/badges/c149b0666dda28813aa4/maintainability)](https://codeclimate.com/github/qiwi/semantic-release-gh-pages-plugin/maintainability)
[![Greenkeeper badge](https://badges.greenkeeper.io/qiwi/semantic-release-gh-pages-plugin.svg)](https://greenkeeper.io/)
[![CodeStyle](https://img.shields.io/badge/code%20style-tslint--config--qiwi-brightgreen.svg)](https://github.com/qiwi/tslint-config-qiwi)

gh-pages publishing plugin for [semantic-release](https://github.com/semantic-release/semantic-release)
Expand Down Expand Up @@ -79,7 +78,7 @@ or even shorter if default settings are used:

| Option | Description | Default |
|-----------------|---------------------------------------------------------| --------|
| `msg` | Commit message template | `updated v{{=it.nextRelease.gitTag}}` |
| `msg` | Commit message template | `docs updated <%= nextRelease.gitTag %>` |
| `src` | Documentation directory | `docs`<br/><br/>**NOTE** don't forget to run docs builder (`yarn docs`, `yarn typedoc`, etc) as a part of your build step or any other way|
| `dst` | Destination directory | `.` (root) |
| `branch` | Docs branch to push | `gh-pages` |
Expand Down
37 changes: 17 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"build:es5": "mkdir -p target/es5 && tsc -p tsconfig.es5.json",
"build:es6": "mkdir -p target/es6 && tsc -p tsconfig.es6.json",
"build:ts": "cp -r src/main/ts/ target/ts/",
"build:libdef": "dts-generator --project ./ --out typings/index.d.ts --prefix @qiwi/semantic-release-gh-pages-plugin/target/es5 --name @qiwi/semantic-release-gh-pages-plugin --main @qiwi/semantic-release-gh-pages-plugin/target/es5/index --moduleResolution node && libdeffix --dts=./typings/index.d.ts --prefix=@qiwi/semantic-release-gh-pages-plugin/target/es5 && flowgen typings/index.d.ts --output-file flow-typed/index.flow.js",
"build:libdef": "libdefkit --tsconfig=tsconfig.es5.json --tsconfig=tsconfig.es6.json",
"test:report": "yarn test && yarn coveralls:push",
"coveralls:push": "cat ./coverage/lcov.info | coveralls",
"docs": "typedoc src/main/ts --ignoreCompilerErrors || exit 0",
Expand All @@ -51,43 +51,40 @@
"dependencies": {
"@types/debug": "^4.1.5",
"@types/git-url-parse": "^9.0.0",
"aggregate-error": "^3.0.1",
"debug": "^4.1.1",
"dot": "^1.1.3",
"aggregate-error": "^3.1.0",
"debug": "^4.2.0",
"execa": "^4.0.3",
"gh-pages": "^3.1.0",
"git-url-parse": "^11.1.2",
"lodash": "^4.17.19",
"queuefy": "^1.1.1",
"git-url-parse": "^11.2.0",
"lodash": "^4.17.20",
"queuefy": "^1.1.2",
"read-pkg": "^5.2.0",
"sync-request": "^6.1.0",
"tslib": "^2.0.0"
"tslib": "^2.0.1"
},
"devDependencies": {
"@qiwi/libdefkit": "^1.0.2",
"@qiwi/libdefkit": "2.0.1",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/git": "^9.0.0",
"@semantic-release/github": "^7.0.7",
"@semantic-release/npm": "^7.0.5",
"@semantic-release/github": "^7.1.1",
"@semantic-release/npm": "^7.0.6",
"@types/aggregate-error": "^1.0.1",
"@types/dot": "^1.1.4",
"@types/gh-pages": "^3.0.0",
"@types/jest": "^26.0.8",
"@types/lodash": "^4.14.158",
"@types/jest": "^26.0.14",
"@types/lodash": "^4.14.161",
"@types/read-pkg": "^5.1.0",
"@types/semantic-release": "^17.1.0",
"coveralls": "^3.1.0",
"eslint-plugin-typescript": "^0.14.0",
"esm": "^3.2.25",
"jest": "^26.2.2",
"semantic-release": "^17.1.1",
"ts-jest": "^26.1.4",
"jest": "^26.4.2",
"semantic-release": "^17.1.2",
"ts-jest": "^26.4.0",
"tslint": "^6.1.3",
"tslint-config-qiwi": "^1.5.0",
"typedoc": "^0.17.8",
"typedoc": "^0.19.2",
"typedoc-plugin-external-module-name": "^4.0.3",
"typescript": "^3.9.7",
"yargs": "^15.4.1"
"typescript": "4.0.3"
},
"release": {
"branch": "master",
Expand Down
2 changes: 1 addition & 1 deletion src/main/ts/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export const PLUGIN_PATH: string = '@qiwi/semantic-release-gh-pages-plugin'
export const DEFAULT_BRANCH: string = 'gh-pages'
export const DEFAULT_SRC: string = 'docs'
export const DEFAULT_DST: string = '.'
export const DEFAULT_MSG: string = 'docs updated {{=it.nextRelease.gitTag}}'
export const DEFAULT_MSG: string = 'docs updated <%= nextRelease.gitTag %>'
export const DEFAULT_ENTERPRISE: boolean = false
export const DEFAULT_PULL_TAGS_BRANCH = 'master'
7 changes: 3 additions & 4 deletions src/main/ts/tpl.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
/** @module semantic-release-gh-pages-plugin */

import { ILogger, TAnyMap } from './interface'
import * as dot from 'dot'
import { template as compile } from 'lodash'

/**
* @private
*/
export const render = (template: string, context: TAnyMap, logger: ILogger) => {
try {
return dot.template(template)(context)

return compile(template)(context)
} catch (err) {
logger.error('dot-template render failure', err)
logger.error('lodash.template render failure', err)

return template
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/ts/tpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ describe('tpl', () => {
}

it('inject data to string', () => {
expect(render('foo {{=it.bar}}', { bar: 'baz' }, logger)).toBe('foo baz')
expect(render('foo <%= bar %>', { bar: 'baz' }, logger)).toBe('foo baz')
})

it('returns template as is on failure', () => {
const res = render('foo {{=it.bar.baz}}', { a: { b: 'c' } }, logger)
const res = render('foo <%= bar.baz %>', { a: { b: 'c' } }, logger)

expect(error).toHaveBeenCalledWith('dot-template render failure', expect.any(Object))
expect(res).toBe('foo {{=it.bar.baz}}')
expect(error).toHaveBeenCalledWith('lodash.template render failure', expect.any(Object))
expect(res).toBe('foo <%= bar.baz %>')
})
})
Loading

0 comments on commit fbf3902

Please sign in to comment.