@sitecore-jss/sitecore-jss-dev-tools 16.0.0-canary.8 → 16.0.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/LICENSE.txt +202 -202
- package/README.md +6 -6
- package/dist/clean.js +3 -0
- package/dist/deploy.js +3 -0
- package/dist/digest.js +7 -0
- package/dist/disconnected-server/DisconnectedLayoutServiceOptions.js +1 -0
- package/dist/disconnected-server/create-default-disconnected-server.js +6 -1
- package/dist/disconnected-server/default-document.js +3 -3
- package/dist/disconnected-server/dictionary-service.js +1 -0
- package/dist/disconnected-server/layout-service.js +45 -8
- package/dist/disconnected-server/media-service.js +3 -0
- package/dist/mergeFs.js +5 -2
- package/dist/package-deploy.js +218 -112
- package/dist/package-generate.js +3 -0
- package/dist/resolve-scjssconfig.js +3 -0
- package/dist/setup/find-app-name.js +6 -0
- package/dist/setup/jss-config.js +1 -3
- package/dist/setup/secret-patch.js +9 -0
- package/dist/setup/setup.js +46 -14
- package/dist/setup/verify-setup.js +2 -5
- package/package.json +10 -8
- package/types/clean.d.ts +3 -0
- package/types/deploy.d.ts +3 -0
- package/types/digest.d.ts +7 -0
- package/types/disconnected-server/create-default-disconnected-server.d.ts +3 -0
- package/types/disconnected-server/default-document.d.ts +5 -1
- package/types/disconnected-server/layout-service.d.ts +8 -1
- package/types/disconnected-server/media-service.d.ts +5 -1
- package/types/index.d.ts +4 -4
- package/types/mergeFs.d.ts +1 -1
- package/types/package-deploy.d.ts +71 -0
- package/types/package-generate.d.ts +3 -0
- package/types/resolve-scjssconfig.d.ts +5 -2
- package/types/setup/find-app-name.d.ts +6 -0
- package/types/setup/secret-patch.d.ts +9 -0
- package/types/setup/setup.d.ts +6 -0
|
@@ -6,6 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.createDisconnectedAssetMiddleware = void 0;
|
|
7
7
|
var fs_1 = __importDefault(require("fs"));
|
|
8
8
|
var path_1 = __importDefault(require("path"));
|
|
9
|
+
/**
|
|
10
|
+
* @param {DisconnectedAssetMiddlewareOptions} config
|
|
11
|
+
*/
|
|
9
12
|
function createDisconnectedAssetMiddleware(_a) {
|
|
10
13
|
var manifestPath = _a.manifestPath, staticRootPath = _a.staticRootPath;
|
|
11
14
|
return function disconnectedAssetMiddleware(request, response) {
|
package/dist/mergeFs.js
CHANGED
|
@@ -25,6 +25,7 @@ var processFileSync = function (filePath, parseFileContents) {
|
|
|
25
25
|
// if no encoding is specified, readFileSync returns a buffer instead of a string
|
|
26
26
|
var contents = fs_1.default.readFileSync(filePath, 'utf8');
|
|
27
27
|
if (contents) {
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
29
|
var contentObject = void 0;
|
|
29
30
|
if (parseFileContents) {
|
|
30
31
|
contentObject = parseFileContents(filePath, contents);
|
|
@@ -47,16 +48,18 @@ var readDirSync = function (dir) {
|
|
|
47
48
|
filesList: [],
|
|
48
49
|
dirList: [],
|
|
49
50
|
};
|
|
50
|
-
if (IS_HIDDEN_FILE(dir))
|
|
51
|
+
if (IS_HIDDEN_FILE(dir)) {
|
|
51
52
|
return result;
|
|
53
|
+
}
|
|
52
54
|
var list = fs_1.default.readdirSync(dir);
|
|
53
55
|
if (!list) {
|
|
54
56
|
return result;
|
|
55
57
|
}
|
|
56
58
|
list.forEach(function (file) {
|
|
57
59
|
var filePath = path_1.default.join(dir, file);
|
|
58
|
-
if (IS_HIDDEN_FILE(file))
|
|
60
|
+
if (IS_HIDDEN_FILE(file)) {
|
|
59
61
|
return;
|
|
62
|
+
}
|
|
60
63
|
var stats = fs_1.default.statSync(filePath);
|
|
61
64
|
if (stats && stats.isDirectory()) {
|
|
62
65
|
result.dirList.push(filePath);
|
package/dist/package-deploy.js
CHANGED
|
@@ -1,4 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
2
32
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
33
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
34
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -39,35 +69,44 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
69
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
70
|
};
|
|
41
71
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.packageDeploy = void 0;
|
|
72
|
+
exports.getHttpsTransport = exports.extractProxy = exports.packageDeploy = exports.logJobStatus = exports.finishWatchJobStatusTask = exports.doFingerprintsMatch = exports.normalizeFingerprint = exports.applyCertPinning = void 0;
|
|
43
73
|
var chalk_1 = __importDefault(require("chalk"));
|
|
44
74
|
var fs_1 = __importDefault(require("fs"));
|
|
45
|
-
var https_1 = require("https");
|
|
75
|
+
var https_1 = __importStar(require("https"));
|
|
46
76
|
var path_1 = __importDefault(require("path"));
|
|
47
|
-
var
|
|
77
|
+
var form_data_1 = __importDefault(require("form-data"));
|
|
78
|
+
var axios_1 = __importDefault(require("axios"));
|
|
48
79
|
var digest_1 = require("./digest");
|
|
49
80
|
// Node does not use system level trusted CAs. This causes issues because SIF likes to install
|
|
50
81
|
// using a Windows trusted CA - so SSL connections to Sitecore will fail from Node.
|
|
51
82
|
// If the options.acceptCertificate is passed, we disable normal SSL validation and use this function
|
|
52
83
|
// to whitelist only a cert with the specific thumbprint - essentially certificate pinning.
|
|
84
|
+
/**
|
|
85
|
+
* @param {ClientRequest} req
|
|
86
|
+
* @param {PackageDeployOptions} options
|
|
87
|
+
*/
|
|
53
88
|
function applyCertPinning(req, options) {
|
|
54
89
|
req.on('socket', function (socket) {
|
|
55
90
|
socket.on('secureConnect', function () {
|
|
56
91
|
var fingerprint = socket.getPeerCertificate().fingerprint;
|
|
57
92
|
// Match the fingerprint with our saved fingerprint
|
|
58
|
-
if (options.acceptCertificate &&
|
|
93
|
+
if (options.acceptCertificate &&
|
|
94
|
+
!doFingerprintsMatch(options.acceptCertificate, fingerprint)) {
|
|
59
95
|
// Abort request, optionally emit an error event
|
|
60
|
-
// tslint:disable-next-line:max-line-length
|
|
61
96
|
req.emit('error', new Error("Expected server SSL certificate to have thumbprint " + options.acceptCertificate + " from acceptCertificate, but got " + fingerprint + " from server. This may mean the certificate has changed, or that a malicious certificate is present."));
|
|
62
97
|
return req.abort();
|
|
63
98
|
}
|
|
64
99
|
});
|
|
65
100
|
});
|
|
66
101
|
}
|
|
102
|
+
exports.applyCertPinning = applyCertPinning;
|
|
103
|
+
/**
|
|
104
|
+
* @param {string} fp
|
|
105
|
+
*/
|
|
67
106
|
function normalizeFingerprint(fp) {
|
|
68
107
|
//
|
|
69
108
|
// The fingerprint for a certificate is a 20-byte value.
|
|
70
|
-
// Such values are typically expressed as strings, but
|
|
109
|
+
// Such values are typically expressed as strings, but
|
|
71
110
|
// there are many different formats that may be used.
|
|
72
111
|
//
|
|
73
112
|
// For example, the following values all represent
|
|
@@ -82,60 +121,117 @@ function normalizeFingerprint(fp) {
|
|
|
82
121
|
// function implements the logic for that conversion.
|
|
83
122
|
return fp.toLowerCase().replace(new RegExp(':', 'g'), '');
|
|
84
123
|
}
|
|
124
|
+
exports.normalizeFingerprint = normalizeFingerprint;
|
|
125
|
+
/**
|
|
126
|
+
* @param {string} fp1
|
|
127
|
+
* @param {string} fp2
|
|
128
|
+
*/
|
|
85
129
|
function doFingerprintsMatch(fp1, fp2) {
|
|
86
130
|
return normalizeFingerprint(fp1) === normalizeFingerprint(fp2);
|
|
87
131
|
}
|
|
132
|
+
exports.doFingerprintsMatch = doFingerprintsMatch;
|
|
133
|
+
/**
|
|
134
|
+
* @param {Object} params
|
|
135
|
+
* @param {string[]} params.warnings
|
|
136
|
+
* @param {string[]} params.errors
|
|
137
|
+
* @param {Function} params.resolve
|
|
138
|
+
* @param {Function} params.reject
|
|
139
|
+
*/
|
|
140
|
+
function finishWatchJobStatusTask(_a) {
|
|
141
|
+
var warnings = _a.warnings, errors = _a.errors, resolve = _a.resolve, reject = _a.reject;
|
|
142
|
+
console.log();
|
|
143
|
+
console.log('Import is complete.');
|
|
144
|
+
if (warnings.length) {
|
|
145
|
+
console.log();
|
|
146
|
+
console.warn(chalk_1.default.yellow('IMPORT WARNING(S) OCCURRED!'));
|
|
147
|
+
warnings.forEach(function (w) { return console.error(chalk_1.default.yellow(w)); });
|
|
148
|
+
}
|
|
149
|
+
if (errors.length) {
|
|
150
|
+
console.log();
|
|
151
|
+
console.error(chalk_1.default.red('IMPORT ERROR(S) OCCURRED!'));
|
|
152
|
+
errors.forEach(function (e) { return console.error(chalk_1.default.red(e)); });
|
|
153
|
+
reject();
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
resolve();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
exports.finishWatchJobStatusTask = finishWatchJobStatusTask;
|
|
160
|
+
/**
|
|
161
|
+
* @param {Object} params
|
|
162
|
+
* @param {string} params.message
|
|
163
|
+
* @param {string} params.entryLevel
|
|
164
|
+
* @param {string[]} params.warnings
|
|
165
|
+
* @param {string[]} params.errors
|
|
166
|
+
*/
|
|
167
|
+
function logJobStatus(_a) {
|
|
168
|
+
var message = _a.message, entryLevel = _a.entryLevel, warnings = _a.warnings, errors = _a.errors;
|
|
169
|
+
switch (entryLevel) {
|
|
170
|
+
case 'WARN':
|
|
171
|
+
console.warn(chalk_1.default.yellow(message));
|
|
172
|
+
warnings.push(message);
|
|
173
|
+
break;
|
|
174
|
+
case 'ERROR':
|
|
175
|
+
console.error(chalk_1.default.red(message));
|
|
176
|
+
errors.push(message);
|
|
177
|
+
break;
|
|
178
|
+
case 'DEBUG':
|
|
179
|
+
console.log(chalk_1.default.white(message));
|
|
180
|
+
break;
|
|
181
|
+
default:
|
|
182
|
+
console.log(chalk_1.default.green(message));
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
exports.logJobStatus = logJobStatus;
|
|
187
|
+
/**
|
|
188
|
+
* @param {PackageDeployOptions} options
|
|
189
|
+
* @param {string} taskName
|
|
190
|
+
*/
|
|
88
191
|
function watchJobStatus(options, taskName) {
|
|
89
192
|
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
-
var logOffset, errors, warnings, factors, mac, requestBaseOptions;
|
|
193
|
+
var logOffset, errors, warnings, factors, mac, isHttps, requestBaseOptions;
|
|
91
194
|
return __generator(this, function (_a) {
|
|
92
195
|
logOffset = 0;
|
|
93
196
|
errors = [];
|
|
94
197
|
warnings = [];
|
|
95
198
|
factors = [options.appName, taskName, options.importServiceUrl + "/status"];
|
|
96
199
|
mac = digest_1.hmac(factors, options.secret);
|
|
200
|
+
isHttps = options.importServiceUrl.startsWith('https');
|
|
97
201
|
requestBaseOptions = {
|
|
202
|
+
transport: isHttps ? getHttpsTransport(options) : undefined,
|
|
98
203
|
headers: {
|
|
99
204
|
'User-Agent': 'Sitecore/JSS-Import',
|
|
100
205
|
'Cache-Control': 'no-cache',
|
|
101
206
|
'X-JSS-Auth': mac,
|
|
102
207
|
},
|
|
103
|
-
proxy: options.proxy,
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
208
|
+
proxy: extractProxy(options.proxy),
|
|
209
|
+
maxRedirects: 0,
|
|
210
|
+
httpsAgent: isHttps
|
|
211
|
+
? new https_1.Agent({
|
|
212
|
+
// we turn off normal CA cert validation when we are whitelisting a single cert thumbprint
|
|
213
|
+
rejectUnauthorized: options.acceptCertificate ? false : true,
|
|
214
|
+
// needed to allow whitelisting a cert thumbprint if a connection is reused
|
|
215
|
+
maxCachedSessions: options.acceptCertificate ? 0 : undefined,
|
|
216
|
+
})
|
|
217
|
+
: undefined,
|
|
107
218
|
};
|
|
108
|
-
// needed to allow whitelisting a cert thumbprint if a connection is reused
|
|
109
|
-
if (options.importServiceUrl.startsWith('https') && options.acceptCertificate) {
|
|
110
|
-
requestBaseOptions.agent = new https_1.Agent({ maxCachedSessions: 0 });
|
|
111
|
-
}
|
|
112
219
|
if (options.debugSecurity) {
|
|
113
220
|
console.log("Deployment status security factors: " + factors);
|
|
114
221
|
console.log("Deployment status HMAC: " + mac);
|
|
115
222
|
}
|
|
116
223
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
224
|
+
/**
|
|
225
|
+
* Send job status request
|
|
226
|
+
*/
|
|
117
227
|
function sendJobStatusRequest() {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
console.error(chalk_1.default.red('Unexpected response from import status service. The import task is probably still running; check the Sitecore logs for details.'));
|
|
123
|
-
if (error) {
|
|
124
|
-
console.error(chalk_1.default.red(error));
|
|
125
|
-
}
|
|
126
|
-
if (response && response.statusMessage) {
|
|
127
|
-
console.error(chalk_1.default.red(response.statusMessage));
|
|
128
|
-
}
|
|
129
|
-
if (body) {
|
|
130
|
-
console.error(chalk_1.default.red(body));
|
|
131
|
-
}
|
|
132
|
-
reject();
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
228
|
+
axios_1.default
|
|
229
|
+
.get(options.importServiceUrl + "/status?appName=" + options.appName + "&jobName=" + taskName + "&after=" + logOffset, requestBaseOptions)
|
|
230
|
+
.then(function (response) {
|
|
231
|
+
var body = response.data;
|
|
135
232
|
try {
|
|
136
|
-
var
|
|
137
|
-
|
|
138
|
-
logReplies.forEach(function (entry) {
|
|
233
|
+
var state = body.state, messages = body.messages;
|
|
234
|
+
messages.forEach(function (entry) {
|
|
139
235
|
logOffset++;
|
|
140
236
|
var entryBits = /^(\[([A-Z]+)\] )?(.+)/.exec(entry);
|
|
141
237
|
var entryLevel = 'INFO';
|
|
@@ -146,49 +242,16 @@ function watchJobStatus(options, taskName) {
|
|
|
146
242
|
// we're not using the capture group as the message might be multi-line
|
|
147
243
|
message = entry.substring(entryLevel.length + 3);
|
|
148
244
|
}
|
|
149
|
-
if (entry.startsWith('Job ended:')) {
|
|
150
|
-
console.log();
|
|
151
|
-
console.log('Import is complete.');
|
|
152
|
-
if (warnings.length > 0) {
|
|
153
|
-
console.log();
|
|
154
|
-
console.warn(chalk_1.default.yellow('IMPORT WARNING(S) OCCURRED!'));
|
|
155
|
-
warnings.forEach(function (w) { return console.error(chalk_1.default.yellow(w)); });
|
|
156
|
-
}
|
|
157
|
-
if (errors.length > 0) {
|
|
158
|
-
console.log();
|
|
159
|
-
console.error(chalk_1.default.red('IMPORT ERROR(S) OCCURRED!'));
|
|
160
|
-
errors.forEach(function (e) { return console.error(chalk_1.default.red(e)); });
|
|
161
|
-
reject();
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
resolve();
|
|
165
|
-
}
|
|
166
|
-
complete_1 = true;
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
245
|
if (message.startsWith('[JSS] - ')) {
|
|
170
246
|
message = message.substring(8);
|
|
171
247
|
}
|
|
172
|
-
|
|
173
|
-
case 'WARN':
|
|
174
|
-
console.warn(chalk_1.default.yellow(message));
|
|
175
|
-
warnings.push(message);
|
|
176
|
-
break;
|
|
177
|
-
case 'ERROR':
|
|
178
|
-
console.error(chalk_1.default.red(message));
|
|
179
|
-
errors.push(message);
|
|
180
|
-
break;
|
|
181
|
-
case 'DEBUG':
|
|
182
|
-
console.log(chalk_1.default.white(message));
|
|
183
|
-
break;
|
|
184
|
-
default:
|
|
185
|
-
console.log(chalk_1.default.green(message));
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
248
|
+
logJobStatus({ message: message, entryLevel: entryLevel, warnings: warnings, errors: errors });
|
|
188
249
|
});
|
|
189
|
-
if (
|
|
190
|
-
|
|
250
|
+
if (state === 'Finished') {
|
|
251
|
+
finishWatchJobStatusTask({ warnings: warnings, errors: errors, resolve: resolve, reject: reject });
|
|
252
|
+
return;
|
|
191
253
|
}
|
|
254
|
+
setTimeout(sendJobStatusRequest, 1000);
|
|
192
255
|
}
|
|
193
256
|
catch (error) {
|
|
194
257
|
console.error(chalk_1.default.red("Unexpected error processing reply from import status service: " + error));
|
|
@@ -196,26 +259,37 @@ function watchJobStatus(options, taskName) {
|
|
|
196
259
|
console.error(chalk_1.default.red('Consult the Sitecore logs for details.'));
|
|
197
260
|
reject(error);
|
|
198
261
|
}
|
|
262
|
+
})
|
|
263
|
+
.catch(function (error) {
|
|
264
|
+
console.error(chalk_1.default.red('Unexpected response from import status service. The import task is probably still running; check the Sitecore logs for details.'));
|
|
265
|
+
if (error.response) {
|
|
266
|
+
console.error(chalk_1.default.red("Status message: " + error.response.statusText));
|
|
267
|
+
console.error(chalk_1.default.red("Status: " + error.response.status));
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
console.error(chalk_1.default.red(error.message));
|
|
271
|
+
}
|
|
272
|
+
reject();
|
|
199
273
|
});
|
|
200
|
-
applyCertPinning(req, options);
|
|
201
274
|
}
|
|
202
275
|
setTimeout(sendJobStatusRequest, 1000);
|
|
203
276
|
})];
|
|
204
277
|
});
|
|
205
278
|
});
|
|
206
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* @param {PackageDeployOptions} options
|
|
282
|
+
*/
|
|
207
283
|
function packageDeploy(options) {
|
|
208
284
|
return __awaiter(this, void 0, void 0, function () {
|
|
209
|
-
var packageFile, factors, _a, requestBaseOptions;
|
|
285
|
+
var packageFile, factors, _a, formData, isHttps, requestBaseOptions;
|
|
210
286
|
return __generator(this, function (_b) {
|
|
211
287
|
switch (_b.label) {
|
|
212
288
|
case 0:
|
|
213
289
|
if (!options.secret) {
|
|
214
|
-
// tslint:disable-next-line:max-line-length
|
|
215
290
|
throw new Error('Deployment secret was not passed. A shared secret must be configured on both the Sitecore app config and the JS app config');
|
|
216
291
|
}
|
|
217
292
|
if (options.secret.length < 32) {
|
|
218
|
-
// tslint:disable-next-line:max-line-length
|
|
219
293
|
throw new Error('Deployment secret was too short. Use a RANDOM (not words or phrases) secret at least 32 characters long.');
|
|
220
294
|
}
|
|
221
295
|
packageFile = null;
|
|
@@ -237,50 +311,82 @@ function packageDeploy(options) {
|
|
|
237
311
|
console.log("Deployment security factors: " + factors);
|
|
238
312
|
console.log("Deployment HMAC: " + digest_1.hmac(factors, options.secret));
|
|
239
313
|
}
|
|
314
|
+
formData = new form_data_1.default();
|
|
315
|
+
formData.append('path', fs_1.default.createReadStream(packageFile));
|
|
316
|
+
formData.append('appName', options.appName);
|
|
317
|
+
isHttps = options.importServiceUrl.startsWith('https');
|
|
240
318
|
requestBaseOptions = {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
},
|
|
319
|
+
transport: isHttps ? getHttpsTransport(options) : undefined,
|
|
320
|
+
headers: __assign({ 'User-Agent': 'Sitecore/JSS-Import', 'Cache-Control': 'no-cache', 'X-JSS-Auth': digest_1.hmac(factors, options.secret) }, formData.getHeaders()),
|
|
321
|
+
proxy: extractProxy(options.proxy),
|
|
322
|
+
httpsAgent: isHttps
|
|
323
|
+
? new https_1.Agent({
|
|
324
|
+
// we turn off normal CA cert validation when we are whitelisting a single cert thumbprint
|
|
325
|
+
rejectUnauthorized: options.acceptCertificate ? false : true,
|
|
326
|
+
// needed to allow whitelisting a cert thumbprint if a connection is reused
|
|
327
|
+
maxCachedSessions: options.acceptCertificate ? 0 : undefined,
|
|
328
|
+
})
|
|
329
|
+
: undefined,
|
|
330
|
+
maxRedirects: 0,
|
|
254
331
|
};
|
|
255
|
-
// needed to allow whitelisting a cert thumbprint if a connection is reused
|
|
256
|
-
if (options.importServiceUrl.startsWith('https') && options.acceptCertificate) {
|
|
257
|
-
requestBaseOptions.agent = new https_1.Agent({ maxCachedSessions: 0 });
|
|
258
|
-
}
|
|
259
332
|
console.log("Sending package " + packageFile + " to " + options.importServiceUrl + "...");
|
|
260
333
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
console.error(chalk_1.default.red(error));
|
|
266
|
-
}
|
|
267
|
-
if (response && response.statusMessage) {
|
|
268
|
-
console.error(chalk_1.default.red("Status message: " + response.statusMessage));
|
|
269
|
-
}
|
|
270
|
-
if (body) {
|
|
271
|
-
console.error(chalk_1.default.red("Body: " + body));
|
|
272
|
-
}
|
|
273
|
-
reject();
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
334
|
+
axios_1.default
|
|
335
|
+
.post(options.importServiceUrl, formData, requestBaseOptions)
|
|
336
|
+
.then(function (response) {
|
|
337
|
+
var body = response.data;
|
|
276
338
|
console.log(chalk_1.default.green("Sitecore has accepted import task " + body));
|
|
277
339
|
resolve(body);
|
|
340
|
+
})
|
|
341
|
+
.catch(function (error) {
|
|
342
|
+
console.error(chalk_1.default.red('Unexpected response from import service:'));
|
|
343
|
+
if (error.response) {
|
|
344
|
+
console.error(chalk_1.default.red("Status message: " + error.response.statusText));
|
|
345
|
+
console.error(chalk_1.default.red("Status: " + error.response.status));
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
console.error(chalk_1.default.red(error.message));
|
|
349
|
+
}
|
|
350
|
+
reject();
|
|
278
351
|
});
|
|
279
|
-
|
|
280
|
-
})
|
|
281
|
-
.then(function (taskName) { return watchJobStatus(options, taskName); })];
|
|
352
|
+
}).then(function (taskName) { return watchJobStatus(options, taskName); })];
|
|
282
353
|
}
|
|
283
354
|
});
|
|
284
355
|
});
|
|
285
356
|
}
|
|
286
357
|
exports.packageDeploy = packageDeploy;
|
|
358
|
+
/**
|
|
359
|
+
* Creates valid proxy object which fit to axios configuration
|
|
360
|
+
* @param {string} [proxy] proxy url
|
|
361
|
+
*/
|
|
362
|
+
function extractProxy(proxy) {
|
|
363
|
+
if (!proxy)
|
|
364
|
+
return undefined;
|
|
365
|
+
try {
|
|
366
|
+
var proxyUrl = new URL(proxy);
|
|
367
|
+
return {
|
|
368
|
+
protocol: proxyUrl.protocol.slice(0, -1),
|
|
369
|
+
host: proxyUrl.hostname,
|
|
370
|
+
port: +proxyUrl.port,
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
catch (error) {
|
|
374
|
+
console.error(chalk_1.default.red("Invalid proxy url provided " + proxy));
|
|
375
|
+
process.exit(1);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
exports.extractProxy = extractProxy;
|
|
379
|
+
/**
|
|
380
|
+
* Provides way to customize axios request adapter
|
|
381
|
+
* in order to execute certificate pinning before request sent:
|
|
382
|
+
* {@link https://github.com/axios/axios/issues/2808}
|
|
383
|
+
* @param {PackageDeployOptions} options
|
|
384
|
+
*/
|
|
385
|
+
function getHttpsTransport(options) {
|
|
386
|
+
return __assign(__assign({}, https_1.default), { request: function (reqOptions, callback) {
|
|
387
|
+
var req = https_1.default.request(__assign({}, reqOptions), callback);
|
|
388
|
+
applyCertPinning(req, options);
|
|
389
|
+
return req;
|
|
390
|
+
} });
|
|
391
|
+
}
|
|
392
|
+
exports.getHttpsTransport = getHttpsTransport;
|
package/dist/package-generate.js
CHANGED
|
@@ -7,6 +7,9 @@ exports.packageGenerate = void 0;
|
|
|
7
7
|
var sitecore_jss_update_package_1 = require("@sitecore-jss/sitecore-jss-update-package");
|
|
8
8
|
var fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
9
|
var path_1 = __importDefault(require("path"));
|
|
10
|
+
/**
|
|
11
|
+
* @param {PackageGenerateOptions} options
|
|
12
|
+
*/
|
|
10
13
|
function packageGenerate(options) {
|
|
11
14
|
// clear output folder
|
|
12
15
|
fs_extra_1.default.emptyDirSync(options.outputPath);
|
|
@@ -5,6 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.resolveScJssConfig = void 0;
|
|
7
7
|
var resolve_1 = __importDefault(require("resolve"));
|
|
8
|
+
/**
|
|
9
|
+
* @param {any} config
|
|
10
|
+
*/
|
|
8
11
|
function resolveScJssConfig(_a) {
|
|
9
12
|
var _b = _a === void 0 ? {} : _a, _c = _b.configPath, configPath = _c === void 0 ? './scjssconfig.json' : _c, _d = _b.configName, configName = _d === void 0 ? 'sitecore' : _d, _e = _b.assert, assert = _e === void 0 ? true : _e;
|
|
10
13
|
return new Promise(function (resolvePromise, rejectPromise) {
|
|
@@ -5,6 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.findAppNameInContents = exports.findAppNameInConfig = void 0;
|
|
7
7
|
var fs_1 = __importDefault(require("fs"));
|
|
8
|
+
/**
|
|
9
|
+
* @param {string} path
|
|
10
|
+
*/
|
|
8
11
|
function findAppNameInConfig(path) {
|
|
9
12
|
if (!fs_1.default.existsSync(path)) {
|
|
10
13
|
return null;
|
|
@@ -13,6 +16,9 @@ function findAppNameInConfig(path) {
|
|
|
13
16
|
return findAppNameInContents(file);
|
|
14
17
|
}
|
|
15
18
|
exports.findAppNameInConfig = findAppNameInConfig;
|
|
19
|
+
/**
|
|
20
|
+
* @param {string} contents
|
|
21
|
+
*/
|
|
16
22
|
function findAppNameInContents(contents) {
|
|
17
23
|
var matches = /<app (.*)name="([^"]+)/gm.exec(contents);
|
|
18
24
|
if (matches && matches.length >= 2) {
|
package/dist/setup/jss-config.js
CHANGED
|
@@ -18,9 +18,7 @@ exports.replaceConfigTokens = function (val) {
|
|
|
18
18
|
// ensure instance path is defined if used
|
|
19
19
|
// this would result in copying files to random places
|
|
20
20
|
if (newVal.indexOf('{sitecoreInstancePath}') > -1 && !config.sitecore.instancePath) {
|
|
21
|
-
throw new Error(
|
|
22
|
-
// tslint:disable-next-line:max-line-length
|
|
23
|
-
"instancePath config variable was used but was undefined or empty. You likely need to run npm run setup or update your " + setup_1.userConfigPath);
|
|
21
|
+
throw new Error("instancePath config variable was used but was undefined or empty. You likely need to run npm run setup or update your " + setup_1.userConfigPath);
|
|
24
22
|
}
|
|
25
23
|
// variable replacement {var} => var from jss config
|
|
26
24
|
Object.keys(config.sitecore).forEach(function (key) {
|
|
@@ -2,10 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createSecretPatchContents = exports.writeSecretPatchFile = void 0;
|
|
4
4
|
var fs_1 = require("fs");
|
|
5
|
+
/**
|
|
6
|
+
* @param {string} path
|
|
7
|
+
* @param {string} appName
|
|
8
|
+
* @param {string} secret
|
|
9
|
+
*/
|
|
5
10
|
function writeSecretPatchFile(path, appName, secret) {
|
|
6
11
|
fs_1.writeFileSync(path, createSecretPatchContents(appName, secret), { encoding: 'utf8' });
|
|
7
12
|
}
|
|
8
13
|
exports.writeSecretPatchFile = writeSecretPatchFile;
|
|
14
|
+
/**
|
|
15
|
+
* @param {string} appName
|
|
16
|
+
* @param {string} secret
|
|
17
|
+
*/
|
|
9
18
|
function createSecretPatchContents(appName, secret) {
|
|
10
19
|
return "<configuration xmlns:patch=\"http://www.sitecore.net/xmlconfig/\">\n <sitecore>\n <javaScriptServices>\n <apps>\n <app name=\"" + appName + "\"\n deploymentSecret=\"" + secret + "\"\n debugSecurity=\"false\"\n />\n </apps>\n </javaScriptServices>\n </sitecore>\n</configuration>\n";
|
|
11
20
|
}
|