auto-upgrade config to non-deprecated alternatives

This commit is contained in:
Eric Allam
2024-08-12 09:59:07 +01:00
committed by Eric Allam
parent de69e72373
commit ffebbb81ae
17 changed files with 668 additions and 162 deletions
+2 -2
View File
@@ -22,7 +22,7 @@
"noFallthroughCasesInSwitch": true,
"resolveJsonModule": true,
"removeComments": true,
"removeComments": false,
"esModuleInterop": true,
"emitDecoratorMetadata": false,
"experimentalDecorators": false,
@@ -31,6 +31,6 @@
"noUncheckedIndexedAccess": true,
"pretty": true,
"customConditions": ["triggerdotdev-source"]
"customConditions": ["@triggerdotdev/source"]
}
}
+6 -7
View File
@@ -1,18 +1,17 @@
import { ResolvedConfig } from "@trigger.dev/core/v3/build";
import { Command } from "commander";
import { render } from "ink";
import React from "react";
import { z } from "zod";
import { CliApiClient } from "../apiClient.js";
import { CommonCommandOptions, commonOptions, wrapCommandAction } from "../cli/common.js";
import { watchConfig } from "../config.js";
import Dev from "../dev/dev.js";
import { chalkError } from "../utilities/cliOutput.js";
import { printDevBanner, printStandloneInitialBanner } from "../utilities/initialBanner.js";
import { logger } from "../utilities/logger.js";
import { runtimeCheck } from "../utilities/runtimeCheck.js";
import { getProjectClient, isLoggedIn, LoginResultOk } from "../utilities/session.js";
import { printDevBanner, printStandloneInitialBanner } from "../utilities/initialBanner.js";
import { updateTriggerPackages } from "./update.js";
import { watchConfig } from "../config.js";
import { ResolvedConfig } from "@trigger.dev/core/v3/build";
import Dev from "../dev/dev.js";
import { render } from "ink";
import React from "react";
const DevCommandOptions = CommonCommandOptions.extend({
debugOtel: z.boolean().default(false),
+60 -2
View File
@@ -8,6 +8,7 @@ import { basename, dirname, isAbsolute, join, relative } from "node:path";
import { findWorkspaceDir, resolveLockfile, resolvePackageJSON, resolveTSConfig } from "pkg-types";
import { generateCode, loadFile } from "./imports/magicast.js";
import { logger } from "./utilities/logger.js";
import { additionalFiles, additionalPackages } from "@trigger.dev/core/v3/extensions";
export type ResolveConfigOptions = {
cwd?: string;
@@ -53,7 +54,7 @@ export async function watchConfig({
debounce,
chokidarOptions: { ignoreInitial },
onUpdate: async ({ newConfig }) => {
const resolvedConfig = await resolveConfig(cwd, newConfig, overrides);
const resolvedConfig = await resolveConfig(cwd, newConfig, overrides, false);
onUpdate(resolvedConfig);
},
@@ -115,7 +116,8 @@ export function configPlugin(resolvedConfig: ResolvedConfig): esbuild.Plugin | u
async function resolveConfig(
cwd: string,
result: c12.ResolvedConfig<TriggerConfig>,
overrides?: Partial<TriggerConfig>
overrides?: Partial<TriggerConfig>,
warn = true
): Promise<ResolvedConfig> {
const packageJsonPath = await resolvePackageJSON(cwd);
const tsconfigPath = await resolveTSConfig(cwd);
@@ -124,6 +126,8 @@ async function resolveConfig(
const workingDir = packageJsonPath ? dirname(packageJsonPath) : cwd;
validateConfig(result.config, warn);
let dirs = result.config.dirs ? result.config.dirs : await autoDetectDirs(workingDir);
dirs = dirs.map((dir) => (isAbsolute(dir) ? relative(workingDir, dir) : dir));
@@ -188,3 +192,57 @@ async function autoDetectDirs(workingDir: string): Promise<string[]> {
return dirs;
}
function validateConfig(config: TriggerConfig, warn = true) {
if (config.additionalFiles && config.additionalFiles.length > 0) {
warn &&
logger.warn(
`The "additionalFiles" option is deprecated and will be removed. Use the "additionalFiles" build extension instead. See https://trigger.dev/docs/trigger-config#additionalFiles for more information.`
);
config.build ??= {};
config.build.extensions ??= [];
config.build.extensions.push(additionalFiles({ files: config.additionalFiles }));
}
if (config.additionalPackages && config.additionalPackages.length > 0) {
warn &&
logger.warn(
`The "additionalPackages" option is deprecated and will be removed. Use the "additionalPackages" build extension instead. See https://trigger.dev/docs/trigger-config#additionalPackages for more information.`
);
config.build ??= {};
config.build.extensions ??= [];
config.build.extensions.push(additionalPackages({ packages: config.additionalPackages }));
}
if (config.triggerDirectories) {
warn &&
logger.warn(
`The "triggerDirectories" option is deprecated and will be removed. Use the "dirs" option instead.`
);
config.dirs = config.triggerDirectories;
}
if (config.dependenciesToBundle) {
warn &&
logger.warn(
`The "dependenciesToBundle" option is deprecated and will be removed. Dependencies are now bundled by default. If you want to exclude some dependencies from the bundle, use the "build.external" option.`
);
}
if (config.tsconfigPath) {
warn &&
logger.warn(
`The "tsconfigPath" option is deprecated and will be removed. Use the "tsconfig" option instead.`
);
config.tsconfig = config.tsconfigPath;
}
if (config.runtime && config.runtime === "bun") {
warn &&
logger.warn(`The "bun" runtime is currently experimental and may not work as expected.`);
}
}
+1 -25
View File
@@ -1,9 +1,7 @@
import { findUp } from "find-up";
import { mkdirSync, writeFileSync } from "node:fs";
import path from "node:path";
import { xdgAppPaths } from "../imports/xdg-app-paths.js";
import { z } from "zod";
import { CONFIG_FILES } from "../consts.js";
import { xdgAppPaths } from "../imports/xdg-app-paths.js";
import { readJSONFileSync } from "./fileSystem.js";
import { logger } from "./logger.js";
@@ -84,25 +82,3 @@ export function writeAuthConfigFile(config: UserAuthConfigFile) {
encoding: "utf-8",
});
}
async function getConfigPath(dir: string, fileName?: string): Promise<string | undefined> {
logger.debug("Searching for the config file", {
dir,
fileName,
configFiles: CONFIG_FILES,
});
return await findUp(fileName ? [fileName] : CONFIG_FILES, { cwd: dir });
}
async function findFilePath(dir: string, fileName: string): Promise<string | undefined> {
const result = await findUp([fileName], { cwd: dir });
logger.debug("Searched for the file", {
dir,
fileName,
result,
});
return result;
}
+39 -38
View File
@@ -53,7 +53,7 @@
"./v3/schemas": "./src/v3/schemas/index.ts"
},
"sourceDialects": [
"triggerdotdev-source"
"@triggerdotdev/source"
]
},
"sideEffects": false,
@@ -83,6 +83,7 @@
"humanize-duration": "^3.27.3",
"socket.io-client": "4.7.5",
"superjson": "^2.2.1",
"tinyglobby": "^0.2.2",
"zod": "3.23.8",
"zod-error": "1.5.0",
"zod-validation-error": "^1.5.0"
@@ -97,9 +98,9 @@
"socket.io": "4.7.4",
"ts-essentials": "10.0.1",
"tshy": "^3.0.2",
"tsx": "4.17.0",
"typescript": "^5.5.4",
"vitest": "^1.6.0",
"tsx": "4.17.0"
"vitest": "^1.6.0"
},
"engines": {
"node": ">=18.20.0"
@@ -108,7 +109,7 @@
"./package.json": "./package.json",
".": {
"import": {
"triggerdotdev-source": "./src/index.ts",
"@triggerdotdev/source": "./src/index.ts",
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
@@ -119,7 +120,7 @@
},
"./logger": {
"import": {
"triggerdotdev-source": "./src/logger.ts",
"@triggerdotdev/source": "./src/logger.ts",
"types": "./dist/esm/logger.d.ts",
"default": "./dist/esm/logger.js"
},
@@ -130,7 +131,7 @@
},
"./bloom": {
"import": {
"triggerdotdev-source": "./src/bloom.ts",
"@triggerdotdev/source": "./src/bloom.ts",
"types": "./dist/esm/bloom.d.ts",
"default": "./dist/esm/bloom.js"
},
@@ -141,7 +142,7 @@
},
"./eventFilterMatches": {
"import": {
"triggerdotdev-source": "./src/eventFilterMatches.ts",
"@triggerdotdev/source": "./src/eventFilterMatches.ts",
"types": "./dist/esm/eventFilterMatches.d.ts",
"default": "./dist/esm/eventFilterMatches.js"
},
@@ -152,7 +153,7 @@
},
"./replacements": {
"import": {
"triggerdotdev-source": "./src/replacements.ts",
"@triggerdotdev/source": "./src/replacements.ts",
"types": "./dist/esm/replacements.d.ts",
"default": "./dist/esm/replacements.js"
},
@@ -163,7 +164,7 @@
},
"./requestFilterMatches": {
"import": {
"triggerdotdev-source": "./src/requestFilterMatches.ts",
"@triggerdotdev/source": "./src/requestFilterMatches.ts",
"types": "./dist/esm/requestFilterMatches.d.ts",
"default": "./dist/esm/requestFilterMatches.js"
},
@@ -174,7 +175,7 @@
},
"./retry": {
"import": {
"triggerdotdev-source": "./src/retry.ts",
"@triggerdotdev/source": "./src/retry.ts",
"types": "./dist/esm/retry.d.ts",
"default": "./dist/esm/retry.js"
},
@@ -185,7 +186,7 @@
},
"./utils": {
"import": {
"triggerdotdev-source": "./src/utils.ts",
"@triggerdotdev/source": "./src/utils.ts",
"types": "./dist/esm/utils.d.ts",
"default": "./dist/esm/utils.js"
},
@@ -196,7 +197,7 @@
},
"./schemas": {
"import": {
"triggerdotdev-source": "./src/schemas/index.ts",
"@triggerdotdev/source": "./src/schemas/index.ts",
"types": "./dist/esm/schemas/index.d.ts",
"default": "./dist/esm/schemas/index.js"
},
@@ -207,7 +208,7 @@
},
"./types": {
"import": {
"triggerdotdev-source": "./src/types.ts",
"@triggerdotdev/source": "./src/types.ts",
"types": "./dist/esm/types.d.ts",
"default": "./dist/esm/types.js"
},
@@ -218,7 +219,7 @@
},
"./versions": {
"import": {
"triggerdotdev-source": "./src/versions.ts",
"@triggerdotdev/source": "./src/versions.ts",
"types": "./dist/esm/versions.d.ts",
"default": "./dist/esm/versions.js"
},
@@ -229,7 +230,7 @@
},
"./v3": {
"import": {
"triggerdotdev-source": "./src/v3/index.ts",
"@triggerdotdev/source": "./src/v3/index.ts",
"types": "./dist/esm/v3/index.d.ts",
"default": "./dist/esm/v3/index.js"
},
@@ -240,7 +241,7 @@
},
"./v3/build": {
"import": {
"triggerdotdev-source": "./src/v3/build/index.ts",
"@triggerdotdev/source": "./src/v3/build/index.ts",
"types": "./dist/esm/v3/build/index.d.ts",
"default": "./dist/esm/v3/build/index.js"
},
@@ -251,7 +252,7 @@
},
"./v3/extensions": {
"import": {
"triggerdotdev-source": "./src/v3/extensions/index.ts",
"@triggerdotdev/source": "./src/v3/extensions/index.ts",
"types": "./dist/esm/v3/extensions/index.d.ts",
"default": "./dist/esm/v3/extensions/index.js"
},
@@ -262,7 +263,7 @@
},
"./v3/apps": {
"import": {
"triggerdotdev-source": "./src/v3/apps/index.ts",
"@triggerdotdev/source": "./src/v3/apps/index.ts",
"types": "./dist/esm/v3/apps/index.d.ts",
"default": "./dist/esm/v3/apps/index.js"
},
@@ -273,7 +274,7 @@
},
"./v3/errors": {
"import": {
"triggerdotdev-source": "./src/v3/errors.ts",
"@triggerdotdev/source": "./src/v3/errors.ts",
"types": "./dist/esm/v3/errors.d.ts",
"default": "./dist/esm/v3/errors.js"
},
@@ -284,7 +285,7 @@
},
"./v3/logger-api": {
"import": {
"triggerdotdev-source": "./src/v3/logger-api.ts",
"@triggerdotdev/source": "./src/v3/logger-api.ts",
"types": "./dist/esm/v3/logger-api.d.ts",
"default": "./dist/esm/v3/logger-api.js"
},
@@ -295,7 +296,7 @@
},
"./v3/otel": {
"import": {
"triggerdotdev-source": "./src/v3/otel/index.ts",
"@triggerdotdev/source": "./src/v3/otel/index.ts",
"types": "./dist/esm/v3/otel/index.d.ts",
"default": "./dist/esm/v3/otel/index.js"
},
@@ -306,7 +307,7 @@
},
"./v3/semanticInternalAttributes": {
"import": {
"triggerdotdev-source": "./src/v3/semanticInternalAttributes.ts",
"@triggerdotdev/source": "./src/v3/semanticInternalAttributes.ts",
"types": "./dist/esm/v3/semanticInternalAttributes.d.ts",
"default": "./dist/esm/v3/semanticInternalAttributes.js"
},
@@ -317,7 +318,7 @@
},
"./v3/utils/durations": {
"import": {
"triggerdotdev-source": "./src/v3/utils/durations.ts",
"@triggerdotdev/source": "./src/v3/utils/durations.ts",
"types": "./dist/esm/v3/utils/durations.d.ts",
"default": "./dist/esm/v3/utils/durations.js"
},
@@ -328,7 +329,7 @@
},
"./v3/utils/flattenAttributes": {
"import": {
"triggerdotdev-source": "./src/v3/utils/flattenAttributes.ts",
"@triggerdotdev/source": "./src/v3/utils/flattenAttributes.ts",
"types": "./dist/esm/v3/utils/flattenAttributes.d.ts",
"default": "./dist/esm/v3/utils/flattenAttributes.js"
},
@@ -339,7 +340,7 @@
},
"./v3/utils/ioSerialization": {
"import": {
"triggerdotdev-source": "./src/v3/utils/ioSerialization.ts",
"@triggerdotdev/source": "./src/v3/utils/ioSerialization.ts",
"types": "./dist/esm/v3/utils/ioSerialization.d.ts",
"default": "./dist/esm/v3/utils/ioSerialization.js"
},
@@ -350,7 +351,7 @@
},
"./v3/utils/omit": {
"import": {
"triggerdotdev-source": "./src/v3/utils/omit.ts",
"@triggerdotdev/source": "./src/v3/utils/omit.ts",
"types": "./dist/esm/v3/utils/omit.d.ts",
"default": "./dist/esm/v3/utils/omit.js"
},
@@ -361,7 +362,7 @@
},
"./v3/utils/retries": {
"import": {
"triggerdotdev-source": "./src/v3/utils/retries.ts",
"@triggerdotdev/source": "./src/v3/utils/retries.ts",
"types": "./dist/esm/v3/utils/retries.d.ts",
"default": "./dist/esm/v3/utils/retries.js"
},
@@ -372,7 +373,7 @@
},
"./v3/utils/structuredLogger": {
"import": {
"triggerdotdev-source": "./src/v3/utils/structuredLogger.ts",
"@triggerdotdev/source": "./src/v3/utils/structuredLogger.ts",
"types": "./dist/esm/v3/utils/structuredLogger.d.ts",
"default": "./dist/esm/v3/utils/structuredLogger.js"
},
@@ -383,7 +384,7 @@
},
"./v3/zodfetch": {
"import": {
"triggerdotdev-source": "./src/v3/zodfetch.ts",
"@triggerdotdev/source": "./src/v3/zodfetch.ts",
"types": "./dist/esm/v3/zodfetch.d.ts",
"default": "./dist/esm/v3/zodfetch.js"
},
@@ -394,7 +395,7 @@
},
"./v3/zodMessageHandler": {
"import": {
"triggerdotdev-source": "./src/v3/zodMessageHandler.ts",
"@triggerdotdev/source": "./src/v3/zodMessageHandler.ts",
"types": "./dist/esm/v3/zodMessageHandler.d.ts",
"default": "./dist/esm/v3/zodMessageHandler.js"
},
@@ -405,7 +406,7 @@
},
"./v3/zodNamespace": {
"import": {
"triggerdotdev-source": "./src/v3/zodNamespace.ts",
"@triggerdotdev/source": "./src/v3/zodNamespace.ts",
"types": "./dist/esm/v3/zodNamespace.d.ts",
"default": "./dist/esm/v3/zodNamespace.js"
},
@@ -416,7 +417,7 @@
},
"./v3/zodSocket": {
"import": {
"triggerdotdev-source": "./src/v3/zodSocket.ts",
"@triggerdotdev/source": "./src/v3/zodSocket.ts",
"types": "./dist/esm/v3/zodSocket.d.ts",
"default": "./dist/esm/v3/zodSocket.js"
},
@@ -427,7 +428,7 @@
},
"./v3/zodIpc": {
"import": {
"triggerdotdev-source": "./src/v3/zodIpc.ts",
"@triggerdotdev/source": "./src/v3/zodIpc.ts",
"types": "./dist/esm/v3/zodIpc.d.ts",
"default": "./dist/esm/v3/zodIpc.js"
},
@@ -438,7 +439,7 @@
},
"./v3/utils/timers": {
"import": {
"triggerdotdev-source": "./src/v3/utils/timers.ts",
"@triggerdotdev/source": "./src/v3/utils/timers.ts",
"types": "./dist/esm/v3/utils/timers.d.ts",
"default": "./dist/esm/v3/utils/timers.js"
},
@@ -449,7 +450,7 @@
},
"./v3/dev": {
"import": {
"triggerdotdev-source": "./src/v3/dev/index.ts",
"@triggerdotdev/source": "./src/v3/dev/index.ts",
"types": "./dist/esm/v3/dev/index.d.ts",
"default": "./dist/esm/v3/dev/index.js"
},
@@ -460,7 +461,7 @@
},
"./v3/prod": {
"import": {
"triggerdotdev-source": "./src/v3/prod/index.ts",
"@triggerdotdev/source": "./src/v3/prod/index.ts",
"types": "./dist/esm/v3/prod/index.d.ts",
"default": "./dist/esm/v3/prod/index.js"
},
@@ -471,7 +472,7 @@
},
"./v3/workers": {
"import": {
"triggerdotdev-source": "./src/v3/workers/index.ts",
"@triggerdotdev/source": "./src/v3/workers/index.ts",
"types": "./dist/esm/v3/workers/index.d.ts",
"default": "./dist/esm/v3/workers/index.js"
},
@@ -482,7 +483,7 @@
},
"./v3/schemas": {
"import": {
"triggerdotdev-source": "./src/v3/schemas/index.ts",
"@triggerdotdev/source": "./src/v3/schemas/index.ts",
"types": "./dist/esm/v3/schemas/index.d.ts",
"default": "./dist/esm/v3/schemas/index.js"
},
@@ -0,0 +1,96 @@
import { relative, join, posix, dirname } from "node:path";
import { glob } from "tinyglobby";
import { copyFile, mkdir } from "node:fs/promises";
import { BuildExtension } from "../build/extensions.js";
export type AdditionalFilesOptions = {
files: string[];
};
export function additionalFiles(options: AdditionalFilesOptions): BuildExtension {
return {
name: "additionalFiles",
async onBuildComplete(context, manifest) {
// Copy any static assets to the destination
const staticAssets = await findStaticAssetFiles(options.files ?? [], manifest.outputPath, {
cwd: context.workingDir,
});
for (const { assets, matcher } of staticAssets) {
if (assets.length === 0) {
console.warn("No files found for matcher", matcher);
}
}
await copyStaticAssets(staticAssets);
},
};
}
type MatchedStaticAssets = { source: string; destination: string }[];
type FoundStaticAssetFiles = Array<{
matcher: string;
assets: MatchedStaticAssets;
}>;
async function findStaticAssetFiles(
matchers: string[],
destinationPath: string,
options?: { cwd?: string; ignore?: string[] }
): Promise<FoundStaticAssetFiles> {
const result: FoundStaticAssetFiles = [];
for (const matcher of matchers) {
const assets = await findStaticAssetsForMatcher(matcher, destinationPath, options);
result.push({ matcher, assets });
}
return result;
}
async function findStaticAssetsForMatcher(
matcher: string,
destinationPath: string,
options?: { cwd?: string; ignore?: string[] }
): Promise<MatchedStaticAssets> {
const result: MatchedStaticAssets = [];
const files = await glob({
patterns: [matcher],
cwd: options?.cwd,
ignore: options?.ignore ?? [],
onlyFiles: true,
absolute: true,
});
let matches = 0;
for (const file of files) {
matches++;
const pathInsideDestinationDir = relative(options?.cwd ?? process.cwd(), file)
.split(posix.sep)
.filter((p) => p !== "..")
.join(posix.sep);
const relativeDestinationPath = join(destinationPath, pathInsideDestinationDir);
result.push({
source: file,
destination: relativeDestinationPath,
});
}
return result;
}
async function copyStaticAssets(staticAssetFiles: FoundStaticAssetFiles): Promise<void> {
for (const { assets } of staticAssetFiles) {
for (const { source, destination } of assets) {
await mkdir(dirname(destination), { recursive: true });
await copyFile(source, destination);
}
}
}
@@ -0,0 +1,97 @@
import { dirname } from "node:path";
import { readPackageJSON } from "pkg-types";
import { BuildExtension } from "../build/extensions.js";
export type AdditionalPackagesOptions = {
packages: string[];
};
/**
* Add additional packages to the build when deploying, useful when you are using the bin command of a package by shelling out to it.
* You can pass the name of the package, and it's version will be resolved from the locally installed version. If the version cannot be automatically resolved, it will resolve to the latest version, or you can specify the version using `@` syntax.
* @example
*
* ```ts
* additionalPackages({
* packages: ["wrangler", "prisma@3.0.0"]
* });
*/
export function additionalPackages(options: AdditionalPackagesOptions): BuildExtension {
return {
name: "additionalPackages",
async onBuildStart(context) {
if (context.target !== "deploy") {
return;
}
const dependencies: Record<string, string> = {};
for (const pkg of options.packages) {
const { name, version } = parsePackageName(pkg);
if (version) {
dependencies[name] = version;
} else {
try {
// Lets try and resolve the version from the local package.json
const modulePath = await context.resolvePath(name);
if (!modulePath) {
dependencies[name] = "latest";
continue;
}
console.log("Resolved module path", { modulePath });
const packageJSON = await readPackageJSON(dirname(modulePath));
if (packageJSON.version) {
dependencies[name] = packageJSON.version;
} else {
console.warn(`Could not resolve version for package ${name}, defaulting to latest`);
dependencies[name] = "latest";
}
} catch (error) {
console.warn(
`Could not resolve version for package ${name}, defaulting to latest`,
error
);
dependencies[name] = "latest";
}
}
}
context.addLayer({
id: "additionalPackages",
dependencies,
});
},
};
}
// This needs to handle packages like @taskhero/config@1.0.0, wrangler, wrangler@1.0.0, @taskhero/config, etc.
function parsePackageName(pkg: string): {
name: string;
version?: string;
} {
// Regular expression to match package names and versions
const regex = /^(@?[a-z0-9-~][a-z0-9-._~]*\/)?([a-z0-9-~][a-z0-9-._~]*)(@(.+))?$/i;
const match = pkg.match(regex);
if (!match) {
throw new Error(`Invalid package name: ${pkg}`);
}
const [, scope, packageName, , version] = match;
if (!packageName) {
throw new Error(`Invalid package name: ${pkg}`);
}
return {
name: scope ? `${scope}${packageName}` : packageName,
version,
};
}
+3
View File
@@ -1 +1,4 @@
export * from "./emitDecoratorMetadata.js";
export * from "./additionalFiles.js";
export * from "./additionalPackages.js";
export * from "./prisma.js";
+126
View File
@@ -0,0 +1,126 @@
import assert from "node:assert";
import { existsSync } from "node:fs";
import { cp } from "node:fs/promises";
import { join, resolve } from "node:path";
import { BuildContext, BuildExtension } from "../build/extensions.js";
import { BuildManifest, BuildTarget } from "../schemas/build.js";
import { binaryForRuntime } from "../build/runtime.js";
export type PrismaExtensionOptions = {
schema: string;
migrate?: boolean;
version?: string;
};
const BINARY_TARGET = "linux-arm64-openssl-3.0.x";
export class PrismaExtension implements BuildExtension {
moduleExternals: string[];
public readonly name = "PrismaExtension";
private _resolvedSchemaPath?: string;
constructor(private options: PrismaExtensionOptions) {
this.moduleExternals = ["@prisma/client", "@prisma/engines"];
}
externalsForTarget(target: BuildTarget) {
if (target === "dev") {
return [];
}
return this.moduleExternals;
}
async onBuildStart(context: BuildContext) {
if (context.target === "dev") {
return;
}
// Resolve the path to the prisma schema, relative to the config.directory
this._resolvedSchemaPath = resolve(context.workingDir, this.options.schema);
console.log(`Resolved the prisma schema to: ${this._resolvedSchemaPath}`);
// Check that the prisma schema exists
if (!existsSync(this._resolvedSchemaPath)) {
throw new Error(
`PrismaExtension could not find the prisma schema at ${this._resolvedSchemaPath}. Make sure the path is correct: ${this.options.schema}, relative to the working dir ${context.workingDir}`
);
}
}
async onBuildComplete(context: BuildContext, manifest: BuildManifest) {
if (context.target === "dev") {
return;
}
assert(this._resolvedSchemaPath, "Resolved schema path is not set");
console.log("Looking for @prisma/client in the externals", {
externals: manifest.externals,
});
const prismaExternal = manifest.externals?.find(
(external) => external.name === "@prisma/client"
);
const version = prismaExternal?.version ?? this.options.version;
if (!version) {
throw new Error(
`PrismaExtension could not determine the version of @prisma/client. It's possible that the @prisma/client was not used in the project. If this isn't the case, please provide a version in the PrismaExtension options.`
);
}
console.log(`PrismaExtension is generating the Prisma client for version ${version}`);
// Now we need to add a layer that:
// Copies the prisma schema to the build outputPath
// Adds the `prisma` CLI dependency to the dependencies
// Adds the `prisma generate` command, which generates the Prisma client
const schemaDestinationPath = join(manifest.outputPath, "prisma", "schema.prisma");
// Copy the prisma schema to the build output path
console.log(
`Copying the prisma schema from ${this._resolvedSchemaPath} to ${schemaDestinationPath}`
);
await cp(this._resolvedSchemaPath, schemaDestinationPath);
const commands = [
`${binaryForRuntime(
manifest.runtime
)} node_modules/prisma/build/index.js generate --schema=./prisma/schema.prisma`,
];
if (this.options.migrate) {
commands.push(
`${binaryForRuntime(manifest.runtime)} node_modules/prisma/build/index.js migrate deploy`
);
}
context.addLayer({
id: "prisma",
commands,
dependencies: {
prisma: version,
},
build: this.options.migrate
? {
env: {
DATABASE_URL: manifest.deploy.env?.DATABASE_URL,
DATABASE_DIRECT_URL:
manifest.deploy.env?.DATABASE_DIRECT_URL ??
manifest.deploy.env?.DIRECT_URL ??
manifest.deploy.env?.DATABASE_URL,
DIRECT_URL:
manifest.deploy.env?.DATABASE_DIRECT_URL ??
manifest.deploy.env?.DIRECT_URL ??
manifest.deploy.env?.DATABASE_URL,
},
}
: {},
});
}
}
+2 -1
View File
@@ -4,6 +4,7 @@
"compilerOptions": {
"isolatedDeclarations": false,
"composite": true,
"sourceMap": true
"sourceMap": true,
"customConditions": ["@triggerdotdev/source"]
}
}
+4 -4
View File
@@ -22,7 +22,7 @@
"./v3/extensions": "./src/v3/extensions.ts"
},
"sourceDialects": [
"triggerdotdev-source"
"@triggerdotdev/source"
]
},
"scripts": {
@@ -71,7 +71,7 @@
"./package.json": "./package.json",
".": {
"import": {
"triggerdotdev-source": "./src/index.ts",
"@triggerdotdev/source": "./src/index.ts",
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
@@ -82,7 +82,7 @@
},
"./v3": {
"import": {
"triggerdotdev-source": "./src/v3/index.ts",
"@triggerdotdev/source": "./src/v3/index.ts",
"types": "./dist/esm/v3/index.d.ts",
"default": "./dist/esm/v3/index.js"
},
@@ -93,7 +93,7 @@
},
"./v3/extensions": {
"import": {
"triggerdotdev-source": "./src/v3/extensions.ts",
"@triggerdotdev/source": "./src/v3/extensions.ts",
"types": "./dist/esm/v3/extensions.d.ts",
"default": "./dist/esm/v3/extensions.js"
},
+188 -48
View File
@@ -1171,6 +1171,9 @@ importers:
superjson:
specifier: ^2.2.1
version: 2.2.1
tinyglobby:
specifier: ^0.2.2
version: 0.2.2
zod:
specifier: 3.23.8
version: 3.23.8
@@ -1455,6 +1458,9 @@ importers:
typeorm:
specifier: ^0.3.20
version: 0.3.20(pg@8.11.5)(ts-node@10.9.2)
wrangler:
specifier: 3.70.0
version: 3.70.0
yt-dlp-wrap:
specifier: ^2.3.12
version: 2.3.12
@@ -3838,6 +3844,13 @@ packages:
mime: 3.0.0
dev: true
/@cloudflare/kv-asset-handler@0.3.4:
resolution: {integrity: sha512-YLPHc8yASwjNkmcDMQMY35yiWjoKAKnhUbPRszBRS0YgH+IXtsMp61j+yTcnCE3oO2DgP0U3iejLC8FTtKDC8Q==}
engines: {node: '>=16.13'}
dependencies:
mime: 3.0.0
dev: false
/@cloudflare/workerd-darwin-64@1.20240512.0:
resolution: {integrity: sha512-VMp+CsSHFALQiBzPdQ5dDI4T1qwLu0mQ0aeKVNDosXjueN0f3zj/lf+mFil5/9jBbG3t4mG0y+6MMnalP9Lobw==}
engines: {node: '>=16'}
@@ -3847,6 +3860,15 @@ packages:
dev: true
optional: true
/@cloudflare/workerd-darwin-64@1.20240806.0:
resolution: {integrity: sha512-FqcVBBCO//I39K5F+HqE/v+UkqY1UrRnS653Jv+XsNNH9TpX5fTs7VCKG4kDSnmxlAaKttyIN5sMEt7lpuNExQ==}
engines: {node: '>=16'}
cpu: [x64]
os: [darwin]
requiresBuild: true
dev: false
optional: true
/@cloudflare/workerd-darwin-arm64@1.20240512.0:
resolution: {integrity: sha512-lZktXGmzMrB5rJqY9+PmnNfv1HKlj/YLZwMjPfF0WVKHUFdvQbAHsi7NlKv6mW9uIvlZnS+K4sIkWc0MDXcRnA==}
engines: {node: '>=16'}
@@ -3856,6 +3878,15 @@ packages:
dev: true
optional: true
/@cloudflare/workerd-darwin-arm64@1.20240806.0:
resolution: {integrity: sha512-8c3KvmzYp/wg+82KHSOzDetJK+pThH4MTrU1OsjmsR2cUfedm5dk5Lah9/0Ld68+6A0umFACi4W2xJHs/RoBpA==}
engines: {node: '>=16'}
cpu: [arm64]
os: [darwin]
requiresBuild: true
dev: false
optional: true
/@cloudflare/workerd-linux-64@1.20240512.0:
resolution: {integrity: sha512-wrHvqCZZqXz6Y3MUTn/9pQNsvaoNjbJpuA6vcXsXu8iCzJi911iVW2WUEBX+MpUWD+mBIP0oXni5tTlhkokOPw==}
engines: {node: '>=16'}
@@ -3865,6 +3896,15 @@ packages:
dev: true
optional: true
/@cloudflare/workerd-linux-64@1.20240806.0:
resolution: {integrity: sha512-/149Bpxw4e2p5QqnBc06g0mx+4sZYh9j0doilnt0wk/uqYkLp0DdXGMQVRB74sBLg2UD3wW8amn1w3KyFhK2tQ==}
engines: {node: '>=16'}
cpu: [x64]
os: [linux]
requiresBuild: true
dev: false
optional: true
/@cloudflare/workerd-linux-arm64@1.20240512.0:
resolution: {integrity: sha512-YPezHMySL9J9tFdzxz390eBswQ//QJNYcZolz9Dgvb3FEfdpK345cE/bsWbMOqw5ws2f82l388epoenghtYvAg==}
engines: {node: '>=16'}
@@ -3874,6 +3914,15 @@ packages:
dev: true
optional: true
/@cloudflare/workerd-linux-arm64@1.20240806.0:
resolution: {integrity: sha512-lacDWY3S1rKL/xT6iMtTQJEKmTTKrBavPczInEuBFXElmrS6IwVjZwv8hhVm32piyNt/AuFu9BYoJALi9D85/g==}
engines: {node: '>=16'}
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: false
optional: true
/@cloudflare/workerd-windows-64@1.20240512.0:
resolution: {integrity: sha512-SxKapDrIYSscMR7lGIp/av0l6vokjH4xQ9ACxHgXh+OdOus9azppSmjaPyw4/ePvg7yqpkaNjf9o258IxWtvKQ==}
engines: {node: '>=16'}
@@ -3883,6 +3932,19 @@ packages:
dev: true
optional: true
/@cloudflare/workerd-windows-64@1.20240806.0:
resolution: {integrity: sha512-hC6JEfTSQK6//Lg+D54TLVn1ceTPY+fv4MXqDZIYlPP53iN+dL8Xd0utn2SG57UYdlL5FRAhm/EWHcATZg1RgA==}
engines: {node: '>=16'}
cpu: [x64]
os: [win32]
requiresBuild: true
dev: false
optional: true
/@cloudflare/workers-shared@0.1.0:
resolution: {integrity: sha512-SyD4iw6jM4anZaG+ujgVETV4fulF2KHBOW31eavbVN7TNpk2l4aJgwY1YSPK00IKSWsoQuH2TigR446KuT5lqQ==}
dev: false
/@cloudflare/workers-types@4.20240512.0:
resolution: {integrity: sha512-o2yTEWg+YK/I1t/Me+dA0oarO0aCbjibp6wSeaw52DSE9tDyKJ7S+Qdyw/XsMrKn4t8kF6f/YOba+9O4MJfW9w==}
dev: true
@@ -4191,7 +4253,6 @@ packages:
esbuild: '*'
dependencies:
esbuild: 0.17.19
dev: true
/@esbuild-plugins/node-modules-polyfill@0.2.2(esbuild@0.17.19):
resolution: {integrity: sha512-LXV7QsWJxRuMYvKbiznh+U1ilIop3g2TeKRzUxOG5X3YITc8JyyTa90BmLwqqv0YnX4v32CSlG+vsziZp9dMvA==}
@@ -4201,7 +4262,6 @@ packages:
esbuild: 0.17.19
escape-string-regexp: 4.0.0
rollup-plugin-node-polyfills: 0.2.1
dev: true
/@esbuild/aix-ppc64@0.19.11:
resolution: {integrity: sha512-FnzU0LyE3ySQk7UntJO4+qIiQgI7KoODnZg5xzXIrFJlKd2P2gwHsHY4927xj9y5PJmJSzULiUCWmv7iWnNa7g==}
@@ -4252,7 +4312,6 @@ packages:
cpu: [arm64]
os: [android]
requiresBuild: true
dev: true
optional: true
/@esbuild/android-arm64@0.17.6:
@@ -4331,7 +4390,6 @@ packages:
cpu: [arm]
os: [android]
requiresBuild: true
dev: true
optional: true
/@esbuild/android-arm@0.17.6:
@@ -4401,7 +4459,6 @@ packages:
cpu: [x64]
os: [android]
requiresBuild: true
dev: true
optional: true
/@esbuild/android-x64@0.17.6:
@@ -4471,7 +4528,6 @@ packages:
cpu: [arm64]
os: [darwin]
requiresBuild: true
dev: true
optional: true
/@esbuild/darwin-arm64@0.17.6:
@@ -4541,7 +4597,6 @@ packages:
cpu: [x64]
os: [darwin]
requiresBuild: true
dev: true
optional: true
/@esbuild/darwin-x64@0.17.6:
@@ -4611,7 +4666,6 @@ packages:
cpu: [arm64]
os: [freebsd]
requiresBuild: true
dev: true
optional: true
/@esbuild/freebsd-arm64@0.17.6:
@@ -4681,7 +4735,6 @@ packages:
cpu: [x64]
os: [freebsd]
requiresBuild: true
dev: true
optional: true
/@esbuild/freebsd-x64@0.17.6:
@@ -4751,7 +4804,6 @@ packages:
cpu: [arm64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@esbuild/linux-arm64@0.17.6:
@@ -4821,7 +4873,6 @@ packages:
cpu: [arm]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@esbuild/linux-arm@0.17.6:
@@ -4891,7 +4942,6 @@ packages:
cpu: [ia32]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@esbuild/linux-ia32@0.17.6:
@@ -4970,7 +5020,6 @@ packages:
cpu: [loong64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@esbuild/linux-loong64@0.17.6:
@@ -5040,7 +5089,6 @@ packages:
cpu: [mips64el]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@esbuild/linux-mips64el@0.17.6:
@@ -5110,7 +5158,6 @@ packages:
cpu: [ppc64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@esbuild/linux-ppc64@0.17.6:
@@ -5180,7 +5227,6 @@ packages:
cpu: [riscv64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@esbuild/linux-riscv64@0.17.6:
@@ -5250,7 +5296,6 @@ packages:
cpu: [s390x]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@esbuild/linux-s390x@0.17.6:
@@ -5320,7 +5365,6 @@ packages:
cpu: [x64]
os: [linux]
requiresBuild: true
dev: true
optional: true
/@esbuild/linux-x64@0.17.6:
@@ -5390,7 +5434,6 @@ packages:
cpu: [x64]
os: [netbsd]
requiresBuild: true
dev: true
optional: true
/@esbuild/netbsd-x64@0.17.6:
@@ -5468,7 +5511,6 @@ packages:
cpu: [x64]
os: [openbsd]
requiresBuild: true
dev: true
optional: true
/@esbuild/openbsd-x64@0.17.6:
@@ -5538,7 +5580,6 @@ packages:
cpu: [x64]
os: [sunos]
requiresBuild: true
dev: true
optional: true
/@esbuild/sunos-x64@0.17.6:
@@ -5608,7 +5649,6 @@ packages:
cpu: [arm64]
os: [win32]
requiresBuild: true
dev: true
optional: true
/@esbuild/win32-arm64@0.17.6:
@@ -5678,7 +5718,6 @@ packages:
cpu: [ia32]
os: [win32]
requiresBuild: true
dev: true
optional: true
/@esbuild/win32-ia32@0.17.6:
@@ -5748,7 +5787,6 @@ packages:
cpu: [x64]
os: [win32]
requiresBuild: true
dev: true
optional: true
/@esbuild/win32-x64@0.17.6:
@@ -12865,7 +12903,6 @@ packages:
resolution: {integrity: sha512-y6PJDYN4xYBxwd22l+OVH35N+1fCYWiuC3aiP2SlXVE6Lo7SS+rSx9r89hLxrP4pn6n1lBGhHJ12pj3F3Mpttw==}
dependencies:
'@types/node': 18.19.20
dev: true
/@types/node@12.20.55:
resolution: {integrity: sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==}
@@ -14061,7 +14098,6 @@ packages:
resolution: {integrity: sha512-xvsWESUJn0JN421Xb9MQw6AsMHRCUknCe0Wjlxvjud80mU4E6hQf1A6NzQKcYNmYw62MfzEtXc+badstZP3JpQ==}
dependencies:
printable-characters: 1.0.42
dev: true
/asn1@0.2.6:
resolution: {integrity: sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==}
@@ -14500,7 +14536,6 @@ packages:
/blake3-wasm@2.1.5:
resolution: {integrity: sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g==}
dev: true
/bluebird@3.4.7:
resolution: {integrity: sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA==}
@@ -14825,7 +14860,6 @@ packages:
tslib: 2.6.2
transitivePeerDependencies:
- supports-color
dev: true
/case-anything@2.1.13:
resolution: {integrity: sha512-zlOQ80VrQ2Ue+ymH5OuM/DlDq64mEm+B9UTdHULv5osUMD6HalNTblf2b1u/m6QecjsnOkBpqVZ+XPwIVsy7Ng==}
@@ -15714,7 +15748,6 @@ packages:
/data-uri-to-buffer@2.0.2:
resolution: {integrity: sha512-ND9qDTLc6diwj+Xe5cdAgVTbLVdXbtxTJRXRhli8Mowuaan+0EJOtdqJ0QCHNSSPyoXGx9HX2/VMnKeC34AChA==}
dev: true
/data-uri-to-buffer@3.0.1:
resolution: {integrity: sha512-WboRycPNsVw3B3TL559F7kuBUM4d8CgMEvk6xEJlOp7OBPjt6G7z8WMWlD2rOFZLk6OYfFIUGsCOWzcQH9K2og==}
@@ -15761,6 +15794,10 @@ packages:
resolution: {integrity: sha512-68s5jYdlvasItOJnCuI2Q9s4q98g0pCyL3HrcKJu8KNugUl8ahgmZYg38ysLTgQjjXX3H8CJLkAvWrclWfcalw==}
dev: false
/date-fns@3.6.0:
resolution: {integrity: sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==}
dev: false
/dayjs@1.11.10:
resolution: {integrity: sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==}
dev: false
@@ -16791,7 +16828,6 @@ packages:
'@esbuild/win32-arm64': 0.17.19
'@esbuild/win32-ia32': 0.17.19
'@esbuild/win32-x64': 0.17.19
dev: true
/esbuild@0.17.6:
resolution: {integrity: sha512-TKFRp9TxrJDdRWfSsSERKEovm6v30iHnrjlcGhLBOtReE28Yp1VSBRfO3GTaOFMoxsNerx4TjrhzSuma9ha83Q==}
@@ -17590,7 +17626,6 @@ packages:
/estree-walker@0.6.1:
resolution: {integrity: sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==}
dev: true
/estree-walker@3.0.3:
resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==}
@@ -17690,7 +17725,6 @@ packages:
/exit-hook@2.2.1:
resolution: {integrity: sha512-eNTPlAD67BmP31LDINZ3U7HSF8l57TxOY2PmBJ1shpCvpnxBF93mWCE8YHBnXs8qiUZJc9WDcWIeC3a2HIAMfw==}
engines: {node: '>=6'}
dev: true
/exit@0.1.2:
resolution: {integrity: sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==}
@@ -17912,6 +17946,17 @@ packages:
bser: 2.1.1
dev: true
/fdir@6.2.0(picomatch@4.0.2):
resolution: {integrity: sha512-9XaWcDl0riOX5j2kYfy0kKdg7skw3IY6kA4LFT8Tk2yF9UdrADUy8D6AJuBLtf7ISm/MksumwAHE3WVbMRyCLw==}
peerDependencies:
picomatch: ^3 || ^4
peerDependenciesMeta:
picomatch:
optional: true
dependencies:
picomatch: 4.0.2
dev: false
/fetch-blob@3.2.0:
resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==}
engines: {node: ^12.20 || >= 14.13}
@@ -18333,7 +18378,6 @@ packages:
dependencies:
data-uri-to-buffer: 2.0.2
source-map: 0.6.1
dev: true
/get-stream@4.1.0:
resolution: {integrity: sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==}
@@ -20774,7 +20818,6 @@ packages:
resolution: {integrity: sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==}
dependencies:
sourcemap-codec: 1.4.8
dev: true
/magic-string@0.30.8:
resolution: {integrity: sha512-ISQTe55T2ao7XtlAStud6qwYPZjE4GK1S/BeVPus4jrq6JuOnQ00YKQC581RWhR122W7msZV263KzVeLoqidyQ==}
@@ -21355,7 +21398,6 @@ packages:
resolution: {integrity: sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==}
engines: {node: '>=10.0.0'}
hasBin: true
dev: true
/mimic-fn@2.1.0:
resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==}
@@ -21403,6 +21445,29 @@ packages:
- utf-8-validate
dev: true
/miniflare@3.20240806.0:
resolution: {integrity: sha512-jDsXBJOLUVpIQXHsluX3xV0piDxXolTCsxdje2Ex2LTC9PsSoBIkMwvCmnCxe9wpJJCq8rb0UMyeEn3KOF3LOw==}
engines: {node: '>=16.13'}
hasBin: true
dependencies:
'@cspotcode/source-map-support': 0.8.1
acorn: 8.12.1
acorn-walk: 8.3.2
capnp-ts: 0.7.0
exit-hook: 2.2.1
glob-to-regexp: 0.4.1
stoppable: 1.1.0
undici: 5.28.4
workerd: 1.20240806.0
ws: 8.18.0
youch: 3.3.3
zod: 3.23.8
transitivePeerDependencies:
- bufferutil
- supports-color
- utf-8-validate
dev: false
/minimal-polyfills@2.2.2:
resolution: {integrity: sha512-eEOUq/LH/DbLWihrxUP050Wi7H/N/I2dQT98Ep6SqOpmIbk4sXOI4wqalve66QoZa+6oljbZWU6I6T4dehQGmw==}
dev: false
@@ -21634,7 +21699,6 @@ packages:
/mustache@4.2.0:
resolution: {integrity: sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==}
hasBin: true
dev: true
/mute-stream@1.0.0:
resolution: {integrity: sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==}
@@ -21676,6 +21740,7 @@ packages:
resolution: {integrity: sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==}
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true
dev: true
/nanoid@3.3.7:
resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==}
@@ -21837,7 +21902,6 @@ packages:
/node-forge@1.3.1:
resolution: {integrity: sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==}
engines: {node: '>= 6.13.0'}
dev: true
/node-int64@0.4.0:
resolution: {integrity: sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==}
@@ -22855,6 +22919,11 @@ packages:
resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==}
engines: {node: '>=8.6'}
/picomatch@4.0.2:
resolution: {integrity: sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==}
engines: {node: '>=12'}
dev: false
/pidtree@0.3.1:
resolution: {integrity: sha512-qQbW94hLHEqCg7nhby4yRC7G2+jYHY4Rguc2bjw7Uug4GIJuu1tvf2uHaZv5Q8zdt+WKJ6qK1FOI6amaWUo5FA==}
engines: {node: '>=0.10'}
@@ -23269,7 +23338,7 @@ packages:
resolution: {integrity: sha512-gY/ACJtJPSmUFPDCHtX78+01fHa64FaU4zaaWfuh1MhGJISufJAH4cun6k/8fwsHYeK4UQmENQK+tRLCFJE8JQ==}
engines: {node: ^10 || ^12 || >=14}
dependencies:
nanoid: 3.3.6
nanoid: 3.3.7
picocolors: 1.0.0
source-map-js: 1.2.0
dev: false
@@ -23518,7 +23587,6 @@ packages:
/printable-characters@1.0.42:
resolution: {integrity: sha512-dKp+C4iXWK4vVYZmYSd0KBH5F/h1HoZRsbJ82AVKRO3PEo8L4lBS/vLwhVtpwwuYcoIsVY+1JYKR268yn480uQ==}
dev: true
/prism-react-renderer@2.1.0(react@18.2.0):
resolution: {integrity: sha512-I5cvXHjA1PVGbGm1MsWCpvBCRrYyxEri0MC7/JbfIfYfcXAxHyO5PaUjs3A8H5GW6kJcLhTHxxMaOZZpRZD2iQ==}
@@ -24750,7 +24818,6 @@ packages:
/resolve.exports@2.0.2:
resolution: {integrity: sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==}
engines: {node: '>=10'}
dev: true
/resolve@1.22.4:
resolution: {integrity: sha512-PXNdCiPqDqeUou+w1C2eTQbNfxKSuMxqTCuvlmmMsk1NWHL5fRrhY6Pl0qEYYc6+QqGClco1Qj8XnjPego4wfg==}
@@ -24858,19 +24925,16 @@ packages:
estree-walker: 0.6.1
magic-string: 0.25.9
rollup-pluginutils: 2.8.2
dev: true
/rollup-plugin-node-polyfills@0.2.1:
resolution: {integrity: sha512-4kCrKPTJ6sK4/gLL/U5QzVT8cxJcofO0OU74tnB19F40cmuAKSzH5/siithxlofFEjwvw1YAhPmbvGNA6jEroA==}
dependencies:
rollup-plugin-inject: 3.0.2
dev: true
/rollup-pluginutils@2.8.2:
resolution: {integrity: sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==}
dependencies:
estree-walker: 0.6.1
dev: true
/rollup@3.10.0:
resolution: {integrity: sha512-JmRYz44NjC1MjVF2VKxc0M1a97vn+cDxeqWmnwyAF4FvpjK8YFdHpaqvQB+3IxCvX05vJxKZkoMDU8TShhmJVA==}
@@ -25050,7 +25114,6 @@ packages:
dependencies:
'@types/node-forge': 1.3.10
node-forge: 1.3.1
dev: true
/sembear@0.5.2:
resolution: {integrity: sha512-Ij1vCAdFgWABd7zTg50Xw1/p0JgESNxuLlneEAsmBrKishA06ulTTL/SHGmNy2Zud7+rKrHTKNI6moJsn1ppAQ==}
@@ -25674,7 +25737,6 @@ packages:
dependencies:
as-table: 1.0.55
get-source: 2.0.12
dev: true
/standard-as-callback@2.1.0:
resolution: {integrity: sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==}
@@ -25703,7 +25765,6 @@ packages:
/stoppable@1.1.0:
resolution: {integrity: sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==}
engines: {node: '>=4', npm: '>=6'}
dev: true
/stream-buffers@3.0.2:
resolution: {integrity: sha512-DQi1h8VEBA/lURbSwFtEHnSTb9s2/pwLEaFuNhXwy1Dx3Sa0lOuYT2yNUr4/j2fs8oCAMANtrZ5OrPZtyVs3MQ==}
@@ -26343,6 +26404,14 @@ packages:
resolution: {integrity: sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==}
dev: false
/tinyglobby@0.2.2:
resolution: {integrity: sha512-mZ2sDMaySvi1PkTp4lTo1In2zjU+cY8OvZsfwrDrx3YGRbXPX1/cbPwCR9zkm3O/Fz9Jo0F1HNgIQ1b8BepqyQ==}
engines: {node: '>=12.0.0'}
dependencies:
fdir: 6.2.0(picomatch@4.0.2)
picomatch: 4.0.2
dev: false
/tinygradient@1.1.5:
resolution: {integrity: sha512-8nIfc2vgQ4TeLnk2lFj4tRLvvJwEfQuabdsmvDdQPT0xlk9TaNtpGd6nNRxXoK6vQhN6RSzj+Cnp5tTQmpxmbw==}
dependencies:
@@ -27208,6 +27277,17 @@ packages:
dependencies:
'@fastify/busboy': 2.0.0
/unenv-nightly@1.10.0-1717606461.a117952:
resolution: {integrity: sha512-u3TfBX02WzbHTpaEfWEKwDijDSFAHcgXkayUZ+MVDrjhLFvgAJzFGTSTmwlEhwWi2exyRQey23ah9wELMM6etg==}
dependencies:
consola: 3.2.3
defu: 6.1.4
mime: 3.0.0
node-fetch-native: 1.6.4
pathe: 1.1.2
ufo: 1.5.4
dev: false
/unicode-canonical-property-names-ecmascript@2.0.0:
resolution: {integrity: sha512-yY5PpDlfVIU5+y/BSCxAJRBIS1Zc2dDG3Ujq+sR0U+JjUevW2JhocOF+soROYDSaAezOzOKuyyixhD6mBknSmQ==}
engines: {node: '>=4'}
@@ -28393,6 +28473,19 @@ packages:
'@cloudflare/workerd-windows-64': 1.20240512.0
dev: true
/workerd@1.20240806.0:
resolution: {integrity: sha512-yyNtyzTMgVY0sgYijHBONqZFVXsOFGj2jDjS8MF/RbO2ZdGROvs4Hkc/9QnmqFWahE0STxXeJ1yW1yVotdF0UQ==}
engines: {node: '>=16'}
hasBin: true
requiresBuild: true
optionalDependencies:
'@cloudflare/workerd-darwin-64': 1.20240806.0
'@cloudflare/workerd-darwin-arm64': 1.20240806.0
'@cloudflare/workerd-linux-64': 1.20240806.0
'@cloudflare/workerd-linux-arm64': 1.20240806.0
'@cloudflare/workerd-windows-64': 1.20240806.0
dev: false
/wrangler@3.57.1(@cloudflare/workers-types@4.20240512.0):
resolution: {integrity: sha512-M8YnWUwdrb8AFiRePtVnzlDn02OX4osWvdl8oVh6eyZqqkqXYg7lwlYBr14Qj92pMN4JvMBmDZoukkYHvwpJRg==}
engines: {node: '>=16.17.0'}
@@ -28426,6 +28519,42 @@ packages:
- utf-8-validate
dev: true
/wrangler@3.70.0:
resolution: {integrity: sha512-aMtCEXmH02SIxbxOFGGuJ8ZemmG9W+IcNRh5D4qIKgzSxqy0mt9mRoPNPSv1geGB2/8YAyeLGPf+tB4lxz+ssg==}
engines: {node: '>=16.17.0'}
hasBin: true
peerDependencies:
'@cloudflare/workers-types': ^4.20240806.0
peerDependenciesMeta:
'@cloudflare/workers-types':
optional: true
dependencies:
'@cloudflare/kv-asset-handler': 0.3.4
'@cloudflare/workers-shared': 0.1.0
'@esbuild-plugins/node-globals-polyfill': 0.2.3(esbuild@0.17.19)
'@esbuild-plugins/node-modules-polyfill': 0.2.2(esbuild@0.17.19)
blake3-wasm: 2.1.5
chokidar: 3.6.0
date-fns: 3.6.0
esbuild: 0.17.19
miniflare: 3.20240806.0
nanoid: 3.3.7
path-to-regexp: 6.2.1
resolve: 1.22.8
resolve.exports: 2.0.2
selfsigned: 2.4.1
source-map: 0.6.1
unenv: /unenv-nightly@1.10.0-1717606461.a117952
workerd: 1.20240806.0
xxhash-wasm: 1.0.2
optionalDependencies:
fsevents: 2.3.3
transitivePeerDependencies:
- bufferutil
- supports-color
- utf-8-validate
dev: false
/wrap-ansi@6.2.0:
resolution: {integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==}
engines: {node: '>=8'}
@@ -28512,6 +28641,19 @@ packages:
utf-8-validate:
optional: true
/ws@8.18.0:
resolution: {integrity: sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==}
engines: {node: '>=10.0.0'}
peerDependencies:
bufferutil: ^4.0.1
utf-8-validate: '>=5.0.2'
peerDependenciesMeta:
bufferutil:
optional: true
utf-8-validate:
optional: true
dev: false
/xdg-app-paths@8.3.0:
resolution: {integrity: sha512-mgxlWVZw0TNWHoGmXq+NC3uhCIc55dDpAlDkMQUaIAcQzysb0kxctwv//fvuW61/nAAeUBJMQ8mnZjMmuYwOcQ==}
engines: {node: '>= 4.0'}
@@ -28541,7 +28683,6 @@ packages:
/xxhash-wasm@1.0.2:
resolution: {integrity: sha512-ibF0Or+FivM9lNrg+HGJfVX8WJqgo+kCLDc4vx6xMeTce7Aj+DLttKbxxRR/gNLSAelRc1omAPlJ77N/Jem07A==}
dev: true
/y18n@4.0.3:
resolution: {integrity: sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==}
@@ -28656,7 +28797,6 @@ packages:
cookie: 0.5.0
mustache: 4.2.0
stacktracey: 2.1.8
dev: true
/yt-dlp-wrap@2.3.12:
resolution: {integrity: sha512-P8fJ+6M1YjukyJENCTviNLiZ8mokxprR54ho3DsSKPWDcac489OjRiStGEARJr6un6ETS6goTn4CWl/b/rM3aA==}
+2 -1
View File
@@ -37,7 +37,8 @@
"stripe": "^12.14.0",
"typeorm": "^0.3.20",
"yt-dlp-wrap": "^2.3.12",
"zod": "3.23.8"
"zod": "3.23.8",
"wrangler": "3.70.0"
},
"devDependencies": {
"@opentelemetry/api": "^1.8.0",
@@ -0,0 +1,36 @@
import { logger, task } from "@trigger.dev/sdk/v3";
import { exec } from "node:child_process";
export const wranglerTask = task({
id: "wrangler-task",
run: async () => {
// Try and resolve wranger from the node_modules/.bin directory
const wranglerPath = await import.meta.resolve?.("wrangler", import.meta.url);
if (!wranglerPath) {
throw new Error("Wrangler not found in node_modules directory");
}
logger.log(`Running wrangler from ${wranglerPath}`, {
meta: import.meta,
});
// remove the file:// prefix
const wranglerPathWithoutFilePrefix = wranglerPath.replace("file://", "");
const version = await new Promise<string>((resolve, reject) => {
exec(`node ${wranglerPathWithoutFilePrefix} --version`, (error, stdout, stderr) => {
if (error) {
reject(error);
return;
}
resolve(stdout.trim());
});
});
return {
version,
};
},
});
@@ -1,30 +0,0 @@
import { logger, task } from "@trigger.dev/sdk/v3";
import { exec } from "node:child_process";
import { join } from "node:path";
const wranglerPath = join(__dirname, "node_modules", ".bin", "wrangler");
export const wranglerTask = task({
id: "wrangler-task",
run: async () => {
logger.log(`Running wrangler from ${wranglerPath}`, {
processEnv: process.env,
cwd: process.cwd(),
});
const version = await new Promise<string>((resolve, reject) => {
exec(`${wranglerPath} --version`, (error, stdout, stderr) => {
if (error) {
reject(error);
return;
}
resolve(stdout.trim());
});
});
return {
version,
};
},
});
+3 -2
View File
@@ -1,16 +1,17 @@
import { OpenAIInstrumentation } from "@traceloop/instrumentation-openai";
import { defineConfig } from "@trigger.dev/sdk/v3";
import { emitDecoratorMetadata } from "@trigger.dev/sdk/v3/extensions";
import { OpenAIInstrumentation } from "@traceloop/instrumentation-openai";
export default defineConfig({
project: "yubjwjsfkxnylobaqvqz",
machine: "small-2x",
instrumentations: [new OpenAIInstrumentation()],
additionalFiles: ["wrangler/wrangler.toml"],
retries: {
enabledInDev: true,
default: {
maxAttempts: 4,
minTimeoutInMs: 1000,
minTimeoutInMs: 10000,
maxTimeoutInMs: 10000,
factor: 2,
randomize: true,
+3 -2
View File
@@ -7,7 +7,7 @@
"strict": true,
"outDir": "dist",
"skipLibCheck": true,
"customConditions": ["triggerdotdev-source"],
"customConditions": ["@triggerdotdev/source"],
"jsx": "preserve",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
@@ -20,6 +20,7 @@
"./src/**/*.ts",
"trigger.config.ts",
"src/trigger/email.tsx",
"src/trigger/openai.mts"
"src/trigger/openai.mts",
"src/trigger/wrangler.mts"
]
}