Compare commits
34 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 |
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
|
7
.gitignore
vendored
7
.gitignore
vendored
@@ -3,7 +3,6 @@
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
@@ -17,4 +16,8 @@ node_modules/
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
||||
# AI
|
||||
.claude/
|
||||
.serena/
|
||||
|
||||
#------# custom
|
139
.gitlab-ci.yml
139
.gitlab-ci.yml
@@ -1,139 +0,0 @@
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: '$CI_BUILD_STAGE'
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
before_script:
|
||||
- npm install -g @shipzone/npmci
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command npm run buildDocs
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
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.
|
@@ -9,12 +9,25 @@
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "smartscaf",
|
||||
"description": "scaffold projects quickly",
|
||||
"npmPackagename": "@pushrocks/smartscaf",
|
||||
"license": "MIT"
|
||||
"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"
|
||||
}
|
||||
}
|
59
package.json
59
package.json
@@ -1,47 +1,52 @@
|
||||
{
|
||||
"name": "@pushrocks/smartscaf",
|
||||
"version": "4.0.5",
|
||||
"name": "@push.rocks/smartscaf",
|
||||
"version": "4.0.19",
|
||||
"private": false,
|
||||
"description": "scaffold projects quickly",
|
||||
"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/)",
|
||||
"test": "(tstest test/ --verbose --logfile --timeout 60)",
|
||||
"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"
|
||||
"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": [
|
||||
"scaffold",
|
||||
"polymer",
|
||||
"npm"
|
||||
"typescript",
|
||||
"scaffolding",
|
||||
"template rendering",
|
||||
"file handling",
|
||||
"project setup",
|
||||
"smart interaction",
|
||||
"yaml",
|
||||
"cli tool"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.66",
|
||||
"@gitzone/tsrun": "^1.2.42",
|
||||
"@gitzone/tstest": "^1.0.74",
|
||||
"@pushrocks/tapbundle": "^5.0.8",
|
||||
"@types/node": "^20.3.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": {
|
||||
"@pushrocks/lik": "^6.0.2",
|
||||
"@pushrocks/smartfile": "^10.0.17",
|
||||
"@pushrocks/smartfm": "^2.0.4",
|
||||
"@pushrocks/smarthbs": "^3.0.3",
|
||||
"@pushrocks/smartinteract": "^2.0.11",
|
||||
"@pushrocks/smartparam": "^1.1.6",
|
||||
"@pushrocks/smartpromise": "^4.0.2",
|
||||
"@pushrocks/smartshell": "^3.0.3",
|
||||
"@pushrocks/smartyaml": "^2.0.5"
|
||||
"@push.rocks/lik": "^6.2.2",
|
||||
"@push.rocks/smartfile": "^11.2.5",
|
||||
"@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.3.0",
|
||||
"@push.rocks/smartyaml": "^3.0.4"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
@@ -58,5 +63,9 @@
|
||||
"type": "module",
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
],
|
||||
"packageManager": "pnpm@10.7.0+sha512.6b865ad4b62a1d9842b61d674a393903b871d9244954f652b8842c2b553c72176b278f64c463e52d40fff8aba385c235c8c9ecf5cc7de4fd78b8bb6d49633ab6",
|
||||
"pnpm": {
|
||||
"overrides": {}
|
||||
}
|
||||
}
|
||||
|
12883
pnpm-lock.yaml
generated
12883
pnpm-lock.yaml
generated
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 @@
|
||||
|
441
readme.md
441
readme.md
@@ -1,46 +1,421 @@
|
||||
# @pushrocks/smartscaf
|
||||
scaffold projects quickly
|
||||
# @push.rocks/smartscaf 🚀
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartscaf)
|
||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartscaf)
|
||||
* [github.com (source mirror)](https://github.com/pushrocks/smartscaf)
|
||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartscaf/)
|
||||
**Lightning-fast project scaffolding with smart templates and variable interpolation**
|
||||
|
||||
## Status for master
|
||||
## What It Does
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
Snyk | [](https://lossless.cloud)
|
||||
TypeScript Support | [](https://lossless.cloud)
|
||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||
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.
|
||||
|
||||
## Usage
|
||||
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**
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
## Installation
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
```bash
|
||||
# Install globally for CLI usage
|
||||
npm install -g @push.rocks/smartscaf
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
# Or add to your project
|
||||
npm install @push.rocks/smartscaf --save-dev
|
||||
```
|
||||
|
||||
[](https://)
|
||||
## Quick Start
|
||||
|
||||
## Contribution
|
||||
### Create Your First Template
|
||||
|
||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||
1. **Set up a template directory** with your project structure:
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
2. **Configure your template** in `.smartscaf.yml`:
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
||||
```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.
|
@@ -1,4 +1,4 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
import * as path from 'path';
|
||||
|
||||
import * as smartscaf from '../ts/index.js';
|
||||
|
@@ -1,3 +1,6 @@
|
||||
|
||||
# this is a wow
|
||||
|
||||
# this is a here
|
||||
|
||||
# this is a undefined variable
|
||||
|
@@ -1 +1,2 @@
|
||||
|
||||
# some undefined variable
|
@@ -1,3 +0,0 @@
|
||||
# this is a wow
|
||||
# this is a here
|
||||
# this is a undefined variable
|
@@ -1,3 +1,5 @@
|
||||
# this is a from default yaml
|
||||
|
||||
# this is a this is another value from yml
|
||||
|
||||
# this is a undefined variable
|
||||
|
@@ -10,4 +10,4 @@ dependencies:
|
||||
- ../test_template_2
|
||||
|
||||
runafter:
|
||||
- npm install
|
||||
- echo 'runafter'
|
||||
|
@@ -1,6 +1,9 @@
|
||||
---
|
||||
fileName: anothername.yml
|
||||
---
|
||||
|
||||
# this is a {{templateObject.value1}}
|
||||
|
||||
# this is a {{templateObject.value2}}
|
||||
|
||||
# this is a {{templateVar3}}
|
||||
|
@@ -1,3 +1,5 @@
|
||||
# this is a {{templateVar1}}
|
||||
|
||||
# this is a {{templateVar2}}
|
||||
|
||||
# this is a {{templateVar3}}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
---
|
||||
fileName: changedname.md
|
||||
---
|
||||
|
||||
# some {{wow}}
|
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smartscaf',
|
||||
version: '4.0.5',
|
||||
description: 'scaffold projects quickly'
|
||||
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,9 +1,6 @@
|
||||
import * as plugins from './smartscaf.plugins.js';
|
||||
import * as interfaces from './interfaces/index.js';
|
||||
|
||||
// interfaces
|
||||
import { Smartfile } from '@pushrocks/smartfile';
|
||||
|
||||
export interface ScafTemplateContructorOptions {
|
||||
name?: string;
|
||||
description?: string;
|
||||
@@ -39,7 +36,7 @@ export class ScafTemplate {
|
||||
/**
|
||||
* the files of the template as array of Smartfiles
|
||||
*/
|
||||
public templateSmartfileArray: Smartfile[];
|
||||
public templateSmartfileArray: plugins.smartfile.SmartFile[];
|
||||
public requiredVariables: string[];
|
||||
public defaultVariables: any;
|
||||
public suppliedVariables: any = {};
|
||||
@@ -53,7 +50,10 @@ export class ScafTemplate {
|
||||
* read a template from a directory
|
||||
*/
|
||||
public async readTemplateFromDir() {
|
||||
this.templateSmartfileArray = await plugins.smartfile.fs.fileTreeToObject(this.dirPath, '**/*');
|
||||
this.templateSmartfileArray = await plugins.smartfile.fs.fileTreeToObject(
|
||||
this.dirPath,
|
||||
'**/*',
|
||||
);
|
||||
|
||||
// read .smartscaf.yml file
|
||||
let smartscafFile: interfaces.ISmartscafFile = {
|
||||
@@ -64,15 +64,17 @@ export class ScafTemplate {
|
||||
runafter: [],
|
||||
};
|
||||
|
||||
const smartscafSmartfile = this.templateSmartfileArray.find((smartfileArg) => {
|
||||
return smartfileArg.parsedPath.base === '.smartscaf.yml';
|
||||
});
|
||||
const smartscafSmartfile = this.templateSmartfileArray.find(
|
||||
(smartfileArg) => {
|
||||
return smartfileArg.parsedPath.base === '.smartscaf.yml';
|
||||
},
|
||||
);
|
||||
|
||||
if (smartscafSmartfile) {
|
||||
smartscafFile = {
|
||||
...smartscafFile,
|
||||
...(await plugins.smartyaml.yamlStringToObject(
|
||||
smartscafSmartfile.contentBuffer.toString()
|
||||
smartscafSmartfile.contentBuffer.toString(),
|
||||
)),
|
||||
};
|
||||
}
|
||||
@@ -108,7 +110,10 @@ export class ScafTemplate {
|
||||
name: missingVariable,
|
||||
type: 'input',
|
||||
default: (() => {
|
||||
if (this.defaultVariables && this.defaultVariables[missingVariable]) {
|
||||
if (
|
||||
this.defaultVariables &&
|
||||
this.defaultVariables[missingVariable]
|
||||
) {
|
||||
return this.defaultVariables[missingVariable];
|
||||
} else {
|
||||
return 'undefined variable';
|
||||
@@ -121,7 +126,11 @@ export class ScafTemplate {
|
||||
const answerBucket = await localSmartInteract.runQueue();
|
||||
const answers = answerBucket.getAllAnswers();
|
||||
for (const answer of answers) {
|
||||
await plugins.smartparam.smartAdd(this.suppliedVariables, answer.name, answer.value);
|
||||
await plugins.smartobject.smartAdd(
|
||||
this.suppliedVariables,
|
||||
answer.name,
|
||||
answer.value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +140,7 @@ export class ScafTemplate {
|
||||
*/
|
||||
public async writeToDisk(destinationDirArg) {
|
||||
this.destinationPath = destinationDirArg;
|
||||
const smartfileArrayToWrite: Smartfile[] = [];
|
||||
const smartfileArrayToWrite: plugins.smartfile.SmartFile[] = [];
|
||||
for (const smartfile of this.templateSmartfileArray) {
|
||||
// lets filter out template files
|
||||
if (smartfile.path === '.smartscaf.yml') {
|
||||
@@ -139,23 +148,32 @@ export class ScafTemplate {
|
||||
}
|
||||
|
||||
// render the template
|
||||
const template = await plugins.smarthbs.getTemplateForString(smartfile.contents.toString());
|
||||
const template = await plugins.smarthbs.getTemplateForString(
|
||||
smartfile.contents.toString(),
|
||||
);
|
||||
const renderedTemplateString = template(this.suppliedVariables);
|
||||
|
||||
// handle frontmatter
|
||||
const smartfmInstance = new plugins.smartfm.Smartfm({
|
||||
fmType: 'yaml',
|
||||
});
|
||||
const 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(await plugins.smarthbs.postprocess(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();
|
||||
}
|
||||
|
||||
@@ -167,7 +185,7 @@ export class ScafTemplate {
|
||||
let templateVariables: string[] = [];
|
||||
for (const templateSmartfile of this.templateSmartfileArray) {
|
||||
const localTemplateVariables = await plugins.smarthbs.findVarsInHbsString(
|
||||
templateSmartfile.contents.toString()
|
||||
templateSmartfile.contents.toString(),
|
||||
);
|
||||
templateVariables = [...templateVariables, ...localTemplateVariables];
|
||||
}
|
||||
@@ -184,7 +202,7 @@ export class ScafTemplate {
|
||||
for (const templateSmartfile of this.templateSmartfileArray) {
|
||||
const localMissingVars = await plugins.smarthbs.checkVarsSatisfaction(
|
||||
templateSmartfile.contents.toString(),
|
||||
this.suppliedVariables
|
||||
this.suppliedVariables,
|
||||
);
|
||||
|
||||
// combine with other missingVars
|
||||
@@ -211,13 +229,15 @@ export class ScafTemplate {
|
||||
* >> - yourDeeperKey: yourValue
|
||||
*/
|
||||
private async _checkDefaultVariables() {
|
||||
const smartscafSmartfile = this.templateSmartfileArray.find((smartfileArg) => {
|
||||
return smartfileArg.parsedPath.base === '.smartscaf.yml';
|
||||
});
|
||||
const smartscafSmartfile = this.templateSmartfileArray.find(
|
||||
(smartfileArg) => {
|
||||
return smartfileArg.parsedPath.base === '.smartscaf.yml';
|
||||
},
|
||||
);
|
||||
|
||||
if (smartscafSmartfile) {
|
||||
const smartscafObject = await plugins.smartyaml.yamlStringToObject(
|
||||
smartscafSmartfile.contents.toString()
|
||||
smartscafSmartfile.contents.toString(),
|
||||
);
|
||||
const defaultObject = smartscafObject.defaults;
|
||||
this.defaultVariables = defaultObject;
|
||||
@@ -240,15 +260,18 @@ export class ScafTemplate {
|
||||
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`
|
||||
`dependency ${dependency} resolves to ${templatePathToMerge} which ist NOT a directory`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
const templateSmartfileArray = await plugins.smartfile.fs.fileTreeToObject(
|
||||
templatePathToMerge,
|
||||
'**/*'
|
||||
const templateSmartfileArray =
|
||||
await plugins.smartfile.fs.fileTreeToObject(
|
||||
templatePathToMerge,
|
||||
'**/*',
|
||||
);
|
||||
this.templateSmartfileArray = this.templateSmartfileArray.concat(
|
||||
templateSmartfileArray,
|
||||
);
|
||||
this.templateSmartfileArray = this.templateSmartfileArray.concat(templateSmartfileArray);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,7 +283,9 @@ export class ScafTemplate {
|
||||
executor: 'bash',
|
||||
});
|
||||
for (const command of this.smartscafFile.runafter) {
|
||||
await smartshellInstance.exec(`cd ${this.destinationPath} && ${command}`);
|
||||
await smartshellInstance.execInteractive(
|
||||
`cd ${this.destinationPath} && ${command}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,13 +1,13 @@
|
||||
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 smartparam from '@pushrocks/smartparam';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartyaml from '@pushrocks/smartyaml';
|
||||
import * as smartshell from '@pushrocks/smartshell';
|
||||
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,
|
||||
@@ -16,7 +16,7 @@ export {
|
||||
smartfm,
|
||||
smarthbs,
|
||||
smartinteract,
|
||||
smartparam,
|
||||
smartobject,
|
||||
smartpromise,
|
||||
smartyaml,
|
||||
smartshell,
|
||||
|
@@ -1,9 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "nodenext"
|
||||
}
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {}
|
||||
},
|
||||
"exclude": ["dist_*/**/*.d.ts"]
|
||||
}
|
||||
|
Reference in New Issue
Block a user