@svgrid/create-studio 0.2.2 → 0.5.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/index.mjs
CHANGED
|
@@ -17,6 +17,7 @@ import { existsSync } from 'node:fs'
|
|
|
17
17
|
import { dirname, join, basename, resolve, isAbsolute } from 'node:path'
|
|
18
18
|
import { fileURLToPath } from 'node:url'
|
|
19
19
|
import { createInterface } from 'node:readline/promises'
|
|
20
|
+
import { createRequire } from 'node:module'
|
|
20
21
|
import { stdin, stdout } from 'node:process'
|
|
21
22
|
|
|
22
23
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
@@ -85,11 +86,14 @@ ${color('bold', 'Examples')}
|
|
|
85
86
|
npm create @svgrid/studio@latest my-app -- --from ./prisma/schema.prisma
|
|
86
87
|
npm create @svgrid/studio@latest my-app -- --project ./studio.config.json
|
|
87
88
|
npm create @svgrid/studio@latest my-app -- --theme material --dark
|
|
89
|
+
|
|
90
|
+
${color('bold', 'Have a database?')}
|
|
91
|
+
npx @svgrid/studio init reads your tables and scaffolds a page for each.
|
|
88
92
|
`)
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
const THEME_IDS = [
|
|
92
|
-
'shadcn', 'tailwind', 'material', 'excel', 'fluent', 'carbon', 'sap',
|
|
96
|
+
'ember', 'shadcn', 'tailwind', 'material', 'excel', 'fluent', 'carbon', 'sap',
|
|
93
97
|
'salesforce', 'atlassian', 'github', 'antd', 'ag-alpine', 'bootstrap',
|
|
94
98
|
'vercel', 'linear', 'notion', 'nord', 'dracula', 'catppuccin',
|
|
95
99
|
]
|
|
@@ -265,12 +269,36 @@ async function renameBack(dir) {
|
|
|
265
269
|
}
|
|
266
270
|
}
|
|
267
271
|
|
|
272
|
+
/**
|
|
273
|
+
* The @svgrid/enterprise version this scaffolder was published alongside, read
|
|
274
|
+
* from the copy npm actually installed next to it.
|
|
275
|
+
*/
|
|
276
|
+
async function svgridVersion() {
|
|
277
|
+
try {
|
|
278
|
+
const require = createRequire(import.meta.url)
|
|
279
|
+
const pkg = JSON.parse(await readFile(require.resolve('@svgrid/enterprise/package.json'), 'utf8'))
|
|
280
|
+
return typeof pkg.version === 'string' && /^\d+\.\d+\.\d+/.test(pkg.version) ? pkg.version : null
|
|
281
|
+
} catch {
|
|
282
|
+
return null
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
268
286
|
async function setProjectName(destDir, name) {
|
|
269
287
|
const pkgPath = join(destDir, 'package.json')
|
|
270
288
|
if (!existsSync(pkgPath)) return
|
|
271
289
|
try {
|
|
272
290
|
const pkg = JSON.parse(await readFile(pkgPath, 'utf8'))
|
|
273
291
|
pkg.name = name
|
|
292
|
+
// The template ships "latest" so it stays honest in the repo, but a
|
|
293
|
+
// scaffolded app pins to the version this scaffolder was built against.
|
|
294
|
+
// Left as "latest", `npm install` resolves it fresh on every machine and
|
|
295
|
+
// every day, so an unrelated publish can break an app nobody touched.
|
|
296
|
+
const version = await svgridVersion()
|
|
297
|
+
if (version && pkg.dependencies) {
|
|
298
|
+
for (const dep of ['@svgrid/grid', '@svgrid/enterprise']) {
|
|
299
|
+
if (pkg.dependencies[dep] === 'latest') pkg.dependencies[dep] = `^${version}`
|
|
300
|
+
}
|
|
301
|
+
}
|
|
274
302
|
await writeFile(pkgPath, JSON.stringify(pkg, null, 2) + '\n')
|
|
275
303
|
} catch {
|
|
276
304
|
// leave the template's name if it isn't valid JSON for some reason
|
|
@@ -376,6 +404,7 @@ async function main() {
|
|
|
376
404
|
stdout.write(` cd ${target}\n`)
|
|
377
405
|
stdout.write(` npm install\n`)
|
|
378
406
|
stdout.write(` npm run dev\n\n`)
|
|
407
|
+
stdout.write(`${color('dim', 'Have a database?')} npx @svgrid/studio init ${color('dim', 'reads your tables and scaffolds a page for each.')}\n`)
|
|
379
408
|
stdout.write(`${color('dim', 'Docs:')} https://svgrid.com/docs/enterprise/studio/\n\n`)
|
|
380
409
|
}
|
|
381
410
|
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"type": "commercial",
|
|
5
5
|
"url": "https://svgrid.com/pricing"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.5.0",
|
|
8
8
|
"description": "Scaffold a runnable SvGrid Studio data app in one command: npm create @svgrid/studio@latest",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"license": "MIT",
|
|
@@ -41,6 +41,6 @@
|
|
|
41
41
|
"node": ">=18"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@svgrid/enterprise": "^2.
|
|
44
|
+
"@svgrid/enterprise": "^2.5.0"
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import '../app.css'
|
|
3
|
-
import { page } from '$app/
|
|
3
|
+
import { page } from '$app/state'
|
|
4
4
|
|
|
5
5
|
let { children } = $props()
|
|
6
6
|
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
<a class="app__brand" href="/">My Studio App</a>
|
|
18
18
|
<nav class="app__links">
|
|
19
19
|
{#each nav as item (item.href)}
|
|
20
|
-
<a class="app__link" class:is-active={
|
|
20
|
+
<a class="app__link" class:is-active={page.url.pathname === item.href} href={item.href}>{item.label}</a>
|
|
21
21
|
{/each}
|
|
22
22
|
</nav>
|
|
23
23
|
<span class="app__foot">Built with SvGrid Studio</span>
|