Skip to content

698: Add "module" prefix to module name in composer.json #848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 16, 2021
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public class NewModuleDialog extends AbstractDialog implements ListSelectionList
private static final String MODULE_VERSION = "module version";
private static final String MODULE_NAME = "module name";
private static final String PACKAGE_NAME = "package name";
private static final String MAGENTO_BEFORE_DECLARATIVE_SCHEMA_VERSION = "2.2.11";
private static final String DEFAULT_MODULE_PREFIX = "module";

@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
message = {NotEmptyRule.MESSAGE, PACKAGE_NAME})
Expand Down Expand Up @@ -106,7 +108,6 @@ public class NewModuleDialog extends AbstractDialog implements ListSelectionList
private String detectedPackageName;
private final ModuleIndex moduleIndex;
private final CamelCaseToHyphen camelCaseToHyphen;
private static final String MAGENTO_BEFORE_DECLARATIVE_SCHEMA_VERSION = "2.2.11";

/**
* Constructor.
Expand Down Expand Up @@ -245,6 +246,11 @@ public String getPackageName() {
return this.packageName.getText().trim();
}

/**
* Getter for Module Name.
*
* @return String
*/
public String getModuleName() {
return this.moduleName.getText().trim();
}
Expand Down Expand Up @@ -332,6 +338,7 @@ public static void open(
private String getComposerPackageName() {
return camelCaseToHyphen.convert(getPackageName())
.concat("/")
.concat(DEFAULT_MODULE_PREFIX + "-")
.concat(camelCaseToHyphen.convert(getModuleName()));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "test/module",
"name": "test/module-test",
"version": "1.0.0-dev",
"description": "test-description",
"type": "magento2-module",
Expand All @@ -17,7 +17,7 @@
"registration.php"
],
"psr-4": {
"TestWithDependencies\\Module\\": ""
"TestWithDependencies\\Test\\": ""
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "test/module",
"name": "test/module-test",
"version": "1.0.0-dev",
"description": "test-description",
"type": "magento2-module",
Expand All @@ -17,7 +17,7 @@
"registration.php"
],
"psr-4": {
"TestWithDependencies\\Module\\": ""
"TestWithDependencies\\Test\\": ""
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "test/module",
"name": "test/module-test",
"version": "1.0.0-dev",
"description": "test-description",
"type": "magento2-module",
Expand All @@ -15,7 +15,7 @@
"registration.php"
],
"psr-4": {
"TestWithoutDependencies\\Module\\": ""
"TestWithoutDependencies\\Test\\": ""
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void testGenerateModuleFile() {
final PsiDirectory projectDir = getProjectDirectory();

final String expectedDirectory =
projectDir.getVirtualFile().getPath() + "/TestWithDependencies/Module";
projectDir.getVirtualFile().getPath() + "/TestWithDependencies/Test";
final PsiFile composerJson = generateComposerJson(
true,
projectDir,
Expand Down Expand Up @@ -65,7 +65,7 @@ public void testGenerateModuleFileWithoutDependencies() {
final PsiFile expectedFile = myFixture.configureByFile(filePath);
final PsiDirectory projectDir = getProjectDirectory();
final String expectedDirectory = projectDir.getVirtualFile().getPath()
+ "/TestWithoutDependencies/Module";
+ "/TestWithoutDependencies/Test";
final PsiFile composerJson = generateComposerJson(
true,
projectDir,
Expand Down Expand Up @@ -102,10 +102,10 @@ private PsiFile generateComposerJson(
);
final ModuleComposerJsonData composerJsonData = new ModuleComposerJsonData(
packageName,
"Module",
"Test",
projectDir,
"test-description",
"test/module",
"test/module-test",
"1.0.0-dev",
licenses,
dependencies,
Expand Down