@svadmin/create 0.6.0 → 0.7.0

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/package.json CHANGED
@@ -1,13 +1,19 @@
1
1
  {
2
2
  "name": "@svadmin/create",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Scaffolding tool for svadmin projects",
5
5
  "type": "module",
6
6
  "bin": {
7
- "create-svadmin": "./index.js"
7
+ "create-svadmin": "./dist/index.js"
8
8
  },
9
+ "files": [
10
+ "dist",
11
+ "template"
12
+ ],
9
13
  "scripts": {
10
- "start": "node index.js"
14
+ "build": "bun build src/index.ts --outdir dist --target node --format esm",
15
+ "sync-template": "bun src/sync-template.ts",
16
+ "prepublishOnly": "bun run build"
11
17
  },
12
18
  "dependencies": {
13
19
  "prompts": "^2.4.2",
@@ -15,7 +21,8 @@
15
21
  },
16
22
  "devDependencies": {
17
23
  "@types/node": "^20.0.0",
18
- "@types/prompts": "^2.4.9"
24
+ "@types/prompts": "^2.4.9",
25
+ "typescript": "^5.7.0"
19
26
  },
20
27
  "keywords": [
21
28
  "svadmin",
package/CHANGELOG.md DELETED
@@ -1,16 +0,0 @@
1
- # Changelog
2
-
3
- ## [0.6.0](https://github.com/zuohuadong/svadmin/compare/create-svadmin-v0.5.14...create-svadmin-v0.6.0) (2026-03-26)
4
-
5
-
6
- ### Features
7
-
8
- * svadmin — headless admin framework for Svelte 5 ([d67041a](https://github.com/zuohuadong/svadmin/commit/d67041a4b6aec77702b0490fe934d3207a88daac))
9
- * **ui:** Sheet, Collapsible, 8 new components + 12 UI enhancements (v0.3.19-v0.3.22) ([58b0a57](https://github.com/zuohuadong/svadmin/commit/58b0a57e24f7caaa9cd5d445a4ada1b20edda261))
10
-
11
-
12
- ### Bug Fixes
13
-
14
- * **create-svadmin:** synchronize css templates with new-york oklch styling and remove conflicting mappings ([82c9ba5](https://github.com/zuohuadong/svadmin/commit/82c9ba507dcf74938f34052d44a9dd9681cfcd76))
15
- * **packages:** add repository URLs to all package.json for npm provenance ([e84978c](https://github.com/zuohuadong/svadmin/commit/e84978cda2d616d37caf388d48adf5315dfe6f13))
16
- * **ui:** resolve typography font loading and adjust badge styling ([c7a0c6b](https://github.com/zuohuadong/svadmin/commit/c7a0c6bea0d2ec36b3a926a547236dc254b9e6f1))
package/index.js DELETED
@@ -1,212 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import fs from 'fs';
4
- import path from 'path';
5
- import { fileURLToPath } from 'url';
6
- import prompts from 'prompts';
7
- import pc from 'picocolors';
8
-
9
- const __filename = fileURLToPath(import.meta.url);
10
- const __dirname = path.dirname(__filename);
11
-
12
- async function init() {
13
- console.log();
14
- console.log(pc.cyan(' ╔═══════════════════════════════════╗'));
15
- console.log(pc.cyan(' ║ ') + pc.bold('create-svadmin') + pc.cyan(' ║'));
16
- console.log(pc.cyan(' ║ ') + pc.dim('Headless Admin for Svelte 5') + pc.cyan(' ║'));
17
- console.log(pc.cyan(' ╚═══════════════════════════════════╝'));
18
- console.log();
19
-
20
- const response = await prompts([
21
- {
22
- type: 'text',
23
- name: 'projectName',
24
- message: 'Project name:',
25
- initial: 'svadmin-app',
26
- validate: (value) => {
27
- if (!value.trim()) return 'Project name is required';
28
- if (fs.existsSync(value.trim()) && fs.readdirSync(value.trim()).length > 0) {
29
- return 'Directory already exists and is not empty';
30
- }
31
- return true;
32
- }
33
- },
34
- {
35
- type: 'select',
36
- name: 'dataProvider',
37
- message: 'Data Provider:',
38
- choices: [
39
- { title: 'Simple REST', value: 'simple-rest', description: 'Standard JSON APIs / JSON Server' },
40
- { title: 'Supabase', value: 'supabase', description: 'PostgreSQL Backend-as-a-Service' },
41
- { title: 'GraphQL', value: 'graphql', description: 'Generic GraphQL endpoints' },
42
- { title: 'Custom', value: 'none', description: 'Implement your own DataProvider' }
43
- ],
44
- initial: 0
45
- },
46
- {
47
- type: 'select',
48
- name: 'authProvider',
49
- message: 'Auth Provider:',
50
- choices: [
51
- { title: 'Mock (Demo)', value: 'mock', description: 'Built-in mock for development' },
52
- { title: 'Simple REST JWT', value: 'jwt', description: 'JWT-based auth via REST API' },
53
- { title: 'Supabase Auth', value: 'supabase', description: 'Supabase authentication' },
54
- { title: 'None', value: 'none', description: 'No authentication' }
55
- ],
56
- initial: 0
57
- },
58
- {
59
- type: 'confirm',
60
- name: 'installDeps',
61
- message: 'Install dependencies now?',
62
- initial: true
63
- }
64
- ]);
65
-
66
- if (!response.projectName) {
67
- console.log(pc.red('\nOperation cancelled.\n'));
68
- return;
69
- }
70
-
71
- const projectDir = path.resolve(process.cwd(), response.projectName.trim());
72
-
73
- if (!fs.existsSync(projectDir)) {
74
- fs.mkdirSync(projectDir, { recursive: true });
75
- }
76
-
77
- console.log(`\n${pc.bold('Scaffolding')} project in ${pc.green(projectDir)}...\n`);
78
-
79
- // 1. Copy template files
80
- const templateDir = path.join(__dirname, 'template');
81
-
82
- function copyDir(src, dest) {
83
- fs.mkdirSync(dest, { recursive: true });
84
- const entries = fs.readdirSync(src, { withFileTypes: true });
85
- for (const entry of entries) {
86
- const srcPath = path.join(src, entry.name);
87
- const destPath = path.join(dest, entry.name === '_gitignore' ? '.gitignore' : entry.name);
88
- if (entry.isDirectory()) {
89
- copyDir(srcPath, destPath);
90
- } else {
91
- fs.copyFileSync(srcPath, destPath);
92
- }
93
- }
94
- }
95
-
96
- if (fs.existsSync(templateDir)) {
97
- copyDir(templateDir, projectDir);
98
- console.log(pc.green(' ✔') + ' Template files copied');
99
- }
100
-
101
- // 2. Generate package.json
102
- const packageJson = {
103
- name: response.projectName,
104
- version: '0.1.0',
105
- private: true,
106
- type: 'module',
107
- scripts: {
108
- dev: 'vite',
109
- build: 'vite build',
110
- preview: 'vite preview',
111
- check: 'svelte-check --tsconfig ./tsconfig.json'
112
- },
113
- dependencies: {
114
- '@svadmin/core': '^0.0.6',
115
- '@svadmin/ui': '^0.0.6',
116
- '@tanstack/svelte-query': '^6.0.0',
117
- 'lucide-svelte': '^0.475.0',
118
- },
119
- devDependencies: {
120
- '@sveltejs/vite-plugin-svelte': '^5.0.0',
121
- 'svelte': '^5.20.0',
122
- 'svelte-check': '^4.0.0',
123
- 'tailwindcss': '^3.4.17',
124
- 'typescript': '^5.7.0',
125
- 'vite': '^6.1.0',
126
- }
127
- };
128
-
129
- // Add data provider dependency
130
- const dpMap = {
131
- 'simple-rest': { '@svadmin/simple-rest': '^0.0.6' },
132
- 'supabase': { '@svadmin/supabase': '^0.0.6', '@supabase/supabase-js': '^2.0.0' },
133
- 'graphql': { '@svadmin/graphql': '^0.0.6', 'graphql-request': '^7.1.0', 'graphql': '^16.8.0' },
134
- };
135
- if (dpMap[response.dataProvider]) {
136
- Object.assign(packageJson.dependencies, dpMap[response.dataProvider]);
137
- }
138
-
139
- // Add auth provider dependency
140
- if (response.authProvider === 'supabase' && response.dataProvider !== 'supabase') {
141
- packageJson.dependencies['@svadmin/supabase'] = '^0.0.6';
142
- packageJson.dependencies['@supabase/supabase-js'] = '^2.0.0';
143
- }
144
- if (response.authProvider === 'jwt' && response.dataProvider !== 'simple-rest') {
145
- packageJson.dependencies['@svadmin/simple-rest'] = '^0.0.6';
146
- }
147
-
148
- fs.writeFileSync(path.join(projectDir, 'package.json'), JSON.stringify(packageJson, null, 2));
149
- console.log(pc.green(' ✔') + ' package.json generated');
150
-
151
- // 3. Generate .gitignore
152
- fs.writeFileSync(path.join(projectDir, '.gitignore'), `node_modules
153
- dist
154
- .svelte-kit
155
- .env
156
- .env.local
157
- *.local
158
- `);
159
- console.log(pc.green(' ✔') + ' .gitignore generated');
160
-
161
- // 4. Generate README
162
- fs.writeFileSync(path.join(projectDir, 'README.md'), `# ${response.projectName}
163
-
164
- Built with [svadmin](https://github.com/zuohuadong/svadmin) — Headless Admin Framework for Svelte 5.
165
-
166
- ## Getting Started
167
-
168
- \`\`\`bash
169
- bun install
170
- bun run dev
171
- \`\`\`
172
-
173
- ## Stack
174
-
175
- - **UI**: Svelte 5 + Shadcn Svelte + TailwindCSS
176
- - **Data**: ${response.dataProvider === 'simple-rest' ? 'Simple REST' : response.dataProvider === 'supabase' ? 'Supabase' : response.dataProvider === 'graphql' ? 'GraphQL' : 'Custom'} DataProvider
177
- - **Auth**: ${response.authProvider === 'mock' ? 'Mock (demo)' : response.authProvider === 'jwt' ? 'JWT' : response.authProvider === 'supabase' ? 'Supabase Auth' : 'None'}
178
- - **State**: TanStack Query v6
179
- `);
180
- console.log(pc.green(' ✔') + ' README.md generated');
181
-
182
- // 5. Install dependencies
183
- if (response.installDeps) {
184
- console.log(`\n${pc.bold('Installing dependencies...')}\n`);
185
- const { execSync } = await import('child_process');
186
- try {
187
- execSync('bun install', { cwd: projectDir, stdio: 'inherit' });
188
- } catch {
189
- try {
190
- execSync('npm install', { cwd: projectDir, stdio: 'inherit' });
191
- } catch {
192
- console.log(pc.yellow('\n ⚠ Auto-install failed. Run `bun install` or `npm install` manually.'));
193
- }
194
- }
195
- }
196
-
197
- // 6. Done!
198
- console.log();
199
- console.log(pc.green(pc.bold(' ✔ Project ready!')));
200
- console.log();
201
- console.log(' Next steps:');
202
- console.log(` ${pc.cyan(`cd ${response.projectName}`)}`);
203
- if (!response.installDeps) {
204
- console.log(` ${pc.cyan('bun install')}`);
205
- }
206
- console.log(` ${pc.cyan('bun run dev')}`);
207
- console.log();
208
- console.log(` Docs: ${pc.blue('https://github.com/zuohuadong/svadmin')}`);
209
- console.log();
210
- }
211
-
212
- init().catch(console.error);
package/sync-template.js DELETED
@@ -1,47 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { fileURLToPath } from 'url';
4
-
5
- const __filename = fileURLToPath(import.meta.url);
6
- const __dirname = path.dirname(__filename);
7
-
8
- const sourceDir = path.resolve(__dirname, '../../example');
9
- const targetDir = path.resolve(__dirname, 'template');
10
-
11
- function copyRecursiveSync(src, dest) {
12
- const exists = fs.existsSync(src);
13
- const stats = exists && fs.statSync(src);
14
- const isDirectory = exists && stats.isDirectory();
15
-
16
- if (isDirectory) {
17
- if (path.basename(src) === 'node_modules' || path.basename(src) === '.svelte-kit' || path.basename(src) === 'dist') return;
18
-
19
- fs.mkdirSync(dest, { recursive: true });
20
- fs.readdirSync(src).forEach((childItemName) => {
21
- copyRecursiveSync(path.join(src, childItemName), path.join(dest, childItemName));
22
- });
23
- } else {
24
- // Skip package.json and lockfiles as they are generated by the CLI
25
- if (['package.json', 'bun.lockb', 'pnpm-lock.yaml', 'package-lock.json'].includes(path.basename(src))) return;
26
- fs.copyFileSync(src, dest);
27
- }
28
- }
29
-
30
- // Clean and recreate template
31
- if (fs.existsSync(targetDir)) {
32
- fs.rmSync(targetDir, { recursive: true, force: true });
33
- }
34
- fs.mkdirSync(targetDir, { recursive: true });
35
-
36
- // Copy example source
37
- copyRecursiveSync(sourceDir, targetDir);
38
-
39
- // Re-write package.json in the template is not needed as the CLI generates it!
40
- // BUT we should rename .gitignore to _gitignore because npm publish ignores .gitignore
41
- const gitignoreSrc = path.join(targetDir, '.gitignore');
42
- const gitignoreDest = path.join(targetDir, '_gitignore');
43
- if (fs.existsSync(gitignoreSrc)) {
44
- fs.renameSync(gitignoreSrc, gitignoreDest);
45
- }
46
-
47
- console.log('Template synced successfully from /example!');