Skip to content

Commit 48e6aff

Browse files
committed
chore: moved types to a separate directory
1 parent d7a27b4 commit 48e6aff

39 files changed

+67
-42
lines changed

src/command/GenerateDiXmlFileCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MagentoScope } from 'types';
1+
import { MagentoScope } from 'types/global';
22
import { SimpleTemplateGeneratorCommand } from './SimpleTemplateGeneratorCommand';
33
import { TemplateWizardData } from 'wizard/SimpleTemplateWizard';
44

src/command/GenerateEventsXmlCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { SimpleTemplateGeneratorCommand } from './SimpleTemplateGeneratorCommand';
22
import { TemplateWizardData } from 'wizard/SimpleTemplateWizard';
3-
import { MagentoScope } from 'types';
3+
import { MagentoScope } from 'types/global';
44
import FileHeader from 'common/xml/FileHeader';
55

66
export default class GenerateEventsXmlCommand extends SimpleTemplateGeneratorCommand {

src/command/GenerateLayoutXmlCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { MagentoScope } from 'types';
1+
import { MagentoScope } from 'types/global';
22
import { SimpleTemplateGeneratorCommand } from './SimpleTemplateGeneratorCommand';
33
import { TemplateWizardData } from 'wizard/SimpleTemplateWizard';
4-
import { WizardField, WizardValidationRule } from 'webview/types';
4+
import { WizardField, WizardValidationRule } from 'types/webview';
55
import { WizardFieldBuilder } from 'webview/WizardFieldBuilder';
66
import FileHeader from 'common/xml/FileHeader';
77

src/command/GenerateRoutesXmlFileCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { SimpleTemplateGeneratorCommand } from './SimpleTemplateGeneratorCommand';
22
import { TemplateWizardData } from 'wizard/SimpleTemplateWizard';
3-
import { MagentoScope } from 'types';
3+
import { MagentoScope } from 'types/global';
44
import FileHeader from 'common/xml/FileHeader';
55
import { WizardFieldBuilder } from 'webview/WizardFieldBuilder';
6-
import { WizardField, WizardValidationRule } from 'webview/types';
6+
import { WizardField, WizardValidationRule } from 'types/webview';
77

88
export default class GenerateRoutesXmlFileCommand extends SimpleTemplateGeneratorCommand {
99
constructor() {

src/command/SimpleTemplateGeneratorCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import FileGeneratorManager from 'generator/FileGeneratorManager';
66
import TemplateGenerator from 'generator/TemplateGenerator';
77
import Common from 'util/Common';
88
import SimpleTemplateWizard, { TemplateWizardData } from 'wizard/SimpleTemplateWizard';
9-
import { MagentoScope } from 'types';
10-
import { WizardField, WizardValidationRule } from 'webview/types';
9+
import { MagentoScope } from 'types/global';
10+
import { WizardField, WizardValidationRule } from 'types/webview';
1111

1212
export abstract class SimpleTemplateGeneratorCommand extends Command {
1313
abstract getWizardTitle(): string;

src/generator/HandlebarsTemplateRenderer.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,24 @@ export default class HandlebarsTemplateRenderer {
1010
public constructor() {
1111
this.handlebars = create();
1212
this.registerHelpers();
13-
this.registerPartials();
13+
this.registerGlobalPartials();
1414
}
1515

16-
public async render(template: string, data?: Record<string, any>): Promise<string> {
16+
public async render(
17+
template: string,
18+
data?: Record<string, any>,
19+
partials?: Record<string, string>
20+
): Promise<string> {
1721
try {
1822
const templatePath = this.getTemplatePath(template);
1923
const templateContent = await FileSystem.readFile(Uri.file(templatePath));
24+
25+
if (partials) {
26+
for (const [name, content] of Object.entries(partials)) {
27+
this.handlebars.registerPartial(name, content + '\n');
28+
}
29+
}
30+
2031
const compiledTemplate = this.handlebars.compile(templateContent);
2132
const content = compiledTemplate(data);
2233
return content;
@@ -39,7 +50,7 @@ export default class HandlebarsTemplateRenderer {
3950
});
4051
}
4152

42-
protected registerPartials(): void {
53+
protected registerGlobalPartials(): void {
4354
this.handlebars.registerPartial('fileHeader', '{{#if fileHeader}}\n{{{fileHeader}}}\n{{/if}}');
4455
}
4556
}

src/generator/plugin/PluginDiGenerator.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,26 @@ export default class PluginDiGenerator extends FileGenerator {
3333

3434
const renderer = new HandlebarsTemplateRenderer();
3535

36-
const pluginXml = await renderer.render('xml/plugin', {
36+
const pluginXml = await renderer.render('xml/di/plugin', {
3737
pluginName: this.data.name,
3838
pluginType: pluginType.toString(),
3939
sortOrder: this.data.sortOrder,
40-
subjectNamespace,
4140
});
4241

42+
const diType = await renderer.render(
43+
'xml/di/type',
44+
{
45+
subjectNamespace,
46+
},
47+
{
48+
typeContent: pluginXml,
49+
}
50+
);
51+
4352
const newDiXml =
4453
diXml.slice(0, insertPosition) +
4554
'\n' +
46-
indentString(pluginXml, 4) +
55+
indentString(diType, 4) +
4756
'\n' +
4857
diXml.slice(insertPosition);
4958

src/generator/util/FindOrCreateDiXml.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Uri } from 'vscode';
22
import FileSystem from 'util/FileSystem';
33
import FileHeader from 'common/xml/FileHeader';
4-
import { MagentoScope } from 'types';
4+
import { MagentoScope } from 'types/global';
55
import Magento from 'util/Magento';
66
import HandlebarsTemplateRenderer from '../HandlebarsTemplateRenderer';
77

src/generator/util/FindOrCreateEventsXml.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Uri } from 'vscode';
22
import FileSystem from 'util/FileSystem';
3-
import { MagentoScope } from 'types';
3+
import { MagentoScope } from 'types/global';
44
import FileHeader from 'common/xml/FileHeader';
55
import HandlebarsTemplateRenderer from '../HandlebarsTemplateRenderer';
66

src/indexer/module/ModuleIndexData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { WizardSelectOption } from 'webview/types';
1+
import { WizardSelectOption } from 'types/webview';
22
import { Module } from './types';
33
import { Uri } from 'vscode';
44
import { AbstractIndexData } from 'indexer/AbstractIndexData';

0 commit comments

Comments
 (0)