BREAKING CHANGE(scope): switch to new @pushrocks scope

This commit is contained in:
Philipp Kunz 2018-08-27 23:55:14 +02:00
parent c5ec7e9c24
commit a3f18c17ed
17 changed files with 1740 additions and 1405 deletions

View File

@ -3,69 +3,140 @@ image: hosttoday/ht-docker-node:npmci
cache:
paths:
- .yarn/
- .npmci_cache/
key: "$CI_BUILD_STAGE"
stages:
- security
- test
- release
- trigger
- pages
- metadata
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
tags:
- docker
- notpriv
snyk:
stage: security
script:
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
tags:
- docker
- notpriv
# ====================
# test stage
# ====================
testLEGACY:
stage: test
script:
- npmci test legacy
- npmci node install legacy
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
allow_failure: true
testLTS:
stage: test
script:
- npmci test lts
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
testSTABLE:
stage: test
script:
- npmci test stable
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
release:
stage: release
script:
- npmci publish
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- 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:
stage: trigger
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
stage: pages
stage: metadata
script:
- npmci command yarn global add npmpage
- npmci command npmpage
- npmci command npm install -g typedoc typescript
- npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
tags:
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true
windowsCompatibility:
image: stefanscherer/node-windows:10-build-tools
stage: metadata
script:
- npm install & npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- windows
allow_failure: true

View File

@ -30,11 +30,11 @@ export declare class ScafTemplate {
* finds all variables in a Template in as string
* e.g. myobject.someKey and myobject.someOtherKey
*/
private _findVariablesInTemplate();
private _findVariablesInTemplate;
/**
* checks if supplied Variables satisfy the template
*/
private _checkSuppliedVariables();
private _checkSuppliedVariables;
/**
* checks the default.yml at the root of a template for default variables
* allows 2 ways of notation in YAML:
@ -47,5 +47,5 @@ export declare class ScafTemplate {
* >> - yourKey:
* >> - yourDeeperKey: yourValue
*/
private _checkDefaultVariables();
private _checkDefaultVariables;
}

View File

@ -33,7 +33,7 @@ class ScafTemplate {
*/
supplyVariables(variablesArg) {
return __awaiter(this, void 0, void 0, function* () {
this.suppliedVariables = plugins.lodash.merge(this.suppliedVariables, variablesArg);
this.suppliedVariables = Object.assign({}, this.suppliedVariables, variablesArg);
this.missingVariables = yield this._checkSuppliedVariables();
});
}
@ -45,7 +45,8 @@ class ScafTemplate {
this.missingVariables = yield this._checkSuppliedVariables();
let localSmartInteract = new plugins.smartinteract.SmartInteract();
for (let missingVariable of this.missingVariables) {
localSmartInteract.addQuestions([{
localSmartInteract.addQuestions([
{
name: missingVariable,
type: 'input',
default: (() => {
@ -57,7 +58,8 @@ class ScafTemplate {
}
})(),
message: `What is the value of ${missingVariable}?`
}]);
}
]);
}
let answerBucket = yield localSmartInteract.runQueue();
answerBucket.answerMap.forEach((answer) => __awaiter(this, void 0, void 0, function* () {
@ -67,7 +69,7 @@ class ScafTemplate {
}
writeToDisk(destinationDirArg) {
return __awaiter(this, void 0, void 0, function* () {
let smartfileArrayToWrite = plugins.lodash.cloneDeep(this.templateSmartfileArray);
let smartfileArrayToWrite = this.templateSmartfileArray;
for (let smartfile of smartfileArrayToWrite) {
// render the template
let template = yield plugins.smarthbs.getTemplateForString(smartfile.contents.toString());
@ -91,9 +93,11 @@ class ScafTemplate {
let templateVariables = [];
for (let templateSmartfile of this.templateSmartfileArray) {
let localTemplateVariables = yield plugins.smarthbs.findVarsInHbsString(templateSmartfile.contents.toString());
templateVariables = plugins.lodash.concat(templateVariables, localTemplateVariables);
templateVariables = [...templateVariables, ...localTemplateVariables];
}
templateVariables = plugins.lodash.uniq(templateVariables);
templateVariables = templateVariables.filter((value, index, self) => {
return self.indexOf(value) === index;
});
});
}
/**
@ -104,9 +108,14 @@ class ScafTemplate {
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 = [
...missingVars,
...localMissingVars
];
}
missingVars = plugins.lodash.uniq(missingVars);
missingVars = missingVars.filter((value, index, self) => {
return self.indexOf(value) === index;
});
return missingVars;
});
}
@ -138,4 +147,4 @@ class ScafTemplate {
}
}
exports.ScafTemplate = ScafTemplate;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLmNsYXNzZXMuc21hcnRzY2FmLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzY2FmLmNsYXNzZXMuc21hcnRzY2FmLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUFBQSwrQ0FBOEM7QUFDOUMsK0NBQThDO0FBVzlDO0lBQUE7UUFNRSxzQkFBaUIsR0FBUSxFQUFFLENBQUE7UUFDM0IscUJBQWdCLEdBQWEsRUFBRSxDQUFBO0lBOEhqQyxDQUFDO0lBNUhDOztPQUVHO0l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Q0gsQ0FBQztLQUFBO0NBQ0Y7QUEvSUQsb0NBK0lDIn0=

View File

@ -40,4 +40,4 @@ exports.deepAddToObject = (objectArg, varStringArg, valueArg) => __awaiter(this,
}
}
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLmhlbHBlcnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNjYWYuaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBRUE7O0dBRUc7QUFDUSxRQUFBLGVBQWUsR0FBRyxDQUFPLFNBQVMsRUFBRSxZQUFvQixFQUFFLFFBQWdCO0lBQ25GLElBQUksYUFBYSxHQUFHLFlBQVksQ0FBQyxLQUFLLENBQUMsR0FBRyxDQUFDLENBQUE7SUFDM0MsSUFBSSxnQkFBZ0IsR0FBRyxTQUFTLENBQUE7SUFDaEMsR0FBRyxDQUFDLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsS0FBSyxhQUFhLENBQUMsTUFBTSxFQUFFLENBQUMsRUFBRSxFQUFFLENBQUM7UUFDaEQsSUFBSSxPQUFPLEdBQUcsYUFBYSxDQUFDLENBQUMsQ0FBQyxDQUFBO1FBRTlCLDZCQUE2QjtRQUM3QixJQUFJLFdBQVcsR0FBVyxDQUFDO1lBQ3pCLEVBQUUsQ0FBQyxDQUFDLGFBQWEsQ0FBQyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO2dCQUN6QixNQUFNLENBQUMsYUFBYSxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQTtZQUM3QixDQUFDO1lBQ0QsTUFBTSxDQUFDLElBQUksQ0FBQTtRQUNiLENBQUMsQ0FBQyxFQUFFLENBQUE7UUFFSixzQ0FBc0M7UUFDdEMsRUFBRSxDQUFDLENBQUMsQ0FBQyxnQkFB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xDQUFBO1NBQzdDO2FBQU07WUFDTCxNQUFNLElBQUksS0FBSyxDQUFDLHVCQUF1QixDQUFDLENBQUE7U0FDekM7S0FDRjtBQUNILENBQUMsQ0FBQSxDQUFBIn0=

View File

@ -1,5 +1,3 @@
import 'typings-global';
import * as lodash from 'lodash';
import * as path from 'path';
import * as smartfile from 'smartfile';
import * as smartfm from 'smartfm';
@ -7,4 +5,4 @@ import * as smarthbs from 'smarthbs';
import * as smartinteract from 'smartinteract';
import * as smartq from 'smartq';
import * as smartyaml from 'smartyaml';
export { lodash, path, smartfile, smartfm, smarthbs, smartinteract, smartq, smartyaml };
export { path, smartfile, smartfm, smarthbs, smartinteract, smartq, smartyaml };

View File

@ -1,8 +1,5 @@
"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");
@ -17,4 +14,4 @@ const smartq = require("smartq");
exports.smartq = smartq;
const smartyaml = require("smartyaml");
exports.smartyaml = smartyaml;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNjYWYucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2QixpQ0FBZ0M7QUFVOUIsd0JBQU07QUFUUiw2QkFBNEI7QUFVMUIsb0JBQUk7QUFUTix1Q0FBc0M7QUFVcEMsOEJBQVM7QUFUWCxtQ0FBa0M7QUFVaEMsMEJBQU87QUFUVCxxQ0FBb0M7QUFVbEMsNEJBQVE7QUFUViwrQ0FBOEM7QUFVNUMsc0NBQWE7QUFUZixpQ0FBZ0M7QUFVOUIsd0JBQU07QUFUUix1Q0FBc0M7QUFVcEMsOEJBQVMifQ==
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNjYWYucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDZCQUE0QjtBQVMxQixvQkFBSTtBQVJOLHVDQUFzQztBQVNwQyw4QkFBUztBQVJYLG1DQUFrQztBQVNoQywwQkFBTztBQVJULHFDQUFvQztBQVNsQyw0QkFBUTtBQVJWLCtDQUE4QztBQVM1QyxzQ0FBYTtBQVJmLGlDQUFnQztBQVM5Qix3QkFBTTtBQVJSLHVDQUFzQztBQVNwQyw4QkFBUyJ9

View File

@ -1,13 +1,16 @@
# smartscaf
scaffold projects quickly
## Availabililty
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartscaf)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartscaf)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartscaf)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartscaf/)
## Status for master
[![build status](https://GitLab.com/pushrocks/smartscaf/badges/master/build.svg)](https://GitLab.com/pushrocks/smartscaf/commits/master)
[![coverage report](https://GitLab.com/pushrocks/smartscaf/badges/master/coverage.svg)](https://GitLab.com/pushrocks/smartscaf/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/smartscaf.svg)](https://www.npmjs.com/package/smartscaf)
@ -19,11 +22,12 @@ scaffold projects quickly
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
Use TypeScript for best in class instellisense.
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)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://)

View File

@ -3,8 +3,7 @@
"coverageTreshold": 30
},
"npmci": {
"globalNpmTools": [
"npmts"
]
"npmGlobalTools": [],
"npmAccessLevel": "public"
}
}

1475
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,13 @@
{
"name": "smartscaf",
"name": "@pushrocks/smartscaf",
"version": "1.0.14",
"private": false,
"description": "scaffold projects quickly",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
"test": "(npmts)",
"test": "(tstest test/)",
"build": "(tsbuild)",
"testLocal": "(npmts --notest && ts-node --compilerOptions '{\"target\":\"es6\"}' test/test.ts)"
},
"repository": {
@ -24,17 +26,20 @@
"npm"
],
"devDependencies": {
"tapbundle": "^1.1.1"
"@gitzone/tsbuild": "^2.0.22",
"@gitzone/tsrun": "^1.1.12",
"@gitzone/tstest": "^1.0.15",
"@pushrocks/tapbundle": "^3.0.5",
"@types/node": "^10.9.2"
},
"dependencies": {
"@pushrocks/smartfile": "^6.0.8",
"@pushrocks/smartfm": "^2.0.1",
"@pushrocks/smarthbs": "^2.0.0",
"@pushrocks/smartinteract": "^2.0.4",
"@pushrocks/smartpromise": "^2.0.5",
"@pushrocks/smartyaml": "^2.0.3",
"@types/lodash": "^4.14.72",
"lodash": "^4.17.4",
"smartfile": "^4.2.20",
"smartfm": "^1.0.5",
"smarthbs": "^1.0.16",
"smartinteract": "^1.0.10",
"smartq": "^1.1.6",
"smartyaml": "^1.0.2",
"typings-global": "^1.0.20"
"lodash": "^4.17.4"
}
}

View File

@ -1,13 +1,16 @@
# smartscaf
scaffold projects quickly
## Availabililty
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartscaf)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartscaf)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartscaf)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartscaf/)
## Status for master
[![build status](https://GitLab.com/pushrocks/smartscaf/badges/master/build.svg)](https://GitLab.com/pushrocks/smartscaf/commits/master)
[![coverage report](https://GitLab.com/pushrocks/smartscaf/badges/master/coverage.svg)](https://GitLab.com/pushrocks/smartscaf/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/smartscaf.svg)](https://www.npmjs.com/package/smartscaf)
@ -19,11 +22,12 @@ scaffold projects quickly
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
Use TypeScript for best in class instellisense.
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)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://)

View File

@ -1,37 +1,37 @@
import { expect, tap } from 'tapbundle'
import * as path from 'path'
import { expect, tap } from '@pushrocks/tapbundle';
import * as path from 'path';
import * as smartscaf from '../ts/index'
import * as smartscaf from '../ts/index';
// process.env.CI = 'true'
process.env.CI = 'true'
let testScafTemplate: smartscaf.ScafTemplate
let testScafTemplate: smartscaf.ScafTemplate;
tap.test('should create new Smartscaf instance', async () => {
testScafTemplate = new smartscaf.ScafTemplate()
expect(testScafTemplate).to.be.instanceof(smartscaf.ScafTemplate)
})
testScafTemplate = new smartscaf.ScafTemplate();
expect(testScafTemplate).to.be.instanceof(smartscaf.ScafTemplate);
});
tap.test('Smartscaf instance -> should read a template directory', async () => {
await testScafTemplate.readTemplateFromDir('./test/test_template')
expect(testScafTemplate.templateSmartfileArray.length).to.equal(5)
})
await testScafTemplate.readTemplateFromDir('./test/test_template');
expect(testScafTemplate.templateSmartfileArray.length).to.equal(5);
});
tap.test('smartfile -> should accept variables', async () => {
await testScafTemplate.supplyVariables({})
console.log(testScafTemplate.missingVariables)
})
await testScafTemplate.supplyVariables({});
console.log(testScafTemplate.missingVariables);
});
tap.test('ask cli', async () => {
await testScafTemplate.askCliForMissingVariables()
})
await testScafTemplate.askCliForMissingVariables();
});
tap.test('should have valid supplied variables', async () => {
console.log(testScafTemplate.suppliedVariables)
})
console.log(testScafTemplate.suppliedVariables);
});
tap.test('should output ready rendered template', async () => {
await testScafTemplate.writeToDisk(path.resolve('./test/test_output'))
})
await testScafTemplate.writeToDisk(path.resolve('./test/test_output'));
});
tap.start()
tap.start();

View File

@ -1 +1 @@
export * from './smartscaf.classes.smartscaf'
export * from './smartscaf.classes.smartscaf';

View File

@ -1,33 +1,33 @@
import * as plugins from './smartscaf.plugins'
import * as helpers from './smartscaf.helpers'
import * as plugins from './smartscaf.plugins';
import * as helpers from './smartscaf.helpers';
// interfaces
import { Smartfile } from 'smartfile'
import { Smartfile } from '@pushrocks/smartfile';
export interface ScafTemplateContructorOptions {
name?: string,
description?: string
sourceDir?: string
name?: string;
description?: string;
sourceDir?: string;
}
export class ScafTemplate {
name: string
description: string
templateSmartfileArray: Smartfile[]
requiredVariables: string[]
defaultVariables: any
suppliedVariables: any = {}
missingVariables: string[] = []
name: string;
description: string;
templateSmartfileArray: Smartfile[];
requiredVariables: string[];
defaultVariables: any;
suppliedVariables: any = {};
missingVariables: string[] = [];
/**
* read a template from a directory
*/
async readTemplateFromDir(dirPathArg: string) {
let dirPath = plugins.path.resolve(dirPathArg)
this.templateSmartfileArray = await plugins.smartfile.fs.fileTreeToObject(dirPath, '**/*')
await this._findVariablesInTemplate()
await this._checkSuppliedVariables()
await this._checkDefaultVariables()
let dirPath = plugins.path.resolve(dirPathArg);
this.templateSmartfileArray = await plugins.smartfile.fs.fileTreeToObject(dirPath, '**/*');
await this._findVariablesInTemplate();
await this._checkSuppliedVariables();
await this._checkDefaultVariables();
}
/**
@ -35,57 +35,61 @@ export class ScafTemplate {
* @param variablesArg gets merged with this.suppliedVariables
*/
async supplyVariables(variablesArg) {
this.suppliedVariables = plugins.lodash.merge(this.suppliedVariables, variablesArg)
this.missingVariables = await this._checkSuppliedVariables()
this.suppliedVariables = {
...this.suppliedVariables,
...variablesArg
};
this.missingVariables = await this._checkSuppliedVariables();
}
/**
* Will ask for the missing variables by cli interaction
*/
async askCliForMissingVariables() {
this.missingVariables = await this._checkSuppliedVariables()
let localSmartInteract = new plugins.smartinteract.SmartInteract()
this.missingVariables = await this._checkSuppliedVariables();
let localSmartInteract = new plugins.smartinteract.SmartInteract();
for (let missingVariable of this.missingVariables) {
localSmartInteract.addQuestions([{
localSmartInteract.addQuestions([
{
name: missingVariable,
type: 'input',
default: (() => {
if (this.defaultVariables && this.defaultVariables[missingVariable]) {
return this.defaultVariables[missingVariable]
return this.defaultVariables[missingVariable];
} else {
return 'undefined variable'
return 'undefined variable';
}
})(),
message: `What is the value of ${missingVariable}?`
}])
}
let answerBucket = await localSmartInteract.runQueue()
]);
}
let answerBucket = await localSmartInteract.runQueue();
answerBucket.answerMap.forEach(async answer => {
await helpers.deepAddToObject(this.suppliedVariables, answer.name, answer.value)
})
await helpers.deepAddToObject(this.suppliedVariables, answer.name, answer.value);
});
}
async writeToDisk(destinationDirArg) {
let smartfileArrayToWrite = plugins.lodash.cloneDeep(this.templateSmartfileArray)
let smartfileArrayToWrite = this.templateSmartfileArray;
for (let smartfile of smartfileArrayToWrite) {
// render the template
let template = await plugins.smarthbs.getTemplateForString(
smartfile.contents.toString()
)
let renderedTemplateString = template(this.suppliedVariables)
let template = await plugins.smarthbs.getTemplateForString(smartfile.contents.toString());
let renderedTemplateString = template(this.suppliedVariables);
// handle frontmatter
let parsedTemplate = plugins.smartfm.parse(renderedTemplateString)
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.updateFileName(parsedTemplate.data.fileName);
}
smartfile.contents = Buffer.from(parsedTemplate.content)
smartfile.contents = Buffer.from(parsedTemplate.content);
}
await plugins.smartfile.memory.smartfileArrayToFs(smartfileArrayToWrite, destinationDirArg)
await plugins.smartfile.memory.smartfileArrayToFs(smartfileArrayToWrite, destinationDirArg);
}
/**
@ -93,28 +97,34 @@ export class ScafTemplate {
* e.g. myobject.someKey and myobject.someOtherKey
*/
private async _findVariablesInTemplate() {
let templateVariables: string[] = []
let templateVariables: string[] = [];
for (let templateSmartfile of this.templateSmartfileArray) {
let localTemplateVariables = await plugins.smarthbs.findVarsInHbsString(templateSmartfile.contents.toString())
templateVariables = plugins.lodash.concat(templateVariables, localTemplateVariables)
let localTemplateVariables = await plugins.smarthbs.findVarsInHbsString(
templateSmartfile.contents.toString()
);
templateVariables = [...templateVariables, ...localTemplateVariables];
}
templateVariables = plugins.lodash.uniq(templateVariables)
templateVariables = templateVariables.filter((value, index, self) => {
return self.indexOf(value) === index;
});
}
/**
* checks if supplied Variables satisfy the template
*/
private async _checkSuppliedVariables() {
let missingVars: string[] = []
let missingVars: string[] = [];
for (let templateSmartfile of this.templateSmartfileArray) {
let localMissingVars = await plugins.smarthbs.checkVarsSatisfaction(
templateSmartfile.contents.toString(),
this.suppliedVariables
)
missingVars = plugins.lodash.concat(missingVars, localMissingVars)
);
missingVars = [...missingVars, ...localMissingVars];
}
missingVars = plugins.lodash.uniq(missingVars)
return missingVars
missingVars = missingVars.filter((value, index, self) => {
return self.indexOf(value) === index;
});
return missingVars;
}
/**
@ -131,16 +141,16 @@ export class ScafTemplate {
*/
private async _checkDefaultVariables() {
let defaultsSmartfile = this.templateSmartfileArray.filter(smartfileArg => {
return smartfileArg.parsedPath.base === 'defaults.yml'
})[0]
return smartfileArg.parsedPath.base === 'defaults.yml';
})[0];
if (defaultsSmartfile) {
let defaultObject = await plugins.smartyaml.yamlStringToObject(
defaultsSmartfile.contents.toString()
)
this.defaultVariables = defaultObject
);
this.defaultVariables = defaultObject;
} else {
this.defaultVariables = {}
this.defaultVariables = {};
}
}
}

View File

@ -1,33 +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
let varNamesArray = varStringArg.split('.');
let referencePointer = objectArg;
for (let i = 0; i !== varNamesArray.length; i++) {
let varName = varNamesArray[i]
let varName = varNamesArray[i];
// is there a next variable ?
let varNameNext: string = (() => {
if (varNamesArray[i + 1]) {
return varNamesArray[i + 1]
return varNamesArray[i + 1];
}
return null
})()
return null;
})();
// build the tree in suppliedVariables
if (!referencePointer[varName] && !varNameNext) {
referencePointer[varName] = valueArg
referencePointer = null
referencePointer[varName] = valueArg;
referencePointer = null;
} else if (!referencePointer[varName] && varNameNext) {
referencePointer[varName] = {}
referencePointer = referencePointer[varName]
referencePointer[varName] = {};
referencePointer = referencePointer[varName];
} else if (referencePointer[varName] && varNameNext) {
referencePointer = referencePointer[varName]
referencePointer = referencePointer[varName];
} else {
throw new Error('Something is strange!')
}
throw new Error('Something is strange!');
}
}
};

View File

@ -1,20 +1,9 @@
import 'typings-global'
import * as lodash from 'lodash'
import * as path from 'path'
import * as smartfile from 'smartfile'
import * as smartfm from 'smartfm'
import * as smarthbs from 'smarthbs'
import * as smartinteract from 'smartinteract'
import * as smartq from 'smartq'
import * as smartyaml from 'smartyaml'
import * as path from 'path';
import * as smartfile from '@pushrocks/smartfile';
import * as smartfm from '@pushrocks/smartfm';
import * as smarthbs from '@pushrocks/smarthbs';
import * as smartinteract from '@pushrocks/smartinteract';
import * as smartq from '@pushrocks/smartpromise';
import * as smartyaml from '@pushrocks/smartyaml';
export {
lodash,
path,
smartfile,
smartfm,
smarthbs,
smartinteract,
smartq,
smartyaml
}
export { path, smartfile, smartfm, smarthbs, smartinteract, smartq, smartyaml };

1226
yarn.lock

File diff suppressed because it is too large Load Diff