From 184aa9be2a94606618912ce369b72c21764a717c Mon Sep 17 00:00:00 2001 From: veith Date: Fri, 8 Mar 2024 10:24:57 +0100 Subject: [PATCH 1/4] feat: Option to set the default icon added. --- .gitignore | 1 + package-lock.json | 2 +- packages/jet-brains-integration/src/types.d.ts | 2 ++ packages/jet-brains-integration/src/web-types-generator.ts | 6 ++++-- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index e07b195..c946a28 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ build # misc .DS_Store *.pem +.idea # debug npm-debug.log* diff --git a/package-lock.json b/package-lock.json index ed408d0..0d0f6f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18637,7 +18637,7 @@ }, "packages/custom-jsdoc-tags": { "name": "cem-plugin-custom-jsdoc-tags", - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "devDependencies": { "@custom-elements-manifest/analyzer": "^0.6.3", diff --git a/packages/jet-brains-integration/src/types.d.ts b/packages/jet-brains-integration/src/types.d.ts index 4f421e5..0fa987b 100644 --- a/packages/jet-brains-integration/src/types.d.ts +++ b/packages/jet-brains-integration/src/types.d.ts @@ -20,6 +20,8 @@ export interface Options extends BaseOptions { packageJson?: boolean; /** Used to create a link within the component info bubble */ referenceTemplate?: (name: string, tag?: string) => Reference; + /** Adds an icon link to the webtypes.json **/ + defaultIcon?: string, } export interface Params { diff --git a/packages/jet-brains-integration/src/web-types-generator.ts b/packages/jet-brains-integration/src/web-types-generator.ts index 51c9b8d..99a526a 100644 --- a/packages/jet-brains-integration/src/web-types-generator.ts +++ b/packages/jet-brains-integration/src/web-types-generator.ts @@ -188,8 +188,10 @@ function getWebTypesFileContents( "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json", "name": "${packageJson.name}", "version": "${packageJson.version}", - "description-markup": "markdown", - "contributions": { + "description-markup": "markdown",${options.defaultIcon ? ` + "default-icon": "${options.defaultIcon}", + ` : '' +} "contributions": { ${ options.excludeHtml ? "" From 34b2f0e5e89bfb0412852bb054108b90844db13c Mon Sep 17 00:00:00 2001 From: veith Date: Fri, 8 Mar 2024 11:27:59 +0100 Subject: [PATCH 2/4] test: Option to set the default icon added. --- packages/jet-brains-integration/.gitignore | 34 +++++++++++++++++++ .../src/__tests__/defaultIcon.test.ts | 27 +++++++++++++++ .../src/__tests__/web-types-generator.ts | 1 + 3 files changed, 62 insertions(+) create mode 100644 packages/jet-brains-integration/.gitignore create mode 100644 packages/jet-brains-integration/src/__tests__/defaultIcon.test.ts diff --git a/packages/jet-brains-integration/.gitignore b/packages/jet-brains-integration/.gitignore new file mode 100644 index 0000000..3ad467d --- /dev/null +++ b/packages/jet-brains-integration/.gitignore @@ -0,0 +1,34 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +node_modules +.pnp +.pnp.js + +# testing +coverage +test_output + +# next.js +.next/ +out/ +build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* + +# local env files +.env.local +.env.development.local +.env.test.local +.env.production.local + +# turbo +.turbo diff --git a/packages/jet-brains-integration/src/__tests__/defaultIcon.test.ts b/packages/jet-brains-integration/src/__tests__/defaultIcon.test.ts new file mode 100644 index 0000000..1854cbe --- /dev/null +++ b/packages/jet-brains-integration/src/__tests__/defaultIcon.test.ts @@ -0,0 +1,27 @@ +import { Options } from "../.."; +import { customElementsManifest } from "./test-data"; +import { getOptions, getTagList, saveWebTypeFile } from "../web-types-generator"; +import { getComponents } from "../../../../tools/cem-utils"; +import fs from "fs"; + +describe("web-types-generator", () => { + const components = getComponents(customElementsManifest); + + + test("given a config to set the defaultIcon, the default-icon: should have the icon", () => { + // Arrange + const options = getOptions({ + defaultIcon: "icon.svg", + outdir:"test_output" + }); + + // Act + saveWebTypeFile([], [], [], options); + + const data = fs.readFileSync("test_output/web-types.json", 'utf-8') + const wtJson = (JSON.parse(data)); + + // Assert + expect(wtJson["default-icon"]).toBe("icon.svg"); + }); +}) diff --git a/packages/jet-brains-integration/src/__tests__/web-types-generator.ts b/packages/jet-brains-integration/src/__tests__/web-types-generator.ts index 7fa180c..1a82198 100644 --- a/packages/jet-brains-integration/src/__tests__/web-types-generator.ts +++ b/packages/jet-brains-integration/src/__tests__/web-types-generator.ts @@ -51,6 +51,7 @@ describe("web-types-generator", () => { expect(JSON.stringify(tagList).includes("**Slots:**")).toBe(false); }); + test("given a config to hide events, the Events section should not be in the docs", () => { // Arrange const options = getOptions({ From 1556e4ea5ce9b3cf565910cb5b7abcd2350e6104 Mon Sep 17 00:00:00 2001 From: veith Date: Fri, 8 Mar 2024 11:46:38 +0100 Subject: [PATCH 3/4] test: change the readFileSync import statement. --- .../jet-brains-integration/src/__tests__/defaultIcon.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/jet-brains-integration/src/__tests__/defaultIcon.test.ts b/packages/jet-brains-integration/src/__tests__/defaultIcon.test.ts index 1854cbe..26df0a7 100644 --- a/packages/jet-brains-integration/src/__tests__/defaultIcon.test.ts +++ b/packages/jet-brains-integration/src/__tests__/defaultIcon.test.ts @@ -2,7 +2,7 @@ import { Options } from "../.."; import { customElementsManifest } from "./test-data"; import { getOptions, getTagList, saveWebTypeFile } from "../web-types-generator"; import { getComponents } from "../../../../tools/cem-utils"; -import fs from "fs"; +import {readFileSync} from "fs"; describe("web-types-generator", () => { const components = getComponents(customElementsManifest); @@ -18,7 +18,7 @@ describe("web-types-generator", () => { // Act saveWebTypeFile([], [], [], options); - const data = fs.readFileSync("test_output/web-types.json", 'utf-8') + const data = readFileSync("test_output/web-types.json", 'utf-8') const wtJson = (JSON.parse(data)); // Assert From f421b3f7554e273f4729500d756f61767e89875b Mon Sep 17 00:00:00 2001 From: veith Date: Sun, 10 Mar 2024 09:43:42 +0100 Subject: [PATCH 4/4] docs: Added defaultIcon documentation to the README.md --- packages/jet-brains-integration/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/jet-brains-integration/README.md b/packages/jet-brains-integration/README.md index 860e277..cd879e2 100644 --- a/packages/jet-brains-integration/README.md +++ b/packages/jet-brains-integration/README.md @@ -112,6 +112,8 @@ export interface Options { typesSrc?: string; /** Automatically adds reference to yor package.json */ packageJson?: boolean; + /** Adds an icon to the webtypes.json **/ + defaultIcon?: string; } ``` @@ -367,3 +369,7 @@ If you are generating a custom types property on your CEM component object and y ## Scoping Tags If your project is scoping components using prefixes or suffixes in the tag name, you can generate a custom data config file using your scoping using the `prefix` or `suffix` option (`prefix: "test_"` => `test_my-element`). + +## Default Icon + +If you want to have your icon in the code completion select dialog. The entry is a relative path to the icon representing the symbol or actual SVG of the icon.