create-vuetify 0.0.6-beta.2

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.
@@ -0,0 +1,117 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+ import { x } from 'tinyexec'
4
+ import { afterAll, beforeAll, describe, expect, it } from 'vitest'
5
+
6
+ const CLI_PATH = path.resolve(__dirname, '../dist/index.mjs')
7
+ // Assuming templates are at the root of the repo
8
+ const TEMPLATES_PATH = path.resolve(__dirname, '../../../templates')
9
+ const TEMP_DIR = path.resolve(__dirname, '../.test-tmp')
10
+
11
+ const TIMEOUT = 10_000 // 10s
12
+
13
+ describe('create-vuetify matrix', () => {
14
+ beforeAll(() => {
15
+ if (!fs.existsSync(TEMP_DIR)) {
16
+ fs.mkdirSync(TEMP_DIR)
17
+ }
18
+ })
19
+
20
+ afterAll(() => {
21
+ // fs.rmSync(TEMP_DIR, { recursive: true, force: true })
22
+ })
23
+
24
+ const runCli = async (args: string[], cwd: string) => {
25
+ try {
26
+ const proc = x('node', [CLI_PATH, ...args], {
27
+ nodeOptions: {
28
+ cwd,
29
+ env: {
30
+ ...process.env,
31
+ VUETIFY_CLI_TEMPLATES_PATH: TEMPLATES_PATH,
32
+ },
33
+ },
34
+ throwOnError: true,
35
+ })
36
+
37
+ for await (const line of proc) {
38
+ console.log(line)
39
+ }
40
+
41
+ return await proc
42
+ } catch (error: any) {
43
+ console.error('Command failed:', error.message)
44
+ console.error('STDOUT:', error.stdout)
45
+ console.error('STDERR:', error.stderr)
46
+ throw error
47
+ }
48
+ }
49
+
50
+ const matrix = [
51
+ // Vue + JS
52
+ { name: 'vue-js', args: ['--type=vue', '--no-typescript', '--features='] },
53
+ // Vue + TS
54
+ { name: 'vue-ts', args: ['--type=vue', '--typescript', '--features='] },
55
+ // Vue + TS + Router
56
+ { name: 'vue-ts-router', args: ['--type=vue', '--typescript', '--features=router'] },
57
+ // Vue + TS + Pinia
58
+ { name: 'vue-ts-pinia', args: ['--type=vue', '--typescript', '--features=pinia'] },
59
+ // Vue + TS + ESLint
60
+ { name: 'vue-ts-eslint', args: ['--type=vue', '--typescript', '--features=eslint'] },
61
+ // Vue + TS + All
62
+ { name: 'vue-ts-all', args: ['--type=vue', '--typescript', '--features=router,pinia,eslint'] },
63
+
64
+ // Nuxt
65
+ { name: 'nuxt', args: ['--type=nuxt', '--features='] },
66
+ // Nuxt + Pinia
67
+ { name: 'nuxt-pinia', args: ['--type=nuxt', '--features=pinia'] },
68
+ // Nuxt + Vuetify Module
69
+ { name: 'nuxt-module', args: ['--type=nuxt', '--features=vuetify-nuxt-module'] },
70
+ // Nuxt + All
71
+ { name: 'nuxt-all', args: ['--type=nuxt', '--features=pinia,eslint,vuetify-nuxt-module'] },
72
+ ]
73
+
74
+ for (const { name, args } of matrix) {
75
+ it(`should create project ${name}`, async () => {
76
+ const projectName = `test-${name}`
77
+ const projectPath = path.join(TEMP_DIR, projectName)
78
+
79
+ // Clean up previous run
80
+ if (fs.existsSync(projectPath)) {
81
+ fs.rmSync(projectPath, { recursive: true, force: true })
82
+ }
83
+
84
+ const cliArgs = [`--name=${projectName}`, ...args, '--package-manager=pnpm', '--force', '--no-install', '--no-interactive']
85
+
86
+ console.log(`Running: create-vuetify ${cliArgs.join(' ')}`)
87
+ const { stdout, stderr } = await runCli(cliArgs, TEMP_DIR)
88
+ console.log('STDOUT:', stdout)
89
+ if (stderr) {
90
+ console.error('STDERR:', stderr)
91
+ }
92
+
93
+ expect(fs.existsSync(projectPath)).toBe(true)
94
+ expect(fs.existsSync(path.join(projectPath, 'package.json'))).toBe(true)
95
+
96
+ // Basic check for file structure
97
+ if (args.includes('vue')) {
98
+ expect(fs.existsSync(path.join(projectPath, 'src/main.ts')) || fs.existsSync(path.join(projectPath, 'src/main.js'))).toBe(true)
99
+ } else if (args.includes('nuxt')) {
100
+ expect(fs.existsSync(path.join(projectPath, 'nuxt.config.ts'))).toBe(true)
101
+
102
+ // Check for modules/vuetify.ts and dependencies
103
+ const hasModuleFeature = args.some(arg => arg.includes('vuetify-nuxt-module'))
104
+ if (hasModuleFeature) {
105
+ expect(fs.existsSync(path.join(projectPath, 'modules/vuetify.ts'))).toBe(false)
106
+ } else {
107
+ expect(fs.existsSync(path.join(projectPath, 'modules/vuetify.ts'))).toBe(true)
108
+
109
+ const pkg = JSON.parse(fs.readFileSync(path.join(projectPath, 'package.json'), 'utf8'))
110
+ expect(pkg.devDependencies).toHaveProperty('vite-plugin-vuetify')
111
+ expect(pkg.devDependencies).toHaveProperty('@vuetify/loader-shared')
112
+ expect(pkg.devDependencies).toHaveProperty('pathe')
113
+ }
114
+ }
115
+ }, TIMEOUT)
116
+ }
117
+ })
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from 'tsdown/config'
2
+
3
+ export default defineConfig({
4
+ entry: './src/index.ts',
5
+ banner: `#!/usr/bin/env node`,
6
+ exports: true,
7
+ })