Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
088bed779f | |||
1cecba6f13 | |||
324b93a419 | |||
4be3fc27b3 | |||
655a8a72ff | |||
80a77d5f06 | |||
6296411b50 | |||
e7690d4020 | |||
b85a29cfc1 | |||
d559b0f402 | |||
7433c1dba4 | |||
c8f6b0296d | |||
0cffae9eaa | |||
d50c8a1260 | |||
b3702d56bc |
21
.gitignore
vendored
21
.gitignore
vendored
@ -1,3 +1,22 @@
|
||||
node_modules/
|
||||
.nogit/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_web/
|
||||
dist_serve/
|
||||
dist_ts_web/
|
||||
|
||||
# custom
|
@ -1,5 +1,5 @@
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
@ -34,48 +34,11 @@ snyk:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
sast:
|
||||
stage: security
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-dbase:npmci
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:stable-dind
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||
- docker run
|
||||
--env SAST_CONFIDENCE_LEVEL="${SAST_CONFIDENCE_LEVEL:-3}"
|
||||
--volume "$PWD:/code"
|
||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
||||
"registry.gitlab.com/gitlab-org/security-products/sast:$SP_VERSION" /app/bin/run /code
|
||||
artifacts:
|
||||
reports:
|
||||
sast: gl-sast-report.json
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install lts
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
testSTABLE:
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
@ -85,6 +48,18 @@ testSTABLE:
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
@ -103,19 +78,12 @@ release:
|
||||
# ====================
|
||||
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]
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
@ -131,13 +99,15 @@ trigger:
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
image: hosttoday/ht-docker-dbase:npmci
|
||||
services:
|
||||
- docker:stable-dind
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci command npm install -g typedoc typescript
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
||||
- npmci command tsdoc
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
23
.snyk
Normal file
23
.snyk
Normal file
@ -0,0 +1,23 @@
|
||||
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
|
||||
version: v1.13.5
|
||||
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
|
||||
ignore:
|
||||
SNYK-JS-JSYAML-173999:
|
||||
- '@pushrocks/smartfm > gray-matter > js-yaml':
|
||||
reason: None given
|
||||
expires: '2019-10-10T16:23:38.993Z'
|
||||
- '@pushrocks/smartyaml > js-yaml':
|
||||
reason: None given
|
||||
expires: '2019-10-10T16:23:38.993Z'
|
||||
SNYK-JS-JSYAML-174129:
|
||||
- '@pushrocks/smartfm > gray-matter > js-yaml':
|
||||
reason: None given
|
||||
expires: '2019-10-10T16:23:38.993Z'
|
||||
- '@pushrocks/smartyaml > js-yaml':
|
||||
reason: None given
|
||||
expires: '2019-10-10T16:23:38.993Z'
|
||||
SNYK-JS-LODASH-450202:
|
||||
- '@pushrocks/smartinteract > inquirer > lodash':
|
||||
reason: None given
|
||||
expires: '2019-10-10T16:23:38.993Z'
|
||||
patch: {}
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "current file",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"${relativeFile}"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
},
|
||||
{
|
||||
"name": "test.ts",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"test/test.ts"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
}
|
||||
]
|
||||
}
|
20
.vscode/settings.json
vendored
Normal file
20
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"json.schemas": [
|
||||
{
|
||||
"fileMatch": ["/npmextra.json"],
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"npmci": {
|
||||
"type": "object",
|
||||
"description": "settings for npmci"
|
||||
},
|
||||
"gitzone": {
|
||||
"type": "object",
|
||||
"description": "settings for gitzone"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
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
|
51
dist/smartscaf.classes.smartscaf.d.ts
vendored
51
dist/smartscaf.classes.smartscaf.d.ts
vendored
@ -1,51 +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[];
|
||||
defaultVariables: any;
|
||||
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 gets merged with this.suppliedVariables
|
||||
*/
|
||||
supplyVariables(variablesArg: any): Promise<void>;
|
||||
/**
|
||||
* Will ask for the missing variables by cli interaction
|
||||
*/
|
||||
askCliForMissingVariables(): Promise<void>;
|
||||
writeToDisk(destinationDirArg: any): Promise<void>;
|
||||
/**
|
||||
* finds all variables in a Template in as string
|
||||
* e.g. myobject.someKey and myobject.someOtherKey
|
||||
*/
|
||||
private _findVariablesInTemplate;
|
||||
/**
|
||||
* checks if supplied Variables satisfy the template
|
||||
*/
|
||||
private _checkSuppliedVariables;
|
||||
/**
|
||||
* checks the default.yml at the root of a template for default variables
|
||||
* allows 2 ways of notation in YAML:
|
||||
* >> myObject.myKey.someDeeperKey: someValue
|
||||
* >> myObject.yourKey.yourDeeperKey: yourValue
|
||||
* or
|
||||
* >> myObject:
|
||||
* >> - someKey:
|
||||
* >> - someDeeperKey: someValue
|
||||
* >> - yourKey:
|
||||
* >> - yourDeeperKey: yourValue
|
||||
*/
|
||||
private _checkDefaultVariables;
|
||||
}
|
150
dist/smartscaf.classes.smartscaf.js
vendored
150
dist/smartscaf.classes.smartscaf.js
vendored
@ -1,150 +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");
|
||||
const helpers = require("./smartscaf.helpers");
|
||||
class ScafTemplate {
|
||||
constructor() {
|
||||
this.suppliedVariables = {};
|
||||
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, '**/*');
|
||||
yield this._findVariablesInTemplate();
|
||||
yield this._checkSuppliedVariables();
|
||||
yield this._checkDefaultVariables();
|
||||
});
|
||||
}
|
||||
/**
|
||||
* supply the variables to render the teplate with
|
||||
* @param variablesArg gets merged with this.suppliedVariables
|
||||
*/
|
||||
supplyVariables(variablesArg) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
this.suppliedVariables = Object.assign({}, 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: (() => {
|
||||
if (this.defaultVariables && this.defaultVariables[missingVariable]) {
|
||||
return this.defaultVariables[missingVariable];
|
||||
}
|
||||
else {
|
||||
return 'undefined variable';
|
||||
}
|
||||
})(),
|
||||
message: `What is the value of ${missingVariable}?`
|
||||
}
|
||||
]);
|
||||
}
|
||||
let answerBucket = yield localSmartInteract.runQueue();
|
||||
answerBucket.answerMap.forEach((answer) => __awaiter(this, void 0, void 0, function* () {
|
||||
yield helpers.deepAddToObject(this.suppliedVariables, answer.name, answer.value);
|
||||
}));
|
||||
});
|
||||
}
|
||||
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
|
||||
* e.g. myobject.someKey and myobject.someOtherKey
|
||||
*/
|
||||
_findVariablesInTemplate() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let templateVariables = [];
|
||||
for (let templateSmartfile of this.templateSmartfileArray) {
|
||||
let localTemplateVariables = yield 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
|
||||
*/
|
||||
_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 = [
|
||||
...missingVars,
|
||||
...localMissingVars
|
||||
];
|
||||
}
|
||||
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
|
||||
* allows 2 ways of notation in YAML:
|
||||
* >> myObject.myKey.someDeeperKey: someValue
|
||||
* >> myObject.yourKey.yourDeeperKey: yourValue
|
||||
* or
|
||||
* >> myObject:
|
||||
* >> - someKey:
|
||||
* >> - someDeeperKey: someValue
|
||||
* >> - yourKey:
|
||||
* >> - yourDeeperKey: yourValue
|
||||
*/
|
||||
_checkDefaultVariables() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let defaultsSmartfile = this.templateSmartfileArray.filter(smartfileArg => {
|
||||
return smartfileArg.parsedPath.base === 'defaults.yml';
|
||||
})[0];
|
||||
if (defaultsSmartfile) {
|
||||
let defaultObject = yield plugins.smartyaml.yamlStringToObject(defaultsSmartfile.contents.toString());
|
||||
this.defaultVariables = defaultObject;
|
||||
}
|
||||
else {
|
||||
this.defaultVariables = {};
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.ScafTemplate = ScafTemplate;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLmNsYXNzZXMuc21hcnRzY2FmLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzY2FmLmNsYXNzZXMuc21hcnRzY2FmLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7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QUFDLFVBQVUsQ0FBQyxJQUFJLEtBQUssY0FBYyxDQUFDO1lBQ3pELENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBRU4sSUFBSSxpQkFBaUIsRUFBRTtnQkFDckIsSUFBSSxhQUFhLEdBQUcsTUFBTSxPQUFPLENBQUMsU0FBUyxDQUFDLGtCQUFrQixDQUM1RCxpQkFBaUIsQ0FBQyxRQUFRLENBQUMsUUFBUSxFQUFFLENBQ3RDLENBQUM7Z0JBQ0YsSUFBSSxDQUFDLGdCQUFnQixHQUFHLGFBQWEsQ0FBQzthQUN2QztpQkFBTTtnQkFDTCxJQUFJLENBQUMsZ0JBQWdCLEdBQUcsRUFBRSxDQUFDO2FBQzVCO1FBQ0gsQ0FBQztLQUFBO0NBQ0Y7QUEvSUQsb0NBK0lDIn0=
|
4
dist/smartscaf.helpers.d.ts
vendored
4
dist/smartscaf.helpers.d.ts
vendored
@ -1,4 +0,0 @@
|
||||
/**
|
||||
* adds a variable in string dot notation to an already more or less expanded object
|
||||
*/
|
||||
export declare let deepAddToObject: (objectArg: any, varStringArg: string, valueArg: string) => Promise<void>;
|
43
dist/smartscaf.helpers.js
vendored
43
dist/smartscaf.helpers.js
vendored
@ -1,43 +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 });
|
||||
/**
|
||||
* adds a variable in string dot notation to an already more or less expanded object
|
||||
*/
|
||||
exports.deepAddToObject = (objectArg, varStringArg, valueArg) => __awaiter(this, void 0, void 0, function* () {
|
||||
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 = (() => {
|
||||
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!');
|
||||
}
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLmhlbHBlcnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNjYWYuaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBRUE7O0dBRUc7QUFDUSxRQUFBLGVBQWUsR0FBRyxDQUFPLFNBQVMsRUFBRSxZQUFvQixFQUFFLFFBQWdCLEVBQUUsRUFBRTtJQUN2RixJQUFJLGFBQWEsR0FBRyxZQUFZLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFBO0lBQzNDLElBQUksZ0JBQWdCLEdBQUcsU0FBUyxDQUFBO0lBQ2hDLEtBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsS0FBSyxhQUFhLENBQUMsTUFBTSxFQUFFLENBQUMsRUFBRSxFQUFFO1FBQy9DLElBQUksT0FBTyxHQUFHLGFBQWEsQ0FBQyxDQUFDLENBQUMsQ0FBQTtRQUU5Qiw2QkFBNkI7UUFDN0IsSUFBSSxXQUFXLEdBQVcsQ0FBQyxHQUFHLEVBQUU7WUFDOUIsSUFBSSxhQUFhLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxFQUFFO2dCQUN4QixPQUFPLGFBQWEsQ0FBQyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUE7YUFDNUI7WUFDRCxPQUFPLElBQUksQ0FBQTtRQUNiLENBQUMsQ0FBQyxFQUFFLENBQUE7UUFFSixzQ0FBc0M7UUFDdEMsSUFBSSxDQUFDLGdCQUFnQixDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsV0FBVyxFQUFFO1lBQzlDLGdCQUFnQixDQUFDLE9BQU8sQ0FBQyxHQUFHLFFBQVEsQ0FBQTtZQUNwQyxnQkFBZ0IsR0FBRyxJQUFJLENBQUE7U0FDeEI7YUFBTSxJQUFJLENBQUMsZ0JBQWdCLENBQUMsT0FBTyxDQUFDLElBQUksV0FBVyxFQUFFO1lBQ3BELGdCQUFnQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsQ0FBQTtZQUM5QixnQkFBZ0IsR0FBRyxnQkFBZ0IsQ0FBQyxPQUFPLENBQUMsQ0FBQTtTQUM3QzthQUFNLElBQUksZ0JBQWdCLENBQUMsT0FBTyxDQUFDLElBQUksV0FBVyxFQUFFO1lBQ25ELGdCQUFnQixHQUFHLGdCQUFnQixDQUFDLE9BQU8sQ0FBQyxDQUFBO1NBQzdDO2FBQU07WUFDTCxNQUFNLElBQUksS0FBSyxDQUFDLHVCQUF1QixDQUFDLENBQUE7U0FDekM7S0FDRjtBQUNILENBQUMsQ0FBQSxDQUFBIn0=
|
8
dist/smartscaf.plugins.d.ts
vendored
8
dist/smartscaf.plugins.d.ts
vendored
@ -1,8 +0,0 @@
|
||||
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';
|
||||
export { path, smartfile, smartfm, smarthbs, smartinteract, smartq, smartyaml };
|
17
dist/smartscaf.plugins.js
vendored
17
dist/smartscaf.plugins.js
vendored
@ -1,17 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path = require("path");
|
||||
exports.path = path;
|
||||
const smartfile = require("smartfile");
|
||||
exports.smartfile = smartfile;
|
||||
const smartfm = require("smartfm");
|
||||
exports.smartfm = smartfm;
|
||||
const smarthbs = require("smarthbs");
|
||||
exports.smarthbs = smarthbs;
|
||||
const smartinteract = require("smartinteract");
|
||||
exports.smartinteract = smartinteract;
|
||||
const smartq = require("smartq");
|
||||
exports.smartq = smartq;
|
||||
const smartyaml = require("smartyaml");
|
||||
exports.smartyaml = smartyaml;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNjYWYucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDZCQUE0QjtBQVMxQixvQkFBSTtBQVJOLHVDQUFzQztBQVNwQyw4QkFBUztBQVJYLG1DQUFrQztBQVNoQywwQkFBTztBQVJULHFDQUFvQztBQVNsQyw0QkFBUTtBQVJWLCtDQUE4QztBQVM1QyxzQ0FBYTtBQVJmLGlDQUFnQztBQVM5Qix3QkFBTTtBQVJSLHVDQUFzQztBQVNwQyw4QkFBUyJ9
|
@ -1,33 +0,0 @@
|
||||
# smartscaf
|
||||
|
||||
scaffold projects quickly
|
||||
|
||||
## Availabililty
|
||||
|
||||
[](https://www.npmjs.com/package/smartscaf)
|
||||
[](https://GitLab.com/pushrocks/smartscaf)
|
||||
[](https://github.com/pushrocks/smartscaf)
|
||||
[](https://pushrocks.gitlab.io/smartscaf/)
|
||||
|
||||
## Status for master
|
||||
|
||||
[](https://GitLab.com/pushrocks/smartscaf/commits/master)
|
||||
[](https://GitLab.com/pushrocks/smartscaf/commits/master)
|
||||
[](https://www.npmjs.com/package/smartscaf)
|
||||
[](https://david-dm.org/pushrocks/smartscaf)
|
||||
[](https://www.bithound.io/github/pushrocks/smartscaf/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/smartscaf)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](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)
|
||||
|
||||
[](https://)
|
@ -5,5 +5,15 @@
|
||||
"npmci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"gitzone": {
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
"gitrepo": "smartscaf",
|
||||
"shortDescription": "scaffold projects quickly",
|
||||
"npmPackagename": "@pushrocks/smartscaf",
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
1541
package-lock.json
generated
1541
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
45
package.json
45
package.json
@ -1,14 +1,13 @@
|
||||
{
|
||||
"name": "@pushrocks/smartscaf",
|
||||
"version": "3.0.2",
|
||||
"version": "3.0.9",
|
||||
"private": false,
|
||||
"description": "scaffold projects quickly",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)",
|
||||
"testLocal": "(npmts --notest && ts-node --compilerOptions '{\"target\":\"es6\"}' test/test.ts)"
|
||||
"build": "(tsbuild)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -26,21 +25,33 @@
|
||||
"npm"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.6",
|
||||
"@gitzone/tsrun": "^1.1.17",
|
||||
"@gitzone/tstest": "^1.0.18",
|
||||
"@pushrocks/tapbundle": "^3.0.7",
|
||||
"@types/node": "^10.12.18"
|
||||
"@gitzone/tsbuild": "^2.1.17",
|
||||
"@gitzone/tsrun": "^1.2.8",
|
||||
"@gitzone/tstest": "^1.0.28",
|
||||
"@pushrocks/tapbundle": "^3.0.13",
|
||||
"@types/node": "^12.7.9",
|
||||
"tslint": "^5.20.0",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/lik": "^3.0.4",
|
||||
"@pushrocks/smartfile": "^6.0.12",
|
||||
"@pushrocks/smartfm": "^2.0.1",
|
||||
"@pushrocks/smarthbs": "^2.0.0",
|
||||
"@pushrocks/lik": "^3.0.11",
|
||||
"@pushrocks/smartfile": "^7.0.6",
|
||||
"@pushrocks/smartfm": "^2.0.4",
|
||||
"@pushrocks/smarthbs": "^2.0.8",
|
||||
"@pushrocks/smartinteract": "^2.0.4",
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@pushrocks/smartyaml": "^2.0.3",
|
||||
"@types/lodash": "^4.14.120",
|
||||
"lodash": "^4.17.11"
|
||||
}
|
||||
"@pushrocks/smartpromise": "^3.0.6",
|
||||
"@pushrocks/smartshell": "^2.0.25",
|
||||
"@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,25 +1,20 @@
|
||||
# smartscaf
|
||||
|
||||
# @pushrocks/smartscaf
|
||||
scaffold projects quickly
|
||||
|
||||
## Availabililty
|
||||
|
||||
[](https://www.npmjs.com/package/smartscaf)
|
||||
[](https://GitLab.com/pushrocks/smartscaf)
|
||||
[](https://github.com/pushrocks/smartscaf)
|
||||
[](https://pushrocks.gitlab.io/smartscaf/)
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartscaf)
|
||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartscaf)
|
||||
* [github.com (source mirror)](https://github.com/pushrocks/smartscaf)
|
||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartscaf/)
|
||||
|
||||
## Status for master
|
||||
|
||||
[](https://GitLab.com/pushrocks/smartscaf/commits/master)
|
||||
[](https://GitLab.com/pushrocks/smartscaf/commits/master)
|
||||
[](https://www.npmjs.com/package/smartscaf)
|
||||
[](https://david-dm.org/pushrocks/smartscaf)
|
||||
[](https://www.bithound.io/github/pushrocks/smartscaf/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/smartscaf)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
[](https://gitlab.com/pushrocks/smartscaf/commits/master)
|
||||
[](https://gitlab.com/pushrocks/smartscaf/commits/master)
|
||||
[](https://www.npmjs.com/package/@pushrocks/smartscaf)
|
||||
[](https://snyk.io/test/npm/@pushrocks/smartscaf)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://prettier.io/)
|
||||
|
||||
## Usage
|
||||
|
||||
@ -31,3 +26,10 @@ For further information read the linked docs at the top of this README.
|
||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
|
||||
[](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)
|
||||
|
@ -8,3 +8,6 @@ defaults:
|
||||
dependencies:
|
||||
merge:
|
||||
- ../test_template_2
|
||||
|
||||
runafter:
|
||||
- npm install
|
1
ts/interfaces/index.ts
Normal file
1
ts/interfaces/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './smartscaf';
|
7
ts/interfaces/smartscaf.ts
Normal file
7
ts/interfaces/smartscaf.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export interface ISmartscafFile {
|
||||
defaults: {[key:string]: string};
|
||||
dependencies: {
|
||||
merge: string[];
|
||||
};
|
||||
runafter: string[];
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import * as plugins from './smartscaf.plugins';
|
||||
import * as interfaces from './interfaces';
|
||||
import * as helpers from './smartscaf.helpers';
|
||||
|
||||
// interfaces
|
||||
@ -11,31 +12,37 @@ export interface ScafTemplateContructorOptions {
|
||||
}
|
||||
|
||||
export class ScafTemplate {
|
||||
static async createTemplateFromDir() {}
|
||||
public static async createTemplateFromDir() {}
|
||||
|
||||
/**
|
||||
* the name of the template
|
||||
*/
|
||||
name: string;
|
||||
public name: string;
|
||||
|
||||
/**
|
||||
* the descriptions of the template
|
||||
*/
|
||||
description: string;
|
||||
public description: string;
|
||||
|
||||
/**
|
||||
* the location on disk of the template
|
||||
*/
|
||||
dirPath: string;
|
||||
public dirPath: string;
|
||||
public destinationPath: string;
|
||||
|
||||
/**
|
||||
* smartscafFile
|
||||
*/
|
||||
public smartscafFile: interfaces.ISmartscafFile;
|
||||
|
||||
/**
|
||||
* the files of the template as array of Smartfiles
|
||||
*/
|
||||
templateSmartfileArray: Smartfile[];
|
||||
requiredVariables: string[];
|
||||
defaultVariables: any;
|
||||
suppliedVariables: any = {};
|
||||
missingVariables: string[] = [];
|
||||
public templateSmartfileArray: Smartfile[];
|
||||
public requiredVariables: string[];
|
||||
public defaultVariables: any;
|
||||
public suppliedVariables: any = {};
|
||||
public missingVariables: string[] = [];
|
||||
|
||||
constructor(dirPathArg: string) {
|
||||
this.dirPath = plugins.path.resolve(dirPathArg);
|
||||
@ -44,8 +51,30 @@ export class ScafTemplate {
|
||||
/**
|
||||
* read a template from a directory
|
||||
*/
|
||||
async readTemplateFromDir() {
|
||||
public async readTemplateFromDir() {
|
||||
this.templateSmartfileArray = await plugins.smartfile.fs.fileTreeToObject(this.dirPath, '**/*');
|
||||
|
||||
// read .smartscaf.yml file
|
||||
let smartscafFile: interfaces.ISmartscafFile = {
|
||||
defaults: {},
|
||||
dependencies: {
|
||||
merge: []
|
||||
},
|
||||
runafter: []
|
||||
};
|
||||
|
||||
const smartscafSmartfile = this.templateSmartfileArray.find(smartfileArg => {
|
||||
return smartfileArg.parsedPath.base === '.smartscaf.yml';
|
||||
});
|
||||
|
||||
if (smartscafSmartfile) {
|
||||
smartscafFile = {
|
||||
...smartscafFile,
|
||||
...await plugins.smartyaml.yamlStringToObject(smartscafSmartfile.contentBuffer.toString())
|
||||
};
|
||||
}
|
||||
this.smartscafFile = smartscafFile;
|
||||
|
||||
await this._resolveTemplateDependencies();
|
||||
await this._findVariablesInTemplate();
|
||||
await this._checkSuppliedVariables();
|
||||
@ -56,7 +85,7 @@ export class ScafTemplate {
|
||||
* supply the variables to render the teplate with
|
||||
* @param variablesArg gets merged with this.suppliedVariables
|
||||
*/
|
||||
async supplyVariables(variablesArg) {
|
||||
public async supplyVariables(variablesArg) {
|
||||
this.suppliedVariables = {
|
||||
...this.suppliedVariables,
|
||||
...variablesArg
|
||||
@ -67,10 +96,10 @@ export class ScafTemplate {
|
||||
/**
|
||||
* Will ask for the missing variables by cli interaction
|
||||
*/
|
||||
async askCliForMissingVariables() {
|
||||
public async askCliForMissingVariables() {
|
||||
this.missingVariables = await this._checkSuppliedVariables();
|
||||
let localSmartInteract = new plugins.smartinteract.SmartInteract();
|
||||
for (let missingVariable of this.missingVariables) {
|
||||
const localSmartInteract = new plugins.smartinteract.SmartInteract();
|
||||
for (const missingVariable of this.missingVariables) {
|
||||
localSmartInteract.addQuestions([
|
||||
{
|
||||
name: missingVariable,
|
||||
@ -86,7 +115,7 @@ export class ScafTemplate {
|
||||
}
|
||||
]);
|
||||
}
|
||||
let answerBucket = await localSmartInteract.runQueue();
|
||||
const answerBucket = await localSmartInteract.runQueue();
|
||||
await answerBucket.answerMap.forEach(async answer => {
|
||||
await helpers.deepAddToObject(this.suppliedVariables, answer.name, answer.value);
|
||||
});
|
||||
@ -96,23 +125,24 @@ export class ScafTemplate {
|
||||
* writes a file to disk
|
||||
* @param destinationDirArg
|
||||
*/
|
||||
async writeToDisk(destinationDirArg) {
|
||||
public async writeToDisk(destinationDirArg) {
|
||||
this.destinationPath = destinationDirArg;
|
||||
const smartfileArrayToWrite: Smartfile[] = [];
|
||||
for (let smartfile of this.templateSmartfileArray) {
|
||||
for (const 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);
|
||||
const template = await plugins.smarthbs.getTemplateForString(smartfile.contents.toString());
|
||||
const renderedTemplateString = template(this.suppliedVariables);
|
||||
|
||||
// handle frontmatter
|
||||
const smartfmInstance = new plugins.smartfm.Smartfm({
|
||||
fmType: 'yaml'
|
||||
});
|
||||
let parsedTemplate = smartfmInstance.parse(renderedTemplateString) as any;
|
||||
const parsedTemplate = smartfmInstance.parse(renderedTemplateString) as any;
|
||||
if (parsedTemplate.data.fileName) {
|
||||
smartfile.updateFileName(parsedTemplate.data.fileName);
|
||||
}
|
||||
@ -122,6 +152,7 @@ export class ScafTemplate {
|
||||
}
|
||||
|
||||
await plugins.smartfile.memory.smartfileArrayToFs(smartfileArrayToWrite, destinationDirArg);
|
||||
await this.runScripts();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -130,8 +161,8 @@ export class ScafTemplate {
|
||||
*/
|
||||
private async _findVariablesInTemplate() {
|
||||
let templateVariables: string[] = [];
|
||||
for (let templateSmartfile of this.templateSmartfileArray) {
|
||||
let localTemplateVariables = await plugins.smarthbs.findVarsInHbsString(
|
||||
for (const templateSmartfile of this.templateSmartfileArray) {
|
||||
const localTemplateVariables = await plugins.smarthbs.findVarsInHbsString(
|
||||
templateSmartfile.contents.toString()
|
||||
);
|
||||
templateVariables = [...templateVariables, ...localTemplateVariables];
|
||||
@ -146,8 +177,8 @@ export class ScafTemplate {
|
||||
*/
|
||||
private async _checkSuppliedVariables() {
|
||||
let missingVars: string[] = [];
|
||||
for (let templateSmartfile of this.templateSmartfileArray) {
|
||||
let localMissingVars = await plugins.smarthbs.checkVarsSatisfaction(
|
||||
for (const templateSmartfile of this.templateSmartfileArray) {
|
||||
const localMissingVars = await plugins.smarthbs.checkVarsSatisfaction(
|
||||
templateSmartfile.contents.toString(),
|
||||
this.suppliedVariables
|
||||
);
|
||||
@ -176,7 +207,7 @@ export class ScafTemplate {
|
||||
* >> - yourDeeperKey: yourValue
|
||||
*/
|
||||
private async _checkDefaultVariables() {
|
||||
let smartscafSmartfile = this.templateSmartfileArray.find(smartfileArg => {
|
||||
const smartscafSmartfile = this.templateSmartfileArray.find(smartfileArg => {
|
||||
return smartfileArg.parsedPath.base === '.smartscaf.yml';
|
||||
});
|
||||
|
||||
@ -199,23 +230,8 @@ export class ScafTemplate {
|
||||
* 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) {
|
||||
for (const dependency of this.smartscafFile.dependencies.merge) {
|
||||
console.log(`Now resolving ${dependency}`);
|
||||
const templatePathToMerge = plugins.path.join(this.dirPath, dependency);
|
||||
if (!plugins.smartfile.fs.isDirectory(templatePathToMerge)) {
|
||||
@ -231,4 +247,16 @@ export class ScafTemplate {
|
||||
this.templateSmartfileArray = this.templateSmartfileArray.concat(templateSmartfileArray);
|
||||
}
|
||||
}
|
||||
|
||||
private async runScripts () {
|
||||
if (!this.destinationPath) {
|
||||
throw new Error('cannot run scripts without an destinationdir');
|
||||
}
|
||||
const smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash'
|
||||
});
|
||||
for (const command of this.smartscafFile.runafter) {
|
||||
await smartshellInstance.exec(`cd ${this.destinationPath} && ${command}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,5 +6,6 @@ import * as smarthbs from '@pushrocks/smarthbs';
|
||||
import * as smartinteract from '@pushrocks/smartinteract';
|
||||
import * as smartq from '@pushrocks/smartpromise';
|
||||
import * as smartyaml from '@pushrocks/smartyaml';
|
||||
import * as smartshell from '@pushrocks/smartshell';
|
||||
|
||||
export { path, lik, smartfile, smartfm, smarthbs, smartinteract, smartq, smartyaml };
|
||||
export { path, lik, smartfile, smartfm, smarthbs, smartinteract, smartq, smartyaml, smartshell };
|
||||
|
Reference in New Issue
Block a user