From cf9ca7921a0fe89edacf72144424724a4699c22b Mon Sep 17 00:00:00 2001 From: bendera Date: Tue, 2 Jan 2024 20:21:53 +0100 Subject: [PATCH] Add vscode custom data to package --- package.json | 20 ++++++++++++++++++-- scripts/generate-custom-data.mjs | 22 ++++++++++++++++++---- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 89087c06..91cae12a 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "files": [ "dist", "custom-elements.json", + "vscode.*-custom-data.json", "!dist/**/*.test.*" ], "customElements": "custom-elements.json", @@ -16,7 +17,7 @@ "build": "wireit", "build:ts": "wireit", "build:watch": "wireit", - "clean": "rimraf .wireit && rimraf coverage && rimraf dist && rimraf custom-elements.json && rimraf stats.html", + "clean": "rimraf -g .wireit coverage dist custom-elements.json stats.html vscode.*-custom-data.json", "lint": "npm run lint:lit-analyzer && npm run lint:eslint", "lint:eslint": "eslint src/**/*.ts", "lint:lit-analyzer": "lit-analyzer", @@ -29,7 +30,8 @@ "test:watch": "wtr --watch", "checksize": "npm run build && cat dist/bundled.js | gzip -9 | wc -c", "generate": "node scripts/generateComponent.js", - "icons": "node scripts/generateIconList.js" + "icons": "node scripts/generateIconList.js", + "vscode-data": "wireit" }, "wireit": { "analyze": { @@ -46,6 +48,7 @@ "command": "rollup -c --file dist/bundled.js", "dependencies": [ "analyze", + "vscode-data", "build:ts" ], "files": [ @@ -100,6 +103,19 @@ "src/**/*.ts" ], "output": [] + }, + "vscode-data": { + "command": "node scripts/generate-custom-data.mjs", + "dependencies": [ + "analyze" + ], + "files": [ + "custom-elements.json" + ], + "output": [ + "vscode.html-custom-data.json", + "vscode.css-custom-data.json" + ] } }, "keywords": [ diff --git a/scripts/generate-custom-data.mjs b/scripts/generate-custom-data.mjs index c11574e4..16efdf7c 100644 --- a/scripts/generate-custom-data.mjs +++ b/scripts/generate-custom-data.mjs @@ -1,6 +1,20 @@ -import { generateVsCodeCustomElementData } from "custom-element-vs-code-integration"; -import manifest from "../custom-elements.json" assert { type: "json" }; +import fs from 'node:fs'; +import util from 'node:util'; +import path, {dirname} from 'node:path'; +import {fileURLToPath} from 'node:url'; +import {generateVsCodeCustomElementData} from 'custom-element-vs-code-integration'; -const options = {}; +const readFile = util.promisify(fs.readFile); +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); -generateVsCodeCustomElementData(manifest, options); +async function main() { + const fc = await readFile(path.join(__dirname, '..', 'custom-elements.json'), 'utf-8'); + const manifest = JSON.parse(fc); + + const options = {}; + + generateVsCodeCustomElementData(manifest, options); +} + +main();