Compare commits

...

14 Commits

Author SHA1 Message Date
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
21 changed files with 4818 additions and 2167 deletions

View 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

4
.gitignore vendored
View File

@ -15,8 +15,6 @@ node_modules/
# builds # builds
dist/ dist/
dist_web/ dist_*/
dist_serve/
dist_ts_web/
# custom # custom

View File

@ -1,126 +0,0 @@
# gitzone ci_default
image: registry.gitlab.com/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:
- lossless
- docker
- notpriv
snyk:
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command snyk test
tags:
- lossless
- docker
- notpriv
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- docker
- priv
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- docker
- notpriv
release:
stage: release
script:
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
script:
- npmci command npm install -g tslint typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
stage: metadata
script:
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true

23
.snyk
View File

@ -1,23 +0,0 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.13.5
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
SNYK-JS-JSYAML-173999:
- '@pushrocks/smartfm > gray-matter > js-yaml':
reason: None given
expires: '2019-10-10T16:23:38.993Z'
- '@pushrocks/smartyaml > js-yaml':
reason: None given
expires: '2019-10-10T16:23:38.993Z'
SNYK-JS-JSYAML-174129:
- '@pushrocks/smartfm > gray-matter > js-yaml':
reason: None given
expires: '2019-10-10T16:23:38.993Z'
- '@pushrocks/smartyaml > js-yaml':
reason: None given
expires: '2019-10-10T16:23:38.993Z'
SNYK-JS-LODASH-450202:
- '@pushrocks/smartinteract > inquirer > lodash':
reason: None given
expires: '2019-10-10T16:23:38.993Z'
patch: {}

24
.vscode/launch.json vendored
View File

@ -2,28 +2,10 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "current file", "command": "npm test",
"type": "node", "name": "Run npm test",
"request": "launch", "request": "launch",
"args": [ "type": "node-terminal"
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
} }
] ]
} }

View File

@ -15,7 +15,7 @@
"properties": { "properties": {
"projectType": { "projectType": {
"type": "string", "type": "string",
"enum": ["website", "element", "service", "npm"] "enum": ["website", "element", "service", "npm", "wcc"]
} }
} }
} }

View File

@ -12,7 +12,7 @@
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "pushrocks", "gitscope": "pushrocks",
"gitrepo": "smartscaf", "gitrepo": "smartscaf",
"shortDescription": "scaffold projects quickly", "description": "scaffold projects quickly",
"npmPackagename": "@pushrocks/smartscaf", "npmPackagename": "@pushrocks/smartscaf",
"license": "MIT" "license": "MIT"
} }

1923
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,14 @@
{ {
"name": "@pushrocks/smartscaf", "name": "@pushrocks/smartscaf",
"version": "3.0.10", "version": "4.0.6",
"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)",
"buildDocs": "tsdoc"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -25,34 +26,37 @@
"npm" "npm"
], ],
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.17", "@gitzone/tsbuild": "^2.1.66",
"@gitzone/tsrun": "^1.2.8", "@gitzone/tsrun": "^1.2.42",
"@gitzone/tstest": "^1.0.28", "@gitzone/tstest": "^1.0.74",
"@pushrocks/tapbundle": "^3.2.0", "@pushrocks/tapbundle": "^5.0.8",
"@types/node": "^13.5.3", "@types/node": "^20.3.1"
"tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/lik": "^3.0.13", "@pushrocks/lik": "^6.0.2",
"@pushrocks/smartfile": "^7.0.6", "@pushrocks/smartfile": "^10.0.17",
"@pushrocks/smartfm": "^2.0.4", "@pushrocks/smartfm": "^2.0.4",
"@pushrocks/smarthbs": "^2.0.8", "@pushrocks/smarthbs": "^3.0.3",
"@pushrocks/smartinteract": "^2.0.4", "@pushrocks/smartinteract": "^2.0.11",
"@pushrocks/smartparam": "^1.1.3", "@pushrocks/smartparam": "^1.1.6",
"@pushrocks/smartpromise": "^3.0.6", "@pushrocks/smartpromise": "^4.0.2",
"@pushrocks/smartshell": "^2.0.25", "@pushrocks/smartshell": "^3.0.3",
"@pushrocks/smartyaml": "^2.0.3" "@pushrocks/smartyaml": "^2.0.5"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",
"ts_web/**/*", "ts_web/**/*",
"dist/**/*", "dist/**/*",
"dist_web/**/*", "dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*", "dist_ts_web/**/*",
"assets/**/*", "assets/**/*",
"cli.js", "cli.js",
"npmextra.json", "npmextra.json",
"readme.md" "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

@ -8,13 +8,19 @@ scaffold projects quickly
* [docs (typedoc)](https://pushrocks.gitlab.io/smartscaf/) * [docs (typedoc)](https://pushrocks.gitlab.io/smartscaf/)
## Status for master ## Status for master
[![pipeline status](https://gitlab.com/pushrocks/smartscaf/badges/master/pipeline.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) Status Category | Status Badge
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartscaf.svg)](https://www.npmjs.com/package/@pushrocks/smartscaf) -- | --
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartscaf/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartscaf) GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartscaf/badges/master/pipeline.svg)](https://lossless.cloud)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartscaf/badges/master/coverage.svg)](https://lossless.cloud)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartscaf)](https://lossless.cloud)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/) Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartscaf)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
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
@ -33,7 +39,6 @@ We are always happy for code contributions. If you are not the code contributing
For further information read the linked docs at the top of this readme. For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) ## 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) | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

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

@ -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.6',
description: 'scaffold projects quickly'
}

View File

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

View File

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

View File

@ -1,5 +1,5 @@
import * as plugins from './smartscaf.plugins'; import * as plugins from './smartscaf.plugins.js';
import * as interfaces from './interfaces'; import * as interfaces from './interfaces/index.js';
// interfaces // interfaces
import { Smartfile } from '@pushrocks/smartfile'; import { Smartfile } from '@pushrocks/smartfile';
@ -11,7 +11,9 @@ export interface ScafTemplateContructorOptions {
} }
export class ScafTemplate { export class ScafTemplate {
public static async createTemplateFromDir() {} public static async createTemplateFromDir(dirPathArg: string) {
return new ScafTemplate(dirPathArg);
}
/** /**
* the name of the template * the name of the template
@ -57,19 +59,21 @@ export class ScafTemplate {
let smartscafFile: interfaces.ISmartscafFile = { let smartscafFile: interfaces.ISmartscafFile = {
defaults: {}, defaults: {},
dependencies: { dependencies: {
merge: [] merge: [],
}, },
runafter: [] runafter: [],
}; };
const smartscafSmartfile = this.templateSmartfileArray.find(smartfileArg => { const smartscafSmartfile = this.templateSmartfileArray.find((smartfileArg) => {
return smartfileArg.parsedPath.base === '.smartscaf.yml'; return smartfileArg.parsedPath.base === '.smartscaf.yml';
}); });
if (smartscafSmartfile) { if (smartscafSmartfile) {
smartscafFile = { smartscafFile = {
...smartscafFile, ...smartscafFile,
...(await plugins.smartyaml.yamlStringToObject(smartscafSmartfile.contentBuffer.toString())) ...(await plugins.smartyaml.yamlStringToObject(
smartscafSmartfile.contentBuffer.toString()
)),
}; };
} }
this.smartscafFile = smartscafFile; this.smartscafFile = smartscafFile;
@ -87,7 +91,7 @@ export class ScafTemplate {
public 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();
} }
@ -110,14 +114,15 @@ export class ScafTemplate {
return 'undefined variable'; return 'undefined variable';
} }
})(), })(),
message: `What is the value of ${missingVariable}?` message: `What is the value of ${missingVariable}?`,
} },
]); ]);
} }
const answerBucket = await localSmartInteract.runQueue(); const answerBucket = await localSmartInteract.runQueue();
await answerBucket.answerMap.forEach(async answer => { const answers = answerBucket.getAllAnswers();
for (const answer of answers) {
await plugins.smartparam.smartAdd(this.suppliedVariables, answer.name, answer.value); await plugins.smartparam.smartAdd(this.suppliedVariables, answer.name, answer.value);
}); }
} }
/** /**
@ -139,14 +144,14 @@ export class ScafTemplate {
// handle frontmatter // handle frontmatter
const smartfmInstance = new plugins.smartfm.Smartfm({ const smartfmInstance = new plugins.smartfm.Smartfm({
fmType: 'yaml' fmType: 'yaml',
}); });
const 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);
} }
@ -206,7 +211,7 @@ export class ScafTemplate {
* >> - yourDeeperKey: yourValue * >> - yourDeeperKey: yourValue
*/ */
private async _checkDefaultVariables() { private async _checkDefaultVariables() {
const smartscafSmartfile = this.templateSmartfileArray.find(smartfileArg => { const smartscafSmartfile = this.templateSmartfileArray.find((smartfileArg) => {
return smartfileArg.parsedPath.base === '.smartscaf.yml'; return smartfileArg.parsedPath.base === '.smartscaf.yml';
}); });
@ -252,7 +257,7 @@ export class ScafTemplate {
throw new Error('cannot run scripts without an destinationdir'); throw new Error('cannot run scripts without an destinationdir');
} }
const smartshellInstance = new plugins.smartshell.Smartshell({ const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash' executor: 'bash',
}); });
for (const command of this.smartscafFile.runafter) { for (const command of this.smartscafFile.runafter) {
await smartshellInstance.exec(`cd ${this.destinationPath} && ${command}`); await smartshellInstance.exec(`cd ${this.destinationPath} && ${command}`);

View File

@ -19,5 +19,5 @@ export {
smartparam, smartparam,
smartpromise, smartpromise,
smartyaml, smartyaml,
smartshell 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"
}