atomsystem 0.1.46 → 0.1.47

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/dist/index.js +212 -43
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,16 +1,182 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- addComponent,
4
- components,
5
- logger
6
- } from "./chunk-US4VD4EW.js";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __esm = (fn, res) => function __init() {
5
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
+ };
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+
12
+ // node_modules/tsup/assets/esm_shims.js
13
+ import path from "path";
14
+ import { fileURLToPath } from "url";
15
+ var init_esm_shims = __esm({
16
+ "node_modules/tsup/assets/esm_shims.js"() {
17
+ "use strict";
18
+ }
19
+ });
20
+
21
+ // src/utils/logger.ts
22
+ import chalk from "chalk";
23
+ var logger;
24
+ var init_logger = __esm({
25
+ "src/utils/logger.ts"() {
26
+ "use strict";
27
+ init_esm_shims();
28
+ logger = {
29
+ error(...args) {
30
+ console.error(chalk.red(...args));
31
+ },
32
+ warn(...args) {
33
+ console.warn(chalk.yellow(...args));
34
+ },
35
+ info(...args) {
36
+ console.info(chalk.cyan(...args));
37
+ },
38
+ success(...args) {
39
+ console.log(chalk.green(...args));
40
+ },
41
+ log(...args) {
42
+ console.log(...args);
43
+ },
44
+ break() {
45
+ console.log("");
46
+ }
47
+ };
48
+ }
49
+ });
50
+
51
+ // src/utils/component.ts
52
+ var component_exports = {};
53
+ __export(component_exports, {
54
+ addComponent: () => addComponent,
55
+ baseDir: () => baseDir,
56
+ components: () => components,
57
+ dependenciesMap: () => dependenciesMap,
58
+ templateDir: () => templateDir,
59
+ updateGlobalsCss: () => updateGlobalsCss
60
+ });
61
+ import fs from "fs";
62
+ import path2 from "path";
63
+ import { fileURLToPath as fileURLToPath2 } from "url";
64
+ function getBaseDir() {
65
+ const isBuilt = path2.basename(__dirname2) === "dist" || fs.existsSync(path2.join(__dirname2, "index.js"));
66
+ if (isBuilt) {
67
+ return path2.join(__dirname2, "..");
68
+ }
69
+ if (path2.basename(__dirname2) === "utils" || path2.basename(__dirname2) === "commands") {
70
+ return path2.join(__dirname2, "..", "..");
71
+ }
72
+ return path2.join(__dirname2, "..", "..");
73
+ }
74
+ function addComponent(comp, cwd, addedComponents) {
75
+ if (addedComponents.has(comp)) return;
76
+ addedComponents.add(comp);
77
+ const componentSourceDir = path2.join(templateDir, comp);
78
+ const componentPath = path2.join(componentSourceDir, `${comp}.tsx`);
79
+ const targetDir = path2.join(cwd, "app", "components", comp);
80
+ const targetPath = path2.join(targetDir, `${comp}.tsx`);
81
+ const cssFileName = `${comp}.css`.toLowerCase();
82
+ const sourceCssPath = path2.join(componentSourceDir, cssFileName);
83
+ const targetCssPath = path2.join(targetDir, cssFileName);
84
+ if (fs.existsSync(componentPath)) {
85
+ if (!fs.existsSync(targetDir)) {
86
+ fs.mkdirSync(targetDir, { recursive: true });
87
+ logger.info(`\uB514\uB809\uD1A0\uB9AC \uC0DD\uC131: ${targetDir}`);
88
+ }
89
+ fs.copyFileSync(componentPath, targetPath);
90
+ logger.success(`\u2705 ${comp} \uCEF4\uD3EC\uB10C\uD2B8(TSX)\uAC00 \uCD94\uAC00\uB418\uC5C8\uC2B5\uB2C8\uB2E4: ${targetPath}`);
91
+ if (fs.existsSync(sourceCssPath)) {
92
+ fs.copyFileSync(sourceCssPath, targetCssPath);
93
+ logger.success(`\u2705 ${comp} \uCEF4\uD3EC\uB10C\uD2B8(CSS)\uAC00 \uCD94\uAC00\uB418\uC5C8\uC2B5\uB2C8\uB2E4: ${targetCssPath}`);
94
+ updateGlobalsCss(comp, cssFileName, cwd);
95
+ }
96
+ if (dependenciesMap[comp]) {
97
+ logger.info(`\u23F3 ${comp}\uC758 \uC758\uC874\uC131 \uCEF4\uD3EC\uB10C\uD2B8 \uD655\uC778 \uC911...`);
98
+ for (const dep of dependenciesMap[comp]) {
99
+ addComponent(dep, cwd, addedComponents);
100
+ }
101
+ }
102
+ } else {
103
+ logger.error(`\u274C ${comp} \uCEF4\uD3EC\uB10C\uD2B8\uAC00 atomsystem\uC5D0 \uC874\uC7AC\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4: ${comp}`);
104
+ }
105
+ }
106
+ function updateGlobalsCss(comp, cssFileName, cwd) {
107
+ const globalsPath = path2.join(cwd, "app", "globals.css");
108
+ const importLine = `@import "./components/${comp}/${cssFileName}";`;
109
+ const componentSectionMarker = "/* Component Styles */";
110
+ if (fs.existsSync(globalsPath)) {
111
+ let content = fs.readFileSync(globalsPath, "utf8");
112
+ if (!content.includes(importLine)) {
113
+ if (content.includes(componentSectionMarker)) {
114
+ const markerIndex = content.indexOf(componentSectionMarker);
115
+ const afterMarker = content.slice(markerIndex);
116
+ const lastImportIndex = afterMarker.lastIndexOf("@import");
117
+ if (lastImportIndex !== -1) {
118
+ const endOfLastImport = markerIndex + lastImportIndex + afterMarker.slice(lastImportIndex).indexOf("\n") + 1;
119
+ content = content.slice(0, endOfLastImport) + importLine + "\n" + content.slice(endOfLastImport);
120
+ } else {
121
+ content = content.slice(0, markerIndex + componentSectionMarker.length) + "\n" + importLine + "\n" + content.slice(markerIndex + componentSectionMarker.length);
122
+ }
123
+ } else {
124
+ content = content.trimEnd() + "\n\n" + componentSectionMarker + "\n" + importLine + "\n";
125
+ }
126
+ fs.writeFileSync(globalsPath, content, "utf8");
127
+ logger.success(`\u2705 globals.css\uC5D0 ${comp} @import\uB97C \uCD94\uAC00\uD588\uC2B5\uB2C8\uB2E4.`);
128
+ }
129
+ } else {
130
+ logger.warn(`\u26A0\uFE0F globals.css\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. \uC218\uB3D9\uC73C\uB85C \uCD94\uAC00\uD574 \uC8FC\uC138\uC694:
131
+ ${importLine}`);
132
+ }
133
+ }
134
+ var __filename2, __dirname2, baseDir, templateDir, components, dependenciesMap;
135
+ var init_component = __esm({
136
+ "src/utils/component.ts"() {
137
+ "use strict";
138
+ init_esm_shims();
139
+ init_logger();
140
+ __filename2 = fileURLToPath2(import.meta.url);
141
+ __dirname2 = path2.dirname(__filename2);
142
+ baseDir = getBaseDir();
143
+ templateDir = path2.join(baseDir, "app", "templates");
144
+ logger.info(`\u{1F50D} Debug: baseDir=${baseDir}`);
145
+ logger.info(`\u{1F50D} Debug: templateDir=${templateDir}`);
146
+ components = [
147
+ "Button",
148
+ "Badge",
149
+ "Card",
150
+ "Collapse",
151
+ "CodeBlock",
152
+ "Navigation",
153
+ "Sidebar",
154
+ "Input",
155
+ "Theme",
156
+ "Tab",
157
+ "Toast",
158
+ "Pagination",
159
+ "Table",
160
+ "Modal",
161
+ "TOC",
162
+ "Dropdown"
163
+ ];
164
+ dependenciesMap = {
165
+ Theme: ["Button", "Form", "Modal"]
166
+ };
167
+ }
168
+ });
7
169
 
8
170
  // src/index.ts
171
+ init_esm_shims();
9
172
  import { Command as Command3 } from "commander";
10
173
 
11
174
  // src/commands/add.ts
175
+ init_esm_shims();
176
+ init_logger();
177
+ init_component();
12
178
  import { Command } from "commander";
13
- import path from "path";
179
+ import path3 from "path";
14
180
  import prompts from "prompts";
15
181
  import { z } from "zod";
16
182
  var addOptionsSchema = z.object({
@@ -23,7 +189,7 @@ var add = new Command().name("add").description("\uD504\uB85C\uC81D\uD2B8\uC5D0
23
189
  const options = addOptionsSchema.parse({
24
190
  components: componentsArg,
25
191
  ...opts,
26
- cwd: path.resolve(opts.cwd)
192
+ cwd: path3.resolve(opts.cwd)
27
193
  });
28
194
  let selectedComponents = options.components || [];
29
195
  if (options.all) {
@@ -53,17 +219,20 @@ var add = new Command().name("add").description("\uD504\uB85C\uC81D\uD2B8\uC5D0
53
219
  });
54
220
 
55
221
  // src/commands/init.ts
222
+ init_esm_shims();
223
+ init_logger();
224
+ init_component();
56
225
  import { Command as Command2 } from "commander";
57
- import fs from "fs";
58
- import path2 from "path";
226
+ import fs2 from "fs";
227
+ import path4 from "path";
59
228
  import { exec } from "child_process";
60
229
  import { promisify } from "util";
61
230
  import ora from "ora";
62
231
  import prompts2 from "prompts";
63
- import { fileURLToPath } from "url";
232
+ import { fileURLToPath as fileURLToPath3 } from "url";
64
233
  import { z as z2 } from "zod";
65
- var __filename2 = fileURLToPath(import.meta.url);
66
- var __dirname2 = path2.dirname(__filename2);
234
+ var __filename3 = fileURLToPath3(import.meta.url);
235
+ var __dirname3 = path4.dirname(__filename3);
67
236
  var execPromise = promisify(exec);
68
237
  var initOptionsSchema = z2.object({
69
238
  cwd: z2.string(),
@@ -73,11 +242,11 @@ var init = new Command2().name("init").description("\uD504\uB85C\uC81D\uD2B8\uB9
73
242
  try {
74
243
  const options = initOptionsSchema.parse({
75
244
  ...opts,
76
- cwd: path2.resolve(opts.cwd)
245
+ cwd: path4.resolve(opts.cwd)
77
246
  });
78
247
  const projectRoot = options.cwd;
79
- const packageJsonPath = path2.join(projectRoot, "package.json");
80
- if (!fs.existsSync(packageJsonPath)) {
248
+ const packageJsonPath = path4.join(projectRoot, "package.json");
249
+ if (!fs2.existsSync(packageJsonPath)) {
81
250
  logger.error("\u274C \uC624\uB958: \uD604\uC7AC \uB514\uB809\uD1A0\uB9AC\uC5D0\uC11C package.json\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.");
82
251
  logger.info("'npm init'\uC744 \uBA3C\uC800 \uC2E4\uD589\uD55C \uD6C4 \uB2E4\uC2DC \uC2DC\uB3C4\uD574 \uC8FC\uC138\uC694.");
83
252
  process.exit(1);
@@ -120,7 +289,7 @@ var init = new Command2().name("init").description("\uD504\uB85C\uC81D\uD2B8\uB9
120
289
  return;
121
290
  }
122
291
  try {
123
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
292
+ const packageJson = JSON.parse(fs2.readFileSync(packageJsonPath, "utf8"));
124
293
  packageJson.type = "module";
125
294
  packageJson.scripts = {
126
295
  ...packageJson.scripts,
@@ -130,17 +299,17 @@ var init = new Command2().name("init").description("\uD504\uB85C\uC81D\uD2B8\uB9
130
299
  "lint": "next lint",
131
300
  "token-build": "node build/build-tokens.js"
132
301
  };
133
- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
302
+ fs2.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
134
303
  logger.success("\u2705 package.json \uC2A4\uD06C\uB9BD\uD2B8 \uC5C5\uB370\uC774\uD2B8 \uC644\uB8CC.");
135
304
  } catch (err) {
136
305
  logger.error("\u274C package.json \uC5C5\uB370\uC774\uD2B8 \uC624\uB958:", err);
137
306
  return;
138
307
  }
139
- const appDir = path2.join(projectRoot, "app");
140
- if (!fs.existsSync(appDir)) fs.mkdirSync(appDir, { recursive: true });
308
+ const appDir = path4.join(projectRoot, "app");
309
+ if (!fs2.existsSync(appDir)) fs2.mkdirSync(appDir, { recursive: true });
141
310
  const files = [
142
311
  {
143
- path: path2.join(appDir, "layout.tsx"),
312
+ path: path4.join(appDir, "layout.tsx"),
144
313
  content: `import { ThemeProvider } from "./components/Theme/Theme";
145
314
  import "./globals.css";
146
315
 
@@ -157,13 +326,13 @@ export default function RootLayout({ children }: { children: React.ReactNode })
157
326
  }`
158
327
  },
159
328
  {
160
- path: path2.join(appDir, "globals.css"),
329
+ path: path4.join(appDir, "globals.css"),
161
330
  content: `@import "tailwindcss";
162
331
  @import "../build/css/_variables.css";
163
332
  @import "../css/text.css";`
164
333
  },
165
334
  {
166
- path: path2.join(appDir, "page.tsx"),
335
+ path: path4.join(appDir, "page.tsx"),
167
336
  content: `import { ThemeSelector } from "./components/Theme/Theme";
168
337
  import { Button } from "./components/Button/Button";
169
338
  import { Card, CardHeader, CardContent, CardFooter } from "./components/Card/Card";
@@ -203,7 +372,7 @@ export default function Page() {
203
372
  }`
204
373
  },
205
374
  {
206
- path: path2.join(projectRoot, "tsconfig.json"),
375
+ path: path4.join(projectRoot, "tsconfig.json"),
207
376
  content: JSON.stringify({
208
377
  compilerOptions: {
209
378
  target: "ES2017",
@@ -229,25 +398,25 @@ export default function Page() {
229
398
  }, null, 2)
230
399
  },
231
400
  {
232
- path: path2.join(projectRoot, "next.config.ts"),
401
+ path: path4.join(projectRoot, "next.config.ts"),
233
402
  content: `import type { NextConfig } from "next";
234
403
 
235
404
  const nextConfig: NextConfig = { reactStrictMode: false };
236
405
  export default nextConfig;`
237
406
  },
238
407
  {
239
- path: path2.join(projectRoot, "postcss.config.mjs"),
408
+ path: path4.join(projectRoot, "postcss.config.mjs"),
240
409
  content: `/** @type {import('postcss-load-config').Config} */
241
410
  const config = { plugins: { "@tailwindcss/postcss": {} } };
242
411
  export default config;`
243
412
  }
244
413
  ];
245
414
  for (const file of files) {
246
- fs.writeFileSync(file.path, file.content);
415
+ fs2.writeFileSync(file.path, file.content);
247
416
  logger.info(`\u2705 \uD30C\uC77C \uC0DD\uC131: ${file.path}`);
248
417
  }
249
- const buildTokensPath = path2.join(projectRoot, "build", "build-tokens.js");
250
- if (fs.existsSync(buildTokensPath)) {
418
+ const buildTokensPath = path4.join(projectRoot, "build", "build-tokens.js");
419
+ if (fs2.existsSync(buildTokensPath)) {
251
420
  const spin = ora("\uB514\uC790\uC778 \uD1A0\uD070 \uBE4C\uB4DC \uC911...").start();
252
421
  try {
253
422
  await execPromise(`node "${buildTokensPath}"`, { cwd: projectRoot });
@@ -258,14 +427,14 @@ export default config;`
258
427
  }
259
428
  }
260
429
  }
261
- const { baseDir: pkgRoot } = await import("./component-SFV77SNH.js");
430
+ const { baseDir: pkgRoot } = await Promise.resolve().then(() => (init_component(), component_exports));
262
431
  logger.info(`\u{1F50D} Debug: pkgRoot=${pkgRoot}`);
263
- const tokenFile = path2.join(pkgRoot, "tokens", "tokens.json");
264
- const buildFile = path2.join(pkgRoot, "build", "build-tokens.js");
265
- const textCssFile = path2.join(pkgRoot, "css", "text.css");
266
- copyFile(tokenFile, path2.join(projectRoot, "tokens", "tokens.json"));
267
- copyFile(buildFile, path2.join(projectRoot, "build", "build-tokens.js"));
268
- copyFile(textCssFile, path2.join(projectRoot, "css", "text.css"));
432
+ const tokenFile = path4.join(pkgRoot, "tokens", "tokens.json");
433
+ const buildFile = path4.join(pkgRoot, "build", "build-tokens.js");
434
+ const textCssFile = path4.join(pkgRoot, "css", "text.css");
435
+ copyFile(tokenFile, path4.join(projectRoot, "tokens", "tokens.json"));
436
+ copyFile(buildFile, path4.join(projectRoot, "build", "build-tokens.js"));
437
+ copyFile(textCssFile, path4.join(projectRoot, "css", "text.css"));
269
438
  const addedComponents = /* @__PURE__ */ new Set();
270
439
  logger.info("\u23F3 \uAE30\uBCF8 \uB370\uBAA8 \uCEF4\uD3EC\uB10C\uD2B8 \uC124\uCE58 \uC911...");
271
440
  addComponent("Button", projectRoot, addedComponents);
@@ -278,10 +447,10 @@ export default config;`
278
447
  }
279
448
  });
280
449
  function copyFile(src, dest) {
281
- const dir = path2.dirname(dest);
282
- if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
283
- if (fs.existsSync(src)) {
284
- fs.copyFileSync(src, dest);
450
+ const dir = path4.dirname(dest);
451
+ if (!fs2.existsSync(dir)) fs2.mkdirSync(dir, { recursive: true });
452
+ if (fs2.existsSync(src)) {
453
+ fs2.copyFileSync(src, dest);
285
454
  logger.info(`\u2705 \uBCF5\uC0AC \uC644\uB8CC: ${src} -> ${dest}`);
286
455
  } else {
287
456
  logger.warn(`\u26A0\uFE0F \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC5B4 \uBCF5\uC0AC\uD558\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4: ${src}`);
@@ -291,12 +460,12 @@ function copyFile(src, dest) {
291
460
  // src/index.ts
292
461
  import { readFileSync } from "fs";
293
462
  import { join } from "path";
294
- import { fileURLToPath as fileURLToPath2 } from "url";
463
+ import { fileURLToPath as fileURLToPath4 } from "url";
295
464
  import { dirname } from "path";
296
- var __filename3 = fileURLToPath2(import.meta.url);
297
- var __dirname3 = dirname(__filename3);
465
+ var __filename4 = fileURLToPath4(import.meta.url);
466
+ var __dirname4 = dirname(__filename4);
298
467
  async function main() {
299
- const packageJsonPath = join(__dirname3, "..", "package.json");
468
+ const packageJsonPath = join(__dirname4, "..", "package.json");
300
469
  const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
301
470
  const program = new Command3().name("atomsystem").description("Atom Ground Design System CLI").version(packageJson.version);
302
471
  program.addCommand(add);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atomsystem",
3
- "version": "0.1.46",
3
+ "version": "0.1.47",
4
4
  "type": "module",
5
5
  "homepage": "https://system.atomground.com",
6
6
  "bin": {
@@ -20,7 +20,7 @@
20
20
  "start": "next start",
21
21
  "lint": "next lint",
22
22
  "token-build": "node build/build-tokens.js",
23
- "cli:build": "tsup src/index.ts --format esm --clean --shims --target node20",
23
+ "cli:build": "tsup src/index.ts --format esm --clean --shims --target node20 --no-splitting",
24
24
  "cli:dev": "tsx src/index.ts"
25
25
  },
26
26
  "peerDependencies": {