Compare commits
41 Commits
Author | SHA1 | Date | |
---|---|---|---|
576ee88283 | |||
d1886a0966 | |||
9f8b14c6fe | |||
e64e610092 | |||
86f19de7d8 | |||
1b6b45f15f | |||
a8d2954689 | |||
6071ae5de3 | |||
a664f3da76 | |||
5d3b4585b0 | |||
11abf9aafd | |||
1b86228bc4 | |||
8a5097ba50 | |||
2dae7b1200 | |||
909cceb1a5 | |||
5f1bc8dc29 | |||
d33f943fc6 | |||
e4c2d86dbc | |||
088bed779f | |||
1cecba6f13 | |||
324b93a419 | |||
4be3fc27b3 | |||
655a8a72ff | |||
80a77d5f06 | |||
6296411b50 | |||
e7690d4020 | |||
b85a29cfc1 | |||
d559b0f402 | |||
7433c1dba4 | |||
c8f6b0296d | |||
0cffae9eaa | |||
d50c8a1260 | |||
b3702d56bc | |||
ff0faa719b | |||
400e228ffc | |||
25871fc970 | |||
eb990a8ec2 | |||
f5194b76bd | |||
6b5e9ac617 | |||
60854250eb | |||
53de92ac1a |
107
.gitea/workflows/gitzone_ci_default.yaml
Normal file
107
.gitea/workflows/gitzone_ci_default.yaml
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
name: CI Pipeline
|
||||||
|
|
||||||
|
on: push
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
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
19
.gitignore
vendored
@ -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
|
142
.gitlab-ci.yml
142
.gitlab-ci.yml
@ -1,142 +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 command npm install -g snyk
|
|
||||||
- npmci command npm install --ignore-scripts
|
|
||||||
- npmci command snyk test
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# test stage
|
|
||||||
# ====================
|
|
||||||
testLEGACY:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci node install legacy
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
testLTS:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- 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 install
|
|
||||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
paths:
|
|
||||||
- public
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
windowsCompatibility:
|
|
||||||
image: stefanscherer/node-windows:10-build-tools
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npm install & npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- windows
|
|
||||||
allow_failure: true
|
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal 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
26
.vscode/settings.json
vendored
Normal 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
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLmNsYXNzZXMuc21hcnRzY2FmLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzY2FmLmNsYXNzZXMuc21hcnRzY2FmLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUFBQSwrQ0FBK0M7QUFDL0MsK0NBQStDO0FBVy9DO0lBQUE7UUFNRSxzQkFBaUIsR0FBUSxFQUFFLENBQUM7UUFDNUIscUJBQWdCLEdBQWEsRUFBRSxDQUFDO0lBd0lsQyxDQUFDO0lBdElDOztPQUVHO0lBQ0csbUJBQW1CLENBQUMsVUFBa0I7O1lBQzFDLElBQUksT0FBTyxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDO1lBQy9DLElBQUksQ0FBQyxzQkFBc0IsR0FBRyxNQUFNLE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLGdCQUFnQixDQUFDLE9BQU8sRUFBRSxNQUFNLENBQUMsQ0FBQztZQUMzRixNQUFNLElBQUksQ0FBQyx3QkFBd0IsRUFBRSxDQUFDO1lBQ3RDLE1BQU0sSUFBSSxDQUFDLHVCQUF1QixFQUFFLENBQUM7WUFDckMsTUFBTSxJQUFJLENBQUMsc0JBQXNCLEVBQUUsQ0FBQztRQUN0QyxDQUFDO0tBQUE7SUFFRDs7O09BR0c7SUFDRyxlQUFlLENBQUMsWUFBWTs7WUFDaEMsSUFBSSxDQUFDLGlCQUFpQixxQkFDakIsSUFBSSxDQ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FDLENBQUMsS0FBSyxFQUFFLEtBQUssRUFBRSxJQUFJLEVBQUUsRUFBRTtnQkFDdEQsT0FBTyxJQUFJLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxLQUFLLEtBQUssQ0FBQztZQUN2QyxDQUFDLENBQUMsQ0FBQztZQUNILE9BQU8sV0FBVyxDQUFDO1FBQ3JCLENBQUM7S0FBQTtJQUVEOzs7Ozs7Ozs7OztPQVdHO0lBQ1csc0JBQXNCOztZQUNsQyxJQUFJLGlCQUFpQixHQUFHLElBQUksQ0FBQyxzQkFBc0IsQ0FBQyxNQUFNLENBQUMsWUFBWSxDQUFDLEVBQUU7Z0JBQ3hFLE9BQU8sWUFBWSxDQUFDLFVBQVUsQ0FBQyxJQUFJLEtBQUssY0FBYyxDQUFDO1lBQ3pELENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBRU4sSUFBSSxpQkFBaUIsRUFBRTtnQkFDckIsSUFBSSxhQUFhLEdBQUcsTUFBTSxPQUFPLENBQUMsU0FBUyxDQUFDLGtCQUFrQixDQUM1RCxpQkFBaUIsQ0FBQyxRQUFRLENBQUMsUUFBUSxFQUFFLENBQ3RDLENBQUM7Z0JBQ0YsSUFBSSxDQUFDLGdCQUFnQixHQUFHLGFBQWEsQ0FBQzthQUN2QztpQkFBTTtnQkFDTCxJQUFJLENBQUMsZ0JBQWdCLEdBQUcsRUFBRSxDQUFDO2FBQzVCO1FBQ0gsQ0FBQztLQUFBO0NBQ0Y7QUEvSUQsb0NBK0lDIn0=
|
|
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,eyJ2ZXJzaW9uIj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xDQUFDLElBQUksV0FBVyxFQUFFO1lBQ3BELGdCQUFnQixDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsQ0FBQTtZQUM5QixnQkFBZ0IsR0FBRyxnQkFBZ0IsQ0FBQyxPQUFPLENBQUMsQ0FBQTtTQUM3QzthQUFNLElBQUksZ0JBQWdCLENBQUMsT0FBTyxDQUFDLElBQUksV0FBVyxFQUFFO1lBQ25ELGdCQUFnQixHQUFHLGdCQUFnQixDQUFDLE9BQU8sQ0FBQyxDQUFBO1NBQzdDO2FBQU07WUFDTCxNQUFNLElBQUksS0FBSyxDQUFDLHVCQUF1QixDQUFDLENBQUE7U0FDekM7S0FDRjtBQUNILENBQUMsQ0FBQSxDQUFBIn0=
|
|
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,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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
1475
package-lock.json
generated
1475
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
56
package.json
56
package.json
@ -1,14 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartscaf",
|
"name": "@pushrocks/smartscaf",
|
||||||
"version": "2.0.2",
|
"version": "4.0.7",
|
||||||
"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.0.22",
|
"@gitzone/tsbuild": "^2.1.66",
|
||||||
"@gitzone/tsrun": "^1.1.12",
|
"@gitzone/tsrun": "^1.2.42",
|
||||||
"@gitzone/tstest": "^1.0.15",
|
"@gitzone/tstest": "^1.0.74",
|
||||||
"@pushrocks/tapbundle": "^3.0.5",
|
"@pushrocks/tapbundle": "^5.0.8",
|
||||||
"@types/node": "^10.9.2"
|
"@types/node": "^20.3.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/lik": "^3.0.1",
|
"@pushrocks/lik": "^6.0.2",
|
||||||
"@pushrocks/smartfile": "^6.0.8",
|
"@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.72",
|
"@pushrocks/smartshell": "^3.0.3",
|
||||||
"lodash": "^4.17.4"
|
"@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
4616
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
45
readme.md
45
readme.md
@ -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)
|
||||||
[](https://www.npmjs.com/package/smartscaf)
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartscaf)
|
||||||
[](https://GitLab.com/pushrocks/smartscaf)
|
* [github.com (source mirror)](https://github.com/pushrocks/smartscaf)
|
||||||
[](https://github.com/pushrocks/smartscaf)
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartscaf/)
|
||||||
[](https://pushrocks.gitlab.io/smartscaf/)
|
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
|
|
||||||
[](https://GitLab.com/pushrocks/smartscaf/commits/master)
|
Status Category | Status Badge
|
||||||
[](https://GitLab.com/pushrocks/smartscaf/commits/master)
|
-- | --
|
||||||
[](https://www.npmjs.com/package/smartscaf)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
[](https://david-dm.org/pushrocks/smartscaf)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
[](https://www.bithound.io/github/pushrocks/smartscaf/master/dependencies/npm)
|
npm | [](https://lossless.cloud)
|
||||||
[](https://www.bithound.io/github/pushrocks/smartscaf)
|
Snyk | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[](http://standardjs.com/)
|
Code Style | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
|
BundlePhobia (total size when bundled) | [](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)
|
||||||
|
|
||||||
[](https://)
|
[](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 | **©** [Task Venture Capital GmbH](https://task.vc)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
12
test/test.ts
12
test/test.ts
@ -1,20 +1,20 @@
|
|||||||
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';
|
||||||
|
|
||||||
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).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('./test/test_template');
|
await testScafTemplate.readTemplateFromDir();
|
||||||
expect(testScafTemplate.templateSmartfileArray.length).to.equal(5);
|
expect(testScafTemplate.templateSmartfileArray.length).toEqual(6);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('smartfile -> should accept variables', async () => {
|
tap.test('smartfile -> should accept variables', async () => {
|
||||||
|
3
test/test_output/anothername.yml
Normal file
3
test/test_output/anothername.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# this is a wow
|
||||||
|
# this is a here
|
||||||
|
# this is a undefined variable
|
@ -1,4 +0,0 @@
|
|||||||
templateVar1: from default yaml
|
|
||||||
templateVar2: this is another value from yml
|
|
||||||
templateObject.value1: wow
|
|
||||||
templateObject.value2: here
|
|
1
test/test_output/hello.md
Normal file
1
test/test_output/hello.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# param1 10
|
13
test/test_template/.smartscaf.yml
Normal file
13
test/test_template/.smartscaf.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
runafter:
|
||||||
|
- npm install
|
@ -1,4 +0,0 @@
|
|||||||
templateVar1: from default yaml
|
|
||||||
templateVar2: this is another value from yml
|
|
||||||
templateObject.value1: wow
|
|
||||||
templateObject.value2: here
|
|
@ -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}}
|
||||||
|
1
test/test_template_2/hello.md
Normal file
1
test/test_template_2/hello.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# param1 {{node_version}}
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@pushrocks/smartscaf',
|
||||||
|
version: '4.0.7',
|
||||||
|
description: 'scaffold projects quickly'
|
||||||
|
}
|
@ -1 +1 @@
|
|||||||
export * from './smartscaf.classes.smartscaf';
|
export * from './smartscaf.classes.smartscaf.js';
|
||||||
|
1
ts/interfaces/index.ts
Normal file
1
ts/interfaces/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './smartscaf.js';
|
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,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,36 +11,87 @@ export interface ScafTemplateContructorOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class ScafTemplate {
|
export class ScafTemplate {
|
||||||
name: string;
|
public static async createTemplateFromDir(dirPathArg: string) {
|
||||||
description: string;
|
return new ScafTemplate(dirPathArg);
|
||||||
templateSmartfileArray: Smartfile[];
|
}
|
||||||
requiredVariables: string[];
|
|
||||||
defaultVariables: any;
|
|
||||||
suppliedVariables: any = {};
|
|
||||||
missingVariables: string[] = [];
|
|
||||||
|
|
||||||
dependencies: ScafTemplate[];
|
/**
|
||||||
|
* the name of the template
|
||||||
|
*/
|
||||||
|
public name: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the descriptions of the template
|
||||||
|
*/
|
||||||
|
public description: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the location on disk of the template
|
||||||
|
*/
|
||||||
|
public dirPath: string;
|
||||||
|
public destinationPath: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* smartscafFile
|
||||||
|
*/
|
||||||
|
public smartscafFile: interfaces.ISmartscafFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the files of the template as array of Smartfiles
|
||||||
|
*/
|
||||||
|
public templateSmartfileArray: Smartfile[];
|
||||||
|
public requiredVariables: string[];
|
||||||
|
public defaultVariables: any;
|
||||||
|
public suppliedVariables: any = {};
|
||||||
|
public 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) {
|
public 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, '**/*');
|
|
||||||
|
// 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._findVariablesInTemplate();
|
||||||
await this._checkSuppliedVariables();
|
await this._checkSuppliedVariables();
|
||||||
await this._checkDefaultVariables();
|
await this._checkDefaultVariables();
|
||||||
await this._resolveTemplateDependencies();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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();
|
||||||
}
|
}
|
||||||
@ -48,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,
|
||||||
@ -63,36 +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();
|
||||||
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
|
||||||
|
* @param destinationDirArg
|
||||||
|
*/
|
||||||
|
public async writeToDisk(destinationDirArg) {
|
||||||
|
this.destinationPath = destinationDirArg;
|
||||||
|
const smartfileArrayToWrite: Smartfile[] = [];
|
||||||
|
for (const smartfile of this.templateSmartfileArray) {
|
||||||
|
// lets filter out template files
|
||||||
|
if (smartfile.path === '.smartscaf.yml') {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
async writeToDisk(destinationDirArg) {
|
|
||||||
let smartfileArrayToWrite = this.templateSmartfileArray;
|
|
||||||
for (let smartfile of smartfileArrayToWrite) {
|
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
await plugins.smartfile.memory.smartfileArrayToFs(smartfileArrayToWrite, destinationDirArg);
|
await plugins.smartfile.memory.smartfileArrayToFs(smartfileArrayToWrite, destinationDirArg);
|
||||||
|
await this.runScripts();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,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];
|
||||||
@ -117,13 +181,17 @@ 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
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// combine with other missingVars
|
||||||
missingVars = [...missingVars, ...localMissingVars];
|
missingVars = [...missingVars, ...localMissingVars];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// dedupe
|
||||||
missingVars = missingVars.filter((value, index, self) => {
|
missingVars = missingVars.filter((value, index, self) => {
|
||||||
return self.indexOf(value) === index;
|
return self.indexOf(value) === index;
|
||||||
});
|
});
|
||||||
@ -131,7 +199,7 @@ export class ScafTemplate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
@ -143,16 +211,21 @@ export class ScafTemplate {
|
|||||||
* >> - yourDeeperKey: yourValue
|
* >> - yourDeeperKey: yourValue
|
||||||
*/
|
*/
|
||||||
private async _checkDefaultVariables() {
|
private async _checkDefaultVariables() {
|
||||||
let defaultsSmartfile = this.templateSmartfileArray.filter(smartfileArg => {
|
const 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()
|
||||||
);
|
);
|
||||||
|
const defaultObject = smartscafObject.defaults;
|
||||||
this.defaultVariables = defaultObject;
|
this.defaultVariables = defaultObject;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
// safeguard against non existent defaults
|
||||||
|
if (!this.defaultVariables) {
|
||||||
|
console.log('this template does not specify defaults');
|
||||||
this.defaultVariables = {};
|
this.defaultVariables = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,14 +234,33 @@ export class ScafTemplate {
|
|||||||
* resolve template dependencies
|
* resolve template dependencies
|
||||||
*/
|
*/
|
||||||
private async _resolveTemplateDependencies() {
|
private async _resolveTemplateDependencies() {
|
||||||
const dependencies = this.templateSmartfileArray.find(smartfileArg => {
|
console.log('looking at templates to merge!');
|
||||||
return smartfileArg.parsedPath.base === "dependencies.yml"
|
for (const dependency of this.smartscafFile.dependencies.merge) {
|
||||||
});
|
console.log(`Now resolving ${dependency}`);
|
||||||
if(!dependencies) {
|
const templatePathToMerge = plugins.path.join(this.dirPath, dependency);
|
||||||
console.log('No further template dependencies defined!');
|
if (!plugins.smartfile.fs.isDirectory(templatePathToMerge)) {
|
||||||
return;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
console.log('Found template dependencies! Resolving them now!')
|
|
||||||
|
|
||||||
|
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}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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!');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
@ -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
9
tsconfig.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "ES2022",
|
||||||
|
"moduleResolution": "nodenext"
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "tslint-config-standard"
|
|
||||||
}
|
|
Reference in New Issue
Block a user