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

Method install

packages/cli/src/frameworks/astro/index.ts:51–116  ·  view source on GitHub ↗
(path: string, { typescript, endpointSlug }: ProjectInstallOptions)

Source from the content-addressed store, hash-verified

49 }
50
51 async install(path: string, { typescript, endpointSlug }: ProjectInstallOptions): Promise<void> {
52 const pathAlias = await getPathAlias({
53 projectPath: path,
54 isTypescriptProject: typescript,
55 extraDirectories: ["src"],
56 });
57 const templatesDir = pathModule.join(templatesPath(), "astro");
58 const srcFolder = pathModule.join(path, "src");
59 const fileExtension = typescript ? ".ts" : ".js";
60
61 //create src/pages/api/trigger.js
62 const apiRoutePath = pathModule.join(srcFolder, "pages", "api", `trigger${fileExtension}`);
63 const apiRouteResult = await createFileFromTemplate({
64 templatePath: pathModule.join(templatesDir, "apiRoute.js"),
65 replacements: {
66 routePathPrefix: pathAlias ? pathAlias + "/" : "../../",
67 },
68 outputPath: apiRoutePath,
69 });
70 if (!apiRouteResult.success) {
71 throw new Error("Failed to create API route file");
72 }
73 logger.success(`✔ Created API route at ${apiRoutePath}`);
74
75 //src/trigger.js
76 const triggerFilePath = pathModule.join(srcFolder, `trigger${fileExtension}`);
77 const triggerResult = await createFileFromTemplate({
78 templatePath: pathModule.join(templatesDir, "trigger.js"),
79 replacements: {
80 endpointSlug,
81 },
82 outputPath: triggerFilePath,
83 });
84 if (!triggerResult.success) {
85 throw new Error("Failed to create trigger file");
86 }
87 logger.success(`✔ Created Trigger client at ${triggerFilePath}`);
88
89 //src/jobs/example.js
90 const exampleJobFilePath = pathModule.join(srcFolder, "jobs", `example${fileExtension}`);
91 const exampleJobResult = await createFileFromTemplate({
92 templatePath: pathModule.join(templatesDir, "exampleJob.js"),
93 replacements: {
94 jobsPathPrefix: pathAlias ? pathAlias + "/" : "../",
95 },
96 outputPath: exampleJobFilePath,
97 });
98 if (!exampleJobResult.success) {
99 throw new Error("Failed to create example job file");
100 }
101 logger.success(`✔ Created example job at ${exampleJobFilePath}`);
102
103 //src/jobs/index.js
104 const jobsIndexFilePath = pathModule.join(srcFolder, "jobs", `index${fileExtension}`);
105 const jobsIndexResult = await createFileFromTemplate({
106 templatePath: pathModule.join(templatesDir, "jobsIndex.js"),
107 replacements: {
108 jobsPathPrefix: pathAlias ? pathAlias + "/" : "../",

Callers

nothing calls this directly

Calls 3

getPathAliasFunction · 0.90
templatesPathFunction · 0.90
createFileFromTemplateFunction · 0.90

Tested by

no test coverage detected