Skip to content

Commit eee2d2e

Browse files
authored
feat: rename react web app templates (#768)
Co-authored-by: mzhang0 <mzhang0@users.noreply.github.com>
1 parent 23b5996 commit eee2d2e

16 files changed

Lines changed: 89 additions & 74 deletions

File tree

.eslintrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"*.js",
6969
"src/templates/lightningcomponent/lwc/typeScript/*",
7070
"src/templates/webapplication/reactbasic/**/*",
71-
"src/templates/project/reactb2e/**/*",
72-
"src/templates/project/reactb2x/**/*"
71+
"src/templates/project/reactinternalapp/**/*",
72+
"src/templates/project/reactexternalapp/**/*"
7373
]
7474
}

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@ oclif.manifest.json
6565
src/templates/webapplication/
6666

6767
# ignore project templates copied from npm during build (copy-templates)
68-
src/templates/project/reactb2e/
69-
src/templates/project/reactb2x/
68+
src/templates/project/reactinternalapp/
69+
src/templates/project/reactexternalapp/

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
"devDependencies": {
2525
"@salesforce/dev-config": "^4.3.2",
2626
"@salesforce/dev-scripts": "^11.0.2",
27-
"@salesforce/webapp-template-app-react-template-b2e-experimental": "^1.112.5",
28-
"@salesforce/webapp-template-app-react-template-b2x-experimental": "^1.112.5",
29-
"@salesforce/webapp-template-base-react-app-experimental": "^1.112.5",
30-
"@salesforce/webapp-template-base-web-app-experimental": "^1.112.5",
27+
"@salesforce/webapp-template-app-react-template-b2e-experimental": "^1.114.0",
28+
"@salesforce/webapp-template-app-react-template-b2x-experimental": "^1.114.0",
29+
"@salesforce/webapp-template-base-react-app-experimental": "^1.114.0",
30+
"@salesforce/webapp-template-base-web-app-experimental": "^1.114.0",
3131
"@salesforce/prettier-config": "^0.0.4",
3232
"@types/chai-as-promised": "^7.1.8",
3333
"@types/ejs": "^3.1.5",

scripts/copy-templates.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,22 @@ const TEMPLATES = [
6868
),
6969
destSubpath: 'webapplication/reactbasic',
7070
},
71-
// Project templates (reactb2e, reactb2x)
71+
// Project templates (reactinternalapp, reactexternalapp)
7272
{
7373
packageName:
7474
'@salesforce/webapp-template-app-react-template-b2e-experimental',
7575
getSourceDir: (packageDir) => path.join(packageDir, 'dist'),
76-
destSubpath: 'project/reactb2e',
77-
appFolderInNpm: 'appreacttemplateb2e',
78-
appSiteFolderInNpm: 'appreacttemplateb2e1',
76+
destSubpath: 'project/reactinternalapp',
77+
appFolderInNpm: 'reactinternalapp',
78+
appSiteFolderInNpm: 'reactinternalapp1',
7979
},
8080
{
8181
packageName:
8282
'@salesforce/webapp-template-app-react-template-b2x-experimental',
8383
getSourceDir: (packageDir) => path.join(packageDir, 'dist'),
84-
destSubpath: 'project/reactb2x',
85-
appFolderInNpm: 'appreacttemplateb2x',
86-
appSiteFolderInNpm: 'appreacttemplateb2x1',
84+
destSubpath: 'project/reactexternalapp',
85+
appFolderInNpm: 'reactexternalapp',
86+
appSiteFolderInNpm: 'reactexternalapp1',
8787
},
8888
];
8989

src/generators/projectGenerator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ const VALID_PROJECT_TEMPLATES = [
1818
'standard',
1919
'empty',
2020
'analytics',
21-
'reactb2e',
22-
'reactb2x',
21+
'reactinternalapp',
22+
'reactexternalapp',
2323
'agent',
2424
'nativemobile',
2525
] as const;
@@ -133,7 +133,7 @@ export default class ProjectGenerator extends BaseGenerator<ProjectOptions> {
133133

134134
/**
135135
* Returns template path for primary; if it doesn't exist, returns fallback path.
136-
* Used so reactb2e/reactb2x can omit shared files and fall back to standard.
136+
* Used so reactinternalapp/reactexternalapp can omit shared files and fall back to standard.
137137
*/
138138
private templatePathWithFallback(primary: string, fallback: string): string {
139139
const primaryPath = this.templatePath(primary);

src/utils/template-placeholders.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default [
6262
toPath: 'skills/_k_',
6363
replacement: 'feature-react-agentforce-conversation-client-embedded-agent',
6464
},
65-
// Path shortening under app folder (reactb2e/reactb2x) for Windows path length.
65+
// Path shortening under app folder (reactinternalapp/reactexternalapp) for Windows path length.
6666
{
6767
key: 'FEATURES_PLACEHOLDER',
6868
placeholder: '_f_',
@@ -78,6 +78,13 @@ export default [
7878
parent: '_f_',
7979
replacement: 'object-search',
8080
},
81+
{
82+
key: 'EXAMPLES_PLACEHOLDER',
83+
placeholder: '_ex_',
84+
dirInNpm: '__examples__',
85+
parent: '_os_',
86+
replacement: '__examples__',
87+
},
8188
{
8289
key: 'GLOBAL_SEARCH_PLACEHOLDER',
8390
placeholder: '_gs_',

src/utils/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ export interface ProjectOptions extends TemplateOptions {
192192
| 'standard'
193193
| 'empty'
194194
| 'analytics'
195-
| 'reactb2e'
196-
| 'reactb2x'
195+
| 'reactinternalapp'
196+
| 'reactexternalapp'
197197
| 'agent'
198198
| 'nativemobile';
199199
manifest: boolean;

src/utils/webappTemplateUtils.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ export const EJS_EXTENSIONS = new Set([
7878
]);
7979

8080
/** Templates that have a full folder under src/templates/project/ (populated at build time from npm) */
81-
export const BUILT_IN_FULL_TEMPLATES = new Set(['reactb2e', 'reactb2x']);
81+
export const BUILT_IN_FULL_TEMPLATES = new Set([
82+
'reactinternalapp',
83+
'reactexternalapp',
84+
]);
8285

8386
/**
8487
* Default app/site names embedded in each full template; all are renamed to the project name.
@@ -88,13 +91,13 @@ export const FULL_TEMPLATE_DEFAULT_NAMES: Record<
8891
string,
8992
{ base: string; withSuffix: string }
9093
> = {
91-
reactb2e: {
92-
base: 'appreacttemplateb2e',
93-
withSuffix: 'appreacttemplateb2e1',
94+
reactinternalapp: {
95+
base: 'reactinternalapp',
96+
withSuffix: 'reactinternalapp1',
9497
},
95-
reactb2x: {
96-
base: 'appreacttemplateb2x',
97-
withSuffix: 'appreacttemplateb2x1',
98+
reactexternalapp: {
99+
base: 'reactexternalapp',
100+
withSuffix: 'reactexternalapp1',
98101
},
99102
};
100103

@@ -136,6 +139,8 @@ export const A4D_SKILL_AGENTFORCE_PLACEHOLDER = '_k_';
136139
export const FEATURES_PLACEHOLDER = '_f_';
137140
/** Replaced with literal "object-search". */
138141
export const OBJECT_SEARCH_PLACEHOLDER = '_os_';
142+
/** Replaced with literal "__examples__". */
143+
export const EXAMPLES_PLACEHOLDER = '_ex_';
139144
/** Replaced with literal "global-search". */
140145
export const GLOBAL_SEARCH_PLACEHOLDER = '_gs_';
141146
/** Replaced with literal "components". */
@@ -158,6 +163,7 @@ export const PLACEHOLDER_KEYS = [
158163
'A4D_SKILL_AGENTFORCE_PLACEHOLDER',
159164
'FEATURES_PLACEHOLDER',
160165
'OBJECT_SEARCH_PLACEHOLDER',
166+
'EXAMPLES_PLACEHOLDER',
161167
'GLOBAL_SEARCH_PLACEHOLDER',
162168
'COMPONENTS_PLACEHOLDER',
163169
'DETAIL_PLACEHOLDER',
@@ -273,7 +279,7 @@ export type GenerateBuiltInFullTemplateOptions = {
273279
};
274280

275281
/**
276-
* Generate project files from a built-in full template (e.g. reactb2e, reactb2x).
282+
* Generate project files from a built-in full template (e.g. reactinternalapp, reactexternalapp).
277283
* Builds template vars and name replacements and delegates to generateFromProjectTemplateDir.
278284
*/
279285
export async function generateBuiltInFullTemplate(
@@ -346,9 +352,9 @@ export type GenerateFromProjectTemplateDirOptions = {
346352
};
347353

348354
/**
349-
* Recursively walk a full project template directory (e.g. reactb2e, reactb2x),
355+
* Recursively walk a full project template directory (e.g. reactinternalapp, reactexternalapp),
350356
* rendering EJS for text files and copying the rest. Renames template default app/site
351-
* names (e.g. appreacttemplateb2e) to the project name in paths and file contents.
357+
* names (e.g. reactinternalapp) to the project name in paths and file contents.
352358
*/
353359
export async function generateFromProjectTemplateDir(
354360
sourceDir: string,

test/fixtures/project-templates/project/reactb2e/appname.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/fixtures/project-templates/project/reactb2e/sample.txt renamed to test/fixtures/project-templates/project/reactexternalapp/sample.txt

File renamed without changes.

0 commit comments

Comments
 (0)