@svadmin/create 0.20.0 → 0.21.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/README.md CHANGED
@@ -134,3 +134,22 @@ overwriting local standards:
134
134
  bunx @svadmin/create guidance .
135
135
  bunx @svadmin/create guidance . --write
136
136
  ```
137
+
138
+ ## Add Lite routes to an existing SPA
139
+
140
+ Lite is an optional SvelteKit server-rendered route tree. It does not modify the
141
+ existing SPA or add IE11 branches to the SPA bundle. In a project that already
142
+ has a SvelteKit `src/routes` directory, run:
143
+
144
+ ```bash
145
+ # Preview the files first; nothing is written
146
+ bunx @svadmin/create lite init .
147
+
148
+ # Generate the shared adapter and dynamic CRUD routes
149
+ bunx @svadmin/create lite init . --write
150
+ ```
151
+
152
+ The generator creates one `[resource]` route for all resources plus the shared
153
+ `src/lib/svadmin-lite.ts` adapter. Your existing `$lib/admin` module only needs
154
+ to export `resources` and `dataProvider`; resources are resolved dynamically at
155
+ request time. Existing files are preserved, so rerunning the command is safe.
package/dist/index.js CHANGED
@@ -5025,8 +5025,8 @@ var require_picocolors = __commonJS(function(exports, module) {
5025
5025
  // src/index.ts
5026
5026
  var import_prompts2 = __toESM(require_prompts3(), 1);
5027
5027
  var import_picocolors2 = __toESM(require_picocolors(), 1);
5028
- import fs2 from "node:fs";
5029
- import path2 from "node:path";
5028
+ import fs3 from "node:fs";
5029
+ import path3 from "node:path";
5030
5030
  import { fileURLToPath } from "node:url";
5031
5031
  import { createRequire as createRequire2 } from "node:module";
5032
5032
  import { spawnSync } from "node:child_process";
@@ -6431,6 +6431,267 @@ function capitalize2(s) {
6431
6431
  return s.charAt(0).toUpperCase() + s.slice(1);
6432
6432
  }
6433
6433
 
6434
+ // src/lite-init.ts
6435
+ import fs2 from "node:fs";
6436
+ import path2 from "node:path";
6437
+ var GENERATED_FILES = {
6438
+ "src/lib/svadmin-lite.ts": `import { dataProvider, resources } from '$lib/admin';
6439
+ import type { ResourceDefinition } from '@svadmin/core';
6440
+
6441
+ export { dataProvider, resources };
6442
+
6443
+ export function getResource(name: string): ResourceDefinition | undefined {
6444
+ return resources.find((resource) => resource.name === name);
6445
+ }
6446
+ `,
6447
+ "src/routes/lite/+layout.ts": `export const ssr = true;
6448
+ export const csr = false;
6449
+ `,
6450
+ "src/routes/lite/+layout.server.ts": `import { resources } from '$lib/svadmin-lite';
6451
+ import type { LayoutServerLoad } from './$types';
6452
+
6453
+ export const load = (({ url }) => {
6454
+ const segments = url.pathname.split('/').filter(Boolean);
6455
+ const currentResource = segments[1] ?? '';
6456
+
6457
+ return { resources, currentResource };
6458
+ }) satisfies LayoutServerLoad;
6459
+ `,
6460
+ "src/routes/lite/+layout.svelte": `<script lang="ts">
6461
+ import type { Snippet } from 'svelte';
6462
+ import { LiteLayout } from '@svadmin/lite';
6463
+ import '@svadmin/lite/lite.css';
6464
+ import type { LayoutData } from './$types';
6465
+
6466
+ let { data, children }: { data: LayoutData; children: Snippet } = $props();
6467
+ </script>
6468
+
6469
+ <LiteLayout
6470
+ resources={data.resources}
6471
+ currentResource={data.currentResource}
6472
+ brandName="Lite Admin"
6473
+ basePath="/lite"
6474
+ >
6475
+ {@render children()}
6476
+ </LiteLayout>
6477
+ `,
6478
+ "src/routes/lite/+page.server.ts": `import { error, redirect } from '@sveltejs/kit';
6479
+ import { resources } from '$lib/svadmin-lite';
6480
+ import type { PageServerLoad } from './$types';
6481
+
6482
+ export const load = (() => {
6483
+ const firstResource = resources[0];
6484
+ if (!firstResource) throw error(404, 'No Lite resources configured');
6485
+ throw redirect(302, \`/lite/\${firstResource.name}\`);
6486
+ }) satisfies PageServerLoad;
6487
+ `,
6488
+ "src/routes/lite/[resource]/+page.server.ts": `import { error } from '@sveltejs/kit';
6489
+ import { createCrudActions, createListLoader } from '@svadmin/lite';
6490
+ import { dataProvider, getResource } from '$lib/svadmin-lite';
6491
+ import type { Actions, PageServerLoad } from './$types';
6492
+
6493
+ export const load = ((event) => {
6494
+ const resource = getResource(event.params.resource);
6495
+ if (!resource) throw error(404, \`Resource "\${event.params.resource}" not found\`);
6496
+ return createListLoader(dataProvider, resource)(event);
6497
+ }) satisfies PageServerLoad;
6498
+
6499
+ export const actions = {
6500
+ delete: (event) => {
6501
+ const resource = getResource(event.params.resource);
6502
+ if (!resource) throw error(404, \`Resource "\${event.params.resource}" not found\`);
6503
+ return createCrudActions(dataProvider, resource).delete(event);
6504
+ },
6505
+ batchDelete: (event) => {
6506
+ const resource = getResource(event.params.resource);
6507
+ if (!resource) throw error(404, \`Resource "\${event.params.resource}" not found\`);
6508
+ return createCrudActions(dataProvider, resource).batchDelete(event);
6509
+ },
6510
+ } satisfies Actions;
6511
+ `,
6512
+ "src/routes/lite/[resource]/+page.svelte": `<script lang="ts">
6513
+ import { LiteListPage } from '@svadmin/lite';
6514
+ import type { PageProps } from './$types';
6515
+
6516
+ let { data }: PageProps = $props();
6517
+ </script>
6518
+
6519
+ <LiteListPage {...data} basePath="/lite" />
6520
+ `,
6521
+ "src/routes/lite/[resource]/create/+page.server.ts": `import { error, redirect } from '@sveltejs/kit';
6522
+ import { createCrudActions } from '@svadmin/lite';
6523
+ import { dataProvider, getResource } from '$lib/svadmin-lite';
6524
+ import type { Actions, PageServerLoad } from './$types';
6525
+
6526
+ export const load = (({ params }) => {
6527
+ const resource = getResource(params.resource);
6528
+ if (!resource) throw error(404, \`Resource "\${params.resource}" not found\`);
6529
+ return { resource };
6530
+ }) satisfies PageServerLoad;
6531
+
6532
+ export const actions = {
6533
+ create: async (event) => {
6534
+ const resource = getResource(event.params.resource);
6535
+ if (!resource) throw error(404, \`Resource "\${event.params.resource}" not found\`);
6536
+ const result = await createCrudActions(dataProvider, resource).create(event);
6537
+ if (result && 'success' in result && result.success) {
6538
+ throw redirect(303, \`/lite/\${resource.name}\`);
6539
+ }
6540
+ return result;
6541
+ },
6542
+ } satisfies Actions;
6543
+ `,
6544
+ "src/routes/lite/[resource]/create/+page.svelte": `<script lang="ts">
6545
+ import { LiteCreatePage } from '@svadmin/lite';
6546
+ import type { PageProps } from './$types';
6547
+
6548
+ let { data, form }: PageProps = $props();
6549
+ </script>
6550
+
6551
+ <LiteCreatePage
6552
+ resource={data.resource}
6553
+ errors={form?.errors}
6554
+ values={form?.values}
6555
+ basePath="/lite"
6556
+ />
6557
+ `,
6558
+ "src/routes/lite/[resource]/show/[id]/+page.server.ts": `import { error } from '@sveltejs/kit';
6559
+ import { createDetailLoader } from '@svadmin/lite';
6560
+ import { dataProvider, getResource } from '$lib/svadmin-lite';
6561
+ import type { PageServerLoad } from './$types';
6562
+
6563
+ export const load = ((event) => {
6564
+ const resource = getResource(event.params.resource);
6565
+ if (!resource) throw error(404, \`Resource "\${event.params.resource}" not found\`);
6566
+ return createDetailLoader(dataProvider, resource)(event);
6567
+ }) satisfies PageServerLoad;
6568
+ `,
6569
+ "src/routes/lite/[resource]/show/[id]/+page.svelte": `<script lang="ts">
6570
+ import { LiteShowPage } from '@svadmin/lite';
6571
+ import type { PageProps } from './$types';
6572
+
6573
+ let { data }: PageProps = $props();
6574
+ </script>
6575
+
6576
+ <LiteShowPage resource={data.resource} record={data.record} basePath="/lite" />
6577
+ `,
6578
+ "src/routes/lite/[resource]/edit/[id]/+page.server.ts": `import { error, redirect } from '@sveltejs/kit';
6579
+ import { createCrudActions, createDetailLoader } from '@svadmin/lite';
6580
+ import { dataProvider, getResource } from '$lib/svadmin-lite';
6581
+ import type { Actions, PageServerLoad } from './$types';
6582
+
6583
+ export const load = ((event) => {
6584
+ const resource = getResource(event.params.resource);
6585
+ if (!resource) throw error(404, \`Resource "\${event.params.resource}" not found\`);
6586
+ return createDetailLoader(dataProvider, resource)(event);
6587
+ }) satisfies PageServerLoad;
6588
+
6589
+ export const actions = {
6590
+ update: async (event) => {
6591
+ const resource = getResource(event.params.resource);
6592
+ if (!resource) throw error(404, \`Resource "\${event.params.resource}" not found\`);
6593
+ const result = await createCrudActions(dataProvider, resource).update(event);
6594
+ if (result && 'success' in result && result.success) {
6595
+ throw redirect(303, \`/lite/\${resource.name}/show/\${event.params.id}\`);
6596
+ }
6597
+ return result;
6598
+ },
6599
+ delete: (event) => {
6600
+ const resource = getResource(event.params.resource);
6601
+ if (!resource) throw error(404, \`Resource "\${event.params.resource}" not found\`);
6602
+ return createCrudActions(dataProvider, resource).delete(event);
6603
+ },
6604
+ } satisfies Actions;
6605
+ `,
6606
+ "src/routes/lite/[resource]/edit/[id]/+page.svelte": `<script lang="ts">
6607
+ import { LiteEditPage } from '@svadmin/lite';
6608
+ import type { PageProps } from './$types';
6609
+
6610
+ let { data, form }: PageProps = $props();
6611
+ </script>
6612
+
6613
+ <LiteEditPage
6614
+ resource={data.resource}
6615
+ record={data.record}
6616
+ errors={form?.errors}
6617
+ basePath="/lite"
6618
+ />
6619
+ `
6620
+ };
6621
+ function parseLiteInitArguments(args) {
6622
+ let write = false;
6623
+ const positional = [];
6624
+ for (const argument of args) {
6625
+ if (argument === "--write")
6626
+ write = true;
6627
+ else if (argument.startsWith("-"))
6628
+ throw new Error(`Unknown option: ${argument}`);
6629
+ else
6630
+ positional.push(argument);
6631
+ }
6632
+ if (positional.length > 1) {
6633
+ throw new Error(`Expected at most one project directory, received: ${positional.join(", ")}`);
6634
+ }
6635
+ return {
6636
+ projectDirectory: path2.resolve(process.cwd(), positional[0] ?? "."),
6637
+ write
6638
+ };
6639
+ }
6640
+ function assertLiteProject(projectDirectory) {
6641
+ if (!fs2.existsSync(projectDirectory)) {
6642
+ throw new Error(`Project directory does not exist: ${projectDirectory}`);
6643
+ }
6644
+ if (!fs2.existsSync(path2.join(projectDirectory, "package.json"))) {
6645
+ throw new Error(`Not a Node project: ${path2.join(projectDirectory, "package.json")} is missing`);
6646
+ }
6647
+ if (!fs2.existsSync(path2.join(projectDirectory, "src", "routes"))) {
6648
+ throw new Error("Lite routes require a SvelteKit project with src/routes. Keep the existing SPA and add a SvelteKit Lite app alongside it.");
6649
+ }
6650
+ const adminModuleExists = ["ts", "js", "svelte"].some((extension) => fs2.existsSync(path2.join(projectDirectory, "src", "lib", `admin.${extension}`)));
6651
+ if (!adminModuleExists) {
6652
+ throw new Error("Lite routes require src/lib/admin.ts (or .js/.svelte) exporting resources and dataProvider.");
6653
+ }
6654
+ }
6655
+ function planLiteInit(projectDirectory) {
6656
+ assertLiteProject(projectDirectory);
6657
+ const entries = Object.entries(GENERATED_FILES).map(([relativePath, content]) => {
6658
+ const filePath = path2.join(projectDirectory, relativePath);
6659
+ return { filePath, relativePath, content, exists: fs2.existsSync(filePath) };
6660
+ });
6661
+ return { projectDirectory, entries };
6662
+ }
6663
+ function writeLiteInit(plan) {
6664
+ const written = [];
6665
+ const preserved = [];
6666
+ for (const entry of plan.entries) {
6667
+ if (entry.exists || fs2.existsSync(entry.filePath)) {
6668
+ preserved.push(entry.relativePath);
6669
+ continue;
6670
+ }
6671
+ fs2.mkdirSync(path2.dirname(entry.filePath), { recursive: true });
6672
+ fs2.writeFileSync(entry.filePath, entry.content);
6673
+ written.push(entry.relativePath);
6674
+ }
6675
+ return { plan, written, preserved };
6676
+ }
6677
+ function liteInitCommand(args) {
6678
+ const options = parseLiteInitArguments(args);
6679
+ const plan = planLiteInit(options.projectDirectory);
6680
+ console.log(`
6681
+ svadmin lite init — ${options.projectDirectory}`);
6682
+ for (const entry of plan.entries) {
6683
+ console.log(` ${entry.exists ? "preserve" : "add"} ${entry.relativePath}`);
6684
+ }
6685
+ if (!options.write) {
6686
+ console.log(`
6687
+ Dry run only; re-run with --write to add missing Lite routes.`);
6688
+ return;
6689
+ }
6690
+ const result = writeLiteInit(plan);
6691
+ console.log(`
6692
+ Written ${result.written.length} file(s); preserved ${result.preserved.length} existing file(s).`);
6693
+ }
6694
+
6434
6695
  // src/project-maintenance.ts
6435
6696
  import {
6436
6697
  constants,
@@ -6440,10 +6701,10 @@ import {
6440
6701
  unlinkSync,
6441
6702
  writeFileSync
6442
6703
  } from "node:fs";
6443
- function parseDependencyMap(candidate, path2) {
6704
+ function parseDependencyMap(candidate, path3) {
6444
6705
  if (candidate === undefined)
6445
6706
  return;
6446
- assertStringRecord(candidate, path2);
6707
+ assertStringRecord(candidate, path3);
6447
6708
  return { ...candidate };
6448
6709
  }
6449
6710
  function parseMaintainedPackageJson(packageJsonCandidate) {
@@ -6719,15 +6980,15 @@ function writeProjectPackageJsonUpgrade(packagePath, scaffold, backupDate) {
6719
6980
 
6720
6981
  // src/index.ts
6721
6982
  var __filename2 = fileURLToPath(import.meta.url);
6722
- var __dirname2 = path2.dirname(__filename2);
6983
+ var __dirname2 = path3.dirname(__filename2);
6723
6984
  function loadShippedScaffoldManifest() {
6724
- return loadScaffoldManifest(path2.join(__dirname2, "..", "scaffold-manifest.json"));
6985
+ return loadScaffoldManifest(path3.join(__dirname2, "..", "scaffold-manifest.json"));
6725
6986
  }
6726
6987
  function projectDirectoryFromArguments(positional) {
6727
6988
  if (positional.length > 1) {
6728
6989
  throw new Error(`Expected at most one project directory, received: ${positional.join(", ")}`);
6729
6990
  }
6730
- return path2.resolve(process.cwd(), positional[0] ?? ".");
6991
+ return path3.resolve(process.cwd(), positional[0] ?? ".");
6731
6992
  }
6732
6993
  function doctorProjectDirectory(args) {
6733
6994
  const unknownOption = args.find((argument) => argument.startsWith("-"));
@@ -6782,7 +7043,7 @@ function printDoctorReport(report, projectDirectory) {
6782
7043
  }
6783
7044
  function doctor(args) {
6784
7045
  const projectDirectory = doctorProjectDirectory(args);
6785
- const project = readMaintainedPackageJson(path2.join(projectDirectory, "package.json"));
7046
+ const project = readMaintainedPackageJson(path3.join(projectDirectory, "package.json"));
6786
7047
  const report = doctorProjectPackageJson(project, loadShippedScaffoldManifest());
6787
7048
  printDoctorReport(report, projectDirectory);
6788
7049
  process.exitCode = report.exitCode;
@@ -6817,14 +7078,14 @@ function printUpgradeExecution(upgradeExecution, projectDirectory, packagePath)
6817
7078
  }
6818
7079
  function upgrade(args) {
6819
7080
  const commandArguments = parseUpgradeArguments(args);
6820
- const packagePath = path2.join(commandArguments.projectDirectory, "package.json");
7081
+ const packagePath = path3.join(commandArguments.projectDirectory, "package.json");
6821
7082
  const scaffoldManifest = loadShippedScaffoldManifest();
6822
7083
  const upgradeExecution = commandArguments.write ? writeProjectPackageJsonUpgrade(packagePath, scaffoldManifest, new Date) : planProjectPackageFileUpgrade(packagePath, scaffoldManifest);
6823
7084
  printUpgradeExecution(upgradeExecution, commandArguments.projectDirectory, packagePath);
6824
7085
  }
6825
7086
  var GUIDANCE_FILES = ["DESIGN.md", "AGENTS.md"];
6826
7087
  function missingGuidanceFiles(projectDirectory) {
6827
- return GUIDANCE_FILES.filter((fileName) => !fs2.existsSync(path2.join(projectDirectory, fileName)));
7088
+ return GUIDANCE_FILES.filter((fileName) => !fs3.existsSync(path3.join(projectDirectory, fileName)));
6828
7089
  }
6829
7090
  function printGuidancePlan(projectDirectory, missingFiles) {
6830
7091
  console.log();
@@ -6836,15 +7097,15 @@ function printGuidancePlan(projectDirectory, missingFiles) {
6836
7097
  }
6837
7098
  function installMissingGuidanceFiles(guidanceDirectory, projectDirectory, missingFiles) {
6838
7099
  for (const fileName of missingFiles) {
6839
- fs2.copyFileSync(path2.join(guidanceDirectory, fileName), path2.join(projectDirectory, fileName));
7100
+ fs3.copyFileSync(path3.join(guidanceDirectory, fileName), path3.join(projectDirectory, fileName));
6840
7101
  }
6841
7102
  }
6842
7103
  function guidance(args) {
6843
7104
  const { projectDirectory, write } = parseUpgradeArguments(args);
6844
- const guidanceDirectory = path2.join(__dirname2, "..", "guidance");
6845
- if (!fs2.existsSync(projectDirectory))
7105
+ const guidanceDirectory = path3.join(__dirname2, "..", "guidance");
7106
+ if (!fs3.existsSync(projectDirectory))
6846
7107
  throw new Error(`Project directory does not exist: ${projectDirectory}`);
6847
- if (!fs2.existsSync(guidanceDirectory))
7108
+ if (!fs3.existsSync(guidanceDirectory))
6848
7109
  throw new Error("Shipped svadmin guidance files are missing");
6849
7110
  const missingFiles = missingGuidanceFiles(projectDirectory);
6850
7111
  if (missingFiles.length === 0) {
@@ -6879,7 +7140,7 @@ async function init() {
6879
7140
  validate: (value) => {
6880
7141
  if (!value.trim())
6881
7142
  return "Project name is required";
6882
- if (fs2.existsSync(value.trim()) && fs2.readdirSync(value.trim()).length > 0) {
7143
+ if (fs3.existsSync(value.trim()) && fs3.readdirSync(value.trim()).length > 0) {
6883
7144
  return "Directory already exists and is not empty";
6884
7145
  }
6885
7146
  return true;
@@ -6922,34 +7183,34 @@ Operation cancelled.
6922
7183
  `));
6923
7184
  return;
6924
7185
  }
6925
- const projectDir = path2.resolve(process.cwd(), response.projectName.trim());
6926
- if (!fs2.existsSync(projectDir)) {
6927
- fs2.mkdirSync(projectDir, { recursive: true });
7186
+ const projectDir = path3.resolve(process.cwd(), response.projectName.trim());
7187
+ if (!fs3.existsSync(projectDir)) {
7188
+ fs3.mkdirSync(projectDir, { recursive: true });
6928
7189
  }
6929
7190
  console.log(`
6930
7191
  ${import_picocolors2.default.bold("Scaffolding")} project in ${import_picocolors2.default.green(projectDir)}...
6931
7192
  `);
6932
- const templateDir = path2.join(__dirname2, "..", "template");
6933
- const guidanceDir = path2.join(__dirname2, "..", "guidance");
7193
+ const templateDir = path3.join(__dirname2, "..", "template");
7194
+ const guidanceDir = path3.join(__dirname2, "..", "guidance");
6934
7195
  const scaffoldManifest = loadShippedScaffoldManifest();
6935
7196
  function copyDir(src, dest) {
6936
- fs2.mkdirSync(dest, { recursive: true });
6937
- const entries = fs2.readdirSync(src, { withFileTypes: true });
7197
+ fs3.mkdirSync(dest, { recursive: true });
7198
+ const entries = fs3.readdirSync(src, { withFileTypes: true });
6938
7199
  for (const entry of entries) {
6939
- const srcPath = path2.join(src, entry.name);
6940
- const destPath = path2.join(dest, entry.name === "_gitignore" ? ".gitignore" : entry.name);
7200
+ const srcPath = path3.join(src, entry.name);
7201
+ const destPath = path3.join(dest, entry.name === "_gitignore" ? ".gitignore" : entry.name);
6941
7202
  if (entry.isDirectory()) {
6942
7203
  copyDir(srcPath, destPath);
6943
7204
  } else {
6944
- fs2.copyFileSync(srcPath, destPath);
7205
+ fs3.copyFileSync(srcPath, destPath);
6945
7206
  }
6946
7207
  }
6947
7208
  }
6948
- if (fs2.existsSync(templateDir)) {
7209
+ if (fs3.existsSync(templateDir)) {
6949
7210
  copyDir(templateDir, projectDir);
6950
7211
  console.log(import_picocolors2.default.green(" ✔") + " Template files copied");
6951
7212
  }
6952
- if (fs2.existsSync(guidanceDir)) {
7213
+ if (fs3.existsSync(guidanceDir)) {
6953
7214
  copyDir(guidanceDir, projectDir);
6954
7215
  console.log(import_picocolors2.default.green(" ✔") + " AI and design guidance copied");
6955
7216
  }
@@ -6958,10 +7219,10 @@ ${import_picocolors2.default.bold("Scaffolding")} project in ${import_picocolors
6958
7219
  dataProvider: response.dataProvider,
6959
7220
  authProvider: response.authProvider
6960
7221
  });
6961
- fs2.writeFileSync(path2.join(projectDir, "package.json"), `${JSON.stringify(packageJson, null, 2)}
7222
+ fs3.writeFileSync(path3.join(projectDir, "package.json"), `${JSON.stringify(packageJson, null, 2)}
6962
7223
  `);
6963
7224
  console.log(import_picocolors2.default.green(" ✔") + " package.json generated");
6964
- fs2.writeFileSync(path2.join(projectDir, ".gitignore"), `node_modules
7225
+ fs3.writeFileSync(path3.join(projectDir, ".gitignore"), `node_modules
6965
7226
  dist
6966
7227
  .svelte-kit
6967
7228
  .env
@@ -6971,7 +7232,7 @@ dist
6971
7232
  console.log(import_picocolors2.default.green(" ✔") + " .gitignore generated");
6972
7233
  const dpLabel = response.dataProvider === "simple-rest" ? "Simple REST" : response.dataProvider === "supabase" ? "Supabase" : response.dataProvider === "graphql" ? "GraphQL" : "Custom";
6973
7234
  const authLabel = response.authProvider === "mock" ? "Mock (demo)" : response.authProvider === "jwt" ? "JWT" : response.authProvider === "supabase" ? "Supabase Auth" : "None";
6974
- fs2.writeFileSync(path2.join(projectDir, "README.md"), `# ${response.projectName}
7235
+ fs3.writeFileSync(path3.join(projectDir, "README.md"), `# ${response.projectName}
6975
7236
 
6976
7237
  Built with [svadmin](https://github.com/vibeunion/svadmin) — Headless Admin Framework for Svelte 5.
6977
7238
 
@@ -7062,33 +7323,33 @@ async function eject(args) {
7062
7323
  let uiSrcDir;
7063
7324
  try {
7064
7325
  const require2 = createRequire2(import.meta.url);
7065
- const uiPkg = path2.dirname(require2.resolve("@svadmin/ui/package.json"));
7066
- uiSrcDir = path2.join(uiPkg, "src", "components");
7326
+ const uiPkg = path3.dirname(require2.resolve("@svadmin/ui/package.json"));
7327
+ uiSrcDir = path3.join(uiPkg, "src", "components");
7067
7328
  } catch {
7068
- const nm = path2.join(process.cwd(), "node_modules", "@svadmin", "ui", "src", "components");
7069
- if (fs2.existsSync(nm)) {
7329
+ const nm = path3.join(process.cwd(), "node_modules", "@svadmin", "ui", "src", "components");
7330
+ if (fs3.existsSync(nm)) {
7070
7331
  uiSrcDir = nm;
7071
7332
  } else {
7072
7333
  console.log(import_picocolors2.default.red(" ✗ Cannot find @svadmin/ui. Run `bun install` first."));
7073
7334
  return;
7074
7335
  }
7075
7336
  }
7076
- const destDir = path2.join(process.cwd(), "src", "components", "svadmin");
7077
- fs2.mkdirSync(destDir, { recursive: true });
7337
+ const destDir = path3.join(process.cwd(), "src", "components", "svadmin");
7338
+ fs3.mkdirSync(destDir, { recursive: true });
7078
7339
  let copied = 0;
7079
7340
  for (const name of toEject) {
7080
- const srcFile = path2.join(uiSrcDir, `${name}.svelte`);
7081
- const srcFileAlt = path2.join(uiSrcDir, "fields", `${name}.svelte`);
7082
- const src = fs2.existsSync(srcFile) ? srcFile : fs2.existsSync(srcFileAlt) ? srcFileAlt : null;
7341
+ const srcFile = path3.join(uiSrcDir, `${name}.svelte`);
7342
+ const srcFileAlt = path3.join(uiSrcDir, "fields", `${name}.svelte`);
7343
+ const src = fs3.existsSync(srcFile) ? srcFile : fs3.existsSync(srcFileAlt) ? srcFileAlt : null;
7083
7344
  if (!src) {
7084
7345
  console.log(import_picocolors2.default.yellow(` ⚠ ${name}.svelte not found in @svadmin/ui (skipped)`));
7085
7346
  continue;
7086
7347
  }
7087
- let content = fs2.readFileSync(src, "utf-8");
7348
+ let content = fs3.readFileSync(src, "utf-8");
7088
7349
  content = content.replace(/from\s+['"]\.\/ui\//g, "from '@svadmin/ui/components/ui/");
7089
7350
  content = content.replace(/from\s+['"]\.\/((?!ui\/)[^'"]+)['"]/g, "from './$1'");
7090
- const destFile = path2.join(destDir, `${name}.svelte`);
7091
- fs2.writeFileSync(destFile, content);
7351
+ const destFile = path3.join(destDir, `${name}.svelte`);
7352
+ fs3.writeFileSync(destFile, content);
7092
7353
  console.log(import_picocolors2.default.green(" ✔") + ` ${name}.svelte → src/components/svadmin/`);
7093
7354
  copied++;
7094
7355
  }
@@ -7125,6 +7386,14 @@ if (subcommand === "eject") {
7125
7386
  runCommand(() => guidance(rest));
7126
7387
  } else if (subcommand === "infer") {
7127
7388
  runCommand(() => inferCommand(rest));
7389
+ } else if (subcommand === "lite") {
7390
+ if (rest[0] !== "init") {
7391
+ runCommand(() => {
7392
+ throw new Error("Usage: create-svadmin lite init [project-directory] [--write]");
7393
+ });
7394
+ } else {
7395
+ runCommand(() => liteInitCommand(rest.slice(1)));
7396
+ }
7128
7397
  } else {
7129
7398
  runCommand(init);
7130
7399
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svadmin/create",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Scaffolding tool for svadmin projects",
5
5
  "type": "module",
6
6
  "bin": {
@@ -27,7 +27,7 @@
27
27
  "@types/node": "^26.4.0",
28
28
  "@types/prompts": "^2.4.9",
29
29
  "typescript": "^7.0.2",
30
- "@svadmin/core": "^0.45.0"
30
+ "@svadmin/core": "^0.46.0"
31
31
  },
32
32
  "keywords": [
33
33
  "svadmin",
@@ -10,8 +10,8 @@
10
10
  "check": "svelte-check --tsconfig ./tsconfig.json"
11
11
  },
12
12
  "dependencies": {
13
- "@svadmin/core": "^0.45.0",
14
- "@svadmin/ui": "^0.63.0",
13
+ "@svadmin/core": "^0.46.0",
14
+ "@svadmin/ui": "^0.64.0",
15
15
  "@tanstack/svelte-query": "^6.1.48",
16
16
  "highlight.js": "^11.12.0",
17
17
  "@lucide/svelte": "^1.35.0"
@@ -32,16 +32,16 @@
32
32
  "@refinedev/core": "^5.0.12"
33
33
  },
34
34
  "simple-rest": {
35
- "@svadmin/simple-rest": "^0.9.18",
35
+ "@svadmin/simple-rest": "^0.9.19",
36
36
  "@refinedev/simple-rest": "^6.0.1"
37
37
  },
38
38
  "supabase": {
39
- "@svadmin/supabase": "^0.13.0",
39
+ "@svadmin/supabase": "^0.13.1",
40
40
  "@supabase/supabase-js": "^2.112.4",
41
41
  "@refinedev/supabase": "^6.0.2"
42
42
  },
43
43
  "graphql": {
44
- "@svadmin/graphql": "^0.9.18",
44
+ "@svadmin/graphql": "^0.9.19",
45
45
  "@refinedev/graphql": "^8.0.1",
46
46
  "graphql-request": "^7.4.0",
47
47
  "graphql": "^16.8.0"