mizzkey/packages/frontend/.storybook/changes.ts
mattyatea 15005c4266 Merge remote-tracking branch 'misskey-dev/develop' into develop
# Conflicts:
#	.config/docker_example.env
#	.config/docker_example.yml
#	CHANGELOG.md
#	locales/index.d.ts
#	locales/ja-JP.yml
#	packages/backend/package.json
#	packages/backend/src/core/entities/UserEntityService.ts
#	packages/backend/src/server/api/endpoints/i/update.ts
#	packages/frontend/package.json
#	packages/frontend/src/components/MkChannelFollowButton.vue
#	packages/frontend/src/components/MkFollowButton.vue
#	packages/frontend/src/components/MkMediaAudio.vue
#	packages/frontend/src/components/MkMenu.vue
#	packages/frontend/src/components/MkNote.vue
#	packages/frontend/src/components/MkNoteDetailed.vue
#	packages/frontend/src/components/MkPostForm.vue
#	packages/frontend/src/components/MkRadio.vue
#	packages/frontend/src/components/MkSuperMenu.vue
#	packages/frontend/src/components/MkSwitch.vue
#	packages/frontend/src/components/MkVisitorDashboard.vue
#	packages/frontend/src/os.ts
#	packages/frontend/src/pages/about.vue
#	packages/frontend/src/pages/admin/roles.editor.vue
#	packages/frontend/src/pages/admin/roles.vue
#	packages/frontend/src/pages/custom-emojis-manager.vue
#	packages/frontend/src/pages/follow.vue
#	packages/frontend/src/pages/timeline.vue
#	packages/frontend/src/pages/user/home.vue
#	packages/frontend/src/scripts/get-note-menu.ts
#	packages/frontend/src/scripts/keycode.ts
#	packages/frontend/src/ui/_common_/navbar-for-mobile.vue
#	packages/frontend/src/ui/_common_/navbar.vue
#	pnpm-lock.yaml
2024-07-15 20:13:51 +09:00

89 lines
2 KiB
TypeScript

/*
* SPDX-FileCopyrightText: syuilo and misskey-project , Type4ny-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import fs from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import path from 'node:path';
import micromatch from 'micromatch';
import main from './main.js';
const __dirname = fileURLToPath(new URL('.', import.meta.url));
interface Stats {
readonly modules: readonly {
readonly id: string;
readonly name: string;
readonly reasons: readonly {
readonly moduleName: string;
}[];
}[];
}
await fs.readFile(
new URL('../storybook-static/preview-stats.json', import.meta.url)
).then((buffer) => {
const stats: Stats = JSON.parse(buffer.toString());
const keys = new Set(stats.modules.map((stat) => stat.id));
const map = new Map(
Array.from(keys, (key) => [
key,
new Set(
stats.modules
.filter((stat) => stat.id === key)
.flatMap((stat) => stat.reasons)
.map((reason) => reason.moduleName)
),
])
);
const modules = new Set(
process.argv
.slice(2)
.map((arg) =>
path.relative(
path.resolve(__dirname, '..'),
path.resolve(__dirname, '../../..', arg)
)
)
.map((path) => path.replace(/(?:(?<=\.stories)\.(?:impl|meta)|\.msw)(?=\.ts$)/g, ''))
);
if (
micromatch(Array.from(modules), [
'../../assets/**',
'../../fluent-emojis/**',
'../../locales/ja-JP.yml',
'../../misskey-assets/**',
'assets/**',
'public/**',
'../../pnpm-lock.yaml',
]).length
) {
return;
}
for (;;) {
const oldSize = modules.size;
for (const module of Array.from(modules)) {
if (map.has(module)) {
for (const dependency of Array.from(map.get(module)!)) {
modules.add(dependency);
}
}
}
if (modules.size === oldSize) {
break;
}
}
const stories = micromatch(
Array.from(modules),
main.stories.map((story) => `./${path.relative('..', story)}`)
);
if (stories.length) {
for (const story of stories) {
process.stdout.write(` --only-story-files ${story}`);
}
} else {
process.stdout.write(` --skip`);
}
});