@scrymore/scry-deployer 0.0.5 → 0.0.6
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/bin/cli.js +29 -2
- package/lib/coverage.js +9 -6
- package/lib/logger.js +16 -0
- package/package.json +2 -1
package/bin/cli.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
const Sentry = require('@sentry/node');
|
|
3
4
|
const yargs = require('yargs/yargs');
|
|
4
5
|
const { hideBin } = require('yargs/helpers');
|
|
5
6
|
const fs = require('fs');
|
|
@@ -175,10 +176,26 @@ async function runDeployment(argv) {
|
|
|
175
176
|
}
|
|
176
177
|
}
|
|
177
178
|
|
|
178
|
-
function handleError(error, argv) {
|
|
179
|
+
async function handleError(error, argv) {
|
|
179
180
|
const logger = createLogger(argv || {});
|
|
180
181
|
logger.error(`\n❌ Error: ${error.message}`);
|
|
181
182
|
|
|
183
|
+
// Capture error in Sentry with additional context
|
|
184
|
+
Sentry.withScope((scope) => {
|
|
185
|
+
if (argv) {
|
|
186
|
+
scope.setTags({
|
|
187
|
+
project: argv.project,
|
|
188
|
+
version: argv.version,
|
|
189
|
+
command: argv._ ? argv._[0] : 'unknown',
|
|
190
|
+
});
|
|
191
|
+
scope.setExtra('argv', argv);
|
|
192
|
+
}
|
|
193
|
+
Sentry.captureException(error);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// Ensure the event is sent before the process exits
|
|
197
|
+
await Sentry.close(2000);
|
|
198
|
+
|
|
182
199
|
if (error instanceof ApiError) {
|
|
183
200
|
if (error.statusCode === 401) {
|
|
184
201
|
logger.error('Suggestion: Check that your API key is correct and has not expired.');
|
|
@@ -195,6 +212,13 @@ function handleError(error, argv) {
|
|
|
195
212
|
}
|
|
196
213
|
|
|
197
214
|
async function main() {
|
|
215
|
+
// Initialize Sentry
|
|
216
|
+
Sentry.init({
|
|
217
|
+
dsn: "https://c66ce229a1db2289f145eebd02436d9c@o4507889391828992.ingest.us.sentry.io/4510699330732032", // Fallback to hardcoded DSN for user reporting
|
|
218
|
+
tracesSampleRate: 1.0,
|
|
219
|
+
environment: process.env.NODE_ENV || 'production',
|
|
220
|
+
});
|
|
221
|
+
|
|
198
222
|
let config;
|
|
199
223
|
try {
|
|
200
224
|
const args = await yargs(hideBin(process.argv))
|
|
@@ -378,6 +402,9 @@ async function main() {
|
|
|
378
402
|
|
|
379
403
|
await runInit(initConfig);
|
|
380
404
|
})
|
|
405
|
+
.command('debug-sentry', 'Test Sentry integration by throwing an error', () => {}, () => {
|
|
406
|
+
throw new Error('Sentry debug error from scry-node CLI');
|
|
407
|
+
})
|
|
381
408
|
.env('STORYBOOK_DEPLOYER')
|
|
382
409
|
.help()
|
|
383
410
|
.alias('help', 'h')
|
|
@@ -385,7 +412,7 @@ async function main() {
|
|
|
385
412
|
.parse();
|
|
386
413
|
|
|
387
414
|
} catch (error) {
|
|
388
|
-
handleError(error, config);
|
|
415
|
+
await handleError(error, config);
|
|
389
416
|
}
|
|
390
417
|
}
|
|
391
418
|
|
package/lib/coverage.js
CHANGED
|
@@ -36,8 +36,7 @@ async function runCoverageAnalysis(options) {
|
|
|
36
36
|
const outputPath = path.join(process.cwd(), `.scry-coverage-report-${Date.now()}.json`);
|
|
37
37
|
|
|
38
38
|
/** @type {string[]} */
|
|
39
|
-
const
|
|
40
|
-
'@scrymore/scry-sbcov',
|
|
39
|
+
const cliArgs = [
|
|
41
40
|
'--storybook-static',
|
|
42
41
|
storybookDir,
|
|
43
42
|
'--output',
|
|
@@ -48,17 +47,21 @@ async function runCoverageAnalysis(options) {
|
|
|
48
47
|
];
|
|
49
48
|
|
|
50
49
|
if (failOnThreshold) {
|
|
51
|
-
|
|
50
|
+
cliArgs.push('--ci');
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
if (execute) {
|
|
55
|
-
|
|
54
|
+
cliArgs.push('--execute');
|
|
56
55
|
}
|
|
57
56
|
|
|
57
|
+
// Use npx with -p flag to ensure package is installed, then run the binary
|
|
58
|
+
// This is more reliable than `npx @scrymore/scry-sbcov` which can fail to find the binary
|
|
59
|
+
const npxCommand = `npx -y -p @scrymore/scry-sbcov scry-sbcov ${cliArgs.map(shellEscape).join(' ')}`;
|
|
60
|
+
|
|
58
61
|
// Debug logging to show the exact command being executed
|
|
59
62
|
console.log(chalk.yellow('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
|
|
60
63
|
console.log(chalk.yellow('DEBUG: Executing coverage command:'));
|
|
61
|
-
console.log(chalk.gray(
|
|
64
|
+
console.log(chalk.gray(npxCommand));
|
|
62
65
|
console.log(chalk.yellow('Working directory: ' + process.cwd()));
|
|
63
66
|
console.log(chalk.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
|
|
64
67
|
|
|
@@ -75,7 +78,7 @@ async function runCoverageAnalysis(options) {
|
|
|
75
78
|
console.log(chalk.yellow('Project root: ' + projectRoot));
|
|
76
79
|
console.log(chalk.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
|
|
77
80
|
|
|
78
|
-
execSync(
|
|
81
|
+
execSync(npxCommand, {
|
|
79
82
|
stdio: 'inherit',
|
|
80
83
|
cwd: projectRoot // Run from the project root, not scry-node directory
|
|
81
84
|
});
|
package/lib/logger.js
CHANGED
|
@@ -8,6 +8,7 @@ const chalk = require('chalk');
|
|
|
8
8
|
* @returns {{info: Function, error: Function, debug: Function, success: Function}}
|
|
9
9
|
*/
|
|
10
10
|
function createLogger({ verbose = false }) {
|
|
11
|
+
const Sentry = require('@sentry/node');
|
|
11
12
|
return {
|
|
12
13
|
/**
|
|
13
14
|
* Logs an informational message.
|
|
@@ -15,6 +16,11 @@ function createLogger({ verbose = false }) {
|
|
|
15
16
|
*/
|
|
16
17
|
info: (message) => {
|
|
17
18
|
console.log(message);
|
|
19
|
+
Sentry.addBreadcrumb({
|
|
20
|
+
category: 'log',
|
|
21
|
+
message: message,
|
|
22
|
+
level: 'info',
|
|
23
|
+
});
|
|
18
24
|
},
|
|
19
25
|
|
|
20
26
|
/**
|
|
@@ -31,6 +37,11 @@ function createLogger({ verbose = false }) {
|
|
|
31
37
|
*/
|
|
32
38
|
error: (message) => {
|
|
33
39
|
console.error(chalk.red(message));
|
|
40
|
+
Sentry.addBreadcrumb({
|
|
41
|
+
category: 'log',
|
|
42
|
+
message: message,
|
|
43
|
+
level: 'error',
|
|
44
|
+
});
|
|
34
45
|
},
|
|
35
46
|
|
|
36
47
|
/**
|
|
@@ -41,6 +52,11 @@ function createLogger({ verbose = false }) {
|
|
|
41
52
|
if (verbose) {
|
|
42
53
|
console.log(chalk.dim(`[debug] ${message}`));
|
|
43
54
|
}
|
|
55
|
+
Sentry.addBreadcrumb({
|
|
56
|
+
category: 'log',
|
|
57
|
+
message: message,
|
|
58
|
+
level: 'debug',
|
|
59
|
+
});
|
|
44
60
|
},
|
|
45
61
|
};
|
|
46
62
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scrymore/scry-deployer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "A CLI to automate the deployment of Storybook static builds.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@octokit/rest": "^20.0.0",
|
|
40
40
|
"@scrymore/scry-sbcov": "^0.2.1",
|
|
41
|
+
"@sentry/node": "^10.33.0",
|
|
41
42
|
"archiver": "^7.0.1",
|
|
42
43
|
"axios": "^1.12.2",
|
|
43
44
|
"chalk": "^4.1.2",
|