Skip to content

Commit

Permalink
Merge pull request #100 from veith/feat/webtypes-default-icon
Browse files Browse the repository at this point in the history
Feat/webtypes default icon
  • Loading branch information
break-stuff committed Mar 14, 2024
2 parents 4d74d90 + f421b3f commit e0aa044
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -17,6 +17,7 @@ build
# misc
.DS_Store
*.pem
.idea

# debug
npm-debug.log*
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions 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
6 changes: 6 additions & 0 deletions packages/jet-brains-integration/README.md
Expand Up @@ -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;
}
```

Expand Down Expand Up @@ -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.
27 changes: 27 additions & 0 deletions 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 {readFileSync} 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 = readFileSync("test_output/web-types.json", 'utf-8')
const wtJson = (JSON.parse(data));

// Assert
expect(wtJson["default-icon"]).toBe("icon.svg");
});
})
Expand Up @@ -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({
Expand Down
2 changes: 2 additions & 0 deletions packages/jet-brains-integration/src/types.d.ts
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions packages/jet-brains-integration/src/web-types-generator.ts
Expand Up @@ -201,8 +201,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
? ""
Expand Down

0 comments on commit e0aa044

Please sign in to comment.