@contentstack/cli-utilities 2.0.0-beta.11 → 2.0.0-beta.12
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/content-type-utils.d.ts +1 -6
- package/lib/content-type-utils.js +5 -0
- package/lib/feature-status/build-auth-headers.d.ts +9 -0
- package/lib/feature-status/build-auth-headers.js +32 -0
- package/lib/feature-status/feature-status-handler.d.ts +3 -0
- package/lib/feature-status/feature-status-handler.js +36 -0
- package/lib/feature-status/feature-uids.d.ts +5 -0
- package/lib/feature-status/feature-uids.js +7 -0
- package/lib/feature-status/index.d.ts +5 -0
- package/lib/feature-status/index.js +13 -0
- package/lib/feature-status/resolve-auth-host.d.ts +8 -0
- package/lib/feature-status/resolve-auth-host.js +30 -0
- package/lib/feature-status/types.d.ts +21 -0
- package/lib/feature-status/types.js +2 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +5 -0
- package/lib/logger/logger.js +5 -1
- package/lib/progress-summary/cli-progress-manager.js +9 -4
- package/lib/region-endpoints.d.ts +26 -0
- package/lib/region-endpoints.js +39 -0
- package/lib/region-refresh.d.ts +9 -0
- package/lib/region-refresh.js +26 -0
- package/package.json +5 -4
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Reads all content type schema files from a directory
|
|
3
|
-
* @param dirPath - Path to content types directory
|
|
4
|
-
* @param ignoredFiles - Files to ignore (defaults to schema.json, .DS_Store, __master.json, __priority.json)
|
|
5
|
-
* @returns Array of content type schemas (empty if the path is missing or has no eligible files)
|
|
6
|
-
*/
|
|
1
|
+
export declare function readGlobalFieldSchemas(dirPath: string, ignoredFiles?: string[]): Record<string, unknown>[];
|
|
7
2
|
export declare function readContentTypeSchemas(dirPath: string, ignoredFiles?: string[]): Record<string, unknown>[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readGlobalFieldSchemas = readGlobalFieldSchemas;
|
|
3
4
|
exports.readContentTypeSchemas = readContentTypeSchemas;
|
|
4
5
|
const node_fs_1 = require("node:fs");
|
|
5
6
|
const node_path_1 = require("node:path");
|
|
@@ -9,6 +10,10 @@ const node_path_1 = require("node:path");
|
|
|
9
10
|
* @param ignoredFiles - Files to ignore (defaults to schema.json, .DS_Store, __master.json, __priority.json)
|
|
10
11
|
* @returns Array of content type schemas (empty if the path is missing or has no eligible files)
|
|
11
12
|
*/
|
|
13
|
+
const DEFAULT_GF_IGNORED_FILES = ['schema.json', '.DS_Store', '__master.json', '__priority.json', 'field_rules_uid.json', 'globalfields.json'];
|
|
14
|
+
function readGlobalFieldSchemas(dirPath, ignoredFiles = DEFAULT_GF_IGNORED_FILES) {
|
|
15
|
+
return readContentTypeSchemas(dirPath, ignoredFiles);
|
|
16
|
+
}
|
|
12
17
|
function readContentTypeSchemas(dirPath, ignoredFiles = ['schema.json', '.DS_Store', '__master.json', '__priority.json', 'field_rules_uid.json']) {
|
|
13
18
|
if (!(0, node_fs_1.existsSync)(dirPath)) {
|
|
14
19
|
return [];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildAuthHeaders = buildAuthHeaders;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const config_handler_1 = tslib_1.__importDefault(require("../config-handler"));
|
|
6
|
+
function buildAuthHeaders(ctx) {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
// 1. Management token takes priority (no 'Bearer' prefix — API contract)
|
|
9
|
+
if ((ctx === null || ctx === void 0 ? void 0 : ctx.managementToken) && (ctx === null || ctx === void 0 ? void 0 : ctx.apiKey)) {
|
|
10
|
+
return {
|
|
11
|
+
Authorization: ctx.managementToken,
|
|
12
|
+
api_key: ctx.apiKey,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
// 2. OAuth
|
|
16
|
+
const oauthToken = config_handler_1.default.get('oauthAccessToken');
|
|
17
|
+
if (oauthToken) {
|
|
18
|
+
return { Authorization: `Bearer ${oauthToken}` };
|
|
19
|
+
}
|
|
20
|
+
// 3. Authtoken + organization_uid
|
|
21
|
+
const authtoken = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.authToken) !== null && _a !== void 0 ? _a : config_handler_1.default.get('authtoken');
|
|
22
|
+
const orgUid = (_b = ctx === null || ctx === void 0 ? void 0 : ctx.orgUid) !== null && _b !== void 0 ? _b : config_handler_1.default.get('oauthOrgUid');
|
|
23
|
+
if (authtoken && orgUid) {
|
|
24
|
+
return { authtoken, organization_uid: orgUid };
|
|
25
|
+
}
|
|
26
|
+
// 4. Authtoken + api_key
|
|
27
|
+
if (authtoken && (ctx === null || ctx === void 0 ? void 0 : ctx.apiKey)) {
|
|
28
|
+
return { authtoken, api_key: ctx.apiKey };
|
|
29
|
+
}
|
|
30
|
+
throw new Error('PLAN_CHECK: Cannot build auth headers — no valid credentials available. ' +
|
|
31
|
+
'Please log in or provide a management token alias.');
|
|
32
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFeatureEnabled = isFeatureEnabled;
|
|
4
|
+
exports.assertFeatureEnabled = assertFeatureEnabled;
|
|
5
|
+
const http_client_1 = require("../http-client");
|
|
6
|
+
const resolve_auth_host_1 = require("./resolve-auth-host");
|
|
7
|
+
const build_auth_headers_1 = require("./build-auth-headers");
|
|
8
|
+
async function isFeatureEnabled(featureUid, ctx) {
|
|
9
|
+
const host = (0, resolve_auth_host_1.resolveAuthHost)(ctx);
|
|
10
|
+
const headers = (0, build_auth_headers_1.buildAuthHeaders)(ctx);
|
|
11
|
+
const client = new http_client_1.HttpClient();
|
|
12
|
+
client.baseUrl(host).headers(headers);
|
|
13
|
+
const res = await client.get(`/v1/feature-status?feature_uid=${encodeURIComponent(featureUid)}`);
|
|
14
|
+
if (res.status < 200 || res.status >= 300) {
|
|
15
|
+
throw new Error(`PLAN_CHECK: feature-status API returned ${res.status} for "${featureUid}".`);
|
|
16
|
+
}
|
|
17
|
+
return res.data;
|
|
18
|
+
}
|
|
19
|
+
async function assertFeatureEnabled(featureUid, ctx) {
|
|
20
|
+
let status;
|
|
21
|
+
try {
|
|
22
|
+
status = await isFeatureEnabled(featureUid, ctx);
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
throw new Error(`Could not verify your plan for "${featureUid}". ` +
|
|
26
|
+
`This command requires a confirmed plan status to run. ` +
|
|
27
|
+
`Please retry; if the problem persists contact support. (${e.message})`);
|
|
28
|
+
}
|
|
29
|
+
if (!status.is_part_of_plan) {
|
|
30
|
+
throw new Error(`"${featureUid}" is not part of your current plan. Please upgrade your plan to use this feature.`);
|
|
31
|
+
}
|
|
32
|
+
if (status.status !== 'enabled') {
|
|
33
|
+
throw new Error(`"${featureUid}" is not enabled for your plan (status: ${status.status}).`);
|
|
34
|
+
}
|
|
35
|
+
return status;
|
|
36
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertFeatureEnabled = exports.isFeatureEnabled = exports.buildAuthHeaders = exports.resolveAuthHost = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./feature-uids"), exports);
|
|
7
|
+
var resolve_auth_host_1 = require("./resolve-auth-host");
|
|
8
|
+
Object.defineProperty(exports, "resolveAuthHost", { enumerable: true, get: function () { return resolve_auth_host_1.resolveAuthHost; } });
|
|
9
|
+
var build_auth_headers_1 = require("./build-auth-headers");
|
|
10
|
+
Object.defineProperty(exports, "buildAuthHeaders", { enumerable: true, get: function () { return build_auth_headers_1.buildAuthHeaders; } });
|
|
11
|
+
var feature_status_handler_1 = require("./feature-status-handler");
|
|
12
|
+
Object.defineProperty(exports, "isFeatureEnabled", { enumerable: true, get: function () { return feature_status_handler_1.isFeatureEnabled; } });
|
|
13
|
+
Object.defineProperty(exports, "assertFeatureEnabled", { enumerable: true, get: function () { return feature_status_handler_1.assertFeatureEnabled; } });
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveAuthHost = resolveAuthHost;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const config_handler_1 = tslib_1.__importDefault(require("../config-handler"));
|
|
6
|
+
// Mirrors config:set:region's own custom-region fallback (region.ts's transformUrl) —
|
|
7
|
+
// same heuristic, applied retroactively for a custom region that predates auth-api.
|
|
8
|
+
// Computed fresh on each call, never persisted back to config.
|
|
9
|
+
function deriveAuthFromCma(cma) {
|
|
10
|
+
let transformed = cma.replace('api', 'auth-api');
|
|
11
|
+
if (transformed.startsWith('http')) {
|
|
12
|
+
transformed = transformed.split('//')[1];
|
|
13
|
+
}
|
|
14
|
+
transformed = transformed.replace(/^dev\d+/, 'dev');
|
|
15
|
+
transformed = transformed.endsWith('io') ? transformed.replace('io', 'com') : transformed;
|
|
16
|
+
return `https://${transformed}`;
|
|
17
|
+
}
|
|
18
|
+
function resolveAuthHost(ctx) {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
const region = ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.region) !== null && _a !== void 0 ? _a : config_handler_1.default.get('region'));
|
|
21
|
+
let authUrl = (_b = region === null || region === void 0 ? void 0 : region.endpoints) === null || _b === void 0 ? void 0 : _b.auth;
|
|
22
|
+
if (!authUrl && (region === null || region === void 0 ? void 0 : region.cma)) {
|
|
23
|
+
authUrl = deriveAuthFromCma(region.cma);
|
|
24
|
+
}
|
|
25
|
+
if (!authUrl) {
|
|
26
|
+
throw new Error('PLAN_CHECK: Auth host is not configured for the current region. ' +
|
|
27
|
+
"Re-run `csdx config:set:region` to refresh region endpoints.");
|
|
28
|
+
}
|
|
29
|
+
return String(authUrl).replace(/\/$/, '');
|
|
30
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface FeatureStatus {
|
|
2
|
+
org_uid: string;
|
|
3
|
+
feature_key: string;
|
|
4
|
+
status: 'enabled' | 'disabled' | string;
|
|
5
|
+
limit: number;
|
|
6
|
+
max_limit: number;
|
|
7
|
+
is_part_of_plan: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface FeatureCtx {
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
orgUid?: string;
|
|
12
|
+
managementToken?: string;
|
|
13
|
+
authToken?: string;
|
|
14
|
+
region?: {
|
|
15
|
+
name?: string;
|
|
16
|
+
cma?: string;
|
|
17
|
+
endpoints?: {
|
|
18
|
+
auth?: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -30,3 +30,6 @@ export { Logger };
|
|
|
30
30
|
export { default as authenticationHandler } from './authentication-handler';
|
|
31
31
|
export { v2Logger as log, cliErrorHandler, handleAndLogError, getLogPath, getSessionLogPath } from './logger/log';
|
|
32
32
|
export { CLIProgressManager, SummaryManager, PrimaryProcessStrategy, ProgressStrategyRegistry, CustomProgressStrategy, DefaultProgressStrategy } from './progress-summary';
|
|
33
|
+
export * from './feature-status';
|
|
34
|
+
export * from './region-endpoints';
|
|
35
|
+
export { refreshRegionEndpoints } from './region-refresh';
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DefaultProgressStrategy = exports.CustomProgressStrategy = exports.ProgressStrategyRegistry = exports.PrimaryProcessStrategy = exports.SummaryManager = exports.CLIProgressManager = exports.getSessionLogPath = exports.getLogPath = exports.handleAndLogError = exports.cliErrorHandler = exports.log = exports.authenticationHandler = exports.Logger = exports.getChalk = exports.loadChalk = exports.TablePrompt = exports.execute = exports.ux = exports.flush = exports.settings = exports.toConfiguredId = exports.toStandardizedId = exports.Plugin = exports.Parser = exports.Interfaces = exports.HelpBase = exports.Help = exports.loadHelpClass = exports.Flags = exports.Errors = exports.Config = exports.CommandHelp = exports.Args = exports.marketplaceSDKInitiator = exports.MarketplaceSDKInitiator = exports.marketplaceSDKClient = exports.CLITable = exports.createLogContext = exports.Command = exports.flags = exports.args = exports.NodeCrypto = exports.managementSDKInitiator = exports.managementSDKClient = exports.configHandler = exports.authHandler = exports.messageHandler = exports.CLIError = exports.cliux = exports.LoggerService = void 0;
|
|
4
|
+
exports.refreshRegionEndpoints = void 0;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const logger_1 = tslib_1.__importDefault(require("./logger"));
|
|
6
7
|
exports.Logger = logger_1.default;
|
|
@@ -82,3 +83,7 @@ Object.defineProperty(exports, "PrimaryProcessStrategy", { enumerable: true, get
|
|
|
82
83
|
Object.defineProperty(exports, "ProgressStrategyRegistry", { enumerable: true, get: function () { return progress_summary_1.ProgressStrategyRegistry; } });
|
|
83
84
|
Object.defineProperty(exports, "CustomProgressStrategy", { enumerable: true, get: function () { return progress_summary_1.CustomProgressStrategy; } });
|
|
84
85
|
Object.defineProperty(exports, "DefaultProgressStrategy", { enumerable: true, get: function () { return progress_summary_1.DefaultProgressStrategy; } });
|
|
86
|
+
tslib_1.__exportStar(require("./feature-status"), exports);
|
|
87
|
+
tslib_1.__exportStar(require("./region-endpoints"), exports);
|
|
88
|
+
var region_refresh_1 = require("./region-refresh");
|
|
89
|
+
Object.defineProperty(exports, "refreshRegionEndpoints", { enumerable: true, get: function () { return region_refresh_1.refreshRegionEndpoints; } });
|
package/lib/logger/logger.js
CHANGED
|
@@ -70,7 +70,11 @@ class Logger {
|
|
|
70
70
|
showConsoleLogs = true;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
// Errors and warnings must always reach the console, even when progress bars
|
|
74
|
+
// suppress info/success/debug output — otherwise failures (e.g. an invalid
|
|
75
|
+
// stack API key or a taxonomy error) are silently swallowed in progress mode.
|
|
76
|
+
const isErrorOrWarn = level === 'error' || level === 'warn';
|
|
77
|
+
if (showConsoleLogs || isErrorOrWarn) {
|
|
74
78
|
transports.push(new winston.transports.Console({
|
|
75
79
|
format: winston.format.combine(winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), winston.format.printf((info) => {
|
|
76
80
|
// Apply full redaction for console (user-facing)
|
|
@@ -353,14 +353,19 @@ class CLIProgressManager {
|
|
|
353
353
|
}
|
|
354
354
|
if (!this.showConsoleLogs && process.progressBar) {
|
|
355
355
|
const totalProcessed = process.current;
|
|
356
|
-
|
|
356
|
+
// Reconcile the bar's total with the number of items actually processed so the
|
|
357
|
+
// rendered "value/total" matches the "Complete (success/processed)" summary. A
|
|
358
|
+
// process registered with an estimated total larger than the items actually ticked
|
|
359
|
+
// would otherwise render mismatched counts, e.g. "37/37 | Complete (27/27)".
|
|
360
|
+
process.progressBar.setTotal(totalProcessed);
|
|
361
|
+
const percentage = totalProcessed > 0 ? 100 : 0;
|
|
357
362
|
const formattedPercentage = this.formatPercentage(percentage);
|
|
358
363
|
const statusText = success
|
|
359
|
-
? (0, chalk_1.getChalk)().green(`✓ Complete (${process.successCount}/${
|
|
360
|
-
: (0, chalk_1.getChalk)().red(`✗ Failed (${process.successCount}/${
|
|
364
|
+
? (0, chalk_1.getChalk)().green(`✓ Complete (${process.successCount}/${totalProcessed})`)
|
|
365
|
+
: (0, chalk_1.getChalk)().red(`✗ Failed (${process.successCount}/${totalProcessed})`);
|
|
361
366
|
const displayName = this.formatProcessName(processName);
|
|
362
367
|
const indentedLabel = ` ├─ ${displayName}`.padEnd(25);
|
|
363
|
-
process.progressBar.update(
|
|
368
|
+
process.progressBar.update(totalProcessed, {
|
|
364
369
|
label: success ? (0, chalk_1.getChalk)().green(indentedLabel) : (0, chalk_1.getChalk)().red(indentedLabel),
|
|
365
370
|
status: statusText,
|
|
366
371
|
percentage: formattedPercentage,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface RegionEndpoints {
|
|
2
|
+
[key: string]: string;
|
|
3
|
+
}
|
|
4
|
+
export interface CanonicalRegion {
|
|
5
|
+
name: string;
|
|
6
|
+
cma: string;
|
|
7
|
+
cda: string;
|
|
8
|
+
uiHost: string;
|
|
9
|
+
developerHubUrl: string;
|
|
10
|
+
launchHubUrl: string;
|
|
11
|
+
personalizeUrl: string;
|
|
12
|
+
composableStudioUrl: string;
|
|
13
|
+
csAssetsUrl?: string;
|
|
14
|
+
endpoints: RegionEndpoints;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the canonical endpoint set for a region name/alias via @contentstack/utils.
|
|
18
|
+
* Returns null when the name isn't a recognized region (e.g. a custom region name).
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveCanonicalEndpoints(name: string): RegionEndpoints | null;
|
|
21
|
+
/**
|
|
22
|
+
* Build a region object from a raw endpoints map, keeping the existing named
|
|
23
|
+
* fields (cma/cda/uiHost/...) plus a full raw `endpoints` passthrough so any
|
|
24
|
+
* future endpoint Contentstack adds is available without further code changes.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildRegionFromEndpoints(name: string, endpoints: RegionEndpoints): CanonicalRegion;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveCanonicalEndpoints = resolveCanonicalEndpoints;
|
|
4
|
+
exports.buildRegionFromEndpoints = buildRegionFromEndpoints;
|
|
5
|
+
const utils_1 = require("@contentstack/utils");
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the canonical endpoint set for a region name/alias via @contentstack/utils.
|
|
8
|
+
* Returns null when the name isn't a recognized region (e.g. a custom region name).
|
|
9
|
+
*/
|
|
10
|
+
function resolveCanonicalEndpoints(name) {
|
|
11
|
+
try {
|
|
12
|
+
const endpoints = (0, utils_1.getContentstackEndpoint)(name);
|
|
13
|
+
if (!endpoints || typeof endpoints === 'string')
|
|
14
|
+
return null;
|
|
15
|
+
return endpoints;
|
|
16
|
+
}
|
|
17
|
+
catch (_a) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Build a region object from a raw endpoints map, keeping the existing named
|
|
23
|
+
* fields (cma/cda/uiHost/...) plus a full raw `endpoints` passthrough so any
|
|
24
|
+
* future endpoint Contentstack adds is available without further code changes.
|
|
25
|
+
*/
|
|
26
|
+
function buildRegionFromEndpoints(name, endpoints) {
|
|
27
|
+
return {
|
|
28
|
+
name,
|
|
29
|
+
cma: endpoints.contentManagement,
|
|
30
|
+
cda: endpoints.contentDelivery,
|
|
31
|
+
uiHost: endpoints.application,
|
|
32
|
+
developerHubUrl: endpoints.developerHub,
|
|
33
|
+
launchHubUrl: endpoints.launch,
|
|
34
|
+
personalizeUrl: endpoints.personalizeManagement,
|
|
35
|
+
composableStudioUrl: endpoints.composableStudio,
|
|
36
|
+
csAssetsUrl: endpoints.assetManagement,
|
|
37
|
+
endpoints,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-heals the persisted region config on every CLI invocation so that
|
|
3
|
+
* customers who set their region on an older CLI version (before a field
|
|
4
|
+
* like authUrl existed) get it backfilled without re-running
|
|
5
|
+
* `csdx config:set:region`. Only named/built-in regions are touched — a
|
|
6
|
+
* custom region's name won't resolve via resolveCanonicalEndpoints, so it's
|
|
7
|
+
* left untouched. Never throws.
|
|
8
|
+
*/
|
|
9
|
+
export declare function refreshRegionEndpoints(): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.refreshRegionEndpoints = refreshRegionEndpoints;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const config_handler_1 = tslib_1.__importDefault(require("./config-handler"));
|
|
6
|
+
const region_endpoints_1 = require("./region-endpoints");
|
|
7
|
+
/**
|
|
8
|
+
* Self-heals the persisted region config on every CLI invocation so that
|
|
9
|
+
* customers who set their region on an older CLI version (before a field
|
|
10
|
+
* like authUrl existed) get it backfilled without re-running
|
|
11
|
+
* `csdx config:set:region`. Only named/built-in regions are touched — a
|
|
12
|
+
* custom region's name won't resolve via resolveCanonicalEndpoints, so it's
|
|
13
|
+
* left untouched. Never throws.
|
|
14
|
+
*/
|
|
15
|
+
function refreshRegionEndpoints() {
|
|
16
|
+
const stored = config_handler_1.default.get('region');
|
|
17
|
+
if (!(stored === null || stored === void 0 ? void 0 : stored.name))
|
|
18
|
+
return;
|
|
19
|
+
const endpoints = (0, region_endpoints_1.resolveCanonicalEndpoints)(stored.name);
|
|
20
|
+
if (!endpoints)
|
|
21
|
+
return;
|
|
22
|
+
const merged = Object.assign(Object.assign({}, stored), (0, region_endpoints_1.buildRegionFromEndpoints)(stored.name, endpoints));
|
|
23
|
+
if (JSON.stringify(merged) !== JSON.stringify(stored)) {
|
|
24
|
+
config_handler_1.default.set('region', merged);
|
|
25
|
+
}
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-utilities",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.12",
|
|
4
4
|
"description": "Utilities for contentstack projects",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -30,8 +30,9 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@contentstack/management": "~1.30.3",
|
|
32
32
|
"@contentstack/marketplace-sdk": "^1.5.2",
|
|
33
|
+
"@contentstack/utils": "~1.9.1",
|
|
33
34
|
"@oclif/core": "^4.11.4",
|
|
34
|
-
"axios": "^1.
|
|
35
|
+
"axios": "^1.18.1",
|
|
35
36
|
"chalk": "^5.6.2",
|
|
36
37
|
"cli-cursor": "^3.1.0",
|
|
37
38
|
"cli-progress": "^3.12.0",
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
"inquirer": "12.11.1",
|
|
43
44
|
"inquirer-search-checkbox": "^1.0.0",
|
|
44
45
|
"inquirer-search-list": "^1.2.6",
|
|
45
|
-
"js-yaml": "^4.
|
|
46
|
+
"js-yaml": "^4.3.0",
|
|
46
47
|
"klona": "^2.0.6",
|
|
47
48
|
"lodash": "^4.18.1",
|
|
48
49
|
"mkdirp": "^1.0.4",
|
|
@@ -83,4 +84,4 @@
|
|
|
83
84
|
"ts-node": "^10.9.2",
|
|
84
85
|
"typescript": "^5.9.3"
|
|
85
86
|
}
|
|
86
|
-
}
|
|
87
|
+
}
|