Skip to content

Commit

Permalink
fix gh build and update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof Radomski committed Nov 2, 2023
1 parent 661ebea commit aa06792
Show file tree
Hide file tree
Showing 5 changed files with 8,732 additions and 35 deletions.
35 changes: 26 additions & 9 deletions README.md
Expand Up @@ -7,9 +7,20 @@
Installation:

```
yarn add --dev storybook_vitest_addon
yarn add storybook_vitest_addon
```

Compatibility:

```
"storybook": "^7.5.2",
"@storybook/react": "^7.5.2",
"vite": "^4.5.0",
"vitest": "^0.34.6"
```

Usage:

Addon meant to display Vitest unit test results in a new Stoybook panel. Developed and tested with React.
Simply add it to the addon list in your Storybook config, and then you can use it in any story.

Expand All @@ -19,21 +30,27 @@ It needs 2 params: `testResults` - test results file in json format and `testFil
Example usage:

```
// Button.stories.tsx
import vitestResults from "./unit-test-results.json";
/.../
export default {
title: "Example/Button",
component: Button,
parameters: {
vitest: {
testFile: "Button.test.tsx",
testResults: vitestResults,
},
},
title: "Example/Button",
component: Button,
parameters: {
vitest: {
testFile: "Button.test.tsx",
testResults: vitestResults,
},
},
};
/.../
```

![](2022-04-01-22-48-00.png)

```
```
5 changes: 1 addition & 4 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "storybook_vitest_addon",
"version": "0.1.0",
"version": "0.1.1",
"description": "Adds a panel to display Vitest unit test results",
"keywords": [
"storybook-addons",
Expand Down Expand Up @@ -94,8 +94,5 @@
"react"
],
"icon": "https://user-images.githubusercontent.com/321738/63501763-88dbf600-c4cc-11e9-96cd-94adadc2fd72.png"
},
"resolutions": {
"jackspeak": "2.1.1"
}
}
24 changes: 2 additions & 22 deletions scripts/prepublish-checks.mjs
@@ -1,8 +1,6 @@
#!/usr/bin/env zx

const packageJson = require("../package.json");
const boxen = require("boxen");
const dedent = require("dedent");

const name = packageJson.name;
const displayName = packageJson.storybook.displayName;
Expand All @@ -15,17 +13,7 @@ $.verbose = false;
*/
if (name.includes("addon-kit") || displayName.includes("Addon Kit")) {
console.error(
boxen(
dedent`
${chalk.red.bold("Missing metadata")}
${chalk.red(dedent`Your package name and/or displayName includes default values from the Addon Kit.
The addon gallery filters out all such addons.
Please configure appropriate metadata before publishing your addon. For more info, see:
https://storybook.js.org/docs/react/addons/addon-catalog#addon-metadata`)}`,
{ padding: 1, borderColor: "red" }
)
"Missing metadata. Your package name and/or displayName includes default values from the Addon Kit. The addon gallery filters out all such addons. Please configure appropriate metadata before publishing your addon. For more info, see:https://storybook.js.org/docs/react/addons/addon-catalog#addon-metadata"
);

exitCode = 1;
Expand All @@ -39,15 +27,7 @@ const readmeTestStrings =

if ((await $`cat README.md | grep -E ${readmeTestStrings}`.exitCode) == 0) {
console.error(
boxen(
dedent`
${chalk.red.bold("README not updated")}
${chalk.red(dedent`You are using the default README.md file that comes with the addon kit.
Please update it to provide info on what your addon does and how to use it.`)}
`,
{ padding: 1, borderColor: "red" }
)
"README not updated. You are using the default README.md file that comes with the addon kit. Please update it to provide info on what your addon does and how to use it."
);

exitCode = 1;
Expand Down
54 changes: 54 additions & 0 deletions scripts/prepublish-checks.mjs.old
@@ -0,0 +1,54 @@
#!/usr/bin/env zx

const packageJson = require("../package.json");

const name = packageJson.name;
const displayName = packageJson.storybook.displayName;

let exitCode = 0;
$.verbose = false;

/**
* Check that meta data has been updated
*/
if (name.includes("addon-kit") || displayName.includes("Addon Kit")) {
console.error(
boxen(
dedent`
${chalk.red.bold("Missing metadata")}

${chalk.red(dedent`Your package name and/or displayName includes default values from the Addon Kit.
The addon gallery filters out all such addons.

Please configure appropriate metadata before publishing your addon. For more info, see:
https://storybook.js.org/docs/react/addons/addon-catalog#addon-metadata`)}`,
{ padding: 1, borderColor: "red" }
)
);

exitCode = 1;
}

/**
* Check that README has been updated
*/
const readmeTestStrings =
"# Storybook Addon Kit|Click the \\*\\*Use this template\\*\\* button to get started.|https://user-images.githubusercontent.com/42671/106809879-35b32000-663a-11eb-9cdc-89f178b5273f.gif";

if ((await $`cat README.md | grep -E ${readmeTestStrings}`.exitCode) == 0) {
console.error(
boxen(
dedent`
${chalk.red.bold("README not updated")}

${chalk.red(dedent`You are using the default README.md file that comes with the addon kit.
Please update it to provide info on what your addon does and how to use it.`)}
`,
{ padding: 1, borderColor: "red" }
)
);

exitCode = 1;
}

process.exit(exitCode);

0 comments on commit aa06792

Please sign in to comment.