Skip to content

Commit

Permalink
ci: only show story files
Browse files Browse the repository at this point in the history
  • Loading branch information
acid-chicken committed Apr 6, 2023
1 parent cbbca12 commit f655fc2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
1 change: 1 addition & 0 deletions packages/frontend/.storybook/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
/generate.js
/preload-locale.js
/locale.ts
/main.js
/preload-theme.js
/themes.ts
40 changes: 26 additions & 14 deletions packages/frontend/.storybook/changes.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
import fs from "node:fs/promises";
import path from "node:path";
import micromatch from "micromatch";
import fs from 'node:fs/promises';
import path from 'node:path';
import micromatch from 'micromatch';
import main from './main';

fs.readFile(
path.resolve(__dirname, "../storybook-static/preview-stats.json")
path.resolve(__dirname, '../storybook-static/preview-stats.json')
).then((buffer) => {
const stats = JSON.parse(buffer.toString());
const modules = new Set(
process.argv.slice(2).map((arg) => path.relative(path.resolve(__dirname, ".."), path.resolve(__dirname, "../../..", arg)))
process.argv
.slice(2)
.map((arg) =>
path.relative(
path.resolve(__dirname, '..'),
path.resolve(__dirname, '../../..', arg)
)
)
);
if (
micromatch(Array.from(modules), [
"../../assets/**",
"../../fluent-emojis/**",
"../../locales/**",
"../../misskey-assets/**",
"assets/**",
"public/**",
"../../pnpm-lock.yaml",
'../../assets/**',
'../../fluent-emojis/**',
'../../locales/**',
'../../misskey-assets/**',
'assets/**',
'public/**',
'../../pnpm-lock.yaml',
]).length
) {
return;
Expand All @@ -35,7 +43,11 @@ fs.readFile(
break;
}
}
for (const file of Array.from(modules)) {
process.stdout.write(` --only-story-files ${path.resolve(__dirname, "..", file)}`);
const stories = micromatch(
Array.from(modules),
main.stories.map((story) => path.resolve(__dirname, story))
);
for (const story of stories) {
process.stdout.write(` --only-story-files ${story}`);
}
});
2 changes: 1 addition & 1 deletion packages/frontend/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const config = {
core: {
disableTelemetry: true,
},
async viteFinal(config, options) {
async viteFinal(config) {
return mergeConfig(config, {
plugins: [
turbosnap({
Expand Down

0 comments on commit f655fc2

Please sign in to comment.