@svgrid/create-studio 0.1.0 → 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,46 @@
1
+ This repository is a multi-package workspace. Different packages ship
2
+ under different licenses. The authoritative license for each package is
3
+ the LICENSE file inside that package directory.
4
+
5
+ ------------------------------------------------------------------------
6
+ Per-package licensing
7
+ ------------------------------------------------------------------------
8
+
9
+ packages/grid/ MIT (terms below, and packages/grid/LICENSE)
10
+ packages/enterprise/ Commercial - see packages/enterprise/LICENSE
11
+ packages/mcp/ Commercial - see packages/mcp/LICENSE
12
+ website/ Proprietary - see website/LICENSE
13
+
14
+ Only `@svgrid/grid` is open source. Everything else in this
15
+ repository (the Pro feature pack, the MCP server, the marketing +
16
+ docs website, and any other package added later that does not ship
17
+ its own MIT LICENSE) is proprietary and may not be copied, modified,
18
+ or redistributed without a paid license. Source is visible in this
19
+ repository for transparency and for paying customers; visibility does
20
+ not grant a license.
21
+
22
+ ------------------------------------------------------------------------
23
+ MIT License (applies ONLY to packages/grid)
24
+ ------------------------------------------------------------------------
25
+
26
+ MIT License
27
+
28
+ Copyright (c) 2026 jQWidgets Ltd
29
+
30
+ Permission is hereby granted, free of charge, to any person obtaining a copy
31
+ of this software and associated documentation files (the "Software"), to deal
32
+ in the Software without restriction, including without limitation the rights
33
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
34
+ copies of the Software, and to permit persons to whom the Software is
35
+ furnished to do so, subject to the following conditions:
36
+
37
+ The above copyright notice and this permission notice shall be included in all
38
+ copies or substantial portions of the Software.
39
+
40
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
41
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
42
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
43
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
44
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
45
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
46
+ SOFTWARE.
package/README.md CHANGED
@@ -39,11 +39,26 @@ and generate the exact screens + blocks you arranged:
39
39
  npm create @svgrid/studio@latest my-app -- --project ./studio.config.json
40
40
  ```
41
41
 
42
+ ## Pick a theme
43
+
44
+ Running interactively, you'll be asked to pick a theme (one of `@svgrid/grid`'s
45
+ 19 built-in presets - shadcn, Tailwind, Material, Excel, Fluent, and more) and
46
+ whether to start in light or dark mode. Both are also available as flags for
47
+ scripted use:
48
+
49
+ ```bash
50
+ npm create @svgrid/studio@latest my-app -- --theme material --dark
51
+ ```
52
+
53
+ Skipped when generating `--project ./studio.config.json` - that export already
54
+ carries the theme you chose in the designer.
55
+
42
56
  ## What you get
43
57
 
44
58
  A full [SvelteKit](https://svelte.dev/docs/kit) app - not a snippet - wired end to end:
45
59
 
46
- - **Nav shell + modern theme** (plain CSS, light/dark aware, no Tailwind).
60
+ - **Nav shell + theme** (plain CSS, light/dark aware, no Tailwind) - your pick
61
+ from `@svgrid/grid`'s built-in presets.
47
62
  - **Two linked entities** - Customers and Orders - where an order references a
48
63
  customer through a **searchable lookup** field.
49
64
  - **Grid + modal CRUD** on every screen: sort, filter, global search, paging,
package/index.mjs CHANGED
@@ -41,7 +41,7 @@ const c = {
41
41
  const color = stdout.isTTY ? (k, s) => `${c[k]}${s}${c.reset}` : (_k, s) => s
42
42
 
43
43
  function parseArgs(argv) {
44
- const args = { _: [], force: false, help: false, from: null, project: null }
44
+ const args = { _: [], force: false, help: false, from: null, project: null, theme: null, dark: false }
45
45
  for (let i = 0; i < argv.length; i++) {
46
46
  const a = argv[i]
47
47
  if (a === '--help' || a === '-h') args.help = true
@@ -50,6 +50,9 @@ function parseArgs(argv) {
50
50
  else if (a.startsWith('--from=')) args.from = a.slice('--from='.length)
51
51
  else if (a === '--project') args.project = argv[++i]
52
52
  else if (a.startsWith('--project=')) args.project = a.slice('--project='.length)
53
+ else if (a === '--theme') args.theme = argv[++i]
54
+ else if (a.startsWith('--theme=')) args.theme = a.slice('--theme='.length)
55
+ else if (a === '--dark') args.dark = true
53
56
  else if (!a.startsWith('-')) args._.push(a)
54
57
  }
55
58
  return args
@@ -72,6 +75,8 @@ ${color('bold', 'Options')}
72
75
  schema instead of the seeded example (auto-detected).
73
76
  --project <path> Generate the app from a studio.config.json exported by the
74
77
  visual designer (screens + blocks, not just entities).
78
+ --theme <id> One of: ${THEME_IDS.join(', ')} (default: tailwind).
79
+ --dark Start the app in dark mode.
75
80
  --force Scaffold into a non-empty directory.
76
81
 
77
82
  ${color('bold', 'Examples')}
@@ -79,9 +84,83 @@ ${color('bold', 'Examples')}
79
84
  pnpm create @svgrid/studio my-data-app
80
85
  npm create @svgrid/studio@latest my-app -- --from ./prisma/schema.prisma
81
86
  npm create @svgrid/studio@latest my-app -- --project ./studio.config.json
87
+ npm create @svgrid/studio@latest my-app -- --theme material --dark
82
88
  `)
83
89
  }
84
90
 
91
+ const THEME_IDS = [
92
+ 'shadcn', 'tailwind', 'material', 'excel', 'fluent', 'carbon', 'sap',
93
+ 'salesforce', 'atlassian', 'github', 'antd', 'ag-alpine', 'bootstrap',
94
+ 'vercel', 'linear', 'notion', 'nord', 'dracula', 'catppuccin',
95
+ ]
96
+
97
+ /**
98
+ * Resolve the theme + mode to apply: from `--theme`/`--dark` flags, or (in a
99
+ * TTY) an interactive prompt; otherwise the default (tailwind, light). Reuses
100
+ * `@svgrid/enterprise/studio`'s own preset list, so the picker can never drift
101
+ * from the canonical set in `@svgrid/grid/themes`.
102
+ */
103
+ async function promptTheme(args, ask, interactive) {
104
+ let studio
105
+ try {
106
+ studio = await import('@svgrid/enterprise/studio')
107
+ } catch {
108
+ return null // theming is best-effort; the template's own default stands in.
109
+ }
110
+
111
+ let themeId = args.theme ? args.theme.trim().toLowerCase() : null
112
+ if (themeId && !studio.getStudioTheme(themeId)) {
113
+ stdout.write(`${color('yellow', '!')} Unknown theme "${themeId}" - using tailwind. (${THEME_IDS.join(', ')})\n`)
114
+ themeId = null
115
+ }
116
+ if (!themeId && interactive) {
117
+ const list = studio.studioThemes.map((t, i) => ` ${i + 1}. ${t.name} ${color('dim', `(${t.id})`)}`).join('\n')
118
+ stdout.write(`\n${color('bold', 'Theme')}\n${list}\n`)
119
+ const choice = await ask('Pick a number or id:', 'tailwind')
120
+ const byIndex = studio.studioThemes[Number(choice) - 1]
121
+ themeId = byIndex ? byIndex.id : (studio.getStudioTheme(choice.trim().toLowerCase())?.id ?? 'tailwind')
122
+ }
123
+ themeId ??= 'tailwind'
124
+
125
+ let dark = args.dark
126
+ if (!dark && interactive) {
127
+ const a = await ask('Start in dark mode? (y/N)', 'N')
128
+ dark = /^y(es)?$/i.test(a)
129
+ }
130
+
131
+ return { themeId, dark, name: studio.getStudioTheme(themeId)?.name ?? themeId, studio }
132
+ }
133
+
134
+ /** Rewrite the template's `app.css` (between the `svgrid-theme` markers) with
135
+ * the resolved `--sg-*` tokens for the chosen theme + mode, and set
136
+ * `data-theme="dark"` on `<html>` when dark mode was picked. */
137
+ async function applyTheme(destDir, choice) {
138
+ if (!choice) return
139
+ const { themeId, dark, studio } = choice
140
+ const light = studio.resolveThemeTokens({ preset: themeId, mode: 'light' })
141
+ const darkTokens = studio.resolveThemeTokens({ preset: themeId, mode: 'dark' })
142
+ const block = (selector, tokens, scheme) => {
143
+ const lines = Object.entries(tokens).map(([k, v]) => ` ${k}: ${v};`).join('\n')
144
+ return `${selector} {\n${lines}\n color-scheme: ${scheme};\n}`
145
+ }
146
+ const css = `${block(':root', light, 'light')}\n${block(":root[data-theme='dark']", darkTokens, 'dark')}`
147
+
148
+ const cssPath = join(destDir, 'src', 'app.css')
149
+ const cssText = await readFile(cssPath, 'utf8')
150
+ const marked = /\/\* svgrid-theme:start \*\/[\s\S]*?\/\* svgrid-theme:end \*\//
151
+ if (marked.test(cssText)) {
152
+ await writeFile(cssPath, cssText.replace(marked, `/* svgrid-theme:start */\n${css}\n/* svgrid-theme:end */`))
153
+ }
154
+
155
+ if (dark) {
156
+ const htmlPath = join(destDir, 'src', 'app.html')
157
+ const htmlText = await readFile(htmlPath, 'utf8').catch(() => null)
158
+ if (htmlText && !/data-theme=/.test(htmlText)) {
159
+ await writeFile(htmlPath, htmlText.replace('<html lang="en">', '<html lang="en" data-theme="dark">'))
160
+ }
161
+ }
162
+ }
163
+
85
164
  /**
86
165
  * Generate the app from a studio.config.json (the visual designer's export):
87
166
  * parse it, emit each screen's composed blocks, and replace the seeded example.
@@ -265,11 +344,16 @@ async function main() {
265
344
  process.exit(1)
266
345
  }
267
346
 
347
+ // 2b. Theme + light/dark mode. Skipped for --project - a designer export
348
+ // already carries its own theme, applied straight into +layout.svelte.
349
+ const themeChoice = args.project ? null : await promptTheme(args, ask, interactive)
350
+ if (rl) rl.close()
351
+
268
352
  // 3. Scaffold.
269
353
  await mkdir(destDir, { recursive: true })
270
354
  await copyTemplate(TEMPLATE_DIR, destDir)
271
355
  await setProjectName(destDir, projectName)
272
- if (rl) rl.close()
356
+ await applyTheme(destDir, themeChoice)
273
357
 
274
358
  // 3b. Generate from a designer project (--project) or a schema file (--from).
275
359
  let entities = null
@@ -290,6 +374,9 @@ async function main() {
290
374
  // 4. Next steps.
291
375
  const rel = isAbsolute(target) || target.startsWith('.') ? target : `./${target}`
292
376
  stdout.write(`\n${color('green', '✔')} Scaffolded ${color('bold', projectName)} into ${rel}\n`)
377
+ if (themeChoice) {
378
+ stdout.write(` ${color('dim', 'theme')} ${themeChoice.name}${themeChoice.dark ? ' (dark)' : ''}\n`)
379
+ }
293
380
  if (entities) {
294
381
  stdout.write(` ${color('dim', 'from')} ${source} ${color('dim', '->')} ${entities.join(', ')}\n`)
295
382
  }
package/package.json CHANGED
@@ -1,39 +1,42 @@
1
- {
2
- "name": "@svgrid/create-studio",
3
- "version": "0.1.0",
4
- "description": "Scaffold a runnable SvGrid Studio data app in one command: npm create @svgrid/studio@latest",
5
- "type": "module",
6
- "license": "MIT",
7
- "author": "jQWidgets Ltd",
8
- "homepage": "https://www.svgrid.com",
9
- "repository": {
10
- "type": "git",
11
- "url": "https://github.com/sv-grid/sv-grid.git",
12
- "directory": "packages/create-studio"
13
- },
14
- "keywords": [
15
- "svelte",
16
- "sveltekit",
17
- "data-grid",
18
- "datagrid",
19
- "data-app",
20
- "crud",
21
- "svgrid",
22
- "studio",
23
- "create",
24
- "scaffold",
25
- "starter",
26
- "template"
27
- ],
28
- "bin": "index.mjs",
29
- "files": [
30
- "index.mjs",
31
- "templates"
32
- ],
33
- "engines": {
34
- "node": ">=18"
35
- },
36
- "dependencies": {
37
- "@svgrid/enterprise": "workspace:*"
38
- }
39
- }
1
+ {
2
+ "name": "@svgrid/create-studio",
3
+ "version": "0.1.2",
4
+ "description": "Scaffold a runnable SvGrid Studio data app in one command: npm create @svgrid/studio@latest",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "jQWidgets Ltd",
8
+ "homepage": "https://www.svgrid.com",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/sv-grid/sv-grid.git",
12
+ "directory": "packages/create-studio"
13
+ },
14
+ "keywords": [
15
+ "svelte",
16
+ "sveltekit",
17
+ "data-grid",
18
+ "datagrid",
19
+ "data-app",
20
+ "crud",
21
+ "svgrid",
22
+ "studio",
23
+ "create",
24
+ "scaffold",
25
+ "starter",
26
+ "template"
27
+ ],
28
+ "bin": "index.mjs",
29
+ "files": [
30
+ "index.mjs",
31
+ "templates"
32
+ ],
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "engines": {
37
+ "node": ">=18"
38
+ },
39
+ "dependencies": {
40
+ "@svgrid/enterprise": "^2.0.2"
41
+ }
42
+ }
@@ -1,14 +1,18 @@
1
1
  /* App theme + chrome. The grid ships its own styles; these tokens drive the
2
- * accent + surfaces (light / dark friendly), the nav shell, and the buttons. */
2
+ * accent + surfaces (light / dark friendly), the nav shell, and the buttons.
3
+ * The block between the markers is rewritten by create-studio's CLI to match
4
+ * the theme + mode you pick when scaffolding - edit freely afterwards. */
5
+ /* svgrid-theme:start */
3
6
  :root {
4
7
  --sg-accent: #4f46e5;
5
8
  color-scheme: light dark;
6
9
  }
10
+ /* svgrid-theme:end */
7
11
 
8
12
  * { box-sizing: border-box; }
9
13
  html, body { margin: 0; height: 100%; }
10
14
  body {
11
- font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
15
+ font-family: var(--sg-font, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
12
16
  color: var(--sg-fg, #0f172a);
13
17
  background: var(--sg-bg, #ffffff);
14
18
  }