@apexdevtools/git-ops 1.4.0 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # git-ops - Changelog
2
2
 
3
+ ## 1.4.1 - 2024-11-22
4
+
5
+ - Fix missing deploy error reporting
6
+
3
7
  ## 1.4.0 - 2024-02-07
4
8
 
5
9
  - Add `getDeployableClasses` API for native based tracking
@@ -35,6 +35,8 @@ export declare class OrgTracking {
35
35
  getLocalStatus(withConflicts?: boolean): Promise<SyncStatus>;
36
36
  deployAndUpdateSourceTracking(paths: Array<string>): Promise<void>;
37
37
  private deploy;
38
+ private reportDeployStatus;
39
+ private reportDeployErrors;
38
40
  private updateSourceTracking;
39
41
  private toSyncStatusRow;
40
42
  private withWorkingDir;
@@ -69,33 +69,55 @@ class OrgTracking {
69
69
  deployAndUpdateSourceTracking(paths) {
70
70
  return __awaiter(this, void 0, void 0, function* () {
71
71
  return yield this.withWorkingDir(this.options.projectDir, () => __awaiter(this, void 0, void 0, function* () {
72
- return this.deploy(paths)
73
- .then(res => this.updateSourceTracking(res))
74
- .catch(e => this.logger.logError(e));
72
+ try {
73
+ this.logger.logDeployProgress('Starting deploy');
74
+ const result = yield this.deploy(paths);
75
+ if (result.response.success) {
76
+ yield this.updateSourceTracking(result);
77
+ }
78
+ else {
79
+ this.reportDeployErrors(result);
80
+ }
81
+ this.logger.logDeployProgress('Finished deploy');
82
+ }
83
+ catch (e) {
84
+ this.logger.logError(e);
85
+ }
75
86
  }));
76
87
  });
77
88
  }
78
89
  deploy(paths) {
79
90
  return __awaiter(this, void 0, void 0, function* () {
80
- const set = source_deploy_retrieve_1.ComponentSet.fromSource(paths);
81
- const deploy = yield set.deploy({
91
+ const deploy = yield source_deploy_retrieve_1.ComponentSet.fromSource(paths).deploy({
82
92
  usernameOrConnection: this.options.connection,
83
93
  });
84
- this.logger.logDeployProgress('Starting deploy');
85
- deploy.onUpdate(response => {
86
- const { status, numberComponentsDeployed, numberComponentsTotal } = response;
87
- const progress = `${numberComponentsDeployed}/${numberComponentsTotal}`;
88
- const message = `Status: ${status} Progress: ${progress}`;
89
- this.logger.logDeployProgress(message);
90
- });
91
- return yield deploy.pollStatus().then(res => {
92
- this.logger.logMessage('Finished deploy');
93
- return res;
94
- });
94
+ deploy.onUpdate(response => this.reportDeployStatus(response));
95
+ const result = yield deploy.pollStatus();
96
+ this.reportDeployStatus(result.response);
97
+ return result;
95
98
  });
96
99
  }
100
+ reportDeployStatus(response) {
101
+ const { status, numberComponentsDeployed, numberComponentsTotal, numberComponentErrors, } = response;
102
+ const progress = `${numberComponentsDeployed}/${numberComponentsTotal}`;
103
+ const message = `Status: ${status} | Progress: ${progress} | Errors: ${numberComponentErrors}`;
104
+ this.logger.logDeployProgress(message);
105
+ }
106
+ reportDeployErrors(result) {
107
+ const errors = result.getFileResponses().reduce((a, c) => {
108
+ if (c.state === source_deploy_retrieve_1.ComponentStatus.Failed) {
109
+ a.push(new Error(`${c.fullName}: ${c.error}`));
110
+ }
111
+ return a;
112
+ }, []);
113
+ if (errors.length) {
114
+ this.logger.logDeployProgress('Deploy errors:');
115
+ errors.forEach(err => this.logger.logError(err));
116
+ }
117
+ }
97
118
  updateSourceTracking(result) {
98
119
  return __awaiter(this, void 0, void 0, function* () {
120
+ this.logger.logDeployProgress('Starting source tracking update');
99
121
  const project = core_1.SfProject.getInstance(this.options.projectDir);
100
122
  const org = yield core_1.Org.create({ connection: this.options.connection });
101
123
  const tracking = yield source_tracking_1.SourceTracking.create({
@@ -104,6 +126,7 @@ class OrgTracking {
104
126
  ignoreLocalCache: true,
105
127
  });
106
128
  yield tracking.updateTrackingFromDeploy(result);
129
+ this.logger.logDeployProgress('Finished source tracking update');
107
130
  });
108
131
  }
109
132
  toSyncStatusRow(from) {
@@ -105,7 +105,7 @@ const mockDeploy = {
105
105
  .fn()
106
106
  .mockImplementation(() => Promise.resolve(mockDeployResult)),
107
107
  };
108
- const mockDeployResult = { done: true };
108
+ const mockDeployResult = { response: { success: true } };
109
109
  const mockComponentSet = {
110
110
  deploy: jest
111
111
  .fn()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apexdevtools/git-ops",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Library to do git operations to find changed files in a given git repository",
5
5
  "author": {
6
6
  "name": "Apex Dev Tools Team",