@trigger.dev/build 0.0.0-prerelease-20250204161430 → 0.0.0-prerelease-20250211141853
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/extensions/audioWaveform.js +1 -1
- package/dist/commonjs/extensions/audioWaveform.js.map +1 -1
- package/dist/commonjs/extensions/python.d.ts +33 -0
- package/dist/commonjs/extensions/python.js +126 -0
- package/dist/commonjs/extensions/python.js.map +1 -0
- package/dist/commonjs/version.js +1 -1
- package/dist/esm/extensions/audioWaveform.js +1 -1
- package/dist/esm/extensions/audioWaveform.js.map +1 -1
- package/dist/esm/extensions/python.d.ts +33 -0
- package/dist/esm/extensions/python.js +116 -0
- package/dist/esm/extensions/python.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/package.json +19 -2
|
@@ -4,7 +4,7 @@ exports.audioWaveform = audioWaveform;
|
|
|
4
4
|
const AUDIOWAVEFORM_VERSION = "1.10.1";
|
|
5
5
|
const AUDIOWAVEFORM_CHECKSUM = "sha256:00b41ea4d6e7a5b4affcfe4ac99951ec89da81a8cba40af19e9b98c3a8f9b4b8";
|
|
6
6
|
function audioWaveform(options = {}) {
|
|
7
|
-
return new AudioWaveformExtension();
|
|
7
|
+
return new AudioWaveformExtension(options);
|
|
8
8
|
}
|
|
9
9
|
class AudioWaveformExtension {
|
|
10
10
|
options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audioWaveform.js","sourceRoot":"","sources":["../../../src/extensions/audioWaveform.ts"],"names":[],"mappings":";;AAYA,sCAEC;AAND,MAAM,qBAAqB,GAAG,QAAQ,CAAC;AACvC,MAAM,sBAAsB,GAC1B,yEAAyE,CAAC;AAE5E,SAAgB,aAAa,CAAC,UAAgC,EAAE;IAC9D,OAAO,IAAI,sBAAsB,
|
|
1
|
+
{"version":3,"file":"audioWaveform.js","sourceRoot":"","sources":["../../../src/extensions/audioWaveform.ts"],"names":[],"mappings":";;AAYA,sCA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"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BuildExtension } from "@trigger.dev/core/v3/build";
|
|
2
|
+
import { Options as XOptions, Result } from "tinyexec";
|
|
3
|
+
export type PythonOptions = {
|
|
4
|
+
requirements?: string[];
|
|
5
|
+
requirementsFile?: string;
|
|
6
|
+
/**
|
|
7
|
+
* [Dev-only] The path to the python binary.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* This option is typically used during local development or in specific testing environments
|
|
11
|
+
* where a particular Python installation needs to be targeted. It should point to the full path of the python executable.
|
|
12
|
+
*
|
|
13
|
+
* Example: `/usr/bin/python3` or `C:\\Python39\\python.exe`
|
|
14
|
+
*/
|
|
15
|
+
pythonBinaryPath?: string;
|
|
16
|
+
/**
|
|
17
|
+
* An array of glob patterns that specify which Python scripts are allowed to be executed.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* These scripts will be copied to the container during the build process.
|
|
21
|
+
*/
|
|
22
|
+
scripts?: string[];
|
|
23
|
+
};
|
|
24
|
+
export declare function pythonExtension(options?: PythonOptions): BuildExtension;
|
|
25
|
+
export declare const run: (scriptArgs?: string[], options?: Partial<XOptions>) => Promise<Result>;
|
|
26
|
+
export declare const runScript: (scriptPath: string, scriptArgs?: string[], options?: Partial<XOptions>) => Promise<Result>;
|
|
27
|
+
export declare const runInline: (scriptContent: string, options?: Partial<XOptions>) => Promise<import("tinyexec").Output>;
|
|
28
|
+
declare const _default: {
|
|
29
|
+
run: (scriptArgs?: string[], options?: Partial<XOptions>) => Promise<Result>;
|
|
30
|
+
runScript: (scriptPath: string, scriptArgs?: string[], options?: Partial<XOptions>) => Promise<Result>;
|
|
31
|
+
runInline: (scriptContent: string, options?: Partial<XOptions>) => Promise<import("tinyexec").Output>;
|
|
32
|
+
};
|
|
33
|
+
export default _default;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.runInline = exports.runScript = exports.run = void 0;
|
|
7
|
+
exports.pythonExtension = pythonExtension;
|
|
8
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
10
|
+
const additionalFiles_js_1 = require("./core/additionalFiles.js");
|
|
11
|
+
const v3_1 = require("@trigger.dev/sdk/v3");
|
|
12
|
+
const tinyexec_1 = require("tinyexec");
|
|
13
|
+
const splitAndCleanComments = (str) => str
|
|
14
|
+
.split("\n")
|
|
15
|
+
.map((line) => line.trim())
|
|
16
|
+
.filter((line) => line && !line.startsWith("#"));
|
|
17
|
+
function pythonExtension(options = {}) {
|
|
18
|
+
return new PythonExtension(options);
|
|
19
|
+
}
|
|
20
|
+
class PythonExtension {
|
|
21
|
+
options;
|
|
22
|
+
name = "PythonExtension";
|
|
23
|
+
constructor(options = {}) {
|
|
24
|
+
this.options = options;
|
|
25
|
+
(0, node_assert_1.default)(!(this.options.requirements && this.options.requirementsFile), "Cannot specify both requirements and requirementsFile");
|
|
26
|
+
if (this.options.requirementsFile) {
|
|
27
|
+
(0, node_assert_1.default)(node_fs_1.default.existsSync(this.options.requirementsFile), `Requirements file not found: ${this.options.requirementsFile}`);
|
|
28
|
+
this.options.requirements = splitAndCleanComments(node_fs_1.default.readFileSync(this.options.requirementsFile, "utf-8"));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async onBuildComplete(context, manifest) {
|
|
32
|
+
await (0, additionalFiles_js_1.additionalFiles)({
|
|
33
|
+
files: this.options.scripts ?? [],
|
|
34
|
+
}).onBuildComplete(context, manifest);
|
|
35
|
+
if (context.target === "dev") {
|
|
36
|
+
if (this.options.pythonBinaryPath) {
|
|
37
|
+
process.env.PYTHON_BIN_PATH = this.options.pythonBinaryPath;
|
|
38
|
+
}
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
context.logger.debug(`Adding ${this.name} to the build`);
|
|
42
|
+
context.addLayer({
|
|
43
|
+
id: "python-installation",
|
|
44
|
+
image: {
|
|
45
|
+
instructions: splitAndCleanComments(`
|
|
46
|
+
# Install Python
|
|
47
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
48
|
+
python3 python3-pip python3-venv && \
|
|
49
|
+
apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
50
|
+
|
|
51
|
+
# Set up Python environment
|
|
52
|
+
RUN python3 -m venv /opt/venv
|
|
53
|
+
ENV PATH="/opt/venv/bin:$PATH"
|
|
54
|
+
`),
|
|
55
|
+
},
|
|
56
|
+
deploy: {
|
|
57
|
+
env: {
|
|
58
|
+
PYTHON_BIN_PATH: `/opt/venv/bin/python`,
|
|
59
|
+
},
|
|
60
|
+
override: true,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
context.addLayer({
|
|
64
|
+
id: "python-dependencies",
|
|
65
|
+
build: {
|
|
66
|
+
env: {
|
|
67
|
+
REQUIREMENTS_CONTENT: this.options.requirements?.join("\n") || "",
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
image: {
|
|
71
|
+
instructions: splitAndCleanComments(`
|
|
72
|
+
ARG REQUIREMENTS_CONTENT
|
|
73
|
+
RUN echo "$REQUIREMENTS_CONTENT" > requirements.txt
|
|
74
|
+
|
|
75
|
+
# Install dependencies
|
|
76
|
+
RUN pip install --no-cache-dir -r requirements.txt
|
|
77
|
+
`),
|
|
78
|
+
},
|
|
79
|
+
deploy: {
|
|
80
|
+
override: true,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const run = async (scriptArgs = [], options = {}) => {
|
|
86
|
+
const pythonBin = process.env.PYTHON_BIN_PATH || "python";
|
|
87
|
+
const result = await (0, tinyexec_1.x)(pythonBin, scriptArgs, {
|
|
88
|
+
...options,
|
|
89
|
+
throwOnError: false, // Ensure errors are handled manually
|
|
90
|
+
});
|
|
91
|
+
try {
|
|
92
|
+
(0, node_assert_1.default)(result.exitCode === 0, `Python command exited with non-zero code ${result.exitCode}\nStdout: ${result.stdout}\nStderr: ${result.stderr}`);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
v3_1.logger.error("Python command execution failed", {
|
|
96
|
+
error: error instanceof Error ? error.message : error,
|
|
97
|
+
command: `${pythonBin} ${scriptArgs.join(" ")}`,
|
|
98
|
+
stdout: result.stdout,
|
|
99
|
+
stderr: result.stderr,
|
|
100
|
+
exitCode: result.exitCode,
|
|
101
|
+
});
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
return result;
|
|
105
|
+
};
|
|
106
|
+
exports.run = run;
|
|
107
|
+
const runScript = (scriptPath, scriptArgs = [], options = {}) => {
|
|
108
|
+
(0, node_assert_1.default)(scriptPath, "Script path is required");
|
|
109
|
+
(0, node_assert_1.default)(node_fs_1.default.existsSync(scriptPath), `Script does not exist: ${scriptPath}`);
|
|
110
|
+
return (0, exports.run)([scriptPath, ...scriptArgs], options);
|
|
111
|
+
};
|
|
112
|
+
exports.runScript = runScript;
|
|
113
|
+
const runInline = async (scriptContent, options = {}) => {
|
|
114
|
+
(0, node_assert_1.default)(scriptContent, "Script content is required");
|
|
115
|
+
const tmpFile = `/tmp/script_${Date.now()}.py`;
|
|
116
|
+
await node_fs_1.default.promises.writeFile(tmpFile, scriptContent, { mode: 0o600 });
|
|
117
|
+
try {
|
|
118
|
+
return await (0, exports.runScript)(tmpFile, [], options);
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
await node_fs_1.default.promises.unlink(tmpFile);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
exports.runInline = runInline;
|
|
125
|
+
exports.default = { run: exports.run, runScript: exports.runScript, runInline: exports.runInline };
|
|
126
|
+
//# sourceMappingURL=python.js.map
|
|
@@ -0,0 +1 @@
|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E,aAAqB,EAAE,UAA6B,EAAE,EAAE,EAAE;IACxF,IAAA,qBAAM,EAAC,aAAa,EAAE,4BAA4B,CAAC,CAAC;IAEpD,MAAM,OAAO,GAAG,eAAe,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC;IAC/C,MAAM,iBAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAErE,IAAI,CAAC;QACH,OAAO,MAAM,IAAA,iBAAS,EAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;YAAS,CAAC;QACT,MAAM,iBAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;AACH,CAAC,CAAC;AAXW,QAAA,SAAS,aAWpB;AAEF,kBAAe,EAAE,GAAG,EAAH,WAAG,EAAE,SAAS,EAAT,iBAAS,EAAE,SAAS,EAAT,iBAAS,EAAE,CAAC"}
|
package/dist/commonjs/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const AUDIOWAVEFORM_VERSION = "1.10.1";
|
|
2
2
|
const AUDIOWAVEFORM_CHECKSUM = "sha256:00b41ea4d6e7a5b4affcfe4ac99951ec89da81a8cba40af19e9b98c3a8f9b4b8";
|
|
3
3
|
export function audioWaveform(options = {}) {
|
|
4
|
-
return new AudioWaveformExtension();
|
|
4
|
+
return new AudioWaveformExtension(options);
|
|
5
5
|
}
|
|
6
6
|
class AudioWaveformExtension {
|
|
7
7
|
options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audioWaveform.js","sourceRoot":"","sources":["../../../src/extensions/audioWaveform.ts"],"names":[],"mappings":"AAQA,MAAM,qBAAqB,GAAG,QAAQ,CAAC;AACvC,MAAM,sBAAsB,GAC1B,yEAAyE,CAAC;AAE5E,MAAM,UAAU,aAAa,CAAC,UAAgC,EAAE;IAC9D,OAAO,IAA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YACnB,KAAK,EAAE;gBACL,IAAI,EAAE,CAAC,KAAK,CAAC;gBACb,YAAY;aACb;SACF,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BuildExtension } from "@trigger.dev/core/v3/build";
|
|
2
|
+
import { Options as XOptions, Result } from "tinyexec";
|
|
3
|
+
export type PythonOptions = {
|
|
4
|
+
requirements?: string[];
|
|
5
|
+
requirementsFile?: string;
|
|
6
|
+
/**
|
|
7
|
+
* [Dev-only] The path to the python binary.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* This option is typically used during local development or in specific testing environments
|
|
11
|
+
* where a particular Python installation needs to be targeted. It should point to the full path of the python executable.
|
|
12
|
+
*
|
|
13
|
+
* Example: `/usr/bin/python3` or `C:\\Python39\\python.exe`
|
|
14
|
+
*/
|
|
15
|
+
pythonBinaryPath?: string;
|
|
16
|
+
/**
|
|
17
|
+
* An array of glob patterns that specify which Python scripts are allowed to be executed.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* These scripts will be copied to the container during the build process.
|
|
21
|
+
*/
|
|
22
|
+
scripts?: string[];
|
|
23
|
+
};
|
|
24
|
+
export declare function pythonExtension(options?: PythonOptions): BuildExtension;
|
|
25
|
+
export declare const run: (scriptArgs?: string[], options?: Partial<XOptions>) => Promise<Result>;
|
|
26
|
+
export declare const runScript: (scriptPath: string, scriptArgs?: string[], options?: Partial<XOptions>) => Promise<Result>;
|
|
27
|
+
export declare const runInline: (scriptContent: string, options?: Partial<XOptions>) => Promise<import("tinyexec").Output>;
|
|
28
|
+
declare const _default: {
|
|
29
|
+
run: (scriptArgs?: string[], options?: Partial<XOptions>) => Promise<Result>;
|
|
30
|
+
runScript: (scriptPath: string, scriptArgs?: string[], options?: Partial<XOptions>) => Promise<Result>;
|
|
31
|
+
runInline: (scriptContent: string, options?: Partial<XOptions>) => Promise<import("tinyexec").Output>;
|
|
32
|
+
};
|
|
33
|
+
export default _default;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import assert from "node:assert";
|
|
3
|
+
import { additionalFiles } from "./core/additionalFiles.js";
|
|
4
|
+
import { logger } from "@trigger.dev/sdk/v3";
|
|
5
|
+
import { x } from "tinyexec";
|
|
6
|
+
const splitAndCleanComments = (str) => str
|
|
7
|
+
.split("\n")
|
|
8
|
+
.map((line) => line.trim())
|
|
9
|
+
.filter((line) => line && !line.startsWith("#"));
|
|
10
|
+
export function pythonExtension(options = {}) {
|
|
11
|
+
return new PythonExtension(options);
|
|
12
|
+
}
|
|
13
|
+
class PythonExtension {
|
|
14
|
+
options;
|
|
15
|
+
name = "PythonExtension";
|
|
16
|
+
constructor(options = {}) {
|
|
17
|
+
this.options = options;
|
|
18
|
+
assert(!(this.options.requirements && this.options.requirementsFile), "Cannot specify both requirements and requirementsFile");
|
|
19
|
+
if (this.options.requirementsFile) {
|
|
20
|
+
assert(fs.existsSync(this.options.requirementsFile), `Requirements file not found: ${this.options.requirementsFile}`);
|
|
21
|
+
this.options.requirements = splitAndCleanComments(fs.readFileSync(this.options.requirementsFile, "utf-8"));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async onBuildComplete(context, manifest) {
|
|
25
|
+
await additionalFiles({
|
|
26
|
+
files: this.options.scripts ?? [],
|
|
27
|
+
}).onBuildComplete(context, manifest);
|
|
28
|
+
if (context.target === "dev") {
|
|
29
|
+
if (this.options.pythonBinaryPath) {
|
|
30
|
+
process.env.PYTHON_BIN_PATH = this.options.pythonBinaryPath;
|
|
31
|
+
}
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
context.logger.debug(`Adding ${this.name} to the build`);
|
|
35
|
+
context.addLayer({
|
|
36
|
+
id: "python-installation",
|
|
37
|
+
image: {
|
|
38
|
+
instructions: splitAndCleanComments(`
|
|
39
|
+
# Install Python
|
|
40
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
41
|
+
python3 python3-pip python3-venv && \
|
|
42
|
+
apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
43
|
+
|
|
44
|
+
# Set up Python environment
|
|
45
|
+
RUN python3 -m venv /opt/venv
|
|
46
|
+
ENV PATH="/opt/venv/bin:$PATH"
|
|
47
|
+
`),
|
|
48
|
+
},
|
|
49
|
+
deploy: {
|
|
50
|
+
env: {
|
|
51
|
+
PYTHON_BIN_PATH: `/opt/venv/bin/python`,
|
|
52
|
+
},
|
|
53
|
+
override: true,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
context.addLayer({
|
|
57
|
+
id: "python-dependencies",
|
|
58
|
+
build: {
|
|
59
|
+
env: {
|
|
60
|
+
REQUIREMENTS_CONTENT: this.options.requirements?.join("\n") || "",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
image: {
|
|
64
|
+
instructions: splitAndCleanComments(`
|
|
65
|
+
ARG REQUIREMENTS_CONTENT
|
|
66
|
+
RUN echo "$REQUIREMENTS_CONTENT" > requirements.txt
|
|
67
|
+
|
|
68
|
+
# Install dependencies
|
|
69
|
+
RUN pip install --no-cache-dir -r requirements.txt
|
|
70
|
+
`),
|
|
71
|
+
},
|
|
72
|
+
deploy: {
|
|
73
|
+
override: true,
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export const run = async (scriptArgs = [], options = {}) => {
|
|
79
|
+
const pythonBin = process.env.PYTHON_BIN_PATH || "python";
|
|
80
|
+
const result = await x(pythonBin, scriptArgs, {
|
|
81
|
+
...options,
|
|
82
|
+
throwOnError: false, // Ensure errors are handled manually
|
|
83
|
+
});
|
|
84
|
+
try {
|
|
85
|
+
assert(result.exitCode === 0, `Python command exited with non-zero code ${result.exitCode}\nStdout: ${result.stdout}\nStderr: ${result.stderr}`);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
logger.error("Python command execution failed", {
|
|
89
|
+
error: error instanceof Error ? error.message : error,
|
|
90
|
+
command: `${pythonBin} ${scriptArgs.join(" ")}`,
|
|
91
|
+
stdout: result.stdout,
|
|
92
|
+
stderr: result.stderr,
|
|
93
|
+
exitCode: result.exitCode,
|
|
94
|
+
});
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
};
|
|
99
|
+
export const runScript = (scriptPath, scriptArgs = [], options = {}) => {
|
|
100
|
+
assert(scriptPath, "Script path is required");
|
|
101
|
+
assert(fs.existsSync(scriptPath), `Script does not exist: ${scriptPath}`);
|
|
102
|
+
return run([scriptPath, ...scriptArgs], options);
|
|
103
|
+
};
|
|
104
|
+
export const runInline = async (scriptContent, options = {}) => {
|
|
105
|
+
assert(scriptContent, "Script content is required");
|
|
106
|
+
const tmpFile = `/tmp/script_${Date.now()}.py`;
|
|
107
|
+
await fs.promises.writeFile(tmpFile, scriptContent, { mode: 0o600 });
|
|
108
|
+
try {
|
|
109
|
+
return await runScript(tmpFile, [], options);
|
|
110
|
+
}
|
|
111
|
+
finally {
|
|
112
|
+
await fs.promises.unlink(tmpFile);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
export default { run, runScript, runInline };
|
|
116
|
+
//# sourceMappingURL=python.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python.js","sourceRoot":"","sources":["../../../src/extensions/python.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAG5D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,CAAC,EAA+B,MAAM,UAAU,CAAC;AAwB1D,MAAM,qBAAqB,GAAG,CAAC,GAAW,EAAE,EAAE,CAC5C,GAAG;KACA,KAAK,CAAC,IAAI,CAAC;KACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,C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AS,CAAC;QACT,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = "
|
|
1
|
+
export const VERSION = "3.3.13";
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trigger.dev/build",
|
|
3
|
-
"version": "0.0.0-prerelease-
|
|
3
|
+
"version": "0.0.0-prerelease-20250211141853",
|
|
4
4
|
"description": "trigger.dev build extensions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"./extensions/prisma": "./src/extensions/prisma.ts",
|
|
29
29
|
"./extensions/audioWaveform": "./src/extensions/audioWaveform.ts",
|
|
30
30
|
"./extensions/typescript": "./src/extensions/typescript.ts",
|
|
31
|
+
"./extensions/python": "./src/extensions/python.ts",
|
|
31
32
|
"./extensions/puppeteer": "./src/extensions/puppeteer.ts"
|
|
32
33
|
},
|
|
33
34
|
"sourceDialects": [
|
|
@@ -51,14 +52,19 @@
|
|
|
51
52
|
"extensions/typescript": [
|
|
52
53
|
"dist/commonjs/extensions/typescript.d.ts"
|
|
53
54
|
],
|
|
55
|
+
"extensions/python": [
|
|
56
|
+
"dist/commonjs/extensions/python.d.ts"
|
|
57
|
+
],
|
|
54
58
|
"extensions/puppeteer": [
|
|
55
59
|
"dist/commonjs/extensions/puppeteer.d.ts"
|
|
56
60
|
]
|
|
57
61
|
}
|
|
58
62
|
},
|
|
59
63
|
"dependencies": {
|
|
60
|
-
"@trigger.dev/core": "0.0.0-prerelease-
|
|
64
|
+
"@trigger.dev/core": "0.0.0-prerelease-20250211141853",
|
|
65
|
+
"@trigger.dev/sdk": "0.0.0-prerelease-20250211141853",
|
|
61
66
|
"pkg-types": "^1.1.3",
|
|
67
|
+
"tinyexec": "^0.3.2",
|
|
62
68
|
"tinyglobby": "^0.2.2",
|
|
63
69
|
"tsconfck": "3.1.3"
|
|
64
70
|
},
|
|
@@ -142,6 +148,17 @@
|
|
|
142
148
|
"default": "./dist/commonjs/extensions/typescript.js"
|
|
143
149
|
}
|
|
144
150
|
},
|
|
151
|
+
"./extensions/python": {
|
|
152
|
+
"import": {
|
|
153
|
+
"@triggerdotdev/source": "./src/extensions/python.ts",
|
|
154
|
+
"types": "./dist/esm/extensions/python.d.ts",
|
|
155
|
+
"default": "./dist/esm/extensions/python.js"
|
|
156
|
+
},
|
|
157
|
+
"require": {
|
|
158
|
+
"types": "./dist/commonjs/extensions/python.d.ts",
|
|
159
|
+
"default": "./dist/commonjs/extensions/python.js"
|
|
160
|
+
}
|
|
161
|
+
},
|
|
145
162
|
"./extensions/puppeteer": {
|
|
146
163
|
"import": {
|
|
147
164
|
"@triggerdotdev/source": "./src/extensions/puppeteer.ts",
|