@siteping/cli 0.4.5 → 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 +22 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18541,6 +18541,14 @@ var _SITEPING_MODELS = {
|
|
|
18541
18541
|
};
|
|
18542
18542
|
var SITEPING_MODELS = Object.freeze(_SITEPING_MODELS);
|
|
18543
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
|
+
|
|
18544
18552
|
// src/generators/prisma.ts
|
|
18545
18553
|
var DEFAULT_SCHEMA_PATH = "prisma/schema.prisma";
|
|
18546
18554
|
function syncPrismaModels(schemaPath = DEFAULT_SCHEMA_PATH) {
|
|
@@ -18920,11 +18928,16 @@ function readPackageJson(cwd) {
|
|
|
18920
18928
|
const pkgPath = join3(cwd, "package.json");
|
|
18921
18929
|
if (!existsSync4(pkgPath)) return null;
|
|
18922
18930
|
try {
|
|
18923
|
-
|
|
18931
|
+
const parsed = JSON.parse(readFileSync2(pkgPath, "utf-8"));
|
|
18932
|
+
if (!hasOwn(parsed, "dependencies") && !hasOwn(parsed, "devDependencies")) return {};
|
|
18933
|
+
return parsed;
|
|
18924
18934
|
} catch {
|
|
18925
18935
|
return null;
|
|
18926
18936
|
}
|
|
18927
18937
|
}
|
|
18938
|
+
function dependencyVersion(pkg, name) {
|
|
18939
|
+
return pkg.dependencies?.[name] ?? pkg.devDependencies?.[name];
|
|
18940
|
+
}
|
|
18928
18941
|
function findWidgetUsage(cwd) {
|
|
18929
18942
|
const searchDirs = [join3(cwd, "src"), join3(cwd, "app"), join3(cwd, "pages")];
|
|
18930
18943
|
const extensions = [".ts", ".tsx", ".js", ".jsx"];
|
|
@@ -19040,17 +19053,13 @@ function statusCommand(options) {
|
|
|
19040
19053
|
v2.error(`${pad("API route", 25)}Not found`);
|
|
19041
19054
|
}
|
|
19042
19055
|
const pkg = readPackageJson(cwd);
|
|
19043
|
-
|
|
19044
|
-
|
|
19045
|
-
const devDeps = pkg.devDependencies ?? {};
|
|
19046
|
-
const version = deps["@siteping/widget"] ?? devDeps["@siteping/widget"];
|
|
19047
|
-
if (version) {
|
|
19048
|
-
v2.success(`${pad("Package", 25)}@siteping/widget@${version}`);
|
|
19049
|
-
} else {
|
|
19050
|
-
v2.error(`${pad("Package", 25)}@siteping/widget not found in package.json`);
|
|
19051
|
-
}
|
|
19052
|
-
} else {
|
|
19056
|
+
const widgetVersion = pkg ? dependencyVersion(pkg, "@siteping/widget") : void 0;
|
|
19057
|
+
if (!pkg) {
|
|
19053
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`);
|
|
19054
19063
|
}
|
|
19055
19064
|
const widgetFile = findWidgetUsage(cwd);
|
|
19056
19065
|
if (widgetFile) {
|
|
@@ -19058,7 +19067,7 @@ function statusCommand(options) {
|
|
|
19058
19067
|
} else {
|
|
19059
19068
|
v2.warn(`${pad("Widget integration", 25)}initSiteping not found in source files`);
|
|
19060
19069
|
}
|
|
19061
|
-
const hasError = !schemaResult.found || !routePath || !pkg ||
|
|
19070
|
+
const hasError = !schemaResult.found || !routePath || !pkg || !widgetVersion;
|
|
19062
19071
|
const hasWarning = schemaResult.missingModels.length > 0 || schemaResult.missingFields.length > 0 || schemaResult.outdatedFields.length > 0 || !widgetFile;
|
|
19063
19072
|
if (hasError) {
|
|
19064
19073
|
fe("Some items are missing \u2014 run `siteping init` to set up.");
|
|
@@ -19107,7 +19116,7 @@ function syncCommand(options) {
|
|
|
19107
19116
|
}
|
|
19108
19117
|
|
|
19109
19118
|
// src/index.ts
|
|
19110
|
-
var program2 = new Command().name("siteping").description("CLI to configure @siteping/* in your project").version("0.4.
|
|
19119
|
+
var program2 = new Command().name("siteping").description("CLI to configure @siteping/* in your project").version("0.4.6");
|
|
19111
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");
|
|
19112
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");
|
|
19113
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");
|