@isomorph.ai/cli 0.10.4 → 0.10.5
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/src/analyzer.js +5 -5
- package/package.json +3 -3
- package/dist/src/gitignore.js +0 -81
package/dist/src/analyzer.js
CHANGED
|
@@ -3,7 +3,7 @@ import { spawnSync } from "node:child_process";
|
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import { lstat, readFile, readdir, stat } from "node:fs/promises";
|
|
5
5
|
import { basename, dirname, join, relative, sep } from "node:path";
|
|
6
|
-
import
|
|
6
|
+
import ignore from "ignore";
|
|
7
7
|
import { sha256 } from "./digest.js";
|
|
8
8
|
import { isEnvExamplePath, isKitCommittedPath, isSourceIntakeExcludedPath } from "./secret-paths.js";
|
|
9
9
|
const ANALYZER_VERSION = "0.1.0";
|
|
@@ -91,18 +91,18 @@ function extension(path) {
|
|
|
91
91
|
* Nested ignore files are not read. A missing file adds no rules.
|
|
92
92
|
*/
|
|
93
93
|
async function loadGitIgnore(root) {
|
|
94
|
-
|
|
94
|
+
const filter = ignore();
|
|
95
95
|
try {
|
|
96
|
-
|
|
96
|
+
filter.add(await readFile(join(root, ".gitignore"), "utf8"));
|
|
97
97
|
}
|
|
98
98
|
catch { /* no .gitignore: nothing extra is ignored */ }
|
|
99
|
-
return
|
|
99
|
+
return filter;
|
|
100
100
|
}
|
|
101
101
|
function isGitIgnored(filter, root, absolute, isDirectory) {
|
|
102
102
|
const path = relative(root, absolute).split(sep).join("/");
|
|
103
103
|
if (!path)
|
|
104
104
|
return false;
|
|
105
|
-
return filter.ignores(path
|
|
105
|
+
return filter.ignores(isDirectory ? `${path}/` : path);
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* Which directories filled the boundary, for the error a builder reads when
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isomorph.ai/cli",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.5",
|
|
4
4
|
"description": "Isomorph development kit CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
"dist/src/analyzer.js",
|
|
19
19
|
"dist/src/contracts.js",
|
|
20
20
|
"dist/src/digest.js",
|
|
21
|
-
"dist/src/gitignore.js",
|
|
22
21
|
"dist/src/secret-paths.js",
|
|
23
22
|
"dist/src/source-digest.js",
|
|
24
23
|
"dist/src/source-intake.js",
|
|
@@ -28,7 +27,8 @@
|
|
|
28
27
|
"node": ">=22.13.0"
|
|
29
28
|
},
|
|
30
29
|
"dependencies": {
|
|
31
|
-
"embedded-postgres": "18.4.0-beta.17"
|
|
30
|
+
"embedded-postgres": "18.4.0-beta.17",
|
|
31
|
+
"ignore": "^7.0.10"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"prebuild": "node scripts/kit-bundle.mjs verify",
|
package/dist/src/gitignore.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
export function parseGitIgnore(content) {
|
|
2
|
-
const rules = [];
|
|
3
|
-
for (const raw of content.split(/\r?\n/)) {
|
|
4
|
-
let line = raw.replace(/\s+$/, "");
|
|
5
|
-
if (!line || line.startsWith("#"))
|
|
6
|
-
continue;
|
|
7
|
-
let negated = false;
|
|
8
|
-
if (line.startsWith("!")) {
|
|
9
|
-
negated = true;
|
|
10
|
-
line = line.slice(1);
|
|
11
|
-
}
|
|
12
|
-
else if (line.startsWith("\\!") || line.startsWith("\\#"))
|
|
13
|
-
line = line.slice(1);
|
|
14
|
-
let directoryOnly = false;
|
|
15
|
-
if (line.endsWith("/")) {
|
|
16
|
-
directoryOnly = true;
|
|
17
|
-
line = line.slice(0, -1);
|
|
18
|
-
}
|
|
19
|
-
if (!line)
|
|
20
|
-
continue;
|
|
21
|
-
let anchored = line.startsWith("/");
|
|
22
|
-
if (anchored)
|
|
23
|
-
line = line.slice(1);
|
|
24
|
-
if (line.includes("/"))
|
|
25
|
-
anchored = true;
|
|
26
|
-
const regex = new RegExp(`^${anchored ? "" : "(?:.*/)?"}${globToRegex(line)}(?:/.*)?$`);
|
|
27
|
-
rules.push({ regex, negated, directoryOnly });
|
|
28
|
-
}
|
|
29
|
-
return {
|
|
30
|
-
ignores(path, isDirectory) {
|
|
31
|
-
const normalized = path.replace(/^\/+|\/+$/g, "");
|
|
32
|
-
if (!normalized)
|
|
33
|
-
return false;
|
|
34
|
-
let ignored = false;
|
|
35
|
-
for (const rule of rules) {
|
|
36
|
-
if (rule.directoryOnly && !isDirectory && !parentMatches(rule.regex, normalized))
|
|
37
|
-
continue;
|
|
38
|
-
if (rule.regex.test(normalized))
|
|
39
|
-
ignored = !rule.negated;
|
|
40
|
-
}
|
|
41
|
-
return ignored;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
/** A directory-only pattern still ignores a file beneath a matching directory. */
|
|
46
|
-
function parentMatches(regex, path) {
|
|
47
|
-
const parts = path.split("/");
|
|
48
|
-
for (let depth = 1; depth < parts.length; depth += 1)
|
|
49
|
-
if (regex.test(parts.slice(0, depth).join("/")))
|
|
50
|
-
return true;
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
function globToRegex(glob) {
|
|
54
|
-
let out = "";
|
|
55
|
-
for (let index = 0; index < glob.length; index += 1) {
|
|
56
|
-
const char = glob[index];
|
|
57
|
-
if (char === "*") {
|
|
58
|
-
if (glob[index + 1] === "*") {
|
|
59
|
-
index += 1;
|
|
60
|
-
if (glob[index + 1] === "/") {
|
|
61
|
-
index += 1;
|
|
62
|
-
out += "(?:.*/)?";
|
|
63
|
-
}
|
|
64
|
-
else
|
|
65
|
-
out += ".*";
|
|
66
|
-
}
|
|
67
|
-
else
|
|
68
|
-
out += "[^/]*";
|
|
69
|
-
}
|
|
70
|
-
else if (char === "?")
|
|
71
|
-
out += "[^/]";
|
|
72
|
-
else if (char === "\\" && index + 1 < glob.length) {
|
|
73
|
-
index += 1;
|
|
74
|
-
out += escape(glob[index]);
|
|
75
|
-
}
|
|
76
|
-
else
|
|
77
|
-
out += escape(char);
|
|
78
|
-
}
|
|
79
|
-
return out;
|
|
80
|
-
}
|
|
81
|
-
function escape(char) { return /[.*+?^${}()|[\]\\/]/.test(char) ? `\\${char}` : char; }
|