Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
"src/templates/lightningcomponent/lwc/typeScript/*",
"src/templates/uiBundles/reactbasic/**/*",
"src/templates/project/reactinternalapp/**/*",
"src/templates/project/reactexternalapp/**/*"
"src/templates/project/reactexternalapp/**/*",
"src/templates/project/angularintapp/**/*",
"src/templates/project/angularextapp/**/*"
]
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,5 @@ src/templates/uiBundles/
# ignore project templates copied from npm during build (copy-templates)
src/templates/project/reactinternalapp/
src/templates/project/reactexternalapp/
src/templates/project/angularintapp/
src/templates/project/angularextapp/
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"@salesforce/dev-config": "^4.3.3",
"@salesforce/dev-scripts": "^11.0.2",
"@salesforce/prettier-config": "^0.0.4",
"@salesforce/ui-bundle-template-app-angular-template-b2e": "^11.31.12",
"@salesforce/ui-bundle-template-app-angular-template-b2x": "^11.31.12",
"@salesforce/ui-bundle-template-app-react-template-b2e": "^10.24.0",
"@salesforce/ui-bundle-template-app-react-template-b2x": "^10.12.2",
"@salesforce/ui-bundle-template-base-angular-app": "^11.31.9",
Expand Down
13 changes: 13 additions & 0 deletions scripts/copy-templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ const TEMPLATES = [
destSubpath: 'project/reactexternalapp',
appFolderInNpm: 'reactexternalapp',
},
// Angular project templates
{
packageName: '@salesforce/ui-bundle-template-app-angular-template-b2x',
getSourceDir: (packageDir) => path.join(packageDir, 'dist'),
destSubpath: 'project/angularextapp',
appFolderInNpm: 'angularextapp',
},
{
packageName: '@salesforce/ui-bundle-template-app-angular-template-b2e',
getSourceDir: (packageDir) => path.join(packageDir, 'dist'),
destSubpath: 'project/angularintapp',
appFolderInNpm: 'angularintapp',
},
];

function copyTemplate(config) {
Expand Down
5 changes: 4 additions & 1 deletion src/generators/projectGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { CreateUtil } from '../utils';
import { GeneratorContext, ProjectOptions } from '../utils/types';
import {
BUILT_IN_FULL_TEMPLATES,
FULL_TEMPLATE_DEFAULT_NAMES,
generateBuiltInFullTemplate,
renderEjsFile,
} from '../utils/uiBundleTemplateUtils';
Expand All @@ -20,6 +21,8 @@ const VALID_PROJECT_TEMPLATES = [
'analytics',
'reactinternalapp',
'reactexternalapp',
'angularinternalapp',
'angularexternalapp',
'agent',
'nativemobile',
] as const;
Expand Down Expand Up @@ -633,7 +636,7 @@ export default class ProjectGenerator extends BaseGenerator<ProjectOptions> {

if (BUILT_IN_FULL_TEMPLATES.has(template)) {
await generateBuiltInFullTemplate(template, projectname, {
templateDir: this.templatePath(template),
templateDir: this.templatePath(FULL_TEMPLATE_DEFAULT_NAMES[template]?.base ?? template),
projectDir: path.join(this.outputdir, projectname),
defaultpackagedir,
ns,
Expand Down
2 changes: 2 additions & 0 deletions src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ export interface ProjectOptions extends TemplateOptions {
| 'analytics'
| 'reactinternalapp'
| 'reactexternalapp'
| 'angularinternalapp'
| 'angularexternalapp'
| 'agent'
| 'nativemobile';
manifest: boolean;
Expand Down
10 changes: 10 additions & 0 deletions src/utils/uiBundleTemplateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ export const EJS_EXTENSIONS = new Set([
export const BUILT_IN_FULL_TEMPLATES = new Set([
'reactinternalapp',
'reactexternalapp',
'angularinternalapp',
'angularexternalapp',
]);

/**
Expand All @@ -99,6 +101,14 @@ export const FULL_TEMPLATE_DEFAULT_NAMES: Record<
base: 'reactexternalapp',
withSuffix: 'reactexternalapp1',
},
angularinternalapp: {
base: 'angularintapp',
withSuffix: 'angularintapp1',
},
angularexternalapp: {
base: 'angularextapp',
withSuffix: 'angularextapp1',
},
};

/** Directories to skip when walking a full template dir (e.g. node_modules) */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Project: <%= projectname %>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
angularintapp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Project: <%= projectname %>
112 changes: 112 additions & 0 deletions test/service/templateService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,118 @@ describe('TemplateService', () => {
chai.expect(sampleContent).to.include('MyReactExternalApp');
});

it('should create Project (angularinternalapp) from built-in template', async () => {
await remove(path.join('testsoutput', 'libraryCreate', 'project'));
// Use relative path so Windows absolute paths (e.g. D:\...) are not passed to URL parser
const fixtureRoot = path.join('test', 'fixtures', 'project-templates');
const templateService = TemplateService.getInstance();
const result = await templateService.create(
TemplateType.Project,
{
outputdir: path.join('testsoutput', 'libraryCreate', 'project'),
projectname: 'MyAngularInternalApp',
template: 'angularinternalapp',
defaultpackagedir: 'force-app',
},
fixtureRoot
);

chai
.expect(result.created)
.to.include(
path.normalize(
'testsoutput/libraryCreate/project/MyAngularInternalApp/config/project-scratch-def.json'
)
);
chai
.expect(result.created)
.to.include(
path.normalize(
'testsoutput/libraryCreate/project/MyAngularInternalApp/sfdx-project.json'
)
);
chai
.expect(result.created)
.to.include(
path.normalize(
'testsoutput/libraryCreate/project/MyAngularInternalApp/sample.txt'
)
);
const samplePath = path.join(
result.outputDir,
'MyAngularInternalApp',
'sample.txt'
);
chai.expect(fs.existsSync(samplePath)).to.be.true;
const sampleContent = fs.readFileSync(samplePath, 'utf8');
chai.expect(sampleContent).to.include('MyAngularInternalApp');
});

it('should create Project (angularexternalapp) from built-in template', async () => {
await remove(path.join('testsoutput', 'libraryCreate', 'project'));
// Use relative path so Windows absolute paths (e.g. D:\...) are not passed to URL parser
const fixtureRoot = path.join('test', 'fixtures', 'project-templates');
const templateService = TemplateService.getInstance();
const result = await templateService.create(
TemplateType.Project,
{
outputdir: path.join('testsoutput', 'libraryCreate', 'project'),
projectname: 'MyAngularExternalApp',
template: 'angularexternalapp',
defaultpackagedir: 'force-app',
},
fixtureRoot
);

chai
.expect(result.created)
.to.include(
path.normalize(
'testsoutput/libraryCreate/project/MyAngularExternalApp/config/project-scratch-def.json'
)
);
chai
.expect(result.created)
.to.include(
path.normalize(
'testsoutput/libraryCreate/project/MyAngularExternalApp/sample.txt'
)
);
const samplePath = path.join(
result.outputDir,
'MyAngularExternalApp',
'sample.txt'
);
chai.expect(fs.existsSync(samplePath)).to.be.true;
const sampleContent = fs.readFileSync(samplePath, 'utf8');
chai.expect(sampleContent).to.include('MyAngularExternalApp');
});

it('should use alphanumeric name for uiBundles under angularinternalapp template', async () => {
await remove(path.join('testsoutput', 'libraryCreate', 'project'));
// Use relative path so Windows absolute paths (e.g. D:\...) are not passed to URL parser
const fixtureRoot = path.join('test', 'fixtures', 'project-templates');
const templateService = TemplateService.getInstance();
const result = await templateService.create(
TemplateType.Project,
{
outputdir: path.join('testsoutput', 'libraryCreate', 'project'),
projectname: 'My_Angular_Internal_App',
template: 'angularinternalapp',
defaultpackagedir: 'force-app',
},
fixtureRoot
);

chai.expect(result.created).to.not.be.empty;
const projectDir = path.join(result.outputDir, 'My_Angular_Internal_App');
chai.expect(fs.existsSync(projectDir)).to.be.true;
const appnamePath = path.join(projectDir, 'appname.txt');
chai.expect(fs.existsSync(appnamePath)).to.be.true;
const appnameContent = fs.readFileSync(appnamePath, 'utf8');
chai.expect(appnameContent.trim()).to.equal('MyAngularInternalApp');
});

it('should use alphanumeric name for uiBundles under reactinternalapp template', async () => {
await remove(path.join('testsoutput', 'libraryCreate', 'project'));
// Use relative path so Windows absolute paths (e.g. D:\...) are not passed to URL parser
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"./src/templates/uiBundles/reactbasic/**/*",
"./src/templates/uiBundles/angularbasic/**/*",
"./src/templates/project/reactinternalapp/**/*",
"./src/templates/project/reactexternalapp/**/*"
"./src/templates/project/reactexternalapp/**/*",
"./src/templates/project/angularintapp/**/*",
"./src/templates/project/angularextapp/**/*"
]
}
Loading