-
Notifications
You must be signed in to change notification settings - Fork 573
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v3' into fix(Link)-missing-relative-imports-linkBase
- Loading branch information
Showing
544 changed files
with
40,221 additions
and
15,197 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 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
Large diffs are not rendered by default.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { defineCommand } from 'citty' | ||
import component from './component.mjs' | ||
import locale from './locale.mjs' | ||
|
||
export default defineCommand({ | ||
meta: { | ||
name: 'make', | ||
description: 'Commands to create new Nuxt UI entities.' | ||
}, | ||
subCommands: { | ||
component, | ||
locale | ||
} | ||
}) |
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,64 @@ | ||
import { existsSync, promises as fsp } from 'node:fs' | ||
import { resolve } from 'pathe' | ||
import { consola } from 'consola' | ||
import { appendFile, sortFile, normalizeLocale } from '../../utils.mjs' | ||
import { defineCommand } from 'citty' | ||
|
||
export default defineCommand({ | ||
meta: { | ||
name: 'locale', | ||
description: 'Make a new locale.' | ||
}, | ||
args: { | ||
code: { | ||
description: 'Locale code to create. For example: en.', | ||
required: true | ||
}, | ||
name: { | ||
description: 'Locale name to create. For example: English.', | ||
required: true | ||
}, | ||
dir: { | ||
description: 'Locale direction. For example: rtl.', | ||
default: 'ltr' | ||
} | ||
}, | ||
async setup({ args }) { | ||
const path = resolve('.') | ||
const localePath = resolve(path, `src/runtime/locale`) | ||
|
||
const originLocaleFilePath = resolve(localePath, 'en.ts') | ||
const newLocaleFilePath = resolve(localePath, `${args.code}.ts`) | ||
|
||
// Validate locale code | ||
if (existsSync(newLocaleFilePath)) { | ||
consola.error(`🚨 ${args.code} already exists!`) | ||
process.exit(1) | ||
} | ||
|
||
if (!['ltr', 'rtl'].includes(args.dir)) { | ||
consola.error(`🚨 Direction ${args.dir} not supported!`) | ||
process.exit(1) | ||
} | ||
|
||
if (!args.code.match(/^[a-z]{2}(?:_[a-z]{2,4})?$/)) { | ||
consola.error(`🚨 ${args.code} is not a valid locale code!\nExample: en or en_us`) | ||
process.exit(1) | ||
} | ||
|
||
// Create new locale export | ||
const localeExportFile = resolve(localePath, `index.ts`) | ||
await appendFile(localeExportFile, `export { default as ${args.code} } from './${args.code}'`) | ||
await sortFile(localeExportFile) | ||
|
||
// Create new locale file | ||
await fsp.copyFile(originLocaleFilePath, newLocaleFilePath) | ||
const localeFile = await fsp.readFile(newLocaleFilePath, 'utf-8') | ||
const rewrittenLocaleFile = localeFile | ||
.replace(/name: '(.*)',/, `name: '${args.name}',`) | ||
.replace(/code: '(.*)',/, `code: '${normalizeLocale(args.code)}',${(args.dir && args.dir !== 'ltr') ? `\n dir: '${args.dir}',` : ''}`) | ||
await fsp.writeFile(newLocaleFilePath, rewrittenLocaleFile) | ||
|
||
consola.success(`🪄 Generated ${newLocaleFilePath}`) | ||
} | ||
}) |
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
Oops, something went wrong.