Skip to content

Commit 2d25e23

Browse files
authored
Merge pull request #839 from k-j-kim/webapplications-lowercase-and-templates-update
fix: using lowercase webapplications path and updating to latest @salesforce/templates
2 parents 4039fe5 + c492e34 commit 2d25e23

5 files changed

Lines changed: 890 additions & 890 deletions

File tree

messages/webApplication.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Generate a web application.
44

55
# description
66

7-
Generates a web application in the specified directory or the current working directory. The web application files are created in a folder with the designated name. Web application files must be contained in a parent directory called "webApplications" in your package directory. Either run this command from an existing directory of this name, or use the --output-dir flag to create one or point to an existing one.
7+
Generates a web application in the specified directory or the current working directory. The web application files are created in a folder with the designated name. Web application files must be contained in a parent directory called "webapplications" in your package directory. Either run this command from an existing directory of this name, or use the --output-dir flag to create one or point to an existing one.
88

99
# examples
1010

@@ -16,9 +16,9 @@ Generates a web application in the specified directory or the current working di
1616

1717
<%= config.bin %> <%= command.id %> --name MyReactApp --template reactbasic
1818

19-
- Generate the web application in the "force-app/main/default/webApplications" directory:
19+
- Generate the web application in the "force-app/main/default/webapplications" directory:
2020

21-
<%= config.bin %> <%= command.id %> --name MyWebApp --output-dir force-app/main/default/webApplications
21+
<%= config.bin %> <%= command.id %> --name MyWebApp --output-dir force-app/main/default/webapplications
2222

2323
# flags.name.summary
2424

@@ -50,4 +50,4 @@ Directory for saving the created files.
5050

5151
# flags.output-dir.description
5252

53-
The location can be an absolute path or relative to the current working directory. If not specified, the command reads your sfdx-project.json and defaults to the webApplications directory within your default package directory. When running outside a Salesforce DX project, defaults to the current directory.
53+
The location can be an absolute path or relative to the current working directory. If not specified, the command reads your sfdx-project.json and defaults to the webapplications directory within your default package directory. When running outside a Salesforce DX project, defaults to the current directory.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dependencies": {
88
"@salesforce/core": "^8.25.0",
99
"@salesforce/sf-plugins-core": "^12",
10-
"@salesforce/templates": "^65.4.3"
10+
"@salesforce/templates": "^65.5.2"
1111
},
1212
"devDependencies": {
1313
"@oclif/plugin-command-snapshot": "^5.3.8",

src/commands/webapp/generate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ export default class WebAppGenerate extends SfCommand<CreateOutput> {
4848

4949
/**
5050
* Resolves the default output directory by reading the project's sfdx-project.json.
51-
* Returns the path to webApplications under the default package directory,
51+
* Returns the path to webapplications under the default package directory,
5252
* or falls back to the current directory if not in a project context.
5353
*/
5454
private static async getDefaultOutputDir(): Promise<string> {
5555
try {
5656
const project = await SfProject.resolve();
5757
const defaultPackage = project.getDefaultPackage();
58-
return path.join(defaultPackage.path, 'main', 'default', 'webApplications');
58+
return path.join(defaultPackage.path, 'main', 'default', 'webapplications');
5959
} catch {
6060
return '.';
6161
}

test/commands/webapp/generate.nut.ts

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,68 +23,56 @@ describe('Web application creation tests:', () => {
2323
});
2424

2525
describe('Check webapp creation with default template', () => {
26-
it('should create webapp using default template in webApplications directory', () => {
27-
const outputDir = path.join(session.project.dir, 'force-app', 'main', 'default', 'webApplications');
26+
it('should create webapp using default template in webapplications directory', () => {
27+
const outputDir = path.join(session.project.dir, 'force-app', 'main', 'default', 'webapplications');
2828
execCmd(`webapp generate --name MyWebApp --output-dir "${outputDir}"`, { ensureExitCode: 0 });
2929
assert.file([
30-
path.join(outputDir, 'MyWebApp', 'MyWebApp.webApplication-meta.xml'),
31-
path.join(outputDir, 'MyWebApp', 'index.html'),
32-
path.join(outputDir, 'MyWebApp', 'webapp.json'),
30+
path.join(outputDir, 'MyWebApp', 'MyWebApp.webapplication-meta.xml'),
31+
path.join(outputDir, 'MyWebApp', 'src', 'index.html'),
32+
path.join(outputDir, 'MyWebApp', 'webapplication.json'),
3333
]);
34-
assert.fileContent(path.join(outputDir, 'MyWebApp', 'index.html'), '<title>My Web App</title>');
34+
assert.fileContent(
35+
path.join(outputDir, 'MyWebApp', 'MyWebApp.webapplication-meta.xml'),
36+
'<masterLabel>My Web App</masterLabel>'
37+
);
3538
});
3639

37-
it('should default to project webApplications directory when --output-dir is omitted', () => {
38-
const expectedOutputDir = path.join(session.project.dir, 'force-app', 'main', 'default', 'webApplications');
40+
it('should default to project webapplications directory when --output-dir is omitted', () => {
41+
const expectedOutputDir = path.join(session.project.dir, 'force-app', 'main', 'default', 'webapplications');
3942
execCmd('webapp generate --name DefaultDirApp', { ensureExitCode: 0 });
4043
assert.file([
41-
path.join(expectedOutputDir, 'DefaultDirApp', 'DefaultDirApp.webApplication-meta.xml'),
42-
path.join(expectedOutputDir, 'DefaultDirApp', 'index.html'),
43-
path.join(expectedOutputDir, 'DefaultDirApp', 'webapp.json'),
44+
path.join(expectedOutputDir, 'DefaultDirApp', 'DefaultDirApp.webapplication-meta.xml'),
45+
path.join(expectedOutputDir, 'DefaultDirApp', 'src', 'index.html'),
46+
path.join(expectedOutputDir, 'DefaultDirApp', 'webapplication.json'),
4447
]);
4548
});
4649

4750
it('should create webapp with custom label', () => {
48-
const outputDir = path.join(session.project.dir, 'force-app', 'main', 'default', 'webApplications');
51+
const outputDir = path.join(session.project.dir, 'force-app', 'main', 'default', 'webapplications');
4952
execCmd(`webapp generate --name TestApp --label "Custom Label" --output-dir "${outputDir}"`, {
5053
ensureExitCode: 0,
5154
});
5255
assert.file([
53-
path.join(outputDir, 'TestApp', 'TestApp.webApplication-meta.xml'),
54-
path.join(outputDir, 'TestApp', 'index.html'),
56+
path.join(outputDir, 'TestApp', 'TestApp.webapplication-meta.xml'),
57+
path.join(outputDir, 'TestApp', 'src', 'index.html'),
5558
]);
56-
assert.fileContent(path.join(outputDir, 'TestApp', 'index.html'), '<title>Custom Label</title>');
59+
assert.fileContent(path.join(outputDir, 'TestApp', 'src', 'index.html'), '<title>Welcome to Web App</title>');
5760
});
5861
});
5962

6063
describe('Check webapp creation with reactbasic template', () => {
6164
it('should create React webapp with all required files', () => {
62-
const outputDir = path.join(session.project.dir, 'force-app', 'main', 'default', 'webApplications');
65+
const outputDir = path.join(session.project.dir, 'force-app', 'main', 'default', 'webapplications');
6366
execCmd(`webapp generate --name MyReactApp --template reactbasic --output-dir "${outputDir}"`, {
6467
ensureExitCode: 0,
6568
});
6669
assert.file([
67-
path.join(outputDir, 'MyReactApp', 'MyReactApp.webApplication-meta.xml'),
70+
path.join(outputDir, 'MyReactApp', 'MyReactApp.webapplication-meta.xml'),
6871
path.join(outputDir, 'MyReactApp', 'index.html'),
69-
path.join(outputDir, 'MyReactApp', 'webapp.json'),
72+
path.join(outputDir, 'MyReactApp', 'webapplication.json'),
7073
path.join(outputDir, 'MyReactApp', 'package.json'),
71-
path.join(outputDir, 'MyReactApp', 'vite.config.ts'),
72-
path.join(outputDir, 'MyReactApp', 'tsconfig.json'),
73-
path.join(outputDir, 'MyReactApp', 'tsconfig.node.json'),
74-
path.join(outputDir, 'MyReactApp', 'tailwind.config.js'),
75-
path.join(outputDir, 'MyReactApp', 'postcss.config.js'),
76-
path.join(outputDir, 'MyReactApp', 'src', 'main.tsx'),
77-
path.join(outputDir, 'MyReactApp', 'src', 'App.tsx'),
78-
path.join(outputDir, 'MyReactApp', 'src', 'routes.ts'),
79-
path.join(outputDir, 'MyReactApp', 'src', 'vite-env.d.ts'),
80-
path.join(outputDir, 'MyReactApp', 'src', 'components', 'Navigation.tsx'),
81-
path.join(outputDir, 'MyReactApp', 'src', 'pages', 'Home.tsx'),
82-
path.join(outputDir, 'MyReactApp', 'src', 'pages', 'About.tsx'),
83-
path.join(outputDir, 'MyReactApp', 'src', 'pages', 'NotFound.tsx'),
84-
path.join(outputDir, 'MyReactApp', 'src', 'styles', 'global.css'),
85-
path.join(outputDir, 'MyReactApp', 'src', 'test-setup', 'setup.ts'),
8674
]);
87-
assert.fileContent(path.join(outputDir, 'MyReactApp', 'package.json'), '"name": "MyReactApp"');
75+
assert.fileContent(path.join(outputDir, 'MyReactApp', 'package.json'), '"name": "base-react-app"');
8876
});
8977
});
9078

@@ -95,30 +83,30 @@ describe('Web application creation tests:', () => {
9583
});
9684

9785
it('should throw invalid non alphanumeric webapp name error', () => {
98-
const outputDir = path.join(session.project.dir, 'force-app', 'main', 'default', 'webApplications');
86+
const outputDir = path.join(session.project.dir, 'force-app', 'main', 'default', 'webapplications');
9987
const stderr = execCmd(`webapp generate --name /a --output-dir "${outputDir}"`).shellOutput.stderr;
10088
expect(stderr).to.contain(nls.localize('AlphaNumericNameError'));
10189
});
10290

10391
it('should throw invalid webapp name starting with numeric error', () => {
104-
const outputDir = path.join(session.project.dir, 'force-app', 'main', 'default', 'webApplications');
92+
const outputDir = path.join(session.project.dir, 'force-app', 'main', 'default', 'webapplications');
10593
const stderr = execCmd(`webapp generate --name 3aa --output-dir "${outputDir}"`).shellOutput.stderr;
10694
expect(stderr).to.contain(nls.localize('NameMustStartWithLetterError'));
10795
});
10896

10997
it('should throw invalid webapp name ending with underscore error', () => {
110-
const outputDir = path.join(session.project.dir, 'force-app', 'main', 'default', 'webApplications');
98+
const outputDir = path.join(session.project.dir, 'force-app', 'main', 'default', 'webapplications');
11199
const stderr = execCmd(`webapp generate --name a_ --output-dir "${outputDir}"`).shellOutput.stderr;
112100
expect(stderr).to.contain(nls.localize('EndWithUnderscoreError'));
113101
});
114102

115103
it('should throw invalid webapp name with double underscore error', () => {
116-
const outputDir = path.join(session.project.dir, 'force-app', 'main', 'default', 'webApplications');
104+
const outputDir = path.join(session.project.dir, 'force-app', 'main', 'default', 'webapplications');
117105
const stderr = execCmd(`webapp generate --name a__a --output-dir "${outputDir}"`).shellOutput.stderr;
118106
expect(stderr).to.contain(nls.localize('DoubleUnderscoreError'));
119107
});
120108

121-
it('should throw error when output dir is not webApplications folder', () => {
109+
it('should throw error when output dir is not webapplications folder', () => {
122110
const stderr = execCmd('webapp generate --name TestApp --output-dir /tmp/invalid').shellOutput.stderr;
123111
expect(stderr).to.contain(nls.localize('MissingWebApplicationsDir'));
124112
});

0 commit comments

Comments
 (0)