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

Function writeConfigFile

packages/cli-v3/src/commands/init.ts:452–510  ·  view source on GitHub ↗
(
  dir: string,
  project: GetProjectResponseBody,
  options: InitCommandOptions,
  triggerDir: { location: string; isCustomValue: boolean }
)

Source from the content-addressed store, hash-verified

450}
451
452async function writeConfigFile(
453 dir: string,
454 project: GetProjectResponseBody,
455 options: InitCommandOptions,
456 triggerDir: { location: string; isCustomValue: boolean }
457) {
458 return await tracer.startActiveSpan("writeConfigFile", async (span) => {
459 try {
460 const spnnr = spinner();
461 spnnr.start("Creating config file");
462
463 const projectDir = resolve(process.cwd(), dir);
464 const templatePath = join(cliRootPath(), "templates", "trigger.config.ts.template");
465 const outputPath = join(projectDir, "trigger.config.ts");
466
467 span.setAttributes({
468 "cli.projectDir": projectDir,
469 "cli.templatePath": templatePath,
470 "cli.outputPath": outputPath,
471 });
472
473 const result = await createFileFromTemplate({
474 templatePath,
475 replacements: {
476 projectRef: project.externalRef,
477 triggerDirectoriesOption: triggerDir.isCustomValue
478 ? `\n triggerDirectories: ["${triggerDir.location}"],`
479 : "",
480 },
481 outputPath,
482 override: options.overrideConfig,
483 });
484
485 const relativePathToOutput = relative(process.cwd(), outputPath);
486
487 spnnr.stop(
488 result.success
489 ? `Config file created at ${relativePathToOutput}`
490 : `Failed to create config file: ${result.error}`
491 );
492
493 if (!result.success) {
494 throw new SkipLoggingError(result.error);
495 }
496
497 span.end();
498
499 return result.success;
500 } catch (e) {
501 if (!(e instanceof SkipCommandError)) {
502 recordSpanException(span, e);
503 }
504
505 span.end();
506
507 throw e;
508 }
509 });

Callers 1

_initCommandFunction · 0.85

Calls 7

spinnerFunction · 0.90
cliRootPathFunction · 0.90
createFileFromTemplateFunction · 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…