@platformos/platformos-graph 0.0.18 → 0.0.20
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/CHANGELOG.md +22 -0
- package/bin/platformos-graph +21 -81
- package/dist/cli.d.ts +46 -0
- package/dist/cli.js +126 -0
- package/dist/cli.js.map +1 -0
- package/dist/graph/augment.js +0 -1
- package/dist/graph/augment.js.map +1 -1
- package/dist/graph/module.d.ts +16 -1
- package/dist/graph/module.js +39 -0
- package/dist/graph/module.js.map +1 -1
- package/dist/graph/test-helpers.d.ts +2 -3
- package/dist/graph/test-helpers.js +2 -6
- package/dist/graph/test-helpers.js.map +1 -1
- package/dist/graph/traverse.d.ts +31 -3
- package/dist/graph/traverse.js +146 -41
- package/dist/graph/traverse.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +14 -19
- package/dist/types.js.map +1 -1
- package/fixtures/background-edges/app/views/pages/broken.liquid +3 -0
- package/fixtures/background-edges/app/views/pages/index.liquid +3 -0
- package/fixtures/background-edges/app/views/partials/jobs/notify.liquid +3 -0
- package/fixtures/function-edges/app/lib/queries/list.liquid +3 -0
- package/fixtures/function-edges/app/views/pages/broken.liquid +3 -0
- package/fixtures/function-edges/app/views/pages/index.liquid +3 -0
- package/fixtures/graphql-edges/app/graphql/blog_posts/find.graphql +10 -0
- package/fixtures/graphql-edges/app/views/pages/broken.liquid +3 -0
- package/fixtures/graphql-edges/app/views/pages/index.liquid +3 -0
- package/fixtures/include-edges/app/views/pages/index.liquid +1 -0
- package/fixtures/include-edges/app/views/partials/shared/header.liquid +1 -0
- package/fixtures/module-edges/app/views/pages/index.liquid +4 -0
- package/fixtures/module-edges/modules/my_module/public/lib/queries/get.liquid +3 -0
- package/fixtures/module-edges/modules/my_module/public/views/partials/card.liquid +1 -0
- package/fixtures/skeleton/app/views/partials/child.liquid +2 -4
- package/fixtures/skeleton/app/views/partials/parent.liquid +2 -4
- package/fixtures/skeleton/assets/app.js +1 -7
- package/package.json +5 -5
- package/src/cli.spec.ts +265 -0
- package/src/cli.ts +151 -0
- package/src/graph/augment.ts +0 -2
- package/src/graph/build.spec.ts +19 -5
- package/src/graph/extract.spec.ts +155 -0
- package/src/graph/module.ts +40 -0
- package/src/graph/test-helpers.ts +2 -9
- package/src/graph/traverse-edges.spec.ts +278 -0
- package/src/graph/traverse.ts +177 -49
- package/src/index.ts +1 -1
- package/src/types.ts +16 -18
- package/bin/jsconfig.json +0 -18
- package/src/getWebComponentMap.ts +0 -81
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# shopify/theme-graph
|
|
2
2
|
|
|
3
|
+
## 0.0.20
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- bc1b71f: Release changes accumulated since 0.0.19: multi-line and JSON support in tags, refreshed warnings for referenced partials, platformos-graph project structural/dependency model for the supervisor, and updated linter documentation data.
|
|
8
|
+
- MCP Supervisor
|
|
9
|
+
- Updated dependencies [bc1b71f]
|
|
10
|
+
- Updated dependencies [4b6e0aa]
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @platformos/liquid-html-parser@0.0.18
|
|
13
|
+
- @platformos/platformos-common@0.0.18
|
|
14
|
+
- @platformos/platformos-check-common@0.0.20
|
|
15
|
+
|
|
16
|
+
## 0.0.19
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Improved checks
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
- @platformos/platformos-check-common@0.0.19
|
|
23
|
+
- @platformos/liquid-html-parser@0.0.17
|
|
24
|
+
|
|
3
25
|
## 0.0.18
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/bin/platformos-graph
CHANGED
|
@@ -1,107 +1,47 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
const {
|
|
5
|
-
NodeFileSystem,
|
|
6
|
-
memoize,
|
|
7
|
-
toSchema,
|
|
8
|
-
path: pathUtils,
|
|
9
|
-
recursiveReadDirectory,
|
|
10
|
-
} = require('@platformos/theme-check-node');
|
|
11
|
-
const path = require('path');
|
|
12
|
-
const { URI } = require('vscode-uri');
|
|
3
|
+
const { buildSerializedGraph, buildSerializedFileDependencies } = require('../dist/cli');
|
|
13
4
|
|
|
14
5
|
const usage = `
|
|
15
6
|
Usage:
|
|
16
|
-
|
|
7
|
+
platformos-graph <path-to-app-directory> [file]
|
|
17
8
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
Without [file], prints the whole app graph (nodes + edges).
|
|
10
|
+
With [file], prints that single file's dependencies and references.
|
|
11
|
+
A relative [file] is resolved against the project directory.
|
|
21
12
|
|
|
22
|
-
|
|
13
|
+
Examples:
|
|
14
|
+
platformos-graph ./app > graph.json
|
|
15
|
+
platformos-graph ./app app/views/partials/header.liquid
|
|
16
|
+
`;
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
* Outputs the JSON representing the theme graph for a Shopify theme directory.
|
|
26
|
-
*
|
|
27
|
-
* @param {string} root
|
|
28
|
-
*/
|
|
29
|
-
async function main(root) {
|
|
18
|
+
async function main(root, file) {
|
|
30
19
|
if (!root) {
|
|
31
20
|
console.error(usage);
|
|
32
21
|
process.exit(1);
|
|
33
22
|
}
|
|
34
23
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const getSourceCode = makeGetSourceCode();
|
|
40
|
-
|
|
41
|
-
// Preload files to get a sense of what is slow
|
|
42
|
-
const fs = NodeFileSystem;
|
|
43
|
-
const rootUri = URI.file(root).toString(true);
|
|
44
|
-
const filesToPreload = await recursiveReadDirectory(fs, rootUri, ([uri]) =>
|
|
45
|
-
['.json', '.liquid'].some((ext) => uri.endsWith(ext)),
|
|
46
|
-
);
|
|
47
|
-
await bench('Preloading files', async () => {
|
|
48
|
-
await Promise.all(
|
|
49
|
-
filesToPreload.map(async (uri) => {
|
|
50
|
-
await getSourceCode(uri);
|
|
51
|
-
}),
|
|
52
|
-
);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
/** @type {import('@platformos/theme-graph').WebComponentMap} */
|
|
56
|
-
const webComponentDefs = new Map();
|
|
57
|
-
|
|
58
|
-
/** @type {import('@platformos/theme-graph').Dependencies} */
|
|
59
|
-
const dependencies = {
|
|
60
|
-
fs,
|
|
61
|
-
// @ts-ignore
|
|
62
|
-
getSectionSchema: memoize(async (name) => {
|
|
63
|
-
const uri = pathUtils.join(rootUri, 'sections', `${name}.liquid`);
|
|
64
|
-
const sourceCode = await getSourceCode(uri);
|
|
65
|
-
return toSchema('theme', uri, /** @type {any} */ (sourceCode), async () => true);
|
|
66
|
-
}, identity),
|
|
67
|
-
// @ts-ignore
|
|
68
|
-
getBlockSchema: memoize(async (name) => {
|
|
69
|
-
const uri = pathUtils.join(rootUri, 'blocks', `${name}.liquid`);
|
|
70
|
-
const sourceCode = await getSourceCode(uri);
|
|
71
|
-
return toSchema('theme', uri, /** @type {any} */ (sourceCode), async () => true);
|
|
72
|
-
}, identity),
|
|
73
|
-
getSourceCode,
|
|
74
|
-
getWebComponentDefinitionReference: (customElementName) =>
|
|
75
|
-
webComponentDefs.get(customElementName),
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
// Build graph
|
|
79
|
-
const graph = await bench('Build graph', () => buildThemeGraph(rootUri, dependencies));
|
|
80
|
-
|
|
81
|
-
// Serialize into JSON
|
|
82
|
-
const serializedGraph = serializeThemeGraph(graph);
|
|
83
|
-
|
|
84
|
-
// Print result to STDOUT
|
|
85
|
-
console.log(JSON.stringify(serializedGraph));
|
|
86
|
-
}
|
|
24
|
+
const result = file
|
|
25
|
+
? await bench('Build graph', () => buildSerializedFileDependencies(root, file))
|
|
26
|
+
: await bench('Build graph', () => buildSerializedGraph(root));
|
|
87
27
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const source = await NodeFileSystem.readFile(uri);
|
|
91
|
-
return await toSourceCode(URI.file(uri).toString(), source);
|
|
92
|
-
}, identity);
|
|
28
|
+
// Print result to STDOUT (diagnostics go to STDERR), so it can be piped.
|
|
29
|
+
console.log(JSON.stringify(result));
|
|
93
30
|
}
|
|
94
31
|
|
|
95
32
|
/**
|
|
96
33
|
* @param {string} name
|
|
97
|
-
* @param {(
|
|
34
|
+
* @param {() => Promise<any>} fn
|
|
98
35
|
*/
|
|
99
36
|
async function bench(name, fn) {
|
|
100
37
|
const start = performance.now();
|
|
101
38
|
const result = await fn();
|
|
102
39
|
const end = performance.now();
|
|
103
|
-
console.error(`${name} took ${end - start}ms`);
|
|
40
|
+
console.error(`${name} took ${(end - start).toFixed(1)}ms`);
|
|
104
41
|
return result;
|
|
105
42
|
}
|
|
106
43
|
|
|
107
|
-
main(process.argv[2])
|
|
44
|
+
main(process.argv[2], process.argv[3]).catch((error) => {
|
|
45
|
+
console.error(error);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
});
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { AbstractFileSystem } from '@platformos/platformos-common';
|
|
2
|
+
import { Reference, SerializableGraph } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* A self-contained {@link AbstractFileSystem} backed by `node:fs`.
|
|
5
|
+
*
|
|
6
|
+
* The graph driver speaks file URIs, so every method converts the incoming URI
|
|
7
|
+
* to a native path with `path.fsPath` and re-emits child URIs with `path.join`
|
|
8
|
+
* (which preserves the `file://` scheme). This mirrors `NodeFileSystem` from
|
|
9
|
+
* `@platformos/platformos-check-node` exactly, but is inlined here so the CLI
|
|
10
|
+
* runs with only this package's own dependencies — `platformos-check-node` is a
|
|
11
|
+
* dev-only dependency and must not be required at runtime.
|
|
12
|
+
*/
|
|
13
|
+
export declare const nodeFileSystem: AbstractFileSystem;
|
|
14
|
+
/**
|
|
15
|
+
* The dependency and reference edges of a single module, as produced for the
|
|
16
|
+
* CLI's single-file mode.
|
|
17
|
+
*/
|
|
18
|
+
export interface SerializableFileDependencies {
|
|
19
|
+
/** The resolved file URI, as keyed in the graph. */
|
|
20
|
+
uri: string;
|
|
21
|
+
/** Outgoing edges — the modules this file renders/includes/runs/queries. */
|
|
22
|
+
dependencies: Reference[];
|
|
23
|
+
/** Incoming edges — the modules that render/include/run/query this file. */
|
|
24
|
+
references: Reference[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Builds the platformOS app graph for the project rooted at `root` (a native
|
|
28
|
+
* filesystem path, absolute or relative to `process.cwd()`) and returns it in
|
|
29
|
+
* serializable JSON form.
|
|
30
|
+
*
|
|
31
|
+
* `fs` is injectable for testing; it defaults to the node-backed filesystem.
|
|
32
|
+
*/
|
|
33
|
+
export declare function buildSerializedGraph(root: string, fs?: AbstractFileSystem): Promise<SerializableGraph>;
|
|
34
|
+
/**
|
|
35
|
+
* Builds the full app graph for `root` and returns the dependency and reference
|
|
36
|
+
* edges of the single module at `file`.
|
|
37
|
+
*
|
|
38
|
+
* The graph is built from its real entry points (every layout and page), not
|
|
39
|
+
* seeded from `file`, so that incoming `references` are complete — the same
|
|
40
|
+
* approach the language server's `AppGraphManager` takes. A file that is not
|
|
41
|
+
* reachable from any entry point therefore has no node in the graph; rather
|
|
42
|
+
* than reporting a misleading empty edge set, this throws.
|
|
43
|
+
*
|
|
44
|
+
* `fs` is injectable for testing; it defaults to the node-backed filesystem.
|
|
45
|
+
*/
|
|
46
|
+
export declare function buildSerializedFileDependencies(root: string, file: string, fs?: AbstractFileSystem): Promise<SerializableFileDependencies>;
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.nodeFileSystem = void 0;
|
|
7
|
+
exports.buildSerializedGraph = buildSerializedGraph;
|
|
8
|
+
exports.buildSerializedFileDependencies = buildSerializedFileDependencies;
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
11
|
+
const platformos_check_common_1 = require("@platformos/platformos-check-common");
|
|
12
|
+
const platformos_common_1 = require("@platformos/platformos-common");
|
|
13
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
14
|
+
const build_1 = require("./graph/build");
|
|
15
|
+
const serialize_1 = require("./graph/serialize");
|
|
16
|
+
/**
|
|
17
|
+
* A self-contained {@link AbstractFileSystem} backed by `node:fs`.
|
|
18
|
+
*
|
|
19
|
+
* The graph driver speaks file URIs, so every method converts the incoming URI
|
|
20
|
+
* to a native path with `path.fsPath` and re-emits child URIs with `path.join`
|
|
21
|
+
* (which preserves the `file://` scheme). This mirrors `NodeFileSystem` from
|
|
22
|
+
* `@platformos/platformos-check-node` exactly, but is inlined here so the CLI
|
|
23
|
+
* runs with only this package's own dependencies — `platformos-check-node` is a
|
|
24
|
+
* dev-only dependency and must not be required at runtime.
|
|
25
|
+
*/
|
|
26
|
+
exports.nodeFileSystem = {
|
|
27
|
+
async readFile(uri) {
|
|
28
|
+
return promises_1.default.readFile(platformos_check_common_1.path.fsPath(uri), 'utf8');
|
|
29
|
+
},
|
|
30
|
+
async readDirectory(uri) {
|
|
31
|
+
const entries = await promises_1.default.readdir(platformos_check_common_1.path.fsPath(uri), { withFileTypes: true });
|
|
32
|
+
return entries.map((entry) => [
|
|
33
|
+
platformos_check_common_1.path.join(uri, entry.name),
|
|
34
|
+
entry.isDirectory() ? platformos_common_1.FileType.Directory : platformos_common_1.FileType.File,
|
|
35
|
+
]);
|
|
36
|
+
},
|
|
37
|
+
async stat(uri) {
|
|
38
|
+
try {
|
|
39
|
+
const stats = await promises_1.default.stat(platformos_check_common_1.path.fsPath(uri));
|
|
40
|
+
return {
|
|
41
|
+
type: stats.isDirectory() ? platformos_common_1.FileType.Directory : platformos_common_1.FileType.File,
|
|
42
|
+
size: stats.size,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
throw new Error(`Failed to get file stat: ${e}`);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Resolves the given root path (absolute, or relative to `process.cwd()`) to the
|
|
52
|
+
* forward-slash-normalized `file://` URI of the enclosing platformOS project,
|
|
53
|
+
* using the same `findRoot` heuristic as the language server (an `app/`,
|
|
54
|
+
* `modules/`, `.pos`, or `.platformos-check.yml` marker at or above the path).
|
|
55
|
+
*
|
|
56
|
+
* Throws when no project is found, so a typo'd or non-platformOS directory fails
|
|
57
|
+
* loudly instead of silently producing an empty graph. Resolving via `findRoot`
|
|
58
|
+
* also lets the CLI be pointed anywhere inside a project, not just at its root.
|
|
59
|
+
*
|
|
60
|
+
* Normalization is load-bearing: the graph keys every module via `path.join` /
|
|
61
|
+
* `path.normalize` (forward slashes), so any lookup must key the same way or it
|
|
62
|
+
* silently misses on Windows, where raw URIs keep backslashes.
|
|
63
|
+
*/
|
|
64
|
+
async function resolveProjectRoot(root, fs) {
|
|
65
|
+
const absolute = node_path_1.default.isAbsolute(root) ? root : node_path_1.default.resolve(process.cwd(), root);
|
|
66
|
+
const startUri = platformos_check_common_1.path.normalize(vscode_uri_1.URI.file(absolute));
|
|
67
|
+
const rootUri = await (0, platformos_check_common_1.findRoot)(startUri, (0, platformos_check_common_1.makeFileExists)(fs));
|
|
68
|
+
if (!rootUri) {
|
|
69
|
+
throw new Error(`Not a platformOS project: ${startUri}\n` +
|
|
70
|
+
`No app/, modules/, .pos, or .platformos-check.yml found at or above this path. ` +
|
|
71
|
+
`Pass the path to a platformOS app directory.`);
|
|
72
|
+
}
|
|
73
|
+
return rootUri;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Resolves the single-file argument to a graph module key. An absolute path is
|
|
77
|
+
* taken as-is; a relative path is resolved against the project **root** (not
|
|
78
|
+
* `process.cwd()`), matching the natural "a file within this project" mental
|
|
79
|
+
* model — only files under the root can appear in the graph anyway.
|
|
80
|
+
*/
|
|
81
|
+
function resolveFileUri(rootUri, file) {
|
|
82
|
+
if (node_path_1.default.isAbsolute(file)) {
|
|
83
|
+
return platformos_check_common_1.path.normalize(vscode_uri_1.URI.file(file));
|
|
84
|
+
}
|
|
85
|
+
return platformos_check_common_1.path.join(rootUri, ...file.split(/[\\/]+/).filter(Boolean));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Builds the platformOS app graph for the project rooted at `root` (a native
|
|
89
|
+
* filesystem path, absolute or relative to `process.cwd()`) and returns it in
|
|
90
|
+
* serializable JSON form.
|
|
91
|
+
*
|
|
92
|
+
* `fs` is injectable for testing; it defaults to the node-backed filesystem.
|
|
93
|
+
*/
|
|
94
|
+
async function buildSerializedGraph(root, fs = exports.nodeFileSystem) {
|
|
95
|
+
const graph = await (0, build_1.buildAppGraph)(await resolveProjectRoot(root, fs), { fs });
|
|
96
|
+
return (0, serialize_1.serializeAppGraph)(graph);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Builds the full app graph for `root` and returns the dependency and reference
|
|
100
|
+
* edges of the single module at `file`.
|
|
101
|
+
*
|
|
102
|
+
* The graph is built from its real entry points (every layout and page), not
|
|
103
|
+
* seeded from `file`, so that incoming `references` are complete — the same
|
|
104
|
+
* approach the language server's `AppGraphManager` takes. A file that is not
|
|
105
|
+
* reachable from any entry point therefore has no node in the graph; rather
|
|
106
|
+
* than reporting a misleading empty edge set, this throws.
|
|
107
|
+
*
|
|
108
|
+
* `fs` is injectable for testing; it defaults to the node-backed filesystem.
|
|
109
|
+
*/
|
|
110
|
+
async function buildSerializedFileDependencies(root, file, fs = exports.nodeFileSystem) {
|
|
111
|
+
const rootUri = await resolveProjectRoot(root, fs);
|
|
112
|
+
const fileUri = resolveFileUri(rootUri, file);
|
|
113
|
+
const graph = await (0, build_1.buildAppGraph)(rootUri, { fs });
|
|
114
|
+
const module = graph.modules[fileUri];
|
|
115
|
+
if (!module) {
|
|
116
|
+
throw new Error(`File is not part of the app graph: ${fileUri}\n` +
|
|
117
|
+
`It must exist and be reachable from a layout or page entry point. ` +
|
|
118
|
+
`Check the path is correct and inside the project root (${rootUri}).`);
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
uri: module.uri,
|
|
122
|
+
dependencies: module.dependencies,
|
|
123
|
+
references: module.references,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AA2GA,oDAMC;AAcD,0EAuBC;AAtJD,0DAAiC;AACjC,gEAAkC;AAClC,iFAAqF;AACrF,qEAAkG;AAClG,2CAAiC;AACjC,yCAA8C;AAC9C,iDAAsD;AAGtD;;;;;;;;;GASG;AACU,QAAA,cAAc,GAAuB;IAChD,KAAK,CAAC,QAAQ,CAAC,GAAW;QACxB,OAAO,kBAAE,CAAC,QAAQ,CAAC,8BAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,GAAW;QAC7B,MAAM,OAAO,GAAG,MAAM,kBAAE,CAAC,OAAO,CAAC,8BAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5E,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;YAC5B,8BAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC;YAC1B,KAAK,CAAC,WAAW,EAAE,CAAC,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AM,CAAC,YAAY;QACjC,UAAU,EAAE,MAAM,CAAC,UAAU;KAC9B,CAAC;AACJ,CAAC"}
|
package/dist/graph/augment.js
CHANGED
|
@@ -13,7 +13,6 @@ function augmentDependencies(rootUri, ideps) {
|
|
|
13
13
|
const contents = await ideps.fs.readFile(uri);
|
|
14
14
|
return (0, toSourceCode_1.toSourceCode)(uri, contents);
|
|
15
15
|
}, utils_1.identity),
|
|
16
|
-
getWebComponentDefinitionReference: ideps.getWebComponentDefinitionReference,
|
|
17
16
|
};
|
|
18
17
|
}
|
|
19
18
|
//# sourceMappingURL=augment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"augment.js","sourceRoot":"","sources":["../../src/graph/augment.ts"],"names":[],"mappings":";;AAKA,
|
|
1
|
+
{"version":3,"file":"augment.js","sourceRoot":"","sources":["../../src/graph/augment.ts"],"names":[],"mappings":";;AAKA,kDAcC;AAnBD,iFAAoE;AACpE,kDAA+C;AAE/C,oCAAoC;AAEpC,SAAgB,mBAAmB,CAAC,OAAe,EAAE,KAAoB;IACvE,OAAO;QACL,EAAE,EAAE,KAAK,CAAC,EAAE;QAEZ,qBAAqB;QACrB,aAAa,EAAE,IAAA,iCAAO,EACpB,KAAK,CAAC,aAAa;YACjB,KAAK,UAAU,oBAAoB,CAAC,GAAG;gBACrC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBAC9C,OAAO,IAAA,2BAAY,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YACrC,CAAC,EACH,gBAAQ,CACT;KACF,CAAC;AACJ,CAAC"}
|
package/dist/graph/module.d.ts
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
import { UriString } from '@platformos/platformos-check-common';
|
|
2
|
-
import { AssetModule, AppGraph, AppModule, LiquidModule } from '../types';
|
|
2
|
+
import { AssetModule, AppGraph, AppModule, GraphQLModule, LiquidModule } from '../types';
|
|
3
3
|
export declare function getModule(appGraph: AppGraph, uri: UriString): AppModule | undefined;
|
|
4
4
|
export declare function getAssetModule(appGraph: AppGraph, asset: string): AssetModule | undefined;
|
|
5
5
|
export declare function getPartialModule(appGraph: AppGraph, partial: string): LiquidModule;
|
|
6
|
+
/**
|
|
7
|
+
* Create (or fetch the cached) Liquid Partial module for an ALREADY-RESOLVED
|
|
8
|
+
* full URI — used for `{% function %}` / `{% include %}` targets whose URI is
|
|
9
|
+
* resolved canonically by `DocumentsLocator` (which handles lib paths, module
|
|
10
|
+
* prefixes, and extensions). Unlike {@link getPartialModule}, it does not
|
|
11
|
+
* reconstruct the path from a name. Commands/queries/lib helpers are all
|
|
12
|
+
* `Partial` kind, consistent with check-common's file-type classification.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getPartialModuleByUri(appGraph: AppGraph, uri: string): LiquidModule;
|
|
15
|
+
/**
|
|
16
|
+
* Create (or fetch the cached) GraphQL module for an already-resolved
|
|
17
|
+
* `.graphql` URI — used for `{% graphql op = 'name' %}` targets resolved by
|
|
18
|
+
* `DocumentsLocator`. A leaf node (no outgoing edges).
|
|
19
|
+
*/
|
|
20
|
+
export declare function getGraphQLModuleByUri(appGraph: AppGraph, uri: string): GraphQLModule;
|
|
6
21
|
export declare function getLayoutModule(appGraph: AppGraph, layoutUri: string | false | undefined): LiquidModule | undefined;
|
|
7
22
|
export declare function getPageModule(appGraph: AppGraph, pageUri: string): LiquidModule;
|
package/dist/graph/module.js
CHANGED
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getModule = getModule;
|
|
4
4
|
exports.getAssetModule = getAssetModule;
|
|
5
5
|
exports.getPartialModule = getPartialModule;
|
|
6
|
+
exports.getPartialModuleByUri = getPartialModuleByUri;
|
|
7
|
+
exports.getGraphQLModuleByUri = getGraphQLModuleByUri;
|
|
6
8
|
exports.getLayoutModule = getLayoutModule;
|
|
7
9
|
exports.getPageModule = getPageModule;
|
|
8
10
|
const platformos_check_common_1 = require("@platformos/platformos-check-common");
|
|
@@ -74,6 +76,43 @@ function getPartialModule(appGraph, partial) {
|
|
|
74
76
|
references: [],
|
|
75
77
|
});
|
|
76
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Create (or fetch the cached) Liquid Partial module for an ALREADY-RESOLVED
|
|
81
|
+
* full URI — used for `{% function %}` / `{% include %}` targets whose URI is
|
|
82
|
+
* resolved canonically by `DocumentsLocator` (which handles lib paths, module
|
|
83
|
+
* prefixes, and extensions). Unlike {@link getPartialModule}, it does not
|
|
84
|
+
* reconstruct the path from a name. Commands/queries/lib helpers are all
|
|
85
|
+
* `Partial` kind, consistent with check-common's file-type classification.
|
|
86
|
+
*/
|
|
87
|
+
function getPartialModuleByUri(appGraph, uri) {
|
|
88
|
+
return module(appGraph, {
|
|
89
|
+
type: "Liquid" /* ModuleType.Liquid */,
|
|
90
|
+
kind: "partial" /* LiquidModuleKind.Partial */,
|
|
91
|
+
// Normalize to forward slashes so module keys match the rest of the graph
|
|
92
|
+
// (getPartialModule/getAssetModule build URIs via path.join, which
|
|
93
|
+
// normalizes). DocumentsLocator returns `Utils.joinPath(...).toString()`
|
|
94
|
+
// unnormalized, which on Windows keeps backslashes and breaks key/edge
|
|
95
|
+
// matching against the normalized URIs everywhere else.
|
|
96
|
+
uri: platformos_check_common_1.path.normalize(uri),
|
|
97
|
+
dependencies: [],
|
|
98
|
+
references: [],
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Create (or fetch the cached) GraphQL module for an already-resolved
|
|
103
|
+
* `.graphql` URI — used for `{% graphql op = 'name' %}` targets resolved by
|
|
104
|
+
* `DocumentsLocator`. A leaf node (no outgoing edges).
|
|
105
|
+
*/
|
|
106
|
+
function getGraphQLModuleByUri(appGraph, uri) {
|
|
107
|
+
return module(appGraph, {
|
|
108
|
+
type: "GraphQL" /* ModuleType.GraphQL */,
|
|
109
|
+
kind: 'graphql',
|
|
110
|
+
// Normalize to forward slashes — see getPartialModuleByUri.
|
|
111
|
+
uri: platformos_check_common_1.path.normalize(uri),
|
|
112
|
+
dependencies: [],
|
|
113
|
+
references: [],
|
|
114
|
+
});
|
|
115
|
+
}
|
|
77
116
|
function getLayoutModule(appGraph, layoutUri) {
|
|
78
117
|
if (!layoutUri)
|
|
79
118
|
return undefined;
|
package/dist/graph/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/graph/module.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/graph/module.ts"],"names":[],"mappings":";;AA6BA,8BAqBC;AAED,wCA0BC;AAED,4CASC;AAUD,sDAaC;AAOD,sDASC;AAED,0CAYC;AAED,sCAQC;AAxJD,iFAAmG;AACnG,oCASkB;AAClB,oCAAmC;AAEnC;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,GAA8C,IAAI,OAAO,EAAE,CAAC;AAE7E,SAAgB,SAAS,CAAC,QAAkB,EAAE,GAAc;IAC1D,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QACnB,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC;IACzB,CAAC;IAED,MAAM,YAAY,GAAG,8BAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAE1D,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,IAAA,kCAAQ,EAAC,GAAG,CAAC;YAChB,OAAO,eAAe,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAExC,KAAK,IAAA,gCAAM,EAAC,GAAG,CAAC;YACd,OAAO,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAEtC,KAAK,IAAA,mCAAS,EAAC,GAAG,CAAC;YACjB,OAA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C,EAAE,CAAC;QAC/B,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC;AACpC,CAAC;AAED,SAAS,MAAM,CAAsB,QAAkB,EAAE,GAAM;IAC7D,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAO,CAAC;AAClC,CAAC"}
|
|
@@ -7,7 +7,7 @@ export declare function makeGetSourceCode(fs: AbstractFileSystem): {
|
|
|
7
7
|
};
|
|
8
8
|
export declare const fixturesRoot: string;
|
|
9
9
|
export declare const skeleton: string;
|
|
10
|
-
export declare function getDependencies(
|
|
10
|
+
export declare function getDependencies(fs?: AbstractFileSystem): {
|
|
11
11
|
fs: AbstractFileSystem;
|
|
12
12
|
getSourceCode: {
|
|
13
13
|
(x: string): Promise<import("..").FileSourceCode>;
|
|
@@ -15,8 +15,7 @@ export declare function getDependencies(rootUri: string, fs?: AbstractFileSystem
|
|
|
15
15
|
invalidate(x: string): void;
|
|
16
16
|
clearCache(): void;
|
|
17
17
|
};
|
|
18
|
-
|
|
19
|
-
}>;
|
|
18
|
+
};
|
|
20
19
|
export declare function mockImpl(obj: any, method: any, callback: any): import("vitest").MockInstance<any> & (new (...args: unknown[]) => any) & {
|
|
21
20
|
[x: string]: any;
|
|
22
21
|
};
|
|
@@ -8,7 +8,6 @@ const platformos_check_common_1 = require("@platformos/platformos-check-common")
|
|
|
8
8
|
const platformos_check_node_1 = require("@platformos/platformos-check-node");
|
|
9
9
|
const vitest_1 = require("vitest");
|
|
10
10
|
const vscode_uri_1 = require("vscode-uri");
|
|
11
|
-
const getWebComponentMap_1 = require("../getWebComponentMap");
|
|
12
11
|
const toSourceCode_1 = require("../toSourceCode");
|
|
13
12
|
const utils_1 = require("../utils");
|
|
14
13
|
function makeGetSourceCode(fs) {
|
|
@@ -19,15 +18,12 @@ function makeGetSourceCode(fs) {
|
|
|
19
18
|
}
|
|
20
19
|
exports.fixturesRoot = platformos_check_common_1.path.join(vscode_uri_1.URI.file(__dirname), ...'../../fixtures'.split('/'));
|
|
21
20
|
exports.skeleton = platformos_check_common_1.path.join(exports.fixturesRoot, 'skeleton');
|
|
22
|
-
|
|
21
|
+
function getDependencies(fs = platformos_check_node_1.NodeFileSystem) {
|
|
23
22
|
const getSourceCode = makeGetSourceCode(fs);
|
|
24
|
-
|
|
23
|
+
return {
|
|
25
24
|
fs,
|
|
26
25
|
getSourceCode,
|
|
27
|
-
getWebComponentDefinitionReference: (customElementName) => webComponentDefs.get(customElementName),
|
|
28
26
|
};
|
|
29
|
-
const webComponentDefs = await (0, getWebComponentMap_1.getWebComponentMap)(rootUri, deps);
|
|
30
|
-
return deps;
|
|
31
27
|
}
|
|
32
28
|
// This thing is way too hard to type.
|
|
33
29
|
function mockImpl(obj, method, callback) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-helpers.js","sourceRoot":"","sources":["../../src/graph/test-helpers.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"test-helpers.js","sourceRoot":"","sources":["../../src/graph/test-helpers.ts"],"names":[],"mappings":";;;AAQA,8CAKC;AAKD,0CAMC;AAGD,4BAKC;AAhCD,iFAAiF;AAEjF,6EAAmE;AACnE,mCAA4B;AAC5B,2CAAiC;AACjC,kDAA+C;AAC/C,oCAAoC;AAEpC,SAAgB,iBAAiB,CAAC,EAAsB;IACtD,OAAO,IAAA,iCAAO,EAAC,KAAK,UAAU,aAAa,CAAC,GAAW;QACrD,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACtC,OAAO,IAAA,2BAAY,EAAC,gBAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC,EAAE,gBAAQ,CAAC,CAAC;AACf,CAAC;AAEY,QAAA,YAAY,GAAG,8BAAS,CAAC,IAAI,CAAC,gBAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACnF,QAAA,QAAQ,GAAG,8BAAS,CAAC,IAAI,CAAC,oBAAY,EAAE,UAAU,CAAC,CAAC;AAEjE,SAAgB,eAAe,CAAC,KAAyB,sCAAc;IACrE,MAAM,aAAa,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAC;IAC5C,OAAO;QACL,EAAE;QACF,aAAa;KACd,CAAC;AACJ,CAAC;AAED,sCAAsC;AACtC,SAAgB,QAAQ,CAAC,GAAQ,EAAE,MAAW,EAAE,QAAa;IAC3D,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO,WAAE,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,kBAAkB,CAAC;QAC9C,OAAO,QAAQ,CAAC,QAAQ,EAAE,GAAG,SAAS,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/graph/traverse.d.ts
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UriString } from '@platformos/platformos-check-common';
|
|
2
|
+
import { AugmentedDependencies, AppGraph, AppModule, FileSourceCode, Range, Reference, ReferenceKind, Void } from '../types';
|
|
3
|
+
/** The dependency surface the reference resolver needs: just a filesystem (for DocumentsLocator). */
|
|
4
|
+
type ResolverDependencies = Pick<AugmentedDependencies, 'fs'>;
|
|
2
5
|
export declare function traverseModule(module: AppModule, appGraph: AppGraph, deps: AugmentedDependencies): Promise<Void>;
|
|
6
|
+
/**
|
|
7
|
+
* Extract one Liquid file's outgoing dependency references, resolved against the
|
|
8
|
+
* project at `rootUri`, WITHOUT building the whole app graph.
|
|
9
|
+
*
|
|
10
|
+
* This is the per-file primitive for consumers that hold a single (possibly
|
|
11
|
+
* in-flight, not-yet-on-disk) buffer — e.g. a `validate_code`-style tool that
|
|
12
|
+
* parses the buffer with {@link toSourceCode} and wants the file's resolved
|
|
13
|
+
* `render`/`include`/`function`/`background`/`graphql`/asset edges with their
|
|
14
|
+
* canonical target URIs and {@link ReferenceKind}. Resolution uses the same
|
|
15
|
+
* `DocumentsLocator`-backed logic as the full graph build, so a target's URI is
|
|
16
|
+
* identical to the key it would have as a graph node.
|
|
17
|
+
*
|
|
18
|
+
* Notes for consumers:
|
|
19
|
+
* - Targets are returned whether or not they exist on disk (resolution is
|
|
20
|
+
* path-based). To distinguish missing targets, `stat` `target.uri` via the
|
|
21
|
+
* same `fs`; unresolved/missing partials are also surfaced by the linter's
|
|
22
|
+
* `MissingPartial` check, so prefer that for diagnostics.
|
|
23
|
+
* - Only statically resolvable references are returned; dynamic targets
|
|
24
|
+
* (`{% render some_var %}`) and inline forms are skipped.
|
|
25
|
+
* - `sourceCode` is parsed by the caller (from the buffer, not disk); only `fs`
|
|
26
|
+
* is touched here, for target resolution.
|
|
27
|
+
*/
|
|
28
|
+
export declare function extractFileReferences(rootUri: UriString, sourceUri: UriString, sourceCode: FileSourceCode, deps: ResolverDependencies): Promise<Reference[]>;
|
|
3
29
|
/**
|
|
4
30
|
* The bind method is the method that links two modules together.
|
|
5
31
|
*
|
|
@@ -7,8 +33,10 @@ export declare function traverseModule(module: AppModule, appGraph: AppGraph, de
|
|
|
7
33
|
*
|
|
8
34
|
* This function mutates the source and target modules.
|
|
9
35
|
*/
|
|
10
|
-
export declare function bind(source: AppModule, target: AppModule, { sourceRange,
|
|
36
|
+
export declare function bind(source: AppModule, target: AppModule, { sourceRange, type, // the type of dependency, can be 'direct' or 'indirect'
|
|
37
|
+
kind, }?: {
|
|
11
38
|
sourceRange?: Range;
|
|
12
|
-
targetRange?: Range;
|
|
13
39
|
type?: Reference['type'];
|
|
40
|
+
kind?: ReferenceKind;
|
|
14
41
|
}): void;
|
|
42
|
+
export {};
|