run402 1.69.6 → 1.69.7
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/lib/blob.mjs +85 -47
- package/lib/deploy-v2.mjs +159 -62
- package/lib/functions.mjs +42 -6
- package/package.json +1 -1
- package/sdk/dist/namespaces/blobs.d.ts +3 -2
- package/sdk/dist/namespaces/blobs.d.ts.map +1 -1
- package/sdk/dist/namespaces/blobs.js +38 -7
- package/sdk/dist/namespaces/blobs.js.map +1 -1
- package/sdk/dist/namespaces/blobs.types.d.ts +5 -6
- package/sdk/dist/namespaces/blobs.types.d.ts.map +1 -1
- package/sdk/dist/namespaces/deploy.d.ts.map +1 -1
- package/sdk/dist/namespaces/deploy.js +13 -1
- package/sdk/dist/namespaces/deploy.js.map +1 -1
- package/sdk/dist/namespaces/functions.d.ts.map +1 -1
- package/sdk/dist/namespaces/functions.js +92 -1
- package/sdk/dist/namespaces/functions.js.map +1 -1
- package/sdk/dist/node/files.d.ts +11 -5
- package/sdk/dist/node/files.d.ts.map +1 -1
- package/sdk/dist/node/files.js +31 -7
- package/sdk/dist/node/files.js.map +1 -1
package/sdk/dist/node/files.js
CHANGED
|
@@ -10,6 +10,20 @@ import { readdir, lstat } from "node:fs/promises";
|
|
|
10
10
|
import { join, relative, sep } from "node:path";
|
|
11
11
|
import { LocalError } from "../errors.js";
|
|
12
12
|
const DEFAULT_IGNORE = new Set([".git", "node_modules", ".DS_Store"]);
|
|
13
|
+
const DEFAULT_SENSITIVE_IGNORE_NAMES = new Set([
|
|
14
|
+
".env",
|
|
15
|
+
".envrc",
|
|
16
|
+
".npmrc",
|
|
17
|
+
".pnpmrc",
|
|
18
|
+
".yarnrc",
|
|
19
|
+
".netrc",
|
|
20
|
+
".pypirc",
|
|
21
|
+
"id_dsa",
|
|
22
|
+
"id_ecdsa",
|
|
23
|
+
"id_ed25519",
|
|
24
|
+
"id_rsa",
|
|
25
|
+
]);
|
|
26
|
+
const DEFAULT_SENSITIVE_IGNORE_SUFFIXES = [".key", ".pem", ".p12", ".pfx"];
|
|
13
27
|
const CONTEXT = "collecting files for deploy";
|
|
14
28
|
/**
|
|
15
29
|
* Walk a directory and return a `FileSet` whose values are `FsFileSource`
|
|
@@ -17,10 +31,12 @@ const CONTEXT = "collecting files for deploy";
|
|
|
17
31
|
* content-type; the deploy normalizer hashes and uploads each file from
|
|
18
32
|
* disk on demand.
|
|
19
33
|
*
|
|
20
|
-
* Skips `.git`, `node_modules`, `.DS_Store
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
34
|
+
* Skips `.git`, `node_modules`, `.DS_Store`, common secret-bearing filenames
|
|
35
|
+
* like `.env`, `.npmrc`, and private-key material (plus any names in
|
|
36
|
+
* `opts.ignore`) at every depth. Pass `{ includeSensitive: true }` to opt in
|
|
37
|
+
* to collecting those sensitive filenames deliberately. Rejects symlinks.
|
|
38
|
+
* Throws `LocalError` if the directory does not exist, is not a directory, or
|
|
39
|
+
* contains no deployable files after the ignore list is applied.
|
|
24
40
|
*
|
|
25
41
|
* @example
|
|
26
42
|
* import { run402 } from "@run402/sdk/node";
|
|
@@ -50,13 +66,13 @@ export async function fileSetFromDir(root, opts = {}) {
|
|
|
50
66
|
throw new LocalError(`path ${root} is not a directory`, CONTEXT);
|
|
51
67
|
}
|
|
52
68
|
const out = {};
|
|
53
|
-
await walkInto(root, root, ignore, out);
|
|
69
|
+
await walkInto(root, root, ignore, opts.includeSensitive === true, out);
|
|
54
70
|
if (Object.keys(out).length === 0) {
|
|
55
71
|
throw new LocalError(`directory ${root} contains no deployable files`, CONTEXT);
|
|
56
72
|
}
|
|
57
73
|
return out;
|
|
58
74
|
}
|
|
59
|
-
async function walkInto(root, current, ignore, out) {
|
|
75
|
+
async function walkInto(root, current, ignore, includeSensitive, out) {
|
|
60
76
|
let entries;
|
|
61
77
|
try {
|
|
62
78
|
entries = await readdir(current, { withFileTypes: true });
|
|
@@ -67,12 +83,14 @@ async function walkInto(root, current, ignore, out) {
|
|
|
67
83
|
for (const entry of entries) {
|
|
68
84
|
if (ignore.has(entry.name))
|
|
69
85
|
continue;
|
|
86
|
+
if (!includeSensitive && isSensitiveIgnoredName(entry.name))
|
|
87
|
+
continue;
|
|
70
88
|
const fullPath = join(current, entry.name);
|
|
71
89
|
if (entry.isSymbolicLink()) {
|
|
72
90
|
throw new LocalError(`symlink found at ${fullPath} (following symlinks is not supported)`, CONTEXT);
|
|
73
91
|
}
|
|
74
92
|
if (entry.isDirectory()) {
|
|
75
|
-
await walkInto(root, fullPath, ignore, out);
|
|
93
|
+
await walkInto(root, fullPath, ignore, includeSensitive, out);
|
|
76
94
|
continue;
|
|
77
95
|
}
|
|
78
96
|
if (entry.isFile()) {
|
|
@@ -81,6 +99,12 @@ async function walkInto(root, current, ignore, out) {
|
|
|
81
99
|
}
|
|
82
100
|
}
|
|
83
101
|
}
|
|
102
|
+
function isSensitiveIgnoredName(name) {
|
|
103
|
+
const lower = name.toLowerCase();
|
|
104
|
+
return (lower.startsWith(".env.") ||
|
|
105
|
+
DEFAULT_SENSITIVE_IGNORE_NAMES.has(lower) ||
|
|
106
|
+
DEFAULT_SENSITIVE_IGNORE_SUFFIXES.some((suffix) => lower.endsWith(suffix)));
|
|
107
|
+
}
|
|
84
108
|
/** Normalize a relative path to POSIX forward slashes. Exposed for tests. */
|
|
85
109
|
export function normalizeRelPath(rel) {
|
|
86
110
|
return sep === "/" ? rel : rel.split(sep).join("/");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/node/files.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,MAAM,cAAc,GAAG,I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