@trigger.dev/build
Advanced tools
Comparing version
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.additionalFiles = additionalFiles; | ||
const node_path_1 = require("node:path"); | ||
const tinyglobby_1 = require("tinyglobby"); | ||
const promises_1 = require("node:fs/promises"); | ||
const additionalFiles_js_1 = require("../../internal/additionalFiles.js"); | ||
function additionalFiles(options) { | ||
@@ -11,55 +9,6 @@ return { | ||
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); | ||
await (0, additionalFiles_js_1.addAdditionalFilesToBuild)("additionalFiles", options, context, manifest); | ||
}, | ||
}; | ||
} | ||
async function findStaticAssetFiles(matchers, destinationPath, options) { | ||
const result = []; | ||
for (const matcher of matchers) { | ||
const assets = await findStaticAssetsForMatcher(matcher, destinationPath, options); | ||
result.push({ matcher, assets }); | ||
} | ||
return result; | ||
} | ||
async function findStaticAssetsForMatcher(matcher, destinationPath, options) { | ||
const result = []; | ||
const files = await (0, tinyglobby_1.glob)({ | ||
patterns: [matcher], | ||
cwd: options?.cwd, | ||
ignore: options?.ignore ?? [], | ||
onlyFiles: true, | ||
absolute: true, | ||
}); | ||
let matches = 0; | ||
for (const file of files) { | ||
matches++; | ||
const pathInsideDestinationDir = (0, node_path_1.relative)(options?.cwd ?? process.cwd(), file) | ||
.split(node_path_1.posix.sep) | ||
.filter((p) => p !== "..") | ||
.join(node_path_1.posix.sep); | ||
const relativeDestinationPath = (0, node_path_1.join)(destinationPath, pathInsideDestinationDir); | ||
result.push({ | ||
source: file, | ||
destination: relativeDestinationPath, | ||
}); | ||
} | ||
return result; | ||
} | ||
async function copyStaticAssets(staticAssetFiles) { | ||
for (const { assets } of staticAssetFiles) { | ||
for (const { source, destination } of assets) { | ||
await (0, promises_1.mkdir)((0, node_path_1.dirname)(destination), { recursive: true }); | ||
await (0, promises_1.copyFile)(source, destination); | ||
} | ||
} | ||
} | ||
//# sourceMappingURL=additionalFiles.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.VERSION = void 0; | ||
exports.VERSION = "3.3.13"; | ||
exports.VERSION = "0.0.0-prerelease-20250226191317"; | ||
//# sourceMappingURL=version.js.map |
@@ -1,4 +0,2 @@ | ||
import { relative, join, posix, dirname } from "node:path"; | ||
import { glob } from "tinyglobby"; | ||
import { copyFile, mkdir } from "node:fs/promises"; | ||
import { addAdditionalFilesToBuild } from "../../internal/additionalFiles.js"; | ||
export function additionalFiles(options) { | ||
@@ -8,55 +6,6 @@ return { | ||
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); | ||
await addAdditionalFilesToBuild("additionalFiles", options, context, manifest); | ||
}, | ||
}; | ||
} | ||
async function findStaticAssetFiles(matchers, destinationPath, options) { | ||
const result = []; | ||
for (const matcher of matchers) { | ||
const assets = await findStaticAssetsForMatcher(matcher, destinationPath, options); | ||
result.push({ matcher, assets }); | ||
} | ||
return result; | ||
} | ||
async function findStaticAssetsForMatcher(matcher, destinationPath, options) { | ||
const result = []; | ||
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) { | ||
for (const { assets } of staticAssetFiles) { | ||
for (const { source, destination } of assets) { | ||
await mkdir(dirname(destination), { recursive: true }); | ||
await copyFile(source, destination); | ||
} | ||
} | ||
} | ||
//# sourceMappingURL=additionalFiles.js.map |
@@ -1,2 +0,2 @@ | ||
export const VERSION = "3.3.13"; | ||
export const VERSION = "0.0.0-prerelease-20250226191317"; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@trigger.dev/build", | ||
"version": "0.0.0-prerelease-20250213143202", | ||
"version": "0.0.0-prerelease-20250226191317", | ||
"description": "trigger.dev build extensions", | ||
@@ -26,2 +26,3 @@ "license": "MIT", | ||
".": "./src/index.ts", | ||
"./internal": "./src/internal.ts", | ||
"./extensions": "./src/extensions/index.ts", | ||
@@ -40,2 +41,5 @@ "./extensions/core": "./src/extensions/core.ts", | ||
"*": { | ||
"internal": [ | ||
"dist/commonjs/internal.d.ts" | ||
], | ||
"extensions": [ | ||
@@ -62,3 +66,3 @@ "dist/commonjs/extensions/index.d.ts" | ||
"dependencies": { | ||
"@trigger.dev/core": "0.0.0-prerelease-20250213143202", | ||
"@trigger.dev/core": "0.0.0-prerelease-20250226191317", | ||
"pkg-types": "^1.1.3", | ||
@@ -93,2 +97,13 @@ "tinyglobby": "^0.2.2", | ||
}, | ||
"./internal": { | ||
"import": { | ||
"@triggerdotdev/source": "./src/internal.ts", | ||
"types": "./dist/esm/internal.d.ts", | ||
"default": "./dist/esm/internal.js" | ||
}, | ||
"require": { | ||
"types": "./dist/commonjs/internal.d.ts", | ||
"default": "./dist/commonjs/internal.js" | ||
} | ||
}, | ||
"./extensions": { | ||
@@ -95,0 +110,0 @@ "import": { |
@@ -1,3 +0,3 @@ | ||
# Official TypeScript SDK for Trigger.dev | ||
# Official Build Package of Trigger.dev | ||
View the full documentation for the [here](https://trigger.dev/docs) | ||
View the full documentation [here](https://trigger.dev/docs) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
122834
4.03%101
13.48%1733
3.03%+ Added
- Removed