Compare commits
80 Commits
Author | SHA1 | Date | |
---|---|---|---|
9e88f62e7e | |||
78bbbb2060 | |||
b262106bd7 | |||
abc7cbc5ea | |||
b2ba770b78 | |||
23e4ff62a3 | |||
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 | |||
60854250eb | |||
53de92ac1a | |||
6cb4fff0a5 | |||
45710ded00 | |||
aa87ed9427 | |||
f3594447ac | |||
a3f18c17ed | |||
c5ec7e9c24 | |||
98875a2ece | |||
5b42cf93cb | |||
e0ab34c466 |
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: code.foss.global/host.today/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{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 @ship.zone/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: code.foss.global/host.today/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{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 @ship.zone/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 @ship.zone/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 @ship.zone/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 @ship.zone/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
|
22
.gitignore
vendored
22
.gitignore
vendored
@@ -1,3 +1,23 @@
|
|||||||
node_modules/
|
.nogit/
|
||||||
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
# AI
|
||||||
|
.claude/
|
||||||
|
.serena/
|
||||||
|
|
||||||
|
#------# custom
|
@@ -1,71 +0,0 @@
|
|||||||
# gitzone standard
|
|
||||||
image: hosttoday/ht-docker-node:npmci
|
|
||||||
|
|
||||||
cache:
|
|
||||||
paths:
|
|
||||||
- .yarn/
|
|
||||||
key: "$CI_BUILD_STAGE"
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- test
|
|
||||||
- release
|
|
||||||
- trigger
|
|
||||||
- pages
|
|
||||||
|
|
||||||
testLEGACY:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci test legacy
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
testLTS:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci test lts
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci test stable
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
release:
|
|
||||||
stage: release
|
|
||||||
script:
|
|
||||||
- npmci publish
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
stage: trigger
|
|
||||||
script:
|
|
||||||
- npmci trigger
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
pages:
|
|
||||||
image: hosttoday/ht-docker-node:npmci
|
|
||||||
stage: pages
|
|
||||||
script:
|
|
||||||
- npmci command yarn global add npmpage
|
|
||||||
- npmci command npmpage
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
paths:
|
|
||||||
- public
|
|
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"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
313
changelog.md
Normal file
313
changelog.md
Normal file
@@ -0,0 +1,313 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-08-17 - 4.0.19 - fix(readme)
|
||||||
|
Update README with comprehensive quick start, usage examples, API reference and advanced guides
|
||||||
|
|
||||||
|
- Expanded README with a detailed Quick Start guide and installation instructions
|
||||||
|
- Added examples for creating templates, supplying variables, and scaffolding projects programmatically
|
||||||
|
- Documented core features: smart variable system, template composition, dynamic file naming, interactive CLI, and post-scaffold scripts
|
||||||
|
- Included advanced usage, CI/CD integration, template validation, and real-world example templates
|
||||||
|
- Improved formatting and added code snippets for API reference and ScafTemplate usage
|
||||||
|
|
||||||
|
## 2025-08-17 - 4.0.18 - fix(ScafTemplate)
|
||||||
|
Use interactive shell for post-scaffold scripts; update CI workflows and package metadata
|
||||||
|
|
||||||
|
- Switched ScafTemplate.runScripts to use smartshell.execInteractive so post-scaffold 'runafter' commands can run interactively
|
||||||
|
- Updated Gitea workflow environment: replaced CI image with code.foss.global/host.today/ht-docker-node:npmci and adjusted NPMCI_COMPUTED_REPOURL
|
||||||
|
- Changed CI install target from @shipzone/npmci to @ship.zone/npmci
|
||||||
|
- Updated package.json metadata (bugs URL and homepage now point to code.foss.global) and added a pnpm.overrides entry
|
||||||
|
- Minor TypeScript code cleanups and formatting (consistent trailing commas, safer string handling when parsing templates/frontmatter, improved concatenation when merging template files)
|
||||||
|
- tsconfig adjustments: enabled emitDecoratorMetadata and added baseUrl/paths entries
|
||||||
|
- Normalized README and template/test output files; updated .gitignore to ignore AI agent directories
|
||||||
|
- Updated changelog and commitinfo metadata
|
||||||
|
|
||||||
|
## 2025-08-17 - 4.0.17 - fix(ScafTemplate)
|
||||||
|
|
||||||
|
Use interactive shell for post-scaffold scripts; update test/build config and dependency versions
|
||||||
|
|
||||||
|
- Switched from smartshell.exec to smartshell.execInteractive when running smartscaf 'runafter' commands to allow interactive commands during post-scaffold execution (ScafTemplate.runScripts).
|
||||||
|
- Updated package.json scripts: test now runs with additional flags (--verbose --logfile --timeout 60). Added typings entry pointing to dist_ts/index.d.ts.
|
||||||
|
- Bumped devDependencies: @git.zone/tsbuild -> ^2.6.4, @git.zone/tstest -> ^2.3.4, @push.rocks/tapbundle -> ^6.0.3.
|
||||||
|
- Updated runtime dependency versions: @push.rocks/lik -> ^6.2.2, @push.rocks/smartfile -> ^11.2.5, @push.rocks/smartshell -> ^3.3.0 (other deps kept or minor bumps).
|
||||||
|
- Added pnpm-workspace.yaml with onlyBuiltDependencies configuration (esbuild, mongodb-memory-server, puppeteer).
|
||||||
|
|
||||||
|
## 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();
|
|
||||||
}
|
|
141
dist/smartscaf.classes.smartscaf.js
vendored
141
dist/smartscaf.classes.smartscaf.js
vendored
@@ -1,141 +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 = plugins.lodash.merge(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 = plugins.lodash.cloneDeep(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 = plugins.lodash.concat(templateVariables, localTemplateVariables);
|
|
||||||
}
|
|
||||||
templateVariables = plugins.lodash.uniq(templateVariables);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 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 = plugins.lodash.concat(missingVars, localMissingVars);
|
|
||||||
}
|
|
||||||
missingVars = plugins.lodash.uniq(missingVars);
|
|
||||||
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLmNsYXNzZXMuc21hcnRzY2FmLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzY2FmLmNsYXN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FBO0lBRUQ7Ozs7Ozs7Ozs7O09BV0c7SUFDVyxzQkFBc0I7O1lBQ2xDLElBQUksaUJBQWlCLEdBQUcsSUFBSSxDQUFDLHNCQUFzQixDQUFDLE1BQU0sQ0FBQyxZQUFZO2dCQUNyRSxNQUFNLENBQUMsWUFBWSxDQUFDLFVBQVUsQ0FBQyxJQUFJLEtBQUssY0FBYyxDQUFBO1lBQ3hELENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFBO1lBRUwsRUFBRSxDQUFDLENBQUMsaUJBQWlCLENBQUMsQ0FBQyxDQUFDO2dCQUN0QixJQUFJLGFBQWEsR0FBRyxNQUFNLE9BQU8sQ0FBQyxTQUFTLENBQUMsa0JBQWtCLENBQzVELGlCQUFpQixDQUFDLFFBQVEsQ0FBQyxRQUFRLEVBQUUsQ0FDdEMsQ0FBQTtnQkFDRCxJQUFJLENBQUMsZ0JBQWdCLEdBQUcsYUFBYSxDQUFBO1lBQ3ZDLENBQUM7WUFBQyxJQUFJLENBQUMsQ0FBQztnQkFDTixJQUFJLENBQUMsZ0JBQWdCLEdBQUcsRUFBRSxDQUFBO1lBQzVCLENBQUM7UUFDSCxDQUFDO0tBQUE7Q0FDRjtBQXJJRCxvQ0FxSUMifQ==
|
|
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLmhlbHBlcnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNjYWYuaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7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BZ0IsQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLENBQUE7WUFDOUIsZ0JBQWdCLEdBQUcsZ0JBQWdCLENBQUMsT0FBTyxDQUFDLENBQUE7UUFDOUMsQ0FBQztRQUFDLElBQUksQ0FBQyxFQUFFLENBQUMsQ0FBQyxnQkFBZ0IsQ0FBQyxPQUFPLENBQUMsSUFBSSxXQUFXLENBQUMsQ0FBQyxDQUFDO1lBQ3BELGdCQUFnQixHQUFHLGdCQUFnQixDQUFDLE9BQU8sQ0FBQyxDQUFBO1FBQzlDLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNOLE1BQU0sSUFBSSxLQUFLLENBQUMsdUJBQXVCLENBQUMsQ0FBQTtRQUMxQyxDQUFDO0lBQ0gsQ0FBQztBQUNILENBQUMsQ0FBQSxDQUFBIn0=
|
|
10
dist/smartscaf.plugins.d.ts
vendored
10
dist/smartscaf.plugins.d.ts
vendored
@@ -1,10 +0,0 @@
|
|||||||
import 'typings-global';
|
|
||||||
import * as lodash from 'lodash';
|
|
||||||
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 { lodash, path, smartfile, smartfm, smarthbs, smartinteract, smartq, smartyaml };
|
|
20
dist/smartscaf.plugins.js
vendored
20
dist/smartscaf.plugins.js
vendored
@@ -1,20 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
require("typings-global");
|
|
||||||
const lodash = require("lodash");
|
|
||||||
exports.lodash = lodash;
|
|
||||||
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNjYWYucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2QixpQ0FBZ0M7QUFVOUIsd0JBQU07QUFUUiw2QkFBNEI7QUFVMUIsb0JBQUk7QUFUTix1Q0FBc0M7QUFVcEMsOEJBQVM7QUFUWCxtQ0FBa0M7QUFVaEMsMEJBQU87QUFUVCxxQ0FBb0M7QUFVbEMsNEJBQVE7QUFUViwrQ0FBOEM7QUFVNUMsc0NBQWE7QUFUZixpQ0FBZ0M7QUFVOUIsd0JBQU07QUFUUix1Q0FBc0M7QUFVcEMsOEJBQVMifQ==
|
|
@@ -1,29 +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://)
|
|
@@ -3,8 +3,31 @@
|
|||||||
"coverageTreshold": 30
|
"coverageTreshold": 30
|
||||||
},
|
},
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"globalNpmTools": [
|
"npmGlobalTools": [],
|
||||||
"npmts"
|
"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"
|
||||||
|
}
|
||||||
}
|
}
|
76
package.json
76
package.json
@@ -1,39 +1,71 @@
|
|||||||
{
|
{
|
||||||
"name": "smartscaf",
|
"name": "@push.rocks/smartscaf",
|
||||||
"version": "1.0.12",
|
"version": "4.0.19",
|
||||||
"description": "scaffold projects quickly",
|
"private": false,
|
||||||
"main": "dist/index.js",
|
"description": "A project aimed at quickly scaffolding projects with support for TypeScript, smart file handling, and template rendering.",
|
||||||
"typings": "dist/index.d.ts",
|
"main": "dist_ts/index.js",
|
||||||
|
"typings": "dist_ts/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)"
|
"test": "(tstest test/ --verbose --logfile --timeout 60)",
|
||||||
|
"build": "(tsbuild --web --allowimplicitany)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+ssh://git@gitlab.com/pushrocks/smartscaf.git"
|
"url": "https://code.foss.global/push.rocks/smartscaf.git"
|
||||||
},
|
},
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://gitlab.com/pushrocks/smartscaf/issues"
|
"url": "https://code.foss.global/push.rocks/smartscaf/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartscaf#README",
|
"homepage": "https://code.foss.global/push.rocks/smartscaf#readme",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"scaffold",
|
"typescript",
|
||||||
"polymer",
|
"scaffolding",
|
||||||
"npm"
|
"template rendering",
|
||||||
|
"file handling",
|
||||||
|
"project setup",
|
||||||
|
"smart interaction",
|
||||||
|
"yaml",
|
||||||
|
"cli tool"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"tapbundle": "^1.1.1"
|
"@git.zone/tsbuild": "^2.6.4",
|
||||||
|
"@git.zone/tsrun": "^1.3.3",
|
||||||
|
"@git.zone/tstest": "^2.3.4",
|
||||||
|
"@push.rocks/tapbundle": "^6.0.3",
|
||||||
|
"@types/node": "^22.14.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/lodash": "^4.14.71",
|
"@push.rocks/lik": "^6.2.2",
|
||||||
"lodash": "^4.17.4",
|
"@push.rocks/smartfile": "^11.2.5",
|
||||||
"smartfile": "^4.2.17",
|
"@push.rocks/smartfm": "^2.2.2",
|
||||||
"smartfm": "^1.0.5",
|
"@push.rocks/smarthbs": "^3.0.3",
|
||||||
"smarthbs": "^1.0.16",
|
"@push.rocks/smartinteract": "^2.0.16",
|
||||||
"smartinteract": "^1.0.7",
|
"@push.rocks/smartobject": "^1.0.12",
|
||||||
"smartq": "^1.1.6",
|
"@push.rocks/smartpromise": "^4.2.3",
|
||||||
"smartyaml": "^1.0.2",
|
"@push.rocks/smartshell": "^3.3.0",
|
||||||
"typings-global": "^1.0.20"
|
"@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",
|
||||||
|
"pnpm": {
|
||||||
|
"overrides": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10833
pnpm-lock.yaml
generated
Normal file
10833
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
4
pnpm-workspace.yaml
Normal file
4
pnpm-workspace.yaml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
onlyBuiltDependencies:
|
||||||
|
- esbuild
|
||||||
|
- mongodb-memory-server
|
||||||
|
- puppeteer
|
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
|
438
readme.md
438
readme.md
@@ -1,29 +1,421 @@
|
|||||||
# smartscaf
|
# @push.rocks/smartscaf 🚀
|
||||||
scaffold projects quickly
|
|
||||||
|
|
||||||
## Availabililty
|
**Lightning-fast project scaffolding with smart templates and variable interpolation**
|
||||||
[](https://www.npmjs.com/package/smartscaf)
|
|
||||||
[](https://GitLab.com/pushrocks/smartscaf)
|
|
||||||
[](https://github.com/pushrocks/smartscaf)
|
|
||||||
[](https://pushrocks.gitlab.io/smartscaf/)
|
|
||||||
|
|
||||||
## Status for master
|
## What It Does
|
||||||
[](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
|
SmartScaf is a powerful TypeScript scaffolding engine that transforms template directories into fully configured projects in seconds. Think of it as your project's DNA replicator - define once, deploy anywhere with custom variables, dependency merging, and automated post-setup scripts.
|
||||||
Use TypeScript for best in class instellisense.
|
|
||||||
|
|
||||||
For further information read the linked docs at the top of this README.
|
Perfect for:
|
||||||
|
- 🏗️ **Bootstrapping microservices** with consistent structure
|
||||||
|
- 📦 **Creating npm packages** with standard configurations
|
||||||
|
- 🎨 **Spinning up frontend projects** with your tech stack
|
||||||
|
- 🔧 **Standardizing team workflows** with company templates
|
||||||
|
- ⚡ **Automating repetitive project setups**
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
## Installation
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
|
||||||
|
|
||||||
[](https://)
|
```bash
|
||||||
|
# Install globally for CLI usage
|
||||||
|
npm install -g @push.rocks/smartscaf
|
||||||
|
|
||||||
|
# Or add to your project
|
||||||
|
npm install @push.rocks/smartscaf --save-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
### Create Your First Template
|
||||||
|
|
||||||
|
1. **Set up a template directory** with your project structure:
|
||||||
|
|
||||||
|
```
|
||||||
|
my-template/
|
||||||
|
├── .smartscaf.yml # Template configuration
|
||||||
|
├── package.json # With {{projectName}} variables
|
||||||
|
├── src/
|
||||||
|
│ └── index.ts # Your source files
|
||||||
|
├── readme.md # With {{description}} placeholder
|
||||||
|
└── .gitignore # Standard ignores
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Configure your template** in `.smartscaf.yml`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# Template defaults and configuration
|
||||||
|
defaults:
|
||||||
|
projectName: 'my-awesome-project'
|
||||||
|
description: 'A fantastic new project'
|
||||||
|
author: '{{gitName}}'
|
||||||
|
license: 'MIT'
|
||||||
|
nodeVersion: '20'
|
||||||
|
|
||||||
|
# Merge other templates (optional)
|
||||||
|
dependencies:
|
||||||
|
merge:
|
||||||
|
- ../shared-config-template
|
||||||
|
- ../company-standards-template
|
||||||
|
|
||||||
|
# Post-scaffold automation
|
||||||
|
runafter:
|
||||||
|
- 'npm install'
|
||||||
|
- 'git init'
|
||||||
|
- 'git add .'
|
||||||
|
- 'git commit -m "Initial commit from SmartScaf"'
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Use Handlebars syntax** in your template files:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// src/index.ts
|
||||||
|
/**
|
||||||
|
* {{description}}
|
||||||
|
* @author {{author}}
|
||||||
|
* @license {{license}}
|
||||||
|
*/
|
||||||
|
|
||||||
|
export class {{className}} {
|
||||||
|
constructor() {
|
||||||
|
console.log('Welcome to {{projectName}}!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Scaffold a New Project
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { ScafTemplate } from '@push.rocks/smartscaf';
|
||||||
|
|
||||||
|
async function createProject() {
|
||||||
|
// Load your template
|
||||||
|
const template = await ScafTemplate.createTemplateFromDir('./my-template');
|
||||||
|
await template.readTemplateFromDir();
|
||||||
|
|
||||||
|
// Supply variables (overrides defaults)
|
||||||
|
await template.supplyVariables({
|
||||||
|
projectName: 'super-api',
|
||||||
|
description: 'Revolutionary API service',
|
||||||
|
className: 'SuperAPI',
|
||||||
|
author: 'John Doe'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Interactive mode - asks for any missing variables
|
||||||
|
await template.askCliForMissingVariables();
|
||||||
|
|
||||||
|
// Generate the project
|
||||||
|
await template.writeToDisk('./projects/super-api');
|
||||||
|
|
||||||
|
console.log('✨ Project scaffolded successfully!');
|
||||||
|
}
|
||||||
|
|
||||||
|
createProject();
|
||||||
|
```
|
||||||
|
|
||||||
|
## Core Features
|
||||||
|
|
||||||
|
### 🎯 Smart Variable System
|
||||||
|
|
||||||
|
SmartScaf intelligently manages template variables through multiple layers:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const template = await ScafTemplate.createTemplateFromDir('./template');
|
||||||
|
await template.readTemplateFromDir();
|
||||||
|
|
||||||
|
// Access variable collections
|
||||||
|
console.log(template.defaultVariables); // From .smartscaf.yml defaults
|
||||||
|
console.log(template.requiredVariables); // Found in template files
|
||||||
|
console.log(template.suppliedVariables); // What you've provided
|
||||||
|
console.log(template.missingVariables); // What still needs values
|
||||||
|
```
|
||||||
|
|
||||||
|
### 🔀 Template Composition
|
||||||
|
|
||||||
|
Merge multiple templates to create complex project structures:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# .smartscaf.yml
|
||||||
|
dependencies:
|
||||||
|
merge:
|
||||||
|
- ../base-template # Common structure
|
||||||
|
- ../auth-template # Authentication setup
|
||||||
|
- ../docker-template # Container configuration
|
||||||
|
```
|
||||||
|
|
||||||
|
Templates are merged in order, allowing you to build sophisticated scaffolds from modular components.
|
||||||
|
|
||||||
|
### 📝 Dynamic File Naming
|
||||||
|
|
||||||
|
Use frontmatter to dynamically rename files during scaffolding:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
---
|
||||||
|
fileName: {{projectName}}.config.js
|
||||||
|
---
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: '{{projectName}}',
|
||||||
|
version: '{{version}}'
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
### 🤖 Interactive CLI Mode
|
||||||
|
|
||||||
|
Let SmartScaf prompt for missing variables:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Automatically prompts for any variables not yet supplied
|
||||||
|
await template.askCliForMissingVariables();
|
||||||
|
```
|
||||||
|
|
||||||
|
### 🚀 Post-Scaffold Scripts
|
||||||
|
|
||||||
|
Automate setup tasks after scaffolding:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
runafter:
|
||||||
|
- 'npm install' # Install dependencies
|
||||||
|
- 'npm run build' # Initial build
|
||||||
|
- 'npm test' # Verify setup
|
||||||
|
- 'code .' # Open in VS Code
|
||||||
|
```
|
||||||
|
|
||||||
|
Scripts run in order using an interactive shell, ensuring proper environment handling.
|
||||||
|
|
||||||
|
## Advanced Usage
|
||||||
|
|
||||||
|
### Programmatic Control
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { ScafTemplate } from '@push.rocks/smartscaf';
|
||||||
|
|
||||||
|
class ProjectGenerator {
|
||||||
|
private template: ScafTemplate;
|
||||||
|
|
||||||
|
async initialize(templatePath: string) {
|
||||||
|
this.template = await ScafTemplate.createTemplateFromDir(templatePath);
|
||||||
|
await this.template.readTemplateFromDir();
|
||||||
|
}
|
||||||
|
|
||||||
|
async generate(config: any, outputPath: string) {
|
||||||
|
// Supply configuration
|
||||||
|
await this.template.supplyVariables(config);
|
||||||
|
|
||||||
|
// Check what's missing
|
||||||
|
if (this.template.missingVariables.length > 0) {
|
||||||
|
console.log('Missing:', this.template.missingVariables);
|
||||||
|
// Handle missing variables programmatically
|
||||||
|
// or use: await this.template.askCliForMissingVariables();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate project
|
||||||
|
await this.template.writeToDisk(outputPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Template Validation
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Validate template before using
|
||||||
|
const template = await ScafTemplate.createTemplateFromDir('./template');
|
||||||
|
await template.readTemplateFromDir();
|
||||||
|
|
||||||
|
// Check template structure
|
||||||
|
if (template.templateSmartfileArray.length === 0) {
|
||||||
|
throw new Error('Template is empty!');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify required variables
|
||||||
|
const required = template.requiredVariables;
|
||||||
|
const defaults = Object.keys(template.defaultVariables);
|
||||||
|
const missing = required.filter(v => !defaults.includes(v));
|
||||||
|
|
||||||
|
if (missing.length > 0) {
|
||||||
|
console.warn(`Template needs: ${missing.join(', ')}`);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Complex Variable Structures
|
||||||
|
|
||||||
|
SmartScaf supports nested object variables:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# .smartscaf.yml
|
||||||
|
defaults:
|
||||||
|
app.name: 'MyApp'
|
||||||
|
app.version: '1.0.0'
|
||||||
|
database.host: 'localhost'
|
||||||
|
database.port: 5432
|
||||||
|
api.endpoints.users: '/api/users'
|
||||||
|
api.endpoints.auth: '/api/auth'
|
||||||
|
```
|
||||||
|
|
||||||
|
Use in templates:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// config.js
|
||||||
|
export default {
|
||||||
|
app: {
|
||||||
|
name: '{{app.name}}',
|
||||||
|
version: '{{app.version}}'
|
||||||
|
},
|
||||||
|
database: {
|
||||||
|
host: '{{database.host}}',
|
||||||
|
port: {{database.port}}
|
||||||
|
},
|
||||||
|
api: {
|
||||||
|
users: '{{api.endpoints.users}}',
|
||||||
|
auth: '{{api.endpoints.auth}}'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
### CI/CD Integration
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// ci-scaffold.ts
|
||||||
|
import { ScafTemplate } from '@push.rocks/smartscaf';
|
||||||
|
|
||||||
|
async function scaffoldForCI() {
|
||||||
|
const template = await ScafTemplate.createTemplateFromDir(
|
||||||
|
process.env.TEMPLATE_PATH
|
||||||
|
);
|
||||||
|
await template.readTemplateFromDir();
|
||||||
|
|
||||||
|
// Get variables from environment
|
||||||
|
const vars = {
|
||||||
|
projectName: process.env.PROJECT_NAME,
|
||||||
|
environment: process.env.DEPLOY_ENV,
|
||||||
|
apiKey: process.env.API_KEY,
|
||||||
|
region: process.env.AWS_REGION
|
||||||
|
};
|
||||||
|
|
||||||
|
await template.supplyVariables(vars);
|
||||||
|
await template.writeToDisk(process.env.OUTPUT_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run in CI pipeline
|
||||||
|
scaffoldForCI().catch(console.error);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Real-World Examples
|
||||||
|
|
||||||
|
### Microservice Template
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# .smartscaf.yml for microservice template
|
||||||
|
defaults:
|
||||||
|
serviceName: 'my-service'
|
||||||
|
port: 3000
|
||||||
|
dockerImage: 'node:20-alpine'
|
||||||
|
healthPath: '/health'
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
merge:
|
||||||
|
- ../shared/base-service
|
||||||
|
- ../shared/monitoring
|
||||||
|
- ../shared/logging
|
||||||
|
|
||||||
|
runafter:
|
||||||
|
- 'npm install'
|
||||||
|
- 'docker build -t {{serviceName}}:latest .'
|
||||||
|
- 'npm run test:integration'
|
||||||
|
```
|
||||||
|
|
||||||
|
### React Component Library
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# .smartscaf.yml for React library
|
||||||
|
defaults:
|
||||||
|
libraryName: 'ui-components'
|
||||||
|
componentPrefix: 'UI'
|
||||||
|
useTypeScript: true
|
||||||
|
useStorybook: true
|
||||||
|
testRunner: 'jest'
|
||||||
|
|
||||||
|
runafter:
|
||||||
|
- 'pnpm install'
|
||||||
|
- 'pnpm build'
|
||||||
|
- 'pnpm storybook:build'
|
||||||
|
- 'pnpm test'
|
||||||
|
```
|
||||||
|
|
||||||
|
## API Reference
|
||||||
|
|
||||||
|
### ScafTemplate Class
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
class ScafTemplate {
|
||||||
|
// Factory method
|
||||||
|
static createTemplateFromDir(dirPath: string): Promise<ScafTemplate>
|
||||||
|
|
||||||
|
// Core methods
|
||||||
|
readTemplateFromDir(): Promise<void>
|
||||||
|
supplyVariables(variables: object): Promise<void>
|
||||||
|
askCliForMissingVariables(): Promise<void>
|
||||||
|
writeToDisk(destinationPath: string): Promise<void>
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
name: string // Template name
|
||||||
|
description: string // Template description
|
||||||
|
templateSmartfileArray: SmartFile[] // Loaded template files
|
||||||
|
defaultVariables: object // Default values from .smartscaf.yml
|
||||||
|
requiredVariables: string[] // Variables found in templates
|
||||||
|
suppliedVariables: object // Variables you've provided
|
||||||
|
missingVariables: string[] // Variables still needed
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Best Practices
|
||||||
|
|
||||||
|
### 📁 Template Organization
|
||||||
|
|
||||||
|
```
|
||||||
|
company-templates/
|
||||||
|
├── base/ # Shared foundations
|
||||||
|
│ ├── typescript/ # TS configuration
|
||||||
|
│ ├── eslint/ # Linting setup
|
||||||
|
│ └── ci-cd/ # CI/CD pipelines
|
||||||
|
├── services/ # Service templates
|
||||||
|
│ ├── rest-api/
|
||||||
|
│ ├── graphql-api/
|
||||||
|
│ └── worker-service/
|
||||||
|
└── frontends/ # Frontend templates
|
||||||
|
├── react-app/
|
||||||
|
├── vue-app/
|
||||||
|
└── static-site/
|
||||||
|
```
|
||||||
|
|
||||||
|
### 🔒 Security Considerations
|
||||||
|
|
||||||
|
- Never commit sensitive data in templates
|
||||||
|
- Use environment variables for secrets
|
||||||
|
- Add `.smartscaf.yml` to `.gitignore` if it contains private defaults
|
||||||
|
- Validate user input when using in automation
|
||||||
|
|
||||||
|
### 🎨 Template Design Tips
|
||||||
|
|
||||||
|
1. **Start small** - Begin with minimal templates and grow them
|
||||||
|
2. **Use composition** - Build complex templates from simple ones
|
||||||
|
3. **Document variables** - Add comments in `.smartscaf.yml`
|
||||||
|
4. **Test templates** - Create test scaffolds before deploying
|
||||||
|
5. **Version templates** - Use git tags for template versions
|
||||||
|
|
||||||
|
## 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.
|
42
test/test.ts
42
test/test.ts
@@ -1,33 +1,37 @@
|
|||||||
import { expect, tap } from 'tapbundle'
|
import { expect, tap } from '@push.rocks/tapbundle';
|
||||||
import * as path from 'path'
|
import * as path from 'path';
|
||||||
|
|
||||||
import * as smartscaf from '../dist/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 () => {
|
||||||
await testScafTemplate.supplyVariables({})
|
await testScafTemplate.supplyVariables({});
|
||||||
console.log(testScafTemplate.missingVariables)
|
console.log(testScafTemplate.missingVariables);
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('ask cli', async () => {
|
tap.test('ask cli', async () => {
|
||||||
await testScafTemplate.askCliForMissingVariables()
|
await testScafTemplate.askCliForMissingVariables();
|
||||||
})
|
});
|
||||||
|
|
||||||
|
tap.test('should have valid supplied variables', async () => {
|
||||||
|
console.log(testScafTemplate.suppliedVariables);
|
||||||
|
});
|
||||||
|
|
||||||
tap.test('should output ready rendered template', async () => {
|
tap.test('should output ready rendered template', async () => {
|
||||||
await testScafTemplate.writeToDisk(path.resolve('./test/test_output'))
|
await testScafTemplate.writeToDisk(path.resolve('./test/test_output'));
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.start()
|
tap.start();
|
||||||
|
@@ -1,3 +1,6 @@
|
|||||||
|
|
||||||
# this is a wow
|
# this is a wow
|
||||||
|
|
||||||
# this is a here
|
# this is a here
|
||||||
|
|
||||||
# this is a undefined variable
|
# this is a undefined variable
|
@@ -1 +1,2 @@
|
|||||||
|
|
||||||
# some undefined variable
|
# some 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
|
@@ -1,3 +1,5 @@
|
|||||||
# this is a from default yaml
|
# this is a from default yaml
|
||||||
|
|
||||||
# this is a this is another value from yml
|
# this is a this is another value from yml
|
||||||
|
|
||||||
# this is a undefined variable
|
# this is a undefined variable
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
# some undefined variable
|
|
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,9 @@
|
|||||||
|
---
|
||||||
|
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,3 +1,5 @@
|
|||||||
# this is a {{templateVar1}}
|
# this is a {{templateVar1}}
|
||||||
|
|
||||||
# this is a {{templateVar2}}
|
# this is a {{templateVar2}}
|
||||||
|
|
||||||
# this is a {{templateVar3}}
|
# this is a {{templateVar3}}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
---
|
---
|
||||||
fileName: changedname.md
|
fileName: changedname.md
|
||||||
---
|
---
|
||||||
|
|
||||||
# some {{wow}}
|
# some {{wow}}
|
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.19',
|
||||||
|
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,124 +1,223 @@
|
|||||||
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
|
|
||||||
import { Smartfile } from 'smartfile'
|
|
||||||
|
|
||||||
export interface ScafTemplateContructorOptions {
|
export interface ScafTemplateContructorOptions {
|
||||||
name?: string,
|
name?: string;
|
||||||
description?: string
|
description?: string;
|
||||||
sourceDir?: string
|
sourceDir?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = {}
|
* the name of the template
|
||||||
missingVariables: string[] = []
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.templateSmartfileArray = await plugins.smartfile.fs.fileTreeToObject(dirPath, '**/*')
|
this.dirPath,
|
||||||
await this._findVariablesInTemplate()
|
'**/*',
|
||||||
await this._checkSuppliedVariables()
|
);
|
||||||
await this._checkDefaultVariables()
|
|
||||||
|
// 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();
|
||||||
|
await this._checkDefaultVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 = plugins.lodash.merge(this.suppliedVariables, variablesArg)
|
this.suppliedVariables = {
|
||||||
this.missingVariables = await this._checkSuppliedVariables()
|
...this.suppliedVariables,
|
||||||
|
...variablesArg,
|
||||||
|
};
|
||||||
|
this.missingVariables = await this._checkSuppliedVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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,
|
||||||
type: 'input',
|
type: 'input',
|
||||||
default: (() => {
|
default: (() => {
|
||||||
if (this.defaultVariables && this.defaultVariables[missingVariable]) {
|
if (
|
||||||
return this.defaultVariables[missingVariable]
|
this.defaultVariables &&
|
||||||
|
this.defaultVariables[missingVariable]
|
||||||
|
) {
|
||||||
|
return this.defaultVariables[missingVariable];
|
||||||
} else {
|
} else {
|
||||||
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 answers = answerBucket.getAllAnswers();
|
||||||
|
for (const answer of answers) {
|
||||||
|
await plugins.smartobject.smartAdd(
|
||||||
|
this.suppliedVariables,
|
||||||
|
answer.name,
|
||||||
|
answer.value,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
let answerBucket = await localSmartInteract.runQueue()
|
|
||||||
answerBucket.answerMap.forEach(async answer => {
|
|
||||||
await helpers.deepAddToObject(this.suppliedVariables, answer.name, answer.value)
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async writeToDisk (destinationDirArg) {
|
/**
|
||||||
let smartfileArrayToWrite = plugins.lodash.cloneDeep(this.templateSmartfileArray)
|
* writes a file to disk
|
||||||
for (let smartfile of smartfileArrayToWrite) {
|
* @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
|
// render the template
|
||||||
let template = await plugins.smarthbs.getTemplateForString(
|
const template = await plugins.smarthbs.getTemplateForString(
|
||||||
smartfile.contents.toString()
|
smartfile.contents.toString(),
|
||||||
)
|
);
|
||||||
let renderedTemplateString = template(this.suppliedVariables)
|
const renderedTemplateString = template(this.suppliedVariables);
|
||||||
|
|
||||||
// handle frontmatter
|
// handle frontmatter
|
||||||
let parsedTemplate = plugins.smartfm.parse(renderedTemplateString)
|
const smartfmInstance = new plugins.smartfm.Smartfm({
|
||||||
|
fmType: 'yaml',
|
||||||
|
});
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* finds all variables in a Template in as string
|
* finds all variables in a Template in as string
|
||||||
* e.g. myobject.someKey and myobject.someOtherKey
|
* e.g. myobject.someKey and myobject.someOtherKey
|
||||||
*/
|
*/
|
||||||
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(templateSmartfile.contents.toString())
|
const localTemplateVariables = await plugins.smarthbs.findVarsInHbsString(
|
||||||
templateVariables = plugins.lodash.concat(templateVariables, localTemplateVariables)
|
templateSmartfile.contents.toString(),
|
||||||
|
);
|
||||||
|
templateVariables = [...templateVariables, ...localTemplateVariables];
|
||||||
}
|
}
|
||||||
templateVariables = plugins.lodash.uniq(templateVariables)
|
templateVariables = templateVariables.filter((value, index, self) => {
|
||||||
|
return self.indexOf(value) === index;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks if supplied Variables satisfy the template
|
* checks if supplied Variables satisfy the template
|
||||||
*/
|
*/
|
||||||
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,
|
||||||
)
|
);
|
||||||
missingVars = plugins.lodash.concat(missingVars, localMissingVars)
|
|
||||||
|
// combine with other missingVars
|
||||||
|
missingVars = [...missingVars, ...localMissingVars];
|
||||||
}
|
}
|
||||||
missingVars = plugins.lodash.uniq(missingVars)
|
|
||||||
return missingVars
|
// dedupe
|
||||||
|
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
|
* 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
|
||||||
@@ -129,18 +228,64 @@ export class ScafTemplate {
|
|||||||
* >> - yourKey:
|
* >> - yourKey:
|
||||||
* >> - yourDeeperKey: yourValue
|
* >> - yourDeeperKey: yourValue
|
||||||
*/
|
*/
|
||||||
private async _checkDefaultVariables () {
|
private async _checkDefaultVariables() {
|
||||||
let defaultsSmartfile = this.templateSmartfileArray.filter(smartfileArg => {
|
const smartscafSmartfile = this.templateSmartfileArray.find(
|
||||||
return smartfileArg.parsedPath.base === 'defaults.yml'
|
(smartfileArg) => {
|
||||||
})[0]
|
return smartfileArg.parsedPath.base === '.smartscaf.yml';
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
if (defaultsSmartfile) {
|
if (smartscafSmartfile) {
|
||||||
let defaultObject = await plugins.smartyaml.yamlStringToObject(
|
const smartscafObject = await plugins.smartyaml.yamlStringToObject(
|
||||||
defaultsSmartfile.contents.toString()
|
smartscafSmartfile.contents.toString(),
|
||||||
)
|
);
|
||||||
this.defaultVariables = defaultObject
|
const defaultObject = smartscafObject.defaults;
|
||||||
} else {
|
this.defaultVariables = defaultObject;
|
||||||
this.defaultVariables = {}
|
}
|
||||||
|
|
||||||
|
// safeguard against non existent defaults
|
||||||
|
if (!this.defaultVariables) {
|
||||||
|
console.log('this template does not specify defaults');
|
||||||
|
this.defaultVariables = {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* resolve template dependencies
|
||||||
|
*/
|
||||||
|
private async _resolveTemplateDependencies() {
|
||||||
|
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);
|
||||||
|
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.execInteractive(
|
||||||
|
`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,20 +1,23 @@
|
|||||||
import 'typings-global'
|
import * as path from 'path';
|
||||||
import * as lodash from 'lodash'
|
import * as lik from '@push.rocks/lik';
|
||||||
import * as path from 'path'
|
import * as smartfile from '@push.rocks/smartfile';
|
||||||
import * as smartfile from 'smartfile'
|
import * as smartfm from '@push.rocks/smartfm';
|
||||||
import * as smartfm from 'smartfm'
|
import * as smarthbs from '@push.rocks/smarthbs';
|
||||||
import * as smarthbs from 'smarthbs'
|
import * as smartinteract from '@push.rocks/smartinteract';
|
||||||
import * as smartinteract from 'smartinteract'
|
import * as smartobject from '@push.rocks/smartobject';
|
||||||
import * as smartq from 'smartq'
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
import * as smartyaml from 'smartyaml'
|
import * as smartyaml from '@push.rocks/smartyaml';
|
||||||
|
import * as smartshell from '@push.rocks/smartshell';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
lodash,
|
|
||||||
path,
|
path,
|
||||||
|
lik,
|
||||||
smartfile,
|
smartfile,
|
||||||
smartfm,
|
smartfm,
|
||||||
smarthbs,
|
smarthbs,
|
||||||
smartinteract,
|
smartinteract,
|
||||||
smartq,
|
smartobject,
|
||||||
smartyaml
|
smartpromise,
|
||||||
}
|
smartyaml,
|
||||||
|
smartshell,
|
||||||
|
};
|
||||||
|
15
tsconfig.json
Normal file
15
tsconfig.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "NodeNext",
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {}
|
||||||
|
},
|
||||||
|
"exclude": ["dist_*/**/*.d.ts"]
|
||||||
|
}
|
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "tslint-config-standard"
|
|
||||||
}
|
|
Reference in New Issue
Block a user