-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
re-structure project environment (#380)
* chore: use pnpm * chore: pass params to test:unit * fix: re-structure e2e and example * add todo memo * add more task * fix: use pnpm on github actions
- Loading branch information
Showing
37 changed files
with
12,700 additions
and
15,082 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# TODO | ||
- [ ] upgrade vitest 1.0 (need to fix `checkInstallPackage` issue in test env) | ||
- [ ] drop fully jest pupeeter for rollup-plugin-vue-i18n, vue-i18n-loader, and vite-plugin-vue-i18n | ||
- [ ] ESLint: migrate flat config style |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { Page } from 'playwright' | ||
|
||
export async function getText( | ||
page: Page, | ||
selector: string, | ||
options?: Parameters<Page['locator']>[1] | ||
) { | ||
return (await page.locator(selector, options).allTextContents())[0] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { getRandomPort, waitForPort } from 'get-port-please' | ||
import { ChildProcess, spawn } from 'node:child_process' | ||
|
||
export type ServerContext = { | ||
serverProcess: ChildProcess | ||
url: (val: string) => string | ||
} | ||
export async function startServer(): Promise<ServerContext> { | ||
const host = '127.0.0.1' | ||
const port = await getRandomPort(host) | ||
|
||
const serverProcess = spawn( | ||
'pnpm', | ||
['play:vite', '--port', String(port), '--host', host], | ||
{ stdio: 'inherit', env: { ...process.env } } | ||
) | ||
|
||
await waitForPort(port, { retries: 32, host }) | ||
|
||
return { | ||
serverProcess, | ||
url: (val: string) => `http://${host}:${port}${val}` | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { startServer } from './setup-server' | ||
import { getText } from './helper' | ||
|
||
import type { ServerContext } from './setup-server' | ||
import type { Browser, Page } from 'playwright' | ||
|
||
// TODO: extract to shim.d.ts | ||
// eslint-disable-next-line @typescript-eslint/no-namespace | ||
declare namespace global { | ||
let browser: Browser | ||
let page: Page | ||
} | ||
|
||
let ctx: ServerContext | ||
describe('vite', () => { | ||
beforeAll(async () => { | ||
ctx = await startServer() | ||
await global.page.goto(ctx.url('/')) | ||
}) | ||
|
||
afterAll(async () => { | ||
ctx.serverProcess.kill() | ||
}) | ||
|
||
test('initial rendering', async () => { | ||
expect(await getText(global.page, '#lang label')).toMatch('言語') | ||
expect(await getText(global.page, '#fruits label')).toMatch( | ||
'バナナが欲しい?' | ||
) | ||
expect(await getText(global.page, '#msg')).toMatch('こんにちは、世界!') | ||
expect(await getText(global.page, '#custom-directive')).toMatch('やあ!') | ||
}) | ||
|
||
test('change locale', async () => { | ||
await global.page.selectOption('#lang select', 'en') | ||
expect(await getText(global.page, '#lang label')).toMatch('Language') | ||
expect(await getText(global.page, '#msg')).toMatch('hello, world!') | ||
expect(await getText(global.page, '#custom-directive')).toMatch('Hi!') | ||
}) | ||
|
||
test('change banana select', async () => { | ||
await global.page.selectOption('#fruits select', '3') | ||
expect(await getText(global.page, '#banana')).toMatch('バナナ 3 個') | ||
}) | ||
}) |
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
...plugin-vue-i18n/examples/vite/src/App.vue → examples/vite/src/App.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...gin-vue-i18n/examples/vite/vite.config.ts → examples/vite/vite.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,7 @@ | |
"eslint-plugin-vue": "^9.26.0", | ||
"esno": "^0.17.0", | ||
"execa": "^5.1.1", | ||
"get-port-please": "^3.1.2", | ||
"jest": "^27.2.3", | ||
"jest-puppeteer": "^6.0.0", | ||
"jest-watch-typeahead": "^0.6.4", | ||
|
@@ -72,6 +73,7 @@ | |
"prettier": "^3.2.5", | ||
"prompts": "^2.4.1", | ||
"puppeteer": "^10.4.0", | ||
"playwright": "^1.44.0", | ||
"rollup": "^2.53.1", | ||
"rollup-plugin-vue": "^6.0.0", | ||
"secretlint": "^3.2.0", | ||
|
@@ -113,54 +115,55 @@ | |
}, | ||
"scripts": { | ||
"prepare": "git config --local core.hooksPath .githooks", | ||
"build": "npm-run-all -s \"build:utils\" \"build:unplugin\"", | ||
"build:utils": "yarn workspace @intlify/bundle-utils build", | ||
"build:rollup": "yarn workspace @intlify/rollup-plugin-vue-i18n build", | ||
"build:vite": "yarn workspace @intlify/vite-plugin-vue-i18n build", | ||
"build:webpack": "yarn workspace @intlify/vue-i18n-loader build", | ||
"build:unplugin": "yarn workspace @intlify/unplugin-vue-i18n build", | ||
"example:unplugin": "yarn workspace @intlify/unplugin-vue-i18n build:example", | ||
"play:unplugin:vite": "yarn workspace @intlify/unplugin-vue-i18n dev:vite", | ||
"play:unplugin:webpack": "yarn workspace @intlify/unplugin-vue-i18n dev:webpack", | ||
"clean": "npm-run-all --parallel \"clean:*\"", | ||
"clean:utils": "yarn workspace @intlify/bundle-utils clean", | ||
"clean:rollup": "yarn workspace @intlify/rollup-plugin-vue-i18n clean", | ||
"clean:vite": "yarn workspace @intlify/vite-plugin-vue-i18n clean", | ||
"clean:webpack": "yarn workspace @intlify/vue-i18n-loader clean", | ||
"clean:unplugin": "yarn workspace @intlify/unplugin-vue-i18n clean", | ||
"build": "run-s \"build:utils\" \"build:unplugin\"", | ||
"build:utils": "pnpm --filter @intlify/bundle-utils build", | ||
"build:rollup": "pnpm --filter @intlify/rollup-plugin-vue-i18n build", | ||
"build:vite": "pnpm --filter @intlify/vite-plugin-vue-i18n build", | ||
"build:webpack": "pnpm --filter @intlify/vue-i18n-loader build", | ||
"build:unplugin": "pnpm --filter @intlify/unplugin-vue-i18n build", | ||
"build:example": "run-s \"build:example:vite {@}\" \"build:example:webpack\" --", | ||
"build:example:vite": "cd examples/vite && vite build --config ./vite.config.ts --outDir ./dist", | ||
"build:example:webpack": "pnpm build && webpack --config ./examples/webpack/webpack.config.js", | ||
"play:vite": "vite examples/vite -c examples/vite/vite.config.ts", | ||
"play:webpack": "pnpm run build:unplugin && webpack serve --config ./examples/webpack/webpack.config.js", | ||
"preview:vite": "vite preview examples/vite --outDir dist", | ||
"check-install": "jiti scripts/playwright.ts", | ||
"clean": "run-p \"clean:*\"", | ||
"clean:utils": "pnpm --filter @intlify/bundle-utils clean", | ||
"clean:rollup": "pnpm --filter @intlify/rollup-plugin-vue-i18n clean", | ||
"clean:vite": "pnpm --filter @intlify/vite-plugin-vue-i18n clean", | ||
"clean:webpack": "pnpm --filter @intlify/vue-i18n-loader clean", | ||
"clean:unplugin": "pnpm --filter @intlify/unplugin-vue-i18n clean", | ||
"coverage": "opener coverage/lcov-report/index.html", | ||
"fix": "npm-run-all --parallel lint:eslint:fix format:fix", | ||
"fix": "run-p lint:eslint:fix format:fix", | ||
"format": "prettier --config .prettierrc --ignore-path .prettierignore '**/*.{js,json,html}'", | ||
"format:fix": "yarn format --write", | ||
"lint": "npm-run-all --parallel lint:eslint lint:secret", | ||
"format:fix": "pnpm format --write", | ||
"lint": "run-p lint:eslint lint:secret", | ||
"lint:eslint": "eslint ./packages ./scripts --ext .ts", | ||
"lint:eslint:fix": "yarn lint:eslint --fix", | ||
"lint:eslint:fix": "pnpm lint:eslint --fix", | ||
"lint:secret": "npx secretlint \"**/*\"", | ||
"test": "yarn test:unit && yarn test:e2e", | ||
"test:e2e": "npm-run-all test:e2e:unplugin", | ||
"test:e2e:rollup": "yarn workspace @intlify/rollup-plugin-vue-i18n test:e2e", | ||
"test:e2e:vite": "yarn workspace @intlify/vite-plugin-vue-i18n test:e2e", | ||
"test:e2e:webpack": "yarn workspace @intlify/vue-i18n-loader test:e2e", | ||
"test:e2e:unplugin": "yarn workspace @intlify/unplugin-vue-i18n test:e2e", | ||
"test:unit": "run-s \"test:unit:utils\" \"test:unit:unplugin\"", | ||
"test:unit:utils": "yarn run build:utils && vitest run packages/bundle-utils", | ||
"test": "pnpm test:unit && pnpm test:e2e", | ||
"test:e2e": "pnpm check-install && vitest -c ./vitest.e2e.config.ts run", | ||
"test:e2e:rollup": "pnpm --filter @intlify/rollup-plugin-vue-i18n test:e2e", | ||
"test:e2e:vite": "pnpm --filter @intlify/vite-plugin-vue-i18n test:e2e", | ||
"test:e2e:webpack": "pnpm --filter @intlify/vue-i18n-loader test:e2e", | ||
"test:e2e:unplugin": "pnpm --filter @intlify/unplugin-vue-i18n test:e2e", | ||
"test:unit": "run-s \"test:unit:utils {@}\" \"test:unit:unplugin {@}\" --", | ||
"test:unit:utils": "vitest run packages/bundle-utils", | ||
"test:unit:rollup": "vitest run packages/rollup-plugin-vue-i18n/test", | ||
"test:unit:unplugin": "vitest run packages/unplugin-vue-i18n/test", | ||
"changelog": "jiti ./scripts/changelog.ts", | ||
"changelog:utils": "yarn workspace @intlify/bundle-utils changelog", | ||
"changelog:rollup": "yarn workspace @intlify/rollup-plugin-vue-i18n changelog", | ||
"changelog:vite": "yarn workspace @intlify/vite-plugin-vue-i18n changelog", | ||
"changelog:webpack": "yarn workspace @intlify/vue-i18n-loader changelog", | ||
"changelog:unplugin": "yarn workspace @intlify/unplugin-vue-i18n changelog", | ||
"changelog:utils": "pnpm --filter @intlify/bundle-utils changelog", | ||
"changelog:rollup": "pnpm --filter @intlify/rollup-plugin-vue-i18n changelog", | ||
"changelog:vite": "pnpm --filter @intlify/vite-plugin-vue-i18n changelog", | ||
"changelog:webpack": "pnpm --filter @intlify/vue-i18n-loader changelog", | ||
"changelog:unplugin": "pnpm --filter @intlify/unplugin-vue-i18n changelog", | ||
"release": "jiti ./scripts/release.ts", | ||
"release:utils": "yarn workspace @intlify/bundle-utils release", | ||
"release:rollup": "yarn workspace @intlify/rollup-plugin-vue-i18n release", | ||
"release:vite": "yarn workspace @intlify/vite-plugin-vue-i18n release", | ||
"release:webpack": "yarn workspace @intlify/vue-i18n-loader release", | ||
"release:unplugin": "yarn workspace @intlify/unplugin-vue-i18n release" | ||
"release:utils": "pnpm --filter @intlify/bundle-utils release", | ||
"release:rollup": "pnpm --filter @intlify/rollup-plugin-vue-i18n release", | ||
"release:vite": "pnpm --filter @intlify/vite-plugin-vue-i18n release", | ||
"release:webpack": "pnpm --filter @intlify/vue-i18n-loader release", | ||
"release:unplugin": "pnpm --filter @intlify/unplugin-vue-i18n release" | ||
}, | ||
"workspaces": [ | ||
"packages/bundle-utils", | ||
"packages/unplugin-vue-i18n" | ||
] | ||
"packageManager": "[email protected]+sha256.e1f9e8d1a16607a46dd3c158b5f7a7dc7945501d1c6222d454d63d033d1d918f" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.