Skip to content

Commit

Permalink
feat: specify the api version when generating a project
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Jun 22, 2023
1 parent 03e43e2 commit cbe372f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions messages/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ The analytics template provides similar files and the force-app/main/default/wav

Namespace associated with this project and any connected scratch orgs.

# flags.api-version.summary

Will set this version as sourceApiVersion in the sfdx-project.json file

# flags.packagedir

Default package directory name.
Expand Down
4 changes: 4 additions & 0 deletions src/commands/project/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export default class Project extends SfCommand<CreateOutput> {
deprecateAliases: true,
}),
loglevel,
'api-version': Flags.orgApiVersion({
summary: messages.getMessage('flags.api-version.summary'),
}),
};
public async run(): Promise<CreateOutput> {
const { flags } = await this.parse(Project);
Expand All @@ -78,6 +81,7 @@ export default class Project extends SfCommand<CreateOutput> {
// namespace is a reserved keyword for the generator
ns: flags.namespace,
defaultpackagedir: flags['default-package-dir'],
apiversion: flags['api-version'],
};
return runGenerator({
generator: ProjectGenerator,
Expand Down
8 changes: 8 additions & 0 deletions test/commands/project/create.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ describe('Project creation tests:', () => {
}
});

it('should create a project with specified api version', () => {
execCmd('force:project:create --projectname apiVersionTest --api-version 50.0', { ensureExitCode: 0 });
assert.fileContent(
path.join(session.project.dir, 'apiVersionTest', 'sfdx-project.json'),
'"sourceApiVersion": "50.0"'
);
});

it('should create project with footest name and manifest folder', () => {
execCmd('force:project:create --projectname footest --manifest', { ensureExitCode: 0 });
assert.file([path.join(session.project.dir, 'footest', 'manifest', 'package.xml')]);
Expand Down

0 comments on commit cbe372f

Please sign in to comment.