fix(smartscaf): migrate file handling to SmartFileFactory and tighten TypeScript compatibility
This commit is contained in:
@@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# 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)
|
## 2026-03-24 - 4.0.21 - fix(smartconfig)
|
||||||
correct smartconfig package key and add npmjs registry for public releases
|
correct smartconfig package key and add npmjs registry for public releases
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
||||||
+13
-14
@@ -7,7 +7,7 @@
|
|||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/ --verbose --logfile --timeout 60)",
|
"test": "(tstest test/ --verbose --logfile --timeout 60)",
|
||||||
"build": "(tsbuild --web --allowimplicitany)",
|
"build": "(tsbuild --web)",
|
||||||
"buildDocs": "tsdoc"
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -31,21 +31,21 @@
|
|||||||
"cli tool"
|
"cli tool"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbuild": "^2.6.4",
|
"@git.zone/tsbuild": "^4.4.0",
|
||||||
"@git.zone/tsrun": "^1.3.3",
|
"@git.zone/tsrun": "^2.0.2",
|
||||||
"@git.zone/tstest": "^2.3.4",
|
"@git.zone/tstest": "^3.6.3",
|
||||||
"@push.rocks/tapbundle": "^6.0.3",
|
"@types/node": "^25.6.0"
|
||||||
"@types/node": "^22.14.1"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@push.rocks/lik": "^6.2.2",
|
"@push.rocks/lik": "^6.4.1",
|
||||||
"@push.rocks/smartfile": "^11.2.5",
|
"@push.rocks/smartfile": "^13.1.3",
|
||||||
"@push.rocks/smartfm": "^2.2.2",
|
"@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/smartinteract": "^2.0.16",
|
||||||
"@push.rocks/smartobject": "^1.0.12",
|
"@push.rocks/smartobject": "^1.0.12",
|
||||||
"@push.rocks/smartpromise": "^4.2.3",
|
"@push.rocks/smartpromise": "^4.2.3",
|
||||||
"@push.rocks/smartshell": "^3.3.0",
|
"@push.rocks/smartshell": "^3.3.8",
|
||||||
"@push.rocks/smartyaml": "^3.0.4"
|
"@push.rocks/smartyaml": "^3.0.4"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
@@ -57,6 +57,8 @@
|
|||||||
"dist_ts_web/**/*",
|
"dist_ts_web/**/*",
|
||||||
"assets/**/*",
|
"assets/**/*",
|
||||||
"cli.js",
|
"cli.js",
|
||||||
|
".smartconfig.json",
|
||||||
|
"license",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
],
|
],
|
||||||
@@ -64,8 +66,5 @@
|
|||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 1 chrome versions"
|
"last 1 chrome versions"
|
||||||
],
|
],
|
||||||
"packageManager": "pnpm@10.7.0+sha512.6b865ad4b62a1d9842b61d674a393903b871d9244954f652b8842c2b553c72176b278f64c463e52d40fff8aba385c235c8c9ecf5cc7de4fd78b8bb6d49633ab6",
|
"packageManager": "pnpm@10.28.2"
|
||||||
"pnpm": {
|
|
||||||
"overrides": {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+2107
-4478
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -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 path from 'path';
|
||||||
|
|
||||||
import * as smartscaf from '../ts/index.js';
|
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'));
|
await testScafTemplate.writeToDisk(path.resolve('./test/test_output'));
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
export default tap.start();
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartscaf',
|
name: '@push.rocks/smartscaf',
|
||||||
version: '4.0.21',
|
version: '4.0.22',
|
||||||
description: 'A project aimed at quickly scaffolding projects with support for TypeScript, smart file handling, and template rendering.'
|
description: 'A project aimed at quickly scaffolding projects with support for TypeScript, smart file handling, and template rendering.'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,31 +15,37 @@ export class ScafTemplate {
|
|||||||
/**
|
/**
|
||||||
* the name of the template
|
* the name of the template
|
||||||
*/
|
*/
|
||||||
public name: string;
|
public name = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the descriptions of the template
|
* the descriptions of the template
|
||||||
*/
|
*/
|
||||||
public description: string;
|
public description = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the location on disk of the template
|
* the location on disk of the template
|
||||||
*/
|
*/
|
||||||
public dirPath: string;
|
public dirPath: string;
|
||||||
public destinationPath: string;
|
public destinationPath?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* smartscafFile
|
* smartscafFile
|
||||||
*/
|
*/
|
||||||
public smartscafFile: interfaces.ISmartscafFile;
|
public smartscafFile: interfaces.ISmartscafFile = {
|
||||||
|
defaults: {},
|
||||||
|
dependencies: {
|
||||||
|
merge: [],
|
||||||
|
},
|
||||||
|
runafter: [],
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the files of the template as array of Smartfiles
|
* the files of the template as array of Smartfiles
|
||||||
*/
|
*/
|
||||||
public templateSmartfileArray: plugins.smartfile.SmartFile[];
|
public templateSmartfileArray: plugins.smartfile.SmartFile[] = [];
|
||||||
public requiredVariables: string[];
|
public requiredVariables: string[] = [];
|
||||||
public defaultVariables: any;
|
public defaultVariables: Record<string, unknown> = {};
|
||||||
public suppliedVariables: any = {};
|
public suppliedVariables: Record<string, unknown> = {};
|
||||||
public missingVariables: string[] = [];
|
public missingVariables: string[] = [];
|
||||||
|
|
||||||
constructor(dirPathArg: string) {
|
constructor(dirPathArg: string) {
|
||||||
@@ -50,10 +56,10 @@ export class ScafTemplate {
|
|||||||
* read a template from a directory
|
* read a template from a directory
|
||||||
*/
|
*/
|
||||||
public async readTemplateFromDir() {
|
public async readTemplateFromDir() {
|
||||||
this.templateSmartfileArray = await plugins.smartfile.fs.fileTreeToObject(
|
const templateVirtualDirectory = await plugins.smartFileFactory.virtualDirectoryFromPath(
|
||||||
this.dirPath,
|
this.dirPath,
|
||||||
'**/*',
|
|
||||||
);
|
);
|
||||||
|
this.templateSmartfileArray = templateVirtualDirectory.listFiles();
|
||||||
|
|
||||||
// read .smartscaf.yml file
|
// read .smartscaf.yml file
|
||||||
let smartscafFile: interfaces.ISmartscafFile = {
|
let smartscafFile: interfaces.ISmartscafFile = {
|
||||||
@@ -90,7 +96,7 @@ export class ScafTemplate {
|
|||||||
* 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
|
||||||
*/
|
*/
|
||||||
public async supplyVariables(variablesArg) {
|
public async supplyVariables(variablesArg: Record<string, unknown>) {
|
||||||
this.suppliedVariables = {
|
this.suppliedVariables = {
|
||||||
...this.suppliedVariables,
|
...this.suppliedVariables,
|
||||||
...variablesArg,
|
...variablesArg,
|
||||||
@@ -168,11 +174,11 @@ export class ScafTemplate {
|
|||||||
// Postprocess: convert {-{ back to {{
|
// Postprocess: convert {-{ back to {{
|
||||||
const finalContent = await plugins.smarthbs.postprocess(parsedTemplate.content);
|
const finalContent = await plugins.smarthbs.postprocess(parsedTemplate.content);
|
||||||
|
|
||||||
renderedFiles.push(new plugins.smartfile.SmartFile({
|
renderedFiles.push(plugins.smartFileFactory.fromBuffer(
|
||||||
path: finalPath,
|
finalPath,
|
||||||
contentBuffer: Buffer.from(finalContent),
|
Buffer.from(finalContent),
|
||||||
base: smartfile.base,
|
smartfile.base,
|
||||||
}));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
return renderedFiles;
|
return renderedFiles;
|
||||||
@@ -182,7 +188,7 @@ export class ScafTemplate {
|
|||||||
* writes a file to disk
|
* writes a file to disk
|
||||||
* @param destinationDirArg
|
* @param destinationDirArg
|
||||||
*/
|
*/
|
||||||
public async writeToDisk(destinationDirArg) {
|
public async writeToDisk(destinationDirArg: string) {
|
||||||
this.destinationPath = destinationDirArg;
|
this.destinationPath = destinationDirArg;
|
||||||
const smartfileArrayToWrite: plugins.smartfile.SmartFile[] = [];
|
const smartfileArrayToWrite: plugins.smartfile.SmartFile[] = [];
|
||||||
for (const smartfile of this.templateSmartfileArray) {
|
for (const smartfile of this.templateSmartfileArray) {
|
||||||
@@ -214,10 +220,10 @@ export class ScafTemplate {
|
|||||||
smartfileArrayToWrite.push(smartfile);
|
smartfileArrayToWrite.push(smartfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
await plugins.smartfile.memory.smartfileArrayToFs(
|
const virtualDirectoryToWrite = plugins.smartFileFactory.virtualDirectoryFromFileArray(
|
||||||
smartfileArrayToWrite,
|
smartfileArrayToWrite,
|
||||||
destinationDirArg,
|
|
||||||
);
|
);
|
||||||
|
await virtualDirectoryToWrite.saveToDisk(destinationDirArg);
|
||||||
await this.runScripts();
|
await this.runScripts();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,17 +308,16 @@ export class ScafTemplate {
|
|||||||
for (const dependency of this.smartscafFile.dependencies.merge) {
|
for (const dependency of this.smartscafFile.dependencies.merge) {
|
||||||
console.log(`Now resolving ${dependency}`);
|
console.log(`Now resolving ${dependency}`);
|
||||||
const templatePathToMerge = plugins.path.join(this.dirPath, dependency);
|
const templatePathToMerge = plugins.path.join(this.dirPath, dependency);
|
||||||
if (!plugins.smartfile.fs.isDirectory(templatePathToMerge)) {
|
if (!(await plugins.smartFs.directory(templatePathToMerge).exists())) {
|
||||||
console.log(
|
console.log(
|
||||||
`dependency ${dependency} resolves to ${templatePathToMerge} which ist NOT a directory`,
|
`dependency ${dependency} resolves to ${templatePathToMerge} which ist NOT a directory`,
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const templateSmartfileArray =
|
const templateVirtualDirectoryToMerge = await plugins.smartFileFactory.virtualDirectoryFromPath(
|
||||||
await plugins.smartfile.fs.fileTreeToObject(
|
templatePathToMerge,
|
||||||
templatePathToMerge,
|
);
|
||||||
'**/*',
|
const templateSmartfileArray = templateVirtualDirectoryToMerge.listFiles();
|
||||||
);
|
|
||||||
this.templateSmartfileArray = this.templateSmartfileArray.concat(
|
this.templateSmartfileArray = this.templateSmartfileArray.concat(
|
||||||
templateSmartfileArray,
|
templateSmartfileArray,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import * as path from 'path';
|
|||||||
import * as lik from '@push.rocks/lik';
|
import * as lik from '@push.rocks/lik';
|
||||||
import * as smartfile from '@push.rocks/smartfile';
|
import * as smartfile from '@push.rocks/smartfile';
|
||||||
import * as smartfm from '@push.rocks/smartfm';
|
import * as smartfm from '@push.rocks/smartfm';
|
||||||
|
import * as smartfs from '@push.rocks/smartfs';
|
||||||
import * as smarthbs from '@push.rocks/smarthbs';
|
import * as smarthbs from '@push.rocks/smarthbs';
|
||||||
import * as smartinteract from '@push.rocks/smartinteract';
|
import * as smartinteract from '@push.rocks/smartinteract';
|
||||||
import * as smartobject from '@push.rocks/smartobject';
|
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 smartyaml from '@push.rocks/smartyaml';
|
||||||
import * as smartshell from '@push.rocks/smartshell';
|
import * as smartshell from '@push.rocks/smartshell';
|
||||||
|
|
||||||
|
export const smartFileFactory = smartfile.SmartFileFactory.nodeFs();
|
||||||
|
export const smartFs = smartFileFactory.getSmartFs() as smartfs.SmartFs;
|
||||||
|
|
||||||
export {
|
export {
|
||||||
path,
|
path,
|
||||||
lik,
|
lik,
|
||||||
smartfile,
|
smartfile,
|
||||||
smartfm,
|
smartfm,
|
||||||
|
smartfs,
|
||||||
smarthbs,
|
smarthbs,
|
||||||
smartinteract,
|
smartinteract,
|
||||||
smartobject,
|
smartobject,
|
||||||
|
|||||||
+2
-2
@@ -6,10 +6,10 @@
|
|||||||
"target": "ES2022",
|
"target": "ES2022",
|
||||||
"module": "NodeNext",
|
"module": "NodeNext",
|
||||||
"moduleResolution": "NodeNext",
|
"moduleResolution": "NodeNext",
|
||||||
|
"noImplicitAny": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"verbatimModuleSyntax": true,
|
"verbatimModuleSyntax": true,
|
||||||
"baseUrl": ".",
|
"types": ["node"]
|
||||||
"paths": {}
|
|
||||||
},
|
},
|
||||||
"exclude": ["dist_*/**/*.d.ts"]
|
"exclude": ["dist_*/**/*.d.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user