atomsystem 0.1.10 → 0.1.12

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/add.js ADDED
@@ -0,0 +1,128 @@
1
+ #!/usr/bin/env node
2
+
3
+ import inquirer from "inquirer";
4
+ import fs from "fs";
5
+ import path from "path";
6
+ import { copyFileSync } from "fs";
7
+ import { fileURLToPath } from "url";
8
+
9
+ const __dirname = fileURLToPath(new URL(".", import.meta.url));
10
+
11
+ // 컴포넌트 템플릿이 위치한 디렉토리
12
+ const templateDir = path.join(__dirname, "templates");
13
+
14
+ // 사용할 수 있는 컴포넌트 목록
15
+ const components = [
16
+ "Button",
17
+ "Card",
18
+ "CodeBlock",
19
+ "GlobalNav",
20
+ "Input",
21
+ "Theme",
22
+ ]; // 여기 추가할 컴포넌트 목록
23
+
24
+ // 명령어에서 컴포넌트 이름 가져오기
25
+ const args = process.argv.slice(2); // 'npx atomsystem-add Button -> [Button]'
26
+ const component = args[0] || "all"; // '사용자가 입력하지 않으면 기본적으로 'all''
27
+
28
+ function addComponent(comp) {
29
+ const componentPath = path.join(templateDir, `${comp}/${comp}.tsx`);
30
+ const targetDir = path.join(process.cwd(), "app", "components", comp);
31
+ const targetPath = path.join(targetDir, `${comp}.tsx`);
32
+
33
+ if (fs.existsSync(componentPath)) {
34
+ // 대상 디렉토리가 없으면 생성
35
+ if (!fs.existsSync(targetDir)) {
36
+ fs.mkdirSync(targetDir, { recursive: true });
37
+ console.log(`Created directory: ${targetDir}`);
38
+ }
39
+ copyFileSync(componentPath, targetPath);
40
+ console.log(`${comp} component has been added to ${targetPath}`);
41
+ } else {
42
+ console.log(`Component ${comp} does not exist in the atomsystem.`);
43
+ }
44
+ }
45
+
46
+ if (component == "all") {
47
+ console.log("Adding all components...");
48
+
49
+ components.forEach((comp) => {
50
+ addComponent(comp);
51
+ });
52
+ } else {
53
+ // 특정 컴포넌트 추가
54
+ addComponent(component);
55
+ }
56
+
57
+ // "all" 이면 모든 컴포넌트를 추가
58
+
59
+ // 사용자에게 추가할 컴포넌트를 선택하도록 묻습니다.
60
+ // inquirer
61
+ // .prompt([
62
+ // {
63
+ // type: "list",
64
+ // name: "component",
65
+ // message: "Which component would you like to add?",
66
+ // choices: ["all", ...components], // 'all'을 첫 번째로 추가
67
+ // },
68
+ // ])
69
+ // .then((answers) => {
70
+ // const { component } = answers;
71
+
72
+ // // 'all'이 선택되면 모든 컴포넌트를 추가합니다.
73
+ // if (component === "all") {
74
+ // console.log("Adding all components...");
75
+
76
+ // components.forEach((comp) => {
77
+ // const componentPath = path.join(templateDir, `${comp}/${comp}.tsx`);
78
+ // const targetDir = path.join(process.cwd(), "app", "components", comp);
79
+ // const targetPath = path.join(targetDir, `${comp}.tsx`);
80
+
81
+ // if (fs.existsSync(componentPath)) {
82
+ // // 대상 디렉토리가 없으면 생성
83
+ // if (!fs.existsSync(targetDir)) {
84
+ // fs.mkdirSync(targetDir, { recursive: true });
85
+ // console.log(`Created directory: ${targetDir}`);
86
+ // }
87
+
88
+ // copyFileSync(componentPath, targetPath);
89
+ // console.log(`${comp} component has been added to ${targetPath}`);
90
+ // } else {
91
+ // console.log(
92
+ // `Component ${comp} does not exist in the templates directory.`
93
+ // );
94
+ // }
95
+ // });
96
+ // } else {
97
+ // // 개별 컴포넌트 추가
98
+ // const componentPath = path.join(
99
+ // templateDir,
100
+ // `${component}/${component}.tsx`
101
+ // );
102
+ // const targetDir = path.join(
103
+ // process.cwd(),
104
+ // "app",
105
+ // "components",
106
+ // component
107
+ // );
108
+ // const targetPath = path.join(targetDir, `${component}.tsx`);
109
+
110
+ // if (fs.existsSync(componentPath)) {
111
+ // // 대상 디렉토리가 없으면 생성
112
+ // if (!fs.existsSync(targetDir)) {
113
+ // fs.mkdirSync(targetDir, { recursive: true });
114
+ // console.log(`Created directory: ${targetDir}`);
115
+ // }
116
+
117
+ // copyFileSync(componentPath, targetPath);
118
+ // console.log(`${component} component has been added to ${targetPath}`);
119
+ // } else {
120
+ // console.log(
121
+ // `Component ${component} does not exist in the templates directory.`
122
+ // );
123
+ // }
124
+ // }
125
+ // })
126
+ // .catch((error) => {
127
+ // console.error("Error:", error);
128
+ // });
package/cli/init.js CHANGED
@@ -1,6 +1,6 @@
1
- #!/usr/bin/env node
2
- import inquirer from "inquirer"; // require -> import
3
- import { exec } from "child_process"; // require -> import
1
+ #!/usr/bin/env node
2
+ import inquirer from "inquirer";
3
+ import { exec } from "child_process";
4
4
  import fs from "fs"; // 파일 시스템 작업을 위한 모듈
5
5
  import path from "path"; // 경로 작업을 위한 모듈
6
6
 
package/package.json CHANGED
@@ -1,18 +1,17 @@
1
1
  {
2
2
  "name": "atomsystem",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "type": "module",
5
5
  "bin": {
6
- "atomsystem-init": "cli/init.js"
6
+ "atomsystem-init": "cli/init.js",
7
+ "atomsystem-add": "cli/add.js"
7
8
  },
8
9
  "files": [
9
- "bin",
10
- "test",
11
10
  "token.json",
12
11
  "tokens",
13
12
  "build",
14
- "app/component",
15
- "tailwind.config.ts"
13
+ "tailwind.config.ts",
14
+ "cli/templates"
16
15
  ],
17
16
  "scripts": {
18
17
  "dev": "npm run build:token && next dev",
@@ -1,42 +0,0 @@
1
- @tailwind base;
2
- @tailwind components;
3
- @tailwind utilities;
4
-
5
- @layer base {
6
- h1 {
7
- @apply text-mobileH1 lg:text-h1 text-text-standard;
8
- }
9
- h2 {
10
- @apply text-mobileH2 lg:text-h2 text-text-standard;
11
- }
12
- h3 {
13
- @apply text-mobileH3 lg:text-h3 text-text-standard;
14
- }
15
- h4 {
16
- @apply text-mobileH4 lg:text-h4 text-text-standard;
17
- }
18
- h5 {
19
- @apply text-mobileH5 lg:text-h5 text-text-standard;
20
- }
21
- h6 {
22
- @apply text-mobileH6 lg:text-h6 text-text-standard;
23
- }
24
-
25
- p {
26
- @apply text-base text-text-standard;
27
- }
28
-
29
- hr {
30
- @apply border-fill-border;
31
- }
32
- *:focus {
33
- @apply outline-none;
34
- }
35
- }
36
-
37
- @layer components {
38
- .required::after {
39
- content: "*";
40
- @apply ml-1 text-danger;
41
- }
42
- }
File without changes