| 11 | import { standardWatchFilePaths } from "../watchConfig"; |
| 12 | |
| 13 | export class Remix implements Framework { |
| 14 | id = "remix"; |
| 15 | name = "Remix"; |
| 16 | |
| 17 | async isMatch(path: string, packageManager: PackageManager): Promise<boolean> { |
| 18 | //check for remix.config.js |
| 19 | const hasConfigFile = await pathExists(pathModule.join(path, "remix.config.js")); |
| 20 | if (hasConfigFile) { |
| 21 | return true; |
| 22 | } |
| 23 | |
| 24 | //check for any packages starting with @remix-run |
| 25 | const packageJsonContent = await readPackageJson(path); |
| 26 | if (!packageJsonContent) { |
| 27 | return false; |
| 28 | } |
| 29 | |
| 30 | const keys = Object.keys(packageJsonContent.dependencies || {}); |
| 31 | const dependencyWithRemix = keys.find((key) => key.startsWith("@remix-run")); |
| 32 | if (dependencyWithRemix) { |
| 33 | return true; |
| 34 | } |
| 35 | |
| 36 | return false; |
| 37 | } |
| 38 | |
| 39 | async dependencies(): Promise<InstallPackage[]> { |
| 40 | return [ |
| 41 | { name: "@trigger.dev/sdk", tag: "latest" }, |
| 42 | { name: "@trigger.dev/remix", tag: "latest" }, |
| 43 | { name: "@trigger.dev/react", tag: "latest" }, |
| 44 | ]; |
| 45 | } |
| 46 | |
| 47 | possibleEnvFilenames(): string[] { |
| 48 | return [".env"]; |
| 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: ["app"], |
| 56 | }); |
| 57 | const templatesDir = pathModule.join(templatesPath(), "remix"); |
| 58 | const appFolder = pathModule.join(path, "app"); |
| 59 | const fileExtension = typescript ? ".ts" : ".js"; |
| 60 | |
| 61 | //create app/api.trigger.js |
| 62 | const apiRoutePath = pathModule.join(appFolder, "routes", `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) { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…