tylersong 1.0.14 โ†’ 1.0.16

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/README.md CHANGED
@@ -46,6 +46,23 @@
46
46
  npx tylersong
47
47
  ```
48
48
 
49
+ ### ๐Ÿ”ง ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ์„ค์ • (์„ ํƒ์‚ฌํ•ญ)
50
+
51
+ ๋” ์ž์„ธํ•œ ๊ฒฝ๋ ฅ ์ •๋ณด์™€ ํฌํŠธํด๋ฆฌ์˜ค ์ •๋ณด๋ฅผ ๋ณด๋ ค๋ฉด Sanity CMS ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์„ค์ •ํ•˜์„ธ์š”:
52
+
53
+ ```bash
54
+ # ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ์„ค์ •
55
+ export SANITY_PROJECT_ID='your-project-id'
56
+ export SANITY_DATASET='production'
57
+ export SANITY_API_VERSION='2025-12-06'
58
+ export SANITY_API_TOKEN='your-token' # ์„ ํƒ์‚ฌํ•ญ, ์ฝ๊ธฐ ์ „์šฉ ๊ถŒ์žฅ
59
+
60
+ # ์‹คํ–‰
61
+ npx tylersong
62
+ ```
63
+
64
+ > **์ฐธ๊ณ **: ํ™˜๊ฒฝ ๋ณ€์ˆ˜๊ฐ€ ์„ค์ •๋˜์ง€ ์•Š์•„๋„ ๊ธฐ๋ณธ ํ”„๋กœํ•„ ์ •๋ณด๋Š” ์ •์ƒ์ ์œผ๋กœ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.
65
+
49
66
  ### ๐Ÿ“ฆ ์ „์—ญ ์„ค์น˜
50
67
 
51
68
  ์ž์ฃผ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด ์ „์—ญ์œผ๋กœ ์„ค์น˜ํ•˜์„ธ์š”:
@@ -22,5 +22,5 @@ export declare const getPortfolio: (name: string | undefined) => Promise<Portfol
22
22
  /**
23
23
  * Sanity ํด๋ผ์ด์–ธํŠธ ์ธ์Šคํ„ด์Šค๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค (ํ•„์š”ํ•œ ๊ฒฝ์šฐ)
24
24
  */
25
- export declare const getSanityClient: () => ReturnType<typeof createClient>;
25
+ export declare const getSanityClient: () => ReturnType<typeof createClient> | null;
26
26
  //# sourceMappingURL=sanity.d.ts.map
@@ -1,72 +1,33 @@
1
1
  import { createClient } from "@sanity/client";
2
- import { readFileSync } from "fs";
3
- import { join, dirname } from "path";
4
- import { fileURLToPath } from "url";
5
- const __filename = fileURLToPath(import.meta.url);
6
- const __dirname = dirname(__filename);
7
2
  /**
8
- * .env ํŒŒ์ผ์—์„œ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์ฝ์–ด์˜ต๋‹ˆ๋‹ค
3
+ * ํ™˜๊ฒฝ ๋ณ€์ˆ˜์—์„œ Sanity ์„ค์ •์„ ๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค
4
+ * npm ํŒจํ‚ค์ง€์—์„œ๋Š” process.env์—์„œ๋งŒ ์ฝ์Šต๋‹ˆ๋‹ค
5
+ * ํ™˜๊ฒฝ ๋ณ€์ˆ˜๊ฐ€ ์—†์œผ๋ฉด null์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค
9
6
  */
10
7
  const loadEnvConfig = () => {
11
- try {
12
- const envPath = join(__dirname, "..", "..", ".env");
13
- const envContent = readFileSync(envPath, "utf-8");
14
- const config = {};
15
- envContent.split("\n").forEach((line) => {
16
- const trimmedLine = line.trim();
17
- if (trimmedLine && !trimmedLine.startsWith("#")) {
18
- const [key, ...valueParts] = trimmedLine.split("=");
19
- const value = valueParts.join("=").replace(/^["']|["']$/g, "");
20
- switch (key.trim()) {
21
- case "SANITY_PROJECT_ID":
22
- config.projectId = value;
23
- break;
24
- case "SANITY_DATASET":
25
- config.dataset = value;
26
- break;
27
- case "SANITY_API_VERSION":
28
- config.apiVersion = value;
29
- break;
30
- case "SANITY_API_TOKEN":
31
- config.token = value;
32
- break;
33
- }
34
- }
35
- });
36
- if (!config.projectId || !config.dataset || !config.apiVersion) {
37
- throw new Error("ํ•„์ˆ˜ Sanity ํ™˜๊ฒฝ ๋ณ€์ˆ˜๊ฐ€ ๋ˆ„๋ฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค: SANITY_PROJECT_ID, SANITY_DATASET, SANITY_API_VERSION");
38
- }
39
- return {
40
- projectId: config.projectId,
41
- dataset: config.dataset,
42
- apiVersion: config.apiVersion,
43
- token: config.token,
44
- useCdn: false, // ์ฝ๊ธฐ ์ „์šฉ์ด๋ฏ€๋กœ CDN ์‚ฌ์šฉ ์•ˆ ํ•จ
45
- };
46
- }
47
- catch (error) {
48
- // .env ํŒŒ์ผ์ด ์—†๊ฑฐ๋‚˜ ์ฝ์„ ์ˆ˜ ์—†๋Š” ๊ฒฝ์šฐ process.env์—์„œ ์‹œ๋„
49
- const projectId = process.env.SANITY_PROJECT_ID;
50
- const dataset = process.env.SANITY_DATASET;
51
- const apiVersion = process.env.SANITY_API_VERSION;
52
- const token = process.env.SANITY_API_TOKEN;
53
- if (!projectId || !dataset || !apiVersion) {
54
- throw new Error("Sanity ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. .env ํŒŒ์ผ์„ ํ™•์ธํ•ด์ฃผ์„ธ์š”.");
55
- }
56
- return {
57
- projectId,
58
- dataset,
59
- apiVersion,
60
- token,
61
- useCdn: false,
62
- };
8
+ const projectId = process.env.SANITY_PROJECT_ID;
9
+ const dataset = process.env.SANITY_DATASET;
10
+ const apiVersion = process.env.SANITY_API_VERSION;
11
+ const token = process.env.SANITY_API_TOKEN;
12
+ if (!projectId || !dataset || !apiVersion) {
13
+ return null;
63
14
  }
15
+ return {
16
+ projectId,
17
+ dataset,
18
+ apiVersion,
19
+ token,
20
+ useCdn: false, // ์ฝ๊ธฐ ์ „์šฉ์ด๋ฏ€๋กœ CDN ์‚ฌ์šฉ ์•ˆ ํ•จ
21
+ };
64
22
  };
65
23
  /**
66
24
  * Sanity ํด๋ผ์ด์–ธํŠธ ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค
67
25
  */
68
26
  const createSanityClient = () => {
69
27
  const config = loadEnvConfig();
28
+ if (!config) {
29
+ return null;
30
+ }
70
31
  return createClient({
71
32
  projectId: config.projectId,
72
33
  dataset: config.dataset,
@@ -75,13 +36,26 @@ const createSanityClient = () => {
75
36
  useCdn: config.useCdn,
76
37
  });
77
38
  };
78
- // Sanity ํด๋ผ์ด์–ธํŠธ ์ธ์Šคํ„ด์Šค
79
- const client = createSanityClient();
39
+ // Sanity ํด๋ผ์ด์–ธํŠธ ์ธ์Šคํ„ด์Šค (์ง€์—ฐ ์ดˆ๊ธฐํ™”)
40
+ let client = null;
41
+ /**
42
+ * Sanity ํด๋ผ์ด์–ธํŠธ๋ฅผ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค (์ง€์—ฐ ์ดˆ๊ธฐํ™”)
43
+ */
44
+ const getClient = () => {
45
+ if (client === null) {
46
+ client = createSanityClient();
47
+ }
48
+ return client;
49
+ };
80
50
  /**
81
51
  * ๋ชจ๋“  Experience(๊ฒฝ๋ ฅ) ๋ฐ์ดํ„ฐ๋ฅผ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค
82
52
  */
83
53
  export const getExperiences = async () => {
84
54
  try {
55
+ const client = getClient();
56
+ if (!client) {
57
+ return [];
58
+ }
85
59
  const query = `*[_type == "experience"] | order(startDate asc) {
86
60
  _id,
87
61
  company,
@@ -104,6 +78,10 @@ export const getExperiences = async () => {
104
78
  */
105
79
  export const getExperienceById = async (id) => {
106
80
  try {
81
+ const client = getClient();
82
+ if (!client) {
83
+ return null;
84
+ }
107
85
  const query = `*[_type == "experience" && _id == $id][0] {
108
86
  _id,
109
87
  company,
@@ -114,7 +92,9 @@ export const getExperienceById = async (id) => {
114
92
  technologies,
115
93
  location
116
94
  }`;
117
- const experience = await client.fetch(query, { id });
95
+ const experience = await client.fetch(query, {
96
+ id,
97
+ });
118
98
  return experience;
119
99
  }
120
100
  catch (error) {
@@ -123,6 +103,10 @@ export const getExperienceById = async (id) => {
123
103
  };
124
104
  export const getPortfolio = async (name) => {
125
105
  try {
106
+ const client = getClient();
107
+ if (!client) {
108
+ return null;
109
+ }
126
110
  // name์ด ์ œ๊ณต๋œ ๊ฒฝ์šฐ author์˜ name๊ณผ ์ผ์น˜ํ•˜๋Š” portfolio๋งŒ ์กฐํšŒ
127
111
  const query = `*[_type == "portfolio" && author->name == $name][0] {
128
112
  "author": author-> {
@@ -142,5 +126,5 @@ export const getPortfolio = async (name) => {
142
126
  /**
143
127
  * Sanity ํด๋ผ์ด์–ธํŠธ ์ธ์Šคํ„ด์Šค๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค (ํ•„์š”ํ•œ ๊ฒฝ์šฐ)
144
128
  */
145
- export const getSanityClient = () => client;
129
+ export const getSanityClient = () => getClient();
146
130
  //# sourceMappingURL=sanity.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tylersong",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "๋‚˜์˜ CLI ์ž๊ธฐ์†Œ๊ฐœ ๋„๊ตฌ",
5
5
  "main": "dist/index.js",
6
6
  "bin": {