@inforge/migrations-tools-cli 1.2.1 → 1.2.3
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 +72 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -461,6 +461,11 @@ var FlowsHandler = class {
|
|
|
461
461
|
};
|
|
462
462
|
|
|
463
463
|
// src/core/metadata/triggers.ts
|
|
464
|
+
import * as fs3 from "fs/promises";
|
|
465
|
+
import * as path3 from "path";
|
|
466
|
+
import { exec } from "child_process";
|
|
467
|
+
import { promisify } from "util";
|
|
468
|
+
var execAsync = promisify(exec);
|
|
464
469
|
var TriggersHandler = class {
|
|
465
470
|
logger;
|
|
466
471
|
constructor() {
|
|
@@ -508,26 +513,57 @@ var TriggersHandler = class {
|
|
|
508
513
|
triggerNames,
|
|
509
514
|
status
|
|
510
515
|
});
|
|
516
|
+
const tempDir = path3.join(process.cwd(), ".trigger-deploy-temp");
|
|
511
517
|
try {
|
|
512
|
-
const
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
518
|
+
const triggersDir = path3.join(tempDir, "force-app", "main", "default", "triggers");
|
|
519
|
+
await fs3.mkdir(triggersDir, { recursive: true });
|
|
520
|
+
const sfdxProjectJson = {
|
|
521
|
+
packageDirectories: [
|
|
522
|
+
{
|
|
523
|
+
path: "force-app",
|
|
524
|
+
default: true
|
|
525
|
+
}
|
|
526
|
+
],
|
|
527
|
+
name: "temp-trigger-deployment",
|
|
528
|
+
namespace: "",
|
|
529
|
+
sfdcLoginUrl: "https://login.salesforce.com",
|
|
530
|
+
sourceApiVersion: "60.0"
|
|
531
|
+
};
|
|
532
|
+
await fs3.writeFile(
|
|
533
|
+
path3.join(tempDir, "sfdx-project.json"),
|
|
534
|
+
JSON.stringify(sfdxProjectJson, null, 2),
|
|
535
|
+
"utf-8"
|
|
536
|
+
);
|
|
537
|
+
await this.logger.debug("Created temp deployment directory with SFDX project", { tempDir, triggersDir });
|
|
538
|
+
await this.logger.debug("Retrieving trigger source code");
|
|
539
|
+
for (const triggerName of triggerNames) {
|
|
540
|
+
try {
|
|
541
|
+
const retrieveCmd = `sf project retrieve start --metadata ApexTrigger:${triggerName} --target-org ${connection.getUsername()}`;
|
|
542
|
+
await this.logger.debug("Executing retrieve command", { command: retrieveCmd, cwd: tempDir });
|
|
543
|
+
const { stdout: retrieveOut, stderr: retrieveErr } = await execAsync(retrieveCmd, { cwd: tempDir });
|
|
544
|
+
await this.logger.debug("Retrieve result", { stdout: retrieveOut, stderr: retrieveErr });
|
|
545
|
+
const metadataPath = path3.join(triggersDir, `${triggerName}.trigger-meta.xml`);
|
|
546
|
+
const existingMetadata = await fs3.readFile(metadataPath, "utf-8");
|
|
547
|
+
await this.logger.debug("Read existing metadata", { triggerName, metadata: existingMetadata });
|
|
548
|
+
const updatedMetadata = existingMetadata.replace(
|
|
549
|
+
/<status>.*?<\/status>/,
|
|
550
|
+
`<status>${status}</status>`
|
|
551
|
+
);
|
|
552
|
+
await fs3.writeFile(metadataPath, updatedMetadata, "utf-8");
|
|
553
|
+
await this.logger.debug("Updated metadata file", { triggerName, newStatus: status });
|
|
554
|
+
} catch (error) {
|
|
555
|
+
await this.logger.error(`Failed to retrieve trigger ${triggerName}`, error);
|
|
556
|
+
throw error;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
const deployCmd = `sf project deploy start --source-dir force-app --target-org ${connection.getUsername()}`;
|
|
560
|
+
await this.logger.debug("Executing deploy command", { command: deployCmd, cwd: tempDir });
|
|
561
|
+
const { stdout: deployOut, stderr: deployErr } = await execAsync(deployCmd, { cwd: tempDir });
|
|
562
|
+
await this.logger.debug("Deploy result", { stdout: deployOut, stderr: deployErr });
|
|
563
|
+
if (deployErr && !deployErr.includes("Deploy Succeeded")) {
|
|
564
|
+
throw new Error(`Deployment failed: ${deployErr}`);
|
|
529
565
|
}
|
|
530
|
-
await this.logger.info("Successfully updated trigger status", {
|
|
566
|
+
await this.logger.info("Successfully updated trigger status via SF CLI deployment", {
|
|
531
567
|
triggerCount: triggerNames.length,
|
|
532
568
|
status
|
|
533
569
|
});
|
|
@@ -537,6 +573,13 @@ var TriggersHandler = class {
|
|
|
537
573
|
status
|
|
538
574
|
});
|
|
539
575
|
throw error;
|
|
576
|
+
} finally {
|
|
577
|
+
try {
|
|
578
|
+
await fs3.rm(tempDir, { recursive: true, force: true });
|
|
579
|
+
await this.logger.debug("Cleaned up temp directory", { tempDir });
|
|
580
|
+
} catch (cleanupError) {
|
|
581
|
+
await this.logger.error("Failed to cleanup temp directory", cleanupError, { tempDir });
|
|
582
|
+
}
|
|
540
583
|
}
|
|
541
584
|
}
|
|
542
585
|
};
|
|
@@ -826,7 +869,7 @@ ${managed.length} managed package ${itemType} cannot be deactivated
|
|
|
826
869
|
};
|
|
827
870
|
|
|
828
871
|
// src/commands/restore.ts
|
|
829
|
-
import * as
|
|
872
|
+
import * as path4 from "path";
|
|
830
873
|
var RestoreCommand = class {
|
|
831
874
|
sfClient;
|
|
832
875
|
backupManager;
|
|
@@ -858,7 +901,7 @@ var RestoreCommand = class {
|
|
|
858
901
|
const backupOptions = await Promise.all(
|
|
859
902
|
backups.map(async (backupPath) => {
|
|
860
903
|
const backup2 = await this.backupManager.load(backupPath);
|
|
861
|
-
const filename =
|
|
904
|
+
const filename = path4.basename(backupPath, ".json");
|
|
862
905
|
const status = backup2.restoredAt ? `restored on ${backup2.restoredAt.split("T")[0]}` : "not restored";
|
|
863
906
|
const opType = backup2.operationType === "individual" ? "Individual changes" : "Bulk deactivate";
|
|
864
907
|
const itemCount = `${backup2.items.length} ${backup2.type === "validation-rules" ? "rules" : backup2.type}`;
|
|
@@ -1358,8 +1401,8 @@ var AutomationsCommand = class {
|
|
|
1358
1401
|
};
|
|
1359
1402
|
|
|
1360
1403
|
// src/commands/backups.ts
|
|
1361
|
-
import * as
|
|
1362
|
-
import * as
|
|
1404
|
+
import * as fs4 from "fs/promises";
|
|
1405
|
+
import * as path5 from "path";
|
|
1363
1406
|
var BackupsCommand = class {
|
|
1364
1407
|
backupManager;
|
|
1365
1408
|
prompts;
|
|
@@ -1390,7 +1433,7 @@ var BackupsCommand = class {
|
|
|
1390
1433
|
async viewBackups() {
|
|
1391
1434
|
const backupDir = ".backups";
|
|
1392
1435
|
try {
|
|
1393
|
-
const orgs = await
|
|
1436
|
+
const orgs = await fs4.readdir(backupDir);
|
|
1394
1437
|
if (orgs.length === 0) {
|
|
1395
1438
|
this.prompts.warning("No backups found.");
|
|
1396
1439
|
return;
|
|
@@ -1399,14 +1442,14 @@ var BackupsCommand = class {
|
|
|
1399
1442
|
for (const org of orgs) {
|
|
1400
1443
|
message += `${org}
|
|
1401
1444
|
`;
|
|
1402
|
-
const orgPath =
|
|
1403
|
-
const objects = await
|
|
1445
|
+
const orgPath = path5.join(backupDir, org);
|
|
1446
|
+
const objects = await fs4.readdir(orgPath);
|
|
1404
1447
|
for (const object of objects) {
|
|
1405
|
-
const objectPath =
|
|
1406
|
-
const types = await
|
|
1448
|
+
const objectPath = path5.join(orgPath, object);
|
|
1449
|
+
const types = await fs4.readdir(objectPath);
|
|
1407
1450
|
for (const type of types) {
|
|
1408
|
-
const typePath =
|
|
1409
|
-
const files = await
|
|
1451
|
+
const typePath = path5.join(objectPath, type);
|
|
1452
|
+
const files = await fs4.readdir(typePath);
|
|
1410
1453
|
message += ` ${object} > ${type} (${files.length} backup(s))
|
|
1411
1454
|
`;
|
|
1412
1455
|
}
|
package/package.json
CHANGED