@hcl-software/dxclient 232.0.0 → 234.0.0

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.
Files changed (52) hide show
  1. package/dist/package.json +5 -9
  2. package/dist/packages/admintasks/src/commands/exportWCMLibrary.js +1 -1
  3. package/dist/packages/admintasks/src/commands/exportWCMLibrary.js.map +1 -1
  4. package/dist/packages/admintasks/src/commands/pznRulesExport.js +1 -1
  5. package/dist/packages/admintasks/src/commands/pznRulesExport.js.map +1 -1
  6. package/dist/packages/admintasks/src/services/differentialReportService.js +1 -1
  7. package/dist/packages/admintasks/src/services/differentialReportService.js.map +1 -1
  8. package/dist/packages/admintasks/src/services/resEnvProviderService.js +5 -5
  9. package/dist/packages/admintasks/src/services/resEnvProviderService.js.map +1 -1
  10. package/dist/packages/admintasks/src/services/virtualPortalServices.js +1 -1
  11. package/dist/packages/admintasks/src/services/virtualPortalServices.js.map +1 -1
  12. package/dist/packages/dam/src/services/stagingService.js +20 -20
  13. package/dist/packages/dam/src/services/stagingService.js.map +1 -1
  14. package/dist/packages/deployscriptapplication/src/commands/pull.d.ts +2 -2
  15. package/dist/packages/deployscriptapplication/src/commands/pull.js +41 -182
  16. package/dist/packages/deployscriptapplication/src/commands/pull.js.map +1 -1
  17. package/dist/packages/deployscriptapplication/src/commands/push.d.ts +13 -6
  18. package/dist/packages/deployscriptapplication/src/commands/push.js +33 -211
  19. package/dist/packages/deployscriptapplication/src/commands/push.js.map +1 -1
  20. package/dist/packages/deployscriptapplication/src/commands/restoreScriptApplication.js +1 -1
  21. package/dist/packages/deployscriptapplication/src/commands/restoreScriptApplication.js.map +1 -1
  22. package/dist/packages/deployscriptapplication/src/commands/undeployScriptApplication.js +3 -3
  23. package/dist/packages/deployscriptapplication/src/commands/undeployScriptApplication.js.map +1 -1
  24. package/dist/packages/deployscriptapplication/src/errors/CommandLineMessages_en.json +7 -1
  25. package/dist/packages/deployscriptapplication/src/messages/messages_en.json +7 -1
  26. package/dist/packages/deployscriptapplication/src/services/deployscriptapplicationServices.d.ts +6 -0
  27. package/dist/packages/deployscriptapplication/src/services/deployscriptapplicationServices.js +173 -0
  28. package/dist/packages/deployscriptapplication/src/services/deployscriptapplicationServices.js.map +1 -0
  29. package/dist/packages/deployscriptapplication/src/util/generic.d.ts +5 -0
  30. package/dist/packages/deployscriptapplication/src/util/generic.js +159 -1
  31. package/dist/packages/deployscriptapplication/src/util/generic.js.map +1 -1
  32. package/dist/packages/deploytheme/src/services/themeServices.js +5 -5
  33. package/dist/packages/deploytheme/src/services/themeServices.js.map +1 -1
  34. package/dist/packages/livesync/src/commands/pullWcmDesignLibrary.js +1 -1
  35. package/dist/packages/livesync/src/commands/pullWcmDesignLibrary.js.map +1 -1
  36. package/dist/packages/livesync/src/services/metadataServices.js +1 -1
  37. package/dist/packages/livesync/src/services/metadataServices.js.map +1 -1
  38. package/dist/packages/livesync/src/services/ongoingSyncServices.js +2 -2
  39. package/dist/packages/livesync/src/services/ongoingSyncServices.js.map +1 -1
  40. package/dist/packages/syndication/src/commands/subscriber.js +1 -1
  41. package/dist/packages/syndication/src/commands/subscriber.js.map +1 -1
  42. package/dist/packages/syndication/src/commands/syndicator.js +1 -1
  43. package/dist/packages/syndication/src/commands/syndicator.js.map +1 -1
  44. package/dist/packages/syndication/src/services/syndicationService.js +6 -6
  45. package/dist/packages/syndication/src/services/syndicationService.js.map +1 -1
  46. package/dist/src/index.js +3 -3
  47. package/dist/src/index.js.map +1 -1
  48. package/dist/src/services/apiServices.js +13 -13
  49. package/dist/src/services/apiServices.js.map +1 -1
  50. package/dist/src/utils/logger.js +17 -4
  51. package/dist/src/utils/logger.js.map +1 -1
  52. package/package.json +5 -9
@@ -5,197 +5,56 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Pull = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
- const fs_extra_1 = __importDefault(require("fs-extra"));
9
- const yauzl_1 = __importDefault(require("yauzl"));
10
8
  const constants_1 = require("../util/constants");
11
- const generic_1 = require("../util/generic");
12
- const requestService_1 = require("../../../../src/services/requestService");
13
9
  const utils_1 = require("../../../../src/utils/utils");
14
10
  const logger_1 = require("../../../../src/utils/logger");
15
- const constants_2 = require("../../../../src/utils/constants");
16
- const filesServices_1 = require("../../../../src/services/filesServices");
11
+ const deployscriptapplicationServices_1 = require("../services/deployscriptapplicationServices");
17
12
  class Pull {
18
- async pullScriptApplication(cmdLineArgs) {
19
- logger_1.logger.debug('Entering the pullScriptApplication function.');
20
- logger_1.logger.info('Begin content pull from Portal.');
21
- const contentRoot = cmdLineArgs.contentRoot ? cmdLineArgs.contentRoot : path_1.default.resolve((0, utils_1.getStoreDir)(), constants_1.CONTENT_ROOT, cmdLineArgs.wcmContentId);
22
- logger_1.logger.debug('contentRoot: %s', contentRoot);
23
- const { wcmContentId } = cmdLineArgs;
24
- logger_1.logger.debug('wcmContentId : %s', wcmContentId);
25
- let urlPath = cmdLineArgs.contenthandlerPath ? cmdLineArgs.contenthandlerPath : constants_1.DEFAULT_CONTENTHANDLER_PATH;
26
- logger_1.logger.debug('urlPath: %s', urlPath);
27
- if (cmdLineArgs.virtualPortalContext) {
28
- if (cmdLineArgs.virtualPortalContext.startsWith('/')) {
29
- urlPath += `${cmdLineArgs.virtualPortalContext}`;
30
- }
31
- else {
32
- urlPath += `/${cmdLineArgs.virtualPortalContext}`;
33
- }
34
- }
35
- if (cmdLineArgs.projectContext) {
36
- if (cmdLineArgs.projectContext.startsWith('/')) {
37
- urlPath += `/$project${cmdLineArgs.projectContext}`;
38
- }
39
- else {
40
- urlPath += `/$project/${cmdLineArgs.projectContext}`;
41
- }
13
+ buildUrlPath(baseUrlPath, virtualPortalContext, projectContext) {
14
+ let urlPath = baseUrlPath;
15
+ if (virtualPortalContext) {
16
+ logger_1.logger.debug('Adding virtual portal context: %s', virtualPortalContext);
17
+ urlPath += virtualPortalContext.startsWith('/')
18
+ ? virtualPortalContext
19
+ : `/${virtualPortalContext}`;
42
20
  }
43
- logger_1.logger.debug('Updated urlPath : %s', urlPath);
44
- let status = false;
45
- try {
46
- const parseUrl = `${cmdLineArgs.dxProtocol}://${cmdLineArgs.hostname}:${cmdLineArgs.dxPort}${urlPath}`;
47
- logger_1.logger.debug('parseUrl: %s', parseUrl);
48
- const auth = (0, utils_1.baseEncode)(cmdLineArgs.dxUsername, cmdLineArgs.dxPassword);
49
- const axiosConfig = {
50
- method: 'GET',
51
- url: parseUrl,
52
- params: {
53
- uri: `${constants_1.DEFAULT_PULL_URI_PATH}${wcmContentId}`,
54
- },
55
- headers: {
56
- Authorization: auth,
57
- 'Content-Type': constants_1.CONTENT_TYPE.applicationZip,
58
- accept_language: (0, generic_1.addAcceptedLanguages)(),
59
- accept: constants_1.CONTENT_TYPE.applicationJson,
60
- },
61
- responseType: constants_1.RESPONSE_TYPE,
62
- validateStatus: () => { return true; },
63
- };
64
- const response = await requestService_1.requestService.axiosService(axiosConfig);
65
- let responseDataStr = '';
66
- if (Buffer.isBuffer(response.data)) {
67
- responseDataStr = response.data.toString();
68
- }
69
- else if (typeof response.data === 'string') {
70
- responseDataStr = response.data;
71
- }
72
- if (responseDataStr && responseDataStr.includes('CWSRV0255E')) {
73
- logger_1.logger.debug('Content handler path issue detected: CWSRV0255E or CWSRV0190E error');
74
- logger_1.logger.error((0, utils_1.errorMessage)('ERROR_INVALID_CONTENTHANDLER_SERVER_RESPONSE', {
75
- 0: cmdLineArgs.contenthandlerPath,
76
- 1: cmdLineArgs.hostname,
77
- 2: cmdLineArgs.dxPort,
78
- }));
79
- return false;
80
- }
81
- if (responseDataStr && responseDataStr.includes('CWSRV0190E')) {
82
- logger_1.logger.debug('Content handler path issue detected: CWSRV0190E error');
83
- logger_1.logger.error((0, utils_1.errorMessage)('ERROR_INVALID_CONTENTHANDLER'));
84
- return false;
85
- }
86
- if (response === undefined) {
87
- logger_1.logger.info('Please check dxProtocol/hostname/dxPort are valid or not');
88
- return false;
89
- }
90
- logger_1.logger.debug('response code: %s', response.status);
91
- logger_1.logger.debug('response Message: %s', response.statusText);
92
- if (response.data.length === 0 && response.status === constants_2.HttpStatus.SUCCESS) {
93
- logger_1.logger.info('WCM Content UUID provided does not exist.');
94
- return false;
95
- }
96
- if (response.status === constants_2.HttpStatus.SUCCESS) {
97
- filesServices_1.fileServices.unZip(contentRoot, response.data);
98
- logger_1.logger.info('Content pull was successful.');
99
- logger_1.logger.info('End content pull from Portal.');
100
- logger_1.logger.info((0, utils_1.message)('CommandLine.20', { 0: 'under logs folder' }));
101
- logger_1.logger.info(`ContentRoot path location: ${path_1.default.relative(process.cwd(), contentRoot)}`);
102
- status = true;
103
- }
104
- else if (response.status === constants_2.HttpStatus.NOT_FOUND) {
105
- logger_1.logger.info('Application pull failed ,please provide a valid URL/provide a valid contentID');
106
- status = false;
107
- }
108
- else if (response.status === constants_2.HttpStatus.UNAUTHORIZED) {
109
- logger_1.logger.info('Username/Password not valid.');
110
- status = false;
111
- }
112
- else if (response.status === constants_2.HttpStatus.INTERNAL_SERVER_ERROR) {
113
- logger_1.logger.info('Application pull failed, Internal server error occurred');
114
- status = false;
115
- }
116
- else {
117
- logger_1.logger.info('Application pull failed.');
118
- status = false;
119
- }
21
+ if (projectContext) {
22
+ logger_1.logger.debug('Adding project context: %s', projectContext);
23
+ const projectPrefix = '/$project';
24
+ urlPath += projectContext.startsWith('/')
25
+ ? `${projectPrefix}${projectContext}`
26
+ : `${projectPrefix}/${projectContext}`;
120
27
  }
121
- catch (err) {
122
- logger_1.logger.error('Application pull failed.', err);
28
+ return urlPath;
29
+ }
30
+ async invoke(cmdArgs) {
31
+ logger_1.logger.debug('Entering the pullScriptApplication function.');
32
+ logger_1.logger.info((0, utils_1.message)('SCRIPT_APPLICATION_PULL'));
33
+ const { wcmContentId } = cmdArgs;
34
+ if (!wcmContentId) {
35
+ logger_1.logger.error((0, utils_1.errorMessage)('ERROR_CONTENT_ID_NOT_FOUND'));
123
36
  return false;
124
37
  }
38
+ logger_1.logger.info((0, utils_1.message)('SCRIPT_APPLICATION_WCM_CONTENT_ID', { 0: wcmContentId }));
39
+ const contentRoot = cmdArgs.contentRoot
40
+ ? cmdArgs.contentRoot
41
+ : path_1.default.resolve((0, utils_1.getStoreDir)(), constants_1.CONTENT_ROOT, wcmContentId);
42
+ logger_1.logger.debug('contentRoot: %s', contentRoot);
43
+ const baseUrlPath = cmdArgs.contenthandlerPath || constants_1.DEFAULT_CONTENTHANDLER_PATH;
44
+ logger_1.logger.debug('Base urlPath: %s', baseUrlPath);
45
+ const urlPath = this.buildUrlPath(baseUrlPath, cmdArgs.virtualPortalContext, cmdArgs.projectContext);
46
+ logger_1.logger.debug('Final urlPath: %s', urlPath);
47
+ const parseUrl = `${cmdArgs.dxProtocol}://${cmdArgs.hostname}:${cmdArgs.dxPort}${urlPath}`;
48
+ logger_1.logger.debug('Complete parseUrl: %s', parseUrl);
49
+ const response = await deployscriptapplicationServices_1.deployscriptapplicationServices.deployscriptapplicationPull(wcmContentId, parseUrl, cmdArgs.dxUsername, cmdArgs.dxPassword, cmdArgs.contenthandlerPath || constants_1.DEFAULT_CONTENTHANDLER_PATH, cmdArgs.hostname, cmdArgs.dxPort, contentRoot);
125
50
  logger_1.logger.debug('Exiting the pullScriptApplication function.');
126
- return status;
127
- }
128
- async unzip(body, contentRoot) {
129
- logger_1.logger.debug('Entering unzip function');
130
- const excludes = null;
131
- let data = '';
132
- return new Promise((resolve, reject) => {
133
- const result = [];
134
- yauzl_1.default.fromBuffer(body, { lazyEntries: true }, (err, zipfile) => {
135
- if (err) {
136
- logger_1.logger.error(err);
137
- return reject(err);
138
- }
139
- zipfile.readEntry();
140
- zipfile.on('error', (error) => {
141
- logger_1.logger.error(error);
142
- return reject(error);
143
- });
144
- zipfile.on('entry', (entry) => {
145
- if (/\/$/.test(entry.fileName) || (0, generic_1.isExcluded)(entry.fileName, excludes)) {
146
- zipfile.readEntry();
147
- }
148
- else {
149
- zipfile.openReadStream(entry, (error, readStream) => {
150
- if (error) {
151
- logger_1.logger.error(error);
152
- return reject(error);
153
- }
154
- try {
155
- const filePath = path_1.default.resolve(contentRoot, entry.fileName);
156
- fs_extra_1.default.ensureDirSync(path_1.default.dirname(filePath));
157
- readStream.on('error', (errors) => {
158
- logger_1.logger.error(errors);
159
- return reject(errors);
160
- });
161
- readStream.on('end', () => {
162
- result[entry.fileName] = entry.uncompressedSize;
163
- zipfile.readEntry();
164
- logger_1.logger.info('Completed unzip process');
165
- });
166
- const writeStream = fs_extra_1.default.createWriteStream(filePath);
167
- writeStream.on('error', (errr) => {
168
- logger_1.logger.error(errr);
169
- return reject(errr);
170
- });
171
- readStream.pipe(writeStream);
172
- if (entry.fileName === constants_1.CONFIG_FILE) {
173
- readStream.on('data', (streamData) => {
174
- data += streamData;
175
- });
176
- readStream.on('end', () => {
177
- logger_1.logger.info('Content Config: %s', data);
178
- });
179
- }
180
- logger_1.logger.info('Content folder created for pull');
181
- }
182
- catch (errr) {
183
- logger_1.logger.error(errr);
184
- reject(errr);
185
- }
186
- return false;
187
- });
188
- }
189
- });
190
- zipfile.on('end', async () => {
191
- zipfile.close();
192
- logger_1.logger.info('Completed unzip process');
193
- resolve(result);
194
- fs_extra_1.default.unlink(path_1.default.resolve(contentRoot, constants_1.CONFIG_FILE));
195
- });
196
- return false;
197
- });
198
- });
51
+ if (response) {
52
+ logger_1.logger.info((0, utils_1.message)('SCRIPT_APPLICATION_PULL_SUCCESS'));
53
+ }
54
+ else {
55
+ logger_1.logger.error((0, utils_1.errorMessage)('SCRIPT_APPLICATION_PULL_FAILED', { 0: '', 1: '' }));
56
+ }
57
+ return response;
199
58
  }
200
59
  }
201
60
  exports.Pull = Pull;
@@ -1 +1 @@
1
- {"version":3,"file":"pull.js","sourceRoot":"","sources":["../../../../../packages/deployscriptapplication/src/commands/pull.ts"],"names":[],"mappings":";;;;;;AAcA,gDAAwB;AACxB,wDAA0B;AAC1B,kDAA0B;AAC1B,iDAE2B;AAC3B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K,EAAE,GAAG,EAAE;wCACxB,eAAM,CAAC,IAAI,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC;oCAC1C,CAAC,CAAC,CAAC;gCACL,CAAC;gCACD,eAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;4BACjD,CAAC;4BAAC,OAAO,IAAI,EAAE,CAAC;gCACd,eAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gCACnB,MAAM,CAAC,IAAI,CAAC,CAAC;4BACf,CAAC;4BACD,OAAO,KAAK,CAAC;wBACf,CAAC,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC,CAAC,CAAC;gBACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE;oBAC3B,OAAO,CAAC,KAAK,EAAE,CAAC;oBAChB,eAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;oBACvC,OAAO,CAAC,MAAM,CAAC,CAAC;oBAChB,kBAAE,CAAC,MAAM,CAAC,cAAI,CAAC,OAAO,CAAC,WAAW,EAAE,uBAAW,CAAC,CAAC,CAAC;gBACpD,CAAC,CAAC,CAAC;gBACH,OAAO,KAAK,CAAC;YACf,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA/LD,oBA+LC"}
1
+ {"version":3,"file":"pull.js","sourceRoot":"","sources":["../../../../../packages/deployscriptapplication/src/commands/pull.ts"],"names":[],"mappings":";;;;;;AAaA,gDAAwB;AACxB,iDAG2B;AAC3B,uDAIqC;AACrC,yDAAsD;AACtD,iGAA8F;AAE9F,MAAa,IAAI;IAIP,YAAY,CAClB,WAAmB,EACnB,oBAA6B,EAC7B,cAAuB;QAEvB,IAAI,OAAO,GAAG,WAAW,CAAC;QAE1B,IAAI,oBAAoB,EAAE,CAAC;YACzB,eAAM,CAAC,KAAK,CAAC,mCAAmC,EAAE,oBAAoB,CAAC,CAAC;YACxE,OAAO,IAAI,oBAAoB,CAAC,UAAU,CAAC,GA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K,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC;QAE9C,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAC/B,WAAW,EACX,OAAO,CAAC,oBAAoB,EAC5B,OAAO,CAAC,cAAc,CACvB,CAAC;QACF,eAAM,CAAC,KAAK,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;QAE3C,MAAM,QAAQ,GAAW,GAAG,OAAO,CAAC,UAAU,MAAM,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,OAAO,EAAE,CAAC;QACnG,eAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE,QAAQ,CAAC,CAAC;QAEhD,MAAM,QAAQ,GAAG,MAAM,iEAA+B,CAAC,2BAA2B,CAChF,YAAY,EACZ,QAAQ,EACR,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,kBAAkB,IAAI,uCAA2B,EACzD,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,MAAM,EACd,WAAW,CACZ,CAAC;QAEF,eAAM,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;QAC5D,IAAI,QAAQ,EAAE,CAAC;YACb,eAAM,CAAC,IAAI,CAAC,IAAA,eAAO,EAAC,iCAAiC,CAAC,CAAC,CAAC;QAC1D,CAAC;aAAM,CAAC;YACN,eAAM,CAAC,KAAK,CAAC,IAAA,oBAAY,EAAC,gCAAgC,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QACjF,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAjFD,oBAiFC"}
@@ -1,9 +1,16 @@
1
1
  import commander from 'commander';
2
+ export interface ScriptApplicationPushResponse {
3
+ status: string;
4
+ contentId: string;
5
+ message?: string;
6
+ importedFiles?: {
7
+ file?: {
8
+ filename?: string;
9
+ };
10
+ };
11
+ skippedFiles?: string;
12
+ }
2
13
  export declare class PushSP {
3
- zipFiles: string[];
4
- pushScriptApplication(cmdLineArgs: commander.OptionValues): Promise<any>;
5
- validateConfig(cmdLineArgs: commander.OptionValues): any;
6
- loadPrebuiltZip(prebuiltZipPath: string): Promise<boolean>;
7
- loadMainHtmlFile(cmdLineArgs: commander.OptionValues): void;
8
- logZipInfo(zipFilePath: string, zippedFiles: string[]): void;
14
+ private zipFiles;
15
+ invoke(cmdLineArgs: commander.OptionValues): Promise<ScriptApplicationPushResponse | false>;
9
16
  }
@@ -6,52 +6,56 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.PushSP = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
- const yauzl_1 = __importDefault(require("yauzl"));
10
9
  const form_data_1 = __importDefault(require("form-data"));
11
10
  const constants_1 = require("../util/constants");
12
- const generic_1 = require("../util/generic");
13
11
  const utils_1 = require("../../../../src/utils/utils");
14
- const requestService_1 = require("../../../../src/services/requestService");
15
12
  const logger_1 = require("../../../../src/utils/logger");
16
13
  const constants_2 = require("../../../../src/utils/constants");
17
14
  const filesServices_1 = require("../../../../src/services/filesServices");
15
+ const deployscriptapplicationServices_1 = require("../services/deployscriptapplicationServices");
16
+ const generic_1 = require("../util/generic");
18
17
  class PushSP {
19
18
  constructor() {
20
19
  this.zipFiles = [];
21
20
  }
22
- async pushScriptApplication(cmdLineArgs) {
21
+ async invoke(cmdLineArgs) {
23
22
  logger_1.logger.debug('Entering the pushScriptApplication function.');
24
23
  const { wcmContentId, wcmContentTitle, wcmContentPath, } = cmdLineArgs;
25
24
  logger_1.logger.debug('contentRoot: %s', cmdLineArgs.contentRoot);
26
- let urlPath = cmdLineArgs.contenthandlerPath ? cmdLineArgs.contenthandlerPath : constants_1.DEFAULT_CONTENTHANDLER_PATH;
25
+ let urlPath = cmdLineArgs.contenthandlerPath || constants_1.DEFAULT_CONTENTHANDLER_PATH;
27
26
  logger_1.logger.debug('urlPath: %s', urlPath);
28
27
  if (cmdLineArgs.virtualPortalContext) {
29
- if (cmdLineArgs.virtualPortalContext.startsWith('/')) {
30
- urlPath += `${cmdLineArgs.virtualPortalContext}`;
31
- }
32
- else {
33
- urlPath += `/${cmdLineArgs.virtualPortalContext}`;
34
- }
28
+ urlPath += cmdLineArgs.virtualPortalContext.startsWith('/')
29
+ ? cmdLineArgs.virtualPortalContext
30
+ : `/${cmdLineArgs.virtualPortalContext}`;
31
+ logger_1.logger.debug('Added virtual portal context: %s', cmdLineArgs.virtualPortalContext);
35
32
  }
36
33
  if (cmdLineArgs.projectContext) {
37
- if (cmdLineArgs.projectContext.startsWith('/')) {
38
- urlPath += `/$project${cmdLineArgs.projectContext}`;
34
+ const projectPrefix = '/$project';
35
+ urlPath += cmdLineArgs.projectContext.startsWith('/')
36
+ ? `${projectPrefix}${cmdLineArgs.projectContext}`
37
+ : `${projectPrefix}/${cmdLineArgs.projectContext}`;
38
+ logger_1.logger.debug('Added project context: %s', cmdLineArgs.projectContext);
39
+ }
40
+ if (cmdLineArgs.prebuiltZip) {
41
+ const prebuiltZipStat = fs_extra_1.default.existsSync(cmdLineArgs.prebuiltZip) ? fs_extra_1.default.statSync(cmdLineArgs.prebuiltZip) : null;
42
+ if (prebuiltZipStat && prebuiltZipStat.isDirectory()) {
43
+ logger_1.logger.error((0, utils_1.errorMessage)('ERROR_CONTENT_ROOT_NOT_FOUND'));
44
+ cmdLineArgs.prebuiltZip = '';
39
45
  }
40
46
  else {
41
- urlPath += `/$project/${cmdLineArgs.projectContext}`;
47
+ this.zipFiles = await (0, generic_1.loadPrebuiltZip)(cmdLineArgs.prebuiltZip);
42
48
  }
43
49
  }
44
- if (cmdLineArgs.prebuiltZip) {
45
- await this.loadPrebuiltZip(cmdLineArgs.prebuiltZip);
46
- }
47
- const constructedContentpath = this.validateConfig(cmdLineArgs);
50
+ const constructedContentpath = (0, generic_1.validateConfig)(cmdLineArgs, this.zipFiles);
48
51
  logger_1.logger.debug('constructedContentpath: %s', constructedContentpath);
49
52
  if (constructedContentpath === false) {
53
+ logger_1.logger.error((0, utils_1.errorMessage)('ERROR_CONFIG_VALIDATION_FAILED'));
50
54
  return false;
51
55
  }
52
- const wcmContentPaths = cmdLineArgs.wcmContentPath ? cmdLineArgs.wcmContentPath : constructedContentpath;
56
+ const wcmContentPaths = cmdLineArgs.wcmContentPath || constructedContentpath;
53
57
  logger_1.logger.debug('wcmContentPaths: %s', wcmContentPaths);
54
- this.loadMainHtmlFile(cmdLineArgs);
58
+ (0, generic_1.loadMainHtmlFile)(cmdLineArgs, this.zipFiles);
55
59
  logger_1.logger.info((0, utils_1.message)('PushCommand.4'));
56
60
  let zipFilePath;
57
61
  let zippedFiles;
@@ -64,22 +68,23 @@ class PushSP {
64
68
  logger_1.logger.info((0, utils_1.message)('PushCommand.11', { 0: cmdLineArgs.mainHtmlFile }));
65
69
  zipFilePath = cmdLineArgs.prebuiltZip;
66
70
  if (!zipFilePath) {
67
- logger_1.logger.info('PrebuiltZip path does not exist.');
71
+ logger_1.logger.debug('Creating zip file from content root');
68
72
  zippedFiles = await filesServices_1.fileServices.createZip(path_1.default.resolve(cmdLineArgs.contentRoot));
69
73
  zipFilePath = zippedFiles.zipFilePaths[0].toString();
70
74
  this.zipFiles = zippedFiles.zipContents;
75
+ logger_1.logger.debug('Zip file created successfully: %s', zipFilePath);
71
76
  }
72
- this.logZipInfo(zipFilePath, this.zipFiles);
77
+ (0, generic_1.logZipInfo)(zipFilePath, this.zipFiles);
73
78
  const fileSize = fs_extra_1.default.statSync(zipFilePath).size + constants_2.REQUEST_BUFFER;
74
79
  const form = new form_data_1.default();
75
80
  const formOptions = { contentType: constants_1.CONTENT_TYPE.applicationUrl };
76
81
  if (wcmContentId) {
77
82
  form.append(constants_1.ConfigKeys.WCM_CONTENT_ID, wcmContentId, formOptions);
78
83
  }
79
- if (wcmContentPaths && wcmContentPaths.length) {
84
+ if (wcmContentPaths?.length) {
80
85
  form.append(constants_1.ConfigKeys.WCM_CONTENT_PATH, wcmContentPaths, formOptions);
81
86
  }
82
- if (wcmContentTitle && wcmContentTitle.length) {
87
+ if (wcmContentTitle?.length) {
83
88
  form.append(constants_1.ConfigKeys.WCM_CONTENT_TITLE, wcmContentTitle, formOptions);
84
89
  }
85
90
  form.append(constants_1.ConfigKeys.MAIN_HTML_FILE, cmdLineArgs.mainHtmlFile, formOptions);
@@ -87,62 +92,11 @@ class PushSP {
87
92
  filename: path_1.default.basename(zipFilePath),
88
93
  contentType: constants_1.CONTENT_TYPE.applicationZip,
89
94
  });
90
- const auth = (0, utils_1.baseEncode)(cmdLineArgs.dxUsername, cmdLineArgs.dxPassword);
91
- const axiosConfig = {
92
- method: 'POST',
93
- url: postUrl,
94
- params: {
95
- uri: `${constants_1.DEFAULT_PUSH_URI_PATH}${wcmContentId || null}`,
96
- },
97
- data: form,
98
- headers: {
99
- ...form.getHeaders(),
100
- Authorization: auth,
101
- accept_language: (0, generic_1.addAcceptedLanguages)(),
102
- accept: constants_1.CONTENT_TYPE.applicationJson,
103
- },
104
- maxContentLength: fileSize,
105
- maxBodyLength: fileSize,
106
- validateStatus: (status) => { return true; },
107
- };
108
- const response = await requestService_1.requestService.axiosService(axiosConfig);
109
- if (response === undefined) {
110
- logger_1.logger.error((0, utils_1.errorMessage)('ERROR_INVALID_SERVER'));
111
- return false;
112
- }
113
- if (response.data
114
- && typeof response.data === 'string'
115
- && (response.data.includes('CWSRV0255E'))) {
116
- logger_1.logger.debug('Content handler path issue detected: CWSRV0255E or CWSRV0190E error');
117
- logger_1.logger.error((0, utils_1.errorMessage)('ERROR_INVALID_CONTENTHANDLER_SERVER_RESPONSE', {
118
- 0: cmdLineArgs.contenthandlerPath,
119
- 1: cmdLineArgs.hostname,
120
- 2: cmdLineArgs.dxPort,
121
- }));
122
- return false;
123
- }
124
- if (response.data
125
- && typeof response.data === 'string'
126
- && (response.data.includes('CWSRV0190E'))) {
127
- logger_1.logger.debug('Content handler path issue detected: CWSRV0190E error');
128
- logger_1.logger.error((0, utils_1.errorMessage)('ERROR_INVALID_CONTENTHANDLER'));
129
- return false;
130
- }
131
- if (response.status === constants_2.HttpStatus.SUCCESS) {
132
- logger_1.logger.info((0, utils_1.message)('PushCommand.31'));
133
- logger_1.logger.info((0, utils_1.message)('PushCommand.32'));
134
- logger_1.logger.info((0, utils_1.message)('GenericResponseHandler.13', { 0: `${JSON.stringify(response.data)}` }));
135
- return response.data;
136
- }
137
- if (response.status === constants_2.HttpStatus.UNAUTHORIZED) {
138
- logger_1.logger.error((0, utils_1.errorMessage)('ERROR_CMDLN_AUTHN_FAILURE_0'));
139
- logger_1.logger.error((0, utils_1.errorMessage)('ERROR_CMDLN_AUTHN_FAILURE_0.explanation'));
140
- return false;
141
- }
142
- if (response.data.error || response.status !== constants_2.HttpStatus.SUCCESS) {
143
- logger_1.logger.error((0, utils_1.errorMessage)('ERROR_CMDLN_PUSH_FAILED_0', { 0: response.data.error || response.statusText }));
95
+ const response = await deployscriptapplicationServices_1.deployscriptapplicationServices.deployscriptapplicationPush(postUrl, wcmContentId, form, fileSize, cmdLineArgs.dxUsername, cmdLineArgs.dxPassword, cmdLineArgs.contenthandlerPath || constants_1.DEFAULT_CONTENTHANDLER_PATH, cmdLineArgs.hostname, cmdLineArgs.dxPort);
96
+ if (response === false) {
144
97
  return false;
145
98
  }
99
+ return response;
146
100
  }
147
101
  catch (err) {
148
102
  logger_1.logger.error((0, utils_1.errorMessage)('ERROR_CMDLN_PUSH_FAILED_0', { 0: err.message || err }));
@@ -150,142 +104,10 @@ class PushSP {
150
104
  }
151
105
  finally {
152
106
  if (zipFilePath && !cmdLineArgs.prebuiltZip) {
107
+ logger_1.logger.debug('Removing temporary zip file: %s', zipFilePath);
153
108
  fs_extra_1.default.removeSync(zipFilePath);
154
109
  }
155
110
  }
156
- logger_1.logger.debug('Exiting the pushScriptApplication function.');
157
- return true;
158
- }
159
- validateConfig(cmdLineArgs) {
160
- logger_1.logger.debug('Entering the validateConfig function.');
161
- if (!cmdLineArgs.prebuiltZip) {
162
- if (!fs_extra_1.default.existsSync(path_1.default.resolve(cmdLineArgs.contentRoot))) {
163
- logger_1.logger.info((0, utils_1.errorMessage)('ERROR_CMDLN_PUSH_REQUIRES_APP_0'));
164
- return false;
165
- }
166
- if (!fs_extra_1.default.existsSync(path_1.default.resolve(cmdLineArgs.contentRoot, cmdLineArgs.mainHtmlFile))) {
167
- logger_1.logger.info((0, utils_1.errorMessage)('ERROR_CMDLN_MISSING_HTML_1', { 0: cmdLineArgs.mainHtmlFile }));
168
- return false;
169
- }
170
- }
171
- else {
172
- if (!fs_extra_1.default.existsSync(cmdLineArgs.prebuiltZip)) {
173
- logger_1.logger.info((0, utils_1.errorMessage)('ERROR_CMDLN_MISSING_ZIP_1', { 0: cmdLineArgs.prebuiltZip }));
174
- return false;
175
- }
176
- if (this.zipFiles && this.zipFiles.length > 0 && this.zipFiles.indexOf(cmdLineArgs.mainHtmlFile) < 0) {
177
- logger_1.logger.info((0, utils_1.errorMessage)('ERROR_CMDLN_NO_HTML_ZIP_1', { 0: cmdLineArgs.mainHtmlFile }));
178
- return false;
179
- }
180
- }
181
- let count = 0;
182
- count += cmdLineArgs.wcmContentId ? 1 : 0;
183
- count += cmdLineArgs.wcmContentName ? 1 : 0;
184
- count += cmdLineArgs.wcmContentPath ? 1 : 0;
185
- if (count === 0) {
186
- logger_1.logger.info((0, utils_1.errorMessage)('ERROR_CMDLN_MISSING_ARG_3', { 0: constants_1.ConfigKeys.WCM_CONTENT_ID, 1: constants_1.ConfigKeys.WCM_CONTENT_NAME, 2: constants_1.ConfigKeys.WCM_CONTENT_PATH }));
187
- return false;
188
- }
189
- if (count > 1) {
190
- logger_1.logger.info((0, utils_1.errorMessage)('ERROR_CMDLN_CONFLICTING_ARGS_3', { 0: constants_1.ConfigKeys.WCM_CONTENT_ID, 1: constants_1.ConfigKeys.WCM_CONTENT_NAME, 2: constants_1.ConfigKeys.WCM_CONTENT_PATH }));
191
- return false;
192
- }
193
- if (cmdLineArgs.wcmContentName) {
194
- if (!cmdLineArgs.wcmSiteArea) {
195
- logger_1.logger.info((0, utils_1.errorMessage)('ERROR_CMDLN_MISSING_ARG_2', { 0: constants_1.ConfigKeys.WCM_CONTENT_NAME, 1: constants_1.ConfigKeys.WCM_SITE_AREA }));
196
- return false;
197
- }
198
- const separator = cmdLineArgs.wcmSiteArea.endsWith(constants_1.SLASH) || cmdLineArgs.wcmContentName.startsWith(constants_1.SLASH) ? '' : constants_1.SLASH;
199
- logger_1.logger.debug('separator : %s', separator);
200
- cmdLineArgs.wcmContentPaths = cmdLineArgs.wcmSiteArea + separator + cmdLineArgs.wcmContentName;
201
- logger_1.logger.debug('updated wcmContentPaths : %s', cmdLineArgs.wcmContentPaths);
202
- }
203
- logger_1.logger.debug('Exiting the validateConfig function.');
204
- return cmdLineArgs.wcmContentPaths;
205
- }
206
- async loadPrebuiltZip(prebuiltZipPath) {
207
- logger_1.logger.debug('Entering the loadPrebuiltZip function.');
208
- logger_1.logger.debug('prebuiltZipPath: %s', prebuiltZipPath);
209
- this.zipFiles = [];
210
- const zipPath = path_1.default.resolve(prebuiltZipPath);
211
- logger_1.logger.debug('zipPath: %s', zipPath);
212
- await new Promise((resolve, reject) => {
213
- yauzl_1.default.open(zipPath, { lazyEntries: true }, (err, zipfile) => {
214
- if (err) {
215
- logger_1.logger.error('Error in loading zip file %o', err);
216
- return false;
217
- }
218
- zipfile.readEntry();
219
- zipfile.on('error', (error) => {
220
- logger_1.logger.error(error);
221
- return false;
222
- });
223
- zipfile.on('entry', (entry) => {
224
- if (/\/$/.test(entry.fileName)) {
225
- zipfile.readEntry();
226
- }
227
- else {
228
- this.zipFiles.push(entry.fileName);
229
- zipfile.readEntry();
230
- }
231
- });
232
- zipfile.on('end', async () => {
233
- logger_1.logger.info('Unzip(Prebuildzip) completed');
234
- zipfile.close();
235
- resolve(1);
236
- });
237
- return true;
238
- });
239
- });
240
- logger_1.logger.debug('Exiting the loadPrebuiltZip function.');
241
- return true;
242
- }
243
- loadMainHtmlFile(cmdLineArgs) {
244
- logger_1.logger.debug('Entering the loadMainHtmlFile function.');
245
- logger_1.logger.debug('mainHtmlFile %s, prebuiltZip: %s', cmdLineArgs.mainHtmlFile, cmdLineArgs.prebuiltZip);
246
- if (!cmdLineArgs.mainHtmlFile) {
247
- if (cmdLineArgs.prebuiltZip) {
248
- if (this.zipFiles.indexOf(constants_1.INDEX_HTM) > -1) {
249
- cmdLineArgs.mainHtmlFile = constants_1.INDEX_HTM;
250
- }
251
- else if (this.zipFiles.indexOf(constants_1.INDEX_HTML) > -1) {
252
- cmdLineArgs.mainHtmlFile = constants_1.INDEX_HTML;
253
- }
254
- }
255
- else if (fs_extra_1.default.existsSync(path_1.default.resolve(cmdLineArgs.contentRoot, constants_1.INDEX_HTM))) {
256
- cmdLineArgs.mainHtmlFile = constants_1.INDEX_HTM;
257
- }
258
- else if (fs_extra_1.default.existsSync(path_1.default.resolve(cmdLineArgs.contentRoot, constants_1.INDEX_HTML))) {
259
- cmdLineArgs.mainHtmlFile = constants_1.INDEX_HTML;
260
- }
261
- logger_1.logger.debug('Updated mainHtmlFile: %s', cmdLineArgs.mainHtmlFile);
262
- if (!cmdLineArgs.mainHtmlFile) {
263
- logger_1.logger.info('Please enter main HTML file');
264
- }
265
- }
266
- logger_1.logger.debug('Exiting the loadMainHtmlFile function.');
267
- }
268
- logZipInfo(zipFilePath, zippedFiles) {
269
- logger_1.logger.debug('Entering the logZipInfo function.');
270
- logger_1.logger.debug('zipFilePath: %s, zippedFiles: %s', zipFilePath, zippedFiles);
271
- let fileSize = 0;
272
- let entryList = '';
273
- let numberOfEntries;
274
- try {
275
- fileSize = fs_extra_1.default.statSync(zipFilePath).size;
276
- zippedFiles.forEach((zf) => {
277
- entryList += `${constants_1.EOL}\t${zf}`;
278
- });
279
- numberOfEntries = zippedFiles.length;
280
- }
281
- catch (err) {
282
- numberOfEntries = (0, utils_1.message)('Logger.24');
283
- entryList = '';
284
- }
285
- logger_1.logger.info((0, utils_1.message)('Logger.26', {
286
- 0: `${constants_1.EOL}${constants_1.EOL}\t${zipFilePath}${constants_1.EOL}\t`, 1: fileSize, 2: numberOfEntries, 3: `${constants_1.EOL}${entryList}`,
287
- }));
288
- logger_1.logger.debug('Exiting the logZipInfo function.');
289
111
  }
290
112
  }
291
113
  exports.PushSP = PushSP;