@siteping/cli 0.4.4 → 0.4.6

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
@@ -18481,6 +18481,7 @@ var _SITEPING_MODELS = {
18481
18481
  url: { type: "String" },
18482
18482
  urlPattern: { type: "String", optional: true },
18483
18483
  screenshotUrl: { type: "String", optional: true, nativeType: "Text" },
18484
+ diagnostics: { type: "Json", optional: true },
18484
18485
  viewport: { type: "String" },
18485
18486
  userAgent: { type: "String" },
18486
18487
  authorName: { type: "String" },
@@ -18540,6 +18541,14 @@ var _SITEPING_MODELS = {
18540
18541
  };
18541
18542
  var SITEPING_MODELS = Object.freeze(_SITEPING_MODELS);
18542
18543
 
18544
+ // ../core/src/type-utils.ts
18545
+ function isRecord(value) {
18546
+ return typeof value === "object" && value !== null;
18547
+ }
18548
+ function hasOwn(value, key) {
18549
+ return isRecord(value) && key in value;
18550
+ }
18551
+
18543
18552
  // src/generators/prisma.ts
18544
18553
  var DEFAULT_SCHEMA_PATH = "prisma/schema.prisma";
18545
18554
  function syncPrismaModels(schemaPath = DEFAULT_SCHEMA_PATH) {
@@ -18919,11 +18928,16 @@ function readPackageJson(cwd) {
18919
18928
  const pkgPath = join3(cwd, "package.json");
18920
18929
  if (!existsSync4(pkgPath)) return null;
18921
18930
  try {
18922
- return JSON.parse(readFileSync2(pkgPath, "utf-8"));
18931
+ const parsed = JSON.parse(readFileSync2(pkgPath, "utf-8"));
18932
+ if (!hasOwn(parsed, "dependencies") && !hasOwn(parsed, "devDependencies")) return {};
18933
+ return parsed;
18923
18934
  } catch {
18924
18935
  return null;
18925
18936
  }
18926
18937
  }
18938
+ function dependencyVersion(pkg, name) {
18939
+ return pkg.dependencies?.[name] ?? pkg.devDependencies?.[name];
18940
+ }
18927
18941
  function findWidgetUsage(cwd) {
18928
18942
  const searchDirs = [join3(cwd, "src"), join3(cwd, "app"), join3(cwd, "pages")];
18929
18943
  const extensions = [".ts", ".tsx", ".js", ".jsx"];
@@ -19039,17 +19053,13 @@ function statusCommand(options) {
19039
19053
  v2.error(`${pad("API route", 25)}Not found`);
19040
19054
  }
19041
19055
  const pkg = readPackageJson(cwd);
19042
- if (pkg) {
19043
- const deps = pkg.dependencies ?? {};
19044
- const devDeps = pkg.devDependencies ?? {};
19045
- const version = deps["@siteping/widget"] ?? devDeps["@siteping/widget"];
19046
- if (version) {
19047
- v2.success(`${pad("Package", 25)}@siteping/widget@${version}`);
19048
- } else {
19049
- v2.error(`${pad("Package", 25)}@siteping/widget not found in package.json`);
19050
- }
19051
- } else {
19056
+ const widgetVersion = pkg ? dependencyVersion(pkg, "@siteping/widget") : void 0;
19057
+ if (!pkg) {
19052
19058
  v2.error(`${pad("Package", 25)}package.json not found`);
19059
+ } else if (widgetVersion) {
19060
+ v2.success(`${pad("Package", 25)}@siteping/widget@${widgetVersion}`);
19061
+ } else {
19062
+ v2.error(`${pad("Package", 25)}@siteping/widget not found in package.json`);
19053
19063
  }
19054
19064
  const widgetFile = findWidgetUsage(cwd);
19055
19065
  if (widgetFile) {
@@ -19057,7 +19067,7 @@ function statusCommand(options) {
19057
19067
  } else {
19058
19068
  v2.warn(`${pad("Widget integration", 25)}initSiteping not found in source files`);
19059
19069
  }
19060
- const hasError = !schemaResult.found || !routePath || !pkg || pkg && !(pkg.dependencies?.["@siteping/widget"] ?? pkg.devDependencies?.["@siteping/widget"]);
19070
+ const hasError = !schemaResult.found || !routePath || !pkg || !widgetVersion;
19061
19071
  const hasWarning = schemaResult.missingModels.length > 0 || schemaResult.missingFields.length > 0 || schemaResult.outdatedFields.length > 0 || !widgetFile;
19062
19072
  if (hasError) {
19063
19073
  fe("Some items are missing \u2014 run `siteping init` to set up.");
@@ -19106,7 +19116,7 @@ function syncCommand(options) {
19106
19116
  }
19107
19117
 
19108
19118
  // src/index.ts
19109
- var program2 = new Command().name("siteping").description("CLI to configure @siteping/* in your project").version("0.4.4");
19119
+ var program2 = new Command().name("siteping").description("CLI to configure @siteping/* in your project").version("0.4.6");
19110
19120
  program2.command("init").description("Set up the Prisma schema and API route in your project").action(initCommand).addHelpText("after", "\n Examples:\n $ siteping init");
19111
19121
  program2.command("sync").description("Sync the Prisma schema (non-interactive, CI-friendly)").option("--schema <path>", "Path to the schema.prisma file").action(syncCommand).addHelpText("after", "\n Examples:\n $ siteping sync\n $ siteping sync --schema prisma/schema.prisma");
19112
19122
  program2.command("status").description("Full diagnostic of the Siteping integration").option("--schema <path>", "Path to the schema.prisma file").action(statusCommand).addHelpText("after", "\n Examples:\n $ siteping status\n $ siteping status --schema prisma/schema.prisma");