atomsystem 0.1.9 → 0.1.10
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/cli/init.js +82 -1
- package/package.json +1 -1
package/cli/init.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
import inquirer from "inquirer"; // require -> import
|
|
3
3
|
import { exec } from "child_process"; // require -> import
|
|
4
|
+
import fs from "fs"; // 파일 시스템 작업을 위한 모듈
|
|
5
|
+
import path from "path"; // 경로 작업을 위한 모듈
|
|
4
6
|
|
|
5
7
|
// 사용자에게 질문을 던져서 Next.js와 React를 설치할지 물어봅니다.
|
|
6
8
|
inquirer
|
|
@@ -25,6 +27,85 @@ inquirer
|
|
|
25
27
|
} else {
|
|
26
28
|
console.log(stdout);
|
|
27
29
|
console.log("Installation complete!");
|
|
30
|
+
|
|
31
|
+
// package.json에 scripts 추가
|
|
32
|
+
const packageJsonPath = path.join(process.cwd(), "package.json");
|
|
33
|
+
fs.readFile(packageJsonPath, "utf8", (err, data) => {
|
|
34
|
+
if (err) {
|
|
35
|
+
console.error("Error reading package.json:", err);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const packageJson = JSON.parse(data);
|
|
40
|
+
|
|
41
|
+
// scripts 항목 추가
|
|
42
|
+
packageJson.scripts = packageJson.scripts || {};
|
|
43
|
+
packageJson.scripts.dev = "next dev";
|
|
44
|
+
packageJson.scripts.build = "next build";
|
|
45
|
+
packageJson.scripts.start = "next start";
|
|
46
|
+
packageJson.scripts.lint = "next lint";
|
|
47
|
+
|
|
48
|
+
// 수정된 package.json을 덮어씁니다.
|
|
49
|
+
fs.writeFile(
|
|
50
|
+
packageJsonPath,
|
|
51
|
+
JSON.stringify(packageJson, null, 2),
|
|
52
|
+
(err) => {
|
|
53
|
+
if (err) {
|
|
54
|
+
console.error("Error updating package.json:", err);
|
|
55
|
+
} else {
|
|
56
|
+
console.log("Updated package.json with scripts.");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// app 디렉토리 생성 및 layout.tsx, page.tsx 파일 추가
|
|
63
|
+
const appDir = path.join(process.cwd(), "app");
|
|
64
|
+
const layoutPath = path.join(appDir, "layout.tsx");
|
|
65
|
+
const pagePath = path.join(appDir, "page.tsx");
|
|
66
|
+
|
|
67
|
+
// app 디렉토리가 없으면 생성
|
|
68
|
+
if (!fs.existsSync(appDir)) {
|
|
69
|
+
fs.mkdirSync(appDir);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// layout.tsx 파일 내용
|
|
73
|
+
const layoutContent = `export default function RootLayout({
|
|
74
|
+
children,
|
|
75
|
+
}: {
|
|
76
|
+
children: React.ReactNode
|
|
77
|
+
}) {
|
|
78
|
+
return (
|
|
79
|
+
<html lang="en">
|
|
80
|
+
<body>{children}</body>
|
|
81
|
+
</html>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
85
|
+
|
|
86
|
+
// page.tsx 파일 내용
|
|
87
|
+
const pageContent = `export default function Page() {
|
|
88
|
+
return <h1>Hello, Next.js!</h1>
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
|
|
92
|
+
// layout.tsx 파일 생성
|
|
93
|
+
fs.writeFile(layoutPath, layoutContent, (err) => {
|
|
94
|
+
if (err) {
|
|
95
|
+
console.error("Error creating layout.tsx:", err);
|
|
96
|
+
} else {
|
|
97
|
+
console.log("Created layout.tsx.");
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// page.tsx 파일 생성
|
|
102
|
+
fs.writeFile(pagePath, pageContent, (err) => {
|
|
103
|
+
if (err) {
|
|
104
|
+
console.error("Error creating page.tsx:", err);
|
|
105
|
+
} else {
|
|
106
|
+
console.log("Created page.tsx.");
|
|
107
|
+
}
|
|
108
|
+
});
|
|
28
109
|
}
|
|
29
110
|
}
|
|
30
111
|
);
|