Compare commits

..

45 Commits

Author SHA1 Message Date
c8eeb4b8e6 4.0.13 2023-06-25 13:48:54 +02:00
56df0d3246 fix(core): update 2023-06-25 13:48:54 +02:00
883ecff182 4.0.12 2023-06-25 13:39:43 +02:00
9589ad6146 fix(core): update 2023-06-25 13:39:42 +02:00
c2d4f9684c 4.0.11 2023-06-25 13:25:54 +02:00
d2b325889d fix(core): update 2023-06-25 13:25:53 +02:00
f6cd3c245b 4.0.10 2023-06-25 13:24:33 +02:00
1529ac12e4 fix(core): update 2023-06-25 13:24:32 +02:00
b4b5e52799 4.0.9 2023-06-25 12:45:44 +02:00
7de1cfbb6f fix(core): update 2023-06-25 12:45:44 +02:00
f426e110f0 4.0.8 2023-06-25 12:33:14 +02:00
02e9cdff98 fix(core): update 2023-06-25 12:33:13 +02:00
576ee88283 4.0.7 2023-06-25 12:27:17 +02:00
d1886a0966 fix(core): update 2023-06-25 12:27:17 +02:00
9f8b14c6fe 4.0.6 2023-06-25 12:26:39 +02:00
e64e610092 fix(core): update 2023-06-25 12:26:39 +02:00
86f19de7d8 4.0.5 2023-06-25 00:59:37 +02:00
1b6b45f15f fix(core): update 2023-06-25 00:59:36 +02:00
a8d2954689 4.0.4 2023-06-25 00:50:25 +02:00
6071ae5de3 fix(core): update 2023-06-25 00:50:25 +02:00
a664f3da76 4.0.3 2022-06-26 00:31:58 +02:00
5d3b4585b0 fix(core): update 2022-06-26 00:31:57 +02:00
11abf9aafd 4.0.2 2022-06-25 03:23:08 +02:00
1b86228bc4 fix(core): update 2022-06-25 03:23:08 +02:00
8a5097ba50 4.0.1 2022-06-25 03:19:43 +02:00
2dae7b1200 fix(core): update 2022-06-25 03:19:43 +02:00
909cceb1a5 4.0.0 2022-06-25 03:19:16 +02:00
5f1bc8dc29 BREAKING CHANGE(core): switch to esm 2022-06-25 03:19:16 +02:00
d33f943fc6 3.0.10 2020-01-31 14:51:06 +00:00
e4c2d86dbc fix(core): update 2020-01-31 14:51:05 +00:00
088bed779f 3.0.9 2019-10-11 21:56:11 +02:00
1cecba6f13 fix(core): update 2019-10-11 21:56:11 +02:00
324b93a419 3.0.8 2019-10-02 12:50:14 +02:00
4be3fc27b3 fix(core): update 2019-10-02 12:50:14 +02:00
655a8a72ff 3.0.7 2019-09-10 18:23:53 +02:00
80a77d5f06 fix(core): update 2019-09-10 18:23:53 +02:00
6296411b50 3.0.6 2019-09-10 18:18:30 +02:00
e7690d4020 fix(core): update 2019-09-10 18:18:30 +02:00
b85a29cfc1 3.0.5 2019-09-10 18:03:33 +02:00
d559b0f402 fix(core): update 2019-09-10 18:03:33 +02:00
7433c1dba4 3.0.4 2019-09-10 18:00:13 +02:00
c8f6b0296d update 2019-09-10 18:00:03 +02:00
0cffae9eaa update dependencies 2019-09-10 17:59:29 +02:00
d50c8a1260 3.0.3 2019-02-17 17:17:47 +01:00
b3702d56bc fix(core): update 2019-02-17 17:17:47 +01:00
32 changed files with 4993 additions and 2555 deletions

View File

@ -0,0 +1,111 @@
name: CI Pipeline
on: push
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm prepare
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
npmci command npm run buildDocs
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: public
path: public
retention-days: 7

19
.gitignore vendored
View File

@ -1,3 +1,20 @@
node_modules/ .nogit/
# artifacts
coverage/ coverage/
public/ public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,150 +0,0 @@
# gitzone standard
image: hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: "$CI_BUILD_STAGE"
stages:
- security
- test
- release
- metadata
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
tags:
- docker
- notpriv
snyk:
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
tags:
- docker
- notpriv
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:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
release:
stage: release
script:
- 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: metadata
script:
- npmci trigger
only:
- tags
tags:
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata
script:
- npmci command npm install -g typedoc typescript
- npmci npm prepare
- 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

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

1
dist/index.d.ts vendored
View File

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

7
dist/index.js vendored
View File

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

View File

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

View File

@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLmNsYXNzZXMuc21hcnRzY2FmLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzY2FmLmNsYXNzZXMuc21hcnRzY2FmLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUFBQSwrQ0FBK0M7QUFDL0MsK0NBQStDO0FBVy9DO0lBQUE7UUFNRSxzQkFBaUIsR0FBUSxFQUFFLENBQUM7UUFDNUIscUJBQWdCLEdBQWEsRUFBRSxDQUFDO0lBd0lsQyxDQUFDO0lBdElDOztPQUVHO0lBQ0csbUJBQW1CLENBQUMsVUFBa0I7O1lBQzFDLElBQUksT0FBTyxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDO1lBQy9DLElBQUksQ0FBQyxzQkFBc0IsR0FBRyxNQUFNLE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLGdCQUFnQixDQUFDLE9BQU8sRUFBRSxNQUFNLENBQUMsQ0FBQztZQUMzRixNQUFNLElBQUksQ0FBQyx3QkFBd0IsRUFBRSxDQUFDO1lBQ3RDLE1BQU0sSUFBSSxDQUFDLHVCQUF1QixFQUFFLENBQUM7WUFDckMsTUFBTSxJQUFJLENBQUMsc0JBQXNCLEVBQUUsQ0FBQztRQUN0QyxDQUFDO0tBQUE7SUFFRDs7O09BR0c7SUFDRyxlQUFlL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BQ3BCLENBQUM7YUFDSDtZQUNELFdBQVcsR0FBRyxXQUFXLENBQUMsTUFBTSxDQUFDLENBQUMsS0FBSyxFQUFFLEtBQUssRUFBRSxJQUFJLEVBQUUsRUFBRTtnQkFDdEQsT0FBTyxJQUFJLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxLQUFLLEtBQUssQ0FBQztZQUN2QyxDQUFDLENBQUMsQ0FBQztZQUNILE9BQU8sV0FBVyxDQUFDO1FBQ3JCLENBQUM7S0FBQTtJQUVEOzs7Ozs7Ozs7OztPQVdHO0lBQ1csc0JBQXNCOztZQUNsQyxJQUFJLGlCQUFpQixHQUFHLElBQUksQ0FBQyxzQkFBc0IsQ0FBQyxNQUFNLENBQUMsWUFBWSxDQUFDLEVBQUU7Z0JBQ3hFLE9BQU8sWUFBWSxDQUFDLFVBQVUsQ0FBQyxJQUFJLEtBQUssY0FBYyxDQUFDO1lBQ3pELENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBRU4sSUFBSSxpQkFBaUIsRUFBRTtnQkFDckIsSUFBSSxhQUFhLEdBQUcsTUFBTSxPQUFPLENBQUMsU0FBUyxDQUFDLGtCQUFrQixDQUM1RCxpQkFBaUIsQ0FBQyxRQUFRLENBQUMsUUFBUSxFQUFFLENBQ3RDLENBQUM7Z0JBQ0YsSUFBSSxDQUFDLGdCQUFnQixHQUFHLGFBQWEsQ0FBQzthQUN2QztpQkFBTTtnQkFDTCxJQUFJLENBQUMsZ0JBQWdCLEdBQUcsRUFBRSxDQUFDO2FBQzVCO1FBQ0gsQ0FBQztLQUFBO0NBQ0Y7QUEvSUQsb0NBK0lDIn0=

View File

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

View File

@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLmhlbHBlcnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNjYWYuaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBRUE7O0dBRUc7QUFDUSxRQUFBLGVBQWUsR0FBRyxDQUFPLFNBQVMsRUFBRSxZQUFvQixFQUFFLFFBQWdCLEVBQUUsRUFBRTtJQUN2RixJQUFJLGFBQWEsR0FBRyxZQUFZLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFBO0lBQzNDLElBQUksZ0JBQWdCLEdBQUcsU0FBUyxDQUFBO0lBQ2hDLEtBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQy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';
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 };

View File

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

View File

@ -1,33 +0,0 @@
# 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

@ -5,5 +5,16 @@
"npmci": { "npmci": {
"npmGlobalTools": [], "npmGlobalTools": [],
"npmAccessLevel": "public" "npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartscaf",
"description": "scaffold projects quickly",
"npmPackagename": "@pushrocks/smartscaf",
"license": "MIT"
}
} }
} }

1946
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,14 @@
{ {
"name": "@pushrocks/smartscaf", "name": "@pushrocks/smartscaf",
"version": "3.0.2", "version": "4.0.13",
"private": false, "private": false,
"description": "scaffold projects quickly", "description": "scaffold projects quickly",
"main": "dist/index.js", "main": "dist_ts/index.js",
"typings": "dist/index.d.ts", "typings": "dist_ts/index.d.ts",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(tstest test/)",
"build": "(tsbuild)", "build": "(tsbuild --web --allowimplicitany)",
"testLocal": "(npmts --notest && ts-node --compilerOptions '{\"target\":\"es6\"}' test/test.ts)" "buildDocs": "tsdoc"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -26,21 +26,37 @@
"npm" "npm"
], ],
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.6", "@gitzone/tsbuild": "^2.1.66",
"@gitzone/tsrun": "^1.1.17", "@gitzone/tsrun": "^1.2.42",
"@gitzone/tstest": "^1.0.18", "@gitzone/tstest": "^1.0.74",
"@pushrocks/tapbundle": "^3.0.7", "@pushrocks/tapbundle": "^5.0.8",
"@types/node": "^10.12.18" "@types/node": "^20.3.1"
}, },
"dependencies": { "dependencies": {
"@pushrocks/lik": "^3.0.4", "@pushrocks/lik": "^6.0.2",
"@pushrocks/smartfile": "^6.0.12", "@pushrocks/smartfile": "^10.0.17",
"@pushrocks/smartfm": "^2.0.1", "@pushrocks/smartfm": "^2.0.4",
"@pushrocks/smarthbs": "^2.0.0", "@pushrocks/smarthbs": "^3.0.3",
"@pushrocks/smartinteract": "^2.0.4", "@pushrocks/smartinteract": "^2.0.11",
"@pushrocks/smartpromise": "^2.0.5", "@pushrocks/smartparam": "^1.1.6",
"@pushrocks/smartyaml": "^2.0.3", "@pushrocks/smartpromise": "^4.0.2",
"@types/lodash": "^4.14.120", "@pushrocks/smartshell": "^3.0.3",
"lodash": "^4.17.11" "@pushrocks/smartyaml": "^2.0.5"
} },
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"type": "module",
"browserslist": [
"last 1 chrome versions"
]
} }

4616
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +1,26 @@
# smartscaf # @pushrocks/smartscaf
scaffold projects quickly scaffold projects quickly
## Availabililty ## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartscaf)
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartscaf) * [gitlab.com (source)](https://gitlab.com/pushrocks/smartscaf)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartscaf) * [github.com (source mirror)](https://github.com/pushrocks/smartscaf)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartscaf) * [docs (typedoc)](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) Status Category | Status Badge
[![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) GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartscaf/badges/master/pipeline.svg)](https://lossless.cloud)
[![Dependency Status](https://david-dm.org/pushrocks/smartscaf.svg)](https://david-dm.org/pushrocks/smartscaf) GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartscaf/badges/master/coverage.svg)](https://lossless.cloud)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartscaf/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartscaf/master/dependencies/npm) npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartscaf)](https://lossless.cloud)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartscaf/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartscaf) Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartscaf)](https://lossless.cloud)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/) TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/) node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/) Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartscaf)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartscaf)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartscaf)](https://lossless.cloud)
## Usage ## Usage
@ -31,3 +32,13 @@ 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) > | 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://)
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
For further information read the linked docs at the top of this readme.
## Legal
> MIT licensed | **&copy;** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)

View File

@ -1,7 +1,7 @@
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@pushrocks/tapbundle';
import * as path from 'path'; import * as path from 'path';
import * as smartscaf from '../ts/index'; import * as smartscaf from '../ts/index.js';
process.env.CI = 'true'; process.env.CI = 'true';
@ -9,12 +9,12 @@ let testScafTemplate: smartscaf.ScafTemplate;
tap.test('should create new Smartscaf instance', async () => { tap.test('should create new Smartscaf instance', async () => {
testScafTemplate = new smartscaf.ScafTemplate('./test/test_template'); testScafTemplate = new smartscaf.ScafTemplate('./test/test_template');
expect(testScafTemplate).to.be.instanceof(smartscaf.ScafTemplate); expect(testScafTemplate).toBeInstanceOf(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(); await testScafTemplate.readTemplateFromDir();
expect(testScafTemplate.templateSmartfileArray.length).to.equal(6); expect(testScafTemplate.templateSmartfileArray.length).toEqual(6);
}); });
tap.test('smartfile -> should accept variables', async () => { tap.test('smartfile -> should accept variables', async () => {

View File

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

View File

@ -8,3 +8,6 @@ defaults:
dependencies: dependencies:
merge: merge:
- ../test_template_2 - ../test_template_2
runafter:
- npm install

View File

@ -1,3 +1,6 @@
---
fileName: anothername.yml
---
# this is a {{templateObject.value1}} # this is a {{templateObject.value1}}
# this is a {{templateObject.value2}} # this is a {{templateObject.value2}}
# this is a {{templateVar3}} # this is a {{templateVar3}}

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@pushrocks/smartscaf',
version: '4.0.13',
description: 'scaffold projects quickly'
}

View File

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

1
ts/interfaces/index.ts Normal file
View File

@ -0,0 +1 @@
export * from './smartscaf.js';

View File

@ -0,0 +1,7 @@
export interface ISmartscafFile {
defaults: { [key: string]: string };
dependencies: {
merge: string[];
};
runafter: string[];
}

View File

@ -1,5 +1,5 @@
import * as plugins from './smartscaf.plugins'; import * as plugins from './smartscaf.plugins.js';
import * as helpers from './smartscaf.helpers'; import * as interfaces from './interfaces/index.js';
// interfaces // interfaces
import { Smartfile } from '@pushrocks/smartfile'; import { Smartfile } from '@pushrocks/smartfile';
@ -11,31 +11,39 @@ export interface ScafTemplateContructorOptions {
} }
export class ScafTemplate { export class ScafTemplate {
static async createTemplateFromDir() {} public static async createTemplateFromDir(dirPathArg: string) {
return new ScafTemplate(dirPathArg);
}
/** /**
* the name of the template * the name of the template
*/ */
name: string; public name: string;
/** /**
* the descriptions of the template * the descriptions of the template
*/ */
description: string; public description: string;
/** /**
* the location on disk of the template * 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 * the files of the template as array of Smartfiles
*/ */
templateSmartfileArray: Smartfile[]; public templateSmartfileArray: Smartfile[];
requiredVariables: string[]; public requiredVariables: string[];
defaultVariables: any; public defaultVariables: any;
suppliedVariables: any = {}; public suppliedVariables: any = {};
missingVariables: string[] = []; public missingVariables: string[] = [];
constructor(dirPathArg: string) { constructor(dirPathArg: string) {
this.dirPath = plugins.path.resolve(dirPathArg); this.dirPath = plugins.path.resolve(dirPathArg);
@ -44,8 +52,32 @@ export class ScafTemplate {
/** /**
* read a template from a directory * read a template from a directory
*/ */
async readTemplateFromDir() { public async readTemplateFromDir() {
this.templateSmartfileArray = await plugins.smartfile.fs.fileTreeToObject(this.dirPath, '**/*'); 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._resolveTemplateDependencies();
await this._findVariablesInTemplate(); await this._findVariablesInTemplate();
await this._checkSuppliedVariables(); await this._checkSuppliedVariables();
@ -56,10 +88,10 @@ export class ScafTemplate {
* 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) { public async supplyVariables(variablesArg) {
this.suppliedVariables = { this.suppliedVariables = {
...this.suppliedVariables, ...this.suppliedVariables,
...variablesArg ...variablesArg,
}; };
this.missingVariables = await this._checkSuppliedVariables(); this.missingVariables = await this._checkSuppliedVariables();
} }
@ -67,10 +99,10 @@ export class ScafTemplate {
/** /**
* Will ask for the missing variables by cli interaction * Will ask for the missing variables by cli interaction
*/ */
async askCliForMissingVariables() { public async askCliForMissingVariables() {
this.missingVariables = await this._checkSuppliedVariables(); this.missingVariables = await this._checkSuppliedVariables();
let localSmartInteract = new plugins.smartinteract.SmartInteract(); const localSmartInteract = new plugins.smartinteract.SmartInteract();
for (let missingVariable of this.missingVariables) { for (const missingVariable of this.missingVariables) {
localSmartInteract.addQuestions([ localSmartInteract.addQuestions([
{ {
name: missingVariable, name: missingVariable,
@ -82,46 +114,49 @@ export class ScafTemplate {
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(); const answerBucket = await localSmartInteract.runQueue();
await answerBucket.answerMap.forEach(async answer => { const answers = answerBucket.getAllAnswers();
await helpers.deepAddToObject(this.suppliedVariables, answer.name, answer.value); for (const answer of answers) {
}); await plugins.smartparam.smartAdd(this.suppliedVariables, answer.name, answer.value);
}
} }
/** /**
* writes a file to disk * writes a file to disk
* @param destinationDirArg * @param destinationDirArg
*/ */
async writeToDisk(destinationDirArg) { public async writeToDisk(destinationDirArg) {
this.destinationPath = destinationDirArg;
const smartfileArrayToWrite: Smartfile[] = []; const smartfileArrayToWrite: Smartfile[] = [];
for (let smartfile of this.templateSmartfileArray) { for (const smartfile of this.templateSmartfileArray) {
// lets filter out template files // lets filter out template files
if (smartfile.path === '.smartscaf.yml') { if (smartfile.path === '.smartscaf.yml') {
continue; continue;
} }
// render the template // render the template
let template = await plugins.smarthbs.getTemplateForString(smartfile.contents.toString()); const template = await plugins.smarthbs.getTemplateForString(smartfile.contents.toString());
let renderedTemplateString = template(this.suppliedVariables); const renderedTemplateString = template(this.suppliedVariables);
// handle frontmatter // handle frontmatter
const smartfmInstance = new plugins.smartfm.Smartfm({ const smartfmInstance = new plugins.smartfm.Smartfm({
fmType: 'yaml' fmType: 'yaml',
}); });
let parsedTemplate = smartfmInstance.parse(renderedTemplateString) as any; const parsedTemplate = smartfmInstance.parse(renderedTemplateString) as any;
if (parsedTemplate.data.fileName) { if (parsedTemplate.data.fileName) {
smartfile.updateFileName(parsedTemplate.data.fileName); smartfile.updateFileName(parsedTemplate.data.fileName);
} }
smartfile.contents = Buffer.from(parsedTemplate.content); smartfile.contents = Buffer.from(await plugins.smarthbs.postprocess(parsedTemplate.content));
smartfileArrayToWrite.push(smartfile); smartfileArrayToWrite.push(smartfile);
} }
await plugins.smartfile.memory.smartfileArrayToFs(smartfileArrayToWrite, destinationDirArg); await plugins.smartfile.memory.smartfileArrayToFs(smartfileArrayToWrite, destinationDirArg);
await this.runScripts();
} }
/** /**
@ -130,8 +165,8 @@ export class ScafTemplate {
*/ */
private async _findVariablesInTemplate() { private async _findVariablesInTemplate() {
let templateVariables: string[] = []; let templateVariables: string[] = [];
for (let templateSmartfile of this.templateSmartfileArray) { for (const templateSmartfile of this.templateSmartfileArray) {
let localTemplateVariables = await plugins.smarthbs.findVarsInHbsString( const localTemplateVariables = await plugins.smarthbs.findVarsInHbsString(
templateSmartfile.contents.toString() templateSmartfile.contents.toString()
); );
templateVariables = [...templateVariables, ...localTemplateVariables]; templateVariables = [...templateVariables, ...localTemplateVariables];
@ -146,8 +181,8 @@ export class ScafTemplate {
*/ */
private async _checkSuppliedVariables() { private async _checkSuppliedVariables() {
let missingVars: string[] = []; let missingVars: string[] = [];
for (let templateSmartfile of this.templateSmartfileArray) { for (const templateSmartfile of this.templateSmartfileArray) {
let localMissingVars = await plugins.smarthbs.checkVarsSatisfaction( const localMissingVars = await plugins.smarthbs.checkVarsSatisfaction(
templateSmartfile.contents.toString(), templateSmartfile.contents.toString(),
this.suppliedVariables this.suppliedVariables
); );
@ -176,7 +211,7 @@ export class ScafTemplate {
* >> - yourDeeperKey: yourValue * >> - yourDeeperKey: yourValue
*/ */
private async _checkDefaultVariables() { private async _checkDefaultVariables() {
let smartscafSmartfile = this.templateSmartfileArray.find(smartfileArg => { const smartscafSmartfile = this.templateSmartfileArray.find((smartfileArg) => {
return smartfileArg.parsedPath.base === '.smartscaf.yml'; return smartfileArg.parsedPath.base === '.smartscaf.yml';
}); });
@ -199,23 +234,8 @@ export class ScafTemplate {
* resolve template dependencies * resolve template dependencies
*/ */
private async _resolveTemplateDependencies() { 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!'); console.log('looking at templates to merge!');
const smartscafYamlObject = await plugins.smartyaml.yamlStringToObject( for (const dependency of this.smartscafFile.dependencies.merge) {
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}`); console.log(`Now resolving ${dependency}`);
const templatePathToMerge = plugins.path.join(this.dirPath, dependency); const templatePathToMerge = plugins.path.join(this.dirPath, dependency);
if (!plugins.smartfile.fs.isDirectory(templatePathToMerge)) { if (!plugins.smartfile.fs.isDirectory(templatePathToMerge)) {
@ -231,4 +251,16 @@ export class ScafTemplate {
this.templateSmartfileArray = this.templateSmartfileArray.concat(templateSmartfileArray); 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}`);
}
}
} }

View File

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

View File

@ -4,7 +4,20 @@ import * as smartfile from '@pushrocks/smartfile';
import * as smartfm from '@pushrocks/smartfm'; import * as smartfm from '@pushrocks/smartfm';
import * as smarthbs from '@pushrocks/smarthbs'; import * as smarthbs from '@pushrocks/smarthbs';
import * as smartinteract from '@pushrocks/smartinteract'; import * as smartinteract from '@pushrocks/smartinteract';
import * as smartq from '@pushrocks/smartpromise'; import * as smartparam from '@pushrocks/smartparam';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartyaml from '@pushrocks/smartyaml'; 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,
smartparam,
smartpromise,
smartyaml,
smartshell,
};

9
tsconfig.json Normal file
View File

@ -0,0 +1,9 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext"
}
}

View File

@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}