@neo4j-cypher/lint-worker 0.0.1 → 1.0.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/CHANGELOG.md +18 -0
- package/package.json +3 -3
- package/src/helpers.ts +41 -6
- package/src/lintWorker.ts +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @neo4j-cypher/lint-worker
|
|
2
2
|
|
|
3
|
+
## 0.1.0-next.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c4f27c9: Adds support for server-versioned lint-workers
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- c1fa91f: Adds support for manual linter switching
|
|
12
|
+
- Updated dependencies [ed65ef3]
|
|
13
|
+
- Updated dependencies [7538cfd]
|
|
14
|
+
- Updated dependencies [c4f27c9]
|
|
15
|
+
- Updated dependencies [039d1c5]
|
|
16
|
+
- Updated dependencies [1ef063e]
|
|
17
|
+
- Updated dependencies [a38255f]
|
|
18
|
+
- @neo4j-cypher/language-support@2.0.0-next.22
|
|
19
|
+
- @neo4j-cypher/query-tools@2.0.0-next.22
|
|
20
|
+
|
|
3
21
|
## 2025.4.1-next.0
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"cypher",
|
|
19
19
|
"lint worker"
|
|
20
20
|
],
|
|
21
|
-
"version": "0.0
|
|
21
|
+
"version": "1.0.0",
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
24
24
|
"url": "git://github.com/neo4j/cypher-language-support.git"
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"vscode-languageserver-types": "^3.17.3",
|
|
38
38
|
"workerpool": "^9.0.4",
|
|
39
39
|
"axios": "^1.9.0",
|
|
40
|
-
"@neo4j-cypher/language-support": "2.0.0-next.
|
|
41
|
-
"@neo4j-cypher/query-tools": "2.0.0-next.
|
|
40
|
+
"@neo4j-cypher/language-support": "2.0.0-next.22",
|
|
41
|
+
"@neo4j-cypher/query-tools": "2.0.0-next.22"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/lodash.debounce": "^4.0.9",
|
package/src/helpers.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
Neo4jFunction,
|
|
5
5
|
Neo4jProcedure,
|
|
6
6
|
} from '@neo4j-cypher/language-support';
|
|
7
|
-
import
|
|
7
|
+
import axios from 'axios';
|
|
8
8
|
import { DbSchema as DbSchemaV1 } from 'languageSupport-next.13';
|
|
9
9
|
|
|
10
10
|
const oldLinter = '5.20.0';
|
|
@@ -13,7 +13,7 @@ const oldLinter = '5.20.0';
|
|
|
13
13
|
// meaning old linters need conversion of the new schema
|
|
14
14
|
export function convertDbSchema(
|
|
15
15
|
originalSchema: DbSchemaV2,
|
|
16
|
-
|
|
16
|
+
linterVersion: string,
|
|
17
17
|
): DbSchemaV2 | DbSchemaV1 {
|
|
18
18
|
let oldFunctions: Record<string, Neo4jFunction> = {};
|
|
19
19
|
let oldProcedures: Record<string, Neo4jProcedure> = {};
|
|
@@ -28,9 +28,6 @@ export function convertDbSchema(
|
|
|
28
28
|
oldProcedures = originalSchema.procedures['CYPHER 5'];
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
const serverVersion = neo4j.connection?.serverVersion;
|
|
32
|
-
const linterVersion = serverVersionToLinter(serverVersion);
|
|
33
|
-
|
|
34
31
|
if (compareMajorMinorVersions(linterVersion, oldLinter) <= 0) {
|
|
35
32
|
const dbSchemaOld: DbSchemaV1 = {
|
|
36
33
|
...originalSchema,
|
|
@@ -44,9 +41,47 @@ export function convertDbSchema(
|
|
|
44
41
|
}
|
|
45
42
|
|
|
46
43
|
export function serverVersionToLinter(serverVersion: string) {
|
|
47
|
-
let candidate: string =
|
|
44
|
+
let candidate: string = 'Latest';
|
|
48
45
|
if (compareMajorMinorVersions(serverVersion, oldLinter) <= 0) {
|
|
49
46
|
candidate = oldLinter;
|
|
50
47
|
}
|
|
51
48
|
return candidate;
|
|
52
49
|
}
|
|
50
|
+
|
|
51
|
+
export function linterFileToServerVersion(fileName: string) {
|
|
52
|
+
const linterFileRegex = /^([\d.]+)-lintWorker-([\d.]+)\.cjs$/;
|
|
53
|
+
return fileName ? fileName.match(linterFileRegex)?.[1] : undefined;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//The data object we get from npm contains more fields than this, but we only need dist-tags here
|
|
57
|
+
export type NpmData = {
|
|
58
|
+
'dist-tags'?: Record<string, string>;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type NpmRelease = {
|
|
62
|
+
tag: string;
|
|
63
|
+
version: string;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const npmTagToLinterVersion = (tag: string) =>
|
|
67
|
+
tag.match(/^neo4j-([\d.]+)$/)?.[1];
|
|
68
|
+
|
|
69
|
+
export async function getTaggedRegistryVersions(): Promise<NpmRelease[]> {
|
|
70
|
+
const registryUrl = 'https://registry.npmjs.org/@neo4j-cypher/lint-worker';
|
|
71
|
+
try {
|
|
72
|
+
const response = await axios.get<NpmData>(registryUrl);
|
|
73
|
+
const data: NpmData = response.data;
|
|
74
|
+
const taggedVersions: { tag: string; version: string }[] = [];
|
|
75
|
+
if (data !== null && data['dist-tags'] !== null) {
|
|
76
|
+
for (const [tag, version] of Object.entries(data['dist-tags'])) {
|
|
77
|
+
if (typeof tag === 'string' && typeof version === 'string') {
|
|
78
|
+
taggedVersions.push({ tag, version });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return taggedVersions;
|
|
84
|
+
} catch (error) {
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
}
|
package/src/lintWorker.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
|
+
SymbolTable,
|
|
3
|
+
SyntaxDiagnostic,
|
|
4
|
+
} from '@neo4j-cypher/language-support';
|
|
2
5
|
import {
|
|
3
6
|
DbSchema,
|
|
4
|
-
SyntaxDiagnostic,
|
|
5
|
-
_internalFeatureFlags,
|
|
6
7
|
lintCypherQuery as _lintCypherQuery,
|
|
8
|
+
_internalFeatureFlags,
|
|
7
9
|
} from 'languageSupport-next.8';
|
|
8
10
|
import workerpool from 'workerpool';
|
|
9
11
|
|
|
@@ -17,8 +19,7 @@ function lintCypherQuery(
|
|
|
17
19
|
_internalFeatureFlags.consoleCommands = featureFlags.consoleCommands;
|
|
18
20
|
}
|
|
19
21
|
//cast to appease git lint check
|
|
20
|
-
|
|
21
|
-
return { diagnostics: diagnostics };
|
|
22
|
+
return { diagnostics: _lintCypherQuery(query, dbSchema as DbSchema) };
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
workerpool.worker({ lintCypherQuery });
|