@contentful/experience-design-system-cli 2.23.2-dev-build-09d87bb.0 → 2.23.2-dev-build-753ceef.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.
Files changed (69) hide show
  1. package/README.md +24 -2
  2. package/dist/package.json +2 -1
  3. package/dist/src/analytics/apply.d.ts +6 -0
  4. package/dist/src/analytics/apply.js +30 -0
  5. package/dist/src/analytics/client.d.ts +7 -0
  6. package/dist/src/analytics/client.js +68 -0
  7. package/dist/src/analytics/constants.d.ts +4 -0
  8. package/dist/src/analytics/constants.js +4 -0
  9. package/dist/src/analytics/env.d.ts +4 -0
  10. package/dist/src/analytics/env.js +14 -0
  11. package/dist/src/analytics/exit.d.ts +5 -0
  12. package/dist/src/analytics/exit.js +24 -0
  13. package/dist/src/analytics/index.d.ts +10 -0
  14. package/dist/src/analytics/index.js +9 -0
  15. package/dist/src/analytics/normalize.d.ts +3 -0
  16. package/dist/src/analytics/normalize.js +18 -0
  17. package/dist/src/analytics/os.d.ts +2 -0
  18. package/dist/src/analytics/os.js +13 -0
  19. package/dist/src/analytics/session.d.ts +3 -0
  20. package/dist/src/analytics/session.js +15 -0
  21. package/dist/src/analytics/tracker.d.ts +17 -0
  22. package/dist/src/analytics/tracker.js +126 -0
  23. package/dist/src/analytics/types.d.ts +28 -0
  24. package/dist/src/analytics/types.js +1 -0
  25. package/dist/src/analyze/command.js +8 -2
  26. package/dist/src/analyze/select/command.js +13 -9
  27. package/dist/src/analyze/select/tui/App.js +1 -4
  28. package/dist/src/analyze/select-agent/command.js +14 -11
  29. package/dist/src/apply/api-client.d.ts +5 -5
  30. package/dist/src/apply/api-client.js +18 -8
  31. package/dist/src/apply/command.d.ts +1 -1
  32. package/dist/src/apply/command.js +81 -77
  33. package/dist/src/apply/preview-utils.d.ts +1 -5
  34. package/dist/src/apply/preview-utils.js +1 -5
  35. package/dist/src/apply/tui/ServerApplyView.d.ts +3 -6
  36. package/dist/src/apply/tui/ServerApplyView.js +6 -15
  37. package/dist/src/apply/tui/ServerPreviewView.d.ts +1 -2
  38. package/dist/src/apply/tui/ServerPreviewView.js +3 -3
  39. package/dist/src/generate/command.js +15 -9
  40. package/dist/src/generate/edit/command.js +1 -0
  41. package/dist/src/import/command.js +1 -6
  42. package/dist/src/import/orchestrator.d.ts +0 -1
  43. package/dist/src/import/orchestrator.js +18 -14
  44. package/dist/src/import/tui/WizardApp.d.ts +1 -2
  45. package/dist/src/import/tui/WizardApp.js +8 -8
  46. package/dist/src/import/tui/final-review-host.d.ts +1 -2
  47. package/dist/src/import/tui/final-review-host.js +2 -2
  48. package/dist/src/import/tui/runLivePreview.d.ts +0 -3
  49. package/dist/src/import/tui/runLivePreview.js +1 -4
  50. package/dist/src/import/tui/steps/GenerateReviewStep.d.ts +1 -2
  51. package/dist/src/import/tui/steps/GenerateReviewStep.js +3 -3
  52. package/dist/src/import/tui/steps/WizardPreviewStep.d.ts +2 -6
  53. package/dist/src/import/tui/steps/WizardPreviewStep.js +3 -12
  54. package/dist/src/import/tui/useFinalizePreview.d.ts +0 -2
  55. package/dist/src/import/tui/useFinalizePreview.js +0 -0
  56. package/dist/src/import/tui/useLivePreview.d.ts +0 -2
  57. package/dist/src/import/tui/useLivePreview.js +0 -1
  58. package/dist/src/index.js +6 -1
  59. package/dist/src/lib/command-options.d.ts +0 -1
  60. package/dist/src/lib/command-options.js +0 -3
  61. package/dist/src/print/command.js +16 -13
  62. package/dist/src/program.js +8 -1
  63. package/dist/src/runs/modify-launcher.d.ts +0 -2
  64. package/dist/src/runs/modify-launcher.js +0 -2
  65. package/dist/src/runs/push-helpers.d.ts +0 -1
  66. package/dist/src/runs/push-helpers.js +0 -3
  67. package/dist/src/runs/replay-helpers.d.ts +0 -4
  68. package/dist/src/runs/replay-helpers.js +0 -3
  69. package/package.json +6 -5
@@ -8,9 +8,10 @@ import { validateDTCGTokenFile } from './validate/validators/dtcg-validator.js';
8
8
  import { formatDiagnostics } from './validate/validators/format-errors.js';
9
9
  import { ValidateView } from './validate/tui/ValidateView.js';
10
10
  import { getInteractiveTerminalSupport } from '../lib/terminal-capabilities.js';
11
- function die(message) {
11
+ import { bindAnalyticsSessionId, exitWithAnalytics } from '../analytics/index.js';
12
+ async function die(message) {
12
13
  process.stderr.write(`${message}\n`);
13
- process.exit(1);
14
+ return exitWithAnalytics(1);
14
15
  }
15
16
  async function pathExists(p) {
16
17
  return access(p)
@@ -21,16 +22,16 @@ async function assertOutIsNotDirectory(outPath) {
21
22
  if (await pathExists(outPath)) {
22
23
  const s = await stat(outPath);
23
24
  if (s.isDirectory())
24
- die(`Error: --out must be a file path, not a directory: ${outPath}`);
25
+ await die(`Error: --out must be a file path, not a directory: ${outPath}`);
25
26
  }
26
27
  }
27
- function resolveSession(sessionFlag, command) {
28
+ async function resolveSession(sessionFlag, command) {
28
29
  const db = openPipelineDb();
29
30
  try {
30
31
  const sessionId = sessionFlag ?? findLatestSessionForCommand(db, command);
31
32
  if (!sessionId) {
32
33
  const hint = command === 'generate components' ? 'generate components' : 'generate tokens';
33
- die(`Error: no completed ${hint} session found. Run ${hint} first, or pass --session <id>.`);
34
+ return await die(`Error: no completed ${hint} session found. Run ${hint} first, or pass --session <id>.`);
34
35
  }
35
36
  return sessionId;
36
37
  }
@@ -85,7 +86,8 @@ export function registerPrintCommand(program) {
85
86
  .action(async (opts) => {
86
87
  const outPath = resolve(opts.out);
87
88
  await assertOutIsNotDirectory(outPath);
88
- const sessionId = resolveSession(opts.session, 'generate components');
89
+ const sessionId = await resolveSession(opts.session, 'generate components');
90
+ await bindAnalyticsSessionId(sessionId);
89
91
  const db = openPipelineDb();
90
92
  let components;
91
93
  let generateStepStatus = null;
@@ -110,13 +112,13 @@ export function registerPrintCommand(program) {
110
112
  // component was rejected or left unresolved. This is a legitimate
111
113
  // "clear the space" intent, but it's destructive, so require --allow-empty.
112
114
  if (!opts.allowEmpty) {
113
- die(`Error: all ${rejectedCount} generated component${rejectedCount === 1 ? ' was' : 's were'} rejected or left unresolved at final review in session '${sessionId}', so there is nothing to save. Accept at least one component (press [a] on a row, or [A] to accept all), or pass --allow-empty to write an empty manifest that will DELETE all components from the target space on push.`);
115
+ await die(`Error: all ${rejectedCount} generated component${rejectedCount === 1 ? ' was' : 's were'} rejected or left unresolved at final review in session '${sessionId}', so there is nothing to save. Accept at least one component (press [a] on a row, or [A] to accept all), or pass --allow-empty to write an empty manifest that will DELETE all components from the target space on push.`);
114
116
  }
115
117
  // Fall through: write an empty-but-present components manifest so a
116
118
  // subsequent push removes every component from the target space.
117
119
  }
118
120
  else {
119
- die(`Error: no generated components in session '${sessionId}'. Run generate components first.`);
121
+ await die(`Error: no generated components in session '${sessionId}'. Run generate components first.`);
120
122
  }
121
123
  }
122
124
  if (generateStepStatus === 'failed') {
@@ -145,7 +147,8 @@ export function registerPrintCommand(program) {
145
147
  .action(async (opts) => {
146
148
  const outPath = resolve(opts.out);
147
149
  await assertOutIsNotDirectory(outPath);
148
- const sessionId = resolveSession(opts.session, 'generate tokens');
150
+ const sessionId = await resolveSession(opts.session, 'generate tokens');
151
+ await bindAnalyticsSessionId(sessionId);
149
152
  const db = openPipelineDb();
150
153
  let result;
151
154
  try {
@@ -155,7 +158,7 @@ export function registerPrintCommand(program) {
155
158
  db.close();
156
159
  }
157
160
  if (result.tokens.length === 0) {
158
- die(`Error: no generated tokens in session '${sessionId}'. Run generate tokens first.`);
161
+ await die(`Error: no generated tokens in session '${sessionId}'. Run generate tokens first.`);
159
162
  }
160
163
  const tree = rebuildDTCGTree(result.groups, result.tokens);
161
164
  await mkdir(resolve(outPath, '..'), { recursive: true });
@@ -171,7 +174,7 @@ export function registerPrintCommand(program) {
171
174
  .action(async (opts) => {
172
175
  if (!opts.components && !opts.tokens) {
173
176
  process.stderr.write('Error: at least one of --components or --tokens is required.\n\nUsage: print validate [--components <path>] [--tokens <path>]\n');
174
- process.exit(1);
177
+ await exitWithAnalytics(1);
175
178
  }
176
179
  const viewResults = [];
177
180
  if (opts.components) {
@@ -199,7 +202,7 @@ export function registerPrintCommand(program) {
199
202
  if (getInteractiveTerminalSupport().supported) {
200
203
  const { waitUntilExit } = render(createElement(ValidateView, {
201
204
  results: viewResults,
202
- onExit: () => process.exit(exitCode),
205
+ onExit: () => void exitWithAnalytics(exitCode),
203
206
  }));
204
207
  await waitUntilExit();
205
208
  }
@@ -212,7 +215,7 @@ export function registerPrintCommand(program) {
212
215
  }))
213
216
  .join('\n\n');
214
217
  process.stdout.write(output + '\n');
215
- process.exit(exitCode);
218
+ await exitWithAnalytics(exitCode);
216
219
  }
217
220
  });
218
221
  }
@@ -12,6 +12,7 @@ import { registerImportCommand } from './import/command.js';
12
12
  import { registerSetupCommand } from './setup/command.js';
13
13
  import { registerRunsCommand } from './runs/ls-command.js';
14
14
  import { beginCommand } from './lib/debug-preamble.js';
15
+ import { completeActiveCommand, flushAnalytics, noteCommandStart } from './analytics/index.js';
15
16
  const require = createRequire(import.meta.url);
16
17
  const pkg = require('../package.json');
17
18
  /**
@@ -89,7 +90,13 @@ export function createProgram() {
89
90
  const chain = [];
90
91
  for (let c = actionCommand; c && c.parent; c = c.parent)
91
92
  chain.unshift(c.name());
92
- await beginCommand(chain.join(' ') || actionCommand.name(), { ...(debug !== undefined ? { debug } : {}) });
93
+ const commandChain = chain.join(' ') || actionCommand.name();
94
+ noteCommandStart(commandChain);
95
+ await beginCommand(commandChain, { ...(debug !== undefined ? { debug } : {}) });
96
+ });
97
+ program.hook('postAction', async () => {
98
+ await completeActiveCommand();
99
+ await flushAnalytics();
93
100
  });
94
101
  return program;
95
102
  }
@@ -26,7 +26,5 @@ export type ModifyLauncherInput = {
26
26
  initialHost?: string;
27
27
  /** Pre-fill CMA token (from credentials.json / env). */
28
28
  initialCmaToken?: string;
29
- /** From `--allow-deletions` flag. Forwarded to wizard's push step. */
30
- allowDeletions?: boolean;
31
29
  };
32
30
  export declare function launchModifyWizard(input: ModifyLauncherInput): Promise<void>;
@@ -35,8 +35,6 @@ export async function launchModifyWizard(input) {
35
35
  props.initialHost = input.initialHost;
36
36
  if (input.initialCmaToken)
37
37
  props.initialCmaToken = input.initialCmaToken;
38
- if (input.allowDeletions !== undefined)
39
- props.allowDeletions = input.allowDeletions;
40
38
  const { waitUntilExit } = render(createElement(WizardApp, props));
41
39
  await waitUntilExit();
42
40
  }
@@ -15,7 +15,6 @@ export type PushSessionOptions = {
15
15
  environmentId: string;
16
16
  cmaToken: string;
17
17
  host?: string;
18
- allowDeletions?: boolean;
19
18
  };
20
19
  /**
21
20
  * Push a recorded pipeline.db session's components + tokens to Contentful by
@@ -60,9 +60,6 @@ export async function pushRunSession(opts) {
60
60
  if (opts.host) {
61
61
  args.push('--host', opts.host);
62
62
  }
63
- if (opts.allowDeletions) {
64
- args.push('--allow-deletions');
65
- }
66
63
  const r = await runCli(args);
67
64
  if (r.exitCode === 0)
68
65
  return { ok: true };
@@ -16,8 +16,6 @@ export type ReplayRunOptions = {
16
16
  interactive?: boolean;
17
17
  /** When true, bypass the source/saved-file staleness check. */
18
18
  force?: boolean;
19
- /** From `--allow-deletions` flag. Forwarded verbatim to the pushed session's apply request. */
20
- allowDeletions?: boolean;
21
19
  /**
22
20
  * Test seam: replace the interactive prompt with a deterministic resolver.
23
21
  * The CLI surface never sets this; only used by tests.
@@ -59,8 +57,6 @@ export type ModifyRunOptions = {
59
57
  outDir?: string;
60
58
  /** When true, bypass the source/saved-file staleness check. */
61
59
  force?: boolean;
62
- /** From `--allow-deletions` flag. Forwarded through the modify wizard's push step. */
63
- allowDeletions?: boolean;
64
60
  };
65
61
  /**
66
62
  * Re-open the wizard with a prior run's extract/generate session pre-populated
@@ -83,7 +83,6 @@ export async function replayRun(opts) {
83
83
  environmentId,
84
84
  cmaToken,
85
85
  ...(host ? { host } : {}),
86
- ...(opts.allowDeletions ? { allowDeletions: true } : {}),
87
86
  });
88
87
  if (!result.ok) {
89
88
  throw new Error(result.error);
@@ -99,7 +98,6 @@ export async function replayRun(opts) {
99
98
  environmentId,
100
99
  cmaToken,
101
100
  ...(host ? { host } : {}),
102
- ...(opts.allowDeletions ? { allowDeletions: true } : {}),
103
101
  });
104
102
  if (!tokenResult.ok) {
105
103
  throw new Error(tokenResult.error);
@@ -159,6 +157,5 @@ export async function modifyRun(opts) {
159
157
  ...(mergedEnvironmentId ? { initialEnvironmentId: mergedEnvironmentId } : {}),
160
158
  ...(mergedHost ? { initialHost: mergedHost } : {}),
161
159
  ...(mergedCmaToken ? { initialCmaToken: mergedCmaToken } : {}),
162
- ...(opts.allowDeletions !== undefined ? { allowDeletions: opts.allowDeletions } : {}),
163
160
  });
164
161
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-cli",
3
- "version": "2.23.2-dev-build-09d87bb.0",
3
+ "version": "2.23.2-dev-build-753ceef.0",
4
4
  "description": "Contentful Experiences design system import CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -28,15 +28,16 @@
28
28
  "prompts/"
29
29
  ],
30
30
  "dependencies": {
31
+ "@segment/analytics-node": "^3.0.0",
31
32
  "commander": "^13.1.0",
32
33
  "ink": "^4.4.1",
33
34
  "react": "^18.3.1",
34
35
  "react-devtools-core": "^4.19.1",
35
36
  "react-dom": "^18.3.1",
36
- "@contentful/experience-design-system-client": "2.23.2-dev-build-09d87bb.0",
37
- "@contentful/experience-design-system-generation": "2.23.2-dev-build-09d87bb.0",
38
- "@contentful/experience-design-system-types": "2.23.2-dev-build-09d87bb.0",
39
- "@contentful/experience-design-system-extraction": "2.23.2-dev-build-09d87bb.0"
37
+ "@contentful/experience-design-system-client": "2.23.2-dev-build-753ceef.0",
38
+ "@contentful/experience-design-system-extraction": "2.23.2-dev-build-753ceef.0",
39
+ "@contentful/experience-design-system-types": "2.23.2-dev-build-753ceef.0",
40
+ "@contentful/experience-design-system-generation": "2.23.2-dev-build-753ceef.0"
40
41
  },
41
42
  "devDependencies": {
42
43
  "@tsconfig/node24": "^24.0.4",