Compare commits

...

7 Commits

Author SHA1 Message Date
jkunz 03d65ce0f5 v4.0.22
Default (tags) / security (push) Failing after 1s
Default (tags) / test (push) Failing after 1s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2026-04-30 10:22:59 +00:00
jkunz 77a921920b fix(smartscaf): migrate file handling to SmartFileFactory and tighten TypeScript compatibility 2026-04-30 10:22:59 +00:00
jkunz 3c68eae55d v4.0.21
Default (tags) / security (push) Failing after 0s
Default (tags) / test (push) Failing after 0s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2026-03-24 16:49:58 +00:00
jkunz d0f485ee85 fix(smartconfig): correct smartconfig package key and add npmjs registry for public releases 2026-03-24 16:49:58 +00:00
jkunz 1c008bfcc1 4.0.20
Default (tags) / security (push) Failing after 0s
Default (tags) / test (push) Failing after 0s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2026-03-24 16:48:20 +00:00
jkunz 80b53ef2fe feat(config): add .smartconfig.json for project configuration and legal information 2026-03-24 16:48:13 +00:00
jkunz 9fb0933dbc feat(ScafTemplate): add renderToMemory() method for in-memory template rendering
Adds a new public method that renders all template files in memory without writing to disk or running scripts. Returns new SmartFile instances without mutating the original templateSmartfileArray. This enables use cases like format commands that need to compare rendered templates with existing files.
2026-03-24 16:42:10 +00:00
10 changed files with 2247 additions and 4529 deletions
+12 -11
View File
@@ -1,12 +1,5 @@
{
"npmts": {
"coverageTreshold": 30
},
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"gitzone": {
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
@@ -25,9 +18,17 @@
"yaml",
"cli tool"
]
},
"release": {
"registries": [
"https://verdaccio.lossless.digital",
"https://registry.npmjs.org"
],
"accessLevel": "public"
}
},
"tsdoc": {
"@git.zone/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"
}
}
},
"@ship.zone/szci": {}
}
+14
View File
@@ -1,5 +1,19 @@
# Changelog
## 2026-04-30 - 4.0.22 - fix(smartscaf)
migrate file handling to SmartFileFactory and tighten TypeScript compatibility
- replace deprecated smartfile fs and memory helpers with SmartFileFactory virtual directory APIs
- initialize class properties and add explicit typings to satisfy stricter TypeScript settings
- update test imports and tooling dependencies for newer tstest and smartfile ecosystem versions
## 2026-03-24 - 4.0.21 - fix(smartconfig)
correct smartconfig package key and add npmjs registry for public releases
- Rename the CLI configuration key from git.zone/cli to @git.zone/cli.
- Add https://registry.npmjs.org to the release registries alongside the existing Verdaccio registry.
- Register @ship.zone/szci in the project smart configuration.
## 2025-08-17 - 4.0.19 - fix(readme)
Update README with comprehensive quick start, usage examples, API reference and advanced guides
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2025 Task Venture Capital GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+14 -15
View File
@@ -1,13 +1,13 @@
{
"name": "@push.rocks/smartscaf",
"version": "4.0.19",
"version": "4.0.22",
"private": false,
"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/ --verbose --logfile --timeout 60)",
"build": "(tsbuild --web --allowimplicitany)",
"build": "(tsbuild --web)",
"buildDocs": "tsdoc"
},
"repository": {
@@ -31,21 +31,21 @@
"cli tool"
],
"devDependencies": {
"@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"
"@git.zone/tsbuild": "^4.4.0",
"@git.zone/tsrun": "^2.0.2",
"@git.zone/tstest": "^3.6.3",
"@types/node": "^25.6.0"
},
"dependencies": {
"@push.rocks/lik": "^6.2.2",
"@push.rocks/smartfile": "^11.2.5",
"@push.rocks/lik": "^6.4.1",
"@push.rocks/smartfile": "^13.1.3",
"@push.rocks/smartfm": "^2.2.2",
"@push.rocks/smarthbs": "^3.0.3",
"@push.rocks/smartfs": "^1.5.1",
"@push.rocks/smarthbs": "^3.0.5",
"@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/smartshell": "^3.3.8",
"@push.rocks/smartyaml": "^3.0.4"
},
"files": [
@@ -57,6 +57,8 @@
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
".smartconfig.json",
"license",
"npmextra.json",
"readme.md"
],
@@ -64,8 +66,5 @@
"browserslist": [
"last 1 chrome versions"
],
"packageManager": "pnpm@10.7.0+sha512.6b865ad4b62a1d9842b61d674a393903b871d9244954f652b8842c2b553c72176b278f64c463e52d40fff8aba385c235c8c9ecf5cc7de4fd78b8bb6d49633ab6",
"pnpm": {
"overrides": {}
}
"packageManager": "pnpm@10.28.2"
}
+2107 -4478
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -1,4 +1,4 @@
import { expect, tap } from '@push.rocks/tapbundle';
import { expect, tap } from '@git.zone/tstest/tapbundle';
import * as path from 'path';
import * as smartscaf from '../ts/index.js';
@@ -34,4 +34,4 @@ tap.test('should output ready rendered template', async () => {
await testScafTemplate.writeToDisk(path.resolve('./test/test_output'));
});
tap.start();
export default tap.start();
+1 -1
View File
@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartscaf',
version: '4.0.19',
version: '4.0.22',
description: 'A project aimed at quickly scaffolding projects with support for TypeScript, smart file handling, and template rendering.'
}
+69 -20
View File
@@ -15,31 +15,37 @@ export class ScafTemplate {
/**
* the name of the template
*/
public name: string;
public name = '';
/**
* the descriptions of the template
*/
public description: string;
public description = '';
/**
* the location on disk of the template
*/
public dirPath: string;
public destinationPath: string;
public destinationPath?: string;
/**
* smartscafFile
*/
public smartscafFile: interfaces.ISmartscafFile;
public smartscafFile: interfaces.ISmartscafFile = {
defaults: {},
dependencies: {
merge: [],
},
runafter: [],
};
/**
* the files of the template as array of Smartfiles
*/
public templateSmartfileArray: plugins.smartfile.SmartFile[];
public requiredVariables: string[];
public defaultVariables: any;
public suppliedVariables: any = {};
public templateSmartfileArray: plugins.smartfile.SmartFile[] = [];
public requiredVariables: string[] = [];
public defaultVariables: Record<string, unknown> = {};
public suppliedVariables: Record<string, unknown> = {};
public missingVariables: string[] = [];
constructor(dirPathArg: string) {
@@ -50,10 +56,10 @@ export class ScafTemplate {
* read a template from a directory
*/
public async readTemplateFromDir() {
this.templateSmartfileArray = await plugins.smartfile.fs.fileTreeToObject(
const templateVirtualDirectory = await plugins.smartFileFactory.virtualDirectoryFromPath(
this.dirPath,
'**/*',
);
this.templateSmartfileArray = templateVirtualDirectory.listFiles();
// read .smartscaf.yml file
let smartscafFile: interfaces.ISmartscafFile = {
@@ -90,7 +96,7 @@ export class ScafTemplate {
* supply the variables to render the teplate with
* @param variablesArg gets merged with this.suppliedVariables
*/
public async supplyVariables(variablesArg) {
public async supplyVariables(variablesArg: Record<string, unknown>) {
this.suppliedVariables = {
...this.suppliedVariables,
...variablesArg,
@@ -134,11 +140,55 @@ export class ScafTemplate {
}
}
/**
* Renders all template files in memory without writing to disk or running scripts.
* Returns new SmartFile instances — does not mutate the original templateSmartfileArray.
*/
public async renderToMemory(): Promise<plugins.smartfile.SmartFile[]> {
const renderedFiles: plugins.smartfile.SmartFile[] = [];
for (const smartfile of this.templateSmartfileArray) {
if (smartfile.path === '.smartscaf.yml') {
continue;
}
// Render handlebars template
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;
// Determine final path (frontmatter fileName rename)
let finalPath = smartfile.path;
if (parsedTemplate.data.fileName) {
const oldFileName = plugins.path.parse(finalPath).base;
finalPath = finalPath.replace(new RegExp(oldFileName + '$'), parsedTemplate.data.fileName);
}
// Postprocess: convert {-{ back to {{
const finalContent = await plugins.smarthbs.postprocess(parsedTemplate.content);
renderedFiles.push(plugins.smartFileFactory.fromBuffer(
finalPath,
Buffer.from(finalContent),
smartfile.base,
));
}
return renderedFiles;
}
/**
* writes a file to disk
* @param destinationDirArg
*/
public async writeToDisk(destinationDirArg) {
public async writeToDisk(destinationDirArg: string) {
this.destinationPath = destinationDirArg;
const smartfileArrayToWrite: plugins.smartfile.SmartFile[] = [];
for (const smartfile of this.templateSmartfileArray) {
@@ -170,10 +220,10 @@ export class ScafTemplate {
smartfileArrayToWrite.push(smartfile);
}
await plugins.smartfile.memory.smartfileArrayToFs(
const virtualDirectoryToWrite = plugins.smartFileFactory.virtualDirectoryFromFileArray(
smartfileArrayToWrite,
destinationDirArg,
);
await virtualDirectoryToWrite.saveToDisk(destinationDirArg);
await this.runScripts();
}
@@ -258,17 +308,16 @@ export class ScafTemplate {
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)) {
if (!(await plugins.smartFs.directory(templatePathToMerge).exists())) {
console.log(
`dependency ${dependency} resolves to ${templatePathToMerge} which ist NOT a directory`,
);
continue;
}
const templateSmartfileArray =
await plugins.smartfile.fs.fileTreeToObject(
templatePathToMerge,
'**/*',
);
const templateVirtualDirectoryToMerge = await plugins.smartFileFactory.virtualDirectoryFromPath(
templatePathToMerge,
);
const templateSmartfileArray = templateVirtualDirectoryToMerge.listFiles();
this.templateSmartfileArray = this.templateSmartfileArray.concat(
templateSmartfileArray,
);
+5
View File
@@ -2,6 +2,7 @@ import * as path from 'path';
import * as lik from '@push.rocks/lik';
import * as smartfile from '@push.rocks/smartfile';
import * as smartfm from '@push.rocks/smartfm';
import * as smartfs from '@push.rocks/smartfs';
import * as smarthbs from '@push.rocks/smarthbs';
import * as smartinteract from '@push.rocks/smartinteract';
import * as smartobject from '@push.rocks/smartobject';
@@ -9,11 +10,15 @@ import * as smartpromise from '@push.rocks/smartpromise';
import * as smartyaml from '@push.rocks/smartyaml';
import * as smartshell from '@push.rocks/smartshell';
export const smartFileFactory = smartfile.SmartFileFactory.nodeFs();
export const smartFs = smartFileFactory.getSmartFs() as smartfs.SmartFs;
export {
path,
lik,
smartfile,
smartfm,
smartfs,
smarthbs,
smartinteract,
smartobject,
+2 -2
View File
@@ -6,10 +6,10 @@
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noImplicitAny": true,
"esModuleInterop": true,
"verbatimModuleSyntax": true,
"baseUrl": ".",
"paths": {}
"types": ["node"]
},
"exclude": ["dist_*/**/*.d.ts"]
}