@uipkge/nuxt 0.1.22 → 0.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.mjs ADDED
@@ -0,0 +1,169 @@
1
+ #!/usr/bin/env node
2
+ import { execSync } from 'child_process'
3
+ import fs from 'fs'
4
+ import path from 'path'
5
+
6
+ const PKG_DIR = path.resolve(import.meta.dirname, '..')
7
+ const TARGET_DIR = process.cwd()
8
+ const distDir = path.join(PKG_DIR, 'dist')
9
+
10
+ const isInstalled = fs.existsSync(distDir)
11
+
12
+ function run(cmd, opts = {}) {
13
+ console.log(`> ${cmd}`)
14
+ execSync(cmd, { stdio: 'inherit', ...opts })
15
+ }
16
+
17
+ function exists(file) {
18
+ return fs.existsSync(path.join(TARGET_DIR, file))
19
+ }
20
+
21
+ console.log('\n🚀 Setting up @uipkge/nuxt in', TARGET_DIR, '\n')
22
+
23
+ if (isInstalled) {
24
+ console.log('📦 @uipkge/nuxt already built, skipping build step')
25
+ } else {
26
+ console.log('📦 Building @uipkge/nuxt...')
27
+ run('npm run build', { cwd: PKG_DIR })
28
+ }
29
+
30
+ // 2. Install @nuxtjs/i18n
31
+ console.log('\n📥 Installing @nuxtjs/i18n...')
32
+ run('npm install @nuxtjs/i18n@latest', { cwd: TARGET_DIR })
33
+
34
+ // 3. Link local @uipkge/nuxt only if not already installed
35
+ if (!isInstalled) {
36
+ console.log('\n🔗 Linking @uipkge/nuxt...')
37
+ run('npm link', { cwd: PKG_DIR })
38
+ run('npm link @uipkge/nuxt', { cwd: TARGET_DIR })
39
+ }
40
+
41
+ // 4. Create i18n folder structure
42
+ const i18nDir = path.join(TARGET_DIR, 'app/i18n/locales')
43
+ if (!fs.existsSync(i18nDir)) {
44
+ console.log('\n📁 Creating i18n folders...')
45
+ fs.mkdirSync(i18nDir, { recursive: true })
46
+ }
47
+
48
+ // 5. Create i18n.config.ts
49
+ const i18nConfigPath = path.join(TARGET_DIR, 'app/i18n/i18n.config.ts')
50
+ if (!exists('app/i18n/i18n.config.ts')) {
51
+ console.log('📝 Creating i18n.config.ts...')
52
+ fs.writeFileSync(i18nConfigPath, `export default defineI18nConfig(() => ({
53
+ numberFormats: {
54
+ en: { currency: { style: 'currency', currency: 'USD' } },
55
+ es: { currency: { style: 'currency', currency: 'EUR' } },
56
+ fr: { currency: { style: 'currency', currency: 'EUR' } },
57
+ ar: { currency: { style: 'currency', currency: 'SAR' } },
58
+ he: { currency: { style: 'currency', currency: 'ILS' } },
59
+ de: { currency: { style: 'currency', currency: 'EUR' } },
60
+ },
61
+ datetimeFormats: {
62
+ en: { short: { year: 'numeric', month: 'short', day: 'numeric' } },
63
+ es: { short: { year: 'numeric', month: 'short', day: 'numeric' } },
64
+ fr: { short: { year: 'numeric', month: 'short', day: 'numeric' } },
65
+ ar: { short: { year: 'numeric', month: 'short', day: 'numeric' } },
66
+ he: { short: { year: 'numeric', month: 'short', day: 'numeric' } },
67
+ de: { short: { year: 'numeric', month: 'short', day: 'numeric' } },
68
+ },
69
+ }))
70
+ `)
71
+ }
72
+
73
+ // 6. Create locale files
74
+ const locales = {
75
+ en: { nav_features: 'Features', nav_docs: 'Docs', nav_pricing: 'Pricing', hero_title: 'Translate faster, ship with confidence', hero_subtitle: 'i18now keeps your translations in sync as you code.', footer_tagline: 'Built for developers who ship fast.' },
76
+ es: { nav_features: 'Características', nav_docs: 'Docs', nav_pricing: 'Precios', hero_title: 'Traduce más rápido, envía con confianza', hero_subtitle: 'i18now mantiene tus traducciones sincronizadas.', footer_tagline: 'Construido para desarrolladores rápidos.' },
77
+ }
78
+ for (const [code, messages] of Object.entries(locales)) {
79
+ const localePath = path.join(i18nDir, `${code}.json`)
80
+ if (!fs.existsSync(localePath)) {
81
+ const data = {
82
+ nav: { features: messages.nav_features, docs: messages.nav_docs, pricing: messages.nav_pricing },
83
+ hero: { title: messages.hero_title, subtitle: messages.hero_subtitle },
84
+ footer: { tagline: messages.footer_tagline }
85
+ }
86
+ fs.writeFileSync(localePath, JSON.stringify(data, null, 2))
87
+ }
88
+ }
89
+
90
+ // 7. Update nuxt.config.ts
91
+ const nuxtConfigPath = path.join(TARGET_DIR, 'nuxt.config.ts')
92
+ console.log('\n⚙️ Updating nuxt.config.ts...')
93
+ const nuxtConfigContent = `export default defineNuxtConfig({
94
+ compatibilityDate: '2025-07-15',
95
+ devtools: { enabled: true },
96
+ modules: ['@nuxtjs/i18n', '@uipkge/nuxt'],
97
+ i18n: {
98
+ defaultLocale: 'en',
99
+ locales: [
100
+ { code: 'en', file: 'en.json' },
101
+ { code: 'es', file: 'es.json' },
102
+ { code: 'fr', file: 'fr.json' },
103
+ { code: 'ar', file: 'ar.json' },
104
+ { code: 'he', file: 'he.json' },
105
+ { code: 'de', file: 'de.json' },
106
+ ],
107
+ langDir: 'app/i18n/locales/',
108
+ strategy: 'no_prefix',
109
+ detectBrowserLanguage: { useCookie: true, cookieKey: 'i18n_locale' },
110
+ vueI18n: './app/i18n/i18n.config.ts',
111
+ },
112
+ i18now: {
113
+ projectId: process.env.I18NOW_PROJECT_ID ?? '',
114
+ apiKey: process.env.I18NOW_API_KEY ?? '',
115
+ host: process.env.I18NOW_HOST ?? 'https://i18now.com',
116
+ cdnUrl: process.env.I18NOW_CDN_URL ?? 'https://cdn.i18now.com',
117
+ environment: process.env.I18NOW_ENV ?? 'dev',
118
+ syncIn: ['development'],
119
+ },
120
+ })
121
+ `
122
+ fs.writeFileSync(nuxtConfigPath, nuxtConfigContent)
123
+
124
+ // 8. Create test page
125
+ const pagesDir = path.join(TARGET_DIR, 'app/pages')
126
+ if (!fs.existsSync(pagesDir)) {
127
+ fs.mkdirSync(pagesDir, { recursive: true })
128
+ }
129
+
130
+ const indexPagePath = path.join(pagesDir, 'index.vue')
131
+ if (!fs.existsSync(indexPagePath)) {
132
+ console.log('📄 Creating test page...')
133
+ fs.writeFileSync(indexPagePath, `<script setup>
134
+ const { t, locale, setLocale, te, n, d } = useI18now()
135
+
136
+ const locales = [
137
+ { code: 'en', label: 'English', flag: '🇬🇧' },
138
+ { code: 'es', label: 'Español', flag: '🇪🇸' },
139
+ { code: 'fr', label: 'Français', flag: '🇫🇷' },
140
+ { code: 'ar', label: 'العربية', flag: '🇸🇦' },
141
+ { code: 'he', label: 'עברית', flag: '🇮🇱' },
142
+ { code: 'de', label: 'Deutsch', flag: '🇩🇪' },
143
+ ]
144
+
145
+ const dir = computed(() => {
146
+ try {
147
+ return new Intl.Locale(locale.value).textInfo?.direction ?? 'ltr'
148
+ } catch {
149
+ return 'ltr'
150
+ }
151
+ })
152
+ </script>
153
+
154
+ <template>
155
+ <div :dir="dir">
156
+ <h1>{{ t('hero.title', 'Hello World') }}</h1>
157
+ <p>{{ t('hero.subtitle', 'Welcome to i18now') }}</p>
158
+ <select v-model="locale">
159
+ <option v-for="l in locales" :key="l.code" :value="l.code">
160
+ {{ l.flag }} {{ l.label }}
161
+ </option>
162
+ </select>
163
+ </div>
164
+ </template>
165
+ `)
166
+ }
167
+
168
+ console.log('\n✅ Setup complete!')
169
+ console.log('Run: npm run dev\n')
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.0.0"
6
6
  },
7
- "version": "0.1.22",
7
+ "version": "0.1.23",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "unknown"
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@uipkge/nuxt",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
+ "bin": {
7
+ "@uipkge/nuxt": "./bin/cli.mjs"
8
+ },
6
9
  "exports": {
7
10
  ".": {
8
11
  "types": "./dist/module.d.mts",
@@ -11,11 +14,9 @@
11
14
  },
12
15
  "main": "./dist/module.mjs",
13
16
  "types": "./dist/module.d.mts",
14
- "engines": {
15
- "node": ">=18.0.0"
16
- },
17
17
  "files": [
18
- "dist"
18
+ "dist",
19
+ "bin"
19
20
  ],
20
21
  "dependencies": {
21
22
  "@nuxt/kit": "^3.0.0"