@sitecore-jss/sitecore-jss-dev-tools 22.4.0-canary.1 → 22.4.0-canary.11
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/dist/cjs/package-deploy.js +20 -50
- package/dist/esm/package-deploy.js +20 -27
- package/package.json +4 -4
- package/types/package-deploy.d.ts +2 -4
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -45,11 +22,12 @@ exports.extractProxy = extractProxy;
|
|
|
45
22
|
exports.getHttpsTransport = getHttpsTransport;
|
|
46
23
|
const chalk_1 = __importDefault(require("chalk"));
|
|
47
24
|
const fs_1 = __importDefault(require("fs"));
|
|
48
|
-
const https_1 =
|
|
25
|
+
const https_1 = __importDefault(require("https"));
|
|
49
26
|
const path_1 = __importDefault(require("path"));
|
|
50
27
|
const form_data_1 = __importDefault(require("form-data"));
|
|
51
|
-
const axios_1 = __importDefault(require("axios"));
|
|
52
28
|
const digest_1 = require("./digest");
|
|
29
|
+
const sitecore_jss_1 = require("@sitecore-jss/sitecore-jss");
|
|
30
|
+
const undici_1 = require("undici");
|
|
53
31
|
// Node does not use system level trusted CAs. This causes issues because SIF likes to install
|
|
54
32
|
// using a Windows trusted CA - so SSL connections to Sitecore will fail from Node.
|
|
55
33
|
// If the options.acceptCertificate is passed, we disable normal SSL validation and use this function
|
|
@@ -161,24 +139,20 @@ function watchJobStatus(options, taskName) {
|
|
|
161
139
|
const warnings = [];
|
|
162
140
|
const factors = [options.appName, taskName, `${options.importServiceUrl}/status`];
|
|
163
141
|
const mac = (0, digest_1.hmac)(factors, options.secret);
|
|
164
|
-
const isHttps = options.importServiceUrl.startsWith('https');
|
|
165
142
|
const requestBaseOptions = {
|
|
166
|
-
transport: isHttps ? getHttpsTransport(options) : undefined,
|
|
167
143
|
headers: {
|
|
168
144
|
'User-Agent': 'Sitecore/JSS-Import',
|
|
169
145
|
'Cache-Control': 'no-cache',
|
|
170
146
|
'X-JSS-Auth': mac,
|
|
171
147
|
},
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
// we turn off normal CA cert validation when we are whitelisting a single cert thumbprint
|
|
148
|
+
dispatcher: new undici_1.ProxyAgent({
|
|
149
|
+
uri: options.proxy || '',
|
|
150
|
+
maxRedirections: 0,
|
|
151
|
+
connect: {
|
|
177
152
|
rejectUnauthorized: options.acceptCertificate ? false : true,
|
|
178
|
-
// needed to allow whitelisting a cert thumbprint if a connection is reused
|
|
179
153
|
maxCachedSessions: options.acceptCertificate ? 0 : undefined,
|
|
180
|
-
}
|
|
181
|
-
|
|
154
|
+
},
|
|
155
|
+
}),
|
|
182
156
|
};
|
|
183
157
|
if (options.debugSecurity) {
|
|
184
158
|
console.log(`Deployment status security factors: ${factors}`);
|
|
@@ -189,12 +163,12 @@ function watchJobStatus(options, taskName) {
|
|
|
189
163
|
* Send job status request
|
|
190
164
|
*/
|
|
191
165
|
function sendJobStatusRequest() {
|
|
192
|
-
|
|
166
|
+
new sitecore_jss_1.NativeDataFetcher()
|
|
193
167
|
.get(`${options.importServiceUrl}/status?appName=${options.appName}&jobName=${taskName}&after=${logOffset}`, requestBaseOptions)
|
|
194
168
|
.then((response) => {
|
|
195
169
|
const body = response.data;
|
|
196
170
|
try {
|
|
197
|
-
const { state, messages } = body;
|
|
171
|
+
const { state, messages } = body.data;
|
|
198
172
|
messages.forEach((entry) => {
|
|
199
173
|
logOffset++;
|
|
200
174
|
const entryBits = /^(\[([A-Z]+)\] )?(.+)/.exec(entry);
|
|
@@ -270,24 +244,22 @@ function packageDeploy(options) {
|
|
|
270
244
|
const formData = new form_data_1.default();
|
|
271
245
|
formData.append('path', fs_1.default.createReadStream(packageFile));
|
|
272
246
|
formData.append('appName', options.appName);
|
|
273
|
-
const isHttps = options.importServiceUrl.startsWith('https');
|
|
274
247
|
const requestBaseOptions = {
|
|
275
|
-
transport: isHttps ? getHttpsTransport(options) : undefined,
|
|
276
248
|
headers: Object.assign({ 'User-Agent': 'Sitecore/JSS-Import', 'Cache-Control': 'no-cache', 'X-JSS-Auth': (0, digest_1.hmac)(factors, options.secret) }, formData.getHeaders()),
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
249
|
+
dispatcher: new undici_1.ProxyAgent({
|
|
250
|
+
uri: options.proxy ? options.proxy : '',
|
|
251
|
+
maxRedirections: 0,
|
|
252
|
+
connect: {
|
|
280
253
|
// we turn off normal CA cert validation when we are whitelisting a single cert thumbprint
|
|
281
254
|
rejectUnauthorized: options.acceptCertificate ? false : true,
|
|
282
255
|
// needed to allow whitelisting a cert thumbprint if a connection is reused
|
|
283
256
|
maxCachedSessions: options.acceptCertificate ? 0 : undefined,
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
maxRedirects: 0,
|
|
257
|
+
},
|
|
258
|
+
}),
|
|
287
259
|
};
|
|
288
260
|
console.log(`Sending package ${packageFile} to ${options.importServiceUrl}...`);
|
|
289
261
|
return new Promise((resolve, reject) => {
|
|
290
|
-
|
|
262
|
+
new sitecore_jss_1.NativeDataFetcher()
|
|
291
263
|
.post(options.importServiceUrl, formData, requestBaseOptions)
|
|
292
264
|
.then((response) => {
|
|
293
265
|
const body = response.data;
|
|
@@ -309,7 +281,7 @@ function packageDeploy(options) {
|
|
|
309
281
|
});
|
|
310
282
|
}
|
|
311
283
|
/**
|
|
312
|
-
* Creates valid proxy object
|
|
284
|
+
* Creates valid proxy object
|
|
313
285
|
* @param {string} [proxy] proxy url
|
|
314
286
|
*/
|
|
315
287
|
function extractProxy(proxy) {
|
|
@@ -329,9 +301,7 @@ function extractProxy(proxy) {
|
|
|
329
301
|
}
|
|
330
302
|
}
|
|
331
303
|
/**
|
|
332
|
-
* Provides way to customize
|
|
333
|
-
* in order to execute certificate pinning before request sent:
|
|
334
|
-
* {@link https://github.com/axios/axios/issues/2808}
|
|
304
|
+
* Provides way to customize request adapter
|
|
335
305
|
* @param {PackageDeployOptions} options
|
|
336
306
|
*/
|
|
337
307
|
function getHttpsTransport(options) {
|
|
@@ -9,11 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import chalk from 'chalk';
|
|
11
11
|
import fs from 'fs';
|
|
12
|
-
import https
|
|
12
|
+
import https from 'https';
|
|
13
13
|
import path from 'path';
|
|
14
14
|
import FormData from 'form-data';
|
|
15
|
-
import axios from 'axios';
|
|
16
15
|
import { digest, hmac } from './digest';
|
|
16
|
+
import { NativeDataFetcher } from '@sitecore-jss/sitecore-jss';
|
|
17
|
+
import { ProxyAgent } from 'undici';
|
|
17
18
|
// Node does not use system level trusted CAs. This causes issues because SIF likes to install
|
|
18
19
|
// using a Windows trusted CA - so SSL connections to Sitecore will fail from Node.
|
|
19
20
|
// If the options.acceptCertificate is passed, we disable normal SSL validation and use this function
|
|
@@ -125,24 +126,20 @@ function watchJobStatus(options, taskName) {
|
|
|
125
126
|
const warnings = [];
|
|
126
127
|
const factors = [options.appName, taskName, `${options.importServiceUrl}/status`];
|
|
127
128
|
const mac = hmac(factors, options.secret);
|
|
128
|
-
const isHttps = options.importServiceUrl.startsWith('https');
|
|
129
129
|
const requestBaseOptions = {
|
|
130
|
-
transport: isHttps ? getHttpsTransport(options) : undefined,
|
|
131
130
|
headers: {
|
|
132
131
|
'User-Agent': 'Sitecore/JSS-Import',
|
|
133
132
|
'Cache-Control': 'no-cache',
|
|
134
133
|
'X-JSS-Auth': mac,
|
|
135
134
|
},
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
// we turn off normal CA cert validation when we are whitelisting a single cert thumbprint
|
|
135
|
+
dispatcher: new ProxyAgent({
|
|
136
|
+
uri: options.proxy || '',
|
|
137
|
+
maxRedirections: 0,
|
|
138
|
+
connect: {
|
|
141
139
|
rejectUnauthorized: options.acceptCertificate ? false : true,
|
|
142
|
-
// needed to allow whitelisting a cert thumbprint if a connection is reused
|
|
143
140
|
maxCachedSessions: options.acceptCertificate ? 0 : undefined,
|
|
144
|
-
}
|
|
145
|
-
|
|
141
|
+
},
|
|
142
|
+
}),
|
|
146
143
|
};
|
|
147
144
|
if (options.debugSecurity) {
|
|
148
145
|
console.log(`Deployment status security factors: ${factors}`);
|
|
@@ -153,12 +150,12 @@ function watchJobStatus(options, taskName) {
|
|
|
153
150
|
* Send job status request
|
|
154
151
|
*/
|
|
155
152
|
function sendJobStatusRequest() {
|
|
156
|
-
|
|
153
|
+
new NativeDataFetcher()
|
|
157
154
|
.get(`${options.importServiceUrl}/status?appName=${options.appName}&jobName=${taskName}&after=${logOffset}`, requestBaseOptions)
|
|
158
155
|
.then((response) => {
|
|
159
156
|
const body = response.data;
|
|
160
157
|
try {
|
|
161
|
-
const { state, messages } = body;
|
|
158
|
+
const { state, messages } = body.data;
|
|
162
159
|
messages.forEach((entry) => {
|
|
163
160
|
logOffset++;
|
|
164
161
|
const entryBits = /^(\[([A-Z]+)\] )?(.+)/.exec(entry);
|
|
@@ -234,24 +231,22 @@ export function packageDeploy(options) {
|
|
|
234
231
|
const formData = new FormData();
|
|
235
232
|
formData.append('path', fs.createReadStream(packageFile));
|
|
236
233
|
formData.append('appName', options.appName);
|
|
237
|
-
const isHttps = options.importServiceUrl.startsWith('https');
|
|
238
234
|
const requestBaseOptions = {
|
|
239
|
-
transport: isHttps ? getHttpsTransport(options) : undefined,
|
|
240
235
|
headers: Object.assign({ 'User-Agent': 'Sitecore/JSS-Import', 'Cache-Control': 'no-cache', 'X-JSS-Auth': hmac(factors, options.secret) }, formData.getHeaders()),
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
236
|
+
dispatcher: new ProxyAgent({
|
|
237
|
+
uri: options.proxy ? options.proxy : '',
|
|
238
|
+
maxRedirections: 0,
|
|
239
|
+
connect: {
|
|
244
240
|
// we turn off normal CA cert validation when we are whitelisting a single cert thumbprint
|
|
245
241
|
rejectUnauthorized: options.acceptCertificate ? false : true,
|
|
246
242
|
// needed to allow whitelisting a cert thumbprint if a connection is reused
|
|
247
243
|
maxCachedSessions: options.acceptCertificate ? 0 : undefined,
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
maxRedirects: 0,
|
|
244
|
+
},
|
|
245
|
+
}),
|
|
251
246
|
};
|
|
252
247
|
console.log(`Sending package ${packageFile} to ${options.importServiceUrl}...`);
|
|
253
248
|
return new Promise((resolve, reject) => {
|
|
254
|
-
|
|
249
|
+
new NativeDataFetcher()
|
|
255
250
|
.post(options.importServiceUrl, formData, requestBaseOptions)
|
|
256
251
|
.then((response) => {
|
|
257
252
|
const body = response.data;
|
|
@@ -273,7 +268,7 @@ export function packageDeploy(options) {
|
|
|
273
268
|
});
|
|
274
269
|
}
|
|
275
270
|
/**
|
|
276
|
-
* Creates valid proxy object
|
|
271
|
+
* Creates valid proxy object
|
|
277
272
|
* @param {string} [proxy] proxy url
|
|
278
273
|
*/
|
|
279
274
|
export function extractProxy(proxy) {
|
|
@@ -293,9 +288,7 @@ export function extractProxy(proxy) {
|
|
|
293
288
|
}
|
|
294
289
|
}
|
|
295
290
|
/**
|
|
296
|
-
* Provides way to customize
|
|
297
|
-
* in order to execute certificate pinning before request sent:
|
|
298
|
-
* {@link https://github.com/axios/axios/issues/2808}
|
|
291
|
+
* Provides way to customize request adapter
|
|
299
292
|
* @param {PackageDeployOptions} options
|
|
300
293
|
*/
|
|
301
294
|
export function getHttpsTransport(options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-dev-tools",
|
|
3
|
-
"version": "22.4.0-canary.
|
|
3
|
+
"version": "22.4.0-canary.11",
|
|
4
4
|
"description": "Utilities to assist in the development and deployment of Sitecore JSS apps.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -33,8 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/parser": "^7.24.0",
|
|
36
|
-
"@sitecore-jss/sitecore-jss": "^22.4.0-canary.
|
|
37
|
-
"axios": "^1.3.2",
|
|
36
|
+
"@sitecore-jss/sitecore-jss": "^22.4.0-canary.11",
|
|
38
37
|
"chalk": "^4.1.2",
|
|
39
38
|
"chokidar": "^3.6.0",
|
|
40
39
|
"del": "^6.0.0",
|
|
@@ -51,6 +50,7 @@
|
|
|
51
50
|
"recast": "^0.23.5",
|
|
52
51
|
"resolve": "^1.22.1",
|
|
53
52
|
"ts-node": "^10.9.1",
|
|
53
|
+
"undici": "^7.2.1",
|
|
54
54
|
"url-join": "^4.0.1",
|
|
55
55
|
"uuid": "^9.0.0",
|
|
56
56
|
"yargs": "^17.6.2"
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"typescript": "~5.6.3"
|
|
87
87
|
},
|
|
88
88
|
"types": "types/index.d.ts",
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "e73a9e717af4eeed7ad334b5822a1efe8f087ea1",
|
|
90
90
|
"files": [
|
|
91
91
|
"dist",
|
|
92
92
|
"types",
|
|
@@ -54,7 +54,7 @@ export declare function logJobStatus({ message, entryLevel, warnings, errors, }:
|
|
|
54
54
|
*/
|
|
55
55
|
export declare function packageDeploy(options: PackageDeployOptions): Promise<unknown>;
|
|
56
56
|
/**
|
|
57
|
-
* Creates valid proxy object
|
|
57
|
+
* Creates valid proxy object
|
|
58
58
|
* @param {string} [proxy] proxy url
|
|
59
59
|
*/
|
|
60
60
|
export declare function extractProxy(proxy?: string): {
|
|
@@ -63,9 +63,7 @@ export declare function extractProxy(proxy?: string): {
|
|
|
63
63
|
port: number;
|
|
64
64
|
} | undefined;
|
|
65
65
|
/**
|
|
66
|
-
* Provides way to customize
|
|
67
|
-
* in order to execute certificate pinning before request sent:
|
|
68
|
-
* {@link https://github.com/axios/axios/issues/2808}
|
|
66
|
+
* Provides way to customize request adapter
|
|
69
67
|
* @param {PackageDeployOptions} options
|
|
70
68
|
*/
|
|
71
69
|
export declare function getHttpsTransport(options: PackageDeployOptions): {
|