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

Method install

packages/cli/src/frameworks/nextjs/index.ts:44–95  ·  view source on GitHub ↗
(
    path: string,
    options: { typescript: boolean; packageManager: PackageManager; endpointSlug: string }
  )

Source from the content-addressed store, hash-verified

42 publicKeyEnvName = "NEXT_PUBLIC_TRIGGER_PUBLIC_API_KEY";
43
44 async install(
45 path: string,
46 options: { typescript: boolean; packageManager: PackageManager; endpointSlug: string }
47 ): Promise<void> {
48 const usesSrcDir = await detectUseOfSrcDir(path);
49 if (usesSrcDir) {
50 logger.info("📁 Detected use of src directory");
51 }
52
53 const nextJsDir = await detectPagesOrAppDir(path);
54 const nextJsVersion = await detectNextVersion(path);
55 const routeDir = pathModule.join(path, usesSrcDir ? "src" : "");
56 const pathAlias = await getPathAlias({
57 projectPath: path,
58 isTypescriptProject: options.typescript,
59 extraDirectories: usesSrcDir ? ["src"] : undefined,
60 });
61 const fileExtension = options.typescript ? ".ts" : ".js";
62
63 if (nextJsDir === "pages") {
64 const apiRoutePath = pathModule.join(routeDir, "pages", "api", `trigger${fileExtension}`);
65 if (nextJsVersion && nextJsVersion !== 'latest' && nextJsVersion < "13.5") {
66 await createTriggerRoute({
67 path: routeDir,
68 apiRoutePath,
69 template: "pagesApiRoute.js",
70 fileExtension,
71 endpointSlug: options.endpointSlug,
72 pathAlias
73 });
74 } else {
75 await createTriggerRoute({
76 path: routeDir,
77 apiRoutePath,
78 template: "pagesApiRouteWithConfigObject.js",
79 fileExtension,
80 endpointSlug: options.endpointSlug,
81 pathAlias
82 });
83 }
84 } else {
85 const apiRoutePath = pathModule.join(routeDir, "app", "api", "trigger", `route${fileExtension}`);
86 await createTriggerRoute({
87 path: routeDir,
88 apiRoutePath,
89 template: "appApiRoute.js",
90 fileExtension,
91 endpointSlug: options.endpointSlug,
92 pathAlias
93 });
94 }
95 }
96
97 async postInstall(
98 path: string,

Callers

nothing calls this directly

Calls 6

getPathAliasFunction · 0.90
detectUseOfSrcDirFunction · 0.85
detectPagesOrAppDirFunction · 0.85
detectNextVersionFunction · 0.85
createTriggerRouteFunction · 0.85
infoMethod · 0.65

Tested by

no test coverage detected