galaxy-design 0.2.71 → 0.2.72
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.
|
@@ -11,7 +11,8 @@ import { dirname } from 'path';
|
|
|
11
11
|
* Get GitHub raw content URL
|
|
12
12
|
*/ export function getGitHubRawUrl(filePath) {
|
|
13
13
|
const { owner, repo, branch } = GITHUB_CONFIG;
|
|
14
|
-
|
|
14
|
+
const cacheBust = Date.now();
|
|
15
|
+
return `https://raw.githubusercontent.com/${owner}/${repo}/${branch}/${filePath}?v=${cacheBust}`;
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
18
|
* Fetch file content from GitHub
|
|
@@ -21,7 +22,13 @@ import { dirname } from 'path';
|
|
|
21
22
|
*/ export async function fetchFileFromGitHub(filePath) {
|
|
22
23
|
const url = getGitHubRawUrl(filePath);
|
|
23
24
|
try {
|
|
24
|
-
const response = await fetch(url
|
|
25
|
+
const response = await fetch(url, {
|
|
26
|
+
cache: 'no-store',
|
|
27
|
+
headers: {
|
|
28
|
+
'Cache-Control': 'no-cache',
|
|
29
|
+
Pragma: 'no-cache'
|
|
30
|
+
}
|
|
31
|
+
});
|
|
25
32
|
if (!response.ok) {
|
|
26
33
|
if (response.status === 404) {
|
|
27
34
|
throw new Error(`File not found: ${filePath}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/github-fetcher.ts"],"sourcesContent":["import { writeFileSync, mkdirSync, existsSync } from 'fs';\nimport { dirname } from 'path';\n\n/**\n * GitHub repository configuration\n */\nconst GITHUB_CONFIG = {\n\towner: 'buikevin',\n\trepo: 'galaxy-design',\n\tbranch: 'main',\n};\n\n/**\n * Get GitHub raw content URL\n */\nexport function getGitHubRawUrl(filePath: string): string {\n\tconst { owner, repo, branch } = GITHUB_CONFIG;\n\treturn `https://raw.githubusercontent.com/${owner}/${repo}/${branch}/${filePath}`;\n}\n\n/**\n * Fetch file content from GitHub\n *\n * @param filePath - Relative path in repository\n * @returns File content as string\n */\nexport async function fetchFileFromGitHub(filePath: string): Promise<string> {\n\tconst url = getGitHubRawUrl(filePath);\n\n\ttry {\n\t\tconst response = await fetch(url);\n\n\t\tif (!response.ok) {\n\t\t\tif (response.status === 404) {\n\t\t\t\tthrow new Error(`File not found: ${filePath}`);\n\t\t\t}\n\t\t\tthrow new Error(`Failed to fetch ${filePath}: ${response.statusText}`);\n\t\t}\n\n\t\treturn await response.text();\n\t} catch (error) {\n\t\tif (error instanceof Error) {\n\t\t\tthrow new Error(`GitHub fetch error: ${error.message}`);\n\t\t}\n\t\tthrow new Error(`Unknown error fetching ${filePath}`);\n\t}\n}\n\n/**\n * Fetch and save file from GitHub to local path\n *\n * @param sourceFilePath - Path in GitHub repository\n * @param targetFilePath - Local file path to save\n * @returns True if successful\n */\nexport async function fetchAndSaveFile(\n\tsourceFilePath: string,\n\ttargetFilePath: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst content = await fetchFileFromGitHub(sourceFilePath);\n\n\t\t// Create directory if it doesn't exist\n\t\tconst dir = dirname(targetFilePath);\n\t\tif (!existsSync(dir)) {\n\t\t\tmkdirSync(dir, { recursive: true });\n\t\t}\n\n\t\t// Write file\n\t\twriteFileSync(targetFilePath, content, 'utf-8');\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(`Failed to fetch and save ${sourceFilePath}:`, error);\n\t\treturn false;\n\t}\n}\n\n/**\n * Fetch multiple files from GitHub\n *\n * @param files - Array of { source: githubPath, target: localPath }\n * @returns Results for each file\n */\nexport async function fetchMultipleFiles(\n\tfiles: Array<{ source: string; target: string }>,\n): Promise<Array<{ file: string; success: boolean; error?: string }>> {\n\tconst results = await Promise.all(\n\t\tfiles.map(async ({ source, target }) => {\n\t\t\ttry {\n\t\t\t\tconst success = await fetchAndSaveFile(source, target);\n\t\t\t\treturn {\n\t\t\t\t\tfile: source,\n\t\t\t\t\tsuccess,\n\t\t\t\t\terror: success ? undefined : 'Failed to fetch',\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\treturn {\n\t\t\t\t\tfile: source,\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: error instanceof Error ? error.message : 'Unknown error',\n\t\t\t\t};\n\t\t\t}\n\t\t}),\n\t);\n\n\treturn results;\n}\n\n/**\n * Get component source path in GitHub repository\n *\n * @param platform - Platform (vue, react, angular, react-native, flutter)\n * @param componentName - Component name\n * @param fileName - File name\n * @returns GitHub repository path\n */\nexport function getComponentGitHubPath(\n\tplatform: string,\n\tcomponentName: string,\n\tfileName: string,\n): string {\n\t// Map platform to package directory\n\tconst platformMap: Record<string, string> = {\n\t\tvue: 'packages/vue/src/components',\n\t\treact: 'packages/react/src/components',\n\t\tangular: 'packages/angular/src/components',\n\t\t'react-native': 'packages/react-native/src/components',\n\t\tflutter: 'packages/flutter/lib/components',\n\t};\n\n\tconst basePath = platformMap[platform] || `packages/${platform}/src/components`;\n\treturn `${basePath}/${componentName}/${fileName}`;\n}\n\n/**\n * Check if GitHub repository is accessible\n */\nexport async function checkGitHubConnection(): Promise<boolean> {\n\ttry {\n\t\tconst url = getGitHubRawUrl('README.md');\n\t\tconst response = await fetch(url, { method: 'HEAD' });\n\t\treturn response.ok;\n\t} catch {\n\t\treturn false;\n\t}\n}\n"],"names":["writeFileSync","mkdirSync","existsSync","dirname","GITHUB_CONFIG","owner","repo","branch","getGitHubRawUrl","filePath","fetchFileFromGitHub","url","response","fetch","ok","status","Error","statusText","text","error","message","fetchAndSaveFile","sourceFilePath","targetFilePath","content","dir","recursive","console","fetchMultipleFiles","files","results","Promise","all","map","source","target","success","file","undefined","getComponentGitHubPath","platform","componentName","fileName","platformMap","vue","react","angular","flutter","basePath","checkGitHubConnection","method"],"mappings":"AAAA,SAASA,aAAa,EAAEC,SAAS,EAAEC,UAAU,QAAQ,KAAK;AAC1D,SAASC,OAAO,QAAQ,OAAO;AAE/B;;CAEC,GACD,MAAMC,gBAAgB;IACrBC,OAAO;IACPC,MAAM;IACNC,QAAQ;AACT;AAEA;;CAEC,GACD,OAAO,SAASC,gBAAgBC,QAAgB;IAC/C,MAAM,EAAEJ,KAAK,EAAEC,IAAI,EAAEC,MAAM,EAAE,GAAGH;IAChC,OAAO,CAAC,kCAAkC,
|
|
1
|
+
{"version":3,"sources":["../../src/utils/github-fetcher.ts"],"sourcesContent":["import { writeFileSync, mkdirSync, existsSync } from 'fs';\nimport { dirname } from 'path';\n\n/**\n * GitHub repository configuration\n */\nconst GITHUB_CONFIG = {\n\towner: 'buikevin',\n\trepo: 'galaxy-design',\n\tbranch: 'main',\n};\n\n/**\n * Get GitHub raw content URL\n */\nexport function getGitHubRawUrl(filePath: string): string {\n\tconst { owner, repo, branch } = GITHUB_CONFIG;\n\tconst cacheBust = Date.now();\n\treturn `https://raw.githubusercontent.com/${owner}/${repo}/${branch}/${filePath}?v=${cacheBust}`;\n}\n\n/**\n * Fetch file content from GitHub\n *\n * @param filePath - Relative path in repository\n * @returns File content as string\n */\nexport async function fetchFileFromGitHub(filePath: string): Promise<string> {\n\tconst url = getGitHubRawUrl(filePath);\n\n\ttry {\n\t\tconst response = await fetch(url, {\n\t\t\tcache: 'no-store',\n\t\t\theaders: {\n\t\t\t\t'Cache-Control': 'no-cache',\n\t\t\t\tPragma: 'no-cache',\n\t\t\t},\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tif (response.status === 404) {\n\t\t\t\tthrow new Error(`File not found: ${filePath}`);\n\t\t\t}\n\t\t\tthrow new Error(`Failed to fetch ${filePath}: ${response.statusText}`);\n\t\t}\n\n\t\treturn await response.text();\n\t} catch (error) {\n\t\tif (error instanceof Error) {\n\t\t\tthrow new Error(`GitHub fetch error: ${error.message}`);\n\t\t}\n\t\tthrow new Error(`Unknown error fetching ${filePath}`);\n\t}\n}\n\n/**\n * Fetch and save file from GitHub to local path\n *\n * @param sourceFilePath - Path in GitHub repository\n * @param targetFilePath - Local file path to save\n * @returns True if successful\n */\nexport async function fetchAndSaveFile(\n\tsourceFilePath: string,\n\ttargetFilePath: string,\n): Promise<boolean> {\n\ttry {\n\t\tconst content = await fetchFileFromGitHub(sourceFilePath);\n\n\t\t// Create directory if it doesn't exist\n\t\tconst dir = dirname(targetFilePath);\n\t\tif (!existsSync(dir)) {\n\t\t\tmkdirSync(dir, { recursive: true });\n\t\t}\n\n\t\t// Write file\n\t\twriteFileSync(targetFilePath, content, 'utf-8');\n\t\treturn true;\n\t} catch (error) {\n\t\tconsole.error(`Failed to fetch and save ${sourceFilePath}:`, error);\n\t\treturn false;\n\t}\n}\n\n/**\n * Fetch multiple files from GitHub\n *\n * @param files - Array of { source: githubPath, target: localPath }\n * @returns Results for each file\n */\nexport async function fetchMultipleFiles(\n\tfiles: Array<{ source: string; target: string }>,\n): Promise<Array<{ file: string; success: boolean; error?: string }>> {\n\tconst results = await Promise.all(\n\t\tfiles.map(async ({ source, target }) => {\n\t\t\ttry {\n\t\t\t\tconst success = await fetchAndSaveFile(source, target);\n\t\t\t\treturn {\n\t\t\t\t\tfile: source,\n\t\t\t\t\tsuccess,\n\t\t\t\t\terror: success ? undefined : 'Failed to fetch',\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\treturn {\n\t\t\t\t\tfile: source,\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: error instanceof Error ? error.message : 'Unknown error',\n\t\t\t\t};\n\t\t\t}\n\t\t}),\n\t);\n\n\treturn results;\n}\n\n/**\n * Get component source path in GitHub repository\n *\n * @param platform - Platform (vue, react, angular, react-native, flutter)\n * @param componentName - Component name\n * @param fileName - File name\n * @returns GitHub repository path\n */\nexport function getComponentGitHubPath(\n\tplatform: string,\n\tcomponentName: string,\n\tfileName: string,\n): string {\n\t// Map platform to package directory\n\tconst platformMap: Record<string, string> = {\n\t\tvue: 'packages/vue/src/components',\n\t\treact: 'packages/react/src/components',\n\t\tangular: 'packages/angular/src/components',\n\t\t'react-native': 'packages/react-native/src/components',\n\t\tflutter: 'packages/flutter/lib/components',\n\t};\n\n\tconst basePath = platformMap[platform] || `packages/${platform}/src/components`;\n\treturn `${basePath}/${componentName}/${fileName}`;\n}\n\n/**\n * Check if GitHub repository is accessible\n */\nexport async function checkGitHubConnection(): Promise<boolean> {\n\ttry {\n\t\tconst url = getGitHubRawUrl('README.md');\n\t\tconst response = await fetch(url, { method: 'HEAD' });\n\t\treturn response.ok;\n\t} catch {\n\t\treturn false;\n\t}\n}\n"],"names":["writeFileSync","mkdirSync","existsSync","dirname","GITHUB_CONFIG","owner","repo","branch","getGitHubRawUrl","filePath","cacheBust","Date","now","fetchFileFromGitHub","url","response","fetch","cache","headers","Pragma","ok","status","Error","statusText","text","error","message","fetchAndSaveFile","sourceFilePath","targetFilePath","content","dir","recursive","console","fetchMultipleFiles","files","results","Promise","all","map","source","target","success","file","undefined","getComponentGitHubPath","platform","componentName","fileName","platformMap","vue","react","angular","flutter","basePath","checkGitHubConnection","method"],"mappings":"AAAA,SAASA,aAAa,EAAEC,SAAS,EAAEC,UAAU,QAAQ,KAAK;AAC1D,SAASC,OAAO,QAAQ,OAAO;AAE/B;;CAEC,GACD,MAAMC,gBAAgB;IACrBC,OAAO;IACPC,MAAM;IACNC,QAAQ;AACT;AAEA;;CAEC,GACD,OAAO,SAASC,gBAAgBC,QAAgB;IAC/C,MAAM,EAAEJ,KAAK,EAAEC,IAAI,EAAEC,MAAM,EAAE,GAAGH;IAChC,MAAMM,YAAYC,KAAKC,GAAG;IAC1B,OAAO,CAAC,kCAAkC,EAAEP,MAAM,CAAC,EAAEC,KAAK,CAAC,EAAEC,OAAO,CAAC,EAAEE,SAAS,GAAG,EAAEC,WAAW;AACjG;AAEA;;;;;CAKC,GACD,OAAO,eAAeG,oBAAoBJ,QAAgB;IACzD,MAAMK,MAAMN,gBAAgBC;IAE5B,IAAI;QACH,MAAMM,WAAW,MAAMC,MAAMF,KAAK;YACjCG,OAAO;YACPC,SAAS;gBACR,iBAAiB;gBACjBC,QAAQ;YACT;QACD;QAEA,IAAI,CAACJ,SAASK,EAAE,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O,GAAG;YACjD;QACD;IACD;IAGD,OAAOU;AACR;AAEA;;;;;;;CAOC,GACD,OAAO,SAASS,uBACfC,QAAgB,EAChBC,aAAqB,EACrBC,QAAgB;IAEhB,oCAAoC;IACpC,MAAMC,cAAsC;QAC3CC,KAAK;QACLC,OAAO;QACPC,SAAS;QACT,gBAAgB;QAChBC,SAAS;IACV;IAEA,MAAMC,WAAWL,WAAW,CAACH,SAAS,IAAI,CAAC,SAAS,EAAEA,SAAS,eAAe,CAAC;IAC/E,OAAO,GAAGQ,SAAS,CAAC,EAAEP,cAAc,CAAC,EAAEC,UAAU;AAClD;AAEA;;CAEC,GACD,OAAO,eAAeO;IACrB,IAAI;QACH,MAAMzC,MAAMN,gBAAgB;QAC5B,MAAMO,WAAW,MAAMC,MAAMF,KAAK;YAAE0C,QAAQ;QAAO;QACnD,OAAOzC,SAASK,EAAE;IACnB,EAAE,UAAM;QACP,OAAO;IACR;AACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "galaxy-design",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.72",
|
|
4
4
|
"description": "CLI tool for adding Galaxy UI components to your Vue, React, Angular, Next.js, Nuxt.js, React Native, or Flutter project",
|
|
5
5
|
"author": "Bùi Trọng Hiếu (kevinbui) <kevinbui210191@gmail.com>",
|
|
6
6
|
"license": "MIT",
|