|
|
|
@ -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}`);
|
|
|
|
|