BREAKING CHANGE(core): switch to esm

This commit is contained in:
2022-06-25 03:19:16 +02:00
parent d33f943fc6
commit 5f1bc8dc29
17 changed files with 11191 additions and 1041 deletions

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@pushrocks/smartscaf',
version: '4.0.0',
description: 'scaffold projects quickly'
}

View File

@ -1 +1 @@
export * from './smartscaf.classes.smartscaf';
export * from './smartscaf.classes.smartscaf.js';

View File

@ -1 +1 @@
export * from './smartscaf';
export * from './smartscaf.js';

View File

@ -1,5 +1,5 @@
import * as plugins from './smartscaf.plugins';
import * as interfaces from './interfaces';
import * as plugins from './smartscaf.plugins.js';
import * as interfaces from './interfaces/index.js';
// interfaces
import { Smartfile } from '@pushrocks/smartfile';
@ -57,19 +57,21 @@ export class ScafTemplate {
let smartscafFile: interfaces.ISmartscafFile = {
defaults: {},
dependencies: {
merge: []
merge: [],
},
runafter: []
runafter: [],
};
const smartscafSmartfile = this.templateSmartfileArray.find(smartfileArg => {
const smartscafSmartfile = this.templateSmartfileArray.find((smartfileArg) => {
return smartfileArg.parsedPath.base === '.smartscaf.yml';
});
if (smartscafSmartfile) {
smartscafFile = {
...smartscafFile,
...(await plugins.smartyaml.yamlStringToObject(smartscafSmartfile.contentBuffer.toString()))
...(await plugins.smartyaml.yamlStringToObject(
smartscafSmartfile.contentBuffer.toString()
)),
};
}
this.smartscafFile = smartscafFile;
@ -87,7 +89,7 @@ export class ScafTemplate {
public async supplyVariables(variablesArg) {
this.suppliedVariables = {
...this.suppliedVariables,
...variablesArg
...variablesArg,
};
this.missingVariables = await this._checkSuppliedVariables();
}
@ -110,14 +112,15 @@ export class ScafTemplate {
return 'undefined variable';
}
})(),
message: `What is the value of ${missingVariable}?`
}
message: `What is the value of ${missingVariable}?`,
},
]);
}
const answerBucket = await localSmartInteract.runQueue();
await answerBucket.answerMap.forEach(async answer => {
const answers = answerBucket.getAllAnswers();
for (const answer of answers) {
await plugins.smartparam.smartAdd(this.suppliedVariables, answer.name, answer.value);
});
}
}
/**
@ -139,7 +142,7 @@ export class ScafTemplate {
// handle frontmatter
const smartfmInstance = new plugins.smartfm.Smartfm({
fmType: 'yaml'
fmType: 'yaml',
});
const parsedTemplate = smartfmInstance.parse(renderedTemplateString) as any;
if (parsedTemplate.data.fileName) {
@ -206,7 +209,7 @@ export class ScafTemplate {
* >> - yourDeeperKey: yourValue
*/
private async _checkDefaultVariables() {
const smartscafSmartfile = this.templateSmartfileArray.find(smartfileArg => {
const smartscafSmartfile = this.templateSmartfileArray.find((smartfileArg) => {
return smartfileArg.parsedPath.base === '.smartscaf.yml';
});
@ -252,7 +255,7 @@ export class ScafTemplate {
throw new Error('cannot run scripts without an destinationdir');
}
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash'
executor: 'bash',
});
for (const command of this.smartscafFile.runafter) {
await smartshellInstance.exec(`cd ${this.destinationPath} && ${command}`);

View File

@ -19,5 +19,5 @@ export {
smartparam,
smartpromise,
smartyaml,
smartshell
smartshell,
};