@contentful/experience-design-system-cli 2.23.2-dev-build-753ceef.0 → 2.23.2-dev-build-d882174.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/README.md +2 -24
- package/dist/package.json +2 -3
- package/dist/src/analyze/command.js +2 -8
- package/dist/src/analyze/select/command.js +9 -13
- package/dist/src/analyze/select/tui/App.js +4 -1
- package/dist/src/analyze/select-agent/command.js +11 -14
- package/dist/src/apply/api-client.d.ts +5 -5
- package/dist/src/apply/api-client.js +8 -18
- package/dist/src/apply/command.d.ts +1 -1
- package/dist/src/apply/command.js +77 -81
- package/dist/src/apply/preview-utils.d.ts +5 -1
- package/dist/src/apply/preview-utils.js +5 -1
- package/dist/src/apply/tui/ServerApplyView.d.ts +6 -3
- package/dist/src/apply/tui/ServerApplyView.js +15 -6
- package/dist/src/apply/tui/ServerPreviewView.d.ts +2 -1
- package/dist/src/apply/tui/ServerPreviewView.js +3 -3
- package/dist/src/generate/command.js +9 -15
- package/dist/src/generate/edit/command.js +0 -1
- package/dist/src/import/command.js +6 -1
- package/dist/src/import/orchestrator.d.ts +1 -0
- package/dist/src/import/orchestrator.js +14 -18
- package/dist/src/import/tui/WizardApp.d.ts +2 -1
- package/dist/src/import/tui/WizardApp.js +8 -8
- package/dist/src/import/tui/final-review-host.d.ts +2 -1
- package/dist/src/import/tui/final-review-host.js +2 -2
- package/dist/src/import/tui/runLivePreview.d.ts +3 -0
- package/dist/src/import/tui/runLivePreview.js +4 -1
- package/dist/src/import/tui/steps/GenerateReviewStep.d.ts +2 -1
- package/dist/src/import/tui/steps/GenerateReviewStep.js +3 -3
- package/dist/src/import/tui/steps/WizardPreviewStep.d.ts +6 -2
- package/dist/src/import/tui/steps/WizardPreviewStep.js +12 -3
- package/dist/src/import/tui/useFinalizePreview.d.ts +2 -0
- package/dist/src/import/tui/useFinalizePreview.js +0 -0
- package/dist/src/import/tui/useLivePreview.d.ts +2 -0
- package/dist/src/import/tui/useLivePreview.js +1 -0
- package/dist/src/index.js +1 -6
- package/dist/src/lib/command-options.d.ts +1 -0
- package/dist/src/lib/command-options.js +3 -0
- package/dist/src/print/command.js +13 -16
- package/dist/src/program.js +1 -8
- package/dist/src/runs/modify-launcher.d.ts +2 -0
- package/dist/src/runs/modify-launcher.js +2 -0
- package/dist/src/runs/push-helpers.d.ts +1 -0
- package/dist/src/runs/push-helpers.js +3 -0
- package/dist/src/runs/replay-helpers.d.ts +4 -0
- package/dist/src/runs/replay-helpers.js +3 -0
- package/package.json +6 -7
- package/dist/src/analytics/apply.d.ts +0 -6
- package/dist/src/analytics/apply.js +0 -30
- package/dist/src/analytics/client.d.ts +0 -7
- package/dist/src/analytics/client.js +0 -68
- package/dist/src/analytics/constants.d.ts +0 -4
- package/dist/src/analytics/constants.js +0 -4
- package/dist/src/analytics/env.d.ts +0 -4
- package/dist/src/analytics/env.js +0 -14
- package/dist/src/analytics/exit.d.ts +0 -5
- package/dist/src/analytics/exit.js +0 -24
- package/dist/src/analytics/index.d.ts +0 -10
- package/dist/src/analytics/index.js +0 -9
- package/dist/src/analytics/normalize.d.ts +0 -3
- package/dist/src/analytics/normalize.js +0 -18
- package/dist/src/analytics/os.d.ts +0 -2
- package/dist/src/analytics/os.js +0 -13
- package/dist/src/analytics/session.d.ts +0 -3
- package/dist/src/analytics/session.js +0 -15
- package/dist/src/analytics/tracker.d.ts +0 -17
- package/dist/src/analytics/tracker.js +0 -126
- package/dist/src/analytics/types.d.ts +0 -28
- package/dist/src/analytics/types.js +0 -1
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { cliVersion, trackEvent } from './client.js';
|
|
2
|
-
import { IMPORT_PIPELINE_ENV } from './constants.js';
|
|
3
|
-
import { normalizeCommand } from './normalize.js';
|
|
4
|
-
import { getOsName } from './os.js';
|
|
5
|
-
import { resolveAnalyticsSessionId } from './session.js';
|
|
6
|
-
let pending = null;
|
|
7
|
-
let sessionId;
|
|
8
|
-
let sessionStartedEmitted = false;
|
|
9
|
-
function isPipelineStep() {
|
|
10
|
-
return process.env[IMPORT_PIPELINE_ENV] === '1';
|
|
11
|
-
}
|
|
12
|
-
function buildBaseProps(command) {
|
|
13
|
-
return {
|
|
14
|
-
dsi_session_id: sessionId,
|
|
15
|
-
command,
|
|
16
|
-
...(isPipelineStep() ? { is_pipeline_step: true } : {}),
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function mergeContext(target, source) {
|
|
20
|
-
if (source.space_key !== undefined)
|
|
21
|
-
target.space_key = source.space_key;
|
|
22
|
-
if (source.environment_key !== undefined)
|
|
23
|
-
target.environment_key = source.environment_key;
|
|
24
|
-
if (source.x_contentful_request_id !== undefined) {
|
|
25
|
-
target.x_contentful_request_id = source.x_contentful_request_id;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/** Record the start of a tracked command. Invoked is deferred until a session is bound. */
|
|
29
|
-
export function noteCommandStart(commandChain) {
|
|
30
|
-
const command = normalizeCommand(commandChain);
|
|
31
|
-
if (!command)
|
|
32
|
-
return;
|
|
33
|
-
pending = {
|
|
34
|
-
command,
|
|
35
|
-
startedAt: Date.now(),
|
|
36
|
-
invoked: false,
|
|
37
|
-
terminalEmitted: false,
|
|
38
|
-
context: {},
|
|
39
|
-
completion: {},
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
/** Bind a session id, preferring a pipeline parent id when present. */
|
|
43
|
-
export async function bindAnalyticsSessionId(sessionId, context) {
|
|
44
|
-
const id = resolveAnalyticsSessionId(sessionId);
|
|
45
|
-
await bindAnalyticsSession(id, context);
|
|
46
|
-
return id;
|
|
47
|
-
}
|
|
48
|
-
/** Attach Contentful target context for the active command. */
|
|
49
|
-
export function setCommandContext(context) {
|
|
50
|
-
if (!pending)
|
|
51
|
-
return;
|
|
52
|
-
mergeContext(pending.context, context);
|
|
53
|
-
mergeContext(pending.completion, context);
|
|
54
|
-
}
|
|
55
|
-
/** Merge optional completion fields before the terminal event fires. */
|
|
56
|
-
export function enrichCommandResult(fields) {
|
|
57
|
-
if (!pending)
|
|
58
|
-
return;
|
|
59
|
-
Object.assign(pending.completion, fields);
|
|
60
|
-
mergeContext(pending.context, fields);
|
|
61
|
-
}
|
|
62
|
-
export function getBoundSessionId() {
|
|
63
|
-
return sessionId;
|
|
64
|
-
}
|
|
65
|
-
/** Bind the pipeline session and emit invoked once both command and session are known. */
|
|
66
|
-
export async function bindAnalyticsSession(id, context) {
|
|
67
|
-
sessionId = id;
|
|
68
|
-
if (context)
|
|
69
|
-
setCommandContext(context);
|
|
70
|
-
await emitInvokedIfReady();
|
|
71
|
-
}
|
|
72
|
-
/** Emit session_started once per new pipeline head. */
|
|
73
|
-
export async function emitSessionStarted(entryCommand) {
|
|
74
|
-
if (!sessionId || sessionStartedEmitted)
|
|
75
|
-
return;
|
|
76
|
-
sessionStartedEmitted = true;
|
|
77
|
-
await trackEvent('dsi_cli_session_started', {
|
|
78
|
-
dsi_session_id: sessionId,
|
|
79
|
-
entry_command: entryCommand,
|
|
80
|
-
cli_version: cliVersion(),
|
|
81
|
-
node_version: process.version,
|
|
82
|
-
os_name: getOsName(),
|
|
83
|
-
}, sessionId, { flush: true });
|
|
84
|
-
await emitInvokedIfReady();
|
|
85
|
-
}
|
|
86
|
-
async function emitInvokedIfReady() {
|
|
87
|
-
if (!pending || pending.invoked || !sessionId)
|
|
88
|
-
return;
|
|
89
|
-
pending.invoked = true;
|
|
90
|
-
await trackEvent('dsi_cli_command_invoked', {
|
|
91
|
-
...buildBaseProps(pending.command),
|
|
92
|
-
...pending.context,
|
|
93
|
-
}, sessionId, { flush: true });
|
|
94
|
-
}
|
|
95
|
-
export async function completeActiveCommand() {
|
|
96
|
-
if (!pending || pending.terminalEmitted || !sessionId || !pending.invoked)
|
|
97
|
-
return;
|
|
98
|
-
pending.terminalEmitted = true;
|
|
99
|
-
const durationMs = Date.now() - pending.startedAt;
|
|
100
|
-
await trackEvent('dsi_cli_command_completed', {
|
|
101
|
-
...buildBaseProps(pending.command),
|
|
102
|
-
...pending.context,
|
|
103
|
-
...pending.completion,
|
|
104
|
-
outcome: 'ok',
|
|
105
|
-
duration_ms: durationMs,
|
|
106
|
-
}, sessionId, { flush: true });
|
|
107
|
-
}
|
|
108
|
-
export async function failActiveCommand(fields = {}) {
|
|
109
|
-
if (!pending || pending.terminalEmitted || !sessionId || !pending.invoked)
|
|
110
|
-
return;
|
|
111
|
-
pending.terminalEmitted = true;
|
|
112
|
-
const durationMs = Date.now() - pending.startedAt;
|
|
113
|
-
const outcome = fields.exit_code === 130 ? 'interrupted' : 'error';
|
|
114
|
-
await trackEvent('dsi_cli_command_failed', {
|
|
115
|
-
...buildBaseProps(pending.command),
|
|
116
|
-
...pending.context,
|
|
117
|
-
...fields,
|
|
118
|
-
outcome,
|
|
119
|
-
duration_ms: durationMs,
|
|
120
|
-
}, sessionId, { flush: true });
|
|
121
|
-
}
|
|
122
|
-
export function resetAnalyticsStateForTests() {
|
|
123
|
-
pending = null;
|
|
124
|
-
sessionId = undefined;
|
|
125
|
-
sessionStartedEmitted = false;
|
|
126
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/** Tracked CLI commands — closed set aligned with the published event schema. */
|
|
2
|
-
export type DsiCliCommand = 'analyze_extract' | 'analyze_select' | 'generate_components' | 'generate_tokens' | 'generate_edit' | 'apply_preview' | 'apply_select' | 'apply_push' | 'print_components' | 'print_tokens' | 'import';
|
|
3
|
-
export type EntryCommand = 'analyze_extract' | 'import';
|
|
4
|
-
export type OsName = 'macOS' | 'Linux' | 'Windows' | 'Android' | 'other';
|
|
5
|
-
export type WriteResult = {
|
|
6
|
-
created_count: number;
|
|
7
|
-
updated_count: number;
|
|
8
|
-
failed_count: number;
|
|
9
|
-
};
|
|
10
|
-
export type CommandContext = {
|
|
11
|
-
space_key?: string;
|
|
12
|
-
environment_key?: string;
|
|
13
|
-
x_contentful_request_id?: string;
|
|
14
|
-
};
|
|
15
|
-
export type CommandCompletion = CommandContext & {
|
|
16
|
-
dsi_operation_id?: string;
|
|
17
|
-
extracted_component_count?: number;
|
|
18
|
-
accepted_component_count?: number;
|
|
19
|
-
component_type_result?: WriteResult;
|
|
20
|
-
design_token_result?: WriteResult;
|
|
21
|
-
};
|
|
22
|
-
export type CommandFailure = CommandContext & {
|
|
23
|
-
dsi_operation_id?: string;
|
|
24
|
-
error_name?: string;
|
|
25
|
-
error_code?: string;
|
|
26
|
-
http_status_code?: number;
|
|
27
|
-
exit_code?: number;
|
|
28
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|