@shadospace/editor 1.0.0 → 1.0.1
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 +1 -1
- package/scripts/init.js +29 -0
package/package.json
CHANGED
package/scripts/init.js
CHANGED
|
@@ -11,6 +11,35 @@ const targetDir = process.env.INIT_CWD || process.cwd();
|
|
|
11
11
|
|
|
12
12
|
console.log(`[tiptap-starter] Initializing in ${targetDir}`);
|
|
13
13
|
|
|
14
|
+
// Verify that the target directory is a Next.js project with shadcn installed
|
|
15
|
+
const targetPackageJsonPath = path.join(targetDir, 'package.json');
|
|
16
|
+
|
|
17
|
+
if (!fs.existsSync(targetPackageJsonPath)) {
|
|
18
|
+
console.error(`[tiptap-starter] Error: package.json not found in ${targetDir}. Please run this in the root of your project.`);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let pkg;
|
|
23
|
+
try {
|
|
24
|
+
pkg = JSON.parse(fs.readFileSync(targetPackageJsonPath, 'utf8'));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.error(`[tiptap-starter] Error: Failed to parse package.json in ${targetDir}`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const hasNext = pkg.dependencies?.next || pkg.devDependencies?.next;
|
|
31
|
+
const hasShadcn = fs.existsSync(path.join(targetDir, 'components.json'));
|
|
32
|
+
|
|
33
|
+
if (!hasNext) {
|
|
34
|
+
console.error(`[tiptap-starter] Error: Next.js is not detected. This package is designed for Next.js projects.`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!hasShadcn) {
|
|
39
|
+
console.error(`[tiptap-starter] Error: shadcn/ui is not detected (components.json not found). Please initialize shadcn first.`);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
|
|
14
43
|
const sourceEditorDir = path.join(__dirname, '../components/editor');
|
|
15
44
|
|
|
16
45
|
// Detect if target project uses src directory
|