Skip to content

Commit 975e1c5

Browse files
authored
fix: rename --variables to --values and remove Variables wrapper (#124)
- Change --variables flag to --values for more generic JSON file support
1 parent d912aca commit 975e1c5

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

command-snapshot.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
"command": "orchestrator:rules:eval",
7777
"flagAliases": [],
7878
"flagChars": ["d", "o", "r", "v"],
79-
"flags": ["api-version", "document", "flags-dir", "json", "rules", "target-org", "variables"],
79+
"flags": ["api-version", "document", "flags-dir", "json", "rules", "target-org", "values"],
8080
"plugin": "@salesforce/plugin-orchestrator"
8181
},
8282
{

messages/orchestrator.rules.eval.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ Path to JSON document file to transform.
3030

3131
Path to the JSON document file (dashboard, lens, etc.) that will be transformed by the rules.
3232

33-
# flags.variables.summary
33+
# flags.values.summary
3434

35-
Path to Analytics variables.json file.
35+
Path to values JSON file.
3636

37-
# flags.variables.description
37+
# flags.values.description
3838

39-
Path to the variables.json file containing variable definitions used in transformations. The file should contain a flat JSON object with key-value pairs. The CLI will automatically wrap these in the required Variables structure.
39+
Path to the JSON file containing values used in transformations. Can contain any JSON structure that matches your transformation rules.
4040

4141
# flags.rules.summary
4242

@@ -49,7 +49,7 @@ Path to the rules.json file containing transformation rules and macro definition
4949
# examples
5050

5151
- Test JSON transformation with Analytics files:
52-
<%= config.bin %> <%= command.id %> --document ./dashboard.json --variables ./variables.json --rules ./rules.json --target-org myorg
52+
<%= config.bin %> <%= command.id %> --document ./dashboard.json --values ./values.json --rules ./rules.json --target-org myorg
5353

5454
- Test with specific API version:
55-
<%= config.bin %> <%= command.id %> --document ./dashboard.json --variables ./variables.json --rules ./rules.json --target-org myorg --api-version 60.0
55+
<%= config.bin %> <%= command.id %> --document ./dashboard.json --values ./values.json --rules ./rules.json --target-org myorg --api-version 60.0

src/commands/orchestrator/rules/eval.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ type TransformationPayload = {
3636
namespace: string;
3737
};
3838
};
39-
values: {
40-
Variables: {
41-
hello: string;
42-
};
43-
};
39+
values: Record<string, unknown>;
4440
definition: {
4541
rules: Array<{
4642
name: string;
@@ -91,10 +87,10 @@ export default class TemplateEval extends SfCommand<TemplatePreviewResult> {
9187
description: messages.getMessage('flags.document.description'),
9288
required: true,
9389
}),
94-
variables: Flags.file({
90+
values: Flags.file({
9591
char: 'v',
96-
summary: messages.getMessage('flags.variables.summary'),
97-
description: messages.getMessage('flags.variables.description'),
92+
summary: messages.getMessage('flags.values.summary'),
93+
description: messages.getMessage('flags.values.description'),
9894
required: true,
9995
}),
10096
rules: Flags.file({
@@ -159,16 +155,16 @@ export default class TemplateEval extends SfCommand<TemplatePreviewResult> {
159155
}
160156
}
161157

162-
private async getTemplatePayload(flags: { document: string; variables: string; rules: string }): Promise<{
158+
private async getTemplatePayload(flags: { document: string; values: string; rules: string }): Promise<{
163159
template: TemplateInfo;
164160
payload: TransformationPayload;
165161
}> {
166-
return this.getDirectFilePayload(flags.document, flags.variables, flags.rules);
162+
return this.getDirectFilePayload(flags.document, flags.values, flags.rules);
167163
}
168164

169165
private async getDirectFilePayload(
170166
documentFile: string,
171-
variablesFile: string,
167+
valuesFile: string,
172168
rulesFile: string
173169
): Promise<{
174170
template: TemplateInfo;
@@ -180,12 +176,10 @@ export default class TemplateEval extends SfCommand<TemplatePreviewResult> {
180176
const documentContent = await fs.readFile(documentFile, 'utf8');
181177
const document = JSON.parse(documentContent) as unknown;
182178

183-
// Read variables file
184-
this.log(`Loading variables: ${variablesFile}`);
185-
const variablesContent = await fs.readFile(variablesFile, 'utf8');
186-
const variablesData = JSON.parse(variablesContent) as Record<string, unknown>;
187-
188-
const values = { Variables: variablesData };
179+
// Read values file
180+
this.log(`Loading values: ${valuesFile}`);
181+
const valuesContent = await fs.readFile(valuesFile, 'utf8');
182+
const values = JSON.parse(valuesContent) as Record<string, unknown>;
189183

190184
// Read rules file
191185
this.log(`Loading rules: ${rulesFile}`);
@@ -200,7 +194,7 @@ export default class TemplateEval extends SfCommand<TemplatePreviewResult> {
200194
},
201195
payload: {
202196
document: document as TransformationPayload['document'],
203-
values: values as TransformationPayload['values'],
197+
values,
204198
definition: definition as TransformationPayload['definition'],
205199
},
206200
};

0 commit comments

Comments
 (0)