dynamic-zone 1.0.2 → 1.0.4

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 +17 -5
  2. package/package.json +10 -10
package/index.js CHANGED
@@ -5,8 +5,21 @@ const path = require("path");
5
5
 
6
6
  const basePath = process.cwd();
7
7
 
8
- // Paths
9
- const cmsPath = path.join(basePath, "cms");
8
+ // Prevent creating inside node_modules
9
+ if (basePath.includes("node_modules")) {
10
+ console.log("❌ Do not run inside node_modules");
11
+ process.exit(0);
12
+ }
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);
19
+ }
20
+
21
+ // Paths for folders
22
+ const cmsPath = path.join(srcPath, "cms");
10
23
  const componentsPath = path.join(cmsPath, "components");
11
24
  const dynamicZonePath = path.join(cmsPath, "dynamic-zone");
12
25
 
@@ -18,7 +31,7 @@ const dynamicZonePath = path.join(cmsPath, "dynamic-zone");
18
31
  }
19
32
  });
20
33
 
21
- // File content
34
+ // Section Renderer file content
22
35
  const fileContent = `import dynamic from "next/dynamic";
23
36
  import { Suspense } from "react";
24
37
 
@@ -84,9 +97,8 @@ export default function SectionRenderer({ sections, slug }: Props) {
84
97
  }
85
98
  `;
86
99
 
87
- // Create file
100
+ // Write file
88
101
  const filePath = path.join(dynamicZonePath, "section-renderer.tsx");
89
-
90
102
  if (!fs.existsSync(filePath)) {
91
103
  fs.writeFileSync(filePath, fileContent);
92
104
  console.log("📄 Created file:", filePath);
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "dynamic-zone",
3
- "version": "1.0.2",
4
- "description": "dynamic zone for cms platforms",
3
+ "version": "1.0.4",
4
+ "description": "Dynamic zone scaffolding for Next.js apps",
5
+ "main": "index.js",
6
+ "type": "commonjs",
7
+ "author": "Web Dev Simplified",
8
+ "license": "ISC",
5
9
  "keywords": [
6
- "dynamic-zone"
10
+ "dynamic-zone",
11
+ "cms",
12
+ "nextjs",
13
+ "scaffold"
7
14
  ],
8
- "license": "ISC",
9
- "author": "Web Dev Simplified",
10
- "type": "commonjs",
11
- "main": "index.js",
12
- "scripts": {
13
- "test": "echo \"Error: no test specified\" && exit 1"
14
- },
15
15
  "bin": {
16
16
  "dynamic-zone": "./index.js"
17
17
  }