@navigate-ai/vite 0.1.22 → 0.1.24
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/ClippyVitePlugin.js +29 -7
- package/package.json +4 -4
package/dist/ClippyVitePlugin.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import { processFile, PolicyGenerator, KnowledgeGraph, deriveBuildId, performUpload } from '@navigate_ai/plugin-shared';
|
|
2
|
+
import { processFile, PolicyGenerator, KnowledgeGraph, linkCrossReferences, deriveBuildId, performUpload } from '@navigate_ai/plugin-shared';
|
|
3
3
|
import { PackageBuilder } from '@navigate_ai/plugin-shared/upload/PackageBuilder';
|
|
4
|
-
import { PackageWriter } from '@navigate_ai/plugin-shared/upload/PackageWriter';
|
|
5
4
|
/** Convert any absolute or backslash path to a forward-slash path relative to cwd. */
|
|
6
5
|
function toRelKey(absPath) {
|
|
7
6
|
return path.relative(process.cwd(), absPath).replace(/\\/g, '/');
|
|
@@ -14,6 +13,33 @@ function generatePolicyFromFiles(files) {
|
|
|
14
13
|
for (const file of files) {
|
|
15
14
|
graph.addFile(file);
|
|
16
15
|
}
|
|
16
|
+
// Resolve imports and link routes to component files
|
|
17
|
+
linkCrossReferences(graph);
|
|
18
|
+
// Free memory: drop components/jsxTree from files that are not
|
|
19
|
+
// route-defining files or route component targets — we only need
|
|
20
|
+
// those for element extraction in PolicyGenerator.
|
|
21
|
+
const routeFiles = new Set();
|
|
22
|
+
for (const sf of graph.getAllFiles()) {
|
|
23
|
+
if (sf.routes.length > 0)
|
|
24
|
+
routeFiles.add(sf.filePath);
|
|
25
|
+
for (const route of sf.routes) {
|
|
26
|
+
if (route.resolvedComponent) {
|
|
27
|
+
routeFiles.add(route.resolvedComponent.filePath);
|
|
28
|
+
// Also keep files imported by the component (one-level expansion targets)
|
|
29
|
+
for (const candidates of (route.resolvedComponent.imports?.values() ?? [])) {
|
|
30
|
+
for (const candidate of candidates) {
|
|
31
|
+
if (candidate.components.length > 0)
|
|
32
|
+
routeFiles.add(candidate.filePath);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
for (const sf of graph.getAllFiles()) {
|
|
39
|
+
if (!routeFiles.has(sf.filePath)) {
|
|
40
|
+
sf.components = [];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
17
43
|
return new PolicyGenerator(graph).generate();
|
|
18
44
|
}
|
|
19
45
|
export function clippyVitePlugin(options) {
|
|
@@ -84,17 +110,13 @@ export function clippyVitePlugin(options) {
|
|
|
84
110
|
const fs = await import('fs');
|
|
85
111
|
const path = await import('path');
|
|
86
112
|
fs.mkdirSync(options.localOutputDir, { recursive: true });
|
|
87
|
-
// Write new policy format
|
|
88
113
|
fs.writeFileSync(path.join(options.localOutputDir, 'clippy-policy.json'), JSON.stringify(policy, null, 2), 'utf-8');
|
|
114
|
+
console.log(`[Clippy] Policy written to ${options.localOutputDir}/clippy-policy.json`);
|
|
89
115
|
}
|
|
90
116
|
catch (e) {
|
|
91
117
|
/* ignore write errors */
|
|
92
118
|
}
|
|
93
119
|
}
|
|
94
|
-
if (options.localOutputDir) {
|
|
95
|
-
const written = new PackageWriter().writeArtifacts(options.localOutputDir, artifacts);
|
|
96
|
-
console.log(`[Clippy] Policy artifacts written: ${written.policyPath}, ${written.selectorsPath}`);
|
|
97
|
-
}
|
|
98
120
|
const artifactUpload = await performUpload(artifacts, options);
|
|
99
121
|
if (artifactUpload.skipped) {
|
|
100
122
|
console.log('[Clippy] Policy artifact upload skipped.');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navigate-ai/vite",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@navigate_ai/plugin-shared": "^0.1.
|
|
21
|
+
"@navigate_ai/plugin-shared": "^0.1.23"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"vite": ">=4.0.0",
|
|
25
24
|
"@babel/parser": "^7.0.0",
|
|
26
|
-
"@babel/traverse": "^7.0.0"
|
|
25
|
+
"@babel/traverse": "^7.0.0",
|
|
26
|
+
"vite": ">=4.0.0"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build": "tsc -p tsconfig.json"
|