@cccarv82/freya 2.3.0 → 2.3.1
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/cli/web.js +32 -9
- package/package.json +1 -1
package/cli/web.js
CHANGED
|
@@ -2072,19 +2072,42 @@ if (req.url === '/api/reports/list') {
|
|
|
2072
2072
|
|
|
2073
2073
|
function autoLinkNotes(textInput) {
|
|
2074
2074
|
try {
|
|
2075
|
+
const lc = textInput.toLowerCase();
|
|
2075
2076
|
const projectsDir = path.join(workspaceDir, 'docs', 'projects');
|
|
2076
|
-
if (!exists(projectsDir)) return '';
|
|
2077
|
-
const files = fs.readdirSync(projectsDir).filter((f) => f.endsWith('.md'));
|
|
2078
2077
|
const links = [];
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
const
|
|
2082
|
-
|
|
2078
|
+
|
|
2079
|
+
if (exists(projectsDir)) {
|
|
2080
|
+
const files = fs.readdirSync(projectsDir).filter((f) => f.endsWith('.md'));
|
|
2081
|
+
for (const f of files) {
|
|
2082
|
+
const name = f.replace('.md', '');
|
|
2083
|
+
const full = path.join(projectsDir, f);
|
|
2084
|
+
const txt = fs.readFileSync(full, 'utf8');
|
|
2085
|
+
const m = txt.match(/DataPath:\s*data\/Clients\/(.+?)\//i);
|
|
2086
|
+
const slug = m ? m[1].toLowerCase() : name.toLowerCase();
|
|
2087
|
+
if (lc.includes(slug)) links.push('[[' + name + ']]');
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
const base = path.join(workspaceDir, 'data', 'Clients');
|
|
2092
|
+
if (exists(base)) {
|
|
2093
|
+
const stack = [base];
|
|
2094
|
+
while (stack.length) {
|
|
2095
|
+
const dirp = stack.pop();
|
|
2096
|
+
const entries = fs.readdirSync(dirp, { withFileTypes: true });
|
|
2097
|
+
for (const ent of entries) {
|
|
2098
|
+
const full = path.join(dirp, ent.name);
|
|
2099
|
+
if (ent.isDirectory()) stack.push(full);
|
|
2100
|
+
else if (ent.isFile() && ent.name === 'status.json') {
|
|
2101
|
+
const slug = path.relative(base, path.dirname(full)).replace(/\\/g, '/').toLowerCase();
|
|
2102
|
+
if (lc.includes(slug)) links.push('[[' + slug + ']]');
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2083
2106
|
}
|
|
2084
|
-
if (!links.length) return '';
|
|
2085
|
-
return `
|
|
2086
2107
|
|
|
2087
|
-
|
|
2108
|
+
const uniq = Array.from(new Set(links));
|
|
2109
|
+
if (!uniq.length) return '';
|
|
2110
|
+
return '\n\nLinks: ' + uniq.join(' ');
|
|
2088
2111
|
} catch {
|
|
2089
2112
|
return '';
|
|
2090
2113
|
}
|
package/package.json
CHANGED