@driftsys/markspec 0.1.0 → 0.3.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/README.md +32 -8
- package/esm/_dnt.polyfills.d.ts +101 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -0
- package/esm/_dnt.polyfills.js +127 -0
- package/esm/compiler/inverses.d.ts +22 -0
- package/esm/compiler/inverses.d.ts.map +1 -0
- package/esm/compiler/inverses.js +147 -0
- package/esm/compiler/link_target.d.ts +19 -0
- package/esm/compiler/link_target.d.ts.map +1 -0
- package/esm/compiler/link_target.js +66 -0
- package/esm/compiler/mod.d.ts +43 -0
- package/esm/compiler/mod.d.ts.map +1 -0
- package/esm/compiler/mod.js +163 -0
- package/esm/compiler/schema.d.ts +38 -0
- package/esm/compiler/schema.d.ts.map +1 -0
- package/esm/compiler/schema.js +44 -0
- package/esm/config/markspec.d.ts +51 -0
- package/esm/config/markspec.d.ts.map +1 -0
- package/esm/config/markspec.js +216 -0
- package/esm/config/mod.d.ts +48 -0
- package/esm/config/mod.d.ts.map +1 -0
- package/esm/config/mod.js +243 -0
- package/esm/formatter/mod.d.ts +65 -0
- package/esm/formatter/mod.d.ts.map +1 -0
- package/esm/formatter/mod.js +306 -0
- package/esm/mod.d.ts +19 -0
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +18 -0
- package/esm/model/attributes.d.ts +47 -0
- package/esm/model/attributes.d.ts.map +1 -0
- package/esm/model/attributes.js +97 -0
- package/esm/model/mod.d.ts +381 -0
- package/esm/model/mod.d.ts.map +1 -0
- package/esm/model/mod.js +73 -0
- package/esm/model/profile.d.ts +189 -0
- package/esm/model/profile.d.ts.map +1 -0
- package/esm/model/profile.js +31 -0
- package/esm/parser/attributes.d.ts +48 -0
- package/esm/parser/attributes.d.ts.map +1 -0
- package/esm/parser/attributes.js +131 -0
- package/esm/parser/captions.d.ts +25 -0
- package/esm/parser/captions.d.ts.map +1 -0
- package/esm/parser/captions.js +148 -0
- package/esm/parser/directives.d.ts +29 -0
- package/esm/parser/directives.d.ts.map +1 -0
- package/esm/parser/directives.js +88 -0
- package/esm/parser/frontmatter.d.ts +53 -0
- package/esm/parser/frontmatter.d.ts.map +1 -0
- package/esm/parser/frontmatter.js +185 -0
- package/esm/parser/grammars.d.ts +22 -0
- package/esm/parser/grammars.d.ts.map +1 -0
- package/esm/parser/grammars.js +70 -0
- package/esm/parser/markdown.d.ts +32 -0
- package/esm/parser/markdown.d.ts.map +1 -0
- package/esm/parser/markdown.js +225 -0
- package/esm/parser/mod.d.ts +73 -0
- package/esm/parser/mod.d.ts.map +1 -0
- package/esm/parser/mod.js +89 -0
- package/esm/parser/references.d.ts +24 -0
- package/esm/parser/references.d.ts.map +1 -0
- package/esm/parser/references.js +71 -0
- package/esm/parser/remark.d.ts +9 -0
- package/esm/parser/remark.d.ts.map +1 -0
- package/esm/parser/remark.js +11 -0
- package/esm/parser/source.d.ts +33 -0
- package/esm/parser/source.d.ts.map +1 -0
- package/esm/parser/source.js +192 -0
- package/esm/profile/cache.d.ts +29 -0
- package/esm/profile/cache.d.ts.map +1 -0
- package/esm/profile/cache.js +45 -0
- package/esm/profile/chain.d.ts +42 -0
- package/esm/profile/chain.d.ts.map +1 -0
- package/esm/profile/chain.js +193 -0
- package/esm/profile/git-cache.d.ts +73 -0
- package/esm/profile/git-cache.d.ts.map +1 -0
- package/esm/profile/git-cache.js +96 -0
- package/esm/profile/load.d.ts +28 -0
- package/esm/profile/load.d.ts.map +1 -0
- package/esm/profile/load.js +50 -0
- package/esm/profile/manifest.d.ts +21 -0
- package/esm/profile/manifest.d.ts.map +1 -0
- package/esm/profile/manifest.js +830 -0
- package/esm/profile/merge.d.ts +26 -0
- package/esm/profile/merge.d.ts.map +1 -0
- package/esm/profile/merge.js +518 -0
- package/esm/profile/mod.d.ts +23 -0
- package/esm/profile/mod.d.ts.map +1 -0
- package/esm/profile/mod.js +14 -0
- package/esm/profile/npm.d.ts +51 -0
- package/esm/profile/npm.d.ts.map +1 -0
- package/esm/profile/npm.js +186 -0
- package/esm/profile/resolver.d.ts +60 -0
- package/esm/profile/resolver.d.ts.map +1 -0
- package/esm/profile/resolver.js +132 -0
- package/esm/reporter/mod.d.ts +31 -0
- package/esm/reporter/mod.d.ts.map +1 -0
- package/esm/reporter/mod.js +173 -0
- package/esm/validator/attributes.d.ts +43 -0
- package/esm/validator/attributes.d.ts.map +1 -0
- package/esm/validator/attributes.js +169 -0
- package/esm/validator/mod.d.ts +44 -0
- package/esm/validator/mod.d.ts.map +1 -0
- package/esm/validator/mod.js +214 -0
- package/esm/validator/normalize.d.ts +21 -0
- package/esm/validator/normalize.d.ts.map +1 -0
- package/esm/validator/normalize.js +58 -0
- package/esm/validator/pattern.d.ts +23 -0
- package/esm/validator/pattern.d.ts.map +1 -0
- package/esm/validator/pattern.js +44 -0
- package/esm/validator/pipeline.d.ts +30 -0
- package/esm/validator/pipeline.d.ts.map +1 -0
- package/esm/validator/pipeline.js +115 -0
- package/esm/validator/traceability.d.ts +48 -0
- package/esm/validator/traceability.d.ts.map +1 -0
- package/esm/validator/traceability.js +141 -0
- package/esm/validator/types.d.ts +48 -0
- package/esm/validator/types.d.ts.map +1 -0
- package/esm/validator/types.js +140 -0
- package/esm/validator/value_types.d.ts +20 -0
- package/esm/validator/value_types.d.ts.map +1 -0
- package/esm/validator/value_types.js +126 -0
- package/package.json +8 -1
- package/script/_dnt.polyfills.d.ts +101 -0
- package/script/_dnt.polyfills.d.ts.map +1 -0
- package/script/_dnt.polyfills.js +130 -0
- package/script/compiler/inverses.d.ts +22 -0
- package/script/compiler/inverses.d.ts.map +1 -0
- package/script/compiler/inverses.js +150 -0
- package/script/compiler/link_target.d.ts +19 -0
- package/script/compiler/link_target.d.ts.map +1 -0
- package/script/compiler/link_target.js +69 -0
- package/script/compiler/mod.d.ts +43 -0
- package/script/compiler/mod.d.ts.map +1 -0
- package/script/compiler/mod.js +169 -0
- package/script/compiler/schema.d.ts +38 -0
- package/script/compiler/schema.d.ts.map +1 -0
- package/script/compiler/schema.js +47 -0
- package/script/config/markspec.d.ts +51 -0
- package/script/config/markspec.d.ts.map +1 -0
- package/script/config/markspec.js +222 -0
- package/script/config/mod.d.ts +48 -0
- package/script/config/mod.d.ts.map +1 -0
- package/script/config/mod.js +250 -0
- package/script/formatter/mod.d.ts +65 -0
- package/script/formatter/mod.d.ts.map +1 -0
- package/script/formatter/mod.js +313 -0
- package/script/mod.d.ts +19 -0
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +65 -2
- package/script/model/attributes.d.ts +47 -0
- package/script/model/attributes.d.ts.map +1 -0
- package/script/model/attributes.js +101 -0
- package/script/model/mod.d.ts +381 -0
- package/script/model/mod.d.ts.map +1 -0
- package/script/model/mod.js +83 -0
- package/script/model/profile.d.ts +189 -0
- package/script/model/profile.d.ts.map +1 -0
- package/script/model/profile.js +34 -0
- package/script/parser/attributes.d.ts +48 -0
- package/script/parser/attributes.d.ts.map +1 -0
- package/script/parser/attributes.js +137 -0
- package/script/parser/captions.d.ts +25 -0
- package/script/parser/captions.d.ts.map +1 -0
- package/script/parser/captions.js +151 -0
- package/script/parser/directives.d.ts +29 -0
- package/script/parser/directives.d.ts.map +1 -0
- package/script/parser/directives.js +91 -0
- package/script/parser/frontmatter.d.ts +53 -0
- package/script/parser/frontmatter.d.ts.map +1 -0
- package/script/parser/frontmatter.js +188 -0
- package/script/parser/grammars.d.ts +22 -0
- package/script/parser/grammars.d.ts.map +1 -0
- package/script/parser/grammars.js +77 -0
- package/script/parser/markdown.d.ts +32 -0
- package/script/parser/markdown.d.ts.map +1 -0
- package/script/parser/markdown.js +228 -0
- package/script/parser/mod.d.ts +73 -0
- package/script/parser/mod.d.ts.map +1 -0
- package/script/parser/mod.js +101 -0
- package/script/parser/references.d.ts +24 -0
- package/script/parser/references.d.ts.map +1 -0
- package/script/parser/references.js +74 -0
- package/script/parser/remark.d.ts +9 -0
- package/script/parser/remark.d.ts.map +1 -0
- package/script/parser/remark.js +17 -0
- package/script/parser/source.d.ts +33 -0
- package/script/parser/source.d.ts.map +1 -0
- package/script/parser/source.js +198 -0
- package/script/profile/cache.d.ts +29 -0
- package/script/profile/cache.d.ts.map +1 -0
- package/script/profile/cache.js +48 -0
- package/script/profile/chain.d.ts +42 -0
- package/script/profile/chain.d.ts.map +1 -0
- package/script/profile/chain.js +229 -0
- package/script/profile/git-cache.d.ts +73 -0
- package/script/profile/git-cache.d.ts.map +1 -0
- package/script/profile/git-cache.js +104 -0
- package/script/profile/load.d.ts +28 -0
- package/script/profile/load.d.ts.map +1 -0
- package/script/profile/load.js +53 -0
- package/script/profile/manifest.d.ts +21 -0
- package/script/profile/manifest.d.ts.map +1 -0
- package/script/profile/manifest.js +833 -0
- package/script/profile/merge.d.ts +26 -0
- package/script/profile/merge.d.ts.map +1 -0
- package/script/profile/merge.js +521 -0
- package/script/profile/mod.d.ts +23 -0
- package/script/profile/mod.d.ts.map +1 -0
- package/script/profile/mod.js +31 -0
- package/script/profile/npm.d.ts +51 -0
- package/script/profile/npm.d.ts.map +1 -0
- package/script/profile/npm.js +191 -0
- package/script/profile/resolver.d.ts +60 -0
- package/script/profile/resolver.d.ts.map +1 -0
- package/script/profile/resolver.js +136 -0
- package/script/reporter/mod.d.ts +31 -0
- package/script/reporter/mod.d.ts.map +1 -0
- package/script/reporter/mod.js +176 -0
- package/script/validator/attributes.d.ts +43 -0
- package/script/validator/attributes.d.ts.map +1 -0
- package/script/validator/attributes.js +173 -0
- package/script/validator/mod.d.ts +44 -0
- package/script/validator/mod.d.ts.map +1 -0
- package/script/validator/mod.js +231 -0
- package/script/validator/normalize.d.ts +21 -0
- package/script/validator/normalize.d.ts.map +1 -0
- package/script/validator/normalize.js +61 -0
- package/script/validator/pattern.d.ts +23 -0
- package/script/validator/pattern.d.ts.map +1 -0
- package/script/validator/pattern.js +47 -0
- package/script/validator/pipeline.d.ts +30 -0
- package/script/validator/pipeline.d.ts.map +1 -0
- package/script/validator/pipeline.js +118 -0
- package/script/validator/traceability.d.ts +48 -0
- package/script/validator/traceability.d.ts.map +1 -0
- package/script/validator/traceability.js +146 -0
- package/script/validator/types.d.ts +48 -0
- package/script/validator/types.d.ts.map +1 -0
- package/script/validator/types.js +144 -0
- package/script/validator/value_types.d.ts +20 -0
- package/script/validator/value_types.d.ts.map +1 -0
- package/script/validator/value_types.js +129 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module parser/source
|
|
4
|
+
*
|
|
5
|
+
* Source-code doc-comment parser. Extracts MarkSpec entry blocks from doc
|
|
6
|
+
* comments in Rust, Kotlin, C, C++, and Java source files. Delegates parsed
|
|
7
|
+
* content to the markdown parser for entry extraction.
|
|
8
|
+
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.parseSource = parseSource;
|
|
14
|
+
const web_tree_sitter_1 = __importDefault(require("web-tree-sitter"));
|
|
15
|
+
const markdown_js_1 = require("./markdown.js");
|
|
16
|
+
/**
|
|
17
|
+
* Parse a source file and return entries extracted from doc comments.
|
|
18
|
+
*
|
|
19
|
+
* Uses tree-sitter to parse the source, walks the AST to find doc comment
|
|
20
|
+
* nodes, strips comment prefixes, and delegates to the markdown parser for
|
|
21
|
+
* entry extraction. Doc comments that don't contain entry blocks are ignored.
|
|
22
|
+
*
|
|
23
|
+
* @param content - Source file text
|
|
24
|
+
* @param options - Parse options (language grammar, file path)
|
|
25
|
+
*/
|
|
26
|
+
function parseSource(content, options) {
|
|
27
|
+
const file = options.file ?? "<unknown>";
|
|
28
|
+
const parser = new web_tree_sitter_1.default();
|
|
29
|
+
parser.setLanguage(options.language);
|
|
30
|
+
const tree = parser.parse(content);
|
|
31
|
+
const blocks = [];
|
|
32
|
+
walkForDocComments(tree.rootNode, blocks);
|
|
33
|
+
const entries = [];
|
|
34
|
+
for (const block of blocks) {
|
|
35
|
+
const markdown = wrapAsListItem(block.lines);
|
|
36
|
+
const parsed = (0, markdown_js_1.parseMarkdown)(markdown, { file });
|
|
37
|
+
for (const entry of parsed) {
|
|
38
|
+
const location = {
|
|
39
|
+
file,
|
|
40
|
+
line: block.startLine,
|
|
41
|
+
column: block.startColumn,
|
|
42
|
+
};
|
|
43
|
+
entries.push({
|
|
44
|
+
...entry,
|
|
45
|
+
source: "doc-comment",
|
|
46
|
+
location,
|
|
47
|
+
properties: {
|
|
48
|
+
file: {
|
|
49
|
+
path: file,
|
|
50
|
+
line: block.startLine,
|
|
51
|
+
column: block.startColumn,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
tree.delete();
|
|
58
|
+
parser.delete();
|
|
59
|
+
return { entries };
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Recursively walk the tree-sitter AST and collect doc comment blocks.
|
|
63
|
+
*
|
|
64
|
+
* At each level, consecutive `line_comment` nodes with
|
|
65
|
+
* `outer_doc_comment_marker` are grouped into a single block.
|
|
66
|
+
* `block_comment` nodes starting with `/**` become individual blocks.
|
|
67
|
+
* Non-comment children are recursed into so that doc comments inside
|
|
68
|
+
* `mod`, `impl`, and other nested scopes are discovered.
|
|
69
|
+
*/
|
|
70
|
+
function walkForDocComments(node, blocks) {
|
|
71
|
+
let currentLines = [];
|
|
72
|
+
let currentStartLine = 0;
|
|
73
|
+
let currentStartColumn = 0;
|
|
74
|
+
let lastRow = -2;
|
|
75
|
+
function flushLineBlock() {
|
|
76
|
+
if (currentLines.length > 0) {
|
|
77
|
+
blocks.push({
|
|
78
|
+
lines: currentLines,
|
|
79
|
+
startLine: currentStartLine,
|
|
80
|
+
startColumn: currentStartColumn,
|
|
81
|
+
});
|
|
82
|
+
currentLines = [];
|
|
83
|
+
lastRow = -2;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
87
|
+
const child = node.child(i);
|
|
88
|
+
if (child.type === "line_comment" && isOuterDocComment(child)) {
|
|
89
|
+
const row = child.startPosition.row;
|
|
90
|
+
// Not consecutive — flush previous block
|
|
91
|
+
if (currentLines.length > 0 && row !== lastRow + 1) {
|
|
92
|
+
flushLineBlock();
|
|
93
|
+
}
|
|
94
|
+
if (currentLines.length === 0) {
|
|
95
|
+
currentStartLine = row + 1; // 1-based
|
|
96
|
+
currentStartColumn = child.startPosition.column + 1; // 1-based
|
|
97
|
+
}
|
|
98
|
+
currentLines.push(stripLineCommentPrefix(child));
|
|
99
|
+
lastRow = row;
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (child.type === "block_comment" && child.text.startsWith("/**")) {
|
|
103
|
+
flushLineBlock();
|
|
104
|
+
blocks.push({
|
|
105
|
+
lines: stripBlockCommentPrefix(child.text),
|
|
106
|
+
startLine: child.startPosition.row + 1,
|
|
107
|
+
startColumn: child.startPosition.column + 1,
|
|
108
|
+
});
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
// Non-comment node — flush pending line comments, then recurse.
|
|
112
|
+
flushLineBlock();
|
|
113
|
+
if (child.childCount > 0) {
|
|
114
|
+
walkForDocComments(child, blocks);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
flushLineBlock();
|
|
118
|
+
}
|
|
119
|
+
/** Check if a line_comment node is a `///` outer doc comment. */
|
|
120
|
+
function isOuterDocComment(node) {
|
|
121
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
122
|
+
if (node.child(i).type === "outer_doc_comment_marker")
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Strip the `///` prefix from a line comment node.
|
|
129
|
+
* Uses the `doc_comment` child if available, otherwise strips manually.
|
|
130
|
+
*/
|
|
131
|
+
function stripLineCommentPrefix(node) {
|
|
132
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
133
|
+
const child = node.child(i);
|
|
134
|
+
if (child.type === "doc_comment") {
|
|
135
|
+
let text = child.text.replace(/\n$/, "");
|
|
136
|
+
// Strip one leading space (convention: `/// text`)
|
|
137
|
+
if (text.startsWith(" "))
|
|
138
|
+
text = text.slice(1);
|
|
139
|
+
return text;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// Fallback: manual prefix stripping
|
|
143
|
+
const text = node.text.replace(/\n$/, "");
|
|
144
|
+
if (text.startsWith("/// "))
|
|
145
|
+
return text.slice(4);
|
|
146
|
+
if (text.startsWith("///"))
|
|
147
|
+
return text.slice(3);
|
|
148
|
+
return text;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Strip block comment delimiters and leading ` * ` prefixes.
|
|
152
|
+
* Returns cleaned lines.
|
|
153
|
+
*/
|
|
154
|
+
function stripBlockCommentPrefix(text) {
|
|
155
|
+
const rawLines = text.split("\n");
|
|
156
|
+
const result = [];
|
|
157
|
+
for (let i = 0; i < rawLines.length; i++) {
|
|
158
|
+
const trimmed = rawLines[i].trim();
|
|
159
|
+
// Skip opening `/**` line (may have content after it)
|
|
160
|
+
if (i === 0) {
|
|
161
|
+
const afterOpening = trimmed.slice(3).trim();
|
|
162
|
+
if (afterOpening && afterOpening !== "/") {
|
|
163
|
+
result.push(afterOpening);
|
|
164
|
+
}
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
// Skip closing `*/`
|
|
168
|
+
if (i === rawLines.length - 1 && trimmed === "*/") {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
// Strip leading ` * ` or ` *`
|
|
172
|
+
if (trimmed.startsWith("* ")) {
|
|
173
|
+
result.push(trimmed.slice(2));
|
|
174
|
+
}
|
|
175
|
+
else if (trimmed === "*") {
|
|
176
|
+
result.push("");
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
result.push(trimmed);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Wrap cleaned doc comment lines as a Markdown list item so the
|
|
186
|
+
* existing `parseMarkdown()` can extract entries.
|
|
187
|
+
*
|
|
188
|
+
* Doc comments use `[DISPLAY_ID] Title` without the `- ` bullet.
|
|
189
|
+
* This wraps to `- [DISPLAY_ID] Title\n\n body...` which parseMarkdown
|
|
190
|
+
* recognizes as an entry block.
|
|
191
|
+
*/
|
|
192
|
+
function wrapAsListItem(lines) {
|
|
193
|
+
if (lines.length === 0)
|
|
194
|
+
return "";
|
|
195
|
+
const first = `- ${lines[0]}`;
|
|
196
|
+
const rest = lines.slice(1).map((line) => line === "" ? "" : ` ${line}`);
|
|
197
|
+
return [first, ...rest].join("\n");
|
|
198
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/profile/cache
|
|
3
|
+
*
|
|
4
|
+
* XDG-compliant cache directory resolution for profile storage.
|
|
5
|
+
* Profiles fetched from git or npm are cached globally so they can
|
|
6
|
+
* be shared across projects.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Environment variables consulted for cache directory resolution.
|
|
10
|
+
* Injectable for testing — production code passes `Deno.env.toObject()`.
|
|
11
|
+
*/
|
|
12
|
+
export interface CacheEnv {
|
|
13
|
+
readonly XDG_CACHE_HOME?: string;
|
|
14
|
+
readonly HOME?: string;
|
|
15
|
+
readonly LOCALAPPDATA?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Resolve the global markspec cache directory (XDG-compliant).
|
|
19
|
+
*
|
|
20
|
+
* - `$XDG_CACHE_HOME/markspec` if set (any platform)
|
|
21
|
+
* - macOS: `~/Library/Caches/markspec`
|
|
22
|
+
* - Windows: `%LOCALAPPDATA%/markspec/cache`
|
|
23
|
+
* - Linux/other: `~/.cache/markspec`
|
|
24
|
+
*
|
|
25
|
+
* @param env - Environment variables (injectable for tests)
|
|
26
|
+
* @param platform - OS platform string (injectable for tests; defaults to `Deno.build.os`)
|
|
27
|
+
*/
|
|
28
|
+
export declare function cacheDir(env?: CacheEnv, platform?: string): string;
|
|
29
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/profile/cache.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CACtB,GAAG,CAAC,EAAE,QAAQ,EACd,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAsBR"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module core/profile/cache
|
|
4
|
+
*
|
|
5
|
+
* XDG-compliant cache directory resolution for profile storage.
|
|
6
|
+
* Profiles fetched from git or npm are cached globally so they can
|
|
7
|
+
* be shared across projects.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.cacheDir = cacheDir;
|
|
11
|
+
const path_1 = require("@std/path");
|
|
12
|
+
/**
|
|
13
|
+
* Resolve the global markspec cache directory (XDG-compliant).
|
|
14
|
+
*
|
|
15
|
+
* - `$XDG_CACHE_HOME/markspec` if set (any platform)
|
|
16
|
+
* - macOS: `~/Library/Caches/markspec`
|
|
17
|
+
* - Windows: `%LOCALAPPDATA%/markspec/cache`
|
|
18
|
+
* - Linux/other: `~/.cache/markspec`
|
|
19
|
+
*
|
|
20
|
+
* @param env - Environment variables (injectable for tests)
|
|
21
|
+
* @param platform - OS platform string (injectable for tests; defaults to `Deno.build.os`)
|
|
22
|
+
*/
|
|
23
|
+
function cacheDir(env, platform) {
|
|
24
|
+
const e = env ?? envFromDeno();
|
|
25
|
+
const os = platform ?? Deno.build.os;
|
|
26
|
+
if (e.XDG_CACHE_HOME) {
|
|
27
|
+
return (0, path_1.join)(e.XDG_CACHE_HOME, "markspec");
|
|
28
|
+
}
|
|
29
|
+
if (os === "darwin") {
|
|
30
|
+
const home = e.HOME ?? "/tmp";
|
|
31
|
+
return (0, path_1.join)(home, "Library", "Caches", "markspec");
|
|
32
|
+
}
|
|
33
|
+
if (os === "windows") {
|
|
34
|
+
const localAppData = e.LOCALAPPDATA ??
|
|
35
|
+
(0, path_1.join)(e.HOME ?? "C:\\Users\\default", "AppData", "Local");
|
|
36
|
+
return (0, path_1.join)(localAppData, "markspec", "cache");
|
|
37
|
+
}
|
|
38
|
+
// Linux and others — XDG default
|
|
39
|
+
const home = e.HOME ?? "/tmp";
|
|
40
|
+
return (0, path_1.join)(home, ".cache", "markspec");
|
|
41
|
+
}
|
|
42
|
+
function envFromDeno() {
|
|
43
|
+
return {
|
|
44
|
+
XDG_CACHE_HOME: Deno.env.get("XDG_CACHE_HOME"),
|
|
45
|
+
HOME: Deno.env.get("HOME"),
|
|
46
|
+
LOCALAPPDATA: Deno.env.get("LOCALAPPDATA"),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/profile/chain
|
|
3
|
+
*
|
|
4
|
+
* Profile chain loader. Walks the `extends:` pointer from a leaf specifier
|
|
5
|
+
* up to the root, producing a multi-tier {@linkcode ProfileChain} ordered
|
|
6
|
+
* root → leaf.
|
|
7
|
+
*
|
|
8
|
+
* Supports both local and git specifiers, with cycle + depth detection. Git
|
|
9
|
+
* specifiers route through {@linkcode resolveGitSpecifier} (per-project
|
|
10
|
+
* shallow+sparse clone cache); local specifiers route through
|
|
11
|
+
* {@linkcode resolveLocalSpecifier}. The chain's {@linkcode EffectiveProfile}
|
|
12
|
+
* is produced by {@linkcode mergeChain}.
|
|
13
|
+
*/
|
|
14
|
+
import type { ReadFile } from "../config/mod.js";
|
|
15
|
+
import type { Diagnostic, ProfileChain, ProfileSpecifier } from "../model/mod.js";
|
|
16
|
+
import type { AppendFile, RunGit } from "./git-cache.js";
|
|
17
|
+
/** Result of loading a profile chain. */
|
|
18
|
+
export interface LoadChainResult {
|
|
19
|
+
readonly chain: ProfileChain | null;
|
|
20
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
21
|
+
}
|
|
22
|
+
/** Options accepted by {@linkcode loadChain}. */
|
|
23
|
+
export interface LoadChainOptions {
|
|
24
|
+
readonly runGit?: RunGit;
|
|
25
|
+
readonly appendFile?: AppendFile;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Load a profile chain from a specifier, walking the `extends:` pointer up
|
|
29
|
+
* to the root. The returned chain's tiers are ordered root → leaf, so
|
|
30
|
+
* `tiers[0]` is the ultimate ancestor and `tiers[last]` is the leaf
|
|
31
|
+
* specified by the caller.
|
|
32
|
+
*
|
|
33
|
+
* @param specifier - The leaf specifier (from `.markspec.yaml`)
|
|
34
|
+
* @param contextDir - Directory the specifier was declared in (for local
|
|
35
|
+
* path resolution)
|
|
36
|
+
* @param projectRoot - Absolute path of the project root (used to locate
|
|
37
|
+
* the `.markspec/cache/` directory for git specifiers)
|
|
38
|
+
* @param readFile - File reader abstraction
|
|
39
|
+
* @param opts - Injectable runners for git-cache operations (optional)
|
|
40
|
+
*/
|
|
41
|
+
export declare function loadChain(specifier: ProfileSpecifier, contextDir: string, projectRoot: string, readFile: ReadFile, opts?: LoadChainOptions): Promise<LoadChainResult>;
|
|
42
|
+
//# sourceMappingURL=chain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../src/profile/chain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EACV,UAAU,EAGV,YAAY,EACZ,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAYzD,yCAAyC;AACzC,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED,iDAAiD;AACjD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;CAClC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,SAAS,CAC7B,SAAS,EAAE,gBAAgB,EAC3B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,QAAQ,EAClB,IAAI,GAAE,gBAAqB,GAC1B,OAAO,CAAC,eAAe,CAAC,CA+G1B"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module core/profile/chain
|
|
4
|
+
*
|
|
5
|
+
* Profile chain loader. Walks the `extends:` pointer from a leaf specifier
|
|
6
|
+
* up to the root, producing a multi-tier {@linkcode ProfileChain} ordered
|
|
7
|
+
* root → leaf.
|
|
8
|
+
*
|
|
9
|
+
* Supports both local and git specifiers, with cycle + depth detection. Git
|
|
10
|
+
* specifiers route through {@linkcode resolveGitSpecifier} (per-project
|
|
11
|
+
* shallow+sparse clone cache); local specifiers route through
|
|
12
|
+
* {@linkcode resolveLocalSpecifier}. The chain's {@linkcode EffectiveProfile}
|
|
13
|
+
* is produced by {@linkcode mergeChain}.
|
|
14
|
+
*/
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
+
}) : function(o, v) {
|
|
29
|
+
o["default"] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
32
|
+
var ownKeys = function(o) {
|
|
33
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
34
|
+
var ar = [];
|
|
35
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
36
|
+
return ar;
|
|
37
|
+
};
|
|
38
|
+
return ownKeys(o);
|
|
39
|
+
};
|
|
40
|
+
return function (mod) {
|
|
41
|
+
if (mod && mod.__esModule) return mod;
|
|
42
|
+
var result = {};
|
|
43
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
})();
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.loadChain = loadChain;
|
|
50
|
+
const path_1 = require("@std/path");
|
|
51
|
+
const manifest_js_1 = require("./manifest.js");
|
|
52
|
+
const merge_js_1 = require("./merge.js");
|
|
53
|
+
const resolver_js_1 = require("./resolver.js");
|
|
54
|
+
/** Maximum number of tiers allowed in an `extends:` chain. */
|
|
55
|
+
const MAX_CHAIN_DEPTH = 20;
|
|
56
|
+
/**
|
|
57
|
+
* Load a profile chain from a specifier, walking the `extends:` pointer up
|
|
58
|
+
* to the root. The returned chain's tiers are ordered root → leaf, so
|
|
59
|
+
* `tiers[0]` is the ultimate ancestor and `tiers[last]` is the leaf
|
|
60
|
+
* specified by the caller.
|
|
61
|
+
*
|
|
62
|
+
* @param specifier - The leaf specifier (from `.markspec.yaml`)
|
|
63
|
+
* @param contextDir - Directory the specifier was declared in (for local
|
|
64
|
+
* path resolution)
|
|
65
|
+
* @param projectRoot - Absolute path of the project root (used to locate
|
|
66
|
+
* the `.markspec/cache/` directory for git specifiers)
|
|
67
|
+
* @param readFile - File reader abstraction
|
|
68
|
+
* @param opts - Injectable runners for git-cache operations (optional)
|
|
69
|
+
*/
|
|
70
|
+
async function loadChain(specifier, contextDir, projectRoot, readFile, opts = {}) {
|
|
71
|
+
const diagnostics = [];
|
|
72
|
+
// Walk extends: chain. Accumulate tiers leaf-first, reverse at the end.
|
|
73
|
+
const tiersLeafFirst = [];
|
|
74
|
+
const visited = new Set(); // canonical specifier key
|
|
75
|
+
let cursorSpec = specifier;
|
|
76
|
+
let cursorDir = contextDir;
|
|
77
|
+
while (cursorSpec !== undefined) {
|
|
78
|
+
const key = specifierKey(cursorSpec, cursorDir);
|
|
79
|
+
if (visited.has(key)) {
|
|
80
|
+
diagnostics.push({
|
|
81
|
+
code: "PROFILE-LOAD-004",
|
|
82
|
+
severity: "error",
|
|
83
|
+
message: `profile extends: cycle detected at ${stringifySpec(cursorSpec)} ` +
|
|
84
|
+
`(already visited in this chain)`,
|
|
85
|
+
location: { file: "<specifier>", line: 1, column: 1 },
|
|
86
|
+
});
|
|
87
|
+
return { chain: null, diagnostics };
|
|
88
|
+
}
|
|
89
|
+
visited.add(key);
|
|
90
|
+
if (tiersLeafFirst.length >= MAX_CHAIN_DEPTH) {
|
|
91
|
+
diagnostics.push({
|
|
92
|
+
code: "PROFILE-LOAD-005",
|
|
93
|
+
severity: "error",
|
|
94
|
+
message: `profile extends: chain exceeds maximum depth (${MAX_CHAIN_DEPTH})`,
|
|
95
|
+
location: { file: "<specifier>", line: 1, column: 1 },
|
|
96
|
+
});
|
|
97
|
+
return { chain: null, diagnostics };
|
|
98
|
+
}
|
|
99
|
+
let resolved;
|
|
100
|
+
if (cursorSpec.kind === "git") {
|
|
101
|
+
resolved = await (0, resolver_js_1.resolveGitSpecifier)(cursorSpec, projectRoot, readFile, diagnostics, { runGit: opts.runGit, appendFile: opts.appendFile });
|
|
102
|
+
}
|
|
103
|
+
else if (cursorSpec.kind === "npm") {
|
|
104
|
+
const { resolveNpmSpecifier } = await Promise.resolve().then(() => __importStar(require("./npm.js")));
|
|
105
|
+
const { cacheDir: cacheDirFn } = await Promise.resolve().then(() => __importStar(require("./cache.js")));
|
|
106
|
+
resolved = await resolveNpmSpecifier(cursorSpec, diagnostics, {
|
|
107
|
+
cacheRoot: cacheDirFn(),
|
|
108
|
+
readFile,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
resolved = await (0, resolver_js_1.resolveLocalSpecifier)(cursorSpec, cursorDir, readFile, diagnostics);
|
|
113
|
+
}
|
|
114
|
+
if (!resolved) {
|
|
115
|
+
return { chain: null, diagnostics };
|
|
116
|
+
}
|
|
117
|
+
const parsed = (0, manifest_js_1.parseManifest)(resolved.rawYaml, resolved.sourcePath);
|
|
118
|
+
diagnostics.push(...parsed.diagnostics);
|
|
119
|
+
if (!parsed.manifest) {
|
|
120
|
+
return { chain: null, diagnostics };
|
|
121
|
+
}
|
|
122
|
+
const tier = {
|
|
123
|
+
id: parsed.manifest.id,
|
|
124
|
+
version: parsed.manifest.version,
|
|
125
|
+
specifier: cursorSpec,
|
|
126
|
+
manifest: parsed.manifest,
|
|
127
|
+
sourcePath: resolved.sourcePath,
|
|
128
|
+
baseDir: resolved.baseDir,
|
|
129
|
+
};
|
|
130
|
+
tiersLeafFirst.push(tier);
|
|
131
|
+
// Advance cursor to the parent, if any.
|
|
132
|
+
if (parsed.manifest.extends !== undefined) {
|
|
133
|
+
cursorSpec = parsed.manifest.extends;
|
|
134
|
+
cursorDir = resolved.baseDir;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
cursorSpec = undefined;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// Reverse so tiers[0] = root parent, tiers[last] = leaf child.
|
|
141
|
+
const tiers = tiersLeafFirst.reverse();
|
|
142
|
+
// Build a temporary chain shape to feed into mergeChain. It reads only
|
|
143
|
+
// .tiers; the placeholder effective is ignored by merge.
|
|
144
|
+
const stubChain = {
|
|
145
|
+
tiers,
|
|
146
|
+
effective: buildPlaceholderEffective(tiers),
|
|
147
|
+
};
|
|
148
|
+
const mergeResult = (0, merge_js_1.mergeChain)(stubChain);
|
|
149
|
+
diagnostics.push(...mergeResult.diagnostics);
|
|
150
|
+
if (!mergeResult.effective) {
|
|
151
|
+
return { chain: null, diagnostics };
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
chain: { tiers, effective: mergeResult.effective },
|
|
155
|
+
diagnostics,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Canonical cycle-detection key for a resolved specifier. Two specifiers that
|
|
160
|
+
* resolve to the same tier are canonicalized to the same key:
|
|
161
|
+
*
|
|
162
|
+
* - Local specifiers key on the absolute resolved directory (after
|
|
163
|
+
* normalization of `.` / `..`).
|
|
164
|
+
* - Git specifiers key on `(repo, tag, subpath)`, which is what the git cache
|
|
165
|
+
* itself uses — two specifiers that hit the same cache entry are the same
|
|
166
|
+
* tier.
|
|
167
|
+
*
|
|
168
|
+
* Note: this does NOT canonicalize symlinks for local specifiers. Two
|
|
169
|
+
* different symlinked paths pointing at the same profile will only be caught
|
|
170
|
+
* by MAX_CHAIN_DEPTH, which emits PROFILE-LOAD-005 instead of
|
|
171
|
+
* PROFILE-LOAD-004. Acceptable for v1 since `Deno.realPath` would require an
|
|
172
|
+
* additional I/O round-trip and a filesystem shim for the test mock reader.
|
|
173
|
+
*/
|
|
174
|
+
function specifierKey(spec, contextDir) {
|
|
175
|
+
if (spec.kind === "local") {
|
|
176
|
+
return `local:${(0, path_1.resolve)(contextDir, spec.path)}`;
|
|
177
|
+
}
|
|
178
|
+
if (spec.kind === "git") {
|
|
179
|
+
return `git:${spec.repo}#${spec.tag}|${spec.subpath ?? ""}`;
|
|
180
|
+
}
|
|
181
|
+
if (spec.kind === "npm") {
|
|
182
|
+
const pkg = spec.scope ? `${spec.scope}/${spec.name}` : spec.name;
|
|
183
|
+
return `npm:${pkg}@${spec.range}`;
|
|
184
|
+
}
|
|
185
|
+
const _exhaustive = spec;
|
|
186
|
+
throw new Error(`Unknown specifier kind`);
|
|
187
|
+
}
|
|
188
|
+
/** Human-readable one-liner for a specifier (used in diagnostic messages). */
|
|
189
|
+
function stringifySpec(spec) {
|
|
190
|
+
if (spec.kind === "local") {
|
|
191
|
+
return spec.path;
|
|
192
|
+
}
|
|
193
|
+
if (spec.kind === "git") {
|
|
194
|
+
return `git+${spec.repo}#${spec.tag}`;
|
|
195
|
+
}
|
|
196
|
+
if (spec.kind === "npm") {
|
|
197
|
+
const pkg = spec.scope ? `${spec.scope}/${spec.name}` : spec.name;
|
|
198
|
+
return `npm:${pkg}@${spec.range}`;
|
|
199
|
+
}
|
|
200
|
+
const _exhaustive = spec;
|
|
201
|
+
throw new Error(`Unknown specifier kind`);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Build a placeholder EffectiveProfile used only as a stub input when
|
|
205
|
+
* constructing the {@linkcode ProfileChain} shape we hand to
|
|
206
|
+
* {@linkcode mergeChain}. `mergeChain` reads only `.tiers`, so the stub
|
|
207
|
+
* contents are irrelevant.
|
|
208
|
+
*/
|
|
209
|
+
function buildPlaceholderEffective(tiers) {
|
|
210
|
+
const leafOrigin = tiers[tiers.length - 1]?.id ?? "<unknown>";
|
|
211
|
+
return {
|
|
212
|
+
required: { value: [], origin: leafOrigin },
|
|
213
|
+
attributes: new Map(),
|
|
214
|
+
labels: { value: [], origin: leafOrigin },
|
|
215
|
+
colors: new Map(),
|
|
216
|
+
identified: {
|
|
217
|
+
required: { value: [], origin: leafOrigin },
|
|
218
|
+
attributes: new Map(),
|
|
219
|
+
traceability: new Map(),
|
|
220
|
+
},
|
|
221
|
+
referenced: {
|
|
222
|
+
required: { value: [], origin: leafOrigin },
|
|
223
|
+
attributes: new Map(),
|
|
224
|
+
traceability: new Map(),
|
|
225
|
+
},
|
|
226
|
+
types: new Map(),
|
|
227
|
+
documents: { types: new Map(), frontMatter: new Map() },
|
|
228
|
+
};
|
|
229
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/profile/git-cache
|
|
3
|
+
*
|
|
4
|
+
* Cache + `git` CLI infrastructure for git-specifier resolution.
|
|
5
|
+
*
|
|
6
|
+
* The cache lives under `<project-root>/.markspec/cache/<sha>/` where `<sha>`
|
|
7
|
+
* is the sha256 of a canonical `(host, repo, subpath, tag)` tuple. Because
|
|
8
|
+
* the spec requires tag-only specifiers and tags are (by convention)
|
|
9
|
+
* immutable, cached content never needs refresh: either the cache directory
|
|
10
|
+
* exists and contains `markspec.yaml`, or we clone afresh.
|
|
11
|
+
*/
|
|
12
|
+
/** Components of a git specifier that contribute to the cache key. */
|
|
13
|
+
export interface GitCacheKeyInput {
|
|
14
|
+
readonly repo: string;
|
|
15
|
+
readonly subpath: string | undefined;
|
|
16
|
+
readonly tag: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Stable sha256 hex digest of the canonical `(repo, subpath, tag)` tuple.
|
|
20
|
+
* Same inputs → same digest, always.
|
|
21
|
+
*/
|
|
22
|
+
export declare function computeCacheKey(input: GitCacheKeyInput): Promise<string>;
|
|
23
|
+
/** Resolved paths for a cache-backed specifier. */
|
|
24
|
+
export interface CacheLocation {
|
|
25
|
+
/** sha256 hex key for the specifier. */
|
|
26
|
+
readonly key: string;
|
|
27
|
+
/** Absolute cache directory — where the clone lives (top-level repo). */
|
|
28
|
+
readonly dir: string;
|
|
29
|
+
/** Absolute path of the `markspec.yaml` the resolver needs to read. */
|
|
30
|
+
readonly manifestPath: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Compute the cache location for a git specifier relative to a project root.
|
|
34
|
+
*/
|
|
35
|
+
export declare function computeCacheLocation(projectRoot: string, input: GitCacheKeyInput): Promise<CacheLocation>;
|
|
36
|
+
/** Result of running a git subcommand — captures exit code + output streams. */
|
|
37
|
+
export interface RunGitResult {
|
|
38
|
+
readonly code: number;
|
|
39
|
+
readonly stdout: string;
|
|
40
|
+
readonly stderr: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Inject this into the resolver to stub git invocations in unit tests.
|
|
44
|
+
* Production code uses {@linkcode defaultRunGit}.
|
|
45
|
+
*/
|
|
46
|
+
export type RunGit = (args: readonly string[], cwd?: string) => Promise<RunGitResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Default implementation backed by `Deno.Command("git", …)`. Captures stdout
|
|
49
|
+
* and stderr; never throws for nonzero exit — callers inspect `result.code`.
|
|
50
|
+
*
|
|
51
|
+
* Requires `--allow-run=git` at the Deno CLI level.
|
|
52
|
+
*/
|
|
53
|
+
export declare const defaultRunGit: RunGit;
|
|
54
|
+
/** Injectable appender for {@linkcode ensureCacheGitignored}. */
|
|
55
|
+
export type AppendFile = (path: string, content: string) => Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Idempotently add `.markspec/cache/` to the project's `.gitignore` if that
|
|
58
|
+
* file exists. No-op when `.gitignore` is absent.
|
|
59
|
+
*
|
|
60
|
+
* Treats `.markspec/`, `.markspec/cache`, and `.markspec/cache/` as already
|
|
61
|
+
* ignored (broadest pattern wins).
|
|
62
|
+
*
|
|
63
|
+
* @param projectRoot - Absolute path containing the `.gitignore`
|
|
64
|
+
* @param readFile - Abstraction matching `core/config/mod.ts` `ReadFile`
|
|
65
|
+
* @param appendFile - Abstraction that appends a string to a file
|
|
66
|
+
*/
|
|
67
|
+
export declare function ensureCacheGitignored(projectRoot: string, readFile: (path: string) => Promise<string | undefined>, appendFile: AppendFile): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Default `AppendFile` backed by `Deno.writeTextFile` with `{ append: true }`.
|
|
70
|
+
* Requires `--allow-write`.
|
|
71
|
+
*/
|
|
72
|
+
export declare const defaultAppendFile: AppendFile;
|
|
73
|
+
//# sourceMappingURL=git-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-cache.d.ts","sourceRoot":"","sources":["../../src/profile/git-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,sEAAsE;AACtE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAAC,MAAM,CAAC,CAWjB;AAED,mDAAmD;AACnD,MAAM,WAAW,aAAa;IAC5B,wCAAwC;IACxC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAAC,aAAa,CAAC,CAOxB;AAED,gFAAgF;AAChF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,CACnB,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,GAAG,CAAC,EAAE,MAAM,KACT,OAAO,CAAC,YAAY,CAAC,CAAC;AAI3B;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,MAa3B,CAAC;AAEF,iEAAiE;AACjE,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1E;;;;;;;;;;GAUG;AACH,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,EACvD,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,IAAI,CAAC,CAmBf;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,UAE/B,CAAC"}
|