@reshotdev/screenshot 0.0.1-beta.2 → 0.0.1-beta.21

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 (81) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +138 -47
  3. package/package.json +27 -16
  4. package/src/commands/auth.js +159 -30
  5. package/src/commands/capture-dom.js +50 -0
  6. package/src/commands/certify.js +62 -0
  7. package/src/commands/compose.js +220 -0
  8. package/src/commands/doctor-release.js +74 -0
  9. package/src/commands/doctor-target.js +108 -0
  10. package/src/commands/drifts.js +16 -69
  11. package/src/commands/import-tests.js +13 -13
  12. package/src/commands/init.js +16 -277
  13. package/src/commands/publish.js +484 -257
  14. package/src/commands/pull.js +302 -35
  15. package/src/commands/refresh.js +166 -0
  16. package/src/commands/run.js +292 -12
  17. package/src/commands/setup-wizard.js +348 -496
  18. package/src/commands/status.js +334 -126
  19. package/src/commands/sync.js +28 -236
  20. package/src/commands/ui.js +1 -1
  21. package/src/commands/variation.js +194 -0
  22. package/src/commands/verify-publish.js +46 -0
  23. package/src/index.js +383 -118
  24. package/src/lib/api-client.js +172 -60
  25. package/src/lib/auto-update/refresh.js +598 -0
  26. package/src/lib/auto-update/scene-runtime.compose.tsx +73 -0
  27. package/src/lib/auto-update/spec.js +89 -0
  28. package/src/lib/capture-engine.js +179 -9
  29. package/src/lib/capture-script-runner.js +639 -214
  30. package/src/lib/certification.js +887 -0
  31. package/src/lib/compose-context.js +156 -0
  32. package/src/lib/compose-pack.js +42 -0
  33. package/src/lib/compose-runtime.js +34 -0
  34. package/src/lib/compose-upload.js +142 -0
  35. package/src/lib/config.js +186 -81
  36. package/src/lib/dom-capture.js +64 -0
  37. package/src/lib/ensure-browser.js +147 -0
  38. package/src/lib/output-path-template.js +3 -3
  39. package/src/lib/record-cdp.js +288 -16
  40. package/src/lib/record-clip.js +83 -3
  41. package/src/lib/record-config.js +1 -5
  42. package/src/lib/release-doctor.js +321 -0
  43. package/src/lib/resolve-targets.js +60 -0
  44. package/src/lib/run-manifest.js +148 -0
  45. package/src/lib/standalone-mode.js +1 -1
  46. package/src/lib/storage-providers.js +5 -5
  47. package/src/lib/style-engine.js +5 -5
  48. package/src/lib/target-contract.js +292 -0
  49. package/src/lib/ui-api-helpers.js +118 -0
  50. package/src/lib/ui-api.js +31 -824
  51. package/src/lib/ui-asset-cleanup.js +62 -0
  52. package/src/lib/ui-output-versions.js +165 -0
  53. package/src/lib/ui-recorder-routes.js +341 -0
  54. package/src/lib/ui-scenario-metadata.js +161 -0
  55. package/vendor/compose/dist/auto-update.cjs +5544 -0
  56. package/vendor/compose/dist/auto-update.mjs +5518 -0
  57. package/vendor/compose/dist/capture.cjs +1450 -0
  58. package/vendor/compose/dist/capture.mjs +1416 -0
  59. package/vendor/compose/dist/eligibility.cjs +5331 -0
  60. package/vendor/compose/dist/eligibility.mjs +5313 -0
  61. package/vendor/compose/dist/index.cjs +2046 -0
  62. package/vendor/compose/dist/index.mjs +1997 -0
  63. package/vendor/compose/dist/jsx-dev-runtime.cjs +55 -0
  64. package/vendor/compose/dist/jsx-dev-runtime.mjs +27 -0
  65. package/vendor/compose/dist/jsx-runtime.cjs +58 -0
  66. package/vendor/compose/dist/jsx-runtime.mjs +31 -0
  67. package/vendor/compose/dist/render.cjs +558 -0
  68. package/vendor/compose/dist/render.mjs +515 -0
  69. package/vendor/compose/dist/verify-cli.cjs +3806 -0
  70. package/vendor/compose/dist/verify-cli.mjs +3812 -0
  71. package/vendor/compose/dist/verify.cjs +3880 -0
  72. package/vendor/compose/dist/verify.mjs +3858 -0
  73. package/web/manager/dist/assets/index-D0S2otug.js +507 -0
  74. package/web/manager/dist/index.html +1 -1
  75. package/src/commands/ci-run.js +0 -123
  76. package/src/commands/ci-setup.js +0 -288
  77. package/src/commands/ingest.js +0 -458
  78. package/src/commands/setup.js +0 -137
  79. package/src/commands/validate-docs.js +0 -529
  80. package/src/lib/playwright-runner.js +0 -252
  81. package/web/manager/dist/assets/index--ZgioErz.js +0 -507
@@ -16,7 +16,7 @@
16
16
  document.documentElement.style.colorScheme = isDark ? 'dark' : 'light';
17
17
  })();
18
18
  </script>
19
- <script type="module" crossorigin src="/assets/index--ZgioErz.js"></script>
19
+ <script type="module" crossorigin src="/assets/index-D0S2otug.js"></script>
20
20
  <link rel="stylesheet" crossorigin href="/assets/index-n468W0Wr.css">
21
21
  </head>
22
22
  <body>
@@ -1,123 +0,0 @@
1
- // ci-run.js - Composite command: run + publish in one step (CI-optimized)
2
- const chalk = require("chalk");
3
- const fs = require("fs-extra");
4
- const path = require("path");
5
- const { detectCI, getCIMetadata } = require("../lib/ci-detect");
6
-
7
- async function ciRunCommand(options = {}) {
8
- const { config: configPath, tag, message, dryRun, publish: shouldPublish = true } = options;
9
-
10
- // Disable colors in CI for cleaner logs
11
- const { isCI, provider } = detectCI();
12
- if (isCI) {
13
- process.env.NO_COLOR = "1";
14
- }
15
-
16
- const ciMeta = getCIMetadata();
17
-
18
- console.log(chalk.cyan("šŸ¤– Reshot CI Run\n"));
19
- if (isCI) {
20
- console.log(chalk.gray(` Provider: ${provider || "unknown"}`));
21
- if (ciMeta.commitSha) {
22
- console.log(chalk.gray(` Commit: ${ciMeta.commitSha.slice(0, 8)}`));
23
- }
24
- if (ciMeta.branch) {
25
- console.log(chalk.gray(` Branch: ${ciMeta.branch}`));
26
- }
27
- console.log();
28
- }
29
-
30
- // Override config path if specified
31
- if (configPath) {
32
- process.env.RESHOT_CONFIG_PATH = configPath;
33
- }
34
-
35
- const ciResult = {
36
- run: { success: false, scenariosRun: 0, scenariosFailed: 0 },
37
- publish: null,
38
- ci: ciMeta,
39
- timestamp: new Date().toISOString(),
40
- };
41
-
42
- // Step 1: Run capture scenarios
43
- console.log(chalk.cyan("━━━ Step 1: Capture ━━━\n"));
44
- try {
45
- const runCommand = require("./run");
46
- const runResult = await runCommand({
47
- headless: true,
48
- noExit: true,
49
- });
50
-
51
- ciResult.run.success = runResult?.success ?? false;
52
- if (runResult?.results) {
53
- ciResult.run.scenariosRun = runResult.results.length;
54
- ciResult.run.scenariosFailed = runResult.results.filter((r) => !r.success).length;
55
- }
56
- } catch (error) {
57
- console.error(chalk.red(`Capture failed: ${error.message}`));
58
- ciResult.run.success = false;
59
- ciResult.run.error = error.message;
60
- }
61
-
62
- // Step 2: Publish (unless --no-publish or capture failed)
63
- if (shouldPublish && ciResult.run.success) {
64
- console.log(chalk.cyan("\n━━━ Step 2: Publish ━━━\n"));
65
- try {
66
- const publishCommand = require("./publish");
67
- const publishResult = await publishCommand({
68
- tag,
69
- message: message || (ciMeta.commitSha ? `CI publish (${ciMeta.commitSha.slice(0, 8)})` : "CI publish"),
70
- dryRun,
71
- force: true, // Skip prompts in CI
72
- outputJson: true,
73
- });
74
-
75
- ciResult.publish = {
76
- success: (publishResult?.assetsFailed || 0) === 0,
77
- assetsProcessed: publishResult?.assetsProcessed || 0,
78
- assetsFailed: publishResult?.assetsFailed || 0,
79
- assetsSkipped: publishResult?.assetsSkipped || 0,
80
- viewUrl: publishResult?.viewUrl || null,
81
- };
82
- } catch (error) {
83
- console.error(chalk.red(`Publish failed: ${error.message}`));
84
- ciResult.publish = { success: false, error: error.message };
85
- }
86
- } else if (!shouldPublish) {
87
- console.log(chalk.gray("\n Skipping publish (--no-publish)"));
88
- } else if (!ciResult.run.success) {
89
- console.log(chalk.yellow("\n Skipping publish (capture failed)"));
90
- }
91
-
92
- // Write composite result
93
- const outputDir = path.join(process.cwd(), ".reshot", "output");
94
- fs.ensureDirSync(outputDir);
95
- const resultPath = path.join(outputDir, "ci-result.json");
96
- fs.writeJsonSync(resultPath, ciResult, { spaces: 2 });
97
- console.log(chalk.gray(`\nšŸ“„ CI result written to: ${resultPath}`));
98
-
99
- // Summary
100
- console.log(chalk.cyan("\n━━━ CI Summary ━━━\n"));
101
- const runIcon = ciResult.run.success ? chalk.green("āœ”") : chalk.red("āœ–");
102
- console.log(` ${runIcon} Capture: ${ciResult.run.scenariosRun} scenario(s), ${ciResult.run.scenariosFailed} failed`);
103
-
104
- if (ciResult.publish) {
105
- const pubIcon = ciResult.publish.success ? chalk.green("āœ”") : chalk.red("āœ–");
106
- console.log(` ${pubIcon} Publish: ${ciResult.publish.assetsProcessed || 0} asset(s)`);
107
- if (ciResult.publish.viewUrl) {
108
- console.log(chalk.cyan(` šŸ”— ${ciResult.publish.viewUrl}`));
109
- }
110
- }
111
-
112
- console.log();
113
-
114
- // Exit with appropriate code
115
- const overallSuccess = ciResult.run.success && (!ciResult.publish || ciResult.publish.success);
116
- if (!overallSuccess) {
117
- process.exitCode = 1;
118
- }
119
-
120
- return ciResult;
121
- }
122
-
123
- module.exports = ciRunCommand;
@@ -1,288 +0,0 @@
1
- // ci-setup.js - Set up CI/CD integration
2
- const inquirer = require('inquirer');
3
- const chalk = require('chalk');
4
- const fs = require('fs-extra');
5
- const path = require('path');
6
-
7
- const GITHUB_ACTIONS_WORKFLOW = (secretNames) => `name: Reshot Visual Documentation
8
-
9
- on:
10
- push:
11
- branches:
12
- - main
13
- - master
14
-
15
- jobs:
16
- docs:
17
- runs-on: ubuntu-latest
18
-
19
- steps:
20
- - name: Checkout code
21
- uses: actions/checkout@v3
22
-
23
- - name: Set up Node.js
24
- uses: actions/setup-node@v3
25
- with:
26
- node-version: '18'
27
-
28
- - name: Install dependencies
29
- run: npm install
30
-
31
- - name: Install Reshot CLI
32
- run: npm install -g @reshot/cli
33
-
34
- - name: Install Playwright browsers
35
- run: npx playwright install chromium
36
-
37
- - name: Install ffmpeg
38
- run: sudo apt-get update && sudo apt-get install -y ffmpeg
39
-
40
- # Generate visual assets from docsync.config.json blueprint
41
- # Only runs if features.visuals is enabled for the project
42
- - name: Run Reshot scenarios
43
- env:
44
- RESHOT_API_KEY: \${{ secrets.${secretNames.apiKey} }}
45
- RESHOT_PROJECT_ID: \${{ secrets.${secretNames.projectId} }}
46
- RESHOT_API_BASE_URL: \${{ secrets.${secretNames.baseUrl} }}
47
- TEST_PASSWORD: \${{ secrets.${secretNames.testPassword} }}
48
- run: reshot run
49
-
50
- # Publish three streams to Reshot (respects project feature toggles):
51
- # Stream A: Visual assets (screenshots/videos) - always enabled
52
- # Stream B: Documentation files (if docs feature enabled + configured)
53
- # Stream C: Changelog drafts from commit messages (if changelog feature enabled)
54
- - name: Publish assets to Reshot
55
- env:
56
- RESHOT_API_KEY: \${{ secrets.${secretNames.apiKey} }}
57
- RESHOT_PROJECT_ID: \${{ secrets.${secretNames.projectId} }}
58
- RESHOT_API_BASE_URL: \${{ secrets.${secretNames.baseUrl} }}
59
- TEST_PASSWORD: \${{ secrets.${secretNames.testPassword} }}
60
- run: reshot publish
61
-
62
- - name: Upload artifacts (optional)
63
- uses: actions/upload-artifact@v3
64
- if: always()
65
- with:
66
- name: reshot-output
67
- path: .reshot/output/
68
- `;
69
-
70
- const CIRCLECI_CONFIG = (secretNames) => `version: 2.1
71
-
72
- jobs:
73
- docs:
74
- docker:
75
- - image: cimg/node:18.0-browsers
76
- environment:
77
- RESHOT_API_KEY: \${${secretNames.apiKey}}
78
- RESHOT_PROJECT_ID: \${${secretNames.projectId}}
79
- RESHOT_API_BASE_URL: \${${secretNames.baseUrl}}
80
- TEST_PASSWORD: \${${secretNames.testPassword}}
81
- steps:
82
- - checkout
83
-
84
- - run:
85
- name: Install dependencies
86
- command: |
87
- npm install
88
- npm install -g @reshot/cli
89
-
90
- - run:
91
- name: Install Playwright browsers
92
- command: npx playwright install chromium
93
-
94
- - run:
95
- name: Install ffmpeg
96
- command: sudo apt-get update && sudo apt-get install -y ffmpeg
97
-
98
- - run:
99
- name: Run Reshot scenarios
100
- command: reshot run
101
-
102
- - run:
103
- name: Publish assets to Reshot
104
- command: reshot publish
105
-
106
- - store_artifacts:
107
- path: .reshot/output
108
-
109
- workflows:
110
- version: 2
111
- docs:
112
- jobs:
113
- - docs
114
- `;
115
-
116
- const GITLAB_CI_CONFIG = (secretNames) => `stages:
117
- - docs
118
-
119
- docs:
120
- stage: docs
121
- image: node:18
122
-
123
- variables:
124
- RESHOT_API_KEY: \$${secretNames.apiKey}
125
- RESHOT_PROJECT_ID: \$${secretNames.projectId}
126
- RESHOT_API_BASE_URL: \$${secretNames.baseUrl}
127
- TEST_PASSWORD: \$${secretNames.testPassword}
128
-
129
- before_script:
130
- - apt-get update && apt-get install -y ffmpeg
131
- - npm install
132
- - npx playwright install chromium
133
- - npm install -g @reshot/cli
134
-
135
- script:
136
- - reshot run
137
- - reshot publish
138
-
139
- artifacts:
140
- paths:
141
- - .reshot/output/
142
- expire_in: 1 week
143
-
144
- only:
145
- - main
146
- - master
147
- `;
148
-
149
- async function ciSetupCommand() {
150
- console.log(chalk.cyan('šŸ”§ Setting up CI/CD integration...\n'));
151
-
152
- // Prompt for CI provider
153
- const { provider } = await inquirer.prompt([
154
- {
155
- type: 'list',
156
- name: 'provider',
157
- message: 'Select your CI/CD provider:',
158
- choices: [
159
- { name: 'GitHub Actions', value: 'github' },
160
- { name: 'CircleCI', value: 'circleci' },
161
- { name: 'GitLab CI', value: 'gitlab' }
162
- ]
163
- }
164
- ]);
165
-
166
- // Prompt for secret names
167
- console.log(chalk.cyan('\nEnter the names for your CI secrets:'));
168
- const { apiKeySecret, projectIdSecret, baseUrlSecret, testPasswordSecret } = await inquirer.prompt([
169
- {
170
- type: 'input',
171
- name: 'apiKeySecret',
172
- message: 'API Key secret name:',
173
- default: 'RESHOT_API_KEY'
174
- },
175
- {
176
- type: 'input',
177
- name: 'projectIdSecret',
178
- message: 'Project ID secret name:',
179
- default: 'RESHOT_PROJECT_ID'
180
- },
181
- {
182
- type: 'input',
183
- name: 'baseUrlSecret',
184
- message: 'Base URL secret name:',
185
- default: 'RESHOT_API_BASE_URL'
186
- },
187
- {
188
- type: 'input',
189
- name: 'testPasswordSecret',
190
- message: 'Test password secret name:',
191
- default: 'TEST_PASSWORD'
192
- }
193
- ]);
194
-
195
- const secretNames = {
196
- apiKey: apiKeySecret,
197
- projectId: projectIdSecret,
198
- baseUrl: baseUrlSecret,
199
- testPassword: testPasswordSecret
200
- };
201
-
202
- // Generate workflow file based on provider
203
- let workflowPath;
204
- let workflowContent;
205
-
206
- switch (provider) {
207
- case 'github':
208
- workflowPath = path.join(process.cwd(), '.github', 'workflows', 'docsync.yml');
209
- workflowContent = GITHUB_ACTIONS_WORKFLOW(secretNames);
210
- break;
211
-
212
- case 'circleci':
213
- workflowPath = path.join(process.cwd(), '.circleci', 'config.yml');
214
- workflowContent = CIRCLECI_CONFIG(secretNames);
215
- break;
216
-
217
- case 'gitlab':
218
- workflowPath = path.join(process.cwd(), '.gitlab-ci.yml');
219
- workflowContent = GITLAB_CI_CONFIG(secretNames);
220
- break;
221
- }
222
-
223
- // Check if file already exists
224
- if (fs.existsSync(workflowPath)) {
225
- const { overwrite } = await inquirer.prompt([
226
- {
227
- type: 'confirm',
228
- name: 'overwrite',
229
- message: `${workflowPath} already exists. Overwrite?`,
230
- default: false
231
- }
232
- ]);
233
-
234
- if (!overwrite) {
235
- console.log(chalk.yellow('\n⚠ Setup cancelled. Existing workflow file was not modified.'));
236
- return;
237
- }
238
- }
239
-
240
- // Write workflow file
241
- fs.ensureDirSync(path.dirname(workflowPath));
242
- fs.writeFileSync(workflowPath, workflowContent);
243
-
244
- console.log(chalk.green(`\nāœ” Workflow file created: ${workflowPath}`));
245
-
246
- // Print instructions
247
- console.log(chalk.cyan('\nšŸ“‹ Next Steps:\n'));
248
-
249
- switch (provider) {
250
- case 'github':
251
- console.log('1. Go to your GitHub repository settings');
252
- console.log('2. Navigate to ' + chalk.bold('Secrets and variables > Actions'));
253
- console.log('3. Add the following secrets:\n');
254
- console.log(` ${chalk.bold(secretNames.apiKey)} (Project API key for CLI uploads)`);
255
- console.log(` ${chalk.bold(secretNames.projectId)} (Project ID for metadata)`);
256
- console.log(` ${chalk.bold(secretNames.baseUrl)} (API base URL, e.g. https://api.reshot.dev/api)`);
257
- console.log(` ${chalk.bold(secretNames.testPassword)} (Any additional test credential you reference)`);
258
- console.log('\n4. Commit and push the workflow file to trigger the action');
259
- break;
260
-
261
- case 'circleci':
262
- console.log('1. Go to your CircleCI project settings');
263
- console.log('2. Navigate to ' + chalk.bold('Environment Variables'));
264
- console.log('3. Add the following variables:\n');
265
- console.log(` ${chalk.bold(secretNames.apiKey)}`);
266
- console.log(` ${chalk.bold(secretNames.projectId)}`);
267
- console.log(` ${chalk.bold(secretNames.baseUrl)}`);
268
- console.log(` ${chalk.bold(secretNames.testPassword)}`);
269
- console.log('\n4. Commit and push the config file to trigger the pipeline');
270
- break;
271
-
272
- case 'gitlab':
273
- console.log('1. Go to your GitLab project settings');
274
- console.log('2. Navigate to ' + chalk.bold('CI/CD > Variables'));
275
- console.log('3. Add the following variables:\n');
276
- console.log(` ${chalk.bold(secretNames.apiKey)}`);
277
- console.log(` ${chalk.bold(secretNames.projectId)}`);
278
- console.log(` ${chalk.bold(secretNames.baseUrl)}`);
279
- console.log(` ${chalk.bold(secretNames.testPassword)}`);
280
- console.log('\n4. Commit and push the config file to trigger the pipeline');
281
- break;
282
- }
283
-
284
- console.log();
285
- }
286
-
287
- module.exports = ciSetupCommand;
288
-