Skip to content

Commit 3390e1b

Browse files
authored
Merge pull request #3 from salesforcecli/ew/let-dev-scripts-control-deps
W-19265277: let devscripts control dev-deps
2 parents e5d4c86 + 708ee22 commit 3390e1b

36 files changed

Lines changed: 8945 additions & 11776 deletions

.eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
extends: ['eslint-config-salesforce-typescript', 'plugin:sf-plugin/recommended'],
2+
extends: ['eslint-config-salesforce-typescript', 'eslint-config-salesforce-license', 'plugin:sf-plugin/recommended'],
33
root: true,
44
rules: {
55
header: 'off',

.sfdevrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"devDepOverrides": ["eslint-config-salesforce-license", "@types/node"],
3+
"wireit": {
4+
"build": {
5+
"dependencies": [
6+
"compile",
7+
"lint",
8+
"gen-manifest"
9+
]
10+
}
11+
}
12+
}

LICENSE.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Apache License Version 2.0
22

3-
Copyright (c) 2024 Salesforce, Inc.
3+
Copyright (c) 2025 Salesforce, Inc.
44
All rights reserved.
55

66
Apache License
@@ -204,4 +204,3 @@ All rights reserved.
204204
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
205205
See the License for the specific language governing permissions and
206206
limitations under the License.
207-

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# plugin-bre-to-cml
22

3-
[![NPM](https://img.shields.io/npm/v/@salesforce/plugin-agent.svg?label=@salesforce/plugin-agent)](https://www.npmjs.com/package/@salesforce/plugin-bre-to-cml) [![Downloads/week](https://img.shields.io/npm/dw/@salesforce/plugin-bre-to-cml.svg)](https://npmjs.org/package/@salesforce/plugin-bre-to-cml) [![License](https://img.shields.io/badge/License-BSD%203--Clause-brightgreen.svg)](https://raw.githubusercontent.com/salesforcecli/plugin-bre-to-cml/main/LICENSE.txt)
3+
[![NPM](https://img.shields.io/npm/v/@salesforce/plugin-agent.svg?label=@salesforce/plugin-agent)](https://www.npmjs.com/package/@salesforce/plugin-bre-to-cml) [![Downloads/week](https://img.shields.io/npm/dw/@salesforce/plugin-bre-to-cml.svg)](https://npmjs.org/package/@salesforce/plugin-bre-to-cml) [![License](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](https://opensource.org/license/apache-2-0)
44

55
## Install
66

@@ -22,7 +22,6 @@ sf plugins install @salesforce/plugin-bre-to-cml@x.y.z
2222
8. Sign CLA (see [CLA](#cla) below).
2323
9. Send us a pull request when you are done. We'll review your code, suggest any needed changes, and merge it in.
2424

25-
2625
### CLA
2726

2827
External contributors will be required to sign a Contributor's License
@@ -64,7 +63,6 @@ sf plugins
6463
- [`sf cml convert prod-cfg-rules`](#sf-cml-convert-prod-cfg-rules)
6564
- [`sf cml import as-expression-set`](#sf-cml-import-as-expression-set)
6665

67-
6866
## `sf cml convert prod-cfg-rules`
6967

7068
Converts BRE based Standard Configurator rules represented as JSON to CML and saves it as a pair of CML and association files.
@@ -120,6 +118,7 @@ EXAMPLES
120118
121119
$ sf cml convert prod-cfg-rules --pcr-file data/ProductConfigurationRules.json --cml-api MY_TEST --workspace-dir data --target-org breSourceOrg
122120
```
121+
123122
_See code: [src/commands/cml/convert/prod-cfg-rules.ts](https://github.com/salesforcecli/plugin-bre-to-cml/blob/main/src/commands/cml/convert/prod-cfg-rules.ts)_
124123

125124
## `sf cml import as-expression-set`
@@ -154,6 +153,7 @@ DESCRIPTION
154153
EXAMPLES
155154
$ sf cml import as-expression-set --cml-api MY_TEST --context-definition PricingTransactionCD2 --workspace-dir data --target-org cmlTargetOrg
156155
```
156+
157157
_See code: [src/commands/cml/import/as-expression-set.ts](https://github.com/salesforcecli/plugin-bre-to-cml/blob/main/src/commands/cml/import/as-expression-set.ts)_
158158

159-
<!-- commandsstop -->
159+
<!-- commandsstop -->

command-snapshot.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[
2+
{
3+
"alias": [],
4+
"command": "cml:convert:prod-cfg-rules",
5+
"flagAliases": [],
6+
"flagChars": ["c", "d", "o", "r", "v", "x"],
7+
"flags": [
8+
"additional-products",
9+
"api-version",
10+
"cml-api",
11+
"flags-dir",
12+
"json",
13+
"pcr-file",
14+
"products-file",
15+
"target-org",
16+
"workspace-dir"
17+
],
18+
"plugin": "@salesforce/plugin-bre-to-cml"
19+
},
20+
{
21+
"alias": [],
22+
"command": "cml:import:as-expression-set",
23+
"flagAliases": [],
24+
"flagChars": ["c", "d", "o", "x"],
25+
"flags": ["api-version", "cml-api", "context-definition", "flags-dir", "json", "target-org", "workspace-dir"],
26+
"plugin": "@salesforce/plugin-bre-to-cml"
27+
}
28+
]

package.json

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,23 @@
55
"salesforceRelease": "256.11",
66
"dependencies": {
77
"@oclif/core": "^4",
8-
"@salesforce/core": "^8",
8+
"@salesforce/core": "^8.2.7",
99
"@salesforce/sf-plugins-core": "^12",
1010
"csv-parse": "^5.6.0",
1111
"got": "12"
1212
},
1313
"devDependencies": {
14-
"@commitlint/cli": "^19.8.0",
15-
"@commitlint/config-conventional": "^19.8.0",
16-
"@oclif/plugin-command-snapshot": "^5.1.9",
14+
"@oclif/plugin-command-snapshot": "^5.3.5",
15+
"@salesforce/plugin-command-reference": "^3.1.61",
1716
"@oclif/test": "^4.1.0",
18-
"@salesforce/cli-plugins-testkit": "^5.3.10",
19-
"@salesforce/dev-scripts": "^10",
20-
"@types/node": "^22.14.1",
21-
"eslint-plugin-sf-plugin": "^1.18.6",
22-
"husky": "^9.1.7",
17+
"@salesforce/cli-plugins-testkit": "^5.3.20",
18+
"@salesforce/dev-scripts": "^11.0.2",
19+
"@types/node": "^22.17.0",
20+
"eslint-config-salesforce-license": "^1.0.1",
21+
"eslint-plugin-sf-plugin": "^1.18.8",
2322
"oclif": "^4.14.0",
24-
"prettier": "^3.5.3",
25-
"pretty-quick": "^4.1.1",
2623
"ts-node": "^10.9.2",
27-
"typescript": "^5.4.5",
28-
"wireit": "^0.14.12"
24+
"typescript": "^5.9.2"
2925
},
3026
"engines": {
3127
"node": ">=18.0.0"
@@ -45,7 +41,7 @@
4541
"sfdx",
4642
"sfdx-plugin"
4743
],
48-
"license": "BSD-3-Clause",
44+
"license": "Apache-2.0",
4945
"oclif": {
5046
"commands": "./lib/commands",
5147
"bin": "sf",
@@ -77,6 +73,7 @@
7773
"compile": "wireit",
7874
"dev.js": "./bin/dev.js cml convert prod-cfg-rules -o prism-dev -r ./data/ProductConfigurationRules3.json -v ./data/Products.json -c TestModel3 -d ./data/output",
7975
"docs": "sf-docs",
76+
"fix-license": "eslint src test --fix --rule \"header/header: [2]\"",
8077
"format": "wireit",
8178
"link-check": "wireit",
8279
"lint": "wireit",
@@ -136,7 +133,7 @@
136133
"output": []
137134
},
138135
"gen-manifest": {
139-
"command": "npx oclif manifest .",
136+
"command": "yarn oclif manifest .",
140137
"dependencies": [
141138
"compile"
142139
],
@@ -159,7 +156,11 @@
159156
"dependencies": [
160157
"test:compile",
161158
"test:only",
162-
"lint"
159+
"test:command-reference",
160+
"test:deprecation-policy",
161+
"lint",
162+
"test:json-schema",
163+
"link-check"
163164
]
164165
},
165166
"test:only": {
@@ -207,7 +208,7 @@
207208
"output": []
208209
},
209210
"link-check": {
210-
"command": "node -e \"process.exit(process.env.CI ? 0 : 1)\" || linkinator \"**/*.md\" --skip \"CHANGELOG.md|node_modules|test/|confluence.internal.salesforce.com|my.salesforce.com|%s\" --markdown --retry --directory-listing --verbosity error",
211+
"command": "node -e \"process.exit(process.env.CI ? 0 : 1)\" || linkinator \"**/*.md\" --skip \"CHANGELOG.md|node_modules|test/|confluence.internal.salesforce.com|my.salesforce.com|localhost|%s\" --markdown --retry --directory-listing --verbosity error",
211212
"files": [
212213
"./*.md",
213214
"./!(CHANGELOG).md",

src/commands/cml/convert/prod-cfg-rules.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright 2025, Salesforce, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
import * as fs from 'node:fs/promises';
217
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
318
import { Messages } from '@salesforce/core';
@@ -182,15 +197,18 @@ export default class CmlConvertProdCfgRules extends SfCommand<CmlConvertProdCfgR
182197
// If there is any product that is in both groups, then we can merge them.
183198
if (
184199
targetGroupProducts.some((pwi) =>
185-
productsForRulesInGroup.some((pwiInGroup) => isProductIdInProductWithIds(pwiInGroup.product.id, pwi)),
200+
productsForRulesInGroup.some((pwiInGroup) => isProductIdInProductWithIds(pwiInGroup.product.id, pwi))
186201
)
187202
) {
188203
// Merge rules and products.
189204
rulesInGroup
190205
.filter((ruleInGroup) => !targetGroupRules.some(({ apiName }) => apiName === ruleInGroup.apiName))
191206
.forEach((ruleInGroup) => targetGroupRules.push(ruleInGroup));
192207
productsForRulesInGroup
193-
.filter((pwiInGroup) => !targetGroupProducts.some((pwi) => isProductIdInProductWithIds(pwiInGroup.product.id, pwi)))
208+
.filter(
209+
(pwiInGroup) =>
210+
!targetGroupProducts.some((pwi) => isProductIdInProductWithIds(pwiInGroup.product.id, pwi))
211+
)
194212
.forEach((pwiInGroup) => targetGroupProducts.push(pwiInGroup));
195213
found = true;
196214
break;
@@ -205,7 +223,7 @@ export default class CmlConvertProdCfgRules extends SfCommand<CmlConvertProdCfgR
205223
// Generate CML for each group of products and rules.
206224
let index = 0;
207225
const genCmlPromises = Array.from(productsWithRules.entries()).map(([productsWithIds, rulesInGroup]) =>
208-
this.generateCmlForProductsAndRulesGroup(rulesInGroup, productsWithIds, safeApi, index++, workspaceDir),
226+
this.generateCmlForProductsAndRulesGroup(rulesInGroup, productsWithIds, safeApi, index++, workspaceDir)
209227
);
210228

211229
await Promise.all(genCmlPromises);
@@ -231,14 +249,14 @@ export default class CmlConvertProdCfgRules extends SfCommand<CmlConvertProdCfgR
231249
productsWithIds: ProductWithIds[],
232250
safeApi: string,
233251
index: number,
234-
workspaceDir: string | undefined,
252+
workspaceDir: string | undefined
235253
): Promise<void> {
236254
this.log(`📦 Generating CML model for rules ${rulesInGroup.map(({ apiName }) => apiName).join(', ')}`);
237255

238256
const cmlModel = newCmlModel();
239257
const modelInfo = PcmGenerator.generateViewModels(
240258
cmlModel,
241-
productsWithIds.map(({ product }) => product),
259+
productsWithIds.map(({ product }) => product)
242260
);
243261
for (const type of modelInfo.types) {
244262
modelInfo.attributes.get(type.name)?.forEach((attr) => type.addAttribute(attr));

src/commands/cml/import/as-expression-set.ts

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright 2025, Salesforce, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
import * as fs from 'node:fs/promises';
217
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
318
import { Messages } from '@salesforce/core';
@@ -73,12 +88,12 @@ export default class CmlImportAsExpressionSet extends SfCommand<CmlImportAsExpre
7388
const { id: expressionSetId } = existingExpressionSetId
7489
? { id: existingExpressionSetId }
7590
: await conn.sobject('ExpressionSet').create({
76-
ApiName: cmlApiName,
77-
Name: cmlApiName,
78-
UsageType: 'Constraint',
79-
ResourceInitializationType: 'Off',
80-
InterfaceSourceType: 'Constraint',
81-
});
91+
ApiName: cmlApiName,
92+
Name: cmlApiName,
93+
UsageType: 'Constraint',
94+
ResourceInitializationType: 'Off',
95+
InterfaceSourceType: 'Constraint',
96+
});
8297
const { Id: expressionSetDefinitionId } =
8398
(await conn.sobject('ExpressionSetDefinition').findOne({ DeveloperName: cmlApiName }, ['Id'])) ?? {};
8499
const { Id: expressionSetDefinitionVersionId } =
@@ -114,9 +129,7 @@ export default class CmlImportAsExpressionSet extends SfCommand<CmlImportAsExpre
114129
if (productIdsStr?.length) {
115130
const productsSoql = `SELECT Id,Name FROM Product2 WHERE Name IN (${productIdsStr})`;
116131
const productsQuery = await conn.query(productsSoql, { autoFetch: true });
117-
productsQuery.records.forEach((r) =>
118-
productNameToId.set(`${r.Name as string}`, `${r.Id as string}`)
119-
);
132+
productsQuery.records.forEach((r) => productNameToId.set(`${r.Name as string}`, `${r.Id as string}`));
120133
}
121134

122135
const classNameToId = new Map<string, string>();
@@ -127,23 +140,23 @@ export default class CmlImportAsExpressionSet extends SfCommand<CmlImportAsExpre
127140
if (classIdsStr?.length) {
128141
const classificationsSoql = `SELECT Id,Name FROM ProductClassification WHERE Name IN (${classIdsStr})`;
129142
const classificationsQuery = await conn.query(classificationsSoql, { autoFetch: true });
130-
classificationsQuery.records.forEach((r) =>
131-
classNameToId.set(`${r.Name as string}`, `${r.Id as string}`)
132-
);
143+
classificationsQuery.records.forEach((r) => classNameToId.set(`${r.Name as string}`, `${r.Id as string}`));
133144
}
134145

135146
const parentAndChildToPrcId = new Map<string, Map<string, string>>();
136147
const parentProductIds: string[] = [...productNameToId.values()];
137148
if (parentProductIds.length > 0) {
138-
const prcSoql = `SELECT Id, ParentProductId, ChildProductId, ChildProductClassificationId FROM ProductRelatedComponent WHERE ParentProductId IN (${parentProductIds.map((id) => `'${id}'`).join(',')})`;
149+
const prcSoql = `SELECT Id, ParentProductId, ChildProductId, ChildProductClassificationId FROM ProductRelatedComponent WHERE ParentProductId IN (${parentProductIds
150+
.map((id) => `'${id}'`)
151+
.join(',')})`;
139152
(await conn.query(prcSoql, { autoFetch: true })).records.forEach((r) => {
140153
if (!parentAndChildToPrcId.has(r.ParentProductId as string)) {
141154
parentAndChildToPrcId.set(r.ParentProductId as string, new Map<string, string>());
142155
}
143156
const childToPrcId = parentAndChildToPrcId.get(r.ParentProductId as string);
144157
childToPrcId?.set(
145158
(r.ChildProductId as string) ?? (r.ChildProductClassificationId as string) ?? 'unexpected',
146-
(r.Id as string) ?? 'unexpected',
159+
(r.Id as string) ?? 'unexpected'
147160
);
148161
});
149162
}
@@ -158,7 +171,7 @@ export default class CmlImportAsExpressionSet extends SfCommand<CmlImportAsExpre
158171
ReferenceObjectId: a.ReferenceObjectId.startsWith('01t')
159172
? productNameToId.get(a.$Product2ReferenceId)
160173
: classNameToId.get(a.$ProductClassificationName),
161-
}) as ExpressionSetConstraintObj,
174+
} as ExpressionSetConstraintObj)
162175
),
163176
...portAssociations.map((a) => {
164177
const [parentProductName, childProductName, childClassName] = a.$ProductRelatedComponentKey.split('||');
@@ -178,7 +191,7 @@ export default class CmlImportAsExpressionSet extends SfCommand<CmlImportAsExpre
178191

179192
const escoSoql = `SELECT Id, ExpressionSetId, ConstraintModelTag, ConstraintModelTagType, ReferenceObjectId FROM ExpressionSetConstraintObj WHERE ExpressionSetId = '${expressionSetId!}'`;
180193
const escos = (await conn.query(escoSoql, { autoFetch: true })).records.map(
181-
(esco) => esco as ExpressionSetConstraintObj,
194+
(esco) => esco as ExpressionSetConstraintObj
182195
);
183196

184197
this.log('📦 Upload CML associations');
@@ -188,8 +201,8 @@ export default class CmlImportAsExpressionSet extends SfCommand<CmlImportAsExpre
188201
(esco) =>
189202
ConstraintModelTag === esco.ConstraintModelTag &&
190203
ConstraintModelTagType === esco.ConstraintModelTagType &&
191-
ReferenceObjectId === esco.ReferenceObjectId,
192-
),
204+
ReferenceObjectId === esco.ReferenceObjectId
205+
)
193206
);
194207
const saveResults = await conn.sobject('ExpressionSetConstraintObj').create(associationtsToInsert);
195208
this.log('✅ Uploaded CML associations:');

src/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
1+
/*
2+
* Copyright 2025, Salesforce, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
export default {};

0 commit comments

Comments
 (0)