@contentstack/cli-utilities 1.18.0-beta.0 → 1.18.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/lib/contentstack-management-sdk.js +13 -3
- package/lib/contentstack-marketplace-sdk.d.ts +2 -2
- package/lib/fs-utility/core.js +0 -2
- package/lib/http-client/client.js +22 -2
- package/lib/http-client/http-response.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/interfaces/index.d.ts +1 -1
- package/lib/logger/cli-error-handler.js +1 -1
- package/lib/logger/log.js +1 -1
- package/lib/logger/session-path.js +1 -1
- package/lib/proxy-helper.d.ts +42 -1
- package/lib/proxy-helper.js +181 -29
- package/package.json +10 -11
|
@@ -15,10 +15,16 @@ class ManagementSDKInitiator {
|
|
|
15
15
|
this.analyticsInfo = context === null || context === void 0 ? void 0 : context.analyticsInfo;
|
|
16
16
|
}
|
|
17
17
|
async createAPIClient(config) {
|
|
18
|
-
//
|
|
19
|
-
const
|
|
18
|
+
// Resolve host so NO_PROXY applies even when config.host is omitted (e.g. from region.cma)
|
|
19
|
+
const host = (0, proxy_helper_1.resolveRequestHost)(config);
|
|
20
|
+
// NO_PROXY has priority over HTTP_PROXY/HTTPS_PROXY and config-set proxy
|
|
21
|
+
const proxyConfig = (0, proxy_helper_1.getProxyConfigForHost)(host);
|
|
22
|
+
// When NO_PROXY matches, strip proxy env so SDK/axios cannot pick up HTTP_PROXY for this process.
|
|
23
|
+
if (host && (0, proxy_helper_1.shouldBypassProxy)(host)) {
|
|
24
|
+
(0, proxy_helper_1.clearProxyEnv)();
|
|
25
|
+
}
|
|
20
26
|
const option = {
|
|
21
|
-
host: config.host,
|
|
27
|
+
host: config.host || host || undefined,
|
|
22
28
|
maxContentLength: config.maxContentLength || 100000000,
|
|
23
29
|
maxBodyLength: config.maxBodyLength || 1000000000,
|
|
24
30
|
maxRequests: 10,
|
|
@@ -106,6 +112,10 @@ class ManagementSDKInitiator {
|
|
|
106
112
|
if (proxyConfig) {
|
|
107
113
|
option.proxy = proxyConfig;
|
|
108
114
|
}
|
|
115
|
+
else if (host && (0, proxy_helper_1.shouldBypassProxy)(host)) {
|
|
116
|
+
option.proxy = false;
|
|
117
|
+
}
|
|
118
|
+
// When host is in NO_PROXY, do not add proxy to option at all
|
|
109
119
|
if (config.endpoint) {
|
|
110
120
|
option.endpoint = config.endpoint;
|
|
111
121
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { App, AppData } from '@contentstack/marketplace-sdk/types/marketplace/app';
|
|
1
|
+
import type { App, AppData } from '@contentstack/marketplace-sdk/types/marketplace/app';
|
|
2
2
|
import { ContentstackConfig, ContentstackClient, ContentstackToken } from '@contentstack/marketplace-sdk';
|
|
3
|
-
import { Installation } from '@contentstack/marketplace-sdk/types/marketplace/installation';
|
|
3
|
+
import type { Installation } from '@contentstack/marketplace-sdk/types/marketplace/installation';
|
|
4
4
|
type ConfigType = Pick<ContentstackConfig, 'host' | 'endpoint' | 'retryDelay' | 'retryLimit'> & {
|
|
5
5
|
skipTokenValidity?: string;
|
|
6
6
|
};
|
package/lib/fs-utility/core.js
CHANGED
|
@@ -337,11 +337,9 @@ class FsUtility {
|
|
|
337
337
|
this.pageInfo.after = index || 0;
|
|
338
338
|
this.pageInfo.before = 1;
|
|
339
339
|
}
|
|
340
|
-
/* eslint-disable unicorn/consistent-destructuring */
|
|
341
340
|
if (!(0, isEmpty_1.default)(this.readIndexer[this.pageInfo.after + 1])) {
|
|
342
341
|
this.pageInfo.hasNextPage = true;
|
|
343
342
|
}
|
|
344
|
-
/* eslint-disable unicorn/consistent-destructuring */
|
|
345
343
|
if (!(0, isEmpty_1.default)(this.readIndexer[this.pageInfo.after - 1])) {
|
|
346
344
|
this.pageInfo.hasPreviousPage = true;
|
|
347
345
|
}
|
|
@@ -7,6 +7,22 @@ const http_response_1 = require("./http-response");
|
|
|
7
7
|
const config_handler_1 = tslib_1.__importDefault(require("../config-handler"));
|
|
8
8
|
const auth_handler_1 = tslib_1.__importDefault(require("../auth-handler"));
|
|
9
9
|
const proxy_helper_1 = require("../proxy-helper");
|
|
10
|
+
/**
|
|
11
|
+
* Derive request host from baseURL or url for NO_PROXY checks.
|
|
12
|
+
*/
|
|
13
|
+
function getRequestHost(baseURL, url) {
|
|
14
|
+
const toTry = [baseURL, url].filter(Boolean);
|
|
15
|
+
for (const u of toTry) {
|
|
16
|
+
try {
|
|
17
|
+
const parsed = new URL(u.startsWith('http') ? u : `https://${u}`);
|
|
18
|
+
return parsed.hostname || undefined;
|
|
19
|
+
}
|
|
20
|
+
catch (_a) {
|
|
21
|
+
// ignore
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
10
26
|
class HttpClient {
|
|
11
27
|
/**
|
|
12
28
|
* Createa new pending HTTP request instance.
|
|
@@ -340,12 +356,16 @@ class HttpClient {
|
|
|
340
356
|
this.headers({ 'x-header-ea': Object.values(earlyAccessHeaders).join(',') });
|
|
341
357
|
}
|
|
342
358
|
}
|
|
343
|
-
// Configure proxy if available
|
|
359
|
+
// Configure proxy if available. NO_PROXY has priority; fall back to region CMA for host resolution.
|
|
344
360
|
if (!this.request.proxy) {
|
|
345
|
-
const
|
|
361
|
+
const host = getRequestHost(this.request.baseURL, url) || (0, proxy_helper_1.resolveRequestHost)({});
|
|
362
|
+
const proxyConfig = (0, proxy_helper_1.getProxyConfigForHost)(host);
|
|
346
363
|
if (proxyConfig) {
|
|
347
364
|
this.request.proxy = proxyConfig;
|
|
348
365
|
}
|
|
366
|
+
else if (host && (0, proxy_helper_1.shouldBypassProxy)(host)) {
|
|
367
|
+
this.request.proxy = false;
|
|
368
|
+
}
|
|
349
369
|
}
|
|
350
370
|
return await this.axiosInstance(Object.assign(Object.assign({ url,
|
|
351
371
|
method, withCredentials: true }, this.request), { data: this.prepareRequestPayload() }));
|
package/lib/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export * from './path-validator';
|
|
|
22
22
|
export { default as CLITable, TableFlags, TableHeader, TableOptions, TableData } from './cli-table';
|
|
23
23
|
export { App, AppData, Installation, marketplaceSDKClient, MarketplaceSDKInitiator, marketplaceSDKInitiator, ContentstackMarketplaceClient, ContentstackMarketplaceConfig, };
|
|
24
24
|
export { Args, CommandHelp, Config, Errors, Flags, loadHelpClass, Help, HelpBase, HelpSection, HelpSectionRenderer, HelpSectionKeyValueTable, Hook, Interfaces, Parser, Plugin, run, toStandardizedId, toConfiguredId, settings, Settings, flush, ux, execute, } from '@oclif/core';
|
|
25
|
-
export { FlagInput, ArgInput, FlagDefinition } from '@oclif/core/lib/interfaces/parser';
|
|
25
|
+
export type { FlagInput, ArgInput, FlagDefinition } from '@oclif/core/lib/interfaces/parser';
|
|
26
26
|
export { default as TablePrompt } from './inquirer-table-prompt';
|
|
27
27
|
export { Logger };
|
|
28
28
|
export { default as authenticationHandler } from './authentication-handler';
|
|
@@ -16,7 +16,7 @@ export interface InquirePayload {
|
|
|
16
16
|
default?: any;
|
|
17
17
|
message: string;
|
|
18
18
|
choices?: Array<any>;
|
|
19
|
-
transformer?:
|
|
19
|
+
transformer?: (value: any) => any;
|
|
20
20
|
validate?(input: any, answers?: any): boolean | string | Promise<boolean | string>;
|
|
21
21
|
selectAll?: boolean;
|
|
22
22
|
pageSize?: number;
|
|
@@ -175,7 +175,7 @@ class CLIErrorHandler {
|
|
|
175
175
|
*/
|
|
176
176
|
extractErrorPayload(error) {
|
|
177
177
|
var _a, _b, _c, _d;
|
|
178
|
-
const { name, message, code, status, response, request, config, statusText } = error;
|
|
178
|
+
const { name, message: _message, code, status, response, request, config, statusText } = error;
|
|
179
179
|
const payload = {
|
|
180
180
|
name,
|
|
181
181
|
message: this.extractClearMessage(error),
|
package/lib/logger/log.js
CHANGED
|
@@ -43,7 +43,7 @@ function createSessionMetadataFile(sessionPath, metadata) {
|
|
|
43
43
|
try {
|
|
44
44
|
fs.writeFileSync(metadataPath, JSON.stringify(metadata, null, 2), 'utf8');
|
|
45
45
|
}
|
|
46
|
-
catch (
|
|
46
|
+
catch (_a) {
|
|
47
47
|
// Silently fail if metadata file cannot be created
|
|
48
48
|
// Logging here would cause circular dependency
|
|
49
49
|
// The session folder and logs will still be created
|
package/lib/proxy-helper.d.ts
CHANGED
|
@@ -8,10 +8,51 @@ export interface ProxyConfig {
|
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Parse NO_PROXY / no_proxy env (both uppercase and lowercase).
|
|
12
|
+
* NO_PROXY has priority over HTTP_PROXY/HTTPS_PROXY: hosts in this list never use the proxy.
|
|
13
|
+
* Values are hostnames only, comma-separated; leading dot matches subdomains (e.g. .contentstack.io).
|
|
14
|
+
* The bypass list is fully dynamic: only env values are used (no hardcoded default).
|
|
15
|
+
* @returns List of trimmed entries, or empty array when NO_PROXY/no_proxy is unset
|
|
16
|
+
*/
|
|
17
|
+
export declare function getNoProxyList(): string[];
|
|
18
|
+
/**
|
|
19
|
+
* Check if the given host should bypass the proxy based on NO_PROXY / no_proxy.
|
|
20
|
+
* Supports: exact host, leading-dot subdomain match (e.g. .contentstack.io), and wildcard *.
|
|
21
|
+
* @param host - Request hostname (with or without port; will be normalized)
|
|
22
|
+
* @returns true if proxy should not be used for this host
|
|
23
|
+
*/
|
|
24
|
+
export declare function shouldBypassProxy(host: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Get proxy configuration. Priority order (per spec):
|
|
27
|
+
* 1. Global CLI config from `csdx config:set:proxy --host <host> --port <port> --protocol <protocol>`
|
|
28
|
+
* 2. Environment variables (HTTPS_PROXY or HTTP_PROXY)
|
|
29
|
+
* For per-request use, prefer getProxyConfigForHost(host) so NO_PROXY overrides both sources.
|
|
12
30
|
* @returns ProxyConfig object or undefined if no proxy is configured
|
|
13
31
|
*/
|
|
14
32
|
export declare function getProxyConfig(): ProxyConfig | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Get proxy config only when the request host is not in NO_PROXY.
|
|
35
|
+
* NO_PROXY has priority over both HTTP_PROXY/HTTPS_PROXY and over proxy set via
|
|
36
|
+
* `csdx config:set:proxy` — if the host matches NO_PROXY, no proxy is used.
|
|
37
|
+
* Use this for all outbound requests so Contentstack and localhost bypass the proxy when set.
|
|
38
|
+
* @param host - Request hostname (e.g. api.contentstack.io or full URL like https://api.contentstack.io)
|
|
39
|
+
* @returns ProxyConfig or undefined if proxy is disabled or host should bypass (NO_PROXY)
|
|
40
|
+
*/
|
|
41
|
+
export declare function getProxyConfigForHost(host: string): ProxyConfig | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Hostname for NO_PROXY / proxy. Prefer `region.cma` when set so callers that pass a
|
|
44
|
+
* default SDK host (e.g. bulk-entries -> api.contentstack.io) still match rules like
|
|
45
|
+
* `.csnonprod.com` against the real API host (e.g. dev11-api.csnonprod.com).
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveRequestHost(config: {
|
|
48
|
+
host?: string;
|
|
49
|
+
}): string;
|
|
50
|
+
/**
|
|
51
|
+
* Temporarily clear proxy-related env vars so SDK/axios cannot use them.
|
|
52
|
+
* Call the returned function to restore. Use when creating a client for a host in NO_PROXY.
|
|
53
|
+
* @returns Restore function (call to put env back)
|
|
54
|
+
*/
|
|
55
|
+
export declare function clearProxyEnv(): () => void;
|
|
15
56
|
/**
|
|
16
57
|
* Check if proxy is configured (from any source)
|
|
17
58
|
* @returns true if proxy is configured, false otherwise
|
package/lib/proxy-helper.js
CHANGED
|
@@ -1,41 +1,95 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProxyUrl = exports.hasProxy = exports.getProxyConfig = void 0;
|
|
3
|
+
exports.getProxyUrl = exports.hasProxy = exports.clearProxyEnv = exports.resolveRequestHost = exports.getProxyConfigForHost = exports.getProxyConfig = exports.shouldBypassProxy = exports.getNoProxyList = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const config_handler_1 = tslib_1.__importDefault(require("./config-handler"));
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Parse NO_PROXY / no_proxy env (both uppercase and lowercase).
|
|
8
|
+
* NO_PROXY has priority over HTTP_PROXY/HTTPS_PROXY: hosts in this list never use the proxy.
|
|
9
|
+
* Values are hostnames only, comma-separated; leading dot matches subdomains (e.g. .contentstack.io).
|
|
10
|
+
* The bypass list is fully dynamic: only env values are used (no hardcoded default).
|
|
11
|
+
* @returns List of trimmed entries, or empty array when NO_PROXY/no_proxy is unset
|
|
9
12
|
*/
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
function getNoProxyList() {
|
|
14
|
+
const raw = process.env.NO_PROXY || process.env.no_proxy || '';
|
|
15
|
+
return raw
|
|
16
|
+
.split(',')
|
|
17
|
+
.map((s) => s.trim())
|
|
18
|
+
.filter(Boolean);
|
|
19
|
+
}
|
|
20
|
+
exports.getNoProxyList = getNoProxyList;
|
|
21
|
+
/**
|
|
22
|
+
* Normalize host for NO_PROXY matching: strip protocol/URL, port, lowercase, handle IPv6 brackets.
|
|
23
|
+
* Accepts hostname, host:port, or full URL (e.g. https://api.contentstack.io).
|
|
24
|
+
*/
|
|
25
|
+
function normalizeHost(host) {
|
|
26
|
+
if (!host || typeof host !== 'string')
|
|
27
|
+
return '';
|
|
28
|
+
let h = host.trim().toLowerCase();
|
|
29
|
+
// If it looks like a URL, extract hostname so NO_PROXY matching works (e.g. region.cma is full URL)
|
|
30
|
+
if (h.includes('://')) {
|
|
14
31
|
try {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const port = url.port ? Number.parseInt(url.port, 10) : defaultPort;
|
|
18
|
-
if (!Number.isNaN(port) && port >= 1 && port <= 65535) {
|
|
19
|
-
const protocol = url.protocol.replace(':', '');
|
|
20
|
-
const proxyConfig = {
|
|
21
|
-
protocol: protocol,
|
|
22
|
-
host: url.hostname,
|
|
23
|
-
port: port,
|
|
24
|
-
};
|
|
25
|
-
if (url.username || url.password) {
|
|
26
|
-
proxyConfig.auth = {
|
|
27
|
-
username: url.username,
|
|
28
|
-
password: url.password,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
return proxyConfig;
|
|
32
|
-
}
|
|
32
|
+
const u = new URL(h);
|
|
33
|
+
h = u.hostname;
|
|
33
34
|
}
|
|
34
35
|
catch (_a) {
|
|
35
|
-
//
|
|
36
|
+
// fall through to port stripping below
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const portIdx = h.lastIndexOf(':');
|
|
40
|
+
if (h.startsWith('[')) {
|
|
41
|
+
const close = h.indexOf(']');
|
|
42
|
+
if (close !== -1 && h.length > close + 1 && h[close + 1] === ':') {
|
|
43
|
+
h = h.slice(1, close);
|
|
36
44
|
}
|
|
37
45
|
}
|
|
38
|
-
|
|
46
|
+
else if (portIdx !== -1) {
|
|
47
|
+
const after = h.slice(portIdx + 1);
|
|
48
|
+
if (/^\d+$/.test(after)) {
|
|
49
|
+
h = h.slice(0, portIdx);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return h;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Check if the given host should bypass the proxy based on NO_PROXY / no_proxy.
|
|
56
|
+
* Supports: exact host, leading-dot subdomain match (e.g. .contentstack.io), and wildcard *.
|
|
57
|
+
* @param host - Request hostname (with or without port; will be normalized)
|
|
58
|
+
* @returns true if proxy should not be used for this host
|
|
59
|
+
*/
|
|
60
|
+
function shouldBypassProxy(host) {
|
|
61
|
+
const normalized = normalizeHost(host);
|
|
62
|
+
if (!normalized)
|
|
63
|
+
return false;
|
|
64
|
+
const list = getNoProxyList();
|
|
65
|
+
for (const entry of list) {
|
|
66
|
+
const e = entry.trim().toLowerCase();
|
|
67
|
+
if (!e)
|
|
68
|
+
continue;
|
|
69
|
+
if (e === '*')
|
|
70
|
+
return true;
|
|
71
|
+
if (e.startsWith('.')) {
|
|
72
|
+
const domain = e.slice(1);
|
|
73
|
+
if (normalized === domain || normalized.endsWith(e))
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
if (normalized === e)
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
exports.shouldBypassProxy = shouldBypassProxy;
|
|
84
|
+
/**
|
|
85
|
+
* Get proxy configuration. Priority order (per spec):
|
|
86
|
+
* 1. Global CLI config from `csdx config:set:proxy --host <host> --port <port> --protocol <protocol>`
|
|
87
|
+
* 2. Environment variables (HTTPS_PROXY or HTTP_PROXY)
|
|
88
|
+
* For per-request use, prefer getProxyConfigForHost(host) so NO_PROXY overrides both sources.
|
|
89
|
+
* @returns ProxyConfig object or undefined if no proxy is configured
|
|
90
|
+
*/
|
|
91
|
+
function getProxyConfig() {
|
|
92
|
+
// Priority 1: Global config (csdx config:set:proxy)
|
|
39
93
|
const globalProxyConfig = config_handler_1.default.get('proxy');
|
|
40
94
|
if (globalProxyConfig) {
|
|
41
95
|
if (typeof globalProxyConfig === 'object') {
|
|
@@ -65,14 +119,112 @@ function getProxyConfig() {
|
|
|
65
119
|
return proxyConfig;
|
|
66
120
|
}
|
|
67
121
|
}
|
|
68
|
-
catch (
|
|
69
|
-
// Invalid URL,
|
|
122
|
+
catch (_a) {
|
|
123
|
+
// Invalid URL, continue to check environment
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Priority 2: Environment variables (HTTPS_PROXY or HTTP_PROXY)
|
|
128
|
+
const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
|
|
129
|
+
if (proxyUrl) {
|
|
130
|
+
try {
|
|
131
|
+
const url = new URL(proxyUrl);
|
|
132
|
+
const defaultPort = url.protocol === 'https:' ? 443 : 80;
|
|
133
|
+
const port = url.port ? Number.parseInt(url.port, 10) : defaultPort;
|
|
134
|
+
if (!Number.isNaN(port) && port >= 1 && port <= 65535) {
|
|
135
|
+
const protocol = url.protocol.replace(':', '');
|
|
136
|
+
const proxyConfig = {
|
|
137
|
+
protocol: protocol,
|
|
138
|
+
host: url.hostname,
|
|
139
|
+
port: port,
|
|
140
|
+
};
|
|
141
|
+
if (url.username || url.password) {
|
|
142
|
+
proxyConfig.auth = {
|
|
143
|
+
username: url.username,
|
|
144
|
+
password: url.password,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return proxyConfig;
|
|
70
148
|
}
|
|
71
149
|
}
|
|
150
|
+
catch (_b) {
|
|
151
|
+
// Invalid URL, return undefined
|
|
152
|
+
}
|
|
72
153
|
}
|
|
73
154
|
return undefined;
|
|
74
155
|
}
|
|
75
156
|
exports.getProxyConfig = getProxyConfig;
|
|
157
|
+
/**
|
|
158
|
+
* Get proxy config only when the request host is not in NO_PROXY.
|
|
159
|
+
* NO_PROXY has priority over both HTTP_PROXY/HTTPS_PROXY and over proxy set via
|
|
160
|
+
* `csdx config:set:proxy` — if the host matches NO_PROXY, no proxy is used.
|
|
161
|
+
* Use this for all outbound requests so Contentstack and localhost bypass the proxy when set.
|
|
162
|
+
* @param host - Request hostname (e.g. api.contentstack.io or full URL like https://api.contentstack.io)
|
|
163
|
+
* @returns ProxyConfig or undefined if proxy is disabled or host should bypass (NO_PROXY)
|
|
164
|
+
*/
|
|
165
|
+
function getProxyConfigForHost(host) {
|
|
166
|
+
if (shouldBypassProxy(host))
|
|
167
|
+
return undefined;
|
|
168
|
+
return getProxyConfig();
|
|
169
|
+
}
|
|
170
|
+
exports.getProxyConfigForHost = getProxyConfigForHost;
|
|
171
|
+
function regionCmaHostname() {
|
|
172
|
+
var _a;
|
|
173
|
+
const cma = (_a = config_handler_1.default.get('region')) === null || _a === void 0 ? void 0 : _a.cma;
|
|
174
|
+
if (!cma || typeof cma !== 'string') {
|
|
175
|
+
return '';
|
|
176
|
+
}
|
|
177
|
+
if (cma.startsWith('http')) {
|
|
178
|
+
try {
|
|
179
|
+
const u = new URL(cma);
|
|
180
|
+
return u.hostname || cma;
|
|
181
|
+
}
|
|
182
|
+
catch (_b) {
|
|
183
|
+
return cma;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return cma;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Hostname for NO_PROXY / proxy. Prefer `region.cma` when set so callers that pass a
|
|
190
|
+
* default SDK host (e.g. bulk-entries -> api.contentstack.io) still match rules like
|
|
191
|
+
* `.csnonprod.com` against the real API host (e.g. dev11-api.csnonprod.com).
|
|
192
|
+
*/
|
|
193
|
+
function resolveRequestHost(config) {
|
|
194
|
+
var _a;
|
|
195
|
+
const fromRegion = regionCmaHostname();
|
|
196
|
+
if (fromRegion) {
|
|
197
|
+
return normalizeHost(fromRegion) || fromRegion;
|
|
198
|
+
}
|
|
199
|
+
const raw = ((_a = config.host) === null || _a === void 0 ? void 0 : _a.trim()) || '';
|
|
200
|
+
if (!raw) {
|
|
201
|
+
return '';
|
|
202
|
+
}
|
|
203
|
+
return normalizeHost(raw) || raw;
|
|
204
|
+
}
|
|
205
|
+
exports.resolveRequestHost = resolveRequestHost;
|
|
206
|
+
/**
|
|
207
|
+
* Temporarily clear proxy-related env vars so SDK/axios cannot use them.
|
|
208
|
+
* Call the returned function to restore. Use when creating a client for a host in NO_PROXY.
|
|
209
|
+
* @returns Restore function (call to put env back)
|
|
210
|
+
*/
|
|
211
|
+
function clearProxyEnv() {
|
|
212
|
+
const saved = {};
|
|
213
|
+
const keys = ['HTTP_PROXY', 'HTTPS_PROXY', 'http_proxy', 'https_proxy', 'ALL_PROXY', 'all_proxy'];
|
|
214
|
+
for (const k of keys) {
|
|
215
|
+
if (k in process.env) {
|
|
216
|
+
saved[k] = process.env[k];
|
|
217
|
+
delete process.env[k];
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return () => {
|
|
221
|
+
for (const k of keys) {
|
|
222
|
+
if (saved[k] !== undefined)
|
|
223
|
+
process.env[k] = saved[k];
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
exports.clearProxyEnv = clearProxyEnv;
|
|
76
228
|
/**
|
|
77
229
|
* Check if proxy is configured (from any source)
|
|
78
230
|
* @returns true if proxy is configured, false otherwise
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-utilities",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.1",
|
|
4
4
|
"description": "Utilities for contentstack projects",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -9,14 +9,8 @@
|
|
|
9
9
|
"build": "pnpm compile",
|
|
10
10
|
"clean": "rm -rf ./lib ./node_modules tsconfig.tsbuildinfo",
|
|
11
11
|
"compile": "tsc -b tsconfig.json",
|
|
12
|
-
"test
|
|
13
|
-
"
|
|
14
|
-
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
|
|
15
|
-
"posttest": "npm run lint",
|
|
16
|
-
"lint": "eslint src/**/*.ts",
|
|
17
|
-
"format": "eslint src/**/*.ts --fix",
|
|
18
|
-
"test:unit": "mocha --forbid-only \"test/unit/**/*.test.ts\"",
|
|
19
|
-
"test:unit:report": "nyc --extension .ts mocha --forbid-only \"test/unit/**/*.test.ts\""
|
|
12
|
+
"test": "mocha \"test/unit/**/*.test.ts\"",
|
|
13
|
+
"lint": "eslint src/**/*.ts"
|
|
20
14
|
},
|
|
21
15
|
"repository": {
|
|
22
16
|
"type": "git",
|
|
@@ -35,7 +29,7 @@
|
|
|
35
29
|
"dependencies": {
|
|
36
30
|
"@contentstack/management": "~1.27.5",
|
|
37
31
|
"@contentstack/marketplace-sdk": "^1.5.0",
|
|
38
|
-
"@oclif/core": "^4.3
|
|
32
|
+
"@oclif/core": "^4.8.3",
|
|
39
33
|
"axios": "^1.13.5",
|
|
40
34
|
"chalk": "^4.1.2",
|
|
41
35
|
"cli-cursor": "^3.1.0",
|
|
@@ -49,7 +43,7 @@
|
|
|
49
43
|
"inquirer-search-list": "^1.2.6",
|
|
50
44
|
"js-yaml": "^4.1.1",
|
|
51
45
|
"klona": "^2.0.6",
|
|
52
|
-
"lodash": "^4.
|
|
46
|
+
"lodash": "^4.18.1",
|
|
53
47
|
"mkdirp": "^1.0.4",
|
|
54
48
|
"open": "^8.4.2",
|
|
55
49
|
"ora": "^5.4.1",
|
|
@@ -63,6 +57,11 @@
|
|
|
63
57
|
"winston": "^3.17.0",
|
|
64
58
|
"xdg-basedir": "^4.0.0"
|
|
65
59
|
},
|
|
60
|
+
"overrides": {
|
|
61
|
+
"@oclif/core": {
|
|
62
|
+
"picomatch": "^4.0.4"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
66
65
|
"devDependencies": {
|
|
67
66
|
"@types/chai": "^4.3.20",
|
|
68
67
|
"@types/inquirer": "^9.0.8",
|