MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / createTriggerDir

Function createTriggerDir

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

Source from the content-addressed store, hash-verified

181}
182
183async function createTriggerDir(dir: string, options: InitCommandOptions) {
184 return await tracer.startActiveSpan("createTriggerDir", async (span) => {
185 try {
186 const defaultValue = join(dir, "src", "trigger");
187
188 const location = await text({
189 message: "Where would you like to create the Trigger.dev directory?",
190 defaultValue: defaultValue,
191 placeholder: defaultValue,
192 });
193
194 if (isCancel(location)) {
195 throw new OutroCommandError();
196 }
197
198 const triggerDir = resolve(process.cwd(), location);
199
200 logger.debug({ triggerDir });
201
202 span.setAttributes({
203 "cli.triggerDir": triggerDir,
204 });
205
206 if (await pathExists(triggerDir)) {
207 throw new Error(`Directory already exists at ${triggerDir}`);
208 }
209
210 const exampleSelection = await select({
211 message: `Choose an example to create in the ${location} directory`,
212 options: [
213 { value: "simple", label: "Simple (Hello World)" },
214 {
215 value: "none",
216 label: "None",
217 hint: "skip creating an example",
218 },
219 ],
220 });
221
222 if (isCancel(exampleSelection)) {
223 throw new OutroCommandError();
224 }
225
226 const example = exampleSelection as string;
227
228 span.setAttributes({
229 "cli.example": example,
230 });
231
232 if (example === "none") {
233 // Create a .gitkeep file in the trigger dir
234 await createFile(join(triggerDir, ".gitkeep"), "");
235
236 log.step(`Created directory at ${location}`);
237
238 span.end();
239 return { location, isCustomValue: location !== defaultValue };
240 }

Callers 1

_initCommandFunction · 0.85

Calls 7

pathExistsFunction · 0.90
createFileFunction · 0.90
cliRootPathFunction · 0.90
createFileFromTemplateFunction · 0.90
recordSpanExceptionFunction · 0.85
startActiveSpanMethod · 0.80
debugMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…