MCPcopy
hub / github.com/triggerdotdev/trigger.dev / installPackages

Function installPackages

packages/cli-v3/src/commands/init.ts:386–450  ·  view source on GitHub ↗
(dir: string, options: InitCommandOptions)

Source from the content-addressed store, hash-verified

384}
385
386async 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 }

Callers 2

_initCommandFunction · 0.70
initializeMethod · 0.50

Calls 6

spinnerFunction · 0.90
getUserPackageManagerFunction · 0.90
recordSpanExceptionFunction · 0.85
startActiveSpanMethod · 0.80
startMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…