@lead-routing/cli 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -902,8 +902,15 @@ function getTunneledDbUrl(localDir, localPort) {
|
|
|
902
902
|
}
|
|
903
903
|
function findPrismaBin() {
|
|
904
904
|
const candidates = [
|
|
905
|
+
// npx / npm global install: @lead-routing/cli is nested under the scope dir,
|
|
906
|
+
// so prisma lands 3 levels above dist/ in node_modules/.bin/
|
|
907
|
+
// e.g. ~/.npm/_npx/HASH/node_modules/.bin/prisma
|
|
908
|
+
path.join(__dirname, "../../../.bin/prisma"),
|
|
909
|
+
path.join(__dirname, "../../../prisma/bin/prisma.js"),
|
|
910
|
+
// Fallback: prisma nested inside the package's own node_modules (hoisted install)
|
|
905
911
|
path.join(__dirname, "../node_modules/.bin/prisma"),
|
|
906
912
|
path.join(__dirname, "../node_modules/prisma/bin/prisma.js"),
|
|
913
|
+
// Monorepo dev paths
|
|
907
914
|
path.resolve("packages/db/node_modules/.bin/prisma"),
|
|
908
915
|
path.resolve("node_modules/.bin/prisma"),
|
|
909
916
|
path.resolve("node_modules/.pnpm/node_modules/.bin/prisma")
|
|
@@ -1043,18 +1050,26 @@ async function sfdcDeployInline(params) {
|
|
|
1043
1050
|
{ reject: false }
|
|
1044
1051
|
);
|
|
1045
1052
|
const alreadyAuthed = authCheck === 0;
|
|
1053
|
+
let sfCredEnv = {};
|
|
1054
|
+
let targetOrgArgs = ["--target-org", orgAlias];
|
|
1046
1055
|
if (alreadyAuthed) {
|
|
1047
1056
|
log6.success("Using existing Salesforce authentication");
|
|
1048
1057
|
} else {
|
|
1049
|
-
await loginViaAppBridge(appUrl, orgAlias);
|
|
1058
|
+
const { accessToken, instanceUrl, aliasStored } = await loginViaAppBridge(appUrl, orgAlias);
|
|
1059
|
+
sfCredEnv = { SF_ACCESS_TOKEN: accessToken, SF_ORG_INSTANCE_URL: instanceUrl };
|
|
1060
|
+
if (!aliasStored) {
|
|
1061
|
+
targetOrgArgs = [];
|
|
1062
|
+
}
|
|
1050
1063
|
}
|
|
1051
1064
|
s.start("Copying Salesforce package\u2026");
|
|
1052
|
-
const
|
|
1065
|
+
const inDist = join5(__dirname2, "sfdc-package");
|
|
1066
|
+
const nextToDist = join5(__dirname2, "..", "sfdc-package");
|
|
1067
|
+
const bundledPkg = existsSync4(inDist) ? inDist : nextToDist;
|
|
1053
1068
|
const destPkg = join5(installDir ?? tmpdir(), "lead-routing-sfdc-package");
|
|
1054
1069
|
if (!existsSync4(bundledPkg)) {
|
|
1055
1070
|
s.stop("sfdc-package not found in CLI bundle");
|
|
1056
1071
|
throw new Error(
|
|
1057
|
-
`Expected bundle at: ${
|
|
1072
|
+
`Expected bundle at: ${inDist}
|
|
1058
1073
|
The CLI may need to be reinstalled: npm i -g @lead-routing/cli`
|
|
1059
1074
|
);
|
|
1060
1075
|
}
|
|
@@ -1104,8 +1119,8 @@ The CLI may need to be reinstalled: npm i -g @lead-routing/cli`
|
|
|
1104
1119
|
try {
|
|
1105
1120
|
await execa3(
|
|
1106
1121
|
"sf",
|
|
1107
|
-
["project", "deploy", "start",
|
|
1108
|
-
{ cwd: destPkg, stdio: "inherit" }
|
|
1122
|
+
["project", "deploy", "start", ...targetOrgArgs, "--source-dir", "force-app"],
|
|
1123
|
+
{ cwd: destPkg, stdio: "inherit", env: { ...process.env, ...sfCredEnv } }
|
|
1109
1124
|
);
|
|
1110
1125
|
s.stop("Package deployed");
|
|
1111
1126
|
} catch (err) {
|
|
@@ -1122,8 +1137,8 @@ The CLI may need to be reinstalled: npm i -g @lead-routing/cli`
|
|
|
1122
1137
|
try {
|
|
1123
1138
|
await execa3(
|
|
1124
1139
|
"sf",
|
|
1125
|
-
["org", "assign", "permset", "--name", "LeadRouterAdmin",
|
|
1126
|
-
{ stdio: "inherit" }
|
|
1140
|
+
["org", "assign", "permset", "--name", "LeadRouterAdmin", ...targetOrgArgs],
|
|
1141
|
+
{ stdio: "inherit", env: { ...process.env, ...sfCredEnv } }
|
|
1127
1142
|
);
|
|
1128
1143
|
s.stop("Permission set assigned \u2014 Lead Router Setup will appear in the App Launcher");
|
|
1129
1144
|
} catch (err) {
|
|
@@ -1145,12 +1160,11 @@ The CLI may need to be reinstalled: npm i -g @lead-routing/cli`
|
|
|
1145
1160
|
const qr = await execa3("sf", [
|
|
1146
1161
|
"data",
|
|
1147
1162
|
"query",
|
|
1148
|
-
|
|
1149
|
-
orgAlias,
|
|
1163
|
+
...targetOrgArgs,
|
|
1150
1164
|
"--query",
|
|
1151
1165
|
"SELECT Id FROM Routing_Settings__c LIMIT 1",
|
|
1152
1166
|
"--json"
|
|
1153
|
-
]);
|
|
1167
|
+
], { env: { ...process.env, ...sfCredEnv } });
|
|
1154
1168
|
const parsed = JSON.parse(qr.stdout);
|
|
1155
1169
|
existingId = parsed?.result?.records?.[0]?.Id;
|
|
1156
1170
|
} catch {
|
|
@@ -1160,27 +1174,25 @@ The CLI may need to be reinstalled: npm i -g @lead-routing/cli`
|
|
|
1160
1174
|
"data",
|
|
1161
1175
|
"update",
|
|
1162
1176
|
"record",
|
|
1163
|
-
|
|
1164
|
-
orgAlias,
|
|
1177
|
+
...targetOrgArgs,
|
|
1165
1178
|
"--sobject",
|
|
1166
1179
|
"Routing_Settings__c",
|
|
1167
1180
|
"--record-id",
|
|
1168
1181
|
existingId,
|
|
1169
1182
|
"--values",
|
|
1170
1183
|
`App_Url__c='${appUrl}' Engine_Endpoint__c='${engineUrl}'`
|
|
1171
|
-
], { stdio: "inherit" });
|
|
1184
|
+
], { stdio: "inherit", env: { ...process.env, ...sfCredEnv } });
|
|
1172
1185
|
} else {
|
|
1173
1186
|
await execa3("sf", [
|
|
1174
1187
|
"data",
|
|
1175
1188
|
"create",
|
|
1176
1189
|
"record",
|
|
1177
|
-
|
|
1178
|
-
orgAlias,
|
|
1190
|
+
...targetOrgArgs,
|
|
1179
1191
|
"--sobject",
|
|
1180
1192
|
"Routing_Settings__c",
|
|
1181
1193
|
"--values",
|
|
1182
1194
|
`App_Url__c='${appUrl}' Engine_Endpoint__c='${engineUrl}'`
|
|
1183
|
-
], { stdio: "inherit" });
|
|
1195
|
+
], { stdio: "inherit", env: { ...process.env, ...sfCredEnv } });
|
|
1184
1196
|
}
|
|
1185
1197
|
s.stop("Org settings written");
|
|
1186
1198
|
} catch (err) {
|
|
@@ -1252,17 +1264,20 @@ Ensure the app is running and the URL is correct.`
|
|
|
1252
1264
|
);
|
|
1253
1265
|
}
|
|
1254
1266
|
s.stop("Authenticated with Salesforce");
|
|
1267
|
+
let aliasStored = false;
|
|
1255
1268
|
try {
|
|
1256
1269
|
await execa3(
|
|
1257
1270
|
"sf",
|
|
1258
1271
|
["org", "login", "access-token", "--instance-url", instanceUrl, "--alias", orgAlias, "--no-prompt"],
|
|
1259
|
-
{
|
|
1272
|
+
{ env: { ...process.env, SFDX_ACCESS_TOKEN: accessToken } }
|
|
1260
1273
|
);
|
|
1261
1274
|
log6.success(`Salesforce org saved as "${orgAlias}"`);
|
|
1275
|
+
aliasStored = true;
|
|
1262
1276
|
} catch (err) {
|
|
1263
|
-
log6.warn(`Could not
|
|
1264
|
-
log6.info("
|
|
1277
|
+
log6.warn(`Could not persist sf CLI credentials: ${String(err)}`);
|
|
1278
|
+
log6.info("Continuing with direct token auth for this session.");
|
|
1265
1279
|
}
|
|
1280
|
+
return { accessToken, instanceUrl, aliasStored };
|
|
1266
1281
|
}
|
|
1267
1282
|
|
|
1268
1283
|
// src/steps/app-launcher-guide.ts
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<RemoteSiteSetting xmlns="http://soap.sforce.com/2006/04/metadata">
|
|
3
|
+
<description>Lead Router App URL — patched by lead-routing sfdc deploy</description>
|
|
4
|
+
<disableProtocolSecurity>false</disableProtocolSecurity>
|
|
5
|
+
<isActive>true</isActive>
|
|
6
|
+
<url>https://app.example.com</url>
|
|
7
|
+
</RemoteSiteSetting>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lead-routing/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Self-hosted deployment CLI for Lead Routing",
|
|
5
5
|
"homepage": "https://github.com/lead-routing/lead-routing",
|
|
6
6
|
"keywords": ["salesforce", "lead-routing", "self-hosted", "deployment", "cli"],
|