Compare commits

..

35 Commits

Author SHA1 Message Date
25871fc970 3.0.1 2018-10-04 17:00:33 +02:00
eb990a8ec2 fix(core): update 2018-10-04 17:00:33 +02:00
f5194b76bd Merge branch 'master' into 'master'
update

See merge request pushrocks/smartscaf!1
2018-10-04 14:48:20 +00:00
6b5e9ac617 update 2018-10-04 16:04:42 +02:00
60854250eb 3.0.0 2018-08-30 22:43:22 +02:00
53de92ac1a BREAKING CHANGE(structure): templates now take their path within the constructor 2018-08-30 22:43:22 +02:00
6cb4fff0a5 2.0.2 2018-08-28 23:57:06 +02:00
45710ded00 2.0.1 2018-08-28 00:20:02 +02:00
aa87ed9427 fix(dependencies): resolve dependencies 2018-08-28 00:20:02 +02:00
f3594447ac 2.0.0 2018-08-27 23:55:14 +02:00
a3f18c17ed BREAKING CHANGE(scope): switch to new @pushrocks scope 2018-08-27 23:55:14 +02:00
c5ec7e9c24 1.0.14 2017-08-09 16:57:39 +02:00
98875a2ece fix variable distribution 2017-08-09 16:57:32 +02:00
5b42cf93cb 1.0.13 2017-08-09 15:31:39 +02:00
e0ab34c466 update dependencies 2017-08-09 15:31:35 +02:00
beb3013e2c 1.0.12 2017-07-28 14:47:46 +02:00
5d1c0a6f1e update dependencies 2017-07-28 14:47:43 +02:00
fc450816e6 1.0.11 2017-06-02 01:03:27 +02:00
5fac35c75f prevent empty defaults.yml causing error 2017-06-02 01:03:24 +02:00
dde29629b7 1.0.10 2017-05-28 00:14:25 +02:00
4347f800e6 update dependencies 2017-05-28 00:14:11 +02:00
59161f1eeb 1.0.9 2017-05-27 23:53:06 +02:00
b9a346c5d7 now supports frontmatter for advanced file templating 2017-05-27 23:52:58 +02:00
fa961f86b8 1.0.8 2017-05-27 03:25:50 +02:00
ff679c1787 add docs 2017-05-27 03:25:42 +02:00
35e3c9ae48 1.0.7 2017-05-27 03:22:00 +02:00
bf0007ff3a fix deep add 2017-05-27 03:21:55 +02:00
3ab780e600 1.0.6 2017-05-27 02:57:25 +02:00
d0662f809f update smartfile 2017-05-27 02:57:22 +02:00
e20bf7f610 1.0.5 2017-05-27 01:47:21 +02:00
0a97ec4d07 fix tests 2017-05-27 01:47:16 +02:00
69e09c8b4c 1.0.4 2017-05-27 01:28:42 +02:00
0e92554d0a update smartfile 2017-05-27 01:28:37 +02:00
648afbcf21 1.0.3 2017-05-26 15:32:54 +02:00
7998c99f27 now works as intended 2017-05-26 15:32:50 +02:00
28 changed files with 1922 additions and 1257 deletions

View File

@ -3,69 +3,140 @@ image: 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
# ====================
# 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: testLEGACY:
stage: test stage: test
script: script:
- npmci test legacy - npmci node install legacy
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- notpriv
allow_failure: true allow_failure: true
testLTS: testLTS:
stage: test stage: test
script: script:
- npmci test lts - npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- notpriv
testSTABLE: testSTABLE:
stage: test stage: test
script: script:
- npmci test stable - npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ 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:npmci image: hosttoday/ht-docker-node:npmci
stage: pages stage: metadata
script: script:
- npmci command yarn global add npmpage - npmci command npm install -g typedoc typescript
- npmci command npmpage - npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
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
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

@ -25,15 +25,16 @@ export declare class ScafTemplate {
* Will ask for the missing variables by cli interaction * Will ask for the missing variables by cli interaction
*/ */
askCliForMissingVariables(): Promise<void>; askCliForMissingVariables(): Promise<void>;
writeToDisk(destinationDirArg: any): Promise<void>;
/** /**
* finds all variables in a Template in as string * finds all variables in a Template in as string
* e.g. myobject.someKey and myobject.someOtherKey * e.g. myobject.someKey and myobject.someOtherKey
*/ */
private _findVariablesInTemplate(); private _findVariablesInTemplate;
/** /**
* checks if supplied Variables satisfy the template * checks if supplied Variables satisfy the template
*/ */
private _checkSuppliedVariables(); private _checkSuppliedVariables;
/** /**
* checks the default.yml at the root of a template for default variables * checks the default.yml at the root of a template for default variables
* allows 2 ways of notation in YAML: * allows 2 ways of notation in YAML:
@ -46,5 +47,5 @@ export declare class ScafTemplate {
* >> - yourKey: * >> - yourKey:
* >> - yourDeeperKey: yourValue * >> - yourDeeperKey: yourValue
*/ */
private _checkDefaultVariables(); private _checkDefaultVariables;
} }

View File

@ -33,7 +33,7 @@ class ScafTemplate {
*/ */
supplyVariables(variablesArg) { supplyVariables(variablesArg) {
return __awaiter(this, void 0, void 0, function* () { 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(); this.missingVariables = yield this._checkSuppliedVariables();
}); });
} }
@ -45,11 +45,12 @@ class ScafTemplate {
this.missingVariables = yield this._checkSuppliedVariables(); this.missingVariables = yield 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, name: missingVariable,
type: 'input', type: 'input',
default: (() => { default: (() => {
if (this.defaultVariables[missingVariable]) { if (this.defaultVariables && this.defaultVariables[missingVariable]) {
return this.defaultVariables[missingVariable]; return this.defaultVariables[missingVariable];
} }
else { else {
@ -57,7 +58,8 @@ class ScafTemplate {
} }
})(), })(),
message: `What is the value of ${missingVariable}?` message: `What is the value of ${missingVariable}?`
}]); }
]);
} }
let answerBucket = yield localSmartInteract.runQueue(); let answerBucket = yield localSmartInteract.runQueue();
answerBucket.answerMap.forEach((answer) => __awaiter(this, void 0, void 0, function* () { answerBucket.answerMap.forEach((answer) => __awaiter(this, void 0, void 0, function* () {
@ -65,6 +67,23 @@ class ScafTemplate {
})); }));
}); });
} }
writeToDisk(destinationDirArg) {
return __awaiter(this, void 0, void 0, function* () {
let smartfileArrayToWrite = this.templateSmartfileArray;
for (let smartfile of smartfileArrayToWrite) {
// render the template
let template = yield plugins.smarthbs.getTemplateForString(smartfile.contents.toString());
let renderedTemplateString = template(this.suppliedVariables);
// handle frontmatter
let parsedTemplate = plugins.smartfm.parse(renderedTemplateString);
if (parsedTemplate.data.fileName) {
smartfile.updateFileName(parsedTemplate.data.fileName);
}
smartfile.contents = Buffer.from(parsedTemplate.content);
}
yield plugins.smartfile.memory.smartfileArrayToFs(smartfileArrayToWrite, destinationDirArg);
});
}
/** /**
* finds all variables in a Template in as string * finds all variables in a Template in as string
* e.g. myobject.someKey and myobject.someOtherKey * e.g. myobject.someKey and myobject.someOtherKey
@ -74,9 +93,11 @@ class ScafTemplate {
let templateVariables = []; let templateVariables = [];
for (let templateSmartfile of this.templateSmartfileArray) { for (let templateSmartfile of this.templateSmartfileArray) {
let localTemplateVariables = yield plugins.smarthbs.findVarsInHbsString(templateSmartfile.contents.toString()); 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;
});
}); });
} }
/** /**
@ -87,9 +108,14 @@ class ScafTemplate {
let missingVars = []; let missingVars = [];
for (let templateSmartfile of this.templateSmartfileArray) { for (let templateSmartfile of this.templateSmartfileArray) {
let localMissingVars = yield plugins.smarthbs.checkVarsSatisfaction(templateSmartfile.contents.toString(), this.suppliedVariables); 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; return missingVars;
}); });
} }
@ -121,4 +147,4 @@ class ScafTemplate {
} }
} }
exports.ScafTemplate = ScafTemplate; exports.ScafTemplate = ScafTemplate;
//# sourceMappingURL=data:application/json;base64,eyJ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FVBQVUsQ0FBQyxJQUFJLEtBQUssY0FBYyxDQUFDO1lBQ3pELENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBRU4sSUFBSSxpQkFBaUIsRUFBRTtnQkFDckIsSUFBSSxhQUFhLEdBQUcsTUFBTSxPQUFPLENBQUMsU0FBUyxDQUFDLGtCQUFrQixDQUM1RCxpQkFBaUIsQ0FBQyxRQUFRLENBQUMsUUFBUSxFQUFFLENBQ3RDLENBQUM7Z0JBQ0YsSUFBSSxDQUFDLGdCQUFnQixHQUFHLGFBQWEsQ0FBQzthQUN2QztpQkFBTTtnQkFDTCxJQUFJLENBQUMsZ0JBQWdCLEdBQUcsRUFBRSxDQUFDO2FBQzVCO1FBQ0gsQ0FBQztLQUFBO0NBQ0Y7QUEvSUQsb0NBK0lDIn0=

View File

@ -26,11 +26,18 @@ exports.deepAddToObject = (objectArg, varStringArg, valueArg) => __awaiter(this,
// build the tree in suppliedVariables // build the tree in suppliedVariables
if (!referencePointer[varName] && !varNameNext) { if (!referencePointer[varName] && !varNameNext) {
referencePointer[varName] = valueArg; referencePointer[varName] = valueArg;
referencePointer = null;
} }
else if (!referencePointer[varName] && varNameNext) { else if (!referencePointer[varName] && varNameNext) {
referencePointer[varName] = {}; referencePointer[varName] = {};
referencePointer = referencePointer[varName]; referencePointer = referencePointer[varName];
} }
else if (referencePointer[varName] && varNameNext) {
referencePointer = referencePointer[varName];
}
else {
throw new Error('Something is strange!');
}
} }
}); });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLmhlbHBlcnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNjYWYuaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBRUE7O0dBRUc7QUFDUSxRQUFBLGVBQWUsR0FBRyxDQUFPLFNBQVMsRUFBRSxZQUFvQixFQUF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FBQTtZQUNwQyxnQkFBZ0IsR0FBRyxJQUFJLENBQUE7U0FDeEI7YUFBTSxJQUFJLENBQUMsZ0JBQWdCLENBQUMsT0FBTyxDQUFDLElBQUksV0FBVyxFQUFFO1lBQ3BELGdCQUFnQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsQ0FBQTtZQUM5QixnQkFBZ0IsR0FBRyxnQkFBZ0IsQ0FBQyxPQUFPLENBQUMsQ0FBQTtTQUM3QzthQUFNLElBQUksZ0JBQWdCLENBQUMsT0FBTyxDQUFDLElBQUksV0FBVyxFQUFFO1lBQ25ELGdCQUFnQixHQUFHLGdCQUFnQixDQUFDLE9BQU8sQ0FBQyxDQUFBO1NBQzdDO2FBQU07WUFDTCxNQUFNLElBQUksS0FBSyxDQUFDLHVCQUF1QixDQUFDLENBQUE7U0FDekM7S0FDRjtBQUNILENBQUMsQ0FBQSxDQUFBIn0=

View File

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

View File

@ -1,12 +1,11 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
require("typings-global");
const lodash = require("lodash");
exports.lodash = lodash;
const path = require("path"); const path = require("path");
exports.path = path; exports.path = path;
const smartfile = require("smartfile"); const smartfile = require("smartfile");
exports.smartfile = smartfile; exports.smartfile = smartfile;
const smartfm = require("smartfm");
exports.smartfm = smartfm;
const smarthbs = require("smarthbs"); const smarthbs = require("smarthbs");
exports.smarthbs = smarthbs; exports.smarthbs = smarthbs;
const smartinteract = require("smartinteract"); const smartinteract = require("smartinteract");
@ -15,4 +14,4 @@ const smartq = require("smartq");
exports.smartq = smartq; exports.smartq = smartq;
const smartyaml = require("smartyaml"); const smartyaml = require("smartyaml");
exports.smartyaml = smartyaml; exports.smartyaml = smartyaml;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNjYWYucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2QixpQ0FBZ0M7QUFTOUIsd0JBQU07QUFSUiw2QkFBNEI7QUFTMUIsb0JBQUk7QUFSTix1Q0FBc0M7QUFTcEMsOEJBQVM7QUFSWCxxQ0FBb0M7QUFTbEMsNEJBQVE7QUFSViwrQ0FBOEM7QUFTNUMsc0NBQWE7QUFSZixpQ0FBZ0M7QUFTOUIsd0JBQU07QUFSUix1Q0FBc0M7QUFTcEMsOEJBQVMifQ== //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNjYWYucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDZCQUE0QjtBQVMxQixvQkFBSTtBQVJOLHVDQUFzQztBQVNwQyw4QkFBUztBQVJYLG1DQUFrQztBQVNoQywwQkFBTztBQVJULHFDQUFvQztBQVNsQyw0QkFBUTtBQVJWLCtDQUE4QztBQVM1QyxzQ0FBYTtBQVJmLGlDQUFnQztBQVM5Qix3QkFBTTtBQVJSLHVDQUFzQztBQVNwQyw4QkFBUyJ9

33
docs/index.md Normal file
View File

@ -0,0 +1,33 @@
# 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)
[![Dependency Status](https://david-dm.org/pushrocks/smartscaf.svg)](https://david-dm.org/pushrocks/smartscaf)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartscaf/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartscaf/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartscaf/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartscaf)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![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 | **&copy;** [Lossless GmbH](https://lossless.gmbh)
> | 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 "coverageTreshold": 30
}, },
"npmci": { "npmci": {
"globalNpmTools": [ "npmGlobalTools": [],
"npmts" "npmAccessLevel": "public"
]
} }
} }

1475
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,14 @@
{ {
"name": "smartscaf", "name": "@pushrocks/smartscaf",
"version": "1.0.2", "version": "3.0.1",
"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)",
"testLocal": "(npmts --notest && ts-node --compilerOptions '{\"target\":\"es6\"}' test/test.ts)"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -23,16 +26,21 @@
"npm" "npm"
], ],
"devDependencies": { "devDependencies": {
"tapbundle": "^1.0.12" "@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": { "dependencies": {
"@types/lodash": "^4.14.64", "@pushrocks/lik": "^3.0.1",
"lodash": "^4.17.4", "@pushrocks/smartfile": "^6.0.8",
"smartfile": "^4.2.11", "@pushrocks/smartfm": "^2.0.1",
"smarthbs": "^1.0.12", "@pushrocks/smarthbs": "^2.0.0",
"smartinteract": "^1.0.4", "@pushrocks/smartinteract": "^2.0.4",
"smartq": "^1.1.1", "@pushrocks/smartpromise": "^2.0.5",
"smartyaml": "^1.0.2", "@pushrocks/smartyaml": "^2.0.3",
"typings-global": "^1.0.16" "@types/lodash": "^4.14.72",
"lodash": "^4.17.4"
} }
} }

View File

@ -1,13 +1,16 @@
# smartscaf # smartscaf
scaffold projects quickly scaffold projects quickly
## Availabililty ## Availabililty
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartscaf) [![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-git.svg)](https://GitLab.com/pushrocks/smartscaf)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.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/) [![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartscaf/)
## Status for master ## Status for master
[![build status](https://GitLab.com/pushrocks/smartscaf/badges/master/build.svg)](https://GitLab.com/pushrocks/smartscaf/commits/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) [![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) [![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/) [![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](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 | **&copy;** [Lossless GmbH](https://lossless.gmbh) > MIT licensed | **&copy;** [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://) [![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://)

View File

@ -1,28 +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';
process.env.CI = 'true' process.env.CI = 'true'
let testScafTemplate: smartscaf.ScafTemplate 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(4) 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();

View File

@ -0,0 +1 @@
# some undefined variable

View File

@ -0,0 +1 @@
# param1 10

View File

@ -0,0 +1 @@
awesome!

View File

@ -0,0 +1,3 @@
# this is a wow
# this is a here
# this is a undefined variable

View 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

View 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

View File

@ -1,2 +0,0 @@
templateVar1: from default yaml
templateVar2: this is another value from yml

View File

@ -0,0 +1 @@
awesome!

View File

@ -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}}

View File

@ -1 +1,4 @@
---
fileName: changedname.md
---
# some {{wow}} # some {{wow}}

View File

@ -0,0 +1 @@
# param1 {{node_version}}

View File

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

View File

@ -1,102 +1,172 @@
import * as plugins from './smartscaf.plugins' import * as plugins from './smartscaf.plugins';
import * as helpers from './smartscaf.helpers' 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[]
defaultVariables: any /**
suppliedVariables: any = {} * the name of the template
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();
await this._findVariablesInTemplate() await this._findVariablesInTemplate();
await this._checkSuppliedVariables() await this._checkSuppliedVariables();
await this._checkDefaultVariables() await this._checkDefaultVariables();
} }
/** /**
* supply the variables to render the teplate with * supply the variables to render the teplate with
* @param variablesArg gets merged with this.suppliedVariables * @param variablesArg gets merged with this.suppliedVariables
*/ */
async supplyVariables (variablesArg) { async supplyVariables(variablesArg) {
this.suppliedVariables = plugins.lodash.merge(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, name: missingVariable,
type: 'input', type: 'input',
default: (() => { default: (() => {
if (this.defaultVariables[missingVariable]) { if (this.defaultVariables && this.defaultVariables[missingVariable]) {
return this.defaultVariables[missingVariable] return this.defaultVariables[missingVariable];
} else { } else {
return 'undefined variable' return 'undefined variable';
} }
})(), })(),
message: `What is the value of ${missingVariable}?` message: `What is the value of ${missingVariable}?`
}])
} }
let answerBucket = await localSmartInteract.runQueue() ]);
answerBucket.answerMap.forEach(async answer => { }
await helpers.deepAddToObject(this.suppliedVariables, answer.name, answer.value) let answerBucket = await localSmartInteract.runQueue();
}) await answerBucket.answerMap.forEach(async answer => {
await helpers.deepAddToObject(this.suppliedVariables, answer.name, answer.value);
});
}
/**
* 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 * finds all variables in a Template in as string
* e.g. myobject.someKey and myobject.someOtherKey * e.g. myobject.someKey and myobject.someOtherKey
*/ */
private async _findVariablesInTemplate () { private async _findVariablesInTemplate() {
let templateVariables: string[] = [] let templateVariables: string[] = [];
for (let templateSmartfile of this.templateSmartfileArray) { for (let templateSmartfile of this.templateSmartfileArray) {
let localTemplateVariables = await plugins.smarthbs.findVarsInHbsString(templateSmartfile.contents.toString()) let localTemplateVariables = await plugins.smarthbs.findVarsInHbsString(
templateVariables = plugins.lodash.concat(templateVariables, localTemplateVariables) 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 * 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)
// combine with other missingVars
missingVars = [...missingVars, ...localMissingVars];
} }
missingVars = plugins.lodash.uniq(missingVars)
return missingVars // dedupe
missingVars = missingVars.filter((value, index, self) => {
return self.indexOf(value) === index;
});
return missingVars;
} }
/** /**
* checks the default.yml at the root of a template for default variables * checks the smartscaf.yml default values at the root of a template
* allows 2 ways of notation in YAML: * allows 2 ways of notation in YAML:
* >> myObject.myKey.someDeeperKey: someValue * >> myObject.myKey.someDeeperKey: someValue
* >> myObject.yourKey.yourDeeperKey: yourValue * >> myObject.yourKey.yourDeeperKey: yourValue
@ -107,18 +177,53 @@ export class ScafTemplate {
* >> - yourKey: * >> - yourKey:
* >> - yourDeeperKey: yourValue * >> - yourDeeperKey: yourValue
*/ */
private async _checkDefaultVariables () { private async _checkDefaultVariables() {
let defaultsSmartfile = this.templateSmartfileArray.filter(smartfileArg => { let smartscafSmartfile = this.templateSmartfileArray.find(smartfileArg => {
return smartfileArg.parsedPath.base === 'defaults.yml' return smartfileArg.parsedPath.base === '.smartscaf.yml';
})[0] });
if (defaultsSmartfile) { if (smartscafSmartfile) {
let defaultObject = await plugins.smartyaml.yamlStringToObject( const smartscafObject = await plugins.smartyaml.yamlStringToObject(
defaultsSmartfile.contents.toString() smartscafSmartfile.contents.toString()
) );
this.defaultVariables = defaultObject const defaultObject = smartscafObject.defaults;
} else { this.defaultVariables = defaultObject;
this.defaultVariables = {} }
// 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);
} }
} }
} }

View File

@ -1,28 +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 * adds a variable in string dot notation to an already more or less expanded object
*/ */
export let deepAddToObject = async (objectArg, varStringArg: string, valueArg: string) => { export let deepAddToObject = async (objectArg, varStringArg: string, valueArg: string) => {
let varNamesArray = varStringArg.split('.') let varNamesArray = varStringArg.split('.');
let referencePointer = objectArg let referencePointer = objectArg;
for (let i = 0; i !== varNamesArray.length; i++) { for (let i = 0; i !== varNamesArray.length; i++) {
let varName = varNamesArray[i] let varName = varNamesArray[i];
// is there a next variable ? // is there a next variable ?
let varNameNext: string = (() => { let varNameNext: string = (() => {
if (varNamesArray[i + 1]) { if (varNamesArray[i + 1]) {
return varNamesArray[i + 1] return varNamesArray[i + 1];
} }
return null return null;
})() })();
// build the tree in suppliedVariables // build the tree in suppliedVariables
if (!referencePointer[varName] && !varNameNext) { if (!referencePointer[varName] && !varNameNext) {
referencePointer[varName] = valueArg referencePointer[varName] = valueArg;
referencePointer = null;
} else if (!referencePointer[varName] && varNameNext) { } else if (!referencePointer[varName] && varNameNext) {
referencePointer[varName] = {} referencePointer[varName] = {};
referencePointer = referencePointer[varName] referencePointer = referencePointer[varName];
} else if (referencePointer[varName] && varNameNext) {
referencePointer = referencePointer[varName];
} else {
throw new Error('Something is strange!');
} }
} }
} };

View File

@ -1,18 +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 'smartyaml' import * as smartyaml from '@pushrocks/smartyaml';
export { export { path, lik, smartfile, smartfm, smarthbs, smartinteract, smartq, smartyaml };
lodash,
path,
smartfile,
smarthbs,
smartinteract,
smartq,
smartyaml
}

1090
yarn.lock

File diff suppressed because it is too large Load Diff