Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create with vue-i18n #548

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0709a51
feat: create with vue-i18n
Procrustes5 Aug 2, 2024
807f730
chore(test): add tests
Procrustes5 Aug 2, 2024
4da6366
Update pnpm-lock.yaml
Procrustes5 Aug 2, 2024
007c98b
fix(ci): add generated files
Procrustes5 Aug 2, 2024
a8764b5
fix(ci): set entrypoints ts
Procrustes5 Aug 2, 2024
cd6b00f
Revert "fix(ci): add generated files"
Procrustes5 Aug 5, 2024
3c8210b
fix: change index.js like vue-i18n document
Procrustes5 Aug 5, 2024
047817d
Merge branch 'main' into feat/create-with-i18n
Procrustes5 Aug 5, 2024
f4b7e2f
chore: pnpm-lock.yaml
Procrustes5 Aug 5, 2024
afd0352
Merge branch 'feat/create-with-i18n' of https://github.com/Procrustes…
Procrustes5 Aug 5, 2024
aebef03
Update pnpm-lock.yaml
Procrustes5 Aug 5, 2024
b2c996a
feat: add flags to snapshot
Procrustes5 Aug 12, 2024
e5c6f33
Merge branch 'main' into feat/create-with-i18n
Procrustes5 Aug 12, 2024
a44a4e8
fix: remove template/tsconfig/vue-i18n
Procrustes5 Aug 12, 2024
3acbe52
Merge branch 'feat/create-with-i18n' of https://github.com/Procrustes…
Procrustes5 Aug 12, 2024
8f7ccff
chore: fix package.json
Procrustes5 Aug 12, 2024
0d4a933
chore: pull main
Procrustes5 Aug 12, 2024
b3fa7e0
feat: add ts files
Procrustes5 Aug 16, 2024
d098768
fix: cd.yml
Procrustes5 Aug 16, 2024
d51fd03
Merge branch 'main' into feat/create-with-i18n
Procrustes5 Aug 16, 2024
cf5d71e
chore: export i18n
Procrustes5 Aug 16, 2024
cd0b81a
Merge branch 'feat/create-with-i18n' of https://github.com/Procrustes…
Procrustes5 Aug 16, 2024
3a83d52
feat: add views
Procrustes5 Aug 16, 2024
17fb167
chore: typo
Procrustes5 Aug 16, 2024
c7922a6
chore: delete i18n on matrix
Procrustes5 Aug 16, 2024
026cd9e
chore: avoid lint error
Procrustes5 Aug 16, 2024
884b9dd
chore: disable eslint
Procrustes5 Aug 16, 2024
ad66d81
chore: test
Procrustes5 Aug 16, 2024
a125bc7
chore: export i18n
Procrustes5 Aug 16, 2024
d2bf4f4
fix: delete duplicated files
Procrustes5 Aug 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
flag-for-router: ['', '--router']
flag-for-pinia: ['', '--pinia']
flag-for-vitest: ['', '--vitest']
flag-for-i18n: ['', '--vue-i18n']

# It's quite costly to install Cypress & Playwright even with cache.
# Maybe we can split them into another job so that all the projects
Expand All @@ -68,6 +69,7 @@ jobs:
flag-for-e2e: '--cypress'
flag-for-eslint: '--eslint'
flag-for-devtools: '--devtools'
flag-for-i18n: '--vue-i18n'

- node-version: 18
os: macos-latest
Expand All @@ -79,6 +81,7 @@ jobs:
flag-for-e2e: '--cypress'
flag-for-eslint: '--eslint'
flag-for-devtools: '--devtools'
flag-for-i18n: '--vue-i18n'

- node-version: 20
os: ubuntu-latest
Expand All @@ -90,6 +93,7 @@ jobs:
flag-for-e2e: '--cypress'
flag-for-eslint: '--eslint'
flag-for-devtools: '--devtools'
flag-for-i18n: '--vue-i18n'

- node-version: 22
os: ubuntu-latest
Expand All @@ -101,10 +105,11 @@ jobs:
flag-for-e2e: '--cypress'
flag-for-eslint: '--eslint'
flag-for-devtools: '--devtools'
flag-for-i18n: '--vue-i18n'
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.os == 'windows-latest' }}
env:
FEATURE_FLAGS: ${{ matrix.flag-for-ts }} ${{ matrix.flag-for-jsx }} ${{ matrix.flag-for-router }} ${{ matrix.flag-for-pinia }} ${{ matrix.flag-for-vitest }} ${{ matrix.flag-for-e2e }} ${{matrix.flag-for-eslint}} ${{matrix.flag-for-devtools}}
FEATURE_FLAGS: ${{ matrix.flag-for-ts }} ${{ matrix.flag-for-jsx }} ${{ matrix.flag-for-router }} ${{ matrix.flag-for-pinia }} ${{ matrix.flag-for-vitest }} ${{ matrix.flag-for-e2e }} ${{matrix.flag-for-eslint}} ${{matrix.flag-for-devtools}} ${{ matrix.flag-for-i18n }}
# Sometimes the Linux runner can't verify Cypress in 30s
CYPRESS_VERIFY_TIMEOUT: 60000
steps:
Expand Down
6 changes: 4 additions & 2 deletions __test__/sortDependencies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ describe('sortDependencies', () => {
'@vitejs/plugin-vue': '^4.4.0',
'eslint-plugin-cypress': '^2.15.1',
'eslint-plugin-vue': '^9.17.0',
vitest: '^0.34.6'
vitest: '^0.34.6',
'vue-i18n': '^9.13.1'
}
}
expect(sortDependencies(packageJson)).toStrictEqual({
Expand All @@ -40,7 +41,8 @@ describe('sortDependencies', () => {
jsdom: '^22.1.0',
'start-server-and-test': '^2.0.1',
vite: '^4.4.11',
vitest: '^0.34.6'
vitest: '^0.34.6',
'vue-i18n': '^9.13.1'
}
})
})
Expand Down
28 changes: 24 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ async function init() {
'vue-router': { type: 'boolean' },
router: { type: 'boolean' },
'vue-devtools': { type: 'boolean' },
devtools: { type: 'boolean' }
devtools: { type: 'boolean' },
'vue-i18n': { type: 'boolean' },
i18n: { type: 'boolean' }
} as const

const { values: argv, positionals } = parseArgs({
Expand All @@ -121,7 +123,9 @@ async function init() {
argv.playwright ??
argv.eslint ??
argv['eslint-with-prettier'] ??
(argv.devtools || argv['vue-devtools'])
(argv.devtools || argv['vue-devtools']) ??
argv['vue-i18n'] ??
argv.i18n
) === 'boolean'

let targetDir = positionals[0]
Expand All @@ -144,6 +148,7 @@ async function init() {
needsEslint?: boolean
needsPrettier?: boolean
needsDevTools?: boolean
needsVueI18n?: boolean
} = {}

try {
Expand Down Expand Up @@ -300,6 +305,14 @@ async function init() {
initial: false,
active: language.defaultToggleOptions.active,
inactive: language.defaultToggleOptions.inactive
},
{
name: 'needsVueI18n',
type: () => (isFeatureFlagsUsed ? null : 'toggle'),
message: language.needsVueI18n.message,
initial: false,
active: language.defaultToggleOptions.active,
inactive: language.defaultToggleOptions.inactive
}
],
{
Expand All @@ -326,7 +339,8 @@ async function init() {
needsVitest = argv.vitest || argv.tests,
needsEslint = argv.eslint || argv['eslint-with-prettier'],
needsPrettier = argv['eslint-with-prettier'],
needsDevTools = argv.devtools || argv['vue-devtools']
needsDevTools = argv.devtools || argv['vue-devtools'],
needsVueI18n = argv['vue-i18n'] || argv.i18n
} = result

const { needsE2eTesting } = result
Expand Down Expand Up @@ -475,6 +489,10 @@ async function init() {
if (needsDevTools) {
render('config/devtools')
}

if (needsVueI18n) {
render('config/vue-i18n')
}
// Render code template.
// prettier-ignore
const codeTemplate =
Expand All @@ -489,6 +507,8 @@ async function init() {
render('entry/pinia')
} else if (needsRouter) {
render('entry/router')
} else if (needsVueI18n) {
render('entry/i18n')
} else {
render('entry/default')
}
Expand Down Expand Up @@ -521,7 +541,7 @@ async function init() {
// We try to share as many files between TypeScript and JavaScript as possible.
// If that's not possible, we put `.ts` version alongside the `.js` one in the templates.
// So after all the templates are rendered, we need to clean up the redundant files.
// (Currently it's only `cypress/plugin/index.ts`, but we might add more in the future.)
// (Currently it's only `cypress/plugin/index.js`, but we might add more in the future.)
// (Or, we might completely get rid of the plugins folder as Cypress 10 supports `cypress.config.ts`)

if (needsTypeScript) {
Expand Down
3 changes: 3 additions & 0 deletions locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"needsDevTools": {
"message": "Add Vue DevTools 7 extension for debugging? (experimental)"
},
"needsVueI18n": {
"message": "Add Vue I18n for internationalization?"
},
"errors": {
"operationCancelled": "Operation cancelled"
},
Expand Down
3 changes: 3 additions & 0 deletions locales/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"needsDevTools": {
"message": "Ajouter l'extension Vue DevTools 7 pour le débogage\u00a0? (expérimental)"
},
"needsVueI18n": {
"message": "Ajouter Vue I18n pour l'internationalisation\u00a0?"
},
"errors": {
"operationCancelled": "Operation annulée"
},
Expand Down
3 changes: 3 additions & 0 deletions locales/tr-TR.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"needsDevTools": {
"message": "Hata ayıklama için Vue DevTools 7 eklentisi eklensin mi? (deneysel)"
},
"needsVueI18n": {
"message": "Uluslararasılaştırma için Vue I18n eklensin mi?"
},
"errors": {
"operationCancelled": "İşlem iptal edildi"
},
Expand Down
3 changes: 3 additions & 0 deletions locales/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"needsDevTools": {
"message": "是否引入 Vue DevTools 7 扩展用于调试? (试验阶段)"
},
"needsVueI18n": {
"message": "是否引入 Vue I18n 用于国际化?"
},
"errors": {
"operationCancelled": "操作取消"
},
Expand Down
3 changes: 3 additions & 0 deletions locales/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
"needsDevTools": {
"message": "是否引入 Vue DevTools 7 擴充元件以協助偵錯?(試驗性功能)"
},
"needsVueI18n": {
"message": "是否引入 Vue I18n 用於國際化?"
},
"errors": {
"operationCancelled": "操作取消"
},
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"prettier": "^3.3.3",
"prompts": "^2.4.2",
"vitest": "^2.0.5",
"zx": "^8.1.4"
"zx": "^8.1.4",
"vue-i18n": "^9.13.1"
},
"lint-staged": {
"*.{js,ts,vue,json}": [
Expand Down
Loading