(dir: string, options: InitCommandOptions)
| 384 | } |
| 385 | |
| 386 | async function installPackages(dir: string, options: InitCommandOptions) { |
| 387 | return await tracer.startActiveSpan("installPackages", async (span) => { |
| 388 | const installSpinner = spinner(); |
| 389 | |
| 390 | try { |
| 391 | const projectDir = resolve(process.cwd(), dir); |
| 392 | const pkgManager = await getUserPackageManager(projectDir); |
| 393 | |
| 394 | span.setAttributes({ |
| 395 | "cli.projectDir": projectDir, |
| 396 | "cli.packageManager": pkgManager, |
| 397 | "cli.tag": options.tag, |
| 398 | }); |
| 399 | |
| 400 | switch (pkgManager) { |
| 401 | case "npm": { |
| 402 | installSpinner.start(`Running npm install @trigger.dev/sdk@${options.tag}`); |
| 403 | |
| 404 | await execa("npm", ["install", `@trigger.dev/sdk@${options.tag}`], { |
| 405 | cwd: projectDir, |
| 406 | stdio: options.logLevel === "debug" ? "inherit" : "ignore", |
| 407 | }); |
| 408 | |
| 409 | break; |
| 410 | } |
| 411 | case "pnpm": { |
| 412 | installSpinner.start(`Running pnpm add @trigger.dev/sdk@${options.tag}`); |
| 413 | |
| 414 | await execa("pnpm", ["add", `@trigger.dev/sdk@${options.tag}`], { |
| 415 | cwd: projectDir, |
| 416 | stdio: options.logLevel === "debug" ? "inherit" : "ignore", |
| 417 | }); |
| 418 | |
| 419 | break; |
| 420 | } |
| 421 | case "yarn": { |
| 422 | installSpinner.start(`Running yarn add @trigger.dev/sdk@${options.tag}`); |
| 423 | |
| 424 | await execa("yarn", ["add", `@trigger.dev/sdk@${options.tag}`], { |
| 425 | cwd: projectDir, |
| 426 | stdio: options.logLevel === "debug" ? "inherit" : "ignore", |
| 427 | }); |
| 428 | |
| 429 | break; |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | installSpinner.stop(`@trigger.dev/sdk@${options.tag} installed`); |
| 434 | |
| 435 | span.end(); |
| 436 | } catch (e) { |
| 437 | installSpinner.stop( |
| 438 | `Failed to install @trigger.dev/sdk@${options.tag}. Rerun command with --log-level debug for more details.` |
| 439 | ); |
| 440 | |
| 441 | if (!(e instanceof SkipCommandError)) { |
| 442 | recordSpanException(span, e); |
| 443 | } |
no test coverage detected
searching dependent graphs…