Skip to content

Commit

Permalink
fix: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmy-Joseph19 committed Mar 13, 2024
1 parent 3a8b0a9 commit 9d4c19a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
1 change: 1 addition & 0 deletions .changeset/metal-socks-add.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
"vscode-ui5-language-assistant": patch
"@ui5-language-assistant/vscode-ui5-language-assistant-bas-ext": patch
---

New script for updating manifest schema and updated manifest schema
2 changes: 1 addition & 1 deletion packages/vscode-ui5-language-assistant/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"coverage:unit": "jest --ci --forceExit --detectOpenHandles --maxWorkers=1 --coverage=true",
"bundle": "node esbuild.js",
"package": "node ./scripts/package-vsix",
"update:schema": "ts-node --project tsconfig.cli.json tools/run-update.ts"
"update:schema": "ts-node --project tsconfig.cli.json scripts/manifest/run-update.ts"
},
"dependencies": {
"@ui5-language-assistant/language-server": "4.0.44",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from "fs/promises";
import { join } from "path";
import prettier from "prettier";

export const BASE_PATH = join("src", "manifest");
export const BASE_PATH = join(process.cwd(), "src", "manifest");
export const MANIFEST_SCHEMA_LOCATION = join(BASE_PATH, "schema.json");
export const ADAPTIVE_CARD_LOCATION = join(BASE_PATH, "adaptive-card.json");
export const MANIFEST_SCHEMA_URI =
Expand All @@ -23,11 +23,8 @@ async function updateManifestResources() {
* Fetch data from ADAPTIVE_CARD_URI and updates the adaptive-card.json
*/
async function updateAdaptiveCard() {
let adaptiveCardContent = await axiosGetRequest(ADAPTIVE_CARD_URI);
const prettifiedContent = prettifyFileContent(
ADAPTIVE_CARD_URI,
JSON.stringify(adaptiveCardContent, null, 2)
);
let content = await axiosGetRequest(ADAPTIVE_CARD_URI);
const prettifiedContent = prettifyFileContent(ADAPTIVE_CARD_URI, content);
if (prettifiedContent) {
await fs.writeFile(ADAPTIVE_CARD_LOCATION, prettifiedContent, "utf8");
}
Expand All @@ -37,25 +34,25 @@ async function updateAdaptiveCard() {
* Fetch data from MANIFEST_SCHEMA_URI and updates the schema.json
*/
async function updateManifestSchama() {
const schemaContent = await axiosGetRequest(MANIFEST_SCHEMA_URI);
const prettifiedContent = prettifyFileContent(
MANIFEST_SCHEMA_URI,
JSON.stringify(schemaContent, null, 2)
);
const finalString = prettifiedContent.replace(
const content = await axiosGetRequest(MANIFEST_SCHEMA_URI);
const finalString = content.replace(
/"(https:\/\/adaptivecards\.io[^"]*)"/,
`"/manifest/adaptive-card.json"`
);
if (finalString) {
await fs.writeFile(MANIFEST_SCHEMA_LOCATION, finalString, "utf8");
const prettifiedContent = prettifyFileContent(
MANIFEST_SCHEMA_URI,
finalString
);
if (prettifiedContent) {
await fs.writeFile(MANIFEST_SCHEMA_LOCATION, prettifiedContent, "utf8");
}
}

async function axiosGetRequest(uri: string): Promise<any> {
const response = await axios.get<any>(uri, {
async function axiosGetRequest(uri: string): Promise<string> {
const response = await axios.get(uri, {
responseType: "json",
});
return response.data;
return JSON.stringify(response.data, null, 2);
}

function prettifyFileContent(filepath: string, content: string): string {
Expand Down

0 comments on commit 9d4c19a

Please sign in to comment.