Skip to content
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

Sm/api-version-on-project-generate #150

Merged
merged 2 commits into from
Jun 26, 2023
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
1 change: 1 addition & 0 deletions command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"command": "project:generate",
"plugin": "@salesforce/plugin-templates",
"flags": [
"api-version",
"default-package-dir",
"json",
"login-url",
Expand Down
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