@vercel/container 0.0.4 → 0.1.0
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/index.js +48 -5
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -31,22 +31,47 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
build: () => build,
|
|
34
|
+
diagnostics: () => diagnostics,
|
|
34
35
|
prepareCache: () => prepareCache,
|
|
35
36
|
startDevServer: () => startDevServer,
|
|
36
37
|
version: () => version
|
|
37
38
|
});
|
|
38
39
|
module.exports = __toCommonJS(src_exports);
|
|
40
|
+
var import_build_utils4 = require("@vercel/build-utils");
|
|
41
|
+
|
|
42
|
+
// src/diagnostics.ts
|
|
43
|
+
var import_build_utils = require("@vercel/build-utils");
|
|
44
|
+
async function generateProjectManifest({
|
|
45
|
+
workPath,
|
|
46
|
+
framework,
|
|
47
|
+
serviceType
|
|
48
|
+
}) {
|
|
49
|
+
try {
|
|
50
|
+
const manifest = {
|
|
51
|
+
version: import_build_utils.MANIFEST_VERSION,
|
|
52
|
+
runtime: "container",
|
|
53
|
+
...framework ? { framework } : {},
|
|
54
|
+
...serviceType ? { serviceType } : {},
|
|
55
|
+
dependencies: []
|
|
56
|
+
};
|
|
57
|
+
await (0, import_build_utils.writeProjectManifest)(manifest, workPath, "container");
|
|
58
|
+
} catch {
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
var diagnostics = (0, import_build_utils.createDiagnostics)("container");
|
|
62
|
+
|
|
63
|
+
// src/index.ts
|
|
39
64
|
var import_node_fs6 = require("fs");
|
|
40
65
|
var import_node_path6 = __toESM(require("path"));
|
|
41
66
|
|
|
42
67
|
// src/util.ts
|
|
43
|
-
var
|
|
68
|
+
var import_build_utils2 = require("@vercel/build-utils");
|
|
44
69
|
var import_node_child_process = require("child_process");
|
|
45
70
|
var import_node_crypto = require("crypto");
|
|
46
71
|
var import_node_fs = require("fs");
|
|
47
72
|
var import_node_os = require("os");
|
|
48
73
|
var import_node_path = require("path");
|
|
49
|
-
var DEBUG = Boolean((0,
|
|
74
|
+
var DEBUG = Boolean((0, import_build_utils2.getPlatformEnv)("BUILDER_DEBUG"));
|
|
50
75
|
function write(line) {
|
|
51
76
|
process.stderr.write(`${line}
|
|
52
77
|
`);
|
|
@@ -1453,7 +1478,7 @@ async function startContainer(options, reuseKey) {
|
|
|
1453
1478
|
}
|
|
1454
1479
|
|
|
1455
1480
|
// src/prepare-cache.ts
|
|
1456
|
-
var
|
|
1481
|
+
var import_build_utils3 = require("@vercel/build-utils");
|
|
1457
1482
|
var import_node_fs5 = require("fs");
|
|
1458
1483
|
var import_node_path5 = require("path");
|
|
1459
1484
|
var CACHE_ROOT = "/vercel";
|
|
@@ -1472,7 +1497,7 @@ async function prepareCache(_options) {
|
|
|
1472
1497
|
return {};
|
|
1473
1498
|
}
|
|
1474
1499
|
const start = Date.now();
|
|
1475
|
-
const files = await (0,
|
|
1500
|
+
const files = await (0, import_build_utils3.glob)(`${GRAPH_ROOT_REL}/**`, CACHE_ROOT);
|
|
1476
1501
|
const count = Object.keys(files).length;
|
|
1477
1502
|
info(
|
|
1478
1503
|
`cached container layer store: ${count} files from ${BUILDAH_GRAPH_ROOT} in ${Date.now() - start}ms`
|
|
@@ -1482,6 +1507,13 @@ async function prepareCache(_options) {
|
|
|
1482
1507
|
|
|
1483
1508
|
// src/index.ts
|
|
1484
1509
|
var version = 2;
|
|
1510
|
+
function resolveFunctionSourceFile(options) {
|
|
1511
|
+
const entrypoint = readString(options.entrypoint) ?? "";
|
|
1512
|
+
if (entrypoint === "<detect>") {
|
|
1513
|
+
return findDockerfile(options.workPath) ?? entrypoint;
|
|
1514
|
+
}
|
|
1515
|
+
return entrypoint;
|
|
1516
|
+
}
|
|
1485
1517
|
function normalizeCommand2(command) {
|
|
1486
1518
|
if (typeof command === "string") {
|
|
1487
1519
|
return [command];
|
|
@@ -1726,7 +1758,16 @@ async function build(options) {
|
|
|
1726
1758
|
{ "service.name": options.service?.name },
|
|
1727
1759
|
(span) => resolveImageHandler(options, span)
|
|
1728
1760
|
);
|
|
1761
|
+
const lambdaOptions = await (0, import_build_utils4.getLambdaOptionsFromFunction)({
|
|
1762
|
+
sourceFile: resolveFunctionSourceFile(options),
|
|
1763
|
+
config: options.config
|
|
1764
|
+
});
|
|
1729
1765
|
const command = normalizeCommand2(options.config.command);
|
|
1766
|
+
await generateProjectManifest({
|
|
1767
|
+
workPath: options.workPath,
|
|
1768
|
+
framework: options.config.framework ?? void 0,
|
|
1769
|
+
serviceType: options.service ? (0, import_build_utils4.getReportedServiceType)(options.service) : void 0
|
|
1770
|
+
});
|
|
1730
1771
|
const routes = [
|
|
1731
1772
|
{ handle: "filesystem" },
|
|
1732
1773
|
{ src: "/(.*)", dest: "/index" }
|
|
@@ -1743,7 +1784,8 @@ async function build(options) {
|
|
|
1743
1784
|
handler: image,
|
|
1744
1785
|
runtime: "container",
|
|
1745
1786
|
environment: {},
|
|
1746
|
-
...command ? { command } : {}
|
|
1787
|
+
...command ? { command } : {},
|
|
1788
|
+
...lambdaOptions
|
|
1747
1789
|
}
|
|
1748
1790
|
}
|
|
1749
1791
|
};
|
|
@@ -1751,6 +1793,7 @@ async function build(options) {
|
|
|
1751
1793
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1752
1794
|
0 && (module.exports = {
|
|
1753
1795
|
build,
|
|
1796
|
+
diagnostics,
|
|
1754
1797
|
prepareCache,
|
|
1755
1798
|
startDevServer,
|
|
1756
1799
|
version
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/container",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"homepage": "https://vercel.com/docs",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/node": "20.11.0",
|
|
17
17
|
"vitest": "2.0.3",
|
|
18
|
-
"@vercel/build-utils": "13.
|
|
18
|
+
"@vercel/build-utils": "13.35.0"
|
|
19
19
|
},
|
|
20
20
|
"publishConfig": {
|
|
21
21
|
"access": "public"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "node ../../utils/build-builder.mjs",
|
|
25
25
|
"type-check": "tsc --noEmit",
|
|
26
|
-
"test-unit": "vitest run --config ../../vitest.config.mts test/unit.test.ts",
|
|
27
|
-
"vitest-unit": "glob --absolute 'test
|
|
26
|
+
"test-unit": "vitest run --config ../../vitest.config.mts test/unit.test.ts test/diagnostics.test.ts",
|
|
27
|
+
"vitest-unit": "glob --absolute 'test/*.test.ts'"
|
|
28
28
|
}
|
|
29
29
|
}
|