prodlysfcli 1.3.2 → 1.4.1

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.
@@ -0,0 +1,77 @@
1
+ import { Messages, SfError } from '@salesforce/core';
2
+ import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
3
+ import { getReleases } from '../../services/release-configurations.js';
4
+ import { postReleases } from '../../services/releases.js';
5
+ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
6
+ const commandMessages = Messages.loadMessages('prodlysfcli', 'prodly.releases');
7
+ const prodlyMessages = Messages.loadMessages('prodlysfcli', 'prodly');
8
+ export default class ProdlyReleases extends SfCommand {
9
+ static summary = commandMessages.getMessage('summary');
10
+ static description = prodlyMessages.getMessage('descriptionReleasesCommand');
11
+ static examples = commandMessages.getMessages('examples');
12
+ static flags = {
13
+ 'api-version': Flags.orgApiVersion(),
14
+ 'target-dev-hub': Flags.requiredHub(),
15
+ 'deactivate-all-events': Flags.boolean({
16
+ char: 'a',
17
+ relationships: [{ type: 'some', flags: ['deploy'] }],
18
+ summary: prodlyMessages.getMessage('deactivateAllReleaseEventsFlagDescription'),
19
+ }),
20
+ 'release-id': Flags.string({
21
+ char: 'r',
22
+ relationships: [{ type: 'some', flags: ['deploy'] }],
23
+ summary: prodlyMessages.getMessage('releaseIdFlagDescription'),
24
+ }),
25
+ deploy: Flags.boolean({
26
+ char: 'd',
27
+ dependsOn: ['instance', 'release-id'],
28
+ exactlyOne: ['list'],
29
+ summary: prodlyMessages.getMessage('deployReleaseFlagDescription'),
30
+ }),
31
+ instance: Flags.string({ char: 'i', summary: prodlyMessages.getMessage('instanceFlagDescription') }),
32
+ list: Flags.boolean({
33
+ char: 'l',
34
+ exactlyOne: ['deploy'],
35
+ exclusive: ['deploy', 'release-id'],
36
+ summary: prodlyMessages.getMessage('listReleasesFlagDescription'),
37
+ }),
38
+ validation: Flags.boolean({
39
+ char: 'n',
40
+ relationships: [{ type: 'some', flags: ['deploy'] }],
41
+ summary: prodlyMessages.getMessage('validationFlagDescription'),
42
+ }),
43
+ };
44
+ async run() {
45
+ const { flags } = await this.parse(ProdlyReleases);
46
+ const { list } = flags;
47
+ const hubOrg = flags['target-dev-hub'];
48
+ const hubConn = hubOrg.getConnection(flags['api-version']);
49
+ if (list) {
50
+ const releases = await getReleases({ hubConn });
51
+ if (!releases)
52
+ throw new SfError('No releases found');
53
+ releases.forEach((release) => this.logRelease(release));
54
+ return releases;
55
+ }
56
+ const { jobId } = await postReleases({
57
+ body: {
58
+ deactivateAllEvents: flags['deactivate-all-events'],
59
+ releaseId: flags['release-id'],
60
+ targetManagedInstanceId: flags.instance,
61
+ validation: flags.validation,
62
+ },
63
+ hubConn,
64
+ });
65
+ this.log(`Release launched with Job ID: ${jobId}`);
66
+ return { jobId, message: 'Release launched' };
67
+ }
68
+ logRelease(release) {
69
+ this.log('Name:', release.PDRI__Release_Name__c);
70
+ this.log('ID:', release.Id);
71
+ this.log('Description:', release?.PDRI__Description__c ?? '');
72
+ this.log('Status:', release?.PDRI__Status__c);
73
+ this.log('Created Date:', new Date(release.CreatedDate).toLocaleString());
74
+ this.log('Created By:', `${release['CreatedBy.Name'] ?? ''}\n`);
75
+ }
76
+ }
77
+ //# sourceMappingURL=releases.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"releases.js","sourceRoot":"","sources":["../../../src/commands/prodly/releases.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI1D,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,eAAe,GAAG,QAAQ,CAAC,YAAY,C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YACnC,IAAI,EAAE;gBACJ,mBAAmB,EAAE,KAAK,CAAC,uBAAuB,CAAC;gBACnD,SAAS,EAAE,KAAK,CAAC,YAAY,CAAC;gBAC9B,uBAAuB,EAAE,KAAK,CAAC,QAAQ;gBACvC,UAAU,EAAE,KAAK,CAAC,UAAU;aAC7B;YACD,OAAO;SACR,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,iCAAiC,KAAK,EAAE,CAAC,CAAC;QACnD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAChD,CAAC;IAEO,UAAU,CAAC,OAA6B;QAC9C,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;QACjD,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;QAC5B,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,EAAE,oBAAoB,IAAI,EAAE,CAAC,CAAC;QAC9D,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;QAC9C,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC;QAC1E,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClE,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { Connection } from '@salesforce/core';
2
+ import { ReleaseConfiguration } from '../types/prodly.js';
3
+ export type GetReleasesFn = ({ hubConn }: {
4
+ hubConn: Connection;
5
+ }) => Promise<ReleaseConfiguration[] | undefined>;
6
+ export declare const getReleases: GetReleasesFn;
@@ -0,0 +1,7 @@
1
+ const BASE_PATH = '/services/apexrest/PDRI/v1/release-configurations';
2
+ export const getReleases = async ({ hubConn }) => {
3
+ const res = await hubConn.request(`${hubConn.instanceUrl}${BASE_PATH}`);
4
+ const responseData = JSON.parse(res);
5
+ return responseData.data;
6
+ };
7
+ //# sourceMappingURL=release-configurations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"release-configurations.js","sourceRoot":"","sources":["../../src/services/release-configurations.ts"],"names":[],"mappings":"AAGA,MAAM,SAAS,GAAG,mDAAmD,CAAC;AAItE,MAAM,CAAC,MAAM,WAAW,GAAkB,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;IAC9D,MAAM,GAAG,GAAW,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,EAAE,CAAC,CAAC;IAChF,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAqC,CAAC;IACzE,OAAO,YAAY,CAAC,IAAI,CAAC;AAC3B,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Connection } from '@salesforce/core';
2
+ export type PostReleasesFn = ({ body, hubConn, }: {
3
+ body: {
4
+ [key: string]: unknown;
5
+ };
6
+ hubConn: Connection;
7
+ }) => Promise<{
8
+ jobId: string;
9
+ }>;
10
+ export declare const postReleases: PostReleasesFn;
@@ -0,0 +1,16 @@
1
+ import { SfError } from '@salesforce/core';
2
+ const BASE_PATH = '/services/apexrest/PDRI/v1/releases';
3
+ export const postReleases = async ({ body, hubConn }) => {
4
+ const request = {
5
+ body: JSON.stringify(body),
6
+ method: 'POST',
7
+ url: BASE_PATH,
8
+ };
9
+ const res = await hubConn.request(request);
10
+ const jobWrapper = JSON.parse(res);
11
+ const jobId = jobWrapper.id;
12
+ if (!jobId)
13
+ throw new SfError('No job ID returned.');
14
+ return { jobId };
15
+ };
16
+ //# sourceMappingURL=releases.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"releases.js","sourceRoot":"","sources":["../../src/services/releases.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,SAAS,GAAG,qCAAqC,CAAC;AASxD,MAAM,CAAC,MAAM,YAAY,GAAmB,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;IACtE,MAAM,OAAO,GAAG;QACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;QAC1B,MAAM,EAAE,MAAe;QACvB,GAAG,EAAE,SAAS;KACf,CAAC;IACF,MAAM,GAAG,GAAW,MAAM,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACnD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAmB,CAAC;IACrD,MAAM,KAAK,GAAG,UAAU,CAAC,EAAE,CAAC;IAC5B,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACrD,OAAO,EAAE,KAAK,EAAE,CAAC;AACnB,CAAC,CAAC"}
@@ -93,3 +93,47 @@ export type NameAndId = {
93
93
  id: string;
94
94
  name: string;
95
95
  };
96
+ export type WorkItem = {
97
+ Id: string;
98
+ Name: string;
99
+ PDRI__Name__c: string;
100
+ PDRI__Description__c: string;
101
+ PDRI__Issue_Type__c: string;
102
+ PDRI__Link__c: string;
103
+ PDRI__Work_Item_ID__c: string;
104
+ PDRI__Work_Item_Key__c: string;
105
+ PDRI__Work_Item_Type__c: string;
106
+ };
107
+ export type Bundle = {
108
+ workItems: WorkItem[];
109
+ Id: string;
110
+ PDRI__Deployment_Bundle_Name__c: string;
111
+ PDRI__Deployment_Bundle_Type__c: string;
112
+ PDRI__Metadata_Rollback_On_Failure__c: string;
113
+ PDRI__Skip_Data_On_Metadata_Failure__c: string;
114
+ PDRI__Test_Level__c: string;
115
+ };
116
+ export type BundleRelationship = {
117
+ bundle: Bundle;
118
+ Id: string;
119
+ PDRI__Deployment_Order__c: number;
120
+ };
121
+ export type ReleaseConfiguration = {
122
+ releaseBundleRelationships?: BundleRelationship[];
123
+ Id: string;
124
+ Name: string;
125
+ PDRI__Release_Name__c: string;
126
+ PDRI__Description__c?: string;
127
+ PDRI__Status__c: string;
128
+ CreatedDate: string;
129
+ LastModifiedDate: string;
130
+ 'CreatedBy.Name': string;
131
+ 'CreatedBy.Username': string;
132
+ 'CreatedBy.Id': string;
133
+ 'LastModifiedBy.Name': string;
134
+ 'LastModifiedBy.Username': string;
135
+ 'LastModifiedBy.Id': string;
136
+ };
137
+ export type ReleasesResponse = {
138
+ id: string;
139
+ };
@@ -8,24 +8,29 @@
8
8
  "createFromChangeTypeUsernameFlagDescription": "username to use for the scratch org",
9
9
  "dataSetFlagDescription": "name or record ID of the data set to deploy",
10
10
  "deactivateFlagDescription": "deactivate all events for the deployment",
11
+ "deactivateAllReleaseEventsFlagDescription": "deactivate all events for the release",
11
12
  "deplomentNameFlagDescription": "name for the deployment",
12
13
  "deploymentPlanFlagDescription": "name or record ID of the deployment plan to deploy",
13
14
  "destinationFlagDescription": "destination managed instance ID",
15
+ "deployReleaseFlagDescription": "deploy a release",
14
16
  "instanceFlagDescription": "managed instance ID on which to perform the action",
15
17
  "instanceNameFlagDescription": "connection and managed instance name",
16
18
  "jobIdFlagSummary": "Prodly Job ID",
17
19
  "listChangeTypesFlagDescription": "list all change types or specific change type",
18
20
  "listFlagDescription": "list all managed instances",
21
+ "listReleasesFlagDescription": "list all releases",
19
22
  "manageFlagDescription": "manage a new instance",
20
23
  "newBranchFlagSummary": "if provided it creates a new branch based on the source branch that will be used for version control",
21
24
  "notesFlagDescription": "notes for the deployment",
22
25
  "printFlagDescription": "print the managed instances in a standard format in addition to returning structured data",
23
26
  "queryFilterFlagDescription": "query filter override for a data set deployment",
27
+ "releaseIdFlagDescription": "release Id to deploy",
24
28
  "simulationFlagDescription": "perform a data simulation",
25
29
  "sourceBranchFlagSummary": "the version control branch or the base for the new branch (if provided)",
26
30
  "sourceFlagDescription": "source managed instance ID",
27
31
  "unlinkBranchFlagDescription": "unlink the branch from the managed instance",
28
32
  "unmanageFlagDescription": "unmanage the specified instance",
33
+ "validationFlagDescription": "perform a data/metadata validation",
29
34
  "versionFlagDescription": "version the new managed instance, branch created and data deployed to the org",
30
35
 
31
36
  "errorDatasetAndPlanFlags": "Specify either the data set or deployment plan parameter, but not both.",
@@ -55,5 +60,6 @@
55
60
  "descriptionDeployCommand": "Deploy data from one Salesforce environment directly to another Salesforce environment.",
56
61
  "descriptionJobsCommand": " Check the job status.",
57
62
  "descriptionManageCommand": "Authorize (or unauthorize) a Salesforce environment (not already added to the Environments page in Release tab) for use by the plugin.",
63
+ "descriptionReleasesCommand": "List all releases and deploy a release.",
58
64
  "descriptionVersionCommand": "Adds version control to a managed environment."
59
65
  }
@@ -0,0 +1,12 @@
1
+ # summary
2
+
3
+ prodly:releases command
4
+
5
+ # examples
6
+
7
+ - <%= config.bin %> prodly:releases --target-dev-hub jsmith@acme.com -l
8
+ Lists all the releases
9
+
10
+ - <%= config.bin %> prodly:releases --target-dev-hub jsmith@acme.com -d -i "f50616b6-57b1-4941-802f-ee0e2506f217" -r "a5H6e0000024xKUEAY"
11
+ Creates a release given a release id and a destination instance id
12
+ The instance should be managed by the Prodly account associated with the default DevHub control org.