dynamic-zone 1.0.4 → 1.0.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.
Files changed (2) hide show
  1. package/index.js +32 -15
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -11,15 +11,33 @@ if (basePath.includes("node_modules")) {
11
11
  process.exit(0);
12
12
  }
13
13
 
14
- // Ensure src folder exists
15
- const srcPath = path.join(basePath, "src");
16
- if (!fs.existsSync(srcPath)) {
17
- console.log("⚠️ No src folder found. Please create a 'src' folder first.");
18
- process.exit(0);
14
+ // --- 1️⃣ Check if package.json exists ---
15
+ const packageJsonPath = path.join(basePath, "package.json");
16
+ if (!fs.existsSync(packageJsonPath)) {
17
+ console.log(" package.json not found. Are you in a Node.js project?");
18
+ process.exit(1);
19
+ }
20
+
21
+ // --- 2️⃣ Read package.json and check for next ---
22
+ const packageJson = require(packageJsonPath);
23
+ const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
24
+
25
+ if (!deps.next) {
26
+ console.log(
27
+ "❌ This is not a Next.js project. dynamic-zone can only be used in Next.js."
28
+ );
29
+ process.exit(1);
30
+ }
31
+
32
+ // --- 3️⃣ Check if app folder exists ---
33
+ const appPath = path.join(basePath, "app");
34
+ if (!fs.existsSync(appPath)) {
35
+ console.log("⚠️ No 'app' folder found. Please create an 'app' folder first.");
36
+ process.exit(1);
19
37
  }
20
38
 
21
39
  // Paths for folders
22
- const cmsPath = path.join(srcPath, "cms");
40
+ const cmsPath = path.join(appPath, "cms");
23
41
  const componentsPath = path.join(cmsPath, "components");
24
42
  const dynamicZonePath = path.join(cmsPath, "dynamic-zone");
25
43
 
@@ -62,9 +80,8 @@ export default function SectionRenderer({ sections, slug }: Props) {
62
80
 
63
81
  if (Array.isArray(sections) && sections.length === 0) {
64
82
  return (
65
- <div className="w-full px-2 md:px-4 py-4">
66
- No Sections Found for {slug}
67
- </div>
83
+ // This is the div for the sections that are not found DO W-FULL PX
84
+ <div>No Sections Found for {slug}</div>
68
85
  );
69
86
  }
70
87
 
@@ -74,9 +91,8 @@ export default function SectionRenderer({ sections, slug }: Props) {
74
91
 
75
92
  if (!Component) {
76
93
  return (
77
- <div className="w-full" key={index}>
78
- No Section Found {sectionType}
79
- </div>
94
+ // This is the div for the section that is not found DO W-FULL
95
+ <div key={index}>No Section Found {sectionType}</div>
80
96
  );
81
97
  }
82
98
 
@@ -89,12 +105,13 @@ export default function SectionRenderer({ sections, slug }: Props) {
89
105
  );
90
106
  };
91
107
 
108
+ const sectionsArray = Array.isArray(sections) ? sections : [];
92
109
  return (
93
- <div className="flex flex-col">
94
- {(sections || []).map(renderSection)}
95
- </div>
110
+ // This is the root div for the dynamic zone DO FLEX FLEX-COL
111
+ <div>{sectionsArray.map(renderSection)}</div>
96
112
  );
97
113
  }
114
+
98
115
  `;
99
116
 
100
117
  // Write file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dynamic-zone",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Dynamic zone scaffolding for Next.js apps",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",