Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ef057e31f | |||
| 494cb72d78 | |||
| 7b27b231ff | |||
| bd9ac0ab46 | |||
| 1c53edca7d | |||
| 6b279824fb | |||
| c06b8e6a18 | |||
| a707dff92d | |||
| 7bad738cb1 | |||
| 0e5db8f6b4 | |||
| deadd463de | |||
| e783dcb1f8 | |||
|
|
62cacffe61 | ||
|
|
df76935a52 | ||
| f078653846 | |||
| 50d70eaece | |||
| 452f086d84 | |||
| 0113d8ea19 |
117
.gitlab-ci.yml
117
.gitlab-ci.yml
@@ -1,59 +1,150 @@
|
|||||||
image: hosttoday/ht-docker-node:npmts
|
# gitzone standard
|
||||||
|
image: hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .npmci_cache/
|
||||||
|
key: "$CI_BUILD_STAGE"
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- trigger
|
- metadata
|
||||||
- pages
|
|
||||||
|
|
||||||
testLEGACY:
|
# ====================
|
||||||
stage: test
|
# security stage
|
||||||
|
# ====================
|
||||||
|
mirror:
|
||||||
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci test legacy
|
- npmci git mirror
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
snyk:
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install -g snyk
|
||||||
|
- npmci command npm install --ignore-scripts
|
||||||
|
- npmci command snyk test
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
sast:
|
||||||
|
stage: security
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-dbase:npmci
|
||||||
|
variables:
|
||||||
|
DOCKER_DRIVER: overlay2
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
services:
|
||||||
|
- docker:stable-dind
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||||
|
- docker run
|
||||||
|
--env SAST_CONFIDENCE_LEVEL="${SAST_CONFIDENCE_LEVEL:-3}"
|
||||||
|
--volume "$PWD:/code"
|
||||||
|
--volume /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
"registry.gitlab.com/gitlab-org/security-products/sast:$SP_VERSION" /app/bin/run /code
|
||||||
|
artifacts:
|
||||||
|
reports:
|
||||||
|
sast: gl-sast-report.json
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# test stage
|
||||||
|
# ====================
|
||||||
|
|
||||||
testLTS:
|
testLTS:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test lts
|
- npmci npm prepare
|
||||||
|
- npmci node install lts
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
testSTABLE:
|
testSTABLE:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test stable
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci publish
|
- npmci node install stable
|
||||||
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# metadata stage
|
||||||
|
# ====================
|
||||||
|
codequality:
|
||||||
|
stage: metadata
|
||||||
|
image: docker:stable
|
||||||
|
allow_failure: true
|
||||||
|
services:
|
||||||
|
- docker:stable-dind
|
||||||
|
script:
|
||||||
|
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||||
|
- docker run
|
||||||
|
--env SOURCE_CODE="$PWD"
|
||||||
|
--volume "$PWD":/code
|
||||||
|
--volume /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
||||||
|
artifacts:
|
||||||
|
paths: [codeclimate.json]
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
stage: trigger
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci trigger
|
- npmci trigger
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmpage
|
image: hosttoday/ht-docker-node:npmci
|
||||||
stage: pages
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command npmpage --host gitlab
|
- npmci command npm install -g typedoc typescript
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
|
allow_failure: true
|
||||||
|
|||||||
4
.snyk
Normal file
4
.snyk
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
|
||||||
|
version: v1.13.3
|
||||||
|
ignore: {}
|
||||||
|
patch: {}
|
||||||
45
README.md
45
README.md
@@ -1,35 +1,40 @@
|
|||||||
# tlt
|
# @pushrocks/smartmustache
|
||||||
templates done right
|
templates done right
|
||||||
|
|
||||||
## Availabililty
|
## Availabililty and Links
|
||||||
[](https://www.npmjs.com/package/tlt)
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartmustache)
|
||||||
[](https://gitlab.com/pushrocks/tlt)
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartmustache)
|
||||||
[](https://github.com/pushrocks/tlt)
|
* [github.com (source mirror)](https://github.com/pushrocks/smartmustache)
|
||||||
[](https://pushrocks.gitlab.io/tlt/)
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartmustache/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
[](https://gitlab.com/pushrocks/tlt/commits/master)
|
[](https://gitlab.com/pushrocks/smartmustache/commits/master)
|
||||||
[](https://gitlab.com/pushrocks/tlt/commits/master)
|
[](https://gitlab.com/pushrocks/smartmustache/commits/master)
|
||||||
[](https://david-dm.org/pushrocks/tlt)
|
[](https://www.npmjs.com/package/@pushrocks/smartmustache)
|
||||||
[](https://www.bithound.io/github/pushrocks/tlt/master/dependencies/npm)
|
[](https://snyk.io/test/npm/@pushrocks/smartmustache)
|
||||||
[](https://www.bithound.io/github/pushrocks/tlt)
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[](http://standardjs.com/)
|
[](http://standardjs.com/)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
We recommend the use of TypeScript for best in class Intellisense
|
|
||||||
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import { Tlt } from 'tlt'
|
import { Tlt } from 'tlt';
|
||||||
|
|
||||||
let myTlt = new Tlt('my {{somePlaceholder}} are {{anotherPlaceholder}}!')
|
let myTlt = new Tlt('my {{somePlaceholder}} are {{anotherPlaceholder}}!');
|
||||||
let appliedString = myTlt.applyData({
|
let appliedString = myTlt.applyData({
|
||||||
"somePlaceholder": "horses",
|
somePlaceholder: 'horses',
|
||||||
"anotherPlaceholder": "awesome"
|
anotherPlaceholder: 'awesome'
|
||||||
})
|
});
|
||||||
|
|
||||||
// appliedString will be 'my horses are awesome!'
|
// appliedString will be 'my horses are awesome!'
|
||||||
```
|
```
|
||||||
|
|
||||||
[](https://push.rocks)
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
||||||
|
|||||||
18
dist/index.d.ts
vendored
18
dist/index.d.ts
vendored
@@ -1,18 +0,0 @@
|
|||||||
/**
|
|
||||||
* class Tlt allows templates to be used with different sets of data
|
|
||||||
*/
|
|
||||||
export declare class Tlt {
|
|
||||||
templateString: string;
|
|
||||||
/**
|
|
||||||
* constructor of class Tlt
|
|
||||||
*/
|
|
||||||
constructor(templateStringArg: string);
|
|
||||||
/**
|
|
||||||
* returns template string with data applied
|
|
||||||
*/
|
|
||||||
applyData(data: any): string;
|
|
||||||
/**
|
|
||||||
* set a new template string
|
|
||||||
*/
|
|
||||||
setTemplate(templateStringArg: string): void;
|
|
||||||
}
|
|
||||||
27
dist/index.js
vendored
27
dist/index.js
vendored
@@ -1,27 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
const mustache = require("mustache");
|
|
||||||
/**
|
|
||||||
* class Tlt allows templates to be used with different sets of data
|
|
||||||
*/
|
|
||||||
class Tlt {
|
|
||||||
/**
|
|
||||||
* constructor of class Tlt
|
|
||||||
*/
|
|
||||||
constructor(templateStringArg) {
|
|
||||||
this.templateString = templateStringArg;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* returns template string with data applied
|
|
||||||
*/
|
|
||||||
applyData(data) {
|
|
||||||
return mustache.render(this.templateString, data);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* set a new template string
|
|
||||||
*/
|
|
||||||
setTemplate(templateStringArg) {
|
|
||||||
this.templateString = templateStringArg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.Tlt = Tlt;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEscUNBQW9DO0FBRXBDOztHQUVHO0FBQ0g7SUFHSTs7T0FFRztJQUNILFlBQVksaUJBQXlCO1FBQ2pDLElBQUksQ0FBQyxjQUFjLEdBQUcsaUJBQWlCLENBQUE7SUFDM0MsQ0FBQztJQUVEOztPQUVHO0lBQ0gsU0FBUyxDQUFDLElBQVM7UUFDZixNQUFNLENBQUMsUUFBUSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsY0FBYyxFQUFFLElBQUksQ0FBQyxDQUFBO0lBQ3JELENBQUM7SUFFRDs7T0FFRztJQUNILFdBQVcsQ0FBQyxpQkFBeUI7UUFDakMsSUFBSSxDQUFDLGNBQWMsR0FBRyxpQkFBaUIsQ0FBQTtJQUMzQyxDQUFDO0NBQ0o7QUF2QkQsa0JBdUJDIn0=
|
|
||||||
15
npmextra.json
Normal file
15
npmextra.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"npmci": {
|
||||||
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "pushrocks",
|
||||||
|
"gitrepo": "smartmustache",
|
||||||
|
"shortDescription": "templates done right",
|
||||||
|
"npmPackagename": "@pushrocks/smartmustache",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1463
package-lock.json
generated
Normal file
1463
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
@@ -1,11 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "tlt",
|
"name": "@pushrocks/smartmustache",
|
||||||
"version": "1.0.4",
|
"version": "2.0.7",
|
||||||
"description": "templates done right",
|
"description": "templates done right",
|
||||||
|
"private": false,
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)"
|
"test": "(tstest test/)",
|
||||||
|
"build": "(tsbuild)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -21,13 +23,12 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/tlt#README",
|
"homepage": "https://gitlab.com/pushrocks/tlt#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/mustache": "^0.8.29",
|
"handlebars": "^4.1.0"
|
||||||
"mustache": "^2.3.0",
|
|
||||||
"typings-global": "^1.0.14"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/should": "^8.1.30",
|
"@gitzone/tsbuild": "^2.1.8",
|
||||||
"should": "^11.1.1",
|
"@gitzone/tsrun": "^1.1.17",
|
||||||
"typings-test": "^1.0.3"
|
"@gitzone/tstest": "^1.0.18",
|
||||||
|
"@pushrocks/tapbundle": "^3.0.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
test/test.d.ts
vendored
1
test/test.d.ts
vendored
@@ -1 +0,0 @@
|
|||||||
import 'typings-test';
|
|
||||||
16
test/test.js
16
test/test.js
@@ -1,16 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-test");
|
|
||||||
const should = require("should");
|
|
||||||
const tlt = require("../dist/index");
|
|
||||||
describe('tlt', function () {
|
|
||||||
let testTlt;
|
|
||||||
it('should create a valid instance of tlt', function () {
|
|
||||||
testTlt = new tlt.Tlt('some awesome {{customString}}');
|
|
||||||
should(testTlt).be.instanceOf(tlt.Tlt);
|
|
||||||
});
|
|
||||||
it('should output a valid string with some data', function () {
|
|
||||||
let appliedString = testTlt.applyData({ customString: 'horse' });
|
|
||||||
should(appliedString).equal('some awesome horse');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixpQ0FBZ0M7QUFFaEMscUNBQW9DO0FBRXBDLFFBQVEsQ0FBQyxLQUFLLEVBQUU7SUFDWixJQUFJLE9BQWdCLENBQUE7SUFDcEIsRUFBRSxDQUFDLHVDQUF1QyxFQUFFO1FBQ3hDLE9BQU8sR0FBRyxJQUFJLEdBQUcsQ0FBQyxHQUFHLENBQUMsK0JBQStCLENBQUMsQ0FBQTtRQUN0RCxNQUFNLENBQUMsT0FBTyxDQUFDLENBQUMsRUFBRSxDQUFDLFVBQVUsQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLENBQUE7SUFDMUMsQ0FBQyxDQUFDLENBQUE7SUFDRixFQUFFLENBQUMsNkNBQTZDLEVBQUU7UUFDOUMsSUFBSSxhQUFhLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFDLFlBQVksRUFBRSxPQUFPLEVBQUMsQ0FBQyxDQUFBO1FBQzlELE1BQU0sQ0FBQyxhQUFhLENBQUMsQ0FBQyxLQUFLLENBQUMsb0JBQW9CLENBQUMsQ0FBQTtJQUNyRCxDQUFDLENBQUMsQ0FBQTtBQUNOLENBQUMsQ0FBQyxDQUFBIn0=
|
|
||||||
32
test/test.ts
32
test/test.ts
@@ -1,16 +1,20 @@
|
|||||||
import 'typings-test'
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
import * as should from 'should'
|
|
||||||
|
|
||||||
import * as tlt from '../dist/index'
|
import * as tlt from '../ts/index';
|
||||||
|
|
||||||
describe('tlt', function() {
|
let testMustache: tlt.SmartMustache;
|
||||||
let testTlt: tlt.Tlt
|
tap.test('should create a valid instance of tlt', async () => {
|
||||||
it('should create a valid instance of tlt', function() {
|
testMustache = new tlt.SmartMustache(
|
||||||
testTlt = new tlt.Tlt('some awesome {{customString}}')
|
'some awesome {{customString}} that is {{license}} licensed'
|
||||||
should(testTlt).be.instanceOf(tlt.Tlt)
|
);
|
||||||
})
|
expect(testMustache).to.be.instanceOf(tlt.SmartMustache);
|
||||||
it('should output a valid string with some data', function(){
|
});
|
||||||
let appliedString = testTlt.applyData({customString: 'horse'})
|
tap.test('should output a valid string with some data', async () => {
|
||||||
should(appliedString).equal('some awesome horse')
|
let appliedString = testMustache.applyData({
|
||||||
})
|
customString: 'horse',
|
||||||
})
|
license: 'MIT'
|
||||||
|
});
|
||||||
|
expect(appliedString).to.equal('some awesome horse that is MIT licensed');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
||||||
|
|||||||
12
ts/index.ts
12
ts/index.ts
@@ -1,29 +1,29 @@
|
|||||||
import * as mustache from 'mustache'
|
import * as handlebars from 'handlebars';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class Tlt allows templates to be used with different sets of data
|
* class Tlt allows templates to be used with different sets of data
|
||||||
*/
|
*/
|
||||||
export class Tlt {
|
export class SmartMustache {
|
||||||
templateString: string
|
template: any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor of class Tlt
|
* constructor of class Tlt
|
||||||
*/
|
*/
|
||||||
constructor(templateStringArg: string) {
|
constructor(templateStringArg: string) {
|
||||||
this.templateString = templateStringArg
|
this.template = handlebars.compile(templateStringArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns template string with data applied
|
* returns template string with data applied
|
||||||
*/
|
*/
|
||||||
applyData(data: any): string {
|
applyData(data: any): string {
|
||||||
return mustache.render(this.templateString, data)
|
return this.template(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set a new template string
|
* set a new template string
|
||||||
*/
|
*/
|
||||||
setTemplate(templateStringArg: string) {
|
setTemplate(templateStringArg: string) {
|
||||||
this.templateString = templateStringArg
|
this.template = handlebars.compile(templateStringArg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
16
tslint.json
16
tslint.json
@@ -1,3 +1,17 @@
|
|||||||
{
|
{
|
||||||
"extends": "tslint-config-standard"
|
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||||
|
"rules": {
|
||||||
|
"semicolon": [true, "always"],
|
||||||
|
"no-console": false,
|
||||||
|
"ordered-imports": false,
|
||||||
|
"object-literal-sort-keys": false,
|
||||||
|
"member-ordering": {
|
||||||
|
"options":{
|
||||||
|
"order": [
|
||||||
|
"static-method"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaultSeverity": "warning"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user