@hcl-software/dxclient 221.0.0 → 222.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.
- package/{README.txt → README.md} +1 -0
- package/dist/configuration/versionConfigMap.json +1 -0
- package/dist/package.json +2 -2
- package/dist/packages/livesync/package-lock.json +7 -0
- package/dist/packages/livesync/package.json +2 -0
- package/dist/packages/livesync/src/commands/pullWcmDesignLibrary.js +4 -4
- package/dist/packages/livesync/src/commands/pullWcmDesignLibrary.js.map +1 -1
- package/dist/packages/livesync/src/commands/pushWcmDesignLibrary.d.ts +16 -0
- package/dist/packages/livesync/src/commands/pushWcmDesignLibrary.js +448 -0
- package/dist/packages/livesync/src/commands/pushWcmDesignLibrary.js.map +1 -1
- package/dist/packages/livesync/src/errors/CommandLineMessages_en.json +28 -1
- package/dist/packages/livesync/src/messages/messages_en.json +10 -1
- package/dist/packages/livesync/src/services/EventsQueue.js.map +1 -1
- package/dist/packages/livesync/src/services/livesyncUtils.d.ts +2 -0
- package/dist/packages/livesync/src/services/livesyncUtils.js +9 -1
- package/dist/packages/livesync/src/services/livesyncUtils.js.map +1 -1
- package/dist/packages/livesync/src/services/metadataServices.d.ts +7 -2
- package/dist/packages/livesync/src/services/metadataServices.js +67 -27
- package/dist/packages/livesync/src/services/metadataServices.js.map +1 -1
- package/dist/packages/livesync/src/services/ongoingSyncServices.d.ts +6 -0
- package/dist/packages/livesync/src/services/ongoingSyncServices.js +383 -2
- package/dist/packages/livesync/src/services/ongoingSyncServices.js.map +1 -1
- package/dist/packages/livesync/src/types/EventQueueItem.type.d.ts +5 -1
- package/dist/packages/livesync/src/types/WcmRestApiV2.type.d.ts +1 -0
- package/dist/src/index.js +14 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/utils/constants.d.ts +13 -1
- package/dist/src/utils/constants.js +17 -1
- package/dist/src/utils/constants.js.map +1 -1
- package/dist/src/utils/utils.js +2 -1
- package/dist/src/utils/utils.js.map +1 -1
- package/package.json +2 -2
package/{README.txt → README.md}
RENAMED
|
@@ -264,6 +264,7 @@ Note that a few parameters are deprecated and replaced with new parameters in th
|
|
|
264
264
|
* DXClient Version Type(Node/Container) information available using help/version-compat commands
|
|
265
265
|
* A one time license agreement click-through is enabled. To skip the prompt, use "accept-license" command.
|
|
266
266
|
* DXClient will be openly distributed in NpmJS & harbor repository.
|
|
267
|
+
* In DAM Staging tasks, the parameters dxWASUsername, dxWASPassword, targetServerWASUsername, and targetServerWASPassword are now deprecated and should no longer be used.
|
|
267
268
|
|
|
268
269
|
## DXClient configuration
|
|
269
270
|
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hcl-software/dxclient",
|
|
3
3
|
"description": "DXClient is a CLI tool to manage tasks such as deploying portlets, script applications and themes easily from source development environments to target HCL DX deployments. This tool is capable of taking artifacts developed locally and deploying them into DX servers deployed on supported on-premise platforms in standalone, cluster or farm topologies and Kubernetes. Kubernetes platforms are supported for HCL Digital Experience 9.5 CF192 and higher only. \n\nCommon command arguments that are listed in `config.json` can be pre-configured via this file. The common arguments could also be provided through command line. If so, it will override the values in `config.json` and execute. A sample configuration file 'default-config-kube.json' for Kubernetes environments is available under the 'samples/sample-configurations' folder for reference.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "222.0.0",
|
|
5
5
|
"license": "Licensed Materials - Property of HCL, Copyright HCL Technologies Ltd. 2020, 2024. All Rights Reserved.",
|
|
6
6
|
"bin": {
|
|
7
7
|
"dxclient": "bin/dxclient"
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"coverageThreshold": {
|
|
121
121
|
"global": {
|
|
122
122
|
"branches": 85.53,
|
|
123
|
-
"functions": 94.
|
|
123
|
+
"functions": 94.74,
|
|
124
124
|
"lines": 93.19,
|
|
125
125
|
"statements": 93.31
|
|
126
126
|
}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@enchanted-prod/eslint-config-eslint": "^1.2.2",
|
|
16
|
+
"@types/mime-types": "^2.1.4",
|
|
16
17
|
"@types/node": "^18.0.0",
|
|
17
18
|
"jest": "^26.5.2",
|
|
18
19
|
"ts-jest": "^26.4.1",
|
|
@@ -1399,6 +1400,12 @@
|
|
|
1399
1400
|
"integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==",
|
|
1400
1401
|
"dev": true
|
|
1401
1402
|
},
|
|
1403
|
+
"node_modules/@types/mime-types": {
|
|
1404
|
+
"version": "2.1.4",
|
|
1405
|
+
"resolved": "https://registry.npmjs.org/@types/mime-types/-/mime-types-2.1.4.tgz",
|
|
1406
|
+
"integrity": "sha512-lfU4b34HOri+kAY5UheuFMWPDOI+OPceBSHZKp69gEyTL/mmJ4cnU6Y/rlme3UL3GyOn6Y42hyIEw0/q8sWx5w==",
|
|
1407
|
+
"dev": true
|
|
1408
|
+
},
|
|
1402
1409
|
"node_modules/@types/node": {
|
|
1403
1410
|
"version": "18.11.10",
|
|
1404
1411
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.10.tgz",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@enchanted-prod/eslint-config-eslint": "^1.2.2",
|
|
12
|
+
"@types/mime-types": "^2.1.4",
|
|
12
13
|
"@types/node": "^18.0.0",
|
|
13
14
|
"jest": "^26.5.2",
|
|
14
15
|
"ts-jest": "^26.4.1",
|
|
@@ -18,6 +19,7 @@
|
|
|
18
19
|
"clean": "rimraf '{dist}/**/*.{js,js.map}'",
|
|
19
20
|
"build": "tsc && mkdir -p dist/messages && cp src/messages/* dist/messages && mkdir -p dist/errors && cp src/errors/* dist/errors",
|
|
20
21
|
"test": "NODE_TLS_REJECT_UNAUTHORIZED=0 CI=true jest --coverage",
|
|
22
|
+
"test-unit": "NODE_TLS_REJECT_UNAUTHORIZED=0 CI=true jest --verbose --runInBand --watchAll=false --testMatch \"**/src/__tests__/(unit)/[^d].(ts)\" --coverage",
|
|
21
23
|
"start": "node .",
|
|
22
24
|
"lint-doc": "eslint --ext md doc/technical-decisions",
|
|
23
25
|
"lint": "eslint --ext .ts src",
|
|
@@ -76,7 +76,7 @@ class PullWcmDesignLibrary {
|
|
|
76
76
|
const component = libraryComponents[index];
|
|
77
77
|
try {
|
|
78
78
|
const libraryResponseHtmlComp = yield htmlComponentWcmServices_1.getHTMLComponent(this.apiOptions, component.id);
|
|
79
|
-
const metadataOutput = metadataServices_1.createComponentsMeta(this.libraryPath, libraryResponseHtmlComp.data, component.parentID);
|
|
79
|
+
const metadataOutput = metadataServices_1.createComponentsMeta(this.libraryPath, libraryResponseHtmlComp.data, component.parentID, libraryId);
|
|
80
80
|
metadataServices_1.createHtmlFile(metadataOutput, this.libraryPath, libraryId);
|
|
81
81
|
}
|
|
82
82
|
catch (error) {
|
|
@@ -103,12 +103,12 @@ class PullWcmDesignLibrary {
|
|
|
103
103
|
logger_1.logger.debug(`Library found: ${libraryFromSearch.title} - ${libraryFromSearch.id}`);
|
|
104
104
|
return libraryFromSearch.id;
|
|
105
105
|
}
|
|
106
|
-
logger_1.logger.
|
|
106
|
+
logger_1.logger.debug(utils_1.errorMessage('ERROR_WCM_DESIGN_LIBRARY_PULL_NOT_FOUND', { 0: libraryName }));
|
|
107
107
|
throw new Error(utils_1.errorMessage('ERROR_WCM_DESIGN_LIBRARY_PULL_NOT_FOUND', { 0: libraryName }));
|
|
108
108
|
}
|
|
109
109
|
catch (error) {
|
|
110
110
|
logger_1.logger.error(utils_1.errorMessage('ERROR_WCM_DESIGN_LIBRARY_PULL_GENERIC', { 0: libraryName, 1: error }));
|
|
111
|
-
|
|
111
|
+
throw new Error(error);
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
114
|
}
|
|
@@ -120,7 +120,7 @@ class PullWcmDesignLibrary {
|
|
|
120
120
|
}
|
|
121
121
|
catch (error) {
|
|
122
122
|
logger_1.logger.error(utils_1.errorMessage('ERROR_WCM_DESIGN_LIBRARY_PULL_GENERIC', { 0: libraryId, 1: error }));
|
|
123
|
-
|
|
123
|
+
throw new Error(error);
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
126
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pullWcmDesignLibrary.js","sourceRoot":"","sources":["../../../../../packages/livesync/src/commands/pullWcmDesignLibrary.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAYA,gDAAwB;AACxB,yDAAsD;AACtD,qEAEuC;AACvC,uEAAuE;AAKvE,mEAEsC;AACtC,0EAAsE;AACtE,+DAAkE;AAClE,6DAA+E;AAC/E,uDAAoE;AACpE,mFAAwE;AAKxE,MAAa,oBAAoB;IA2BzB,MAAM,CAAC,OAA0B;;;YACrC,eAAM,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;YACjE,OAAO,CAAC,GAAG,CAAC,4BAA4B,GAAG,GAAG,CAAC;YAC/C,IAAI,WAAW,GAAG,OAAO,CAAC,WAAW,KAAI,MAAA,OAAO,CAAC,eAAe,0CAAE,IAAI,CAAA,CAAC;YACvE,WAAW,GAAG,WAAW,IAAI,OAAO,CAAC,SAAS,CAAC;YAC/C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;YACvC,eAAM,CAAC,IAAI,CAAC,eAAO,CAAC,iCAAiC,EAAE,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;YACpG,IAAI,CAAC,UAAU,GAAG;gBAChB,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;gBAC9C,UAAU,EAAE,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KAAK,CAAC,oBAAY,CAAC,6CAA6C,EAAE,EAAE,CAAC,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;gBACxG,OAAO,IAAI,CAAC;aACb;QACH,CAAC;KAAA;IAQa,qBAAqB,CAAC,MAAc,EAAE,UAAkB;;YACpE,IAAI,MAAM,uCAAuB,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE;gBAC1D,MAAM,CAAC,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;gBACtD,IAAI,mCAAgB,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE;oBAC9C,OAAO,MAAM,CAAC;iBACf;aACF;YACD,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;CACF;AAhOD,oDAgOC"}
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import commander from 'commander';
|
|
2
|
+
import chokidar from 'chokidar';
|
|
3
|
+
import { EventsQueue } from '../services/EventsQueue';
|
|
4
|
+
import { OngoingSyncHooks } from '../types';
|
|
2
5
|
export declare class PushWcmDesignLibrary {
|
|
6
|
+
private libraryPath;
|
|
7
|
+
private savedMetadata;
|
|
8
|
+
private apiOptions;
|
|
9
|
+
private libraryMetaData;
|
|
10
|
+
watcher: chokidar.FSWatcher;
|
|
11
|
+
eventsQueue: EventsQueue;
|
|
3
12
|
invoke(cmdArgs: commander.Command): Promise<boolean>;
|
|
13
|
+
deleteFoldersAndFiles(libraryPath: string): Promise<boolean>;
|
|
14
|
+
private deleteRootMissingFolder;
|
|
15
|
+
private pushAll;
|
|
16
|
+
private pushHTMLFile;
|
|
17
|
+
private pushFolderComponent;
|
|
18
|
+
ongoingSync(cmdArgs: commander.Command, hooks?: OngoingSyncHooks): void;
|
|
19
|
+
closeWatcher(emitIsSuccess: boolean, hooks?: OngoingSyncHooks): Promise<void>;
|
|
4
20
|
}
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
23
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,16 +27,445 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
27
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
28
|
});
|
|
10
29
|
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
11
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
34
|
exports.PushWcmDesignLibrary = void 0;
|
|
35
|
+
const path_1 = __importStar(require("path"));
|
|
36
|
+
const fs_1 = __importDefault(require("fs"));
|
|
37
|
+
const fs_extra_1 = require("fs-extra");
|
|
38
|
+
const chokidar_1 = __importDefault(require("chokidar"));
|
|
39
|
+
const lodash_1 = require("lodash");
|
|
13
40
|
const logger_1 = require("../../../../src/utils/logger");
|
|
41
|
+
const metadataServices_1 = require("../services/metadataServices");
|
|
42
|
+
const htmlComponentWcmServices_1 = require("../services/htmlComponentWcmServices");
|
|
43
|
+
const constants_1 = require("../../../../src/utils/constants");
|
|
44
|
+
const foldersWcmServices_1 = require("../services/foldersWcmServices");
|
|
45
|
+
const utils_1 = require("../../../../src/utils/utils");
|
|
46
|
+
const filesServices_1 = require("../../../../src/services/filesServices");
|
|
47
|
+
const EventsQueue_1 = require("../services/EventsQueue");
|
|
48
|
+
const livesyncUtils_1 = require("../services/livesyncUtils");
|
|
49
|
+
const ongoingSyncServices_1 = require("../services/ongoingSyncServices");
|
|
14
50
|
class PushWcmDesignLibrary {
|
|
51
|
+
constructor() {
|
|
52
|
+
this.watcher = null;
|
|
53
|
+
this.eventsQueue = null;
|
|
54
|
+
}
|
|
15
55
|
invoke(cmdArgs) {
|
|
16
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
57
|
logger_1.logger.debug('LiveSync Push WCM Design Library invoke function');
|
|
58
|
+
let isSuccess = false;
|
|
59
|
+
this.libraryPath = cmdArgs.libraryPath;
|
|
60
|
+
this.savedMetadata = metadataServices_1.getSavedMetadata(cmdArgs.libraryPath);
|
|
61
|
+
this.libraryMetaData = metadataServices_1.getLibraryMetadata(this.libraryPath);
|
|
62
|
+
const libraryName = this.libraryMetaData.name;
|
|
63
|
+
this.apiOptions = {
|
|
64
|
+
dxProtocol: cmdArgs.dxProtocol,
|
|
65
|
+
hostname: cmdArgs.hostname,
|
|
66
|
+
dxPort: cmdArgs.dxPort,
|
|
67
|
+
contenthandlerPath: cmdArgs.contenthandlerPath,
|
|
68
|
+
dxUsername: cmdArgs.dxUsername,
|
|
69
|
+
dxPassword: cmdArgs.dxPassword,
|
|
70
|
+
};
|
|
71
|
+
try {
|
|
72
|
+
isSuccess = yield this.pushAll(cmdArgs.libraryPath);
|
|
73
|
+
if (isSuccess) {
|
|
74
|
+
yield this.deleteFoldersAndFiles(cmdArgs.libraryPath);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
this.savedMetadata = metadataServices_1.getSavedMetadata(cmdArgs.libraryPath);
|
|
80
|
+
return new Promise((resolve) => {
|
|
81
|
+
this.ongoingSync(cmdArgs, {
|
|
82
|
+
onWatcherClose: (ongoingSyncSuccess) => __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
if (!ongoingSyncSuccess) {
|
|
84
|
+
logger_1.logger.error(utils_1.errorMessage('ERROR_WCM_DESIGN_LIBRARY_ONGOING_PUSH', { 0: libraryName }));
|
|
85
|
+
resolve(false);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
logger_1.logger.info(utils_1.message('LIVESYNC_PUSH_WCM_DESIGN_LIBRARY_END_SUCCESS'));
|
|
89
|
+
resolve(true);
|
|
90
|
+
}
|
|
91
|
+
}),
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
logger_1.logger.error(utils_1.errorMessage('ERROR_WCM_DESIGN_LIBRARY_PUSH_GENERIC', { 0: libraryName, 1: error.message }));
|
|
97
|
+
isSuccess = false;
|
|
98
|
+
}
|
|
99
|
+
return isSuccess;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
deleteFoldersAndFiles(libraryPath) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
const deletelogic = Object.entries(this.savedMetadata).map(([key, entry]) => __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
if (!this.savedMetadata[key])
|
|
106
|
+
return;
|
|
107
|
+
const isSuccess = fs_extra_1.existsSync(entry.localPath);
|
|
108
|
+
if (!isSuccess && entry.type === 'Folder') {
|
|
109
|
+
if (yield this.deleteRootMissingFolder(entry.parentID, entry.id)) {
|
|
110
|
+
const metadataPath = path_1.join(libraryPath, '.library', 'folders', `${entry.id}.json`);
|
|
111
|
+
logger_1.logger.debug('=====================');
|
|
112
|
+
logger_1.logger.debug('deleting metadata: ', metadataPath);
|
|
113
|
+
fs_1.default.rmSync(metadataPath, { recursive: true, force: true });
|
|
114
|
+
this.savedMetadata[key] = null;
|
|
115
|
+
logger_1.logger.debug('Deleted Folders And Files successfully');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else if (!isSuccess && entry.type === 'LibraryHTMLComponent') {
|
|
119
|
+
const resp = yield htmlComponentWcmServices_1.deleteHtmlComponent(this.apiOptions, `${entry.id}`);
|
|
120
|
+
if ([204, 404].includes(resp.status)) {
|
|
121
|
+
try {
|
|
122
|
+
const metadataPath = path_1.join(libraryPath, '.library', 'components', `${entry.id}.json`);
|
|
123
|
+
fs_1.default.rmSync(metadataPath, { recursive: true, force: true });
|
|
124
|
+
logger_1.logger.debug('Html file deleted successfully');
|
|
125
|
+
}
|
|
126
|
+
catch (err) {
|
|
127
|
+
logger_1.logger.error(utils_1.errorMessage('ERROR_DELETE_HTML_FILE', { 0: err }));
|
|
128
|
+
}
|
|
129
|
+
this.savedMetadata[key] = null;
|
|
130
|
+
logger_1.logger.debug('Deleted Folders And Files successfully');
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}));
|
|
134
|
+
yield Promise.all(deletelogic);
|
|
135
|
+
return true;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
deleteRootMissingFolder(parentID, childID) {
|
|
139
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
const parentFolderMeta = metadataServices_1.getFolderMeta(this.libraryPath, parentID);
|
|
141
|
+
if (!parentFolderMeta) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
if (!fs_extra_1.existsSync(parentFolderMeta.localPath)) {
|
|
145
|
+
yield this.deleteRootMissingFolder(parentFolderMeta.parentID, parentID);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
const resp = yield foldersWcmServices_1.deleteFolder(this.apiOptions, childID);
|
|
149
|
+
if ([204, 404].includes(resp.status)) {
|
|
150
|
+
try {
|
|
151
|
+
const metadataPath = path_1.join(this.libraryPath, '.library', 'folders', `${childID}.json`);
|
|
152
|
+
fs_1.default.rmSync(metadataPath, { recursive: true, force: true });
|
|
153
|
+
logger_1.logger.debug('Folder deleted successfully');
|
|
154
|
+
}
|
|
155
|
+
catch (err) {
|
|
156
|
+
logger_1.logger.error(utils_1.errorMessage('ERROR_DELETE_FOLDER', { 0: err }));
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return false;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
pushAll(directoryPath) {
|
|
166
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
logger_1.logger.debug('LiveSync Push WCM Design Library initPusLibraryHTMLComponent function');
|
|
168
|
+
const files = fs_extra_1.readdirSync(directoryPath);
|
|
169
|
+
yield Promise.all(files.map((file) => __awaiter(this, void 0, void 0, function* () {
|
|
170
|
+
const filePath = path_1.join(directoryPath, file);
|
|
171
|
+
const fileStats = fs_extra_1.statSync(filePath);
|
|
172
|
+
if (!constants_1.LIVESYNC_WCM_LIBRARY_DEFAULT_DIRS.includes(file)) {
|
|
173
|
+
if (directoryPath === this.libraryPath) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (path_1.default.extname(filePath) === '.html') {
|
|
177
|
+
yield this.pushHTMLFile(filePath);
|
|
178
|
+
}
|
|
179
|
+
else if (fileStats.isDirectory()) {
|
|
180
|
+
yield this.pushFolderComponent(filePath);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (fileStats.isDirectory() && file !== '.library') {
|
|
184
|
+
yield this.pushAll(filePath);
|
|
185
|
+
}
|
|
186
|
+
})));
|
|
18
187
|
return true;
|
|
19
188
|
});
|
|
20
189
|
}
|
|
190
|
+
pushHTMLFile(filePath) {
|
|
191
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
192
|
+
const directoryPath = path_1.default.parse(filePath).dir;
|
|
193
|
+
const directoryfileName = path_1.default.parse(directoryPath).name;
|
|
194
|
+
const directoryFileMeta = this.savedMetadata[`${directoryfileName}`];
|
|
195
|
+
logger_1.logger.debug('LiveSync Push WCM Design Library pushFile function');
|
|
196
|
+
const fileName = path_1.default.parse(filePath).name;
|
|
197
|
+
const libraryID = metadataServices_1.getLibraryMetadata(this.libraryPath).id;
|
|
198
|
+
const parentID = directoryFileMeta ? directoryFileMeta.id : libraryID;
|
|
199
|
+
const fileMeta = this.savedMetadata[`${fileName}`];
|
|
200
|
+
const data = JSON.stringify({
|
|
201
|
+
entry: {
|
|
202
|
+
title: {
|
|
203
|
+
lang: 'en',
|
|
204
|
+
value: fileName,
|
|
205
|
+
},
|
|
206
|
+
description: {
|
|
207
|
+
lang: 'en',
|
|
208
|
+
value: 'HTML Component Description',
|
|
209
|
+
},
|
|
210
|
+
name: fileName,
|
|
211
|
+
type: 'LibraryHTMLComponent',
|
|
212
|
+
link: [
|
|
213
|
+
{
|
|
214
|
+
rel: 'library',
|
|
215
|
+
href: `${this.apiOptions.contenthandlerPath}${constants_1.URL_PATH.wcmV2Libraries}/${libraryID}`,
|
|
216
|
+
lang: 'en',
|
|
217
|
+
label: 'Library',
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
rel: 'parent',
|
|
221
|
+
href: `${this.apiOptions.contenthandlerPath}${constants_1.URL_PATH.wcmV2Folders}/${parentID}`,
|
|
222
|
+
lang: 'en',
|
|
223
|
+
label: 'Parent',
|
|
224
|
+
},
|
|
225
|
+
],
|
|
226
|
+
content: {
|
|
227
|
+
type: 'text/html',
|
|
228
|
+
value: fs_extra_1.readFileSync(filePath, 'utf8'),
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
});
|
|
232
|
+
if (!fileMeta) {
|
|
233
|
+
const resp = yield htmlComponentWcmServices_1.createHtmlComponent(this.apiOptions, data);
|
|
234
|
+
this.savedMetadata[fileName] = metadataServices_1.createComponentsMeta(this.libraryPath, resp.data, parentID, libraryID);
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
const resp = yield htmlComponentWcmServices_1.updateHtmlComponent(this.apiOptions, fileMeta.id, data);
|
|
238
|
+
this.savedMetadata[fileName] = metadataServices_1.createComponentsMeta(this.libraryPath, resp.data, fileMeta.parentID, libraryID, true);
|
|
239
|
+
}
|
|
240
|
+
return true;
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
pushFolderComponent(filePath) {
|
|
244
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
245
|
+
logger_1.logger.debug('LiveSync Push WCM Design Library pushFile function');
|
|
246
|
+
const fileName = path_1.default.parse(filePath).name;
|
|
247
|
+
const fileMeta = this.savedMetadata[`${fileName}`];
|
|
248
|
+
const libraryID = metadataServices_1.getLibraryMetadata(this.libraryPath).id;
|
|
249
|
+
const directoryPath = path_1.default.parse(filePath).dir;
|
|
250
|
+
const directoryFileName = path_1.default.parse(directoryPath).name;
|
|
251
|
+
const directoryFileMeta = this.savedMetadata[`${directoryFileName}`];
|
|
252
|
+
const parentID = directoryFileMeta.id;
|
|
253
|
+
const data = {
|
|
254
|
+
type: 'Folder',
|
|
255
|
+
name: fileName,
|
|
256
|
+
description: {
|
|
257
|
+
lang: 'en',
|
|
258
|
+
value: fileName,
|
|
259
|
+
},
|
|
260
|
+
title: {
|
|
261
|
+
lang: 'en',
|
|
262
|
+
value: fileName,
|
|
263
|
+
},
|
|
264
|
+
libraryID,
|
|
265
|
+
parentID,
|
|
266
|
+
};
|
|
267
|
+
if (!fileMeta) {
|
|
268
|
+
const resp = yield foldersWcmServices_1.createFolder(this.apiOptions, libraryID, JSON.stringify(data));
|
|
269
|
+
resp.data.localPath = filePath;
|
|
270
|
+
metadataServices_1.createFolderMeta(this.libraryPath, resp.data);
|
|
271
|
+
this.savedMetadata[fileName] = resp.data;
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
const resp = yield foldersWcmServices_1.updateFolder(this.apiOptions, fileMeta.id, JSON.stringify(data));
|
|
275
|
+
metadataServices_1.createFolderMeta(this.libraryPath, resp.data);
|
|
276
|
+
resp.data.localPath = filePath;
|
|
277
|
+
this.savedMetadata[fileName] = resp.data;
|
|
278
|
+
}
|
|
279
|
+
return true;
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
ongoingSync(cmdArgs, hooks) {
|
|
283
|
+
logger_1.logger.debug('LiveSync Push WCM Design Library ongoingSync function');
|
|
284
|
+
let isSuccess = true;
|
|
285
|
+
const { libraryPath } = cmdArgs;
|
|
286
|
+
const handlerProvider = {
|
|
287
|
+
[constants_1.ChokidarEvent.ADD]: () => __awaiter(this, void 0, void 0, function* () {
|
|
288
|
+
logger_1.logger.debug('File created');
|
|
289
|
+
}),
|
|
290
|
+
[constants_1.ChokidarEvent.ADD_HTML]: ongoingSyncServices_1.addWCMHtmlComponentHandler,
|
|
291
|
+
[constants_1.ChokidarEvent.ADD_DIR]: ongoingSyncServices_1.addWCMFolderHandler,
|
|
292
|
+
[constants_1.ChokidarEvent.CHANGE]: () => __awaiter(this, void 0, void 0, function* () {
|
|
293
|
+
logger_1.logger.debug('Updated file event');
|
|
294
|
+
}),
|
|
295
|
+
[constants_1.ChokidarEvent.CHANGE_HTML]: ongoingSyncServices_1.updateWCMHtmlComponentHandler,
|
|
296
|
+
[constants_1.ChokidarEvent.CHANGE_DIR]: ongoingSyncServices_1.updateWCMFolderHandler,
|
|
297
|
+
[constants_1.ChokidarEvent.UNLINK]: ongoingSyncServices_1.deleteWCMHtmlComponentHandler,
|
|
298
|
+
[constants_1.ChokidarEvent.UNLINK_DIR]: ongoingSyncServices_1.deleteWCMFolderHandle,
|
|
299
|
+
};
|
|
300
|
+
this.eventsQueue = new EventsQueue_1.EventsQueue(handlerProvider);
|
|
301
|
+
this.eventsQueue.initialize();
|
|
302
|
+
logger_1.logger.debug('Initializing chokidar watcher...');
|
|
303
|
+
logger_1.logger.info(utils_1.message('LIVE_SYNC_START', { 0: libraryPath }));
|
|
304
|
+
const STABILITY_THRESHOLD = 100;
|
|
305
|
+
const POLL_INTERVAL = 2000;
|
|
306
|
+
const watchOptions = {
|
|
307
|
+
awaitWriteFinish: {
|
|
308
|
+
stabilityThreshold: STABILITY_THRESHOLD,
|
|
309
|
+
pollInterval: POLL_INTERVAL,
|
|
310
|
+
},
|
|
311
|
+
persistent: true,
|
|
312
|
+
ignoreInitial: true,
|
|
313
|
+
ignored: filesServices_1.fileServices.getIgnoredPaths(libraryPath),
|
|
314
|
+
};
|
|
315
|
+
this.watcher = chokidar_1.default
|
|
316
|
+
.watch(libraryPath, watchOptions)
|
|
317
|
+
.on(constants_1.ChokidarEvent.ADD, (chokidarPath) => __awaiter(this, void 0, void 0, function* () {
|
|
318
|
+
logger_1.logger.debug(`Detected file created: ${chokidarPath}`);
|
|
319
|
+
const chokidarEventType = livesyncUtils_1.getEventByFileType(chokidarPath, constants_1.ChokidarEvent.ADD);
|
|
320
|
+
switch (chokidarEventType) {
|
|
321
|
+
case constants_1.ChokidarEvent.ADD_HTML:
|
|
322
|
+
this.eventsQueue.push({
|
|
323
|
+
cmdArgs,
|
|
324
|
+
chokidarEvent: chokidarEventType,
|
|
325
|
+
chokidarPath,
|
|
326
|
+
options: {
|
|
327
|
+
library: this.libraryMetaData,
|
|
328
|
+
},
|
|
329
|
+
});
|
|
330
|
+
break;
|
|
331
|
+
case constants_1.ChokidarEvent.ADD:
|
|
332
|
+
this.eventsQueue.push({ cmdArgs, chokidarEvent: chokidarEventType, chokidarPath });
|
|
333
|
+
break;
|
|
334
|
+
default:
|
|
335
|
+
logger_1.logger.debug(`Detected file created: ${chokidarPath}`);
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
}))
|
|
339
|
+
.on(constants_1.ChokidarEvent.ADD_DIR, (chokidarPath) => __awaiter(this, void 0, void 0, function* () {
|
|
340
|
+
logger_1.logger.debug(`Detected folder created: ${chokidarPath}`);
|
|
341
|
+
this.eventsQueue.push({
|
|
342
|
+
cmdArgs,
|
|
343
|
+
chokidarEvent: constants_1.ChokidarEvent.ADD_DIR,
|
|
344
|
+
chokidarPath,
|
|
345
|
+
options: {
|
|
346
|
+
library: this.libraryMetaData,
|
|
347
|
+
},
|
|
348
|
+
});
|
|
349
|
+
}))
|
|
350
|
+
.on(constants_1.ChokidarEvent.CHANGE, (chokidarPath) => __awaiter(this, void 0, void 0, function* () {
|
|
351
|
+
logger_1.logger.debug(`Detected file updated: ${chokidarPath}`);
|
|
352
|
+
const chokidarEventType = livesyncUtils_1.getEventByFileType(chokidarPath, constants_1.ChokidarEvent.CHANGE);
|
|
353
|
+
switch (chokidarEventType) {
|
|
354
|
+
case constants_1.ChokidarEvent.CHANGE_HTML:
|
|
355
|
+
this.eventsQueue.push({
|
|
356
|
+
cmdArgs,
|
|
357
|
+
chokidarEvent: chokidarEventType,
|
|
358
|
+
chokidarPath,
|
|
359
|
+
options: {
|
|
360
|
+
library: this.libraryMetaData,
|
|
361
|
+
},
|
|
362
|
+
});
|
|
363
|
+
break;
|
|
364
|
+
case constants_1.ChokidarEvent.CHANGE:
|
|
365
|
+
this.eventsQueue.push({ cmdArgs, chokidarEvent: chokidarEventType, chokidarPath });
|
|
366
|
+
break;
|
|
367
|
+
default:
|
|
368
|
+
logger_1.logger.debug(`Detected file updated: ${chokidarPath}`);
|
|
369
|
+
this.eventsQueue.push({
|
|
370
|
+
cmdArgs,
|
|
371
|
+
chokidarEvent: livesyncUtils_1.getEventByFileType(chokidarPath, constants_1.ChokidarEvent.CHANGE),
|
|
372
|
+
chokidarPath,
|
|
373
|
+
});
|
|
374
|
+
break;
|
|
375
|
+
}
|
|
376
|
+
}))
|
|
377
|
+
.on(constants_1.ChokidarEvent.CHANGE_DIR, (chokidarPath) => __awaiter(this, void 0, void 0, function* () {
|
|
378
|
+
logger_1.logger.debug(`Detected folder updated: ${chokidarPath}`);
|
|
379
|
+
this.eventsQueue.push({
|
|
380
|
+
cmdArgs,
|
|
381
|
+
chokidarEvent: constants_1.ChokidarEvent.CHANGE_DIR,
|
|
382
|
+
chokidarPath,
|
|
383
|
+
options: {
|
|
384
|
+
library: this.libraryMetaData,
|
|
385
|
+
},
|
|
386
|
+
});
|
|
387
|
+
}))
|
|
388
|
+
.on(constants_1.ChokidarEvent.UNLINK, (chokidarPath) => __awaiter(this, void 0, void 0, function* () {
|
|
389
|
+
logger_1.logger.debug(`Detected file deleted: ${chokidarPath}`);
|
|
390
|
+
const chokidarEventType = livesyncUtils_1.getEventByFileType(chokidarPath, constants_1.ChokidarEvent.UNLINK);
|
|
391
|
+
switch (chokidarEventType) {
|
|
392
|
+
case constants_1.ChokidarEvent.UNLINK:
|
|
393
|
+
this.eventsQueue.push({
|
|
394
|
+
cmdArgs,
|
|
395
|
+
chokidarEvent: chokidarEventType,
|
|
396
|
+
chokidarPath,
|
|
397
|
+
options: {
|
|
398
|
+
library: this.libraryMetaData,
|
|
399
|
+
},
|
|
400
|
+
});
|
|
401
|
+
break;
|
|
402
|
+
default:
|
|
403
|
+
logger_1.logger.debug(`Detected file delete: ${chokidarPath}`);
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
}))
|
|
407
|
+
.on(constants_1.ChokidarEvent.UNLINK_DIR, (chokidarPath) => __awaiter(this, void 0, void 0, function* () {
|
|
408
|
+
logger_1.logger.debug(`Detected folder deleted: ${chokidarPath}`);
|
|
409
|
+
this.eventsQueue.push({
|
|
410
|
+
cmdArgs,
|
|
411
|
+
chokidarEvent: constants_1.ChokidarEvent.UNLINK_DIR,
|
|
412
|
+
chokidarPath,
|
|
413
|
+
options: {
|
|
414
|
+
library: this.libraryMetaData,
|
|
415
|
+
},
|
|
416
|
+
});
|
|
417
|
+
}))
|
|
418
|
+
.on(constants_1.ChokidarEvent.ERROR, (error) => __awaiter(this, void 0, void 0, function* () {
|
|
419
|
+
logger_1.logger.debug('Something went wrong while running chokidar watch: %o', error);
|
|
420
|
+
isSuccess = false;
|
|
421
|
+
yield this.closeWatcher(isSuccess);
|
|
422
|
+
}))
|
|
423
|
+
.on(constants_1.ChokidarEvent.READY, () => {
|
|
424
|
+
if (hooks && hooks.onWatcherReady && lodash_1.isFunction(hooks.onWatcherReady)) {
|
|
425
|
+
hooks.onWatcherReady();
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
const sigIntcallBack = () => __awaiter(this, void 0, void 0, function* () {
|
|
429
|
+
const iSuccess = true;
|
|
430
|
+
process.removeListener('SIGINT', sigIntcallBack);
|
|
431
|
+
yield this.closeWatcher(iSuccess);
|
|
432
|
+
});
|
|
433
|
+
process.on('SIGINT', sigIntcallBack);
|
|
434
|
+
}
|
|
435
|
+
closeWatcher(emitIsSuccess, hooks) {
|
|
436
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
437
|
+
if (this.watcher) {
|
|
438
|
+
yield this.watcher.close();
|
|
439
|
+
this.watcher = null;
|
|
440
|
+
}
|
|
441
|
+
if (this.eventsQueue) {
|
|
442
|
+
yield this.eventsQueue.kill();
|
|
443
|
+
}
|
|
444
|
+
logger_1.logger.info(utils_1.message('LIVESYNC_RUN_CLEANUP_QUEUE'));
|
|
445
|
+
const maxRetryCount = 60;
|
|
446
|
+
const timeInterval = 1000;
|
|
447
|
+
const waitForQueueToFinish = (retryCount = 0) => __awaiter(this, void 0, void 0, function* () {
|
|
448
|
+
if (!this.eventsQueue.queue.running()) {
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
if (retryCount < maxRetryCount) {
|
|
452
|
+
logger_1.logger.debug('Waiting for queue process to finish...');
|
|
453
|
+
yield new Promise((resolve) => {
|
|
454
|
+
return setTimeout(resolve, timeInterval);
|
|
455
|
+
});
|
|
456
|
+
yield waitForQueueToFinish(retryCount + 1);
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
logger_1.logger.info(utils_1.message('LIVESYNC_END_CLEANUP_QUEUE'));
|
|
460
|
+
emitIsSuccess = false;
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
yield waitForQueueToFinish();
|
|
464
|
+
if ((hooks === null || hooks === void 0 ? void 0 : hooks.onWatcherClose) && typeof hooks.onWatcherClose === 'function') {
|
|
465
|
+
hooks.onWatcherClose(emitIsSuccess);
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
}
|
|
21
469
|
}
|
|
22
470
|
exports.PushWcmDesignLibrary = PushWcmDesignLibrary;
|
|
23
471
|
//# sourceMappingURL=pushWcmDesignLibrary.js.map
|