vovk-cli 0.0.1-beta.85 → 0.0.1-beta.86
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.
|
@@ -7,9 +7,7 @@ export const BUNDLE_BUILD_TSDOWN = async ({ entry, outDir }) => {
|
|
|
7
7
|
const { build } = await import('tsdown');
|
|
8
8
|
await build({
|
|
9
9
|
entry,
|
|
10
|
-
dts:
|
|
11
|
-
resolve: [/^(?!next($|\/))/],
|
|
12
|
-
},
|
|
10
|
+
dts: true,
|
|
13
11
|
format: 'esm',
|
|
14
12
|
hash: false,
|
|
15
13
|
fixedExtension: true,
|
|
@@ -25,7 +23,7 @@ export const BUNDLE_BUILD_TSDOWN = async ({ entry, outDir }) => {
|
|
|
25
23
|
mainFields: ['module', 'main'],
|
|
26
24
|
},
|
|
27
25
|
},
|
|
28
|
-
noExternal: ['
|
|
26
|
+
noExternal: ['!next/**'],
|
|
29
27
|
});
|
|
30
28
|
};
|
|
31
29
|
export async function createConfig({ root, options: { validationLibrary, bundle, lang, dryRun }, }) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Project, QuoteKind, IndentationText, NewLineKind, SyntaxKind, Node } from 'ts-morph';
|
|
1
|
+
import { Project, QuoteKind, IndentationText, NewLineKind, SyntaxKind, Node, } from 'ts-morph';
|
|
2
2
|
export function updateConfigProperty(sourceCode, pathToProperty, newValue) {
|
|
3
3
|
const project = createProject();
|
|
4
4
|
const sourceFile = project.createSourceFile('config-temp.mts', sourceCode, { overwrite: true });
|
|
@@ -20,6 +20,20 @@ function createProject() {
|
|
|
20
20
|
},
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
+
function findPropertyAssignment(objectNode, key) {
|
|
24
|
+
const properties = objectNode.getProperties();
|
|
25
|
+
for (const prop of properties) {
|
|
26
|
+
if (Node.isPropertyAssignment(prop)) {
|
|
27
|
+
const name = prop.getName();
|
|
28
|
+
// Handle both quoted and unquoted property names
|
|
29
|
+
const unquotedName = name.replace(/^['"]|['"]$/g, '');
|
|
30
|
+
if (unquotedName === key || name === key) {
|
|
31
|
+
return prop;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
23
37
|
function mutateConfig(sourceFile, pathToProperty, newValue) {
|
|
24
38
|
const variableDeclaration = sourceFile.getVariableDeclaration('config');
|
|
25
39
|
if (!variableDeclaration) {
|
|
@@ -32,63 +46,50 @@ function mutateConfig(sourceFile, pathToProperty, newValue) {
|
|
|
32
46
|
let currentNode = initializer;
|
|
33
47
|
for (let i = 0; i < pathToProperty.length; i++) {
|
|
34
48
|
const key = pathToProperty[i];
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
const property = currentNode.getProperty(key);
|
|
49
|
+
const isLastKey = i === pathToProperty.length - 1;
|
|
50
|
+
const property = findPropertyAssignment(currentNode, key);
|
|
39
51
|
if (!property) {
|
|
40
52
|
// Property does not exist
|
|
41
53
|
if (newValue === undefined) {
|
|
42
54
|
// Nothing to remove
|
|
43
55
|
return sourceFile.getFullText();
|
|
44
56
|
}
|
|
57
|
+
if (isLastKey) {
|
|
58
|
+
// Last key - add the final value
|
|
59
|
+
currentNode.addPropertyAssignment({
|
|
60
|
+
name: key,
|
|
61
|
+
initializer: (writer) => writeInitializer(writer, newValue),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
45
64
|
else {
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
// Need to create nested object
|
|
56
|
-
const newObjectAssignment = currentNode.addPropertyAssignment({
|
|
57
|
-
name: key,
|
|
58
|
-
initializer: '{}',
|
|
59
|
-
});
|
|
60
|
-
const init = newObjectAssignment.getInitializerIfKindOrThrow(SyntaxKind.ObjectLiteralExpression);
|
|
61
|
-
currentNode = init;
|
|
62
|
-
}
|
|
65
|
+
// Need to create nested object
|
|
66
|
+
const newObjectAssignment = currentNode.addPropertyAssignment({
|
|
67
|
+
name: key,
|
|
68
|
+
initializer: '{}',
|
|
69
|
+
});
|
|
70
|
+
currentNode = newObjectAssignment.getInitializerIfKindOrThrow(SyntaxKind.ObjectLiteralExpression);
|
|
63
71
|
}
|
|
64
72
|
}
|
|
65
73
|
else {
|
|
66
74
|
// Property exists
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// Remove the property
|
|
73
|
-
property.remove();
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
// Update the value
|
|
77
|
-
property.setInitializer((writer) => writeInitializer(writer, newValue));
|
|
78
|
-
}
|
|
75
|
+
const propInitializer = property.getInitializer();
|
|
76
|
+
if (isLastKey) {
|
|
77
|
+
// Last key - update or remove the value
|
|
78
|
+
if (newValue === undefined) {
|
|
79
|
+
property.remove();
|
|
79
80
|
}
|
|
80
81
|
else {
|
|
81
|
-
|
|
82
|
-
if (propInitializer && Node.isObjectLiteralExpression(propInitializer)) {
|
|
83
|
-
currentNode = propInitializer;
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
throw new Error(`Cannot traverse into non-object property at ${pathToProperty.slice(0, i + 1).join('.')}.`);
|
|
87
|
-
}
|
|
82
|
+
property.setInitializer((writer) => writeInitializer(writer, newValue));
|
|
88
83
|
}
|
|
89
84
|
}
|
|
90
85
|
else {
|
|
91
|
-
|
|
86
|
+
// Need to go deeper into existing object
|
|
87
|
+
if (propInitializer && Node.isObjectLiteralExpression(propInitializer)) {
|
|
88
|
+
currentNode = propInitializer;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
throw new Error(`Cannot traverse into non-object property at ${pathToProperty.slice(0, i + 1).join('.')}.`);
|
|
92
|
+
}
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vovk-cli",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.86",
|
|
4
4
|
"description": "CLI tool for managing Vovk.ts projects",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"scripts": {
|
|
18
18
|
"build": "rm -rf dist tsconfig.build.tsbuildinfo && tsc -P tsconfig.build.json",
|
|
19
19
|
"postbuild": "chmod +x ./dist/index.mjs",
|
|
20
|
-
"pre-test": "npm run build",
|
|
20
|
+
"pre-test": "npm run build && npm run clear-test-cache",
|
|
21
21
|
"test-only": "npm run pre-test && node --experimental-transform-types --experimental-strip-types --experimental-vm-modules --test --test-only test/spec/**/*.mts",
|
|
22
22
|
"test": "npm run pre-test && node --experimental-transform-types --experimental-strip-types --experimental-vm-modules --test --test-concurrency=1 test/spec/**/*.mts",
|
|
23
23
|
"tsc": "tsc --noEmit",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
},
|
|
43
43
|
"homepage": "https://vovk.dev",
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"vovk": "^3.0.0-beta.
|
|
46
|
-
"vovk-ajv": "^0.0.0-beta.
|
|
47
|
-
"vovk-client": "^0.0.4-beta.
|
|
48
|
-
"vovk-python": "^0.0.1-beta.
|
|
49
|
-
"vovk-rust": "^0.0.1-beta.
|
|
45
|
+
"vovk": "^3.0.0-beta.130",
|
|
46
|
+
"vovk-ajv": "^0.0.0-beta.22",
|
|
47
|
+
"vovk-client": "^0.0.4-beta.23",
|
|
48
|
+
"vovk-python": "^0.0.1-beta.12",
|
|
49
|
+
"vovk-rust": "^0.0.1-beta.14"
|
|
50
50
|
},
|
|
51
51
|
"optionalDependencies": {
|
|
52
52
|
"@rolldown/binding-linux-x64-gnu": "1.0.0-beta.60"
|