Compare commits
63 Commits
Author | SHA1 | Date | |
---|---|---|---|
30ad1d2b65 | |||
99e2d08a83 | |||
27ef8f28a0 | |||
3138ec130d | |||
7449d5e316 | |||
c4505a9a57 | |||
c8c4c8c18a | |||
297e44a5e3 | |||
757bf763df | |||
4c158ba0ea | |||
831ab25a6f | |||
8fb95634df | |||
c8eeb4b8e6 | |||
56df0d3246 | |||
883ecff182 | |||
9589ad6146 | |||
c2d4f9684c | |||
d2b325889d | |||
f6cd3c245b | |||
1529ac12e4 | |||
b4b5e52799 | |||
7de1cfbb6f | |||
f426e110f0 | |||
02e9cdff98 | |||
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 |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@ -0,0 +1,66 @@
|
||||
name: Default (not tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags-ignore:
|
||||
- '**'
|
||||
|
||||
env:
|
||||
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||
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
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@ -0,0 +1,124 @@
|
||||
name: Default (tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
env:
|
||||
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||
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: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
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: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- 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: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- 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: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Code quality
|
||||
run: |
|
||||
npmci command npm install -g typescript
|
||||
npmci npm install
|
||||
|
||||
- name: Trigger
|
||||
run: npmci trigger
|
||||
|
||||
- name: Build docs and upload artifacts
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
pnpm install -g @git.zone/tsdoc
|
||||
npmci command tsdoc
|
||||
continue-on-error: true
|
19
.gitignore
vendored
19
.gitignore
vendored
@ -1,3 +1,20 @@
|
||||
node_modules/
|
||||
.nogit/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
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"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
237
changelog.md
Normal file
237
changelog.md
Normal file
@ -0,0 +1,237 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-04-15 - 4.0.16 - fix(dependencies)
|
||||
Update dependency references and bump version numbers; adjust workflow and template commands
|
||||
|
||||
- Bump versions for devDependencies (@git.zone/tsbuild, @git.zone/tsrun, @git.zone/tstest, @push.rocks/tapbundle, and @types/node) and dependencies (@push.rocks/lik, @push.rocks/smartfile, @push.rocks/smartfm, @push.rocks/smarthbs, @push.rocks/smartinteract, @push.rocks/smartobject, @push.rocks/smartpromise, @push.rocks/smartshell, and @push.rocks/smartyaml)
|
||||
- Replace smartparam with smartobject in both plugins and core modules
|
||||
- Fix workflow install command by renaming '@gitzone/tsdoc' to '@git.zone/tsdoc'
|
||||
- Update template runafter command from 'npm install' to 'echo "runafter"'
|
||||
|
||||
## 2024-05-29 - 4.0.15 - configuration updates
|
||||
Updates to the project’s configuration files, description and build settings.
|
||||
|
||||
- Updated description.
|
||||
- Updated tsconfig (applied in multiple commits).
|
||||
- Updated npmextra.json (githost).
|
||||
|
||||
## 2023-08-18 - 4.0.14 - core
|
||||
Improved core functionality.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2023-07-25 - 4.0.13 - core & organization
|
||||
Enhancements in core behavior and organizational structure.
|
||||
|
||||
- Fixed core update.
|
||||
- Switched to new organization scheme.
|
||||
|
||||
## 2023-06-25 - 4.0.12 - core
|
||||
Core improvements.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2023-06-25 - 4.0.11 - core
|
||||
Core improvements.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2023-06-25 - 4.0.10 - core
|
||||
Core improvements.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2023-06-25 - 4.0.9 - core
|
||||
Core improvements.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2023-06-25 - 4.0.8 - core
|
||||
Core improvements.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2023-06-25 - 4.0.7 - core
|
||||
Core improvements.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2023-06-25 - 4.0.6 - core
|
||||
Core improvements.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2023-06-25 - 4.0.5 - core
|
||||
Core improvements.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2023-06-24 - 4.0.4 - core
|
||||
Core improvements.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2023-06-24 - 4.0.3 - core
|
||||
Core improvements.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2022-06-25 - 4.0.2 - core
|
||||
Core improvements.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2022-06-25 - 4.0.1 - core
|
||||
Core improvements.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2022-06-25 - 4.0.0 - core
|
||||
Core improvements.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2022-06-25 - 3.0.10 - core (breaking)
|
||||
A breaking change was introduced affecting the module format.
|
||||
|
||||
- BREAKING CHANGE (core): switched to ESM.
|
||||
|
||||
## 2020-01-31 - 3.0.9 - core
|
||||
Routine core update.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2019-10-11 - 3.0.8 - core
|
||||
Routine core update.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2019-10-02 - 3.0.7 - core
|
||||
Routine core update.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2019-09-10 - 3.0.6 - core
|
||||
Routine core update.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2019-09-10 - 3.0.5 - core
|
||||
Routine core update.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2019-09-10 - 3.0.4 - core
|
||||
Routine core update.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2019-09-10 - 3.0.3 - general updates
|
||||
Updates to project dependencies and general code improvements.
|
||||
|
||||
- Performed update.
|
||||
- Updated dependencies.
|
||||
|
||||
## 2019-02-17 - 3.0.2 - core
|
||||
Routine core update.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2019-01-27 - 3.0.1 - core
|
||||
Routine core update.
|
||||
|
||||
- Fixed core update.
|
||||
|
||||
## 2018-10-04 - 3.0.0 - core
|
||||
Changes from merging and core improvements.
|
||||
|
||||
- Fixed core update.
|
||||
- Merged master branch changes and performed additional updates.
|
||||
|
||||
## 2018-08-30 - 2.0.2 - structure (breaking)
|
||||
A breaking change in the project’s structure.
|
||||
|
||||
- BREAKING CHANGE (structure): templates now take their path within the constructor.
|
||||
|
||||
## 2018-08-27 - 2.0.1 - minor
|
||||
Versions in this range involved only version bump commits with no significant changes.
|
||||
|
||||
- No significant changes.
|
||||
|
||||
## 2017-08-09 - 1.0.14 - scope (breaking)
|
||||
A breaking change in the package scope was applied.
|
||||
|
||||
- BREAKING CHANGE (scope): switched to new @pushrocks scope.
|
||||
|
||||
## 2017-08-09 - 1.0.13 - core
|
||||
Improvements to variable handling.
|
||||
|
||||
- Fixed variable distribution.
|
||||
|
||||
## 2017-07-28 - 1.0.12 - dependencies
|
||||
Dependency updates.
|
||||
|
||||
- Updated dependencies.
|
||||
|
||||
## 2017-06-01 - 1.0.11 - dependencies
|
||||
Dependency updates.
|
||||
|
||||
- Updated dependencies.
|
||||
|
||||
## 2017-06-01 - 1.0.10 - CLI improvements
|
||||
Enhanced CLI error prevention.
|
||||
|
||||
- Prevented error due to empty defaults.yml.
|
||||
|
||||
## 2017-05-27 - 1.0.9 - dependencies
|
||||
Dependency updates.
|
||||
|
||||
- Updated dependencies.
|
||||
|
||||
## 2017-05-27 - 1.0.8 - templating
|
||||
Improved file templating support.
|
||||
|
||||
- Added support for frontmatter for advanced file templating.
|
||||
|
||||
## 2017-05-27 - 1.0.7 - documentation
|
||||
Documentation improvements.
|
||||
|
||||
- Added docs.
|
||||
|
||||
## 2017-05-27 - 1.0.6 - fixes
|
||||
Minor fixes.
|
||||
|
||||
- Fixed deep add.
|
||||
|
||||
## 2017-05-26 - 1.0.5 - smartfile updates
|
||||
Smartfile updates.
|
||||
|
||||
- Updated smartfile.
|
||||
|
||||
## 2017-05-26 - 1.0.4 - tests
|
||||
Test fixes.
|
||||
|
||||
- Fixed tests.
|
||||
|
||||
## 2017-05-26 - 1.0.3 - smartfile updates
|
||||
Smartfile updates.
|
||||
|
||||
- Updated smartfile.
|
||||
|
||||
## 2017-05-25 - 1.0.2 - functionality
|
||||
Minor functionality improvements.
|
||||
|
||||
- Ensured proper functionality.
|
||||
|
||||
## 2017-05-25 - 1.0.1 - core
|
||||
Core fixes.
|
||||
|
||||
- Fixed working issues.
|
||||
|
||||
## 2017-05-06 - 1.0.0 - initial release and CLI integration
|
||||
The initial release introducing CLI support and project setup.
|
||||
|
||||
- Added CLI to prompt for missing variables.
|
||||
- Started CLI integration.
|
||||
- Added readme and CI tslint configuration.
|
||||
- Performed initial setup and various update tasks.
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLmNsYXNzZXMuc21hcnRzY2FmLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21h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FBQyxzQkFBc0IsQ0FBQyxNQUFNLENBQUMsWUFBWSxDQUFDLEVBQUU7Z0JBQ3hFLE9BQU8sWUFBWSxDQUFDLFVBQVUsQ0FBQyxJQUFJLEtBQUssY0FBYyxDQUFDO1lBQ3pELENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBRU4sSUFBSSxpQkFBaUIsRUFBRTtnQkFDckIsSUFBSSxhQUFhLEdBQUcsTUFBTSxPQUFPLENBQUMsU0FBUyxDQUFDLGtCQUFrQixDQUM1RCxpQkFBaUIsQ0FBQyxRQUFRLENBQUMsUUFBUSxFQUFFLENBQ3RDLENBQUM7Z0JBQ0YsSUFBSSxDQUFDLGdCQUFnQixHQUFHLGFBQWEsQ0FBQzthQUN2QztpQkFBTTtnQkFDTCxJQUFJLENBQUMsZ0JBQWdCLEdBQUcsRUFBRSxDQUFDO2FBQzVCO1FBQ0gsQ0FBQztLQUFBO0NBQ0Y7QUEvSUQsb0NBK0lDIn0=
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLmhlbHBlcnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNjYWYuaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBRUE7O0dBRUc7QUFDUSxRQUFBLGVBQWUsR0FBRyxDQUFPLFNBQVMsRUFBRSxZQUFvQixFQUFFLFFBQWdCLEVBQUUsRUFBRTtJQUN2RixJQUFJLGFBQWEsR0FBRyxZQUFZLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxDQUFBO0lBQzNDLElBQUksZ0JBQWdCLEdBQUcsU0FBUyxDQUFBO0lBQ2hDLEtBQUssSUFBSSxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsS0FBSyxhQ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ored
@ -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,29 @@
|
||||
"npmci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "smartscaf",
|
||||
"description": "A project aimed at quickly scaffolding projects with support for TypeScript, smart file handling, and template rendering.",
|
||||
"npmPackagename": "@push.rocks/smartscaf",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"typescript",
|
||||
"scaffolding",
|
||||
"template rendering",
|
||||
"file handling",
|
||||
"project setup",
|
||||
"smart interaction",
|
||||
"yaml",
|
||||
"cli tool"
|
||||
]
|
||||
}
|
||||
},
|
||||
"tsdoc": {
|
||||
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||
}
|
||||
}
|
1475
package-lock.json
generated
1475
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
76
package.json
76
package.json
@ -1,46 +1,68 @@
|
||||
{
|
||||
"name": "@pushrocks/smartscaf",
|
||||
"version": "3.0.0",
|
||||
"name": "@push.rocks/smartscaf",
|
||||
"version": "4.0.16",
|
||||
"private": false,
|
||||
"description": "scaffold projects quickly",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"description": "A project aimed at quickly scaffolding projects with support for TypeScript, smart file handling, and template rendering.",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)",
|
||||
"testLocal": "(npmts --notest && ts-node --compilerOptions '{\"target\":\"es6\"}' test/test.ts)"
|
||||
"build": "(tsbuild --web --allowimplicitany)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@gitlab.com/pushrocks/smartscaf.git"
|
||||
"url": "https://code.foss.global/push.rocks/smartscaf.git"
|
||||
},
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://gitlab.com/pushrocks/smartscaf/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/smartscaf#README",
|
||||
"homepage": "https://code.foss.global/push.rocks/smartscaf",
|
||||
"keywords": [
|
||||
"scaffold",
|
||||
"polymer",
|
||||
"npm"
|
||||
"typescript",
|
||||
"scaffolding",
|
||||
"template rendering",
|
||||
"file handling",
|
||||
"project setup",
|
||||
"smart interaction",
|
||||
"yaml",
|
||||
"cli tool"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.0.22",
|
||||
"@gitzone/tsrun": "^1.1.12",
|
||||
"@gitzone/tstest": "^1.0.15",
|
||||
"@pushrocks/tapbundle": "^3.0.5",
|
||||
"@types/node": "^10.9.2"
|
||||
"@git.zone/tsbuild": "^2.3.2",
|
||||
"@git.zone/tsrun": "^1.3.3",
|
||||
"@git.zone/tstest": "^1.0.96",
|
||||
"@push.rocks/tapbundle": "^5.6.3",
|
||||
"@types/node": "^22.14.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/lik": "^3.0.1",
|
||||
"@pushrocks/smartfile": "^6.0.8",
|
||||
"@pushrocks/smartfm": "^2.0.1",
|
||||
"@pushrocks/smarthbs": "^2.0.0",
|
||||
"@pushrocks/smartinteract": "^2.0.4",
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@pushrocks/smartyaml": "^2.0.3",
|
||||
"@types/lodash": "^4.14.72",
|
||||
"lodash": "^4.17.4"
|
||||
}
|
||||
"@push.rocks/lik": "^6.1.0",
|
||||
"@push.rocks/smartfile": "^11.2.0",
|
||||
"@push.rocks/smartfm": "^2.2.2",
|
||||
"@push.rocks/smarthbs": "^3.0.3",
|
||||
"@push.rocks/smartinteract": "^2.0.16",
|
||||
"@push.rocks/smartobject": "^1.0.12",
|
||||
"@push.rocks/smartpromise": "^4.2.3",
|
||||
"@push.rocks/smartshell": "^3.2.3",
|
||||
"@push.rocks/smartyaml": "^3.0.4"
|
||||
},
|
||||
"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"
|
||||
],
|
||||
"packageManager": "pnpm@10.7.0+sha512.6b865ad4b62a1d9842b61d674a393903b871d9244954f652b8842c2b553c72176b278f64c463e52d40fff8aba385c235c8c9ecf5cc7de4fd78b8bb6d49633ab6"
|
||||
}
|
||||
|
10262
pnpm-lock.yaml
generated
Normal file
10262
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
||||
|
112
readme.md
112
readme.md
@ -1,33 +1,97 @@
|
||||
# smartscaf
|
||||
|
||||
# @push.rocks/smartscaf
|
||||
scaffold projects quickly
|
||||
|
||||
## Availabililty
|
||||
## Install
|
||||
To install `@push.rocks/smartscaf`, run the following command in your project directory:
|
||||
|
||||
[](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/)
|
||||
```bash
|
||||
npm install @push.rocks/smartscaf --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
Smartscaf provides a streamlined approach to quickly scaffold projects with predefined templates. It leverages modern TypeScript and ESM syntax to offer a flexible and powerful toolchain for project initialization. This guide will walk you through utilizing Smartscaf to its full potential, including setting up templates, customizing scaffolding processes, and programmatically controlling scaffolding operations.
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
### Setting Up Your First Template
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
A Smartscaf template is essentially a directory with a set of files that you want to reuse across projects. It can include source code files, configuration files, and a special `.smartscaf.yml` file for defining template variables and dependencies.
|
||||
|
||||
[](https://)
|
||||
1. **Create a Template Directory**: This directory should contain all the files and folders representing your template.
|
||||
|
||||
2. **Define Template Variables in `.smartscaf.yml`**: This YAML file contains metadata about your template, such as default values for variables, dependency templates to merge, and scripts to run after scaffolding. Here's a basic example:
|
||||
|
||||
```yml
|
||||
defaults:
|
||||
projectName: "My Awesome Project"
|
||||
dependencies:
|
||||
merge: []
|
||||
runafter:
|
||||
- "npm install"
|
||||
```
|
||||
|
||||
3. **Utilize Handlebars Syntax for Dynamic Content**: Files in your template can use the Handlebars syntax (`{{variableName}}`) for dynamic content that will be replaced during the scaffolding process.
|
||||
|
||||
### Scaffolding a New Project
|
||||
|
||||
Once you have a template ready, you can scaffold a new project by programmatically creating and manipulating a `ScafTemplate` instance from Smartscaf.
|
||||
|
||||
1. **Import Smartscaf and Create a New Instance**:
|
||||
|
||||
```typescript
|
||||
import { ScafTemplate } from '@push.rocks/smartscaf';
|
||||
|
||||
async function scaffoldProject() {
|
||||
const myTemplate = await ScafTemplate.createTemplateFromDir('<path-to-your-template>');
|
||||
await myTemplate.readTemplateFromDir(); // Load the template
|
||||
// Supply any additional variables or override defaults
|
||||
await myTemplate.supplyVariables({
|
||||
projectName: 'My New Project'
|
||||
});
|
||||
// Optionally, interactively ask for missing variables
|
||||
// await myTemplate.askCliForMissingVariables();
|
||||
await myTemplate.writeToDisk('<destination-path>'); // Scaffold!
|
||||
}
|
||||
|
||||
scaffoldProject().then(() => console.log('Project scaffolded successfully!'));
|
||||
```
|
||||
|
||||
2. **Customizing the Scaffolding Process**: You can customize the scaffolding process by defining additional logic to manipulate files, directories, or template variables before writing to disk.
|
||||
|
||||
### Advanced Features
|
||||
|
||||
- **Merging Templates**: Smartscaf allows you to compose complex templates by specifying dependencies in the `.smartscaf.yml` file. This enables you to merge multiple templates into one scaffolded project.
|
||||
|
||||
- **Running Scripts After Scaffolding**: Specify an array of shell commands in the `runafter` section of your `.smartscaf.yml` to be executed after the project is scaffolded. This is useful for running installations or initial builds.
|
||||
|
||||
- **Programmatic API**: Smartscaf's flexible API allows for programmatically controlling every aspect of the scaffolding process, making it suitable for integrating into build tools, command line utilities, or CI/CD pipelines.
|
||||
|
||||
### Complete Feature Set and Use Cases
|
||||
|
||||
The usage scenarios outlined above merely scratch the surface of what Smartscaf can do. With its comprehensive API, you can manage complex scaffolding tasks, including but not limited to:
|
||||
|
||||
- Creating project templates with varying levels of complexity and customization.
|
||||
- Dynamically adjusting project structures based on user input or external parameters.
|
||||
- Integrating scaffolding steps into larger automation workflows, significantly reducing manual setup time for new projects.
|
||||
|
||||
In conclusion, Smartscaf empowers developers to streamline their project initialization process, ensuring consistency, reducing boilerplate, and allowing more time to be spent on development rather than setup. Its flexibility and broad feature set make it a valuable tool in a modern developer's toolkit.
|
||||
|
||||
For further information and a deeper dive into Smartscaf's capabilities, please refer to the [official documentation](https://gitlab.com/push.rocks/smartscaf#README) and explore the [source code](https://gitlab.com/push.rocks/smartscaf) for advanced use cases and customization options.
|
||||
|
||||
## License and Legal Information
|
||||
|
||||
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||
|
||||
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||
|
||||
### Trademarks
|
||||
|
||||
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||
|
||||
### Company Information
|
||||
|
||||
Task Venture Capital GmbH
|
||||
Registered at District court Bremen HRB 35230 HB, Germany
|
||||
|
||||
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||
|
||||
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||
|
10
test/test.ts
10
test/test.ts
@ -1,20 +1,20 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
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;
|
||||
|
||||
tap.test('should create new Smartscaf instance', async () => {
|
||||
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 () => {
|
||||
await testScafTemplate.readTemplateFromDir();
|
||||
expect(testScafTemplate.templateSmartfileArray.length).to.equal(5);
|
||||
expect(testScafTemplate.templateSmartfileArray.length).toEqual(6);
|
||||
});
|
||||
|
||||
tap.test('smartfile -> should accept variables', async () => {
|
||||
|
@ -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:
|
||||
- echo 'runafter'
|
@ -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.value2}}
|
||||
# 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 @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartscaf',
|
||||
version: '4.0.16',
|
||||
description: 'A project aimed at quickly scaffolding projects with support for TypeScript, smart file handling, and template rendering.'
|
||||
}
|
@ -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,8 +1,5 @@
|
||||
import * as plugins from './smartscaf.plugins';
|
||||
import * as helpers from './smartscaf.helpers';
|
||||
|
||||
// interfaces
|
||||
import { Smartfile } from '@pushrocks/smartfile';
|
||||
import * as plugins from './smartscaf.plugins.js';
|
||||
import * as interfaces from './interfaces/index.js';
|
||||
|
||||
export interface ScafTemplateContructorOptions {
|
||||
name?: string;
|
||||
@ -11,18 +8,39 @@ export interface ScafTemplateContructorOptions {
|
||||
}
|
||||
|
||||
export class ScafTemplate {
|
||||
static async createTemplateFromDir() {
|
||||
|
||||
public static async createTemplateFromDir(dirPathArg: string) {
|
||||
return new ScafTemplate(dirPathArg);
|
||||
}
|
||||
|
||||
name: string;
|
||||
description: string;
|
||||
dirPath: string;
|
||||
templateSmartfileArray: Smartfile[];
|
||||
requiredVariables: string[];
|
||||
defaultVariables: any;
|
||||
suppliedVariables: any = {};
|
||||
missingVariables: string[] = [];
|
||||
/**
|
||||
* 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: plugins.smartfile.SmartFile[];
|
||||
public requiredVariables: string[];
|
||||
public defaultVariables: any;
|
||||
public suppliedVariables: any = {};
|
||||
public missingVariables: string[] = [];
|
||||
|
||||
constructor(dirPathArg: string) {
|
||||
this.dirPath = plugins.path.resolve(dirPathArg);
|
||||
@ -31,8 +49,32 @@ export class ScafTemplate {
|
||||
/**
|
||||
* read a template from a directory
|
||||
*/
|
||||
async readTemplateFromDir() {
|
||||
public async readTemplateFromDir() {
|
||||
this.templateSmartfileArray = await plugins.smartfile.fs.fileTreeToObject(this.dirPath, '**/*');
|
||||
|
||||
// read .smartscaf.yml file
|
||||
let smartscafFile: interfaces.ISmartscafFile = {
|
||||
defaults: {},
|
||||
dependencies: {
|
||||
merge: [],
|
||||
},
|
||||
runafter: [],
|
||||
};
|
||||
|
||||
const smartscafSmartfile = this.templateSmartfileArray.find((smartfileArg) => {
|
||||
return smartfileArg.parsedPath.base === '.smartscaf.yml';
|
||||
});
|
||||
|
||||
if (smartscafSmartfile) {
|
||||
smartscafFile = {
|
||||
...smartscafFile,
|
||||
...(await plugins.smartyaml.yamlStringToObject(
|
||||
smartscafSmartfile.contentBuffer.toString()
|
||||
)),
|
||||
};
|
||||
}
|
||||
this.smartscafFile = smartscafFile;
|
||||
|
||||
await this._resolveTemplateDependencies();
|
||||
await this._findVariablesInTemplate();
|
||||
await this._checkSuppliedVariables();
|
||||
@ -43,10 +85,10 @@ export class ScafTemplate {
|
||||
* supply the variables to render the teplate with
|
||||
* @param variablesArg gets merged with this.suppliedVariables
|
||||
*/
|
||||
async supplyVariables(variablesArg) {
|
||||
public async supplyVariables(variablesArg) {
|
||||
this.suppliedVariables = {
|
||||
...this.suppliedVariables,
|
||||
...variablesArg
|
||||
...variablesArg,
|
||||
};
|
||||
this.missingVariables = await this._checkSuppliedVariables();
|
||||
}
|
||||
@ -54,10 +96,10 @@ export class ScafTemplate {
|
||||
/**
|
||||
* Will ask for the missing variables by cli interaction
|
||||
*/
|
||||
async askCliForMissingVariables() {
|
||||
public async askCliForMissingVariables() {
|
||||
this.missingVariables = await this._checkSuppliedVariables();
|
||||
let localSmartInteract = new plugins.smartinteract.SmartInteract();
|
||||
for (let missingVariable of this.missingVariables) {
|
||||
const localSmartInteract = new plugins.smartinteract.SmartInteract();
|
||||
for (const missingVariable of this.missingVariables) {
|
||||
localSmartInteract.addQuestions([
|
||||
{
|
||||
name: missingVariable,
|
||||
@ -69,36 +111,49 @@ export class ScafTemplate {
|
||||
return 'undefined variable';
|
||||
}
|
||||
})(),
|
||||
message: `What is the value of ${missingVariable}?`
|
||||
}
|
||||
message: `What is the value of ${missingVariable}?`,
|
||||
},
|
||||
]);
|
||||
}
|
||||
let answerBucket = await localSmartInteract.runQueue();
|
||||
answerBucket.answerMap.forEach(async answer => {
|
||||
await helpers.deepAddToObject(this.suppliedVariables, answer.name, answer.value);
|
||||
});
|
||||
const answerBucket = await localSmartInteract.runQueue();
|
||||
const answers = answerBucket.getAllAnswers();
|
||||
for (const answer of answers) {
|
||||
await plugins.smartobject.smartAdd(this.suppliedVariables, answer.name, answer.value);
|
||||
}
|
||||
}
|
||||
|
||||
async writeToDisk(destinationDirArg) {
|
||||
let smartfileArrayToWrite = this.templateSmartfileArray;
|
||||
for (let smartfile of smartfileArrayToWrite) {
|
||||
/**
|
||||
* writes a file to disk
|
||||
* @param destinationDirArg
|
||||
*/
|
||||
public async writeToDisk(destinationDirArg) {
|
||||
this.destinationPath = destinationDirArg;
|
||||
const smartfileArrayToWrite: plugins.smartfile.SmartFile[] = [];
|
||||
for (const smartfile of this.templateSmartfileArray) {
|
||||
// lets filter out template files
|
||||
if (smartfile.path === '.smartscaf.yml') {
|
||||
continue;
|
||||
}
|
||||
|
||||
// render the template
|
||||
let template = await plugins.smarthbs.getTemplateForString(smartfile.contents.toString());
|
||||
let renderedTemplateString = template(this.suppliedVariables);
|
||||
const template = await plugins.smarthbs.getTemplateForString(smartfile.contents.toString());
|
||||
const renderedTemplateString = template(this.suppliedVariables);
|
||||
|
||||
// handle frontmatter
|
||||
const smartfmInstance = new plugins.smartfm.Smartfm({
|
||||
fmType: "yaml"
|
||||
fmType: 'yaml',
|
||||
});
|
||||
let parsedTemplate = smartfmInstance.parse(renderedTemplateString) as any;
|
||||
const parsedTemplate = smartfmInstance.parse(renderedTemplateString) as any;
|
||||
if (parsedTemplate.data.fileName) {
|
||||
smartfile.updateFileName(parsedTemplate.data.fileName);
|
||||
}
|
||||
|
||||
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 this.runScripts();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,8 +162,8 @@ export class ScafTemplate {
|
||||
*/
|
||||
private async _findVariablesInTemplate() {
|
||||
let templateVariables: string[] = [];
|
||||
for (let templateSmartfile of this.templateSmartfileArray) {
|
||||
let localTemplateVariables = await plugins.smarthbs.findVarsInHbsString(
|
||||
for (const templateSmartfile of this.templateSmartfileArray) {
|
||||
const localTemplateVariables = await plugins.smarthbs.findVarsInHbsString(
|
||||
templateSmartfile.contents.toString()
|
||||
);
|
||||
templateVariables = [...templateVariables, ...localTemplateVariables];
|
||||
@ -123,13 +178,17 @@ export class ScafTemplate {
|
||||
*/
|
||||
private async _checkSuppliedVariables() {
|
||||
let missingVars: string[] = [];
|
||||
for (let templateSmartfile of this.templateSmartfileArray) {
|
||||
let localMissingVars = await plugins.smarthbs.checkVarsSatisfaction(
|
||||
for (const templateSmartfile of this.templateSmartfileArray) {
|
||||
const localMissingVars = await plugins.smarthbs.checkVarsSatisfaction(
|
||||
templateSmartfile.contents.toString(),
|
||||
this.suppliedVariables
|
||||
);
|
||||
|
||||
// combine with other missingVars
|
||||
missingVars = [...missingVars, ...localMissingVars];
|
||||
}
|
||||
|
||||
// dedupe
|
||||
missingVars = missingVars.filter((value, index, self) => {
|
||||
return self.indexOf(value) === index;
|
||||
});
|
||||
@ -137,7 +196,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:
|
||||
* >> myObject.myKey.someDeeperKey: someValue
|
||||
* >> myObject.yourKey.yourDeeperKey: yourValue
|
||||
@ -149,16 +208,21 @@ export class ScafTemplate {
|
||||
* >> - yourDeeperKey: yourValue
|
||||
*/
|
||||
private async _checkDefaultVariables() {
|
||||
let defaultsSmartfile = this.templateSmartfileArray.filter(smartfileArg => {
|
||||
return smartfileArg.parsedPath.base === 'defaults.yml';
|
||||
})[0];
|
||||
const smartscafSmartfile = this.templateSmartfileArray.find((smartfileArg) => {
|
||||
return smartfileArg.parsedPath.base === '.smartscaf.yml';
|
||||
});
|
||||
|
||||
if (defaultsSmartfile) {
|
||||
let defaultObject = await plugins.smartyaml.yamlStringToObject(
|
||||
defaultsSmartfile.contents.toString()
|
||||
if (smartscafSmartfile) {
|
||||
const smartscafObject = await plugins.smartyaml.yamlStringToObject(
|
||||
smartscafSmartfile.contents.toString()
|
||||
);
|
||||
const defaultObject = smartscafObject.defaults;
|
||||
this.defaultVariables = defaultObject;
|
||||
} else {
|
||||
}
|
||||
|
||||
// safeguard against non existent defaults
|
||||
if (!this.defaultVariables) {
|
||||
console.log('this template does not specify defaults');
|
||||
this.defaultVariables = {};
|
||||
}
|
||||
}
|
||||
@ -167,20 +231,33 @@ export class ScafTemplate {
|
||||
* resolve template dependencies
|
||||
*/
|
||||
private async _resolveTemplateDependencies() {
|
||||
const dependenciesSmartfile = this.templateSmartfileArray.find(smartfileArg => {
|
||||
return smartfileArg.parsedPath.base === "dependencies.yml"
|
||||
});
|
||||
if(!dependenciesSmartfile) {
|
||||
console.log('No further template dependencies defined!');
|
||||
return;
|
||||
}
|
||||
console.log('Found template dependencies! Resolving them now!');
|
||||
console.log('looking at templates to merge!')
|
||||
const dependencies = await plugins.smartyaml.yamlStringToObject(dependenciesSmartfile.contentBuffer.toString());
|
||||
for (const dependency of dependencies.merge) {
|
||||
console.log('looking at templates to merge!');
|
||||
for (const dependency of this.smartscafFile.dependencies.merge) {
|
||||
console.log(`Now resolving ${dependency}`);
|
||||
const templatePathToMerge = plugins.path.join(this.dirPath, dependency);
|
||||
const templateSmartfileArray = await plugins.smartfile.fs.fileTreeToObject(templatePathToMerge, '**/*');
|
||||
this.templateSmartfileArray.concat(templateSmartfileArray);
|
||||
if (!plugins.smartfile.fs.isDirectory(templatePathToMerge)) {
|
||||
console.log(
|
||||
`dependency ${dependency} resolves to ${templatePathToMerge} which ist NOT a directory`
|
||||
);
|
||||
continue;
|
||||
}
|
||||
const templateSmartfileArray = await plugins.smartfile.fs.fileTreeToObject(
|
||||
templatePathToMerge,
|
||||
'**/*'
|
||||
);
|
||||
this.templateSmartfileArray = this.templateSmartfileArray.concat(templateSmartfileArray);
|
||||
}
|
||||
}
|
||||
|
||||
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!');
|
||||
}
|
||||
}
|
||||
};
|
@ -1,10 +1,23 @@
|
||||
import * as path from 'path';
|
||||
import * as lik from '@pushrocks/lik';
|
||||
import * as smartfile from '@pushrocks/smartfile';
|
||||
import * as smartfm from '@pushrocks/smartfm';
|
||||
import * as smarthbs from '@pushrocks/smarthbs';
|
||||
import * as smartinteract from '@pushrocks/smartinteract';
|
||||
import * as smartq from '@pushrocks/smartpromise';
|
||||
import * as smartyaml from '@pushrocks/smartyaml';
|
||||
import * as lik from '@push.rocks/lik';
|
||||
import * as smartfile from '@push.rocks/smartfile';
|
||||
import * as smartfm from '@push.rocks/smartfm';
|
||||
import * as smarthbs from '@push.rocks/smarthbs';
|
||||
import * as smartinteract from '@push.rocks/smartinteract';
|
||||
import * as smartobject from '@push.rocks/smartobject';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
import * as smartyaml from '@push.rocks/smartyaml';
|
||||
import * as smartshell from '@push.rocks/smartshell';
|
||||
|
||||
export { path, lik, smartfile, smartfm, smarthbs, smartinteract, smartq, smartyaml };
|
||||
export {
|
||||
path,
|
||||
lik,
|
||||
smartfile,
|
||||
smartfm,
|
||||
smarthbs,
|
||||
smartinteract,
|
||||
smartobject,
|
||||
smartpromise,
|
||||
smartyaml,
|
||||
smartshell,
|
||||
};
|
||||
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"extends": "tslint-config-standard"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user