Skip to content

Commit 43b3cfc

Browse files
feat!: restructure function-specific flags for CLI
- Change --used-in-feature to --use-in-feature BREAKING CHANGE: Command signatures changed for function init, deploy, and run @W-22278901
1 parent 8f43b76 commit 43b3cfc

7 files changed

Lines changed: 24 additions & 28 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ USAGE
168168
$ sf data-code-extension function init -p <value> [--flags-dir <value>] [-u SearchIndexChunking]
169169
170170
FLAGS
171-
-p, --package-dir=<value> (required) Directory path where the package will be created.
172-
-u, --used-in-feature=<option> [default: SearchIndexChunking] Feature flag for function initialization (function
173-
packages only).
174-
<options: SearchIndexChunking>
171+
-p, --package-dir=<value> (required) Directory path where the package will be created.
172+
-u, --use-in-feature=<option> [default: SearchIndexChunking] Feature flag for function initialization (function
173+
packages only).
174+
<options: SearchIndexChunking>
175175
176176
GLOBAL FLAGS
177177
--flags-dir=<value> Import flag values from a directory.
@@ -191,7 +191,7 @@ FLAG DESCRIPTIONS
191191
192192
The directory path where the new package will be initialized. The directory will be created if it doesn't exist.
193193
194-
-u, --used-in-feature=SearchIndexChunking Feature flag for function initialization (function packages only).
194+
-u, --use-in-feature=SearchIndexChunking Feature flag for function initialization (function packages only).
195195
196196
Configuration for which feature this function will be used in. SearchIndexChunking is the only valid option and is
197197
used by default if not specified.

commit.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22

33
git add -A && git commit -m "feat!: restructure function-specific flags for CLI
44
5-
- Move --function-invoke-opt from deploy to init as --used-in-feature
6-
- Change value from UnstructuredChunking to SearchIndexChunking
7-
- Add --test-with flag to function run (required)
8-
- Remove --target-org from function run (not needed for functions)
9-
- Make --used-in-feature optional with SearchIndexChunking default
5+
- Change --used-in-feature to --use-in-feature
106
117
BREAKING CHANGE: Command signatures changed for function init, deploy, and run
128
13-
@W-22278901"
9+
@W-22278901"

messages/init.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Initializes the Data Code Extension by checking system requirements and setting
2020

2121
- Initialize a function package with explicit feature flag:
2222

23-
<%= config.bin %> data-code-extension function init --package-dir ./my-function-package --used-in-feature SearchIndexChunking
23+
<%= config.bin %> data-code-extension function init --package-dir ./my-function-package --use-in-feature SearchIndexChunking
2424

2525
# examples.script
2626

@@ -84,10 +84,10 @@ Directory path where the package will be created.
8484

8585
The directory path where the new package will be initialized. The directory will be created if it doesn't exist.
8686

87-
# flags.usedInFeature.summary
87+
# flags.useInFeature.summary
8888

8989
Feature flag for function initialization (function packages only).
9090

91-
# flags.usedInFeature.description
91+
# flags.useInFeature.description
9292

9393
Configuration for which feature this function will be used in. SearchIndexChunking is the only valid option and is used by default if not specified.

src/base/initBase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export abstract class InitBase<TFlags extends BaseInitFlags = BaseInitFlags> ext
5050
const executionResult = await DatacodeBinaryExecutor.executeBinaryInit(
5151
codeType,
5252
packageDir,
53-
additionalFlags.usedInFeature as string | undefined
53+
additionalFlags.useInFeature as string | undefined
5454
);
5555

5656
this.spinner.stop();

src/commands/data-code-extension/function/init.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
2121
const messages = Messages.loadMessages('@salesforce/plugin-data-code-extension', 'init');
2222

2323
export type FunctionInitFlags = BaseInitFlags & {
24-
'used-in-feature': string;
24+
'use-in-feature': string;
2525
};
2626

2727
// eslint-disable-next-line sf-plugin/only-extend-SfCommand
@@ -41,10 +41,10 @@ export default class Init extends InitBase<FunctionInitFlags> {
4141
exists: false, // Allow non-existing directories (will be created)
4242
}),
4343
// Function-specific flag
44-
'used-in-feature': Flags.string({
44+
'use-in-feature': Flags.string({
4545
char: 'u',
46-
summary: messages.getMessage('flags.usedInFeature.summary'),
47-
description: messages.getMessage('flags.usedInFeature.description'),
46+
summary: messages.getMessage('flags.useInFeature.summary'),
47+
description: messages.getMessage('flags.useInFeature.description'),
4848
options: ['SearchIndexChunking'],
4949
default: 'SearchIndexChunking',
5050
required: false,
@@ -64,7 +64,7 @@ export default class Init extends InitBase<FunctionInitFlags> {
6464
// eslint-disable-next-line class-methods-use-this
6565
protected getAdditionalFlags(flags: FunctionInitFlags): Record<string, unknown> {
6666
return {
67-
usedInFeature: flags['used-in-feature'],
67+
useInFeature: flags['use-in-feature'],
6868
};
6969
}
7070
}

src/utils/datacodeBinaryExecutor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,20 @@ export class DatacodeBinaryExecutor {
8383
*
8484
* @param codeType The type of code package to initialize
8585
* @param packageDir The directory to initialize the package in
86-
* @param usedInFeature Optional feature flag (function packages only)
86+
* @param useInFeature Optional feature flag (function packages only)
8787
* @returns Execution result with stdout, stderr, and parsed file list
8888
* @throws SfError if execution fails
8989
*/
9090
public static async executeBinaryInit(
9191
codeType: 'script' | 'function',
9292
packageDir: string,
93-
usedInFeature?: string
93+
useInFeature?: string
9494
): Promise<DatacodeInitExecutionResult> {
9595
try {
9696
const args = ['init', '--code-type', codeType];
9797

98-
if (usedInFeature) {
99-
args.push('--used-in-feature', usedInFeature);
98+
if (useInFeature) {
99+
args.push('--use-in-feature', useInFeature);
100100
}
101101

102102
args.push(packageDir);

test/commands/data-code-extension/init.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ describe('data-code-extension init commands', () => {
124124
const result = await FunctionInit.run([
125125
'--package-dir',
126126
'./test-function',
127-
'--used-in-feature',
127+
'--use-in-feature',
128128
'SearchIndexChunking',
129129
]);
130130
expect(result.codeType).to.equal('function');
@@ -176,7 +176,7 @@ describe('data-code-extension init commands', () => {
176176
const result = await FunctionInit.run([
177177
'--package-dir',
178178
'./test-function-type',
179-
'--used-in-feature',
179+
'--use-in-feature',
180180
'SearchIndexChunking',
181181
]);
182182
expect(result.codeType).to.equal('function');
@@ -219,12 +219,12 @@ describe('data-code-extension init commands', () => {
219219
expect(error).to.exist;
220220
if (error instanceof Error) {
221221
// Could fail on either missing flag
222-
expect(error.message).to.match(/package-dir|used-in-feature/);
222+
expect(error.message).to.match(/package-dir|use-in-feature/);
223223
}
224224
}
225225
});
226226

227-
it('uses default value for used-in-feature when not provided', async () => {
227+
it('uses default value for use-in-feature when not provided', async () => {
228228
try {
229229
const result = await FunctionInit.run(['--package-dir', './test-function']);
230230
// Should succeed with default value

0 commit comments

Comments
 (0)