@svadmin/create 0.21.0 → 0.22.1

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/dist/index.js CHANGED
@@ -5024,9 +5024,9 @@ var require_picocolors = __commonJS(function(exports, module) {
5024
5024
 
5025
5025
  // src/index.ts
5026
5026
  var import_prompts2 = __toESM(require_prompts3(), 1);
5027
- var import_picocolors2 = __toESM(require_picocolors(), 1);
5028
- import fs3 from "node:fs";
5029
- import path3 from "node:path";
5027
+ var import_picocolors3 = __toESM(require_picocolors(), 1);
5028
+ import fs4 from "node:fs";
5029
+ import path4 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";
@@ -5998,6 +5998,10 @@ function parseInferArguments(args) {
5998
5998
  options.primaryKey = args[++i];
5999
5999
  } else if (arg.startsWith("--primary-key=")) {
6000
6000
  options.primaryKey = arg.slice(14);
6001
+ } else if (arg === "--fields") {
6002
+ options.fields = args[++i];
6003
+ } else if (arg.startsWith("--fields=")) {
6004
+ options.fields = arg.slice(9);
6001
6005
  } else if (arg === "--header" || arg === "-H") {
6002
6006
  const headerLine = args[++i] ?? "";
6003
6007
  const colonIndex = headerLine.indexOf(":");
@@ -6431,9 +6435,85 @@ function capitalize2(s) {
6431
6435
  return s.charAt(0).toUpperCase() + s.slice(1);
6432
6436
  }
6433
6437
 
6434
- // src/lite-init.ts
6438
+ // src/generate-command.ts
6439
+ var import_picocolors2 = __toESM(require_picocolors(), 1);
6435
6440
  import fs2 from "node:fs";
6436
6441
  import path2 from "node:path";
6442
+ function parseGenerateArguments(args) {
6443
+ return parseInferArguments(args);
6444
+ }
6445
+ async function generateCommand(args) {
6446
+ const options = parseGenerateArguments(args);
6447
+ if (options.resource && options.fields) {
6448
+ const resourceName = options.resource;
6449
+ const primaryKey = options.primaryKey ?? "id";
6450
+ const fieldDefs = options.fields.split(",").map((f) => {
6451
+ const [key, typeRaw] = f.split(":");
6452
+ const type = typeRaw || "text";
6453
+ return {
6454
+ key: key.trim(),
6455
+ label: key.trim().charAt(0).toUpperCase() + key.trim().slice(1),
6456
+ type,
6457
+ required: key.trim() === primaryKey
6458
+ };
6459
+ });
6460
+ const mockSample = {};
6461
+ for (const f of fieldDefs) {
6462
+ mockSample[f.key] = f.type === "number" ? 1 : f.type === "boolean" ? true : `sample_${f.key}`;
6463
+ }
6464
+ const inferRes = inferResource(resourceName, [mockSample], { primaryKey });
6465
+ const resources = [
6466
+ {
6467
+ name: resourceName,
6468
+ label: resourceName.charAt(0).toUpperCase() + resourceName.slice(1),
6469
+ primaryKey,
6470
+ fields: fieldDefs
6471
+ }
6472
+ ];
6473
+ const bundles = new Map([[resourceName, inferRes]]);
6474
+ const files = planGeneratedFiles(resources, bundles, options.format);
6475
+ let wrote = false;
6476
+ if (options.outDir && options.write) {
6477
+ const targetDir = path2.resolve(process.cwd(), options.outDir);
6478
+ for (const file of files) {
6479
+ const fullPath = path2.join(targetDir, file.relativePath);
6480
+ fs2.mkdirSync(path2.dirname(fullPath), { recursive: true });
6481
+ fs2.writeFileSync(fullPath, file.content, "utf-8");
6482
+ }
6483
+ wrote = true;
6484
+ }
6485
+ printInferResult({
6486
+ resources,
6487
+ bundles,
6488
+ files,
6489
+ sourceDescription: `manual schema: ${options.fields}`,
6490
+ wrote,
6491
+ outDir: options.outDir
6492
+ });
6493
+ return;
6494
+ }
6495
+ if (options.url || options.file) {
6496
+ const result = await executeInfer(options);
6497
+ printInferResult(result);
6498
+ return;
6499
+ }
6500
+ console.log(`
6501
+ ${import_picocolors2.default.bold("svadmin generate")} — Generate complete Resource Definitions, Schemas, and CRUD pages.
6502
+
6503
+ ${import_picocolors2.default.bold("USAGE:")}
6504
+ svadmin generate --resource <name> --fields <field:type,...> [OPTIONS]
6505
+ svadmin generate --file <schema.json|openapi.yaml|schema.graphql> [OPTIONS]
6506
+ svadmin generate --url <api-url|openapi-url> [OPTIONS]
6507
+
6508
+ ${import_picocolors2.default.bold("EXAMPLES:")}
6509
+ svadmin generate --resource posts --fields "id:number,title:text,content:textarea,published:boolean" --out-dir src/resources --write
6510
+ svadmin generate --file openapi.json --out-dir src/resources --write
6511
+ `);
6512
+ }
6513
+
6514
+ // src/lite-init.ts
6515
+ import fs3 from "node:fs";
6516
+ import path3 from "node:path";
6437
6517
  var GENERATED_FILES = {
6438
6518
  "src/lib/svadmin-lite.ts": `import { dataProvider, resources } from '$lib/admin';
6439
6519
  import type { ResourceDefinition } from '@svadmin/core';
@@ -6633,21 +6713,21 @@ function parseLiteInitArguments(args) {
6633
6713
  throw new Error(`Expected at most one project directory, received: ${positional.join(", ")}`);
6634
6714
  }
6635
6715
  return {
6636
- projectDirectory: path2.resolve(process.cwd(), positional[0] ?? "."),
6716
+ projectDirectory: path3.resolve(process.cwd(), positional[0] ?? "."),
6637
6717
  write
6638
6718
  };
6639
6719
  }
6640
6720
  function assertLiteProject(projectDirectory) {
6641
- if (!fs2.existsSync(projectDirectory)) {
6721
+ if (!fs3.existsSync(projectDirectory)) {
6642
6722
  throw new Error(`Project directory does not exist: ${projectDirectory}`);
6643
6723
  }
6644
- if (!fs2.existsSync(path2.join(projectDirectory, "package.json"))) {
6645
- throw new Error(`Not a Node project: ${path2.join(projectDirectory, "package.json")} is missing`);
6724
+ if (!fs3.existsSync(path3.join(projectDirectory, "package.json"))) {
6725
+ throw new Error(`Not a Node project: ${path3.join(projectDirectory, "package.json")} is missing`);
6646
6726
  }
6647
- if (!fs2.existsSync(path2.join(projectDirectory, "src", "routes"))) {
6727
+ if (!fs3.existsSync(path3.join(projectDirectory, "src", "routes"))) {
6648
6728
  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
6729
  }
6650
- const adminModuleExists = ["ts", "js", "svelte"].some((extension) => fs2.existsSync(path2.join(projectDirectory, "src", "lib", `admin.${extension}`)));
6730
+ const adminModuleExists = ["ts", "js", "svelte"].some((extension) => fs3.existsSync(path3.join(projectDirectory, "src", "lib", `admin.${extension}`)));
6651
6731
  if (!adminModuleExists) {
6652
6732
  throw new Error("Lite routes require src/lib/admin.ts (or .js/.svelte) exporting resources and dataProvider.");
6653
6733
  }
@@ -6655,8 +6735,8 @@ function assertLiteProject(projectDirectory) {
6655
6735
  function planLiteInit(projectDirectory) {
6656
6736
  assertLiteProject(projectDirectory);
6657
6737
  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) };
6738
+ const filePath = path3.join(projectDirectory, relativePath);
6739
+ return { filePath, relativePath, content, exists: fs3.existsSync(filePath) };
6660
6740
  });
6661
6741
  return { projectDirectory, entries };
6662
6742
  }
@@ -6664,12 +6744,12 @@ function writeLiteInit(plan) {
6664
6744
  const written = [];
6665
6745
  const preserved = [];
6666
6746
  for (const entry of plan.entries) {
6667
- if (entry.exists || fs2.existsSync(entry.filePath)) {
6747
+ if (entry.exists || fs3.existsSync(entry.filePath)) {
6668
6748
  preserved.push(entry.relativePath);
6669
6749
  continue;
6670
6750
  }
6671
- fs2.mkdirSync(path2.dirname(entry.filePath), { recursive: true });
6672
- fs2.writeFileSync(entry.filePath, entry.content);
6751
+ fs3.mkdirSync(path3.dirname(entry.filePath), { recursive: true });
6752
+ fs3.writeFileSync(entry.filePath, entry.content);
6673
6753
  written.push(entry.relativePath);
6674
6754
  }
6675
6755
  return { plan, written, preserved };
@@ -6701,10 +6781,10 @@ import {
6701
6781
  unlinkSync,
6702
6782
  writeFileSync
6703
6783
  } from "node:fs";
6704
- function parseDependencyMap(candidate, path3) {
6784
+ function parseDependencyMap(candidate, path4) {
6705
6785
  if (candidate === undefined)
6706
6786
  return;
6707
- assertStringRecord(candidate, path3);
6787
+ assertStringRecord(candidate, path4);
6708
6788
  return { ...candidate };
6709
6789
  }
6710
6790
  function parseMaintainedPackageJson(packageJsonCandidate) {
@@ -6980,15 +7060,15 @@ function writeProjectPackageJsonUpgrade(packagePath, scaffold, backupDate) {
6980
7060
 
6981
7061
  // src/index.ts
6982
7062
  var __filename2 = fileURLToPath(import.meta.url);
6983
- var __dirname2 = path3.dirname(__filename2);
7063
+ var __dirname2 = path4.dirname(__filename2);
6984
7064
  function loadShippedScaffoldManifest() {
6985
- return loadScaffoldManifest(path3.join(__dirname2, "..", "scaffold-manifest.json"));
7065
+ return loadScaffoldManifest(path4.join(__dirname2, "..", "scaffold-manifest.json"));
6986
7066
  }
6987
7067
  function projectDirectoryFromArguments(positional) {
6988
7068
  if (positional.length > 1) {
6989
7069
  throw new Error(`Expected at most one project directory, received: ${positional.join(", ")}`);
6990
7070
  }
6991
- return path3.resolve(process.cwd(), positional[0] ?? ".");
7071
+ return path4.resolve(process.cwd(), positional[0] ?? ".");
6992
7072
  }
6993
7073
  function doctorProjectDirectory(args) {
6994
7074
  const unknownOption = args.find((argument) => argument.startsWith("-"));
@@ -7024,52 +7104,52 @@ function upgradeChangeMessage(change) {
7024
7104
  return `update ${change.packageName} from ${change.from ?? "missing"} to ${change.to}`;
7025
7105
  }
7026
7106
  function printDoctorIssue(issue) {
7027
- const marker = issue.kind === "drift" || issue.kind === "section" ? import_picocolors2.default.yellow(" ⚠") : import_picocolors2.default.red(" ✗");
7107
+ const marker = issue.kind === "drift" || issue.kind === "section" ? import_picocolors3.default.yellow(" ⚠") : import_picocolors3.default.red(" ✗");
7028
7108
  console.log(`${marker} ${doctorIssueMessage(issue)}`);
7029
- console.log(import_picocolors2.default.dim(` → ${issue.action}`));
7109
+ console.log(import_picocolors3.default.dim(` → ${issue.action}`));
7030
7110
  }
7031
7111
  function printDoctorReport(report, projectDirectory) {
7032
7112
  console.log();
7033
- console.log(import_picocolors2.default.bold(`svadmin doctor — ${projectDirectory}`));
7113
+ console.log(import_picocolors3.default.bold(`svadmin doctor — ${projectDirectory}`));
7034
7114
  if (report.status === "clean") {
7035
- console.log(import_picocolors2.default.green(" ✔ Dependencies match the shipped svadmin scaffold."));
7115
+ console.log(import_picocolors3.default.green(" ✔ Dependencies match the shipped svadmin scaffold."));
7036
7116
  } else {
7037
7117
  for (const issue of report.issues)
7038
7118
  printDoctorIssue(issue);
7039
7119
  console.log();
7040
- console.log(import_picocolors2.default.yellow(` ${report.issues.length} actionable issue(s) found.`));
7120
+ console.log(import_picocolors3.default.yellow(` ${report.issues.length} actionable issue(s) found.`));
7041
7121
  }
7042
7122
  console.log();
7043
7123
  }
7044
7124
  function doctor(args) {
7045
7125
  const projectDirectory = doctorProjectDirectory(args);
7046
- const project = readMaintainedPackageJson(path3.join(projectDirectory, "package.json"));
7126
+ const project = readMaintainedPackageJson(path4.join(projectDirectory, "package.json"));
7047
7127
  const report = doctorProjectPackageJson(project, loadShippedScaffoldManifest());
7048
7128
  printDoctorReport(report, projectDirectory);
7049
7129
  process.exitCode = report.exitCode;
7050
7130
  }
7051
7131
  function printUpgradeChanges(upgradeExecution) {
7052
7132
  for (const change of upgradeExecution.plan.changes) {
7053
- console.log(` ${import_picocolors2.default.cyan("•")} ${upgradeChangeMessage(change)}`);
7133
+ console.log(` ${import_picocolors3.default.cyan("•")} ${upgradeChangeMessage(change)}`);
7054
7134
  }
7055
7135
  console.log();
7056
7136
  }
7057
7137
  function printUpgradeOutcome(upgradeExecution, packagePath) {
7058
7138
  if (upgradeExecution.wrote) {
7059
- console.log(import_picocolors2.default.green(" ✔ package.json updated."));
7060
- console.log(` Backup: ${import_picocolors2.default.cyan(upgradeExecution.backupPath)}`);
7061
- console.log(` Restore by copying the backup over: ${import_picocolors2.default.cyan(packagePath)}`);
7139
+ console.log(import_picocolors3.default.green(" ✔ package.json updated."));
7140
+ console.log(` Backup: ${import_picocolors3.default.cyan(upgradeExecution.backupPath)}`);
7141
+ console.log(` Restore by copying the backup over: ${import_picocolors3.default.cyan(packagePath)}`);
7062
7142
  } else {
7063
- console.log(import_picocolors2.default.yellow(" Dry run only; package.json was not changed."));
7143
+ console.log(import_picocolors3.default.yellow(" Dry run only; package.json was not changed."));
7064
7144
  console.log(" Re-run this command with --write to apply the plan.");
7065
7145
  }
7066
7146
  console.log();
7067
7147
  }
7068
7148
  function printUpgradeExecution(upgradeExecution, projectDirectory, packagePath) {
7069
7149
  console.log();
7070
- console.log(import_picocolors2.default.bold(`svadmin upgrade — ${projectDirectory}`));
7150
+ console.log(import_picocolors3.default.bold(`svadmin upgrade — ${projectDirectory}`));
7071
7151
  if (upgradeExecution.plan.changes.length === 0) {
7072
- console.log(import_picocolors2.default.green(" ✔ package.json already matches the shipped scaffold."));
7152
+ console.log(import_picocolors3.default.green(" ✔ package.json already matches the shipped scaffold."));
7073
7153
  console.log();
7074
7154
  return;
7075
7155
  }
@@ -7078,58 +7158,58 @@ function printUpgradeExecution(upgradeExecution, projectDirectory, packagePath)
7078
7158
  }
7079
7159
  function upgrade(args) {
7080
7160
  const commandArguments = parseUpgradeArguments(args);
7081
- const packagePath = path3.join(commandArguments.projectDirectory, "package.json");
7161
+ const packagePath = path4.join(commandArguments.projectDirectory, "package.json");
7082
7162
  const scaffoldManifest = loadShippedScaffoldManifest();
7083
7163
  const upgradeExecution = commandArguments.write ? writeProjectPackageJsonUpgrade(packagePath, scaffoldManifest, new Date) : planProjectPackageFileUpgrade(packagePath, scaffoldManifest);
7084
7164
  printUpgradeExecution(upgradeExecution, commandArguments.projectDirectory, packagePath);
7085
7165
  }
7086
7166
  var GUIDANCE_FILES = ["DESIGN.md", "AGENTS.md"];
7087
7167
  function missingGuidanceFiles(projectDirectory) {
7088
- return GUIDANCE_FILES.filter((fileName) => !fs3.existsSync(path3.join(projectDirectory, fileName)));
7168
+ return GUIDANCE_FILES.filter((fileName) => !fs4.existsSync(path4.join(projectDirectory, fileName)));
7089
7169
  }
7090
7170
  function printGuidancePlan(projectDirectory, missingFiles) {
7091
7171
  console.log();
7092
- console.log(import_picocolors2.default.bold(`svadmin guidance — ${projectDirectory}`));
7172
+ console.log(import_picocolors3.default.bold(`svadmin guidance — ${projectDirectory}`));
7093
7173
  for (const fileName of missingFiles) {
7094
- console.log(` ${import_picocolors2.default.cyan("•")} add ${fileName}`);
7174
+ console.log(` ${import_picocolors3.default.cyan("•")} add ${fileName}`);
7095
7175
  }
7096
7176
  console.log();
7097
7177
  }
7098
7178
  function installMissingGuidanceFiles(guidanceDirectory, projectDirectory, missingFiles) {
7099
7179
  for (const fileName of missingFiles) {
7100
- fs3.copyFileSync(path3.join(guidanceDirectory, fileName), path3.join(projectDirectory, fileName));
7180
+ fs4.copyFileSync(path4.join(guidanceDirectory, fileName), path4.join(projectDirectory, fileName));
7101
7181
  }
7102
7182
  }
7103
7183
  function guidance(args) {
7104
7184
  const { projectDirectory, write } = parseUpgradeArguments(args);
7105
- const guidanceDirectory = path3.join(__dirname2, "..", "guidance");
7106
- if (!fs3.existsSync(projectDirectory))
7185
+ const guidanceDirectory = path4.join(__dirname2, "..", "guidance");
7186
+ if (!fs4.existsSync(projectDirectory))
7107
7187
  throw new Error(`Project directory does not exist: ${projectDirectory}`);
7108
- if (!fs3.existsSync(guidanceDirectory))
7188
+ if (!fs4.existsSync(guidanceDirectory))
7109
7189
  throw new Error("Shipped svadmin guidance files are missing");
7110
7190
  const missingFiles = missingGuidanceFiles(projectDirectory);
7111
7191
  if (missingFiles.length === 0) {
7112
- console.log(import_picocolors2.default.green(`
7192
+ console.log(import_picocolors3.default.green(`
7113
7193
  ✔ DESIGN.md and AGENTS.md already exist; nothing was changed.
7114
7194
  `));
7115
7195
  return;
7116
7196
  }
7117
7197
  printGuidancePlan(projectDirectory, missingFiles);
7118
7198
  if (!write) {
7119
- console.log(import_picocolors2.default.yellow(` Dry run only; re-run with --write to add missing guidance files.
7199
+ console.log(import_picocolors3.default.yellow(` Dry run only; re-run with --write to add missing guidance files.
7120
7200
  `));
7121
7201
  return;
7122
7202
  }
7123
7203
  installMissingGuidanceFiles(guidanceDirectory, projectDirectory, missingFiles);
7124
- console.log(import_picocolors2.default.green(` ✔ Added ${missingFiles.length} guidance file(s); existing files were preserved.`));
7204
+ console.log(import_picocolors3.default.green(` ✔ Added ${missingFiles.length} guidance file(s); existing files were preserved.`));
7125
7205
  console.log();
7126
7206
  }
7127
7207
  async function init() {
7128
7208
  console.log();
7129
- console.log(import_picocolors2.default.cyan(" ╔═══════════════════════════════════╗"));
7130
- console.log(import_picocolors2.default.cyan(" ║ ") + import_picocolors2.default.bold("create-svadmin") + import_picocolors2.default.cyan(" ║"));
7131
- console.log(import_picocolors2.default.cyan(" ║ ") + import_picocolors2.default.dim("Headless Admin for Svelte 5") + import_picocolors2.default.cyan(" ║"));
7132
- console.log(import_picocolors2.default.cyan(" ╚═══════════════════════════════════╝"));
7209
+ console.log(import_picocolors3.default.cyan(" ╔═══════════════════════════════════╗"));
7210
+ console.log(import_picocolors3.default.cyan(" ║ ") + import_picocolors3.default.bold("create-svadmin") + import_picocolors3.default.cyan(" ║"));
7211
+ console.log(import_picocolors3.default.cyan(" ║ ") + import_picocolors3.default.dim("Headless Admin for Svelte 5") + import_picocolors3.default.cyan(" ║"));
7212
+ console.log(import_picocolors3.default.cyan(" ╚═══════════════════════════════════╝"));
7133
7213
  console.log();
7134
7214
  const response = await import_prompts2.default([
7135
7215
  {
@@ -7140,7 +7220,7 @@ async function init() {
7140
7220
  validate: (value) => {
7141
7221
  if (!value.trim())
7142
7222
  return "Project name is required";
7143
- if (fs3.existsSync(value.trim()) && fs3.readdirSync(value.trim()).length > 0) {
7223
+ if (fs4.existsSync(value.trim()) && fs4.readdirSync(value.trim()).length > 0) {
7144
7224
  return "Directory already exists and is not empty";
7145
7225
  }
7146
7226
  return true;
@@ -7178,61 +7258,61 @@ async function init() {
7178
7258
  }
7179
7259
  ]);
7180
7260
  if (!response.projectName) {
7181
- console.log(import_picocolors2.default.red(`
7261
+ console.log(import_picocolors3.default.red(`
7182
7262
  Operation cancelled.
7183
7263
  `));
7184
7264
  return;
7185
7265
  }
7186
- const projectDir = path3.resolve(process.cwd(), response.projectName.trim());
7187
- if (!fs3.existsSync(projectDir)) {
7188
- fs3.mkdirSync(projectDir, { recursive: true });
7266
+ const projectDir = path4.resolve(process.cwd(), response.projectName.trim());
7267
+ if (!fs4.existsSync(projectDir)) {
7268
+ fs4.mkdirSync(projectDir, { recursive: true });
7189
7269
  }
7190
7270
  console.log(`
7191
- ${import_picocolors2.default.bold("Scaffolding")} project in ${import_picocolors2.default.green(projectDir)}...
7271
+ ${import_picocolors3.default.bold("Scaffolding")} project in ${import_picocolors3.default.green(projectDir)}...
7192
7272
  `);
7193
- const templateDir = path3.join(__dirname2, "..", "template");
7194
- const guidanceDir = path3.join(__dirname2, "..", "guidance");
7273
+ const templateDir = path4.join(__dirname2, "..", "template");
7274
+ const guidanceDir = path4.join(__dirname2, "..", "guidance");
7195
7275
  const scaffoldManifest = loadShippedScaffoldManifest();
7196
7276
  function copyDir(src, dest) {
7197
- fs3.mkdirSync(dest, { recursive: true });
7198
- const entries = fs3.readdirSync(src, { withFileTypes: true });
7277
+ fs4.mkdirSync(dest, { recursive: true });
7278
+ const entries = fs4.readdirSync(src, { withFileTypes: true });
7199
7279
  for (const entry of entries) {
7200
- const srcPath = path3.join(src, entry.name);
7201
- const destPath = path3.join(dest, entry.name === "_gitignore" ? ".gitignore" : entry.name);
7280
+ const srcPath = path4.join(src, entry.name);
7281
+ const destPath = path4.join(dest, entry.name === "_gitignore" ? ".gitignore" : entry.name);
7202
7282
  if (entry.isDirectory()) {
7203
7283
  copyDir(srcPath, destPath);
7204
7284
  } else {
7205
- fs3.copyFileSync(srcPath, destPath);
7285
+ fs4.copyFileSync(srcPath, destPath);
7206
7286
  }
7207
7287
  }
7208
7288
  }
7209
- if (fs3.existsSync(templateDir)) {
7289
+ if (fs4.existsSync(templateDir)) {
7210
7290
  copyDir(templateDir, projectDir);
7211
- console.log(import_picocolors2.default.green(" ✔") + " Template files copied");
7291
+ console.log(import_picocolors3.default.green(" ✔") + " Template files copied");
7212
7292
  }
7213
- if (fs3.existsSync(guidanceDir)) {
7293
+ if (fs4.existsSync(guidanceDir)) {
7214
7294
  copyDir(guidanceDir, projectDir);
7215
- console.log(import_picocolors2.default.green(" ✔") + " AI and design guidance copied");
7295
+ console.log(import_picocolors3.default.green(" ✔") + " AI and design guidance copied");
7216
7296
  }
7217
7297
  const packageJson = createProjectPackageJson(scaffoldManifest, {
7218
7298
  projectName: response.projectName,
7219
7299
  dataProvider: response.dataProvider,
7220
7300
  authProvider: response.authProvider
7221
7301
  });
7222
- fs3.writeFileSync(path3.join(projectDir, "package.json"), `${JSON.stringify(packageJson, null, 2)}
7302
+ fs4.writeFileSync(path4.join(projectDir, "package.json"), `${JSON.stringify(packageJson, null, 2)}
7223
7303
  `);
7224
- console.log(import_picocolors2.default.green(" ✔") + " package.json generated");
7225
- fs3.writeFileSync(path3.join(projectDir, ".gitignore"), `node_modules
7304
+ console.log(import_picocolors3.default.green(" ✔") + " package.json generated");
7305
+ fs4.writeFileSync(path4.join(projectDir, ".gitignore"), `node_modules
7226
7306
  dist
7227
7307
  .svelte-kit
7228
7308
  .env
7229
7309
  .env.local
7230
7310
  *.local
7231
7311
  `);
7232
- console.log(import_picocolors2.default.green(" ✔") + " .gitignore generated");
7312
+ console.log(import_picocolors3.default.green(" ✔") + " .gitignore generated");
7233
7313
  const dpLabel = response.dataProvider === "simple-rest" ? "Simple REST" : response.dataProvider === "supabase" ? "Supabase" : response.dataProvider === "graphql" ? "GraphQL" : "Custom";
7234
7314
  const authLabel = response.authProvider === "mock" ? "Mock (demo)" : response.authProvider === "jwt" ? "JWT" : response.authProvider === "supabase" ? "Supabase Auth" : "None";
7235
- fs3.writeFileSync(path3.join(projectDir, "README.md"), `# ${response.projectName}
7315
+ fs4.writeFileSync(path4.join(projectDir, "README.md"), `# ${response.projectName}
7236
7316
 
7237
7317
  Built with [svadmin](https://github.com/vibeunion/svadmin) — Headless Admin Framework for Svelte 5.
7238
7318
 
@@ -7250,30 +7330,30 @@ bun run dev
7250
7330
  - **Auth**: ${authLabel}
7251
7331
  - **State**: TanStack Query v6
7252
7332
  `);
7253
- console.log(import_picocolors2.default.green(" ✔") + " README.md generated");
7333
+ console.log(import_picocolors3.default.green(" ✔") + " README.md generated");
7254
7334
  if (response.installDeps) {
7255
7335
  console.log(`
7256
- ${import_picocolors2.default.bold("Installing dependencies...")}
7336
+ ${import_picocolors3.default.bold("Installing dependencies...")}
7257
7337
  `);
7258
7338
  const bunInstall = spawnSync("bun", ["install"], { cwd: projectDir, stdio: "inherit" });
7259
7339
  if (bunInstall.status !== 0) {
7260
7340
  const npmInstall = spawnSync("npm", ["install"], { cwd: projectDir, stdio: "inherit" });
7261
7341
  if (npmInstall.status !== 0) {
7262
- console.log(import_picocolors2.default.yellow("\n ⚠ Auto-install failed. Run `bun install` or `npm install` manually."));
7342
+ console.log(import_picocolors3.default.yellow("\n ⚠ Auto-install failed. Run `bun install` or `npm install` manually."));
7263
7343
  }
7264
7344
  }
7265
7345
  }
7266
7346
  console.log();
7267
- console.log(import_picocolors2.default.green(import_picocolors2.default.bold(" ✔ Project ready!")));
7347
+ console.log(import_picocolors3.default.green(import_picocolors3.default.bold(" ✔ Project ready!")));
7268
7348
  console.log();
7269
7349
  console.log(" Next steps:");
7270
- console.log(` ${import_picocolors2.default.cyan(`cd ${response.projectName}`)}`);
7350
+ console.log(` ${import_picocolors3.default.cyan(`cd ${response.projectName}`)}`);
7271
7351
  if (!response.installDeps) {
7272
- console.log(` ${import_picocolors2.default.cyan("bun install")}`);
7352
+ console.log(` ${import_picocolors3.default.cyan("bun install")}`);
7273
7353
  }
7274
- console.log(` ${import_picocolors2.default.cyan("bun run dev")}`);
7354
+ console.log(` ${import_picocolors3.default.cyan("bun run dev")}`);
7275
7355
  console.log();
7276
- console.log(` Docs: ${import_picocolors2.default.blue("https://github.com/vibeunion/svadmin")}`);
7356
+ console.log(` Docs: ${import_picocolors3.default.blue("https://github.com/vibeunion/svadmin")}`);
7277
7357
  console.log();
7278
7358
  }
7279
7359
  var EJECT_COMPONENTS = [
@@ -7305,64 +7385,64 @@ var EJECT_COMPONENTS = [
7305
7385
  ];
7306
7386
  async function eject(args) {
7307
7387
  console.log();
7308
- console.log(import_picocolors2.default.cyan(" svadmin eject") + import_picocolors2.default.dim(" — copy internal components for deep customization"));
7388
+ console.log(import_picocolors3.default.cyan(" svadmin eject") + import_picocolors3.default.dim(" — copy internal components for deep customization"));
7309
7389
  console.log();
7310
7390
  const requested = args.filter((a) => !a.startsWith("-"));
7311
7391
  const toEject = requested.length > 0 ? requested.filter((name) => {
7312
7392
  if (!EJECT_COMPONENTS.includes(name)) {
7313
- console.log(import_picocolors2.default.yellow(` ⚠ Unknown component: ${name} (skipped)`));
7393
+ console.log(import_picocolors3.default.yellow(` ⚠ Unknown component: ${name} (skipped)`));
7314
7394
  return false;
7315
7395
  }
7316
7396
  return true;
7317
7397
  }) : [...EJECT_COMPONENTS];
7318
7398
  if (toEject.length === 0) {
7319
- console.log(import_picocolors2.default.red(" No valid components to eject."));
7399
+ console.log(import_picocolors3.default.red(" No valid components to eject."));
7320
7400
  console.log(` Available: ${EJECT_COMPONENTS.join(", ")}`);
7321
7401
  return;
7322
7402
  }
7323
7403
  let uiSrcDir;
7324
7404
  try {
7325
7405
  const require2 = createRequire2(import.meta.url);
7326
- const uiPkg = path3.dirname(require2.resolve("@svadmin/ui/package.json"));
7327
- uiSrcDir = path3.join(uiPkg, "src", "components");
7406
+ const uiPkg = path4.dirname(require2.resolve("@svadmin/ui/package.json"));
7407
+ uiSrcDir = path4.join(uiPkg, "src", "components");
7328
7408
  } catch {
7329
- const nm = path3.join(process.cwd(), "node_modules", "@svadmin", "ui", "src", "components");
7330
- if (fs3.existsSync(nm)) {
7409
+ const nm = path4.join(process.cwd(), "node_modules", "@svadmin", "ui", "src", "components");
7410
+ if (fs4.existsSync(nm)) {
7331
7411
  uiSrcDir = nm;
7332
7412
  } else {
7333
- console.log(import_picocolors2.default.red(" ✗ Cannot find @svadmin/ui. Run `bun install` first."));
7413
+ console.log(import_picocolors3.default.red(" ✗ Cannot find @svadmin/ui. Run `bun install` first."));
7334
7414
  return;
7335
7415
  }
7336
7416
  }
7337
- const destDir = path3.join(process.cwd(), "src", "components", "svadmin");
7338
- fs3.mkdirSync(destDir, { recursive: true });
7417
+ const destDir = path4.join(process.cwd(), "src", "components", "svadmin");
7418
+ fs4.mkdirSync(destDir, { recursive: true });
7339
7419
  let copied = 0;
7340
7420
  for (const name of toEject) {
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;
7421
+ const srcFile = path4.join(uiSrcDir, `${name}.svelte`);
7422
+ const srcFileAlt = path4.join(uiSrcDir, "fields", `${name}.svelte`);
7423
+ const src = fs4.existsSync(srcFile) ? srcFile : fs4.existsSync(srcFileAlt) ? srcFileAlt : null;
7344
7424
  if (!src) {
7345
- console.log(import_picocolors2.default.yellow(` ⚠ ${name}.svelte not found in @svadmin/ui (skipped)`));
7425
+ console.log(import_picocolors3.default.yellow(` ⚠ ${name}.svelte not found in @svadmin/ui (skipped)`));
7346
7426
  continue;
7347
7427
  }
7348
- let content = fs3.readFileSync(src, "utf-8");
7428
+ let content = fs4.readFileSync(src, "utf-8");
7349
7429
  content = content.replace(/from\s+['"]\.\/ui\//g, "from '@svadmin/ui/components/ui/");
7350
7430
  content = content.replace(/from\s+['"]\.\/((?!ui\/)[^'"]+)['"]/g, "from './$1'");
7351
- const destFile = path3.join(destDir, `${name}.svelte`);
7352
- fs3.writeFileSync(destFile, content);
7353
- console.log(import_picocolors2.default.green(" ✔") + ` ${name}.svelte → src/components/svadmin/`);
7431
+ const destFile = path4.join(destDir, `${name}.svelte`);
7432
+ fs4.writeFileSync(destFile, content);
7433
+ console.log(import_picocolors3.default.green(" ✔") + ` ${name}.svelte → src/components/svadmin/`);
7354
7434
  copied++;
7355
7435
  }
7356
7436
  console.log();
7357
7437
  if (copied > 0) {
7358
- console.log(import_picocolors2.default.green(import_picocolors2.default.bold(` ✔ Ejected ${copied} component(s)`)));
7438
+ console.log(import_picocolors3.default.green(import_picocolors3.default.bold(` ✔ Ejected ${copied} component(s)`)));
7359
7439
  console.log();
7360
7440
  console.log(" Usage: import overrides in your AdminApp and pass via `components` prop:");
7361
7441
  console.log();
7362
- console.log(import_picocolors2.default.dim(' import CustomLayout from "./components/svadmin/Layout.svelte";'));
7363
- console.log(import_picocolors2.default.dim(" <AdminApp components={{ Layout: CustomLayout }} ... />"));
7442
+ console.log(import_picocolors3.default.dim(' import CustomLayout from "./components/svadmin/Layout.svelte";'));
7443
+ console.log(import_picocolors3.default.dim(" <AdminApp components={{ Layout: CustomLayout }} ... />"));
7364
7444
  } else {
7365
- console.log(import_picocolors2.default.yellow(" No components were ejected."));
7445
+ console.log(import_picocolors3.default.yellow(" No components were ejected."));
7366
7446
  }
7367
7447
  console.log();
7368
7448
  }
@@ -7370,7 +7450,7 @@ var [, , subcommand, ...rest] = process.argv;
7370
7450
  var runCommand = (command) => {
7371
7451
  Promise.resolve().then(command).catch((error) => {
7372
7452
  const message = error instanceof Error ? error.message : String(error);
7373
- console.error(import_picocolors2.default.red(`
7453
+ console.error(import_picocolors3.default.red(`
7374
7454
  ✗ ${message}
7375
7455
  `));
7376
7456
  process.exitCode = 2;
@@ -7386,6 +7466,8 @@ if (subcommand === "eject") {
7386
7466
  runCommand(() => guidance(rest));
7387
7467
  } else if (subcommand === "infer") {
7388
7468
  runCommand(() => inferCommand(rest));
7469
+ } else if (subcommand === "generate" || subcommand === "gen") {
7470
+ runCommand(() => generateCommand(rest));
7389
7471
  } else if (subcommand === "lite") {
7390
7472
  if (rest[0] !== "init") {
7391
7473
  runCommand(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svadmin/create",
3
- "version": "0.21.0",
3
+ "version": "0.22.1",
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.46.0"
30
+ "@svadmin/core": "^0.47.1"
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.46.0",
14
- "@svadmin/ui": "^0.64.0",
13
+ "@svadmin/core": "^0.47.1",
14
+ "@svadmin/ui": "^0.65.1",
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.19",
35
+ "@svadmin/simple-rest": "^0.9.21",
36
36
  "@refinedev/simple-rest": "^6.0.1"
37
37
  },
38
38
  "supabase": {
39
- "@svadmin/supabase": "^0.13.1",
39
+ "@svadmin/supabase": "^0.13.3",
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.19",
44
+ "@svadmin/graphql": "^0.9.21",
45
45
  "@refinedev/graphql": "^8.0.1",
46
46
  "graphql-request": "^7.4.0",
47
47
  "graphql": "^16.8.0"