@deneb-ui/cli 2.0.120 → 2.0.121

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deneb-ui/cli",
3
- "version": "2.0.120",
3
+ "version": "2.0.121",
4
4
  "description": "Official DENEB CLI — scaffold, convert, validate, and package Fivora-ready storefront templates.",
5
5
  "bin": {
6
6
  "deneb": "bin/index.js",
@@ -49,7 +49,7 @@
49
49
  "license": "MIT",
50
50
  "dependencies": {
51
51
  "@babel/parser": "^7.28.0",
52
- "@deneb-ui/core": "^2.0.120",
52
+ "@deneb-ui/core": "^2.0.121",
53
53
  "@octokit/rest": "^22.0.1",
54
54
  "adm-zip": "^0.6.0",
55
55
  "dotenv": "^17.4.2",
@@ -1068,6 +1068,66 @@ function runDoctor(targetDirInput = '.', options = {}) {
1068
1068
  addCheck(suite5, 'warn', 'Next.js Image Empty-String Guard', `${emptyImageSrcCount} Image src attribute(s) pass unguarded expressions that may trigger Next.js empty string download errors. Run with --fix to guard.`, { code: 'DNB-IMG-002' });
1069
1069
  }
1070
1070
 
1071
+ // Check: Next.js Image BasePath Safety (DNB-IMG-003)
1072
+ let unwrappedLocalImageCount = 0;
1073
+ for (const file of sourceFiles) {
1074
+ let c = fs.readFileSync(file, 'utf-8');
1075
+ if (c.includes('<Image') || c.includes('<img')) {
1076
+ const rawImageTagRegex = /<(?:Image|img)\b([^>]*\bsrc=(?:["'](\/[^"'#?][^"']*)["']|\{(?:["'](\/[^"'#?][^"']*)["'])\})[^>]*)>/g;
1077
+ const tagMatches = [...c.matchAll(rawImageTagRegex)];
1078
+ let fileModified = false;
1079
+
1080
+ for (const m of tagMatches) {
1081
+ const fullTag = m[0];
1082
+ const rawPath = m[2] || m[3];
1083
+ if (rawPath && !rawPath.startsWith('//') && !fullTag.includes('withBasePath') && !fullTag.includes('resolveAsset') && !fullTag.includes('contentImage')) {
1084
+ unwrappedLocalImageCount++;
1085
+ if (shouldFix) {
1086
+ const doubleQuoteSrc = 'src="' + rawPath + '"';
1087
+ const singleQuoteSrc = "src='" + rawPath + "'";
1088
+ const curlyDoubleSrc = 'src={"' + rawPath + '"}';
1089
+ const curlySingleSrc = "src={'" + rawPath + "'}";
1090
+
1091
+ if (c.includes(doubleQuoteSrc)) {
1092
+ c = c.replace(doubleQuoteSrc, "src={withBasePath('" + rawPath + "')}");
1093
+ fileModified = true;
1094
+ } else if (c.includes(singleQuoteSrc)) {
1095
+ c = c.replace(singleQuoteSrc, "src={withBasePath('" + rawPath + "')}");
1096
+ fileModified = true;
1097
+ } else if (c.includes(curlyDoubleSrc)) {
1098
+ c = c.replace(curlyDoubleSrc, "src={withBasePath('" + rawPath + "')}");
1099
+ fileModified = true;
1100
+ } else if (c.includes(curlySingleSrc)) {
1101
+ c = c.replace(curlySingleSrc, "src={withBasePath('" + rawPath + "')}");
1102
+ fileModified = true;
1103
+ }
1104
+ }
1105
+ }
1106
+ }
1107
+
1108
+ if (shouldFix && fileModified) {
1109
+ if (!c.includes('withBasePath')) {
1110
+ if (c.includes("from '@deneb-ui/ui'") || c.includes('from "@deneb-ui/ui"')) {
1111
+ c = c.replace(/import\s*\{([^}]+)\}\s*from\s*(['"]@deneb-ui\/ui['"])/, 'import { $1, withBasePath } from $2');
1112
+ } else if (c.includes("from '@/lib/utils'") || c.includes('from "@/lib/utils"')) {
1113
+ c = c.replace(/import\s*\{([^}]+)\}\s*from\s*(['"]@\/lib\/utils['"])/, 'import { $1, withBasePath } from $2');
1114
+ } else {
1115
+ c = "import { withBasePath } from '@deneb-ui/ui';\n" + c;
1116
+ }
1117
+ }
1118
+ fs.writeFileSync(file, c, 'utf8');
1119
+ }
1120
+ }
1121
+ }
1122
+
1123
+ if (unwrappedLocalImageCount === 0) {
1124
+ addCheck(suite5, 'pass', 'Next.js Image BasePath Safety', 'All local Image src attributes are protected with withBasePath()', { code: 'DNB-IMG-003' });
1125
+ } else if (shouldFix) {
1126
+ addCheck(suite5, 'fixed', 'Next.js Image BasePath Safety', `Protected ${unwrappedLocalImageCount} local Image path(s) with withBasePath()`, { code: 'DNB-IMG-003', action: 'Wrapped with withBasePath()' });
1127
+ } else {
1128
+ addCheck(suite5, 'warn', 'Next.js Image BasePath Safety', `${unwrappedLocalImageCount} local Image path(s) lack withBasePath(). Will 404 under Fivora preview subpaths. Run with --fix to wrap.`, { code: 'DNB-IMG-003', action: 'Wrap with withBasePath() or use DenebImage' });
1129
+ }
1130
+
1071
1131
  // Check: Product Card Color Swatch & Strikethrough Price Editability (DNB-COL-009)
1072
1132
  let staticSwatchCount = 0;
1073
1133
  let missingColorSchemaCount = 0;