Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b0a2ebe470 | |||
| 1ab3432325 | |||
| c6a09e5f40 | |||
| 099d331fa7 | |||
| e6f9459fc8 | |||
| d25fe85fcd | |||
| 5ef057e31f | |||
| 494cb72d78 | |||
| 7b27b231ff | |||
| bd9ac0ab46 | |||
| 1c53edca7d | |||
| 6b279824fb | |||
| c06b8e6a18 | |||
| a707dff92d | |||
| 7bad738cb1 | |||
| 0e5db8f6b4 | |||
| deadd463de | |||
| e783dcb1f8 | |||
|
|
62cacffe61 | ||
|
|
df76935a52 | ||
| f078653846 | |||
| 50d70eaece | |||
| 452f086d84 | |||
| 0113d8ea19 |
18
.gitignore
vendored
18
.gitignore
vendored
@@ -1,4 +1,20 @@
|
||||
node_modules/
|
||||
.nogit/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
||||
112
.gitlab-ci.yml
112
.gitlab-ci.yml
@@ -1,59 +1,137 @@
|
||||
image: hosttoday/ht-docker-node:npmts
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: '$CI_BUILD_STAGE'
|
||||
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
- trigger
|
||||
- pages
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
testLEGACY:
|
||||
stage: test
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci test legacy
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test lts
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testSTABLE:
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci publish
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: trigger
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmpage
|
||||
stage: pages
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci command npmpage --host gitlab
|
||||
- npmci node install lts
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- 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: {}
|
||||
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "current file",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"${relativeFile}"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
},
|
||||
{
|
||||
"name": "test.ts",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"test/test.ts"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
}
|
||||
]
|
||||
}
|
||||
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"json.schemas": [
|
||||
{
|
||||
"fileMatch": ["/npmextra.json"],
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"npmci": {
|
||||
"type": "object",
|
||||
"description": "settings for npmci"
|
||||
},
|
||||
"gitzone": {
|
||||
"type": "object",
|
||||
"description": "settings for gitzone",
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
49
README.md
49
README.md
@@ -1,35 +1,40 @@
|
||||
# tlt
|
||||
# @pushrocks/smartmustache
|
||||
templates done right
|
||||
|
||||
## Availabililty
|
||||
[](https://www.npmjs.com/package/tlt)
|
||||
[](https://gitlab.com/pushrocks/tlt)
|
||||
[](https://github.com/pushrocks/tlt)
|
||||
[](https://pushrocks.gitlab.io/tlt/)
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartmustache)
|
||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartmustache)
|
||||
* [github.com (source mirror)](https://github.com/pushrocks/smartmustache)
|
||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartmustache/)
|
||||
|
||||
## Status for master
|
||||
[](https://gitlab.com/pushrocks/tlt/commits/master)
|
||||
[](https://gitlab.com/pushrocks/tlt/commits/master)
|
||||
[](https://david-dm.org/pushrocks/tlt)
|
||||
[](https://www.bithound.io/github/pushrocks/tlt/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/tlt)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
[](https://gitlab.com/pushrocks/smartmustache/commits/master)
|
||||
[](https://gitlab.com/pushrocks/smartmustache/commits/master)
|
||||
[](https://www.npmjs.com/package/@pushrocks/smartmustache)
|
||||
[](https://snyk.io/test/npm/@pushrocks/smartmustache)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://prettier.io/)
|
||||
|
||||
## Usage
|
||||
We recommend the use of TypeScript for best in class Intellisense
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
```javascript
|
||||
import { Tlt } from 'tlt'
|
||||
import { SmartMustache } from '@pushrocks/smartmustache';
|
||||
|
||||
let myTlt = new Tlt('my {{somePlaceholder}} are {{anotherPlaceholder}}!')
|
||||
let appliedString = myTlt.applyData({
|
||||
"somePlaceholder": "horses",
|
||||
"anotherPlaceholder": "awesome"
|
||||
})
|
||||
const mySmartmustache = new SmartMustache('my {{somePlaceholder}} are {{anotherPlaceholder}}!');
|
||||
const appliedString = myTlt.applyData({
|
||||
somePlaceholder: 'horses',
|
||||
anotherPlaceholder: '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)
|
||||
|
||||
[](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=
|
||||
16
npmextra.json
Normal file
16
npmextra.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"npmci": {
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
"gitrepo": "smartmustache",
|
||||
"shortDescription": "templates done right",
|
||||
"npmPackagename": "@pushrocks/smartmustache",
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
||||
11539
package-lock.json
generated
Normal file
11539
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
40
package.json
40
package.json
@@ -1,11 +1,13 @@
|
||||
{
|
||||
"name": "tlt",
|
||||
"version": "1.0.4",
|
||||
"name": "@pushrocks/smartmustache",
|
||||
"version": "2.0.10",
|
||||
"description": "templates done right",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"private": false,
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(npmts)"
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -21,13 +23,27 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/tlt#README",
|
||||
"dependencies": {
|
||||
"@types/mustache": "^0.8.29",
|
||||
"mustache": "^2.3.0",
|
||||
"typings-global": "^1.0.14"
|
||||
"handlebars": "^4.7.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/should": "^8.1.30",
|
||||
"should": "^11.1.1",
|
||||
"typings-test": "^1.0.3"
|
||||
}
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tsrun": "^1.2.12",
|
||||
"@gitzone/tstest": "^1.0.52",
|
||||
"@pushrocks/tapbundle": "^3.2.14"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
||||
|
||||
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 * as should from 'should'
|
||||
import { tap, expect } from '@pushrocks/tapbundle';
|
||||
|
||||
import * as tlt from '../dist/index'
|
||||
import * as tlt from '../ts/index';
|
||||
|
||||
describe('tlt', function() {
|
||||
let testTlt: tlt.Tlt
|
||||
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')
|
||||
})
|
||||
})
|
||||
let testMustache: tlt.SmartMustache;
|
||||
tap.test('should create a valid instance of tlt', async () => {
|
||||
testMustache = new tlt.SmartMustache(
|
||||
'some awesome {{customString}} that is {{license}} licensed'
|
||||
);
|
||||
expect(testMustache).to.be.instanceOf(tlt.SmartMustache);
|
||||
});
|
||||
tap.test('should output a valid string with some data', async () => {
|
||||
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
|
||||
*/
|
||||
export class Tlt {
|
||||
templateString: string
|
||||
export class SmartMustache {
|
||||
template: any;
|
||||
|
||||
/**
|
||||
* constructor of class Tlt
|
||||
*/
|
||||
constructor(templateStringArg: string) {
|
||||
this.templateString = templateStringArg
|
||||
this.template = handlebars.compile(templateStringArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns template string with data applied
|
||||
*/
|
||||
applyData(data: any): string {
|
||||
return mustache.render(this.templateString, data)
|
||||
return this.template(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* set a new template 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