Skip to content

Commit 62a4a99

Browse files
committed
Merge branch 'master' of github-magebit:magebitcom/magento-toolbox into feature/xml-snippets
2 parents 24b3caf + aad3da5 commit 62a4a99

File tree

151 files changed

+3348
-356
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+3348
-356
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
steps:
2727
- name: Checkout
2828
uses: actions/checkout@v4
29+
- name: Install
30+
run: npm install
2931
- name: Publish
3032
run: npm run deploy
3133
env:

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,33 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
66

77
## [Unreleased]
88

9+
- Added: Event name autocomplete
10+
11+
## [1.5.0] - 2025-04-06
12+
- Added: Class namespace autocomplete in XML files
13+
- Added: Module name autocomplete in module.xml files
14+
- Added: Module hover information
15+
- Added: Added extension config fields for enabling/disabling completions, definitions and hovers
16+
- Added: acl.xml indexer, definitions, autocomplete and hovers
17+
- Added: template file indexer, definitions and autocomplete
18+
- Added: Index data persistance
19+
- Changed: Adjusted namespace indexer logic
20+
21+
## [1.4.0] - 2025-04-04
22+
- Added: Generator command for a ViewModel class
23+
- Added: Generator command for data patches
24+
- Added: Generator command for cron jobs
25+
- Added: Jump-to-definition for magento modules (in module.xml and routes.xml)
26+
- Fixed: Method plugin hover messages are now grouped and include a link to di.xml
27+
28+
## [1.3.1] - 2025-03-23
29+
- Fixed: Generated plugin class arguments contain an incorrect namespace
30+
31+
## [1.3.0] - 2025-03-17
32+
933
- Added: Jump to module command
34+
- Changed: All dropdown inputs now support searching
35+
- Changed: Migrated ejs templates to handlebars
1036

1137
## [1.2.0] - 2025-03-13
1238

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,28 @@
44
"description": "Magento 2 code generation, inspection and utility tools",
55
"publisher": "magebit",
66
"icon": "resources/logo.jpg",
7-
"version": "1.2.0",
7+
"version": "1.5.0",
88
"engines": {
99
"vscode": "^1.93.1"
1010
},
1111
"repository": {
1212
"type": "git",
1313
"url": "https://github.com/magebitcom/magento-toolbox.git"
1414
},
15+
"homepage": "https://github.com/magebitcom/magento-toolbox",
16+
"bugs": {
17+
"url": "https://github.com/magebitcom/magento-toolbox/issues"
18+
},
1519
"categories": [
1620
"Other"
1721
],
22+
"keywords": [
23+
"magento",
24+
"adobe commerce",
25+
"code completion",
26+
"code generation",
27+
"intellisense"
28+
],
1829
"activationEvents": [
1930
"workspaceContains:**/app/etc/env.php",
2031
"workspaceContains:**/app/etc/di.xml",
@@ -41,6 +52,21 @@
4152
"editPresentation": "multilineText",
4253
"default": "",
4354
"markdownDescription": "`%module%` will be replaced with the module name. \n\n **Do not add comment symbols like `<!--` or `-->`, they will be added automatically.**"
55+
},
56+
"magento-toolbox.provideXmlCompletions": {
57+
"type": "boolean",
58+
"default": true,
59+
"description": "Enable autocomplete for Magento 2 XML files."
60+
},
61+
"magento-toolbox.provideXmlDefinitions": {
62+
"type": "boolean",
63+
"default": true,
64+
"description": "Enable definitions for Magento 2 XML files."
65+
},
66+
"magento-toolbox.provideXmlHovers": {
67+
"type": "boolean",
68+
"default": true,
69+
"description": "Enable hover decorations for Magento 2 XML files."
4470
}
4571
}
4672
},
@@ -65,6 +91,11 @@
6591
"title": "Generate Block",
6692
"category": "Magento Toolbox"
6793
},
94+
{
95+
"command": "magento-toolbox.generateViewModel",
96+
"title": "Generate ViewModel",
97+
"category": "Magento Toolbox"
98+
},
6899
{
69100
"command": "magento-toolbox.indexWorkspace",
70101
"title": "Index Workspace",
@@ -190,6 +221,16 @@
190221
"title": "Generate Sample config.xml",
191222
"category": "Magento Toolbox"
192223
},
224+
{
225+
"command": "magento-toolbox.generateDataPatch",
226+
"title": "Generate Data Patch",
227+
"category": "Magento Toolbox"
228+
},
229+
{
230+
"command": "magento-toolbox.generateCronJob",
231+
"title": "Generate Cron Job",
232+
"category": "Magento Toolbox"
233+
},
193234
{
194235
"command": "magento-toolbox.jumpToModule",
195236
"title": "Jump to Module",
@@ -244,6 +285,10 @@
244285
"command": "magento-toolbox.generateBlock",
245286
"when": "resourcePath =~ /app\\/code\\/.+\\/.+/i"
246287
},
288+
{
289+
"command": "magento-toolbox.generateViewModel",
290+
"when": "resourcePath =~ /app\\/code\\/.+\\/.+/i"
291+
},
247292
{
248293
"command": "magento-toolbox.generateEventsXml",
249294
"when": "resourcePath =~ /app\\/code\\/.+\\/.+/i"
@@ -319,6 +364,14 @@
319364
{
320365
"command": "magento-toolbox.generateConfigXmlFile",
321366
"when": "resourcePath =~ /app\\/code\\/.+\\/.+/i"
367+
},
368+
{
369+
"command": "magento-toolbox.generateDataPatch",
370+
"when": "resourcePath =~ /app\\/code\\/.+\\/.+/i"
371+
},
372+
{
373+
"command": "magento-toolbox.generateCronJob",
374+
"when": "resourcePath =~ /app\\/code\\/.+\\/.+/i"
322375
}
323376
]
324377
}
Lines changed: 3 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,20 @@
11
import { Command } from 'command/Command';
2-
import IndexManager from 'indexer/IndexManager';
3-
import ModuleIndexer from 'indexer/module/ModuleIndexer';
2+
import GetMagentoPath from 'common/GetMagentoPath';
43
import { Uri, window, env } from 'vscode';
54

65
export default class CopyMagentoPathCommand extends Command {
7-
public static readonly TEMPLATE_EXTENSIONS = ['.phtml'];
8-
public static readonly WEB_EXTENSIONS = ['.css', '.js'];
9-
public static readonly IMAGE_EXTENSIONS = ['.png', '.jpg', '.jpeg', '.gif', '.svg'];
10-
11-
private static readonly TEMPLATE_PATHS = [
12-
'view/frontend/templates/',
13-
'view/adminhtml/templates/',
14-
'view/base/templates/',
15-
'templates/',
16-
];
17-
18-
private static readonly WEB_PATHS = [
19-
'view/frontend/web/',
20-
'view/adminhtml/web/',
21-
'view/base/web/',
22-
'web/',
23-
];
24-
256
constructor() {
267
super('magento-toolbox.copyMagentoPath');
278
}
289

2910
public async execute(file: Uri): Promise<void> {
30-
if (!file) {
31-
return;
32-
}
33-
34-
const moduleIndexData = IndexManager.getIndexData(ModuleIndexer.KEY);
35-
36-
if (!moduleIndexData) {
37-
return;
38-
}
39-
40-
const module = moduleIndexData.getModuleByUri(file);
41-
42-
if (!module) {
43-
return;
44-
}
11+
const magentoPath = GetMagentoPath.getMagentoPath(file);
4512

46-
const paths = this.getPaths(file);
47-
48-
if (!paths) {
13+
if (!magentoPath) {
4914
return;
5015
}
5116

52-
const pathIndex = paths.findIndex(p => file.fsPath.lastIndexOf(p) !== -1);
53-
54-
if (pathIndex === -1) {
55-
return;
56-
}
57-
58-
const endIndex = file.fsPath.lastIndexOf(paths[pathIndex]);
59-
const offset = paths[pathIndex].length;
60-
const relativePath = file.fsPath.slice(offset + endIndex);
61-
62-
const magentoPath = `${module.name}::${relativePath}`;
63-
6417
await env.clipboard.writeText(magentoPath);
6518
window.showInformationMessage(`Copied: ${magentoPath}`);
6619
}
67-
68-
private getPaths(file: Uri): string[] | undefined {
69-
if (CopyMagentoPathCommand.TEMPLATE_EXTENSIONS.some(ext => file.fsPath.endsWith(ext))) {
70-
return CopyMagentoPathCommand.TEMPLATE_PATHS;
71-
}
72-
73-
if (
74-
CopyMagentoPathCommand.WEB_EXTENSIONS.some(ext => file.fsPath.endsWith(ext)) ||
75-
CopyMagentoPathCommand.IMAGE_EXTENSIONS.some(ext => file.fsPath.endsWith(ext))
76-
) {
77-
return CopyMagentoPathCommand.WEB_PATHS;
78-
}
79-
80-
return undefined;
81-
}
8220
}

src/command/GenerateAclXmlFileCommand.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { SimpleTemplateGeneratorCommand } from './SimpleTemplateGeneratorCommand';
22
import { TemplateWizardData } from 'wizard/SimpleTemplateWizard';
3+
import { TemplatePath } from 'types/handlebars';
34

45
export default class GenerateAclXmlFileCommand extends SimpleTemplateGeneratorCommand {
56
constructor() {
@@ -16,7 +17,7 @@ export default class GenerateAclXmlFileCommand extends SimpleTemplateGeneratorCo
1617
return `app/code/${vendor}/${module}/etc/acl.xml`;
1718
}
1819

19-
getTemplateName(data: TemplateWizardData): string {
20-
return 'xml/blank-acl';
20+
getTemplateName(data: TemplateWizardData): TemplatePath {
21+
return TemplatePath.XmlBlankAcl;
2122
}
2223
}

src/command/GenerateConfigXmlFileCommand.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { SimpleTemplateGeneratorCommand } from './SimpleTemplateGeneratorCommand';
22
import { TemplateWizardData } from 'wizard/SimpleTemplateWizard';
33
import FileHeader from 'common/xml/FileHeader';
4+
import { TemplatePath } from 'types/handlebars';
45

56
export default class GenerateConfigXmlFileCommand extends SimpleTemplateGeneratorCommand {
67
constructor() {
@@ -21,7 +22,7 @@ export default class GenerateConfigXmlFileCommand extends SimpleTemplateGenerato
2122
return `app/code/${vendor}/${module}/etc/config.xml`;
2223
}
2324

24-
getTemplateName(data: TemplateWizardData): string {
25-
return 'xml/blank-config';
25+
getTemplateName(data: TemplateWizardData): TemplatePath {
26+
return TemplatePath.XmlBlankConfig;
2627
}
2728
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { Command } from 'command/Command';
2+
import CronJobWizard, { CronJobWizardData } from 'wizard/CronJobWizard';
3+
import WizzardClosedError from 'webview/error/WizzardClosedError';
4+
import FileGeneratorManager from 'generator/FileGeneratorManager';
5+
import Common from 'util/Common';
6+
import { Uri, window } from 'vscode';
7+
import CronJobClassGenerator from 'generator/cronJob/CronJobClassGenerator';
8+
import CronJobXmlGenerator from 'generator/cronJob/CronJobXmlGenerator';
9+
import IndexManager from 'indexer/IndexManager';
10+
import ModuleIndexer from 'indexer/module/ModuleIndexer';
11+
12+
export default class GenerateCronJobCommand extends Command {
13+
constructor() {
14+
super('magento-toolbox.generateCronJob');
15+
}
16+
17+
public async execute(uri?: Uri): Promise<void> {
18+
const moduleIndex = IndexManager.getIndexData(ModuleIndexer.KEY);
19+
let contextModule: string | undefined;
20+
21+
const contextUri = uri || window.activeTextEditor?.document.uri;
22+
23+
if (moduleIndex && contextUri) {
24+
const module = moduleIndex.getModuleByUri(contextUri);
25+
26+
if (module) {
27+
contextModule = module.name;
28+
}
29+
}
30+
31+
const cronJobWizard = new CronJobWizard();
32+
33+
let data: CronJobWizardData;
34+
35+
try {
36+
data = await cronJobWizard.show(contextModule);
37+
} catch (error) {
38+
if (error instanceof WizzardClosedError) {
39+
return;
40+
}
41+
42+
throw error;
43+
}
44+
45+
const manager = new FileGeneratorManager([
46+
new CronJobClassGenerator(data),
47+
new CronJobXmlGenerator(data),
48+
]);
49+
50+
const workspaceFolder = Common.getActiveWorkspaceFolder();
51+
52+
if (!workspaceFolder) {
53+
window.showErrorMessage('No active workspace folder');
54+
return;
55+
}
56+
57+
await manager.generate(workspaceFolder.uri);
58+
await manager.writeFiles();
59+
await manager.refreshIndex(workspaceFolder);
60+
manager.openAllFiles();
61+
}
62+
}

src/command/GenerateCrontabXmlCommand.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { SimpleTemplateGeneratorCommand } from './SimpleTemplateGeneratorCommand';
22
import { TemplateWizardData } from 'wizard/SimpleTemplateWizard';
33
import FileHeader from 'common/xml/FileHeader';
4+
import { TemplatePath } from 'types/handlebars';
45

56
export default class GenerateCrontabXmlCommand extends SimpleTemplateGeneratorCommand {
67
constructor() {
@@ -21,7 +22,7 @@ export default class GenerateCrontabXmlCommand extends SimpleTemplateGeneratorCo
2122
return `app/code/${vendor}/${module}/etc/crontab.xml`;
2223
}
2324

24-
getTemplateName(data: TemplateWizardData): string {
25-
return 'xml/blank-crontab';
25+
getTemplateName(data: TemplateWizardData): TemplatePath {
26+
return TemplatePath.XmlBlankCrontab;
2627
}
2728
}

0 commit comments

Comments
 (0)