@contentful/experience-design-system-cli 2.37.1-dev-build-8757f66c.0 → 2.37.1-dev-build-7d013617.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/dist/app.d.ts +2 -1
- package/dist/app.js +419 -763
- package/dist/index.js +542 -756
- package/dist/package.json +1 -1
- package/dist/src/commands/import-options.d.ts +13 -0
- package/dist/src/commands/import.d.ts +2 -1
- package/dist/src/tui/import/shared/error-step/controls.d.ts +7 -0
- package/dist/src/tui/import/shared/error-step/error-step.d.ts +10 -0
- package/dist/src/tui/import/shared/error-step/logic.d.ts +15 -0
- package/dist/src/tui/import/shared/gate-step/controls.d.ts +8 -0
- package/dist/src/tui/import/shared/gate-step/gate-step.d.ts +14 -0
- package/dist/src/tui/import/shared/gate-step/logic.d.ts +11 -0
- package/dist/src/tui/import/shared/index.d.ts +3 -0
- package/dist/src/tui/import/shared/running-step/logic.d.ts +12 -0
- package/dist/src/tui/import/shared/running-step/running-step.d.ts +11 -0
- package/dist/src/tui/import/shared/running-step/theme.d.ts +3 -0
- package/dist/src/tui/import/shared/running-step/use-elapsed.d.ts +1 -0
- package/dist/src/tui/import/spawn-v1-import.d.ts +6 -1
- package/dist/src/tui/import/steps/04-credentials/logic.d.ts +3 -0
- package/dist/src/tui/import/steps/04-credentials/validate.d.ts +1 -1
- package/dist/src/tui/import/steps/05-token-reuse/logic.d.ts +22 -0
- package/dist/src/tui/import/steps/05-token-reuse/screen.d.ts +10 -0
- package/dist/src/tui/import/steps/index.d.ts +1 -0
- package/legacy/dist/src/index.js +26 -79
- package/legacy/package.json +1 -1
- package/package.json +3 -3
package/dist/app.js
CHANGED
|
@@ -880,7 +880,8 @@ var init_cache_keys = __esm({
|
|
|
880
880
|
});
|
|
881
881
|
|
|
882
882
|
// packages/experience-design-system-cli/app.tsx
|
|
883
|
-
import {
|
|
883
|
+
import { join as join7 } from "node:path";
|
|
884
|
+
import { useEffect as useEffect10, useState as useState14 } from "react";
|
|
884
885
|
|
|
885
886
|
// packages/experience-design-system-cli/src/tui/home/home.tsx
|
|
886
887
|
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
@@ -1803,15 +1804,15 @@ function walkProjectTree(dir, result, includeContent) {
|
|
|
1803
1804
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/helpers/collect-files/collect-files.js
|
|
1804
1805
|
function collectFiles(root, options = {}) {
|
|
1805
1806
|
const resolved = path4.resolve(root);
|
|
1806
|
-
let
|
|
1807
|
+
let stat2;
|
|
1807
1808
|
try {
|
|
1808
|
-
|
|
1809
|
+
stat2 = statSync2(resolved);
|
|
1809
1810
|
} catch (err) {
|
|
1810
1811
|
return { ok: false, failure: classifyStatError(err.code), rootPath: resolved };
|
|
1811
1812
|
}
|
|
1812
|
-
if (
|
|
1813
|
+
if (stat2.isFile())
|
|
1813
1814
|
return { ok: false, failure: "is-file", rootPath: resolved };
|
|
1814
|
-
if (!
|
|
1815
|
+
if (!stat2.isDirectory())
|
|
1815
1816
|
return { ok: false, failure: "not-directory", rootPath: resolved };
|
|
1816
1817
|
const result = {
|
|
1817
1818
|
filePaths: [],
|
|
@@ -1835,9 +1836,6 @@ import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
|
1835
1836
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/repositories/migration.js
|
|
1836
1837
|
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
1837
1838
|
|
|
1838
|
-
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/credentials/helpers/host-utils.js
|
|
1839
|
-
var DEFAULT_CONFIGURED_HOST = "api.contentful.com";
|
|
1840
|
-
|
|
1841
1839
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/index.js
|
|
1842
1840
|
init_cache_keys();
|
|
1843
1841
|
|
|
@@ -2175,9 +2173,9 @@ var mergeConfigs = (a, b) => {
|
|
|
2175
2173
|
config.headers = mergeHeaders(a.headers, b.headers);
|
|
2176
2174
|
return config;
|
|
2177
2175
|
};
|
|
2178
|
-
var mergeHeaders = (...
|
|
2176
|
+
var mergeHeaders = (...headers2) => {
|
|
2179
2177
|
const mergedHeaders = new Headers();
|
|
2180
|
-
for (const header of
|
|
2178
|
+
for (const header of headers2) {
|
|
2181
2179
|
if (!header || typeof header !== "object") {
|
|
2182
2180
|
continue;
|
|
2183
2181
|
}
|
|
@@ -2396,587 +2394,9 @@ var createClient = (config = {}) => {
|
|
|
2396
2394
|
// packages/experience-design-system-client/dist/src/generated/client.gen.js
|
|
2397
2395
|
var client = createClient(createConfig());
|
|
2398
2396
|
|
|
2399
|
-
// packages/experience-design-system-client/dist/src/generated/sdk.gen.js
|
|
2400
|
-
var designSystemImportSourcelessPreview = (options) => {
|
|
2401
|
-
return (options.client ?? client).post({
|
|
2402
|
-
url: "/spaces/{spaceId}/environments/{environmentId}/design_systems/imports/preview",
|
|
2403
|
-
...options,
|
|
2404
|
-
headers: {
|
|
2405
|
-
"Content-Type": "application/json",
|
|
2406
|
-
...options.headers
|
|
2407
|
-
}
|
|
2408
|
-
});
|
|
2409
|
-
};
|
|
2410
|
-
var designSystemImportApply = (options) => {
|
|
2411
|
-
return (options.client ?? client).post({
|
|
2412
|
-
url: "/spaces/{spaceId}/environments/{environmentId}/design_systems/imports/apply",
|
|
2413
|
-
...options,
|
|
2414
|
-
headers: {
|
|
2415
|
-
"Content-Type": "application/json",
|
|
2416
|
-
...options.headers
|
|
2417
|
-
}
|
|
2418
|
-
});
|
|
2419
|
-
};
|
|
2420
|
-
var designSystemImportGetOperation = (options) => {
|
|
2421
|
-
return (options.client ?? client).get({
|
|
2422
|
-
url: "/spaces/{spaceId}/environments/{environmentId}/design_systems/imports/apply/{operationId}",
|
|
2423
|
-
...options
|
|
2424
|
-
});
|
|
2425
|
-
};
|
|
2426
|
-
|
|
2427
|
-
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/constants/api.js
|
|
2428
|
-
var PREVIEW_ERROR_PREFIX = "preview failed:";
|
|
2429
|
-
var APPLY_ERROR_PREFIX = "apply failed:";
|
|
2430
|
-
var USER_AGENT = "experience-design-system-backend-pipeline";
|
|
2431
|
-
|
|
2432
|
-
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/http-utils.js
|
|
2433
|
-
var MAX_RETRY_AFTER_MS = 6e4;
|
|
2434
|
-
function isTransientStatus(status) {
|
|
2435
|
-
return status >= 500 && status <= 599;
|
|
2436
|
-
}
|
|
2437
|
-
function retryAfterMs(response) {
|
|
2438
|
-
const value = response.headers?.get("retry-after")?.trim();
|
|
2439
|
-
if (!value)
|
|
2440
|
-
return void 0;
|
|
2441
|
-
const seconds = Number(value);
|
|
2442
|
-
const delayMs = Number.isFinite(seconds) ? seconds * 1e3 : Date.parse(value) - Date.now();
|
|
2443
|
-
if (!Number.isFinite(delayMs) || delayMs < 0 || delayMs > MAX_RETRY_AFTER_MS)
|
|
2444
|
-
return void 0;
|
|
2445
|
-
return Math.round(delayMs);
|
|
2446
|
-
}
|
|
2447
|
-
function isApsDenialBody(body) {
|
|
2448
|
-
if (!body)
|
|
2449
|
-
return false;
|
|
2450
|
-
try {
|
|
2451
|
-
const parsed = JSON.parse(body);
|
|
2452
|
-
const id = parsed?.sys?.id;
|
|
2453
|
-
return id === "NotFound" || id === "AccessDenied";
|
|
2454
|
-
} catch {
|
|
2455
|
-
return false;
|
|
2456
|
-
}
|
|
2457
|
-
}
|
|
2458
|
-
function stringifyError(error) {
|
|
2459
|
-
return typeof error === "string" ? error : JSON.stringify(error ?? {});
|
|
2460
|
-
}
|
|
2461
|
-
function errorMessage(error) {
|
|
2462
|
-
return error instanceof Error && error.message ? error.message : String(error);
|
|
2463
|
-
}
|
|
2464
|
-
function defaultSleep(delayMs) {
|
|
2465
|
-
return new Promise((resolve2) => setTimeout(resolve2, delayMs));
|
|
2466
|
-
}
|
|
2467
|
-
|
|
2468
|
-
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/sanitize-preview.js
|
|
2469
|
-
var PROPERTY_BREAKING_REASONS = /* @__PURE__ */ new Set([
|
|
2470
|
-
"removed",
|
|
2471
|
-
"added_required_no_default",
|
|
2472
|
-
"type_changed",
|
|
2473
|
-
"validation_narrowed"
|
|
2474
|
-
]);
|
|
2475
|
-
var SLOT_BREAKING_REASONS = /* @__PURE__ */ new Set(["slot_removed", "slot_allowed_components_narrowed"]);
|
|
2476
|
-
function sanitizeBreakingChanges(raw) {
|
|
2477
|
-
if (!Array.isArray(raw))
|
|
2478
|
-
return [];
|
|
2479
|
-
const out = [];
|
|
2480
|
-
for (const bc of raw) {
|
|
2481
|
-
if (typeof bc !== "object" || bc === null)
|
|
2482
|
-
continue;
|
|
2483
|
-
const reason = bc.reason;
|
|
2484
|
-
if (typeof reason !== "string")
|
|
2485
|
-
continue;
|
|
2486
|
-
if ("propertyId" in bc && typeof bc.propertyId === "string") {
|
|
2487
|
-
if (PROPERTY_BREAKING_REASONS.has(reason))
|
|
2488
|
-
out.push(bc);
|
|
2489
|
-
continue;
|
|
2490
|
-
}
|
|
2491
|
-
if ("slotId" in bc && typeof bc.slotId === "string") {
|
|
2492
|
-
if (SLOT_BREAKING_REASONS.has(reason))
|
|
2493
|
-
out.push(bc);
|
|
2494
|
-
continue;
|
|
2495
|
-
}
|
|
2496
|
-
}
|
|
2497
|
-
return out;
|
|
2498
|
-
}
|
|
2499
|
-
function sanitizePreviewResponse(res) {
|
|
2500
|
-
for (const item of res.components?.changed ?? []) {
|
|
2501
|
-
const cc = item.changeClassification;
|
|
2502
|
-
if (cc && Array.isArray(cc.breakingChanges)) {
|
|
2503
|
-
cc.breakingChanges = sanitizeBreakingChanges(cc.breakingChanges);
|
|
2504
|
-
}
|
|
2505
|
-
}
|
|
2506
|
-
return res;
|
|
2507
|
-
}
|
|
2508
|
-
|
|
2509
|
-
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/host-utils.js
|
|
2510
|
-
var DEFAULT_API_HOST = "https://api.contentful.com";
|
|
2511
|
-
function trimTrailingSlashes(value) {
|
|
2512
|
-
return value.replace(/\/+$/, "");
|
|
2513
|
-
}
|
|
2514
|
-
function normalizeHostInput(host) {
|
|
2515
|
-
const value = host?.trim();
|
|
2516
|
-
if (!value)
|
|
2517
|
-
return void 0;
|
|
2518
|
-
return trimTrailingSlashes(value);
|
|
2519
|
-
}
|
|
2520
|
-
function toConfiguredHost2(host) {
|
|
2521
|
-
const normalized = normalizeHostInput(host);
|
|
2522
|
-
if (!normalized)
|
|
2523
|
-
return void 0;
|
|
2524
|
-
return normalized.replace(/^https:\/\//i, "");
|
|
2525
|
-
}
|
|
2526
|
-
function toApiHost2(host) {
|
|
2527
|
-
const normalized = normalizeHostInput(host);
|
|
2528
|
-
if (!normalized)
|
|
2529
|
-
return DEFAULT_API_HOST;
|
|
2530
|
-
if (/^[a-z][a-z\d+\-.]*:\/\//i.test(normalized))
|
|
2531
|
-
return normalized;
|
|
2532
|
-
return `https://${normalized}`;
|
|
2533
|
-
}
|
|
2534
|
-
|
|
2535
|
-
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/types/api-error.js
|
|
2536
|
-
var ERROR_BODY_LOG_CAP = 16384;
|
|
2537
|
-
var ApiError = class extends Error {
|
|
2538
|
-
status;
|
|
2539
|
-
body;
|
|
2540
|
-
guidance;
|
|
2541
|
-
constructor(message, status, body, guidance) {
|
|
2542
|
-
super(message);
|
|
2543
|
-
this.status = status;
|
|
2544
|
-
this.body = body;
|
|
2545
|
-
this.guidance = guidance;
|
|
2546
|
-
if (body) {
|
|
2547
|
-
const trimmed = body.length > ERROR_BODY_LOG_CAP ? body.slice(0, ERROR_BODY_LOG_CAP) + "\u2026" : body;
|
|
2548
|
-
this.message = `${message}
|
|
2549
|
-
${trimmed}`;
|
|
2550
|
-
}
|
|
2551
|
-
}
|
|
2552
|
-
};
|
|
2553
|
-
|
|
2554
|
-
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/api-client/api-client.js
|
|
2555
|
-
var ApiClient = class {
|
|
2556
|
-
host;
|
|
2557
|
-
token;
|
|
2558
|
-
spaceId;
|
|
2559
|
-
environmentId;
|
|
2560
|
-
retry;
|
|
2561
|
-
lastRequestId;
|
|
2562
|
-
constructor(opts) {
|
|
2563
|
-
this.host = toApiHost2(opts.host);
|
|
2564
|
-
this.token = opts.cmaToken;
|
|
2565
|
-
this.spaceId = opts.spaceId;
|
|
2566
|
-
this.environmentId = opts.environmentId;
|
|
2567
|
-
const initialDelayMs = Math.max(0, opts.retry?.initialDelayMs ?? 250);
|
|
2568
|
-
this.retry = {
|
|
2569
|
-
maxAttempts: Math.max(1, Math.floor(opts.retry?.maxAttempts ?? 3)),
|
|
2570
|
-
initialDelayMs,
|
|
2571
|
-
maxDelayMs: Math.max(initialDelayMs, opts.retry?.maxDelayMs ?? 2e3),
|
|
2572
|
-
sleep: opts.retry?.sleep ?? defaultSleep
|
|
2573
|
-
};
|
|
2574
|
-
}
|
|
2575
|
-
getLastRequestId() {
|
|
2576
|
-
return this.lastRequestId;
|
|
2577
|
-
}
|
|
2578
|
-
noteRequestId(response) {
|
|
2579
|
-
const id = response.headers.get("x-contentful-request-id");
|
|
2580
|
-
if (id)
|
|
2581
|
-
this.lastRequestId = id;
|
|
2582
|
-
}
|
|
2583
|
-
headers() {
|
|
2584
|
-
return {
|
|
2585
|
-
Authorization: `Bearer ${this.token}`,
|
|
2586
|
-
"Content-Type": "application/json",
|
|
2587
|
-
"X-Contentful-User-Agent": USER_AGENT
|
|
2588
|
-
};
|
|
2589
|
-
}
|
|
2590
|
-
async requestWithRetry(phase, errorPrefix, makeCall) {
|
|
2591
|
-
for (let attempt = 1; attempt <= this.retry.maxAttempts; attempt++) {
|
|
2592
|
-
let result;
|
|
2593
|
-
try {
|
|
2594
|
-
result = await makeCall();
|
|
2595
|
-
} catch (error) {
|
|
2596
|
-
if (attempt === this.retry.maxAttempts) {
|
|
2597
|
-
const body = `The request failed after ${attempt} attempts because of a network error: ${errorMessage(error)}. Check your connection and try again.`;
|
|
2598
|
-
throw new ApiError(`${errorPrefix} 0`, 0, body);
|
|
2599
|
-
}
|
|
2600
|
-
await this.retry.sleep(Math.min(this.retry.initialDelayMs * 2 ** (attempt - 1), this.retry.maxDelayMs));
|
|
2601
|
-
continue;
|
|
2602
|
-
}
|
|
2603
|
-
if (!isTransientStatus(result.response.status)) {
|
|
2604
|
-
this.noteRequestId(result.response);
|
|
2605
|
-
return result;
|
|
2606
|
-
}
|
|
2607
|
-
if (attempt === this.retry.maxAttempts) {
|
|
2608
|
-
const body = stringifyError(result.error);
|
|
2609
|
-
const guidance = `The ${phase} request failed after ${attempt} attempts because the service remained unavailable. Wait a moment and try again.`;
|
|
2610
|
-
throw new ApiError(`${errorPrefix} ${result.response.status}`, result.response.status, body, guidance);
|
|
2611
|
-
}
|
|
2612
|
-
const backoffMs = Math.min(this.retry.initialDelayMs * 2 ** (attempt - 1), this.retry.maxDelayMs);
|
|
2613
|
-
await this.retry.sleep(retryAfterMs(result.response) ?? backoffMs);
|
|
2614
|
-
}
|
|
2615
|
-
throw new Error("Retry attempts exhausted");
|
|
2616
|
-
}
|
|
2617
|
-
async validateToken() {
|
|
2618
|
-
const res = await fetch(`${this.host}/users/me`, { headers: this.headers() });
|
|
2619
|
-
this.noteRequestId(res);
|
|
2620
|
-
if (res.status === 401) {
|
|
2621
|
-
throw new ApiError("CMA token is invalid or revoked", res.status, await res.text());
|
|
2622
|
-
}
|
|
2623
|
-
if (!res.ok) {
|
|
2624
|
-
throw new ApiError(`unexpected error validating token: ${res.status}`, res.status, await res.text());
|
|
2625
|
-
}
|
|
2626
|
-
await this.checkPreflight();
|
|
2627
|
-
}
|
|
2628
|
-
async checkPreflight() {
|
|
2629
|
-
const url = `${this.host}/spaces/${this.spaceId}/environments/${this.environmentId}/design_systems/preflight`;
|
|
2630
|
-
let res;
|
|
2631
|
-
try {
|
|
2632
|
-
res = await fetch(url, { headers: this.headers() });
|
|
2633
|
-
} catch {
|
|
2634
|
-
return;
|
|
2635
|
-
}
|
|
2636
|
-
this.noteRequestId(res);
|
|
2637
|
-
if (res.ok)
|
|
2638
|
-
return;
|
|
2639
|
-
if (res.status >= 500)
|
|
2640
|
-
return;
|
|
2641
|
-
const body = await res.text();
|
|
2642
|
-
if (res.status === 404 && !isApsDenialBody(body))
|
|
2643
|
-
return;
|
|
2644
|
-
throw new ApiError(`preflight failed: ${res.status}`, res.status, body);
|
|
2645
|
-
}
|
|
2646
|
-
async previewImport(cdf) {
|
|
2647
|
-
const result = await this.requestWithRetry("preview", PREVIEW_ERROR_PREFIX, () => designSystemImportSourcelessPreview({
|
|
2648
|
-
baseUrl: this.host,
|
|
2649
|
-
headers: this.headers(),
|
|
2650
|
-
path: { spaceId: this.spaceId, environmentId: this.environmentId },
|
|
2651
|
-
body: cdf,
|
|
2652
|
-
parseAs: "json"
|
|
2653
|
-
}));
|
|
2654
|
-
if (!result.response.ok) {
|
|
2655
|
-
throw new ApiError(`${PREVIEW_ERROR_PREFIX} ${result.response.status}`, result.response.status, stringifyError(result.error));
|
|
2656
|
-
}
|
|
2657
|
-
return sanitizePreviewResponse(result.data);
|
|
2658
|
-
}
|
|
2659
|
-
async applyImport(cdf, opts) {
|
|
2660
|
-
let result;
|
|
2661
|
-
try {
|
|
2662
|
-
result = await designSystemImportApply({
|
|
2663
|
-
baseUrl: this.host,
|
|
2664
|
-
headers: this.headers(),
|
|
2665
|
-
path: { spaceId: this.spaceId, environmentId: this.environmentId },
|
|
2666
|
-
body: { ...cdf, acknowledgeBreakingChanges: opts.acknowledgeBreakingChanges },
|
|
2667
|
-
parseAs: "json"
|
|
2668
|
-
});
|
|
2669
|
-
} catch (error) {
|
|
2670
|
-
const body = `The apply request was not retried because its outcome is unknown and retrying could start a duplicate operation. Cause: ${errorMessage(error)}`;
|
|
2671
|
-
throw new ApiError(`${APPLY_ERROR_PREFIX} 0`, 0, body);
|
|
2672
|
-
}
|
|
2673
|
-
if (!result.response.ok) {
|
|
2674
|
-
const body = stringifyError(result.error);
|
|
2675
|
-
const guidance = isTransientStatus(result.response.status) ? "The apply request was not retried because the server may already have started an operation and retrying could create a duplicate." : void 0;
|
|
2676
|
-
throw new ApiError(`${APPLY_ERROR_PREFIX} ${result.response.status}`, result.response.status, body, guidance);
|
|
2677
|
-
}
|
|
2678
|
-
this.noteRequestId(result.response);
|
|
2679
|
-
return result.data;
|
|
2680
|
-
}
|
|
2681
|
-
async pollOperation(operationId, opts = {}) {
|
|
2682
|
-
const intervalMs = opts.intervalMs ?? 2e3;
|
|
2683
|
-
const maxIntervalMs = opts.maxIntervalMs ?? Math.round(intervalMs * 2.5);
|
|
2684
|
-
const maxAttempts = opts.maxAttempts ?? 150;
|
|
2685
|
-
const terminalStatuses = /* @__PURE__ */ new Set(["succeeded", "partial", "failed"]);
|
|
2686
|
-
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
2687
|
-
const result = await this.requestWithRetry("poll", "poll failed:", () => designSystemImportGetOperation({
|
|
2688
|
-
baseUrl: this.host,
|
|
2689
|
-
headers: this.headers(),
|
|
2690
|
-
path: { spaceId: this.spaceId, environmentId: this.environmentId, operationId },
|
|
2691
|
-
parseAs: "json"
|
|
2692
|
-
}));
|
|
2693
|
-
if (!result.response.ok) {
|
|
2694
|
-
throw new ApiError(`poll failed: ${result.response.status}`, result.response.status, stringifyError(result.error));
|
|
2695
|
-
}
|
|
2696
|
-
const op = result.data;
|
|
2697
|
-
opts.onProgress?.(op);
|
|
2698
|
-
if (terminalStatuses.has(op.sys.status))
|
|
2699
|
-
return op;
|
|
2700
|
-
if (attempt < maxAttempts - 1) {
|
|
2701
|
-
const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
|
|
2702
|
-
const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
|
|
2703
|
-
const jitter = Math.random() * baseDelay * 0.15;
|
|
2704
|
-
await new Promise((resolve2) => setTimeout(resolve2, baseDelay + jitter));
|
|
2705
|
-
}
|
|
2706
|
-
}
|
|
2707
|
-
throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
|
|
2708
|
-
}
|
|
2709
|
-
};
|
|
2710
|
-
|
|
2711
2397
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/controller/validation/assert-no-unresolved-slot-references.js
|
|
2712
2398
|
init_shared();
|
|
2713
2399
|
|
|
2714
|
-
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/edsi-errors/parse-binding-diagnostics.js
|
|
2715
|
-
function parseBindingDiagnostics(body) {
|
|
2716
|
-
if (!/binding configurations are invalid|Pointer path does not exist/i.test(body))
|
|
2717
|
-
return null;
|
|
2718
|
-
const locationMatches = [...body.matchAll(/(?:^|\.\s)([A-Za-z0-9_$-]+(?:\s*›\s*[A-Za-z0-9_$-]+){2,})/g)];
|
|
2719
|
-
const location = locationMatches.at(-1)?.[1];
|
|
2720
|
-
const pointerMessage = body.match(/Pointer path does not exist for '\[object Object\]':\s*(.+?)(?=\.\s*Default\s*›|$)/i)?.[1];
|
|
2721
|
-
const graphQlMessage = body.match(/return GraphQL validation error:\s*(.+?)(?=\.\s*Default\s*›|$)/i)?.[1];
|
|
2722
|
-
const heading = body.match(/^(.*?)(?=\.?\s*Pointer path does not exist|\.?\s*Default\s*›)/i)?.[1]?.trim();
|
|
2723
|
-
const diagnostics = [];
|
|
2724
|
-
if (pointerMessage)
|
|
2725
|
-
diagnostics.push({ message: pointerMessage.trim(), ...location ? { path: location } : {} });
|
|
2726
|
-
if (graphQlMessage)
|
|
2727
|
-
diagnostics.push({ message: graphQlMessage.trim(), ...location ? { path: location } : {} });
|
|
2728
|
-
return {
|
|
2729
|
-
code: "BindingValidationFailed",
|
|
2730
|
-
message: heading || "One or more binding configurations are invalid.",
|
|
2731
|
-
...diagnostics.length > 0 ? { diagnostics } : {}
|
|
2732
|
-
};
|
|
2733
|
-
}
|
|
2734
|
-
|
|
2735
|
-
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/edsi-errors/helpers.js
|
|
2736
|
-
function asRecord(value) {
|
|
2737
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
2738
|
-
}
|
|
2739
|
-
function displayValue(value) {
|
|
2740
|
-
if (typeof value === "string")
|
|
2741
|
-
return value;
|
|
2742
|
-
if (typeof value === "number" || typeof value === "boolean")
|
|
2743
|
-
return String(value);
|
|
2744
|
-
if (value === null || value === void 0)
|
|
2745
|
-
return null;
|
|
2746
|
-
try {
|
|
2747
|
-
return JSON.stringify(value);
|
|
2748
|
-
} catch {
|
|
2749
|
-
return null;
|
|
2750
|
-
}
|
|
2751
|
-
}
|
|
2752
|
-
function isPathSegment(value) {
|
|
2753
|
-
return typeof value === "string" || typeof value === "number" && Number.isFinite(value);
|
|
2754
|
-
}
|
|
2755
|
-
function formatPath(value) {
|
|
2756
|
-
if (isPathSegment(value))
|
|
2757
|
-
return String(value) ? { path: String(value) } : { path: null };
|
|
2758
|
-
if (Array.isArray(value)) {
|
|
2759
|
-
const parts = value.filter(isPathSegment);
|
|
2760
|
-
return parts.length > 0 ? { path: parts.join(" \u203A ") } : { path: null };
|
|
2761
|
-
}
|
|
2762
|
-
return {};
|
|
2763
|
-
}
|
|
2764
|
-
function componentFromPath(path5) {
|
|
2765
|
-
if (!path5)
|
|
2766
|
-
return void 0;
|
|
2767
|
-
const manifestMatch = path5.match(/manifest:components\/([^/›]+)/);
|
|
2768
|
-
if (manifestMatch?.[1])
|
|
2769
|
-
return manifestMatch[1];
|
|
2770
|
-
const parts = path5.split(/[›/]/).map((part) => part.trim()).filter(Boolean);
|
|
2771
|
-
const componentsIndex = parts.findIndex((part) => part === "components");
|
|
2772
|
-
return componentsIndex === -1 ? void 0 : parts[componentsIndex + 1];
|
|
2773
|
-
}
|
|
2774
|
-
function diagnosticMessage(error) {
|
|
2775
|
-
const candidates = [
|
|
2776
|
-
["message", error.message],
|
|
2777
|
-
["details", error.details],
|
|
2778
|
-
["error", error.error],
|
|
2779
|
-
["name", error.name]
|
|
2780
|
-
];
|
|
2781
|
-
for (const [messageSource, value] of candidates) {
|
|
2782
|
-
const message = displayValue(value);
|
|
2783
|
-
if (message !== null)
|
|
2784
|
-
return { message, messageSource };
|
|
2785
|
-
}
|
|
2786
|
-
return { message: "Validation failed" };
|
|
2787
|
-
}
|
|
2788
|
-
function parseObjectLiteralTail(body) {
|
|
2789
|
-
const braceStart = body.lastIndexOf("{");
|
|
2790
|
-
if (braceStart === -1)
|
|
2791
|
-
return null;
|
|
2792
|
-
const tail = body.slice(braceStart);
|
|
2793
|
-
const codeMatch = tail.match(/code:\s*['"]([^'"]+)['"]/);
|
|
2794
|
-
const cycleMatch = tail.match(/cycle:\s*\[\s*([^\]]*)\s*\]/);
|
|
2795
|
-
if (!codeMatch && !cycleMatch)
|
|
2796
|
-
return null;
|
|
2797
|
-
const code = codeMatch ? codeMatch[1] : null;
|
|
2798
|
-
let cycle = null;
|
|
2799
|
-
if (cycleMatch) {
|
|
2800
|
-
cycle = cycleMatch[1].split(",").map((s) => s.trim().replace(/^['"]|['"]$/g, "")).filter((s) => s.length > 0);
|
|
2801
|
-
if (cycle.length === 0)
|
|
2802
|
-
cycle = null;
|
|
2803
|
-
}
|
|
2804
|
-
return { code, cycle };
|
|
2805
|
-
}
|
|
2806
|
-
|
|
2807
|
-
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/edsi-errors/parse-json-body.js
|
|
2808
|
-
function parseValidationDiagnostics(details) {
|
|
2809
|
-
if (!Array.isArray(details.errors))
|
|
2810
|
-
return [];
|
|
2811
|
-
const diagnostics = [];
|
|
2812
|
-
for (const rawError of details.errors) {
|
|
2813
|
-
const error = asRecord(rawError);
|
|
2814
|
-
if (!error)
|
|
2815
|
-
continue;
|
|
2816
|
-
const location = formatPath(error.path);
|
|
2817
|
-
const component = displayValue(error.component ?? error.componentName ?? error.componentId) ?? componentFromPath(location.path);
|
|
2818
|
-
diagnostics.push({ ...diagnosticMessage(error), ...location, ...component ? { component } : {} });
|
|
2819
|
-
}
|
|
2820
|
-
return diagnostics;
|
|
2821
|
-
}
|
|
2822
|
-
function parseJsonBody(body) {
|
|
2823
|
-
let parsed;
|
|
2824
|
-
try {
|
|
2825
|
-
parsed = JSON.parse(body);
|
|
2826
|
-
} catch {
|
|
2827
|
-
return null;
|
|
2828
|
-
}
|
|
2829
|
-
const p = asRecord(parsed);
|
|
2830
|
-
if (!p)
|
|
2831
|
-
return null;
|
|
2832
|
-
const details = asRecord(p.details) ?? {};
|
|
2833
|
-
const pick = (k) => p[k] !== void 0 ? p[k] : details[k];
|
|
2834
|
-
const codeRaw = pick("code") ?? asRecord(p.sys)?.id;
|
|
2835
|
-
const messageRaw = pick("message");
|
|
2836
|
-
const cycleRaw = pick("cycle");
|
|
2837
|
-
const out = {};
|
|
2838
|
-
if (typeof codeRaw === "string")
|
|
2839
|
-
out.code = codeRaw;
|
|
2840
|
-
if (typeof messageRaw === "string")
|
|
2841
|
-
out.message = messageRaw;
|
|
2842
|
-
if (Array.isArray(cycleRaw)) {
|
|
2843
|
-
const strs = cycleRaw.filter((x) => typeof x === "string");
|
|
2844
|
-
if (strs.length > 0)
|
|
2845
|
-
out.cycle = strs;
|
|
2846
|
-
}
|
|
2847
|
-
const diagnostics = parseValidationDiagnostics(details);
|
|
2848
|
-
if (diagnostics.length > 0)
|
|
2849
|
-
out.diagnostics = diagnostics;
|
|
2850
|
-
return out;
|
|
2851
|
-
}
|
|
2852
|
-
|
|
2853
|
-
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/edsi-errors/strip-lambda-log-prefix.js
|
|
2854
|
-
var LAMBDA_LOG_PREFIX_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z\s+[0-9a-f-]+\s+ERROR\s+(?:\[dd\.[^\]]*\]\s*)?/;
|
|
2855
|
-
var DD_TAG_RE = /\[dd\.(?:trace_id|span_id)=[^\]]*\]\s*/g;
|
|
2856
|
-
function stripLambdaLogPrefix(body) {
|
|
2857
|
-
return body.replace(LAMBDA_LOG_PREFIX_RE, "").replace(DD_TAG_RE, "").trim();
|
|
2858
|
-
}
|
|
2859
|
-
|
|
2860
|
-
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/edsi-errors/parse-edsi-error.js
|
|
2861
|
-
var API_ERROR_PREFIX_RE = /^(?:apply|preview|poll) failed: \d+$/;
|
|
2862
|
-
function parseEdsiError(rawInput) {
|
|
2863
|
-
if (!rawInput)
|
|
2864
|
-
return { code: null, message: "", cycle: null, raw: true };
|
|
2865
|
-
const { body, prefix } = splitPhasePrefix(rawInput);
|
|
2866
|
-
const cleaned = stripLambdaLogPrefix(body);
|
|
2867
|
-
const json = parseJsonBody(cleaned) ?? parseJsonBody(body);
|
|
2868
|
-
const bindingFromJson = typeof json?.message === "string" ? parseBindingDiagnostics(json.message) : null;
|
|
2869
|
-
if (bindingFromJson) {
|
|
2870
|
-
return {
|
|
2871
|
-
code: bindingFromJson.code ?? json?.code ?? null,
|
|
2872
|
-
message: bindingFromJson.message ?? cleaned,
|
|
2873
|
-
cycle: null,
|
|
2874
|
-
raw: false,
|
|
2875
|
-
...bindingFromJson.diagnostics ? { diagnostics: bindingFromJson.diagnostics } : {}
|
|
2876
|
-
};
|
|
2877
|
-
}
|
|
2878
|
-
if (json && (json.code || json.message || json.cycle)) {
|
|
2879
|
-
return {
|
|
2880
|
-
code: json.code ?? null,
|
|
2881
|
-
message: json.message ?? (cleaned || prefix),
|
|
2882
|
-
cycle: json.cycle ?? null,
|
|
2883
|
-
raw: false,
|
|
2884
|
-
...json.diagnostics ? { diagnostics: json.diagnostics } : {}
|
|
2885
|
-
};
|
|
2886
|
-
}
|
|
2887
|
-
const binding = parseBindingDiagnostics(cleaned);
|
|
2888
|
-
if (binding) {
|
|
2889
|
-
return {
|
|
2890
|
-
code: binding.code ?? null,
|
|
2891
|
-
message: binding.message ?? cleaned,
|
|
2892
|
-
cycle: null,
|
|
2893
|
-
raw: false,
|
|
2894
|
-
...binding.diagnostics ? { diagnostics: binding.diagnostics } : {}
|
|
2895
|
-
};
|
|
2896
|
-
}
|
|
2897
|
-
const literal2 = parseObjectLiteralTail(cleaned);
|
|
2898
|
-
if (literal2 && (literal2.code || literal2.cycle)) {
|
|
2899
|
-
const braceStart = cleaned.lastIndexOf("{");
|
|
2900
|
-
const head = braceStart === -1 ? cleaned : cleaned.slice(0, braceStart).trim();
|
|
2901
|
-
return { code: literal2.code ?? null, message: head || cleaned, cycle: literal2.cycle ?? null, raw: false };
|
|
2902
|
-
}
|
|
2903
|
-
return { code: null, message: cleaned || prefix || rawInput, cycle: null, raw: true };
|
|
2904
|
-
}
|
|
2905
|
-
function splitPhasePrefix(input) {
|
|
2906
|
-
const nlIndex = input.indexOf("\n");
|
|
2907
|
-
if (nlIndex === -1)
|
|
2908
|
-
return { body: input, prefix: "" };
|
|
2909
|
-
const firstLine = input.slice(0, nlIndex);
|
|
2910
|
-
if (!API_ERROR_PREFIX_RE.test(firstLine))
|
|
2911
|
-
return { body: input, prefix: "" };
|
|
2912
|
-
return { body: input.slice(nlIndex + 1), prefix: firstLine };
|
|
2913
|
-
}
|
|
2914
|
-
|
|
2915
|
-
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/edsi-errors/format-parsed-edsi-error.js
|
|
2916
|
-
function formatParsedEdsiError(parsed, opts = {}) {
|
|
2917
|
-
const lines = [];
|
|
2918
|
-
if (parsed.code)
|
|
2919
|
-
lines.push(`[${parsed.code}]`);
|
|
2920
|
-
if (parsed.message)
|
|
2921
|
-
lines.push(parsed.message);
|
|
2922
|
-
for (const diagnostic of parsed.diagnostics ?? []) {
|
|
2923
|
-
const context = [
|
|
2924
|
-
diagnostic.component ? `Component: ${diagnostic.component}` : null,
|
|
2925
|
-
diagnostic.path ? `Path: ${diagnostic.path}` : null
|
|
2926
|
-
].filter(Boolean);
|
|
2927
|
-
lines.push(`- ${diagnostic.message}${context.length > 0 ? ` (${context.join("; ")})` : ""}`);
|
|
2928
|
-
if (diagnostic.path === null) {
|
|
2929
|
-
lines.push(" Location: not provided by the server. Review the submitted CDF file; no component or field was identified.");
|
|
2930
|
-
}
|
|
2931
|
-
if (opts.verbose && diagnostic.messageSource) {
|
|
2932
|
-
lines.push(` Message field: ${diagnostic.messageSource}`);
|
|
2933
|
-
}
|
|
2934
|
-
}
|
|
2935
|
-
if (parsed.code === "BindingValidationFailed") {
|
|
2936
|
-
const location = parsed.diagnostics?.find((d) => d.path)?.path;
|
|
2937
|
-
lines.push(location ? `Next action: review the binding at ${location} and correct its pointer or GraphQL selection.` : "Next action: review the binding pointer and GraphQL selection.");
|
|
2938
|
-
}
|
|
2939
|
-
if (parsed.code === "AccessDenied") {
|
|
2940
|
-
lines.push("Next action: this operation requires DesignToken and Component permissions in this environment. Ask a Contentful admin to grant both on your role.");
|
|
2941
|
-
}
|
|
2942
|
-
if (parsed.code === "NotFound") {
|
|
2943
|
-
lines.push("Next action: verify the resource id is correct. If it should exist, your role may lack read permission on DesignToken or Component.");
|
|
2944
|
-
}
|
|
2945
|
-
if (parsed.cycle && parsed.cycle.length > 0) {
|
|
2946
|
-
lines.push(`Cycle: ${parsed.cycle.join(" \u2192 ")} \u2192 ${parsed.cycle[0]}`);
|
|
2947
|
-
lines.push("Break the cycle by removing at least one $allowedComponents entry.");
|
|
2948
|
-
}
|
|
2949
|
-
if (opts.verbose && opts.raw) {
|
|
2950
|
-
lines.push("");
|
|
2951
|
-
lines.push("--- raw ---");
|
|
2952
|
-
lines.push(opts.raw);
|
|
2953
|
-
}
|
|
2954
|
-
return lines.filter(Boolean).join("\n");
|
|
2955
|
-
}
|
|
2956
|
-
|
|
2957
|
-
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/edsi-errors/format-edsi-error.js
|
|
2958
|
-
function formatEdsiError(raw, opts = {}) {
|
|
2959
|
-
const input = typeof raw === "string" ? raw : displayValue(raw);
|
|
2960
|
-
if (!input)
|
|
2961
|
-
return "";
|
|
2962
|
-
return formatParsedEdsiError(parseEdsiError(input), { ...opts, raw: opts.raw ?? input });
|
|
2963
|
-
}
|
|
2964
|
-
|
|
2965
|
-
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/edsi-errors/format-api-error.js
|
|
2966
|
-
function formatApiError(error, verbose = false) {
|
|
2967
|
-
const formatted = formatEdsiError(error.body || error.message, { verbose, raw: error.body }) || error.message;
|
|
2968
|
-
const phase = error.message.split("\n", 1)[0];
|
|
2969
|
-
const withPhase = /^(?:apply|preview|poll) failed: \d+$/.test(phase) && formatted !== phase ? `${phase}
|
|
2970
|
-
${formatted}` : formatted;
|
|
2971
|
-
return error.guidance ? `${withPhase}
|
|
2972
|
-
${error.guidance}` : withPhase;
|
|
2973
|
-
}
|
|
2974
|
-
|
|
2975
|
-
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/controller/errors/format-api-error.js
|
|
2976
|
-
function formatApiError2(request) {
|
|
2977
|
-
return formatApiError(request.error, request.verbose ?? false);
|
|
2978
|
-
}
|
|
2979
|
-
|
|
2980
2400
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/tokens/read-tokens-from-path.js
|
|
2981
2401
|
init_shared();
|
|
2982
2402
|
|
|
@@ -3115,6 +2535,7 @@ import { useInput as useInput6 } from "ink";
|
|
|
3115
2535
|
|
|
3116
2536
|
// packages/experience-design-system-cli/src/tui/import/steps/04-credentials/logic.ts
|
|
3117
2537
|
var FIELDS = ["spaceId", "environmentId", "cmaToken", "host"];
|
|
2538
|
+
var DEFAULT_HOST = "api.contentful.com";
|
|
3118
2539
|
function keyAction2(input, key) {
|
|
3119
2540
|
if (key.escape) return "back";
|
|
3120
2541
|
if (key.tab) return "next-field";
|
|
@@ -3124,12 +2545,21 @@ function keyAction2(input, key) {
|
|
|
3124
2545
|
function nextField(field) {
|
|
3125
2546
|
return FIELDS[(FIELDS.indexOf(field) + 1) % FIELDS.length];
|
|
3126
2547
|
}
|
|
2548
|
+
function toConfiguredHost3(host) {
|
|
2549
|
+
const value = (host ?? "").trim().replace(/\/+$/, "");
|
|
2550
|
+
return value === "" ? DEFAULT_HOST : value.replace(/^https:\/\//i, "");
|
|
2551
|
+
}
|
|
2552
|
+
function toApiHost3(host) {
|
|
2553
|
+
const value = host.trim().replace(/\/+$/, "");
|
|
2554
|
+
if (value === "") return `https://${DEFAULT_HOST}`;
|
|
2555
|
+
return /^[a-z][a-z\d+\-.]*:\/\//i.test(value) ? value : `https://${value}`;
|
|
2556
|
+
}
|
|
3127
2557
|
function normalize(values) {
|
|
3128
2558
|
return {
|
|
3129
2559
|
spaceId: values.spaceId.trim(),
|
|
3130
2560
|
environmentId: values.environmentId.trim(),
|
|
3131
2561
|
cmaToken: values.cmaToken.trim(),
|
|
3132
|
-
host:
|
|
2562
|
+
host: toConfiguredHost3(values.host)
|
|
3133
2563
|
};
|
|
3134
2564
|
}
|
|
3135
2565
|
function missingField(values) {
|
|
@@ -3157,30 +2587,59 @@ function useCredentialsControls(handlers) {
|
|
|
3157
2587
|
}
|
|
3158
2588
|
|
|
3159
2589
|
// packages/experience-design-system-cli/src/tui/import/steps/04-credentials/validate.ts
|
|
2590
|
+
var USER_AGENT2 = "app contentful.experience-design-system-cli";
|
|
2591
|
+
function headers(token) {
|
|
2592
|
+
return { Authorization: `Bearer ${token}`, "X-Contentful-User-Agent": USER_AGENT2 };
|
|
2593
|
+
}
|
|
2594
|
+
function isApsDenial(body) {
|
|
2595
|
+
try {
|
|
2596
|
+
const id = JSON.parse(body).sys?.id;
|
|
2597
|
+
return id === "NotFound" || id === "AccessDenied";
|
|
2598
|
+
} catch {
|
|
2599
|
+
return false;
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
function messageFrom(body) {
|
|
2603
|
+
try {
|
|
2604
|
+
const message = JSON.parse(body).message;
|
|
2605
|
+
return typeof message === "string" && message !== "" ? message : void 0;
|
|
2606
|
+
} catch {
|
|
2607
|
+
return void 0;
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
3160
2610
|
async function validateCredentials(values) {
|
|
3161
|
-
const
|
|
3162
|
-
|
|
3163
|
-
host,
|
|
3164
|
-
spaceId: values.spaceId,
|
|
3165
|
-
environmentId: values.environmentId,
|
|
3166
|
-
cmaToken: values.cmaToken
|
|
3167
|
-
});
|
|
2611
|
+
const base = toApiHost3(values.host);
|
|
2612
|
+
let me;
|
|
3168
2613
|
try {
|
|
3169
|
-
await
|
|
3170
|
-
return { ok: true };
|
|
2614
|
+
me = await fetch(`${base}/users/me`, { headers: headers(values.cmaToken) });
|
|
3171
2615
|
} catch (error) {
|
|
3172
|
-
return { ok: false, error:
|
|
2616
|
+
return { ok: false, error: `Could not reach ${base}: ${error instanceof Error ? error.message : String(error)}` };
|
|
3173
2617
|
}
|
|
3174
|
-
}
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
2618
|
+
if (me.status === 401) return { ok: false, error: "CMA token is invalid or revoked." };
|
|
2619
|
+
if (!me.ok) return { ok: false, error: `Unexpected error validating the token (${me.status}).` };
|
|
2620
|
+
let preflight;
|
|
2621
|
+
try {
|
|
2622
|
+
preflight = await fetch(
|
|
2623
|
+
`${base}/spaces/${values.spaceId}/environments/${values.environmentId}/design_systems/preflight`,
|
|
2624
|
+
{ headers: headers(values.cmaToken) }
|
|
2625
|
+
);
|
|
2626
|
+
} catch {
|
|
2627
|
+
return { ok: true };
|
|
2628
|
+
}
|
|
2629
|
+
if (preflight.ok || preflight.status >= 500) return { ok: true };
|
|
2630
|
+
const body = await preflight.text();
|
|
2631
|
+
if (preflight.status === 404 && !isApsDenial(body)) return { ok: true };
|
|
2632
|
+
const detail = messageFrom(body);
|
|
2633
|
+
if (preflight.status === 403) {
|
|
2634
|
+
return { ok: false, error: `Access denied. ${detail ?? "Your token cannot write design system components here."}` };
|
|
2635
|
+
}
|
|
2636
|
+
if (preflight.status === 404) {
|
|
2637
|
+
return {
|
|
2638
|
+
ok: false,
|
|
2639
|
+
error: `Not found. Check the space ID, environment and API host.${detail ? ` (${detail})` : ""}`
|
|
2640
|
+
};
|
|
3181
2641
|
}
|
|
3182
|
-
|
|
3183
|
-
return String(error);
|
|
2642
|
+
return { ok: false, error: `Credential check failed (${preflight.status}).${detail ? ` ${detail}` : ""}` };
|
|
3184
2643
|
}
|
|
3185
2644
|
|
|
3186
2645
|
// packages/experience-design-system-cli/src/tui/import/steps/04-credentials/screen.tsx
|
|
@@ -3257,7 +2716,7 @@ function CredentialsScreen({
|
|
|
3257
2716
|
value: values[field],
|
|
3258
2717
|
focus: active === field && !validating,
|
|
3259
2718
|
mask: field === "cmaToken" ? "\u2022" : void 0,
|
|
3260
|
-
placeholder: field === "host" ?
|
|
2719
|
+
placeholder: field === "host" ? DEFAULT_HOST : void 0,
|
|
3261
2720
|
onChange: change(field),
|
|
3262
2721
|
onSubmit: () => void submit(field)
|
|
3263
2722
|
}
|
|
@@ -3279,18 +2738,163 @@ function CredentialsScreen({
|
|
|
3279
2738
|
] });
|
|
3280
2739
|
}
|
|
3281
2740
|
|
|
2741
|
+
// packages/experience-design-system-cli/src/tui/import/shared/error-step/error-step.tsx
|
|
2742
|
+
import { Box as Box7, Text as Text8 } from "ink";
|
|
2743
|
+
|
|
2744
|
+
// packages/experience-design-system-cli/src/tui/import/shared/error-step/controls.ts
|
|
2745
|
+
import { useInput as useInput7 } from "ink";
|
|
2746
|
+
|
|
2747
|
+
// packages/experience-design-system-cli/src/tui/import/shared/error-step/error-step.tsx
|
|
2748
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2749
|
+
|
|
2750
|
+
// packages/experience-design-system-cli/src/tui/import/shared/gate-step/gate-step.tsx
|
|
2751
|
+
import { Box as Box8, Text as Text9 } from "ink";
|
|
2752
|
+
|
|
2753
|
+
// packages/experience-design-system-cli/src/tui/import/shared/gate-step/controls.ts
|
|
2754
|
+
import { useInput as useInput8 } from "ink";
|
|
2755
|
+
|
|
2756
|
+
// packages/experience-design-system-cli/src/tui/import/shared/gate-step/logic.ts
|
|
2757
|
+
function gateAction(input, key, canSkip) {
|
|
2758
|
+
if (key.return) return "continue";
|
|
2759
|
+
if (input === "a" && canSkip) return "skip";
|
|
2760
|
+
if (key.escape) return "quit";
|
|
2761
|
+
return null;
|
|
2762
|
+
}
|
|
2763
|
+
function gateControls(continueLabel, skipLabel, canSkip) {
|
|
2764
|
+
return [
|
|
2765
|
+
{ keys: "Enter", label: continueLabel },
|
|
2766
|
+
...canSkip ? [{ keys: "a", label: skipLabel }] : [],
|
|
2767
|
+
{ keys: "Esc", label: "Quit" }
|
|
2768
|
+
];
|
|
2769
|
+
}
|
|
2770
|
+
|
|
2771
|
+
// packages/experience-design-system-cli/src/tui/import/shared/gate-step/controls.ts
|
|
2772
|
+
function useGateControls(handlers) {
|
|
2773
|
+
useInput8((input, key) => {
|
|
2774
|
+
const action = gateAction(input, key, handlers.canSkip);
|
|
2775
|
+
if (action === "continue") handlers.onContinue();
|
|
2776
|
+
else if (action === "skip") handlers.onSkip();
|
|
2777
|
+
else if (action === "quit") handlers.onQuit();
|
|
2778
|
+
});
|
|
2779
|
+
}
|
|
2780
|
+
|
|
2781
|
+
// packages/experience-design-system-cli/src/tui/import/shared/gate-step/gate-step.tsx
|
|
2782
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2783
|
+
function GateStep({
|
|
2784
|
+
message,
|
|
2785
|
+
onContinue,
|
|
2786
|
+
onQuit,
|
|
2787
|
+
summary,
|
|
2788
|
+
context,
|
|
2789
|
+
continueLabel = "Continue",
|
|
2790
|
+
skipLabel = "Approve all and skip",
|
|
2791
|
+
onSkip,
|
|
2792
|
+
intent = "success"
|
|
2793
|
+
}) {
|
|
2794
|
+
useGateControls({ canSkip: onSkip !== void 0, onContinue, onSkip: onSkip ?? (() => {
|
|
2795
|
+
}), onQuit });
|
|
2796
|
+
const color = intent === "error" ? PALETTE.error : PALETTE.success;
|
|
2797
|
+
const icon = intent === "error" ? "\u2717" : "\u2713";
|
|
2798
|
+
return /* @__PURE__ */ jsxs8(Box8, { flexDirection: "column", gap: 1, paddingX: 2, paddingY: 1, children: [
|
|
2799
|
+
/* @__PURE__ */ jsxs8(Text9, { color, children: [
|
|
2800
|
+
icon,
|
|
2801
|
+
" ",
|
|
2802
|
+
message
|
|
2803
|
+
] }),
|
|
2804
|
+
summary && /* @__PURE__ */ jsx9(Text9, { color: PALETTE.muted, children: summary }),
|
|
2805
|
+
context && /* @__PURE__ */ jsx9(Box8, { marginTop: 1, children: /* @__PURE__ */ jsx9(Text9, { children: context }) }),
|
|
2806
|
+
/* @__PURE__ */ jsx9(Box8, { marginTop: 1, gap: 3, children: gateControls(continueLabel, skipLabel, onSkip !== void 0).map((control) => /* @__PURE__ */ jsxs8(Text9, { dimColor: true, children: [
|
|
2807
|
+
"[",
|
|
2808
|
+
control.keys,
|
|
2809
|
+
"] ",
|
|
2810
|
+
control.label
|
|
2811
|
+
] }, control.keys)) })
|
|
2812
|
+
] });
|
|
2813
|
+
}
|
|
2814
|
+
|
|
2815
|
+
// packages/experience-design-system-cli/src/tui/import/shared/running-step/running-step.tsx
|
|
2816
|
+
import { Box as Box9, Text as Text10 } from "ink";
|
|
2817
|
+
import { ProgressBar, Spinner, ThemeProvider } from "@inkjs/ui";
|
|
2818
|
+
|
|
2819
|
+
// packages/experience-design-system-cli/src/tui/import/shared/running-step/theme.ts
|
|
2820
|
+
import { defaultTheme, extendTheme } from "@inkjs/ui";
|
|
2821
|
+
var PROGRESS_THEME = extendTheme(defaultTheme, {
|
|
2822
|
+
components: {
|
|
2823
|
+
ProgressBar: {
|
|
2824
|
+
styles: {
|
|
2825
|
+
completed: () => ({ color: "blue" })
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2829
|
+
});
|
|
2830
|
+
|
|
2831
|
+
// packages/experience-design-system-cli/src/tui/import/shared/running-step/use-elapsed.ts
|
|
2832
|
+
import { useEffect as useEffect4, useState as useState7 } from "react";
|
|
2833
|
+
|
|
2834
|
+
// packages/experience-design-system-cli/src/tui/import/shared/running-step/running-step.tsx
|
|
2835
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2836
|
+
var RULE2 = "\u2500".repeat(40);
|
|
2837
|
+
|
|
2838
|
+
// packages/experience-design-system-cli/src/tui/import/steps/05-token-reuse/logic.ts
|
|
2839
|
+
import { access, stat } from "node:fs/promises";
|
|
2840
|
+
import { join as join3 } from "node:path";
|
|
2841
|
+
async function inspectTokens({ rawTokensPath, outDir, cache }) {
|
|
2842
|
+
if (!cache) return { kind: "none" };
|
|
2843
|
+
const tokensPath = join3(outDir, "tokens.json");
|
|
2844
|
+
try {
|
|
2845
|
+
await access(tokensPath);
|
|
2846
|
+
} catch {
|
|
2847
|
+
return { kind: "none" };
|
|
2848
|
+
}
|
|
2849
|
+
const [generated, source] = await Promise.all([stat(tokensPath), stat(rawTokensPath).catch(() => null)]);
|
|
2850
|
+
return { kind: "cached", tokensPath, sourceChanged: source ? source.mtimeMs > generated.mtimeMs : false };
|
|
2851
|
+
}
|
|
2852
|
+
function gateText({ tokensPath, sourceChanged }) {
|
|
2853
|
+
const summary = sourceChanged ? `Source file has been modified since tokens were last generated.
|
|
2854
|
+
|
|
2855
|
+
Tokens Path: ${tokensPath}` : `Source file has not changed since tokens were last generated.
|
|
2856
|
+
|
|
2857
|
+
Tokens Path: ${tokensPath}`;
|
|
2858
|
+
return sourceChanged ? { summary, context: "The source tokens file changed \u2014 regenerating is recommended." } : { summary };
|
|
2859
|
+
}
|
|
2860
|
+
|
|
2861
|
+
// packages/experience-design-system-cli/src/tui/import/steps/05-token-reuse/screen.tsx
|
|
2862
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
2863
|
+
function TokenReuseScreen({
|
|
2864
|
+
tokensPath,
|
|
2865
|
+
sourceChanged,
|
|
2866
|
+
onReuse,
|
|
2867
|
+
onRegenerate,
|
|
2868
|
+
onQuit
|
|
2869
|
+
}) {
|
|
2870
|
+
const { summary, context } = gateText({ tokensPath, sourceChanged });
|
|
2871
|
+
return /* @__PURE__ */ jsx11(
|
|
2872
|
+
GateStep,
|
|
2873
|
+
{
|
|
2874
|
+
message: "Existing tokens.json found",
|
|
2875
|
+
summary,
|
|
2876
|
+
context,
|
|
2877
|
+
continueLabel: "Reuse existing tokens",
|
|
2878
|
+
skipLabel: "Regenerate tokens",
|
|
2879
|
+
onContinue: onReuse,
|
|
2880
|
+
onSkip: onRegenerate,
|
|
2881
|
+
onQuit
|
|
2882
|
+
}
|
|
2883
|
+
);
|
|
2884
|
+
}
|
|
2885
|
+
|
|
3282
2886
|
// packages/experience-design-system-cli/src/tui/import/spawn-v1-import.ts
|
|
3283
2887
|
import { spawn } from "node:child_process";
|
|
3284
2888
|
|
|
3285
2889
|
// packages/experience-design-system-cli/src/legacy/legacy-cli-path.ts
|
|
3286
2890
|
import { existsSync as existsSync2 } from "node:fs";
|
|
3287
|
-
import { join as
|
|
2891
|
+
import { join as join4 } from "node:path";
|
|
3288
2892
|
var PACKAGE_NAME2 = "@contentful/experience-design-system-cli";
|
|
3289
2893
|
function findLegacyCliPath() {
|
|
3290
2894
|
const root = findPackageRoot(import.meta.url, PACKAGE_NAME2);
|
|
3291
2895
|
const candidates = [
|
|
3292
|
-
|
|
3293
|
-
|
|
2896
|
+
join4(root, "legacy", "bin", "cli.js"),
|
|
2897
|
+
join4(root, "..", "experience-design-system-cli-legacy", "bin", "cli.js")
|
|
3294
2898
|
];
|
|
3295
2899
|
const found = candidates.find((candidate) => existsSync2(candidate));
|
|
3296
2900
|
if (!found) {
|
|
@@ -3300,6 +2904,15 @@ ${candidates.join("\n")}`);
|
|
|
3300
2904
|
return found;
|
|
3301
2905
|
}
|
|
3302
2906
|
|
|
2907
|
+
// packages/experience-design-system-cli/src/commands/import-options.ts
|
|
2908
|
+
function importOptionArgs(options) {
|
|
2909
|
+
return [
|
|
2910
|
+
...options.agent ? ["--agent", options.agent] : [],
|
|
2911
|
+
...options.prompt.flatMap((value) => ["--prompt", value]),
|
|
2912
|
+
...options.cache ? [] : ["--no-cache"]
|
|
2913
|
+
];
|
|
2914
|
+
}
|
|
2915
|
+
|
|
3303
2916
|
// packages/experience-design-system-cli/src/tui/import/spawn-v1-import.ts
|
|
3304
2917
|
function buildArgs2(options) {
|
|
3305
2918
|
const args = ["import"];
|
|
@@ -3309,15 +2922,23 @@ function buildArgs2(options) {
|
|
|
3309
2922
|
if (options.tokens) {
|
|
3310
2923
|
args.push("--tokens", options.tokens);
|
|
3311
2924
|
}
|
|
2925
|
+
args.push(...importOptionArgs({ agent: options.agent, prompt: options.prompt ?? [], cache: options.cache ?? true }));
|
|
3312
2926
|
return args;
|
|
3313
2927
|
}
|
|
2928
|
+
function buildEnv(options, base = process.env) {
|
|
2929
|
+
return {
|
|
2930
|
+
...base,
|
|
2931
|
+
...options.skipCredentials ? { EDS_IMPORT_SKIP_CREDENTIALS: "1" } : {},
|
|
2932
|
+
...options.tokenStrategy ? { EDS_IMPORT_TOKENS: options.tokenStrategy } : {}
|
|
2933
|
+
};
|
|
2934
|
+
}
|
|
3314
2935
|
async function spawnV1Import(options = {}) {
|
|
3315
2936
|
const cliPath = findLegacyCliPath();
|
|
3316
2937
|
const args = buildArgs2(options);
|
|
3317
2938
|
return new Promise((resolvePromise) => {
|
|
3318
2939
|
const child = spawn("node", [cliPath, ...args], {
|
|
3319
2940
|
stdio: "inherit",
|
|
3320
|
-
env: options
|
|
2941
|
+
env: buildEnv(options)
|
|
3321
2942
|
});
|
|
3322
2943
|
child.on("close", (code) => {
|
|
3323
2944
|
resolvePromise({ exitCode: code ?? 1, result: void 0, stdout: "", stderr: "" });
|
|
@@ -3347,24 +2968,24 @@ function startReadingTerminal() {
|
|
|
3347
2968
|
}
|
|
3348
2969
|
|
|
3349
2970
|
// packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
|
|
3350
|
-
import { useEffect as
|
|
3351
|
-
import { Box as
|
|
2971
|
+
import { useEffect as useEffect5, useState as useState8 } from "react";
|
|
2972
|
+
import { Box as Box10, Text as Text11, useInput as useInput9 } from "ink";
|
|
3352
2973
|
|
|
3353
2974
|
// packages/experience-design-system-cli/src/tui/debug-store.ts
|
|
3354
2975
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
|
|
3355
2976
|
import { existsSync as existsSync3, readdirSync as readdirSync2 } from "node:fs";
|
|
3356
|
-
import { join as
|
|
2977
|
+
import { join as join6 } from "node:path";
|
|
3357
2978
|
|
|
3358
2979
|
// packages/experience-design-system-types/dist/src/config/index.js
|
|
3359
2980
|
import { randomBytes } from "node:crypto";
|
|
3360
2981
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
3361
2982
|
import { homedir as homedir2 } from "node:os";
|
|
3362
|
-
import { dirname as dirname2, join as
|
|
2983
|
+
import { dirname as dirname2, join as join5 } from "node:path";
|
|
3363
2984
|
function configRoot2() {
|
|
3364
|
-
return process.env["EDS_HOME"] ||
|
|
2985
|
+
return process.env["EDS_HOME"] || join5(homedir2(), ".contentful", "experience-design-system-cli");
|
|
3365
2986
|
}
|
|
3366
|
-
var configFilePath2 = () =>
|
|
3367
|
-
var debugSessionsDir2 = () =>
|
|
2987
|
+
var configFilePath2 = () => join5(configRoot2(), "config.json");
|
|
2988
|
+
var debugSessionsDir2 = () => join5(configRoot2(), "debug", "sessions");
|
|
3368
2989
|
async function readSettings2() {
|
|
3369
2990
|
try {
|
|
3370
2991
|
return JSON.parse(await readFile(configFilePath2(), "utf8"));
|
|
@@ -3423,7 +3044,7 @@ function generateSessionId3() {
|
|
|
3423
3044
|
}
|
|
3424
3045
|
var SESSION_ID = generateSessionId3();
|
|
3425
3046
|
function sessionDebugDir() {
|
|
3426
|
-
return
|
|
3047
|
+
return join6(debugSessionsDir2(), SESSION_ID);
|
|
3427
3048
|
}
|
|
3428
3049
|
function currentDebugSessionDir() {
|
|
3429
3050
|
return sessionDebugDir();
|
|
@@ -3472,10 +3093,10 @@ async function finishDebugRun({
|
|
|
3472
3093
|
const durationMs = Date.now() - run.startedAt;
|
|
3473
3094
|
const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
|
|
3474
3095
|
const flowSegments = run.flow.split("/");
|
|
3475
|
-
const dir =
|
|
3096
|
+
const dir = join6(sessionDebugDir(), ...flowSegments);
|
|
3476
3097
|
await mkdir2(dir, { recursive: true });
|
|
3477
3098
|
const filename = nextAttemptFilename(dir, run.menuOption);
|
|
3478
|
-
await writeFile2(
|
|
3099
|
+
await writeFile2(join6(dir, filename), content, { mode: 384 });
|
|
3479
3100
|
}
|
|
3480
3101
|
function nextAttemptFilename(dir, menuOption) {
|
|
3481
3102
|
const today = datePrefix();
|
|
@@ -3490,13 +3111,13 @@ function nextAttemptFilename(dir, menuOption) {
|
|
|
3490
3111
|
}
|
|
3491
3112
|
function renderMarkdown(run, finish) {
|
|
3492
3113
|
const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
|
|
3493
|
-
const
|
|
3114
|
+
const stepLabel2 = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
|
|
3494
3115
|
const flowSlug = run.flow.split("/").join("-");
|
|
3495
3116
|
return `# Debug Log
|
|
3496
3117
|
|
|
3497
3118
|
- Run ID: ${run.runId}
|
|
3498
3119
|
- Flow: ${flowSlug}
|
|
3499
|
-
- Step: ${
|
|
3120
|
+
- Step: ${stepLabel2}
|
|
3500
3121
|
- Menu option: ${run.menuOption}
|
|
3501
3122
|
- Date: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
3502
3123
|
- CLI version: ${readPackageVersion()}
|
|
@@ -3558,19 +3179,19 @@ async function readHelpInfo() {
|
|
|
3558
3179
|
}
|
|
3559
3180
|
|
|
3560
3181
|
// packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
|
|
3561
|
-
import { Fragment as Fragment2, jsx as
|
|
3182
|
+
import { Fragment as Fragment2, jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
3562
3183
|
function Section({ title, rows }) {
|
|
3563
|
-
return /* @__PURE__ */
|
|
3564
|
-
/* @__PURE__ */
|
|
3565
|
-
rows.map((row) => /* @__PURE__ */
|
|
3566
|
-
/* @__PURE__ */
|
|
3567
|
-
/* @__PURE__ */
|
|
3184
|
+
return /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", children: [
|
|
3185
|
+
/* @__PURE__ */ jsx12(Text11, { bold: true, color: PALETTE.accent, children: title }),
|
|
3186
|
+
rows.map((row) => /* @__PURE__ */ jsxs10(Box10, { gap: 1, children: [
|
|
3187
|
+
/* @__PURE__ */ jsx12(Box10, { width: 14, flexShrink: 0, children: /* @__PURE__ */ jsx12(Text11, { color: PALETTE.muted, children: row.label }) }),
|
|
3188
|
+
/* @__PURE__ */ jsx12(Text11, { children: row.value })
|
|
3568
3189
|
] }, row.label))
|
|
3569
3190
|
] });
|
|
3570
3191
|
}
|
|
3571
3192
|
function HelpScreen({ onDone }) {
|
|
3572
|
-
const [info, setInfo] =
|
|
3573
|
-
|
|
3193
|
+
const [info, setInfo] = useState8();
|
|
3194
|
+
useEffect5(() => {
|
|
3574
3195
|
startDebugRun({ flow: "help", step: "01-help", menuOption: "Help", inputs: {} });
|
|
3575
3196
|
void readHelpInfo().then(setInfo);
|
|
3576
3197
|
}, []);
|
|
@@ -3578,7 +3199,7 @@ function HelpScreen({ onDone }) {
|
|
|
3578
3199
|
void finishDebugRun({ outputs: {}, status: "success", exitMethod });
|
|
3579
3200
|
onDone();
|
|
3580
3201
|
};
|
|
3581
|
-
|
|
3202
|
+
useInput9((input, key) => {
|
|
3582
3203
|
if (key.return) {
|
|
3583
3204
|
leave("saved");
|
|
3584
3205
|
return;
|
|
@@ -3588,14 +3209,14 @@ function HelpScreen({ onDone }) {
|
|
|
3588
3209
|
return;
|
|
3589
3210
|
}
|
|
3590
3211
|
});
|
|
3591
|
-
return /* @__PURE__ */
|
|
3592
|
-
/* @__PURE__ */
|
|
3593
|
-
info ? /* @__PURE__ */
|
|
3594
|
-
/* @__PURE__ */
|
|
3595
|
-
/* @__PURE__ */
|
|
3596
|
-
/* @__PURE__ */
|
|
3597
|
-
] }) : /* @__PURE__ */
|
|
3598
|
-
/* @__PURE__ */
|
|
3212
|
+
return /* @__PURE__ */ jsxs10(Box10, { flexDirection: "column", paddingX: 2, paddingY: 1, gap: 1, children: [
|
|
3213
|
+
/* @__PURE__ */ jsx12(Text11, { bold: true, children: "Help" }),
|
|
3214
|
+
info ? /* @__PURE__ */ jsxs10(Fragment2, { children: [
|
|
3215
|
+
/* @__PURE__ */ jsx12(Section, { title: "Where things are stored", rows: info.storage }),
|
|
3216
|
+
/* @__PURE__ */ jsx12(Section, { title: "Troubleshooting", rows: info.troubleshooting }),
|
|
3217
|
+
/* @__PURE__ */ jsx12(Text11, { color: PALETTE.muted, children: "Hit a problem? Turn on Debug Mode in Settings, reproduce it, then share the session folder above. The CMA token is redacted from those logs." })
|
|
3218
|
+
] }) : /* @__PURE__ */ jsx12(Text11, { color: PALETTE.accent, children: "Loading..." }),
|
|
3219
|
+
/* @__PURE__ */ jsx12(
|
|
3599
3220
|
ControlHints,
|
|
3600
3221
|
{
|
|
3601
3222
|
hints: [
|
|
@@ -3608,20 +3229,20 @@ function HelpScreen({ onDone }) {
|
|
|
3608
3229
|
}
|
|
3609
3230
|
|
|
3610
3231
|
// packages/experience-design-system-cli/src/tui/settings/PageContainer.tsx
|
|
3611
|
-
import { useState as
|
|
3612
|
-
import { Box as
|
|
3613
|
-
import { jsx as
|
|
3232
|
+
import { useState as useState9 } from "react";
|
|
3233
|
+
import { Box as Box11, Text as Text12, useInput as useInput10 } from "ink";
|
|
3234
|
+
import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3614
3235
|
function SettingsScreen({
|
|
3615
3236
|
onNavigate,
|
|
3616
3237
|
onBack
|
|
3617
3238
|
}) {
|
|
3618
|
-
const [focusIdx, setFocusIdx] =
|
|
3239
|
+
const [focusIdx, setFocusIdx] = useState9(0);
|
|
3619
3240
|
const items = [
|
|
3620
3241
|
{ label: "Configuration", screen: "settings-configuration" },
|
|
3621
3242
|
{ label: "Opt-in Analytics", screen: "settings-opt-in-analytics" },
|
|
3622
3243
|
{ label: "Debug Mode", screen: "settings-debug-mode" }
|
|
3623
3244
|
];
|
|
3624
|
-
|
|
3245
|
+
useInput10((input, key) => {
|
|
3625
3246
|
if (key.upArrow) {
|
|
3626
3247
|
setFocusIdx((i) => (i - 1 + items.length) % items.length);
|
|
3627
3248
|
return;
|
|
@@ -3641,15 +3262,15 @@ function SettingsScreen({
|
|
|
3641
3262
|
onBack();
|
|
3642
3263
|
}
|
|
3643
3264
|
});
|
|
3644
|
-
return /* @__PURE__ */
|
|
3645
|
-
/* @__PURE__ */
|
|
3646
|
-
/* @__PURE__ */
|
|
3647
|
-
items.map((item, i) => /* @__PURE__ */
|
|
3265
|
+
return /* @__PURE__ */ jsxs11(Box11, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
3266
|
+
/* @__PURE__ */ jsx13(Text12, { bold: true, children: "Settings" }),
|
|
3267
|
+
/* @__PURE__ */ jsx13(Text12, { children: " " }),
|
|
3268
|
+
items.map((item, i) => /* @__PURE__ */ jsxs11(Text12, { color: i === focusIdx ? "cyan" : void 0, children: [
|
|
3648
3269
|
i === focusIdx ? "> " : " ",
|
|
3649
3270
|
item.label
|
|
3650
3271
|
] }, item.label)),
|
|
3651
|
-
/* @__PURE__ */
|
|
3652
|
-
/* @__PURE__ */
|
|
3272
|
+
/* @__PURE__ */ jsx13(Text12, { children: " " }),
|
|
3273
|
+
/* @__PURE__ */ jsx13(
|
|
3653
3274
|
ControlHints,
|
|
3654
3275
|
{
|
|
3655
3276
|
hints: [
|
|
@@ -3663,8 +3284,8 @@ function SettingsScreen({
|
|
|
3663
3284
|
}
|
|
3664
3285
|
|
|
3665
3286
|
// packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
|
|
3666
|
-
import { useEffect as
|
|
3667
|
-
import { Box as
|
|
3287
|
+
import { useEffect as useEffect6, useState as useState10 } from "react";
|
|
3288
|
+
import { Box as Box12, Text as Text13, useInput as useInput11 } from "ink";
|
|
3668
3289
|
import TextInput4 from "ink-text-input";
|
|
3669
3290
|
|
|
3670
3291
|
// packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts
|
|
@@ -3696,7 +3317,7 @@ async function writeCredentials(config) {
|
|
|
3696
3317
|
}
|
|
3697
3318
|
|
|
3698
3319
|
// packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
|
|
3699
|
-
import { Fragment as Fragment3, jsx as
|
|
3320
|
+
import { Fragment as Fragment3, jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3700
3321
|
var FIELD_ORDER = [
|
|
3701
3322
|
"spaceId",
|
|
3702
3323
|
"environmentId",
|
|
@@ -3724,14 +3345,14 @@ var FIELD_LABELS = {
|
|
|
3724
3345
|
defaultTokenFile: "Default token file (optional)"
|
|
3725
3346
|
};
|
|
3726
3347
|
function ConfigurationScreen({ onDone }) {
|
|
3727
|
-
const [stage, setStage] =
|
|
3728
|
-
const [config, setConfig] =
|
|
3729
|
-
const [activeField, setActiveField] =
|
|
3730
|
-
const [notice, setNotice] =
|
|
3731
|
-
const [lastSaved, setLastSaved] =
|
|
3732
|
-
const [editing, setEditing] =
|
|
3733
|
-
const [valueBeforeEdit, setValueBeforeEdit] =
|
|
3734
|
-
|
|
3348
|
+
const [stage, setStage] = useState10("loading");
|
|
3349
|
+
const [config, setConfig] = useState10(null);
|
|
3350
|
+
const [activeField, setActiveField] = useState10("spaceId");
|
|
3351
|
+
const [notice, setNotice] = useState10(null);
|
|
3352
|
+
const [lastSaved, setLastSaved] = useState10(null);
|
|
3353
|
+
const [editing, setEditing] = useState10(false);
|
|
3354
|
+
const [valueBeforeEdit, setValueBeforeEdit] = useState10("");
|
|
3355
|
+
useEffect6(() => {
|
|
3735
3356
|
readCredentials().then((cfg) => {
|
|
3736
3357
|
setConfig(cfg);
|
|
3737
3358
|
setStage("form");
|
|
@@ -3771,7 +3392,7 @@ function ConfigurationScreen({ onDone }) {
|
|
|
3771
3392
|
);
|
|
3772
3393
|
onDone();
|
|
3773
3394
|
}
|
|
3774
|
-
|
|
3395
|
+
useInput11((input, key) => {
|
|
3775
3396
|
if (stage === "loading" || stage === "saving") return;
|
|
3776
3397
|
if (editing) {
|
|
3777
3398
|
if (key.escape) {
|
|
@@ -3808,26 +3429,26 @@ function ConfigurationScreen({ onDone }) {
|
|
|
3808
3429
|
}
|
|
3809
3430
|
});
|
|
3810
3431
|
if (stage === "loading") {
|
|
3811
|
-
return /* @__PURE__ */
|
|
3812
|
-
/* @__PURE__ */
|
|
3813
|
-
/* @__PURE__ */
|
|
3814
|
-
/* @__PURE__ */
|
|
3432
|
+
return /* @__PURE__ */ jsxs12(Box12, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
3433
|
+
/* @__PURE__ */ jsx14(Text13, { bold: true, children: "Configuration" }),
|
|
3434
|
+
/* @__PURE__ */ jsx14(Text13, { children: " " }),
|
|
3435
|
+
/* @__PURE__ */ jsx14(Text13, { color: PALETTE.accent, children: "Loading..." })
|
|
3815
3436
|
] });
|
|
3816
3437
|
}
|
|
3817
|
-
return /* @__PURE__ */
|
|
3818
|
-
/* @__PURE__ */
|
|
3819
|
-
/* @__PURE__ */
|
|
3820
|
-
/* @__PURE__ */
|
|
3438
|
+
return /* @__PURE__ */ jsxs12(Box12, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
3439
|
+
/* @__PURE__ */ jsx14(Text13, { bold: true, children: "Configuration" }),
|
|
3440
|
+
/* @__PURE__ */ jsx14(Text13, { children: " " }),
|
|
3441
|
+
/* @__PURE__ */ jsx14(Box12, { flexDirection: "column", children: FIELD_ORDER.map((field) => {
|
|
3821
3442
|
const isActive = activeField === field;
|
|
3822
3443
|
const value = fieldValue(field);
|
|
3823
3444
|
const display = field === "cmaToken" ? "\u2022".repeat(value.length) : value;
|
|
3824
|
-
return /* @__PURE__ */
|
|
3825
|
-
/* @__PURE__ */
|
|
3826
|
-
/* @__PURE__ */
|
|
3445
|
+
return /* @__PURE__ */ jsxs12(Box12, { gap: 1, children: [
|
|
3446
|
+
/* @__PURE__ */ jsx14(Text13, { color: isActive ? PALETTE.accent : void 0, children: isActive ? "\u276F" : " " }),
|
|
3447
|
+
/* @__PURE__ */ jsxs12(Text13, { bold: isActive, children: [
|
|
3827
3448
|
FIELD_LABELS[field],
|
|
3828
3449
|
":"
|
|
3829
3450
|
] }),
|
|
3830
|
-
isActive && editing ? /* @__PURE__ */
|
|
3451
|
+
isActive && editing ? /* @__PURE__ */ jsx14(
|
|
3831
3452
|
TextInput4,
|
|
3832
3453
|
{
|
|
3833
3454
|
value,
|
|
@@ -3835,19 +3456,19 @@ function ConfigurationScreen({ onDone }) {
|
|
|
3835
3456
|
onSubmit: () => setEditing(false),
|
|
3836
3457
|
mask: field === "cmaToken" ? "\u2022" : void 0
|
|
3837
3458
|
}
|
|
3838
|
-
) : /* @__PURE__ */
|
|
3459
|
+
) : /* @__PURE__ */ jsx14(Text13, { children: display || /* @__PURE__ */ jsx14(Text13, { color: PALETTE.muted, children: "(empty)" }) })
|
|
3839
3460
|
] }, field);
|
|
3840
3461
|
}) }),
|
|
3841
|
-
notice && /* @__PURE__ */
|
|
3842
|
-
/* @__PURE__ */
|
|
3843
|
-
/* @__PURE__ */
|
|
3462
|
+
notice && /* @__PURE__ */ jsxs12(Fragment3, { children: [
|
|
3463
|
+
/* @__PURE__ */ jsx14(Text13, { children: " " }),
|
|
3464
|
+
/* @__PURE__ */ jsxs12(Text13, { color: notice.kind === "success" ? PALETTE.success : PALETTE.error, children: [
|
|
3844
3465
|
notice.kind === "success" ? "\u2713" : "\u2717",
|
|
3845
3466
|
" ",
|
|
3846
3467
|
notice.text
|
|
3847
3468
|
] })
|
|
3848
3469
|
] }),
|
|
3849
|
-
/* @__PURE__ */
|
|
3850
|
-
/* @__PURE__ */
|
|
3470
|
+
/* @__PURE__ */ jsx14(Text13, { children: " " }),
|
|
3471
|
+
/* @__PURE__ */ jsx14(
|
|
3851
3472
|
ControlHints,
|
|
3852
3473
|
{
|
|
3853
3474
|
hints: editing ? [
|
|
@@ -3868,8 +3489,8 @@ function ConfigurationScreen({ onDone }) {
|
|
|
3868
3489
|
}
|
|
3869
3490
|
|
|
3870
3491
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
|
|
3871
|
-
import { useEffect as
|
|
3872
|
-
import { Box as
|
|
3492
|
+
import { useEffect as useEffect7, useState as useState11 } from "react";
|
|
3493
|
+
import { Box as Box13, Text as Text14, useInput as useInput12 } from "ink";
|
|
3873
3494
|
|
|
3874
3495
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/analytics-store.ts
|
|
3875
3496
|
async function readAnalyticsSetting() {
|
|
@@ -3887,11 +3508,11 @@ async function writeAnalyticsSetting(setting) {
|
|
|
3887
3508
|
}
|
|
3888
3509
|
|
|
3889
3510
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
|
|
3890
|
-
import { Fragment as Fragment4, jsx as
|
|
3511
|
+
import { Fragment as Fragment4, jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3891
3512
|
function OptInAnalyticsScreen({ onDone }) {
|
|
3892
|
-
const [loading, setLoading] =
|
|
3893
|
-
const [enabled, setEnabled] =
|
|
3894
|
-
|
|
3513
|
+
const [loading, setLoading] = useState11(true);
|
|
3514
|
+
const [enabled, setEnabled] = useState11(true);
|
|
3515
|
+
useEffect7(() => {
|
|
3895
3516
|
readAnalyticsSetting().then((setting) => {
|
|
3896
3517
|
setEnabled(setting.enabled);
|
|
3897
3518
|
setLoading(false);
|
|
@@ -3903,7 +3524,7 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
3903
3524
|
});
|
|
3904
3525
|
});
|
|
3905
3526
|
}, []);
|
|
3906
|
-
|
|
3527
|
+
useInput12((input, key) => {
|
|
3907
3528
|
if (loading) return;
|
|
3908
3529
|
if (key.return || input === " ") {
|
|
3909
3530
|
setEnabled((current) => {
|
|
@@ -3918,21 +3539,21 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
3918
3539
|
onDone();
|
|
3919
3540
|
}
|
|
3920
3541
|
});
|
|
3921
|
-
return /* @__PURE__ */
|
|
3922
|
-
/* @__PURE__ */
|
|
3923
|
-
/* @__PURE__ */
|
|
3924
|
-
loading ? /* @__PURE__ */
|
|
3925
|
-
/* @__PURE__ */
|
|
3542
|
+
return /* @__PURE__ */ jsxs13(Box13, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
3543
|
+
/* @__PURE__ */ jsx15(Text14, { bold: true, children: "Settings \u203A Opt-in Analytics" }),
|
|
3544
|
+
/* @__PURE__ */ jsx15(Text14, { children: " " }),
|
|
3545
|
+
loading ? /* @__PURE__ */ jsx15(Text14, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs13(Fragment4, { children: [
|
|
3546
|
+
/* @__PURE__ */ jsxs13(Text14, { children: [
|
|
3926
3547
|
"Share anonymous usage data:",
|
|
3927
3548
|
" ",
|
|
3928
|
-
/* @__PURE__ */
|
|
3549
|
+
/* @__PURE__ */ jsx15(Text14, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
|
|
3929
3550
|
] }),
|
|
3930
|
-
/* @__PURE__ */
|
|
3931
|
-
/* @__PURE__ */
|
|
3932
|
-
/* @__PURE__ */
|
|
3551
|
+
/* @__PURE__ */ jsx15(Text14, { children: " " }),
|
|
3552
|
+
/* @__PURE__ */ jsx15(Text14, { color: PALETTE.muted, children: "Shares which CLI commands are used and where imports succeed or fail." }),
|
|
3553
|
+
/* @__PURE__ */ jsx15(Text14, { color: PALETTE.muted, children: "Never includes source code, file paths, credentials, or authored content." })
|
|
3933
3554
|
] }),
|
|
3934
|
-
/* @__PURE__ */
|
|
3935
|
-
/* @__PURE__ */
|
|
3555
|
+
/* @__PURE__ */ jsx15(Text14, { children: " " }),
|
|
3556
|
+
/* @__PURE__ */ jsx15(
|
|
3936
3557
|
ControlHints,
|
|
3937
3558
|
{
|
|
3938
3559
|
hints: [
|
|
@@ -3945,13 +3566,13 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
3945
3566
|
}
|
|
3946
3567
|
|
|
3947
3568
|
// packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
|
|
3948
|
-
import { useEffect as
|
|
3949
|
-
import { Box as
|
|
3950
|
-
import { jsx as
|
|
3569
|
+
import { useEffect as useEffect8, useState as useState12 } from "react";
|
|
3570
|
+
import { Box as Box14, Text as Text15, useInput as useInput13 } from "ink";
|
|
3571
|
+
import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3951
3572
|
var UPGRADE_COMMANDS = ["git pull", "pnpm install", "pnpm build"];
|
|
3952
3573
|
function UpgradeScreen({ onDone }) {
|
|
3953
|
-
const [upgradeCheck, setUpgradeCheck] =
|
|
3954
|
-
|
|
3574
|
+
const [upgradeCheck, setUpgradeCheck] = useState12();
|
|
3575
|
+
useEffect8(() => {
|
|
3955
3576
|
startDebugRun({
|
|
3956
3577
|
flow: "upgrade",
|
|
3957
3578
|
step: "01-upgrade",
|
|
@@ -3960,7 +3581,7 @@ function UpgradeScreen({ onDone }) {
|
|
|
3960
3581
|
});
|
|
3961
3582
|
checkForUpgrade().then(setUpgradeCheck).catch(() => setUpgradeCheck({ status: "error" }));
|
|
3962
3583
|
}, []);
|
|
3963
|
-
|
|
3584
|
+
useInput13((_input, key) => {
|
|
3964
3585
|
if (key.return) {
|
|
3965
3586
|
void finishDebugRun({
|
|
3966
3587
|
outputs: upgradeCheck ?? {},
|
|
@@ -3971,12 +3592,12 @@ function UpgradeScreen({ onDone }) {
|
|
|
3971
3592
|
return;
|
|
3972
3593
|
}
|
|
3973
3594
|
});
|
|
3974
|
-
return /* @__PURE__ */
|
|
3975
|
-
/* @__PURE__ */
|
|
3976
|
-
/* @__PURE__ */
|
|
3595
|
+
return /* @__PURE__ */ jsxs14(Box14, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
3596
|
+
/* @__PURE__ */ jsx16(Text15, { bold: true, children: "Upgrade" }),
|
|
3597
|
+
/* @__PURE__ */ jsx16(Text15, { children: " " }),
|
|
3977
3598
|
renderBody(upgradeCheck),
|
|
3978
|
-
/* @__PURE__ */
|
|
3979
|
-
/* @__PURE__ */
|
|
3599
|
+
/* @__PURE__ */ jsx16(Text15, { children: " " }),
|
|
3600
|
+
/* @__PURE__ */ jsxs14(Text15, { bold: true, color: PALETTE.accent, children: [
|
|
3980
3601
|
FOCUS_MARKER,
|
|
3981
3602
|
" Go Back"
|
|
3982
3603
|
] })
|
|
@@ -3984,45 +3605,45 @@ function UpgradeScreen({ onDone }) {
|
|
|
3984
3605
|
}
|
|
3985
3606
|
function renderBody(upgradeCheck) {
|
|
3986
3607
|
if (!upgradeCheck) {
|
|
3987
|
-
return /* @__PURE__ */
|
|
3608
|
+
return /* @__PURE__ */ jsx16(Text15, { color: PALETTE.muted, children: "Checking for updates\u2026" });
|
|
3988
3609
|
}
|
|
3989
3610
|
if (upgradeCheck.status === "error") {
|
|
3990
|
-
return /* @__PURE__ */
|
|
3611
|
+
return /* @__PURE__ */ jsx16(Text15, { color: PALETTE.warning, children: "Couldn't check for updates \u2014 check your network connection and try again." });
|
|
3991
3612
|
}
|
|
3992
3613
|
if (upgradeCheck.status === "up-to-date") {
|
|
3993
|
-
return /* @__PURE__ */
|
|
3614
|
+
return /* @__PURE__ */ jsxs14(Text15, { color: PALETTE.success, children: [
|
|
3994
3615
|
"You're already on the latest version (v",
|
|
3995
3616
|
upgradeCheck.current,
|
|
3996
3617
|
")."
|
|
3997
3618
|
] });
|
|
3998
3619
|
}
|
|
3999
|
-
return /* @__PURE__ */
|
|
4000
|
-
/* @__PURE__ */
|
|
4001
|
-
/* @__PURE__ */
|
|
3620
|
+
return /* @__PURE__ */ jsxs14(Box14, { flexDirection: "column", children: [
|
|
3621
|
+
/* @__PURE__ */ jsxs14(Text15, { color: PALETTE.muted, children: [
|
|
3622
|
+
/* @__PURE__ */ jsxs14(Text15, { bold: true, color: PALETTE.success, children: [
|
|
4002
3623
|
"v",
|
|
4003
3624
|
upgradeCheck.latest
|
|
4004
3625
|
] }),
|
|
4005
3626
|
" ",
|
|
4006
3627
|
"is available (you're on ",
|
|
4007
|
-
/* @__PURE__ */
|
|
3628
|
+
/* @__PURE__ */ jsxs14(Text15, { bold: true, children: [
|
|
4008
3629
|
"v",
|
|
4009
3630
|
upgradeCheck.current
|
|
4010
3631
|
] }),
|
|
4011
3632
|
"). Exit this program, cd into the root of your local clone of contentful/experience-design-system-sdk-public, then run:"
|
|
4012
3633
|
] }),
|
|
4013
|
-
/* @__PURE__ */
|
|
4014
|
-
/* @__PURE__ */
|
|
3634
|
+
/* @__PURE__ */ jsx16(Text15, { children: " " }),
|
|
3635
|
+
/* @__PURE__ */ jsx16(Box14, { flexDirection: "column", borderStyle: "round", borderColor: PALETTE.border, paddingX: 1, children: UPGRADE_COMMANDS.map((cmd) => /* @__PURE__ */ jsx16(Text15, { bold: true, children: cmd }, cmd)) })
|
|
4015
3636
|
] });
|
|
4016
3637
|
}
|
|
4017
3638
|
|
|
4018
3639
|
// packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
|
|
4019
|
-
import { useEffect as
|
|
4020
|
-
import { Box as
|
|
4021
|
-
import { jsx as
|
|
3640
|
+
import { useEffect as useEffect9, useState as useState13 } from "react";
|
|
3641
|
+
import { Box as Box15, Text as Text16, useInput as useInput14 } from "ink";
|
|
3642
|
+
import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
4022
3643
|
function DebugModeScreen({ onDone }) {
|
|
4023
|
-
const [loading, setLoading] =
|
|
4024
|
-
const [enabled, setEnabled] =
|
|
4025
|
-
|
|
3644
|
+
const [loading, setLoading] = useState13(true);
|
|
3645
|
+
const [enabled, setEnabled] = useState13(true);
|
|
3646
|
+
useEffect9(() => {
|
|
4026
3647
|
readDebugModeSetting().then((setting) => {
|
|
4027
3648
|
setEnabled(setting.enabled);
|
|
4028
3649
|
setLoading(false);
|
|
@@ -4034,7 +3655,7 @@ function DebugModeScreen({ onDone }) {
|
|
|
4034
3655
|
});
|
|
4035
3656
|
});
|
|
4036
3657
|
}, []);
|
|
4037
|
-
|
|
3658
|
+
useInput14((input, key) => {
|
|
4038
3659
|
if (loading) return;
|
|
4039
3660
|
if (key.return || input === " ") {
|
|
4040
3661
|
setEnabled((current) => {
|
|
@@ -4049,16 +3670,16 @@ function DebugModeScreen({ onDone }) {
|
|
|
4049
3670
|
onDone();
|
|
4050
3671
|
}
|
|
4051
3672
|
});
|
|
4052
|
-
return /* @__PURE__ */
|
|
4053
|
-
/* @__PURE__ */
|
|
4054
|
-
/* @__PURE__ */
|
|
4055
|
-
loading ? /* @__PURE__ */
|
|
3673
|
+
return /* @__PURE__ */ jsxs15(Box15, { flexDirection: "column", paddingX: 2, paddingY: 1, children: [
|
|
3674
|
+
/* @__PURE__ */ jsx17(Text16, { bold: true, children: "Settings \u203A Debug Mode" }),
|
|
3675
|
+
/* @__PURE__ */ jsx17(Text16, { children: " " }),
|
|
3676
|
+
loading ? /* @__PURE__ */ jsx17(Text16, { color: PALETTE.muted, children: "Loading\u2026" }) : /* @__PURE__ */ jsxs15(Text16, { children: [
|
|
4056
3677
|
"Debug logging:",
|
|
4057
3678
|
" ",
|
|
4058
|
-
/* @__PURE__ */
|
|
3679
|
+
/* @__PURE__ */ jsx17(Text16, { bold: true, color: enabled ? PALETTE.success : PALETTE.muted, children: enabled ? "On" : "Off" })
|
|
4059
3680
|
] }),
|
|
4060
|
-
/* @__PURE__ */
|
|
4061
|
-
/* @__PURE__ */
|
|
3681
|
+
/* @__PURE__ */ jsx17(Text16, { children: " " }),
|
|
3682
|
+
/* @__PURE__ */ jsx17(
|
|
4062
3683
|
ControlHints,
|
|
4063
3684
|
{
|
|
4064
3685
|
hints: [
|
|
@@ -4071,16 +3692,17 @@ function DebugModeScreen({ onDone }) {
|
|
|
4071
3692
|
}
|
|
4072
3693
|
|
|
4073
3694
|
// packages/experience-design-system-cli/app.tsx
|
|
4074
|
-
import { Fragment as Fragment5, jsx as
|
|
4075
|
-
function App({ onLaunchImport, importExitCode }) {
|
|
3695
|
+
import { Fragment as Fragment5, jsx as jsx18 } from "react/jsx-runtime";
|
|
3696
|
+
function App({ importOptions, onLaunchImport, importExitCode }) {
|
|
4076
3697
|
const returnedFromImport = importExitCode !== void 0;
|
|
4077
|
-
const [screen, setScreen] =
|
|
4078
|
-
const [showImportResult, setShowImportResult] =
|
|
4079
|
-
const [projectPath, setProjectPath] =
|
|
4080
|
-
const [tokensPath, setTokensPath] =
|
|
4081
|
-
const [scannedFiles, setScannedFiles] =
|
|
4082
|
-
const [
|
|
4083
|
-
|
|
3698
|
+
const [screen, setScreen] = useState14(returnedFromImport ? "import" : "start");
|
|
3699
|
+
const [showImportResult, setShowImportResult] = useState14(returnedFromImport);
|
|
3700
|
+
const [projectPath, setProjectPath] = useState14();
|
|
3701
|
+
const [tokensPath, setTokensPath] = useState14();
|
|
3702
|
+
const [scannedFiles, setScannedFiles] = useState14();
|
|
3703
|
+
const [pendingLaunch, setPendingLaunch] = useState14();
|
|
3704
|
+
const [importDefaults, setImportDefaults] = useState14();
|
|
3705
|
+
useEffect10(() => {
|
|
4084
3706
|
if (screen !== "import") {
|
|
4085
3707
|
setImportDefaults(void 0);
|
|
4086
3708
|
return;
|
|
@@ -4095,7 +3717,27 @@ function App({ onLaunchImport, importExitCode }) {
|
|
|
4095
3717
|
}, [screen]);
|
|
4096
3718
|
const finishCredentials = async (result, projectPath2, tokens, filePaths) => {
|
|
4097
3719
|
if (!result.skipped) await writeCredentials({ ...result.credentials });
|
|
4098
|
-
|
|
3720
|
+
const launch = {
|
|
3721
|
+
projectPath: projectPath2,
|
|
3722
|
+
tokens,
|
|
3723
|
+
filePaths,
|
|
3724
|
+
skipCredentials: result.skipped,
|
|
3725
|
+
...importOptions
|
|
3726
|
+
};
|
|
3727
|
+
const state = await inspectTokens({
|
|
3728
|
+
rawTokensPath: tokens,
|
|
3729
|
+
outDir: join7(resolveUserPath(projectPath2), ".contentful"),
|
|
3730
|
+
cache: importOptions.cache
|
|
3731
|
+
});
|
|
3732
|
+
if (state.kind === "cached") {
|
|
3733
|
+
setPendingLaunch({ launch, cached: { tokensPath: state.tokensPath, sourceChanged: state.sourceChanged } });
|
|
3734
|
+
return;
|
|
3735
|
+
}
|
|
3736
|
+
onLaunchImport?.({ ...launch, tokenStrategy: "generate" });
|
|
3737
|
+
};
|
|
3738
|
+
const chooseTokenStrategy = (pending, tokenStrategy) => {
|
|
3739
|
+
setPendingLaunch(void 0);
|
|
3740
|
+
onLaunchImport?.({ ...pending.launch, tokenStrategy });
|
|
4099
3741
|
};
|
|
4100
3742
|
const goToStart = () => setScreen("start");
|
|
4101
3743
|
const goToSettings = () => setScreen("settings");
|
|
@@ -4103,6 +3745,7 @@ function App({ onLaunchImport, importExitCode }) {
|
|
|
4103
3745
|
setProjectPath(void 0);
|
|
4104
3746
|
setTokensPath(void 0);
|
|
4105
3747
|
setScannedFiles(void 0);
|
|
3748
|
+
setPendingLaunch(void 0);
|
|
4106
3749
|
};
|
|
4107
3750
|
const finishImportResult = () => {
|
|
4108
3751
|
setShowImportResult(false);
|
|
@@ -4115,13 +3758,13 @@ function App({ onLaunchImport, importExitCode }) {
|
|
|
4115
3758
|
};
|
|
4116
3759
|
switch (screen) {
|
|
4117
3760
|
case "import":
|
|
4118
|
-
if (showImportResult) return /* @__PURE__ */
|
|
4119
|
-
if (importDefaults === void 0) return /* @__PURE__ */
|
|
3761
|
+
if (showImportResult) return /* @__PURE__ */ jsx18(ImportScreen, { exitCode: importExitCode, onDone: finishImportResult });
|
|
3762
|
+
if (importDefaults === void 0) return /* @__PURE__ */ jsx18(Fragment5, {});
|
|
4120
3763
|
if (projectPath === void 0) {
|
|
4121
|
-
return /* @__PURE__ */
|
|
3764
|
+
return /* @__PURE__ */ jsx18(WelcomeScreen, { onContinue: setProjectPath, onQuit: leaveImport, initialPath: importDefaults.componentDir });
|
|
4122
3765
|
}
|
|
4123
3766
|
if (tokensPath === void 0) {
|
|
4124
|
-
return /* @__PURE__ */
|
|
3767
|
+
return /* @__PURE__ */ jsx18(
|
|
4125
3768
|
TokenInputScreen,
|
|
4126
3769
|
{
|
|
4127
3770
|
initialPath: importDefaults.tokenFile,
|
|
@@ -4131,7 +3774,7 @@ function App({ onLaunchImport, importExitCode }) {
|
|
|
4131
3774
|
);
|
|
4132
3775
|
}
|
|
4133
3776
|
if (scannedFiles === void 0) {
|
|
4134
|
-
return /* @__PURE__ */
|
|
3777
|
+
return /* @__PURE__ */ jsx18(
|
|
4135
3778
|
PathValidationScreen,
|
|
4136
3779
|
{
|
|
4137
3780
|
projectPath,
|
|
@@ -4141,7 +3784,19 @@ function App({ onLaunchImport, importExitCode }) {
|
|
|
4141
3784
|
}
|
|
4142
3785
|
);
|
|
4143
3786
|
}
|
|
4144
|
-
|
|
3787
|
+
if (pendingLaunch?.cached) {
|
|
3788
|
+
return /* @__PURE__ */ jsx18(
|
|
3789
|
+
TokenReuseScreen,
|
|
3790
|
+
{
|
|
3791
|
+
tokensPath: pendingLaunch.cached.tokensPath,
|
|
3792
|
+
sourceChanged: pendingLaunch.cached.sourceChanged,
|
|
3793
|
+
onReuse: () => chooseTokenStrategy(pendingLaunch, "reuse"),
|
|
3794
|
+
onRegenerate: () => chooseTokenStrategy(pendingLaunch, "regenerate"),
|
|
3795
|
+
onQuit: leaveImport
|
|
3796
|
+
}
|
|
3797
|
+
);
|
|
3798
|
+
}
|
|
3799
|
+
return /* @__PURE__ */ jsx18(
|
|
4145
3800
|
CredentialsScreen,
|
|
4146
3801
|
{
|
|
4147
3802
|
initial: importDefaults.credentials,
|
|
@@ -4150,28 +3805,29 @@ function App({ onLaunchImport, importExitCode }) {
|
|
|
4150
3805
|
}
|
|
4151
3806
|
);
|
|
4152
3807
|
case "help":
|
|
4153
|
-
return /* @__PURE__ */
|
|
3808
|
+
return /* @__PURE__ */ jsx18(HelpScreen, { onDone: goToStart });
|
|
4154
3809
|
case "upgrade":
|
|
4155
|
-
return /* @__PURE__ */
|
|
3810
|
+
return /* @__PURE__ */ jsx18(UpgradeScreen, { onDone: goToStart });
|
|
4156
3811
|
case "settings":
|
|
4157
|
-
return /* @__PURE__ */
|
|
3812
|
+
return /* @__PURE__ */ jsx18(SettingsScreen, { onNavigate: setScreen, onBack: goToStart });
|
|
4158
3813
|
case "settings-configuration":
|
|
4159
|
-
return /* @__PURE__ */
|
|
3814
|
+
return /* @__PURE__ */ jsx18(ConfigurationScreen, { onDone: goToSettings });
|
|
4160
3815
|
case "settings-opt-in-analytics":
|
|
4161
|
-
return /* @__PURE__ */
|
|
3816
|
+
return /* @__PURE__ */ jsx18(OptInAnalyticsScreen, { onDone: goToSettings });
|
|
4162
3817
|
case "settings-debug-mode":
|
|
4163
|
-
return /* @__PURE__ */
|
|
3818
|
+
return /* @__PURE__ */ jsx18(DebugModeScreen, { onDone: goToSettings });
|
|
4164
3819
|
case "start":
|
|
4165
|
-
return /* @__PURE__ */
|
|
3820
|
+
return /* @__PURE__ */ jsx18(HomeScreen, { onNavigate: setScreen });
|
|
4166
3821
|
}
|
|
4167
3822
|
}
|
|
4168
3823
|
var CLEAR_SCREEN = "\x1B[2J\x1B[H";
|
|
4169
|
-
async function renderUntilImportRequestedOrExit(renderApp, importExitCode) {
|
|
3824
|
+
async function renderUntilImportRequestedOrExit(renderApp, importOptions, importExitCode) {
|
|
4170
3825
|
let requestedImport;
|
|
4171
3826
|
const instance = renderApp(
|
|
4172
|
-
/* @__PURE__ */
|
|
3827
|
+
/* @__PURE__ */ jsx18(
|
|
4173
3828
|
App,
|
|
4174
3829
|
{
|
|
3830
|
+
importOptions,
|
|
4175
3831
|
importExitCode,
|
|
4176
3832
|
onLaunchImport: (options) => {
|
|
4177
3833
|
requestedImport = options;
|
|
@@ -4187,13 +3843,13 @@ async function renderUntilImportRequestedOrExit(renderApp, importExitCode) {
|
|
|
4187
3843
|
}
|
|
4188
3844
|
return requestedImport;
|
|
4189
3845
|
}
|
|
4190
|
-
async function runApp(renderApp) {
|
|
3846
|
+
async function runApp(renderApp, importOptions) {
|
|
4191
3847
|
let importExitCode;
|
|
4192
|
-
let requestedImport = await renderUntilImportRequestedOrExit(renderApp, importExitCode);
|
|
3848
|
+
let requestedImport = await renderUntilImportRequestedOrExit(renderApp, importOptions, importExitCode);
|
|
4193
3849
|
while (requestedImport !== void 0) {
|
|
4194
3850
|
importExitCode = (await spawnV1Import(requestedImport)).exitCode;
|
|
4195
3851
|
startReadingTerminal();
|
|
4196
|
-
requestedImport = await renderUntilImportRequestedOrExit(renderApp, importExitCode);
|
|
3852
|
+
requestedImport = await renderUntilImportRequestedOrExit(renderApp, importOptions, importExitCode);
|
|
4197
3853
|
}
|
|
4198
3854
|
}
|
|
4199
3855
|
export {
|