Skip to content

Commit 1405dac

Browse files
Merge branch 'main' into restructure-e2e-tests
2 parents 625eacb + 5609d4b commit 1405dac

File tree

29 files changed

+269
-180
lines changed

29 files changed

+269
-180
lines changed

common/config/rush/pnpm-lock.yaml

Lines changed: 10 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

workspaces/ballerina/ballerina-extension/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,6 @@
12131213
"node-schedule": "^2.1.1",
12141214
"portfinder": "^1.0.32",
12151215
"source-map-support": "^0.5.21",
1216-
"toml": "^3.0.0",
12171216
"unzipper": "~0.12.3",
12181217
"uuid": "^11.1.0",
12191218
"vscode-debugadapter": "^1.51.0",
@@ -1229,7 +1228,8 @@
12291228
"xml-js": "^1.6.11",
12301229
"xstate": "^4.38.3",
12311230
"zod": "^4.1.8",
1232-
"protobufjs": "^7.2.5"
1231+
"protobufjs": "^7.2.5",
1232+
"@iarna/toml": "^2.2.5"
12331233
},
12341234
"devDependencies": {
12351235
"@sentry/webpack-plugin": "^1.20.1",

workspaces/ballerina/ballerina-extension/src/features/config-generator/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
import { debug } from "../../utils/logger";
20-
import toml from "toml";
20+
import { parse } from "@iarna/toml";
2121
import { CompletionItem, CompletionItemKind, Position, TextDocument, Uri } from "vscode";
2222
import { BallerinaExtension } from "../../core";
2323
import { findPropertyValues, getConfigValue, getCurrentBallerinaProjectFromContext } from "./configGenerator";
@@ -33,7 +33,7 @@ export const typeOfComment = 'Type of';
3333
*/
3434
export function parseTomlToConfig(tomlContent: string): object {
3535
try {
36-
return toml.parse(tomlContent);
36+
return parse(tomlContent);
3737
} catch (error) {
3838
debug("Error while parsing the Config.toml file content: " + error);
3939
}

workspaces/ballerina/ballerina-extension/src/features/tracing/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import * as fs from 'fs';
1919
import * as path from 'path';
20-
import { parse } from 'toml';
20+
import { parse, stringify } from '@iarna/toml';
2121
import { OTLP_PORT } from './constants';
2222

2323
/**
@@ -145,7 +145,7 @@ function updateOrAddSection(content: string, sectionName: string, values: Record
145145
// Build the new section content
146146
let sectionLines: string[] = [sectionHeader];
147147
for (const [key, value] of Object.entries(values)) {
148-
const formattedValue = typeof value === 'string' ? `"${value}"` : String(value);
148+
const formattedValue = stringify.value(value);
149149
sectionLines.push(`${key} = ${formattedValue}`);
150150
}
151151
const sectionContent = sectionLines.join('\n');

workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-manager.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import {
4141
LoginMethod,
4242
MetadataWithAttachments,
4343
OperationType,
44+
PackageTomlValues,
4445
PostProcessRequest,
4546
PostProcessResponse,
4647
ProcessContextTypeCreationRequest,
@@ -64,7 +65,7 @@ import * as crypto from 'crypto';
6465
import * as fs from 'fs';
6566
import * as os from 'os';
6667
import path from "path";
67-
import { parse } from 'toml';
68+
import { parse } from "@iarna/toml";
6869
import { workspace } from 'vscode';
6970

7071
import { isNumber } from "lodash";
@@ -812,8 +813,8 @@ async function getCurrentProjectSource(requestType: OperationType, projectPath?:
812813
const tomlContent = await fs.promises.readFile(ballerinaTomlPath, 'utf-8');
813814
// Simple parsing to extract the package.name field
814815
try {
815-
const tomlObj = parse(tomlContent);
816-
packageName = tomlObj.package.name;
816+
const tomlObj = parse(tomlContent) as Partial<PackageTomlValues>;
817+
packageName = tomlObj?.package?.name;
817818
} catch (error) {
818819
packageName = '';
819820
}

workspaces/ballerina/ballerina-extension/src/rpc-managers/common/rpc-manager.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,9 @@ export class CommonRpcManager implements CommonRPCAPI {
265265
return extension.ballerinaExtInstance.isNPSupported;
266266
}
267267

268-
async getCurrentProjectTomlValues(): Promise<PackageTomlValues> {
269-
return getProjectTomlValues(StateMachine.context().projectPath);
268+
async getCurrentProjectTomlValues(): Promise<Partial<PackageTomlValues>> {
269+
const tomlValues = await getProjectTomlValues(StateMachine.context().projectPath);
270+
return tomlValues ?? {};
270271
}
271272

272273
async getWorkspaceType(): Promise<WorkspaceTypeResponse> {

workspaces/ballerina/ballerina-extension/src/utils/bi.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import { applyModifications, modifyFileContent, writeBallerinaFileDidOpen } from
3838
import { ModulePart, STKindChecker } from "@wso2/syntax-tree";
3939
import { URI } from "vscode-uri";
4040
import { debug } from "./logger";
41-
import { parse } from "toml";
41+
import { parse } from "@iarna/toml";
4242
import { getProjectTomlValues } from "./config";
4343

4444
export const README_FILE = "readme.md";
@@ -363,8 +363,8 @@ function addToWorkspaceToml(workspacePath: string, packageName: string) {
363363

364364
try {
365365
const ballerinaTomlContent = fs.readFileSync(ballerinaTomlPath, 'utf8');
366-
const tomlData: WorkspaceTomlValues = parse(ballerinaTomlContent);
367-
const existingPackages: string[] = tomlData.workspace?.packages || [];
366+
const tomlData = parse(ballerinaTomlContent) as Partial<WorkspaceTomlValues>;
367+
const existingPackages: string[] = tomlData?.workspace?.packages ?? [];
368368

369369
if (existingPackages.includes(packageName)) {
370370
return; // Package already exists
@@ -388,8 +388,8 @@ export function deleteProjectFromWorkspace(workspacePath: string, packagePath: s
388388

389389
try {
390390
const ballerinaTomlContent = fs.readFileSync(ballerinaTomlPath, 'utf8');
391-
const tomlData: WorkspaceTomlValues = parse(ballerinaTomlContent);
392-
const existingPackages: string[] = tomlData.workspace?.packages || [];
391+
const tomlData = parse(ballerinaTomlContent) as Partial<WorkspaceTomlValues>;
392+
const existingPackages: string[] = tomlData?.workspace?.packages ?? [];
393393

394394
if (!existingPackages.includes(relativeProjectPath)) {
395395
return; // Package not found

workspaces/ballerina/ballerina-extension/src/utils/config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { BallerinaExtension } from '../core';
2121
import { WorkspaceConfiguration, workspace, Uri, RelativePattern } from 'vscode';
2222
import * as fs from 'fs';
2323
import * as path from 'path';
24-
import { parse } from 'toml';
24+
import { parse } from '@iarna/toml';
2525

2626
export enum VERSION {
2727
BETA = 'beta',
@@ -303,25 +303,25 @@ export function getOrgPackageName(projectPath: string): { orgName: string, packa
303303
}
304304
}
305305

306-
export async function getProjectTomlValues(projectPath: string): Promise<PackageTomlValues | undefined> {
306+
export async function getProjectTomlValues(projectPath: string): Promise<Partial<PackageTomlValues> | undefined> {
307307
const ballerinaTomlPath = path.join(projectPath, 'Ballerina.toml');
308308
if (fs.existsSync(ballerinaTomlPath)) {
309309
const tomlContent = await fs.promises.readFile(ballerinaTomlPath, 'utf-8');
310310
try {
311-
return parse(tomlContent);
311+
return parse(tomlContent) as Partial<PackageTomlValues>;
312312
} catch (error) {
313313
console.error("Failed to load Ballerina.toml content for project at path: ", projectPath, error);
314314
return;
315315
}
316316
}
317317
}
318318

319-
export async function getWorkspaceTomlValues(workspacePath: string): Promise<WorkspaceTomlValues | undefined> {
319+
export async function getWorkspaceTomlValues(workspacePath: string): Promise<Partial<WorkspaceTomlValues> | undefined> {
320320
const ballerinaTomlPath = path.join(workspacePath, 'Ballerina.toml');
321321
if (fs.existsSync(ballerinaTomlPath)) {
322322
const tomlContent = await fs.promises.readFile(ballerinaTomlPath, 'utf-8');
323323
try {
324-
return parse(tomlContent);
324+
return parse(tomlContent) as Partial<WorkspaceTomlValues>;
325325
} catch (error) {
326326
console.error("Failed to load Ballerina.toml content for workspace at path: ", workspacePath, error);
327327
return;

workspaces/ballerina/ballerina-rpc-client/src/rpc-clients/common/rpc-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class CommonRpcClient implements CommonRPCAPI {
116116
return this._messenger.sendNotification(showErrorMessage, HOST_EXTENSION, params);
117117
}
118118

119-
getCurrentProjectTomlValues(): Promise<PackageTomlValues> {
119+
getCurrentProjectTomlValues(): Promise<Partial<PackageTomlValues>> {
120120
return this._messenger.sendRequest(getCurrentProjectTomlValues, HOST_EXTENSION);
121121
}
122122

workspaces/bi/bi-extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
"@wso2/ballerina-core": "workspace:*",
178178
"@wso2/font-wso2-vscode": "workspace:*",
179179
"xstate": "^4.38.3",
180-
"toml": "^3.0.0"
180+
"@iarna/toml": "^2.2.5"
181181
},
182182
"devDependencies": {
183183
"@vscode/vsce": "^3.7.0",

0 commit comments

Comments
 (0)