From 6f5b27fa316af76ccc514e0219193add9c38e37f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Sun, 26 Jun 2022 22:53:02 +0900 Subject: [PATCH] feat: add vite-setup-catalogue (#83) --- .github/workflows/ecosystem-ci-selected.yml | 1 + .github/workflows/ecosystem-ci.yml | 3 ++- tests/vite-setup-catalogue.ts | 12 ++++++++++++ types.d.ts | 4 ++++ utils.ts | 15 +++++++++------ 5 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 tests/vite-setup-catalogue.ts diff --git a/.github/workflows/ecosystem-ci-selected.yml b/.github/workflows/ecosystem-ci-selected.yml index fad0d7a..2fc80e9 100644 --- a/.github/workflows/ecosystem-ci-selected.yml +++ b/.github/workflows/ecosystem-ci-selected.yml @@ -42,6 +42,7 @@ on: - astro - rakkas - storybook + - vite-setup-catalogue jobs: execute-selected-suite: timeout-minutes: 20 diff --git a/.github/workflows/ecosystem-ci.yml b/.github/workflows/ecosystem-ci.yml index 25adb8f..6868720 100644 --- a/.github/workflows/ecosystem-ci.yml +++ b/.github/workflows/ecosystem-ci.yml @@ -48,7 +48,8 @@ jobs: telefunc, astro, rakkas, - storybook + storybook, + vite-setup-catalogue ] fail-fast: false steps: diff --git a/tests/vite-setup-catalogue.ts b/tests/vite-setup-catalogue.ts new file mode 100644 index 0000000..33e7d20 --- /dev/null +++ b/tests/vite-setup-catalogue.ts @@ -0,0 +1,12 @@ +import { runInRepo } from '../utils' +import { RunOptions } from '../types' + +export async function test(options: RunOptions) { + await runInRepo({ + ...options, + repo: 'sapphi-red/vite-setup-catalogue', + branch: 'main', + test: 'test-for-ecosystem-ci', + useCopyForOverrides: true // needs copy because node_modules is mounted on docker container + }) +} diff --git a/types.d.ts b/types.d.ts index dbc1b2a..c9f76f5 100644 --- a/types.d.ts +++ b/types.d.ts @@ -16,6 +16,10 @@ export interface RunOptions { build?: Task test?: Task | Task[] beforeInstall?: Task + /** + * Whether to use `file:` instead of `link:` + */ + useCopyForOverrides?: boolean } type Task = string | (() => Promise) diff --git a/utils.ts b/utils.ts index 54055c7..cc26a1d 100644 --- a/utils.ts +++ b/utils.ts @@ -122,7 +122,8 @@ export async function runInRepo(options: RunOptions & RepoOptions) { commit, skipGit, verify, - beforeInstall + beforeInstall, + useCopyForOverrides } = options const beforeInstallCommand = toCommand(beforeInstall) const buildCommand = toCommand(build) @@ -155,19 +156,21 @@ export async function runInRepo(options: RunOptions & RepoOptions) { overrides.vite = options.release } } else { - overrides.vite ||= `${options.vitePath}/packages/vite` + const protocol = useCopyForOverrides ? 'file:' : '' + + overrides.vite ||= `${protocol}${options.vitePath}/packages/vite` overrides[ `@vitejs/plugin-vue` - ] ||= `${options.vitePath}/packages/plugin-vue` + ] ||= `${protocol}${options.vitePath}/packages/plugin-vue` overrides[ `@vitejs/plugin-vue-jsx` - ] ||= `${options.vitePath}/packages/plugin-vue-jsx` + ] ||= `${protocol}${options.vitePath}/packages/plugin-vue-jsx` overrides[ `@vitejs/plugin-react` - ] ||= `${options.vitePath}/packages/plugin-react` + ] ||= `${protocol}${options.vitePath}/packages/plugin-react` overrides[ `@vitejs/plugin-legacy` - ] ||= `${options.vitePath}/packages/plugin-legacy` + ] ||= `${protocol}${options.vitePath}/packages/plugin-legacy` } await applyPackageOverrides(dir, overrides)