Compare commits
48 Commits
Author | SHA1 | Date | |
---|---|---|---|
6296411b50 | |||
e7690d4020 | |||
b85a29cfc1 | |||
d559b0f402 | |||
7433c1dba4 | |||
c8f6b0296d | |||
0cffae9eaa | |||
d50c8a1260 | |||
b3702d56bc | |||
ff0faa719b | |||
400e228ffc | |||
25871fc970 | |||
eb990a8ec2 | |||
f5194b76bd | |||
6b5e9ac617 | |||
60854250eb | |||
53de92ac1a | |||
6cb4fff0a5 | |||
45710ded00 | |||
aa87ed9427 | |||
f3594447ac | |||
a3f18c17ed | |||
c5ec7e9c24 | |||
98875a2ece | |||
5b42cf93cb | |||
e0ab34c466 | |||
beb3013e2c | |||
5d1c0a6f1e | |||
fc450816e6 | |||
5fac35c75f | |||
dde29629b7 | |||
4347f800e6 | |||
59161f1eeb | |||
b9a346c5d7 | |||
fa961f86b8 | |||
ff679c1787 | |||
35e3c9ae48 | |||
bf0007ff3a | |||
3ab780e600 | |||
d0662f809f | |||
e20bf7f610 | |||
0a97ec4d07 | |||
69e09c8b4c | |||
0e92554d0a | |||
648afbcf21 | |||
7998c99f27 | |||
8e3633827c | |||
eac20873e5 |
21
.gitignore
vendored
21
.gitignore
vendored
@ -1,3 +1,22 @@
|
|||||||
node_modules/
|
.nogit/
|
||||||
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_web/
|
||||||
|
dist_serve/
|
||||||
|
dist_ts_web/
|
||||||
|
|
||||||
|
# custom
|
110
.gitlab-ci.yml
110
.gitlab-ci.yml
@ -1,71 +1,119 @@
|
|||||||
# gitzone standard
|
# gitzone ci_default
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- .yarn/
|
- .npmci_cache/
|
||||||
key: "$CI_BUILD_STAGE"
|
key: "$CI_BUILD_STAGE"
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- trigger
|
- metadata
|
||||||
- pages
|
|
||||||
|
|
||||||
testLEGACY:
|
# ====================
|
||||||
|
# security stage
|
||||||
|
# ====================
|
||||||
|
mirror:
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci git mirror
|
||||||
|
tags:
|
||||||
|
- 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
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# test stage
|
||||||
|
# ====================
|
||||||
|
|
||||||
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test legacy
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
allow_failure: true
|
- priv
|
||||||
|
|
||||||
testLTS:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test lts
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci test stable
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
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
|
||||||
|
allow_failure: true
|
||||||
|
script:
|
||||||
|
- npmci command npm install -g tslint typescript
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
|
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:npmci
|
image: hosttoday/ht-docker-dbase:npmci
|
||||||
stage: pages
|
services:
|
||||||
|
- docker:stable-dind
|
||||||
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command yarn global add npmpage
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
- npmci command npmpage
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
|
allow_failure: true
|
||||||
|
1
dist/index.d.ts
vendored
1
dist/index.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
export * from './smartscaf.classes.smartscaf';
|
|
7
dist/index.js
vendored
7
dist/index.js
vendored
@ -1,7 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
function __export(m) {
|
|
||||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
||||||
}
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
__export(require("./smartscaf.classes.smartscaf"));
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLG1EQUE2QyJ9
|
|
35
dist/smartscaf.classes.smartscaf.d.ts
vendored
35
dist/smartscaf.classes.smartscaf.d.ts
vendored
@ -1,35 +0,0 @@
|
|||||||
import { Smartfile } from 'smartfile';
|
|
||||||
export interface ScafTemplateContructorOptions {
|
|
||||||
name?: string;
|
|
||||||
description?: string;
|
|
||||||
sourceDir?: string;
|
|
||||||
}
|
|
||||||
export declare class ScafTemplate {
|
|
||||||
name: string;
|
|
||||||
description: string;
|
|
||||||
templateSmartfileArray: Smartfile[];
|
|
||||||
requiredVariables: string[];
|
|
||||||
suppliedVariables: any;
|
|
||||||
missingVariables: string[];
|
|
||||||
/**
|
|
||||||
* read a template from a directory
|
|
||||||
*/
|
|
||||||
readTemplateFromDir(dirPathArg: string): Promise<void>;
|
|
||||||
/**
|
|
||||||
* supply the variables to render the teplate with
|
|
||||||
* @param variablesArg
|
|
||||||
*/
|
|
||||||
supplyVariables(variablesArg: any): Promise<void>;
|
|
||||||
/**
|
|
||||||
* Will ask for the missing variables by cli interaction
|
|
||||||
*/
|
|
||||||
askCliForMissingVariables(): Promise<void>;
|
|
||||||
/**
|
|
||||||
* finds all variables in a Template
|
|
||||||
*/
|
|
||||||
private _findVariablesInTemplate();
|
|
||||||
/**
|
|
||||||
* checks if supplied Variables satisfy the template
|
|
||||||
*/
|
|
||||||
private _checkSuppliedVariables();
|
|
||||||
}
|
|
79
dist/smartscaf.classes.smartscaf.js
vendored
79
dist/smartscaf.classes.smartscaf.js
vendored
@ -1,79 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const plugins = require("./smartscaf.plugins");
|
|
||||||
class ScafTemplate {
|
|
||||||
constructor() {
|
|
||||||
this.missingVariables = [];
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* read a template from a directory
|
|
||||||
*/
|
|
||||||
readTemplateFromDir(dirPathArg) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let dirPath = plugins.path.resolve(dirPathArg);
|
|
||||||
this.templateSmartfileArray = yield plugins.smartfile.fs.fileTreeToObject(dirPath, '**/*');
|
|
||||||
this._findVariablesInTemplate();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* supply the variables to render the teplate with
|
|
||||||
* @param variablesArg
|
|
||||||
*/
|
|
||||||
supplyVariables(variablesArg) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
this.suppliedVariables = variablesArg;
|
|
||||||
this.missingVariables = yield this._checkSuppliedVariables();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Will ask for the missing variables by cli interaction
|
|
||||||
*/
|
|
||||||
askCliForMissingVariables() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
this.missingVariables = yield this._checkSuppliedVariables();
|
|
||||||
let localSmartInteract = new plugins.smartinteract.SmartInteract();
|
|
||||||
for (let missingVariable of this.missingVariables) {
|
|
||||||
localSmartInteract.addQuestions([{
|
|
||||||
name: missingVariable,
|
|
||||||
type: 'input',
|
|
||||||
default: `undefined ${missingVariable}`,
|
|
||||||
message: `What is the value of ${missingVariable}?`
|
|
||||||
}]);
|
|
||||||
}
|
|
||||||
let answers = yield localSmartInteract.runQueue();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* finds all variables in a Template
|
|
||||||
*/
|
|
||||||
_findVariablesInTemplate() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
for (let localSmartfile of this.templateSmartfileArray) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* checks if supplied Variables satisfy the template
|
|
||||||
*/
|
|
||||||
_checkSuppliedVariables() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let missingVars = [];
|
|
||||||
for (let templateSmartFile of this.templateSmartfileArray) {
|
|
||||||
let localMissingVars = yield plugins.smarthbs.checkVarsSatisfaction(templateSmartFile.contents.toString(), this.suppliedVariables);
|
|
||||||
missingVars = plugins.lodash.concat(missingVars, localMissingVars);
|
|
||||||
missingVars = plugins.lodash.uniq(missingVars);
|
|
||||||
}
|
|
||||||
return missingVars;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.ScafTemplate = ScafTemplate;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLmNsYXNzZXMuc21hcnRzY2FmLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzY2FmLmNsYXNzZXMuc21hcnRzY2FmLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUFBQSwrQ0FBOEM7QUFXOUM7SUFBQTtRQU1FLHFCQUFnQixHQUFhLEVBQUUsQ0FBQTtJQTZEakMsQ0FBQztJQTNEQzs7T0FFRztJQUNHLG1CQUFtQixDQUFFLFVBQWtCOztZQUMzQyxJQUFJLE9BQU8sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FBQTtZQUM5QyxJQUFJLENBQUMsc0JBQXNCLEdBQUcsTUFBTSxPQUFPLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyxnQkFBZ0IsQ0FBQyxPQUFPLEVBQUUsTUFBTSxDQUFDLENBQUE7WUFDMUYsSUFBSSxDQUFDLHdCQUF3QixFQUFFLENBQUE7UUFDakMsQ0FBQztLQUFBO0lBRUQ7OztPQUdHO0lBQ0csZUFBZSxDQUFFLFlBQVk7O1lBQ2pDLElBQUksQ0FBQyxpQkFBaUIsR0FBRyxZQUFZLENBQUE7WUFDckMsSUFBSSxDQUFDLGdCQUFnQixHQUFHLE1BQU0sSUFBSSxDQUFDLHVCQUF1QixFQUFFLENBQUE7UUFDOUQsQ0FBQztLQUFBO0lBRUQ7O09BRUc7SUFDRyx5QkFBeUI7O1lBQzdCLElBQUksQ0FBQyxnQkFBZ0IsR0FBRyxNQUFNLElBQUksQ0FBQyx1QkFBdUIsRUFBRSxDQUFBO1lBQzVELElBQUksa0JBQWtCLEdBQUcsSUFBSSxPQUFPLENBQUMsYUFBYSxDQUFDLGFBQWEsRUFBRSxDQUFBO1lBQ2xFLEdBQUcsQ0FBQyxDQUFDLElBQUksZUFBZSxJQUFJLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxDQUFDLENBQUM7Z0JBQ2xELGtCQUFrQixDQUFDLFlBQVksQ0FBQyxDQUFDO3dCQUMvQixJQUFJLEVBQUUsZUFBZTt3QkFDckIsSUFBSSxFQUFFLE9BQU87d0JBQ2IsT0FBTyxFQUFFLGFBQWEsZUFBZSxFQUFFO3dCQUN2QyxPQUFPLEVBQUUsd0JBQXdCLGVBQWUsR0FBRztxQkFDcEQsQ0FBQyxDQUFDLENBQUE7WUFDTCxDQUFDO1lBQ0QsSUFBSSxPQUFPLEdBQUcsTUFBTSxrQkFBa0IsQ0FBQyxRQUFRLEVBQUUsQ0FBQTtRQUNuRCxDQUFDO0tBQUE7SUFFRDs7T0FFRztJQUNXLHdCQUF3Qjs7WUFDcEMsR0FBRyxDQUFDLENBQUMsSUFBSSxjQUFjLElBQUksSUFBSSxDQUFDLHNCQUFzQixDQUFDLENBQUMsQ0FBQztZQUV6RCxDQUFDO1FBQ0gsQ0FBQztLQUFBO0lBRUQ7O09BRUc7SUFDVyx1QkFBdUI7O1lBQ25DLElBQUksV0FBVyxHQUFhLEVBQUUsQ0FBQTtZQUM5QixHQUFHLENBQUMsQ0FBQyxJQUFJLGlCQUFpQixJQUFJLElBQUksQ0FBQyxzQkFBc0IsQ0FBQyxDQUFDLENBQUM7Z0JBQzFELElBQUksZ0JBQWdCLEdBQUcsTUFBTSxPQUFPLENBQUMsUUFBUSxDQUFDLHFCQUFxQixDQUNqRSxpQkFBaUIsQ0FBQyxRQUFRLENBQUMsUUFBUSxFQUFFLEVBQ3JDLElBQUksQ0FBQyxpQkFBaUIsQ0FDdkIsQ0FBQTtnQkFDRCxXQUFXLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxNQUFNLENBQUMsV0FBVyxFQUFFLGdCQUFnQixDQUFDLENBQUE7Z0JBQ2xFLFdBQVcsR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQTtZQUNoRCxDQUFDO1lBQ0QsTUFBTSxDQUFDLFdBQVcsQ0FBQTtRQUNwQixDQUFDO0tBQUE7Q0FDRjtBQW5FRCxvQ0FtRUMifQ==
|
|
0
dist/smartscaf.helpers.d.ts
vendored
0
dist/smartscaf.helpers.d.ts
vendored
3
dist/smartscaf.helpers.js
vendored
3
dist/smartscaf.helpers.js
vendored
@ -1,3 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLmhlbHBlcnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNjYWYuaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
|
|
8
dist/smartscaf.plugins.d.ts
vendored
8
dist/smartscaf.plugins.d.ts
vendored
@ -1,8 +0,0 @@
|
|||||||
import 'typings-global';
|
|
||||||
import * as lodash from 'lodash';
|
|
||||||
import * as path from 'path';
|
|
||||||
import * as smartfile from 'smartfile';
|
|
||||||
import * as smarthbs from 'smarthbs';
|
|
||||||
import * as smartinteract from 'smartinteract';
|
|
||||||
import * as smartq from 'smartq';
|
|
||||||
export { lodash, path, smartfile, smarthbs, smartinteract, smartq };
|
|
16
dist/smartscaf.plugins.js
vendored
16
dist/smartscaf.plugins.js
vendored
@ -1,16 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
require("typings-global");
|
|
||||||
const lodash = require("lodash");
|
|
||||||
exports.lodash = lodash;
|
|
||||||
const path = require("path");
|
|
||||||
exports.path = path;
|
|
||||||
const smartfile = require("smartfile");
|
|
||||||
exports.smartfile = smartfile;
|
|
||||||
const smarthbs = require("smarthbs");
|
|
||||||
exports.smarthbs = smarthbs;
|
|
||||||
const smartinteract = require("smartinteract");
|
|
||||||
exports.smartinteract = smartinteract;
|
|
||||||
const smartq = require("smartq");
|
|
||||||
exports.smartq = smartq;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNjYWYucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2QixpQ0FBZ0M7QUFROUIsd0JBQU07QUFQUiw2QkFBNEI7QUFRMUIsb0JBQUk7QUFQTix1Q0FBc0M7QUFRcEMsOEJBQVM7QUFQWCxxQ0FBb0M7QUFRbEMsNEJBQVE7QUFQViwrQ0FBOEM7QUFRNUMsc0NBQWE7QUFQZixpQ0FBZ0M7QUFROUIsd0JBQU0ifQ==
|
|
@ -3,8 +3,17 @@
|
|||||||
"coverageTreshold": 30
|
"coverageTreshold": 30
|
||||||
},
|
},
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"globalNpmTools": [
|
"npmGlobalTools": [],
|
||||||
"npmts"
|
"npmAccessLevel": "public"
|
||||||
]
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "pushrocks",
|
||||||
|
"gitrepo": "smartscaf",
|
||||||
|
"shortDescription": "scaffold projects quickly",
|
||||||
|
"npmPackagename": "@pushrocks/smartscaf",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
1920
package-lock.json
generated
Normal file
1920
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
41
package.json
41
package.json
@ -1,11 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "smartscaf",
|
"name": "@pushrocks/smartscaf",
|
||||||
"version": "1.0.1",
|
"version": "3.0.6",
|
||||||
|
"private": false,
|
||||||
"description": "scaffold projects quickly",
|
"description": "scaffold projects quickly",
|
||||||
"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",
|
||||||
@ -23,15 +25,30 @@
|
|||||||
"npm"
|
"npm"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"tapbundle": "^1.0.10"
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
|
"@gitzone/tstest": "^1.0.24",
|
||||||
|
"@pushrocks/tapbundle": "^3.0.13",
|
||||||
|
"@types/node": "^12.7.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/lodash": "^4.14.63",
|
"@pushrocks/lik": "^3.0.11",
|
||||||
"lodash": "^4.17.4",
|
"@pushrocks/smartfile": "^7.0.4",
|
||||||
"smartfile": "^4.2.9",
|
"@pushrocks/smartfm": "^2.0.4",
|
||||||
"smarthbs": "^1.0.12",
|
"@pushrocks/smarthbs": "^2.0.8",
|
||||||
"smartinteract": "^1.0.4",
|
"@pushrocks/smartinteract": "^2.0.4",
|
||||||
"smartq": "^1.1.1",
|
"@pushrocks/smartpromise": "^3.0.2",
|
||||||
"typings-global": "^1.0.16"
|
"@pushrocks/smartyaml": "^2.0.3"
|
||||||
}
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/*",
|
||||||
|
"ts_web/*",
|
||||||
|
"dist/*",
|
||||||
|
"dist_web/*",
|
||||||
|
"dist_ts_web/*",
|
||||||
|
"assets/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
38
readme.md
38
readme.md
@ -1,29 +1,35 @@
|
|||||||
# smartscaf
|
# @pushrocks/smartscaf
|
||||||
scaffold projects quickly
|
scaffold projects quickly
|
||||||
|
|
||||||
## Availabililty
|
## Availabililty and Links
|
||||||
[](https://www.npmjs.com/package/smartscaf)
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartscaf)
|
||||||
[](https://GitLab.com/pushrocks/smartscaf)
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartscaf)
|
||||||
[](https://github.com/pushrocks/smartscaf)
|
* [github.com (source mirror)](https://github.com/pushrocks/smartscaf)
|
||||||
[](https://pushrocks.gitlab.io/smartscaf/)
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartscaf/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
[](https://GitLab.com/pushrocks/smartscaf/commits/master)
|
[](https://gitlab.com/pushrocks/smartscaf/commits/master)
|
||||||
[](https://GitLab.com/pushrocks/smartscaf/commits/master)
|
[](https://gitlab.com/pushrocks/smartscaf/commits/master)
|
||||||
[](https://www.npmjs.com/package/smartscaf)
|
[](https://www.npmjs.com/package/@pushrocks/smartscaf)
|
||||||
[](https://david-dm.org/pushrocks/smartscaf)
|
[](https://snyk.io/test/npm/@pushrocks/smartscaf)
|
||||||
[](https://www.bithound.io/github/pushrocks/smartscaf/master/dependencies/npm)
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[](https://www.bithound.io/github/pushrocks/smartscaf)
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
[](https://prettier.io/)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[](http://standardjs.com/)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Use TypeScript for best in class instellisense.
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
For further information read the linked docs at the top of this README.
|
For further information read the linked docs at the top of this README.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||||
|
|
||||||
[](https://)
|
[](https://)
|
||||||
|
|
||||||
|
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)
|
||||||
|
41
test/test.ts
41
test/test.ts
@ -1,26 +1,37 @@
|
|||||||
import { expect, tap } from 'tapbundle'
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
import * as smartscaf from '../dist/index'
|
import * as smartscaf from '../ts/index';
|
||||||
|
|
||||||
let testScafTemplate: smartscaf.ScafTemplate
|
process.env.CI = 'true';
|
||||||
|
|
||||||
|
let testScafTemplate: smartscaf.ScafTemplate;
|
||||||
|
|
||||||
tap.test('should create new Smartscaf instance', async () => {
|
tap.test('should create new Smartscaf instance', async () => {
|
||||||
testScafTemplate = new smartscaf.ScafTemplate()
|
testScafTemplate = new smartscaf.ScafTemplate('./test/test_template');
|
||||||
expect(testScafTemplate).to.be.instanceof(smartscaf.ScafTemplate)
|
expect(testScafTemplate).to.be.instanceof(smartscaf.ScafTemplate);
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('Smartscaf instance -> should read a template directory', async () => {
|
tap.test('Smartscaf instance -> should read a template directory', async () => {
|
||||||
await testScafTemplate.readTemplateFromDir('./test/test_template')
|
await testScafTemplate.readTemplateFromDir();
|
||||||
expect(testScafTemplate.templateSmartfileArray.length).to.equal(3)
|
expect(testScafTemplate.templateSmartfileArray.length).to.equal(6);
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('smartfile -> should accept variables', async () => {
|
tap.test('smartfile -> should accept variables', async () => {
|
||||||
await testScafTemplate.supplyVariables({})
|
await testScafTemplate.supplyVariables({});
|
||||||
console.log(testScafTemplate.missingVariables)
|
console.log(testScafTemplate.missingVariables);
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('ask cli', async () => {
|
tap.test('ask cli', async () => {
|
||||||
await testScafTemplate.askCliForMissingVariables()
|
await testScafTemplate.askCliForMissingVariables();
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.start()
|
tap.test('should have valid supplied variables', async () => {
|
||||||
|
console.log(testScafTemplate.suppliedVariables);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should output ready rendered template', async () => {
|
||||||
|
await testScafTemplate.writeToDisk(path.resolve('./test/test_output'));
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
||||||
|
1
test/test_output/changedname.md
Normal file
1
test/test_output/changedname.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# some undefined variable
|
1
test/test_output/hello.md
Normal file
1
test/test_output/hello.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# param1 10
|
1
test/test_output/notemplate.yml
Normal file
1
test/test_output/notemplate.yml
Normal file
@ -0,0 +1 @@
|
|||||||
|
awesome!
|
3
test/test_output/template1.md
Normal file
3
test/test_output/template1.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# this is a wow
|
||||||
|
# this is a here
|
||||||
|
# this is a undefined variable
|
3
test/test_output/template2.md
Normal file
3
test/test_output/template2.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# this is a from default yaml
|
||||||
|
# this is a this is another value from yml
|
||||||
|
# this is a undefined variable
|
10
test/test_template/.smartscaf.yml
Normal file
10
test/test_template/.smartscaf.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
defaults:
|
||||||
|
templateVar1: from default yaml
|
||||||
|
templateVar2: this is another value from yml
|
||||||
|
templateObject.value1: wow
|
||||||
|
templateObject.value2: here
|
||||||
|
node_version: '10'
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
merge:
|
||||||
|
- ../test_template_2
|
1
test/test_template/notemplate.yml
Normal file
1
test/test_template/notemplate.yml
Normal file
@ -0,0 +1 @@
|
|||||||
|
awesome!
|
@ -1,3 +1,3 @@
|
|||||||
# this is a {{templateVar1}}
|
# this is a {{templateObject.value1}}
|
||||||
# this is a {{templateVar2}}
|
# this is a {{templateObject.value2}}
|
||||||
# this is a {{templateVar3}}
|
# this is a {{templateVar3}}
|
||||||
|
@ -1 +1,4 @@
|
|||||||
|
---
|
||||||
|
fileName: changedname.md
|
||||||
|
---
|
||||||
# some {{wow}}
|
# some {{wow}}
|
1
test/test_template_2/hello.md
Normal file
1
test/test_template_2/hello.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# param1 {{node_version}}
|
@ -1 +1 @@
|
|||||||
export * from './smartscaf.classes.smartscaf'
|
export * from './smartscaf.classes.smartscaf';
|
||||||
|
@ -1,79 +1,234 @@
|
|||||||
import * as plugins from './smartscaf.plugins'
|
import * as plugins from './smartscaf.plugins';
|
||||||
|
import * as helpers from './smartscaf.helpers';
|
||||||
|
|
||||||
// interfaces
|
// interfaces
|
||||||
import { Smartfile } from 'smartfile'
|
import { Smartfile } from '@pushrocks/smartfile';
|
||||||
|
|
||||||
export interface ScafTemplateContructorOptions {
|
export interface ScafTemplateContructorOptions {
|
||||||
name?: string,
|
name?: string;
|
||||||
description?: string
|
description?: string;
|
||||||
sourceDir?: string
|
sourceDir?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ScafTemplate {
|
export class ScafTemplate {
|
||||||
name: string
|
static async createTemplateFromDir() {}
|
||||||
description: string
|
|
||||||
templateSmartfileArray: Smartfile[]
|
/**
|
||||||
requiredVariables: string[]
|
* the name of the template
|
||||||
suppliedVariables: any
|
*/
|
||||||
missingVariables: string[] = []
|
name: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the descriptions of the template
|
||||||
|
*/
|
||||||
|
description: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the location on disk of the template
|
||||||
|
*/
|
||||||
|
dirPath: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the files of the template as array of Smartfiles
|
||||||
|
*/
|
||||||
|
templateSmartfileArray: Smartfile[];
|
||||||
|
requiredVariables: string[];
|
||||||
|
defaultVariables: any;
|
||||||
|
suppliedVariables: any = {};
|
||||||
|
missingVariables: string[] = [];
|
||||||
|
|
||||||
|
constructor(dirPathArg: string) {
|
||||||
|
this.dirPath = plugins.path.resolve(dirPathArg);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read a template from a directory
|
* read a template from a directory
|
||||||
*/
|
*/
|
||||||
async readTemplateFromDir (dirPathArg: string) {
|
async readTemplateFromDir() {
|
||||||
let dirPath = plugins.path.resolve(dirPathArg)
|
this.templateSmartfileArray = await plugins.smartfile.fs.fileTreeToObject(this.dirPath, '**/*');
|
||||||
this.templateSmartfileArray = await plugins.smartfile.fs.fileTreeToObject(dirPath, '**/*')
|
await this._resolveTemplateDependencies();
|
||||||
this._findVariablesInTemplate()
|
await this._findVariablesInTemplate();
|
||||||
|
await this._checkSuppliedVariables();
|
||||||
|
await this._checkDefaultVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* supply the variables to render the teplate with
|
* supply the variables to render the teplate with
|
||||||
* @param variablesArg
|
* @param variablesArg gets merged with this.suppliedVariables
|
||||||
*/
|
*/
|
||||||
async supplyVariables (variablesArg) {
|
async supplyVariables(variablesArg) {
|
||||||
this.suppliedVariables = variablesArg
|
this.suppliedVariables = {
|
||||||
this.missingVariables = await this._checkSuppliedVariables()
|
...this.suppliedVariables,
|
||||||
|
...variablesArg
|
||||||
|
};
|
||||||
|
this.missingVariables = await this._checkSuppliedVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will ask for the missing variables by cli interaction
|
* Will ask for the missing variables by cli interaction
|
||||||
*/
|
*/
|
||||||
async askCliForMissingVariables () {
|
async askCliForMissingVariables() {
|
||||||
this.missingVariables = await this._checkSuppliedVariables()
|
this.missingVariables = await this._checkSuppliedVariables();
|
||||||
let localSmartInteract = new plugins.smartinteract.SmartInteract()
|
let localSmartInteract = new plugins.smartinteract.SmartInteract();
|
||||||
for (let missingVariable of this.missingVariables) {
|
for (let missingVariable of this.missingVariables) {
|
||||||
localSmartInteract.addQuestions([{
|
localSmartInteract.addQuestions([
|
||||||
name: missingVariable,
|
{
|
||||||
type: 'input',
|
name: missingVariable,
|
||||||
default: `undefined ${missingVariable}`,
|
type: 'input',
|
||||||
message: `What is the value of ${missingVariable}?`
|
default: (() => {
|
||||||
}])
|
if (this.defaultVariables && this.defaultVariables[missingVariable]) {
|
||||||
|
return this.defaultVariables[missingVariable];
|
||||||
|
} else {
|
||||||
|
return 'undefined variable';
|
||||||
|
}
|
||||||
|
})(),
|
||||||
|
message: `What is the value of ${missingVariable}?`
|
||||||
|
}
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
let answers = await localSmartInteract.runQueue()
|
let answerBucket = await localSmartInteract.runQueue();
|
||||||
|
await answerBucket.answerMap.forEach(async answer => {
|
||||||
|
await helpers.deepAddToObject(this.suppliedVariables, answer.name, answer.value);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* finds all variables in a Template
|
* writes a file to disk
|
||||||
|
* @param destinationDirArg
|
||||||
|
*/
|
||||||
|
async writeToDisk(destinationDirArg) {
|
||||||
|
const smartfileArrayToWrite: Smartfile[] = [];
|
||||||
|
for (let smartfile of this.templateSmartfileArray) {
|
||||||
|
// lets filter out template files
|
||||||
|
if (smartfile.path === '.smartscaf.yml') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// render the template
|
||||||
|
let template = await plugins.smarthbs.getTemplateForString(smartfile.contents.toString());
|
||||||
|
let renderedTemplateString = template(this.suppliedVariables);
|
||||||
|
|
||||||
|
// handle frontmatter
|
||||||
|
const smartfmInstance = new plugins.smartfm.Smartfm({
|
||||||
|
fmType: 'yaml'
|
||||||
|
});
|
||||||
|
let parsedTemplate = smartfmInstance.parse(renderedTemplateString) as any;
|
||||||
|
if (parsedTemplate.data.fileName) {
|
||||||
|
smartfile.updateFileName(parsedTemplate.data.fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
smartfile.contents = Buffer.from(parsedTemplate.content);
|
||||||
|
smartfileArrayToWrite.push(smartfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
await plugins.smartfile.memory.smartfileArrayToFs(smartfileArrayToWrite, destinationDirArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* finds all variables in a Template in as string
|
||||||
|
* e.g. myobject.someKey and myobject.someOtherKey
|
||||||
*/
|
*/
|
||||||
private async _findVariablesInTemplate() {
|
private async _findVariablesInTemplate() {
|
||||||
for (let localSmartfile of this.templateSmartfileArray) {
|
let templateVariables: string[] = [];
|
||||||
|
for (let templateSmartfile of this.templateSmartfileArray) {
|
||||||
|
let localTemplateVariables = await plugins.smarthbs.findVarsInHbsString(
|
||||||
|
templateSmartfile.contents.toString()
|
||||||
|
);
|
||||||
|
templateVariables = [...templateVariables, ...localTemplateVariables];
|
||||||
}
|
}
|
||||||
|
templateVariables = templateVariables.filter((value, index, self) => {
|
||||||
|
return self.indexOf(value) === index;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks if supplied Variables satisfy the template
|
* checks if supplied Variables satisfy the template
|
||||||
*/
|
*/
|
||||||
private async _checkSuppliedVariables() {
|
private async _checkSuppliedVariables() {
|
||||||
let missingVars: string[] = []
|
let missingVars: string[] = [];
|
||||||
for (let templateSmartFile of this.templateSmartfileArray) {
|
for (let templateSmartfile of this.templateSmartfileArray) {
|
||||||
let localMissingVars = await plugins.smarthbs.checkVarsSatisfaction(
|
let localMissingVars = await plugins.smarthbs.checkVarsSatisfaction(
|
||||||
templateSmartFile.contents.toString(),
|
templateSmartfile.contents.toString(),
|
||||||
this.suppliedVariables
|
this.suppliedVariables
|
||||||
)
|
);
|
||||||
missingVars = plugins.lodash.concat(missingVars, localMissingVars)
|
|
||||||
missingVars = plugins.lodash.uniq(missingVars)
|
// combine with other missingVars
|
||||||
|
missingVars = [...missingVars, ...localMissingVars];
|
||||||
|
}
|
||||||
|
|
||||||
|
// dedupe
|
||||||
|
missingVars = missingVars.filter((value, index, self) => {
|
||||||
|
return self.indexOf(value) === index;
|
||||||
|
});
|
||||||
|
return missingVars;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* checks the smartscaf.yml default values at the root of a template
|
||||||
|
* allows 2 ways of notation in YAML:
|
||||||
|
* >> myObject.myKey.someDeeperKey: someValue
|
||||||
|
* >> myObject.yourKey.yourDeeperKey: yourValue
|
||||||
|
* or
|
||||||
|
* >> myObject:
|
||||||
|
* >> - someKey:
|
||||||
|
* >> - someDeeperKey: someValue
|
||||||
|
* >> - yourKey:
|
||||||
|
* >> - yourDeeperKey: yourValue
|
||||||
|
*/
|
||||||
|
private async _checkDefaultVariables() {
|
||||||
|
let smartscafSmartfile = this.templateSmartfileArray.find(smartfileArg => {
|
||||||
|
return smartfileArg.parsedPath.base === '.smartscaf.yml';
|
||||||
|
});
|
||||||
|
|
||||||
|
if (smartscafSmartfile) {
|
||||||
|
const smartscafObject = await plugins.smartyaml.yamlStringToObject(
|
||||||
|
smartscafSmartfile.contents.toString()
|
||||||
|
);
|
||||||
|
const defaultObject = smartscafObject.defaults;
|
||||||
|
this.defaultVariables = defaultObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
// safeguard against non existent defaults
|
||||||
|
if (!this.defaultVariables) {
|
||||||
|
console.log('this template does not specify defaults');
|
||||||
|
this.defaultVariables = {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* resolve template dependencies
|
||||||
|
*/
|
||||||
|
private async _resolveTemplateDependencies() {
|
||||||
|
const smartscafSmartfile = this.templateSmartfileArray.find(smartfileArg => {
|
||||||
|
return smartfileArg.parsedPath.base === '.smartscaf.yml';
|
||||||
|
});
|
||||||
|
if (!smartscafSmartfile) {
|
||||||
|
console.log('No further template dependencies defined!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log('Found template dependencies! Resolving them now!');
|
||||||
|
console.log('looking at templates to merge!');
|
||||||
|
const smartscafYamlObject = await plugins.smartyaml.yamlStringToObject(
|
||||||
|
smartscafSmartfile.contentBuffer.toString()
|
||||||
|
);
|
||||||
|
if (!smartscafYamlObject) {
|
||||||
|
console.log('Something seems strange about the supplied dependencies.yml file.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (const dependency of smartscafYamlObject.dependencies.merge) {
|
||||||
|
console.log(`Now resolving ${dependency}`);
|
||||||
|
const templatePathToMerge = plugins.path.join(this.dirPath, dependency);
|
||||||
|
if (!plugins.smartfile.fs.isDirectory(templatePathToMerge)) {
|
||||||
|
console.log(
|
||||||
|
`dependency ${dependency} resolves to ${templatePathToMerge} which ist NOT a directory`
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const templateSmartfileArray = await plugins.smartfile.fs.fileTreeToObject(
|
||||||
|
templatePathToMerge,
|
||||||
|
'**/*'
|
||||||
|
);
|
||||||
|
this.templateSmartfileArray = this.templateSmartfileArray.concat(templateSmartfileArray);
|
||||||
}
|
}
|
||||||
return missingVars
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,33 @@
|
|||||||
import * as plugins from './smartscaf.plugins'
|
import * as plugins from './smartscaf.plugins';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* adds a variable in string dot notation to an already more or less expanded object
|
||||||
|
*/
|
||||||
|
export let deepAddToObject = async (objectArg, varStringArg: string, valueArg: string) => {
|
||||||
|
let varNamesArray = varStringArg.split('.');
|
||||||
|
let referencePointer = objectArg;
|
||||||
|
for (let i = 0; i !== varNamesArray.length; i++) {
|
||||||
|
let varName = varNamesArray[i];
|
||||||
|
|
||||||
|
// is there a next variable ?
|
||||||
|
let varNameNext: string = (() => {
|
||||||
|
if (varNamesArray[i + 1]) {
|
||||||
|
return varNamesArray[i + 1];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
})();
|
||||||
|
|
||||||
|
// build the tree in suppliedVariables
|
||||||
|
if (!referencePointer[varName] && !varNameNext) {
|
||||||
|
referencePointer[varName] = valueArg;
|
||||||
|
referencePointer = null;
|
||||||
|
} else if (!referencePointer[varName] && varNameNext) {
|
||||||
|
referencePointer[varName] = {};
|
||||||
|
referencePointer = referencePointer[varName];
|
||||||
|
} else if (referencePointer[varName] && varNameNext) {
|
||||||
|
referencePointer = referencePointer[varName];
|
||||||
|
} else {
|
||||||
|
throw new Error('Something is strange!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@ -1,16 +1,10 @@
|
|||||||
import 'typings-global'
|
import * as path from 'path';
|
||||||
import * as lodash from 'lodash'
|
import * as lik from '@pushrocks/lik';
|
||||||
import * as path from 'path'
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
import * as smartfile from 'smartfile'
|
import * as smartfm from '@pushrocks/smartfm';
|
||||||
import * as smarthbs from 'smarthbs'
|
import * as smarthbs from '@pushrocks/smarthbs';
|
||||||
import * as smartinteract from 'smartinteract'
|
import * as smartinteract from '@pushrocks/smartinteract';
|
||||||
import * as smartq from 'smartq'
|
import * as smartq from '@pushrocks/smartpromise';
|
||||||
|
import * as smartyaml from '@pushrocks/smartyaml';
|
||||||
|
|
||||||
export {
|
export { path, lik, smartfile, smartfm, smarthbs, smartinteract, smartq, smartyaml };
|
||||||
lodash,
|
|
||||||
path,
|
|
||||||
smartfile,
|
|
||||||
smarthbs,
|
|
||||||
smartinteract,
|
|
||||||
smartq
|
|
||||||
}
|
|
||||||
|
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