@oaysus/cli 0.1.0
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 +166 -0
- package/bin/oaysus.js +6 -0
- package/dist/cli.d.ts +11 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +174 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +75 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +2 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +23 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/whoami.d.ts +2 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +44 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/components/App.d.ts +43 -0
- package/dist/components/App.d.ts.map +1 -0
- package/dist/components/App.js +63 -0
- package/dist/components/App.js.map +1 -0
- package/dist/components/BuildProgress.d.ts +16 -0
- package/dist/components/BuildProgress.d.ts.map +1 -0
- package/dist/components/BuildProgress.js +42 -0
- package/dist/components/BuildProgress.js.map +1 -0
- package/dist/components/ErrorMessage.d.ts +13 -0
- package/dist/components/ErrorMessage.d.ts.map +1 -0
- package/dist/components/ErrorMessage.js +29 -0
- package/dist/components/ErrorMessage.js.map +1 -0
- package/dist/components/FileList.d.ts +13 -0
- package/dist/components/FileList.d.ts.map +1 -0
- package/dist/components/FileList.js +25 -0
- package/dist/components/FileList.js.map +1 -0
- package/dist/components/Header.d.ts +12 -0
- package/dist/components/Header.d.ts.map +1 -0
- package/dist/components/Header.js +18 -0
- package/dist/components/Header.js.map +1 -0
- package/dist/components/LastCommand.d.ts +9 -0
- package/dist/components/LastCommand.d.ts.map +1 -0
- package/dist/components/LastCommand.js +39 -0
- package/dist/components/LastCommand.js.map +1 -0
- package/dist/components/Logo.d.ts +14 -0
- package/dist/components/Logo.d.ts.map +1 -0
- package/dist/components/Logo.js +44 -0
- package/dist/components/Logo.js.map +1 -0
- package/dist/components/ProgressBar.d.ts +13 -0
- package/dist/components/ProgressBar.d.ts.map +1 -0
- package/dist/components/ProgressBar.js +20 -0
- package/dist/components/ProgressBar.js.map +1 -0
- package/dist/components/SlashCommands.d.ts +17 -0
- package/dist/components/SlashCommands.d.ts.map +1 -0
- package/dist/components/SlashCommands.js +59 -0
- package/dist/components/SlashCommands.js.map +1 -0
- package/dist/components/Spinner.d.ts +13 -0
- package/dist/components/Spinner.d.ts.map +1 -0
- package/dist/components/Spinner.js +16 -0
- package/dist/components/Spinner.js.map +1 -0
- package/dist/components/StatusCard.d.ts +14 -0
- package/dist/components/StatusCard.d.ts.map +1 -0
- package/dist/components/StatusCard.js +40 -0
- package/dist/components/StatusCard.js.map +1 -0
- package/dist/components/SuccessMessage.d.ts +12 -0
- package/dist/components/SuccessMessage.d.ts.map +1 -0
- package/dist/components/SuccessMessage.js +18 -0
- package/dist/components/SuccessMessage.js.map +1 -0
- package/dist/components/UploadProgress.d.ts +13 -0
- package/dist/components/UploadProgress.d.ts.map +1 -0
- package/dist/components/UploadProgress.js +40 -0
- package/dist/components/UploadProgress.js.map +1 -0
- package/dist/components/ValidationProgress.d.ts +12 -0
- package/dist/components/ValidationProgress.d.ts.map +1 -0
- package/dist/components/ValidationProgress.js +44 -0
- package/dist/components/ValidationProgress.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/core/framework-registry.d.ts +27 -0
- package/dist/lib/core/framework-registry.d.ts.map +1 -0
- package/dist/lib/core/framework-registry.js +67 -0
- package/dist/lib/core/framework-registry.js.map +1 -0
- package/dist/lib/core/types.d.ts +124 -0
- package/dist/lib/core/types.d.ts.map +1 -0
- package/dist/lib/core/types.js +6 -0
- package/dist/lib/core/types.js.map +1 -0
- package/dist/lib/project-generator.d.ts +15 -0
- package/dist/lib/project-generator.d.ts.map +1 -0
- package/dist/lib/project-generator.js +286 -0
- package/dist/lib/project-generator.js.map +1 -0
- package/dist/lib/push.d.ts +20 -0
- package/dist/lib/push.d.ts.map +1 -0
- package/dist/lib/push.js +222 -0
- package/dist/lib/push.js.map +1 -0
- package/dist/lib/react/builder.d.ts +45 -0
- package/dist/lib/react/builder.d.ts.map +1 -0
- package/dist/lib/react/builder.js +381 -0
- package/dist/lib/react/builder.js.map +1 -0
- package/dist/lib/react/bundler.d.ts +104 -0
- package/dist/lib/react/bundler.d.ts.map +1 -0
- package/dist/lib/react/bundler.js +654 -0
- package/dist/lib/react/bundler.js.map +1 -0
- package/dist/lib/react/config.d.ts +34 -0
- package/dist/lib/react/config.d.ts.map +1 -0
- package/dist/lib/react/config.js +64 -0
- package/dist/lib/react/config.js.map +1 -0
- package/dist/lib/react/import-map.d.ts +54 -0
- package/dist/lib/react/import-map.d.ts.map +1 -0
- package/dist/lib/react/import-map.js +187 -0
- package/dist/lib/react/import-map.js.map +1 -0
- package/dist/lib/shared/auth-middleware.d.ts +29 -0
- package/dist/lib/shared/auth-middleware.d.ts.map +1 -0
- package/dist/lib/shared/auth-middleware.js +48 -0
- package/dist/lib/shared/auth-middleware.js.map +1 -0
- package/dist/lib/shared/auth.d.ts +50 -0
- package/dist/lib/shared/auth.d.ts.map +1 -0
- package/dist/lib/shared/auth.js +243 -0
- package/dist/lib/shared/auth.js.map +1 -0
- package/dist/lib/shared/cdn-downloader.d.ts +30 -0
- package/dist/lib/shared/cdn-downloader.d.ts.map +1 -0
- package/dist/lib/shared/cdn-downloader.js +126 -0
- package/dist/lib/shared/cdn-downloader.js.map +1 -0
- package/dist/lib/shared/command-history.d.ts +29 -0
- package/dist/lib/shared/command-history.d.ts.map +1 -0
- package/dist/lib/shared/command-history.js +73 -0
- package/dist/lib/shared/command-history.js.map +1 -0
- package/dist/lib/shared/commands.d.ts +24 -0
- package/dist/lib/shared/commands.d.ts.map +1 -0
- package/dist/lib/shared/commands.js +63 -0
- package/dist/lib/shared/commands.js.map +1 -0
- package/dist/lib/shared/config.d.ts +40 -0
- package/dist/lib/shared/config.d.ts.map +1 -0
- package/dist/lib/shared/config.js +69 -0
- package/dist/lib/shared/config.js.map +1 -0
- package/dist/lib/shared/file-utils.d.ts +45 -0
- package/dist/lib/shared/file-utils.d.ts.map +1 -0
- package/dist/lib/shared/file-utils.js +88 -0
- package/dist/lib/shared/file-utils.js.map +1 -0
- package/dist/lib/shared/import-analyzer.d.ts +49 -0
- package/dist/lib/shared/import-analyzer.d.ts.map +1 -0
- package/dist/lib/shared/import-analyzer.js +268 -0
- package/dist/lib/shared/import-analyzer.js.map +1 -0
- package/dist/lib/shared/path-builder.d.ts +55 -0
- package/dist/lib/shared/path-builder.d.ts.map +1 -0
- package/dist/lib/shared/path-builder.js +66 -0
- package/dist/lib/shared/path-builder.js.map +1 -0
- package/dist/lib/shared/uploader.d.ts +79 -0
- package/dist/lib/shared/uploader.d.ts.map +1 -0
- package/dist/lib/shared/uploader.js +340 -0
- package/dist/lib/shared/uploader.js.map +1 -0
- package/dist/lib/shared/zip-creator.d.ts +18 -0
- package/dist/lib/shared/zip-creator.d.ts.map +1 -0
- package/dist/lib/shared/zip-creator.js +131 -0
- package/dist/lib/shared/zip-creator.js.map +1 -0
- package/dist/lib/svelte/builder.d.ts +37 -0
- package/dist/lib/svelte/builder.d.ts.map +1 -0
- package/dist/lib/svelte/builder.js +364 -0
- package/dist/lib/svelte/builder.js.map +1 -0
- package/dist/lib/svelte/bundler.d.ts +92 -0
- package/dist/lib/svelte/bundler.d.ts.map +1 -0
- package/dist/lib/svelte/bundler.js +499 -0
- package/dist/lib/svelte/bundler.js.map +1 -0
- package/dist/lib/svelte/config.d.ts +22 -0
- package/dist/lib/svelte/config.d.ts.map +1 -0
- package/dist/lib/svelte/config.js +65 -0
- package/dist/lib/svelte/config.js.map +1 -0
- package/dist/lib/svelte/import-map.d.ts +42 -0
- package/dist/lib/svelte/import-map.d.ts.map +1 -0
- package/dist/lib/svelte/import-map.js +197 -0
- package/dist/lib/svelte/import-map.js.map +1 -0
- package/dist/lib/template-manager.d.ts +33 -0
- package/dist/lib/template-manager.d.ts.map +1 -0
- package/dist/lib/template-manager.js +69 -0
- package/dist/lib/template-manager.js.map +1 -0
- package/dist/lib/validator.d.ts +10 -0
- package/dist/lib/validator.d.ts.map +1 -0
- package/dist/lib/validator.js +343 -0
- package/dist/lib/validator.js.map +1 -0
- package/dist/lib/vue/builder.d.ts +37 -0
- package/dist/lib/vue/builder.d.ts.map +1 -0
- package/dist/lib/vue/builder.js +366 -0
- package/dist/lib/vue/builder.js.map +1 -0
- package/dist/lib/vue/bundler.d.ts +78 -0
- package/dist/lib/vue/bundler.d.ts.map +1 -0
- package/dist/lib/vue/bundler.js +208 -0
- package/dist/lib/vue/bundler.js.map +1 -0
- package/dist/lib/vue/config.d.ts +18 -0
- package/dist/lib/vue/config.d.ts.map +1 -0
- package/dist/lib/vue/config.js +42 -0
- package/dist/lib/vue/config.js.map +1 -0
- package/dist/lib/vue/import-map.d.ts +42 -0
- package/dist/lib/vue/import-map.d.ts.map +1 -0
- package/dist/lib/vue/import-map.js +156 -0
- package/dist/lib/vue/import-map.js.map +1 -0
- package/dist/screens/BuildScreen.d.ts +8 -0
- package/dist/screens/BuildScreen.d.ts.map +1 -0
- package/dist/screens/BuildScreen.js +158 -0
- package/dist/screens/BuildScreen.js.map +1 -0
- package/dist/screens/CreateScreen.d.ts +12 -0
- package/dist/screens/CreateScreen.d.ts.map +1 -0
- package/dist/screens/CreateScreen.js +305 -0
- package/dist/screens/CreateScreen.js.map +1 -0
- package/dist/screens/InitScreen.d.ts +11 -0
- package/dist/screens/InitScreen.d.ts.map +1 -0
- package/dist/screens/InitScreen.js +339 -0
- package/dist/screens/InitScreen.js.map +1 -0
- package/dist/screens/LoginScreen.d.ts +15 -0
- package/dist/screens/LoginScreen.d.ts.map +1 -0
- package/dist/screens/LoginScreen.js +427 -0
- package/dist/screens/LoginScreen.js.map +1 -0
- package/dist/screens/LogoutScreen.d.ts +15 -0
- package/dist/screens/LogoutScreen.d.ts.map +1 -0
- package/dist/screens/LogoutScreen.js +187 -0
- package/dist/screens/LogoutScreen.js.map +1 -0
- package/dist/screens/PushScreen.d.ts +12 -0
- package/dist/screens/PushScreen.d.ts.map +1 -0
- package/dist/screens/PushScreen.js +546 -0
- package/dist/screens/PushScreen.js.map +1 -0
- package/dist/screens/ValidateScreen.d.ts +12 -0
- package/dist/screens/ValidateScreen.d.ts.map +1 -0
- package/dist/screens/ValidateScreen.js +193 -0
- package/dist/screens/ValidateScreen.js.map +1 -0
- package/dist/screens/WelcomeScreen.d.ts +39 -0
- package/dist/screens/WelcomeScreen.d.ts.map +1 -0
- package/dist/screens/WelcomeScreen.js +297 -0
- package/dist/screens/WelcomeScreen.js.map +1 -0
- package/dist/screens/WhoamiScreen.d.ts +14 -0
- package/dist/screens/WhoamiScreen.d.ts.map +1 -0
- package/dist/screens/WhoamiScreen.js +180 -0
- package/dist/screens/WhoamiScreen.js.map +1 -0
- package/dist/types/index.d.ts +40 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/templates.d.ts +55 -0
- package/dist/types/templates.d.ts.map +1 -0
- package/dist/types/templates.js +6 -0
- package/dist/types/templates.js.map +1 -0
- package/dist/types/validation.d.ts +108 -0
- package/dist/types/validation.d.ts.map +1 -0
- package/dist/types/validation.js +6 -0
- package/dist/types/validation.js.map +1 -0
- package/package.json +94 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* R2 Path Builder
|
|
3
|
+
* Constructs environment-aware R2 paths for component theme uploads
|
|
4
|
+
*/
|
|
5
|
+
import { getEnvironment, DEVELOPER } from './config.js';
|
|
6
|
+
/**
|
|
7
|
+
* Build R2 base path for component theme upload
|
|
8
|
+
*
|
|
9
|
+
* Path structure (base path without filename):
|
|
10
|
+
* - Local: local/{developer}/{websiteId}/{themeName}/{version}
|
|
11
|
+
* - Dev: dev/{websiteId}/{themeName}/{version}
|
|
12
|
+
* - Prod: prod/{websiteId}/{themeName}/{version}
|
|
13
|
+
*
|
|
14
|
+
* Build files are appended to this base path:
|
|
15
|
+
* - {basePath}/index.js
|
|
16
|
+
* - {basePath}/index.css
|
|
17
|
+
* - {basePath}/metadata.json
|
|
18
|
+
*/
|
|
19
|
+
export function buildR2Path(packageJson, credentials) {
|
|
20
|
+
const env = getEnvironment();
|
|
21
|
+
const websiteId = credentials.websiteId;
|
|
22
|
+
const themeName = packageJson.oaysus?.theme?.name || packageJson.name;
|
|
23
|
+
const version = packageJson.version;
|
|
24
|
+
// Local environment includes developer namespace
|
|
25
|
+
if (env === 'local') {
|
|
26
|
+
const developer = DEVELOPER || 'unknown';
|
|
27
|
+
return `local/${developer}/${websiteId}/${themeName}/${version}`;
|
|
28
|
+
}
|
|
29
|
+
// Dev and prod have same structure (no developer)
|
|
30
|
+
return `${env}/${websiteId}/${themeName}/${version}`;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Build complete upload metadata
|
|
34
|
+
*/
|
|
35
|
+
export function buildUploadMetadata(packageJson, credentials, options) {
|
|
36
|
+
const env = getEnvironment();
|
|
37
|
+
const r2Path = buildR2Path(packageJson, credentials);
|
|
38
|
+
const themeName = packageJson.oaysus?.theme?.name || packageJson.name;
|
|
39
|
+
const displayName = packageJson.oaysus?.theme?.displayName || themeName;
|
|
40
|
+
return {
|
|
41
|
+
environment: env,
|
|
42
|
+
developer: env === 'local' ? DEVELOPER : undefined,
|
|
43
|
+
websiteId: credentials.websiteId,
|
|
44
|
+
themeName,
|
|
45
|
+
displayName,
|
|
46
|
+
version: packageJson.version,
|
|
47
|
+
r2Path,
|
|
48
|
+
importMap: options?.importMap,
|
|
49
|
+
stylesheets: options?.stylesheets,
|
|
50
|
+
dependencies: options?.dependencies
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get base path for theme (without version)
|
|
55
|
+
*/
|
|
56
|
+
export function getThemeBasePath(packageJson, credentials) {
|
|
57
|
+
const env = getEnvironment();
|
|
58
|
+
const websiteId = credentials.websiteId;
|
|
59
|
+
const themeName = packageJson.oaysus?.theme?.name || packageJson.name;
|
|
60
|
+
if (env === 'local') {
|
|
61
|
+
const developer = DEVELOPER || 'unknown';
|
|
62
|
+
return `local/${developer}/${websiteId}/${themeName}`;
|
|
63
|
+
}
|
|
64
|
+
return `${env}/${websiteId}/${themeName}`;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=path-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-builder.js","sourceRoot":"","sources":["../../../src/lib/shared/path-builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAqBxD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CACzB,WAAwB,EACxB,WAAwB;IAExB,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;IAC7B,MAAM,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC;IACxC,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,IAAI,WAAW,CAAC,IAAI,CAAC;IACtE,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC;IAEpC,iDAAiD;IACjD,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;QACpB,MAAM,SAAS,GAAG,SAAS,IAAI,SAAS,CAAC;QACzC,OAAO,SAAS,SAAS,IAAI,SAAS,IAAI,SAAS,IAAI,OAAO,EAAE,CAAC;IACnE,CAAC;IAED,kDAAkD;IAClD,OAAO,GAAG,GAAG,IAAI,SAAS,IAAI,SAAS,IAAI,OAAO,EAAE,CAAC;AACvD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,WAAwB,EACxB,WAAwB,EACxB,O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ZIP packages to Oaysus API/R2
|
|
4
|
+
*/
|
|
5
|
+
import type { PackageJson } from '../../types/validation.js';
|
|
6
|
+
/**
|
|
7
|
+
* Upload result from server
|
|
8
|
+
*/
|
|
9
|
+
export interface UploadResult {
|
|
10
|
+
themePackId?: string;
|
|
11
|
+
componentId?: string;
|
|
12
|
+
componentIds?: string[];
|
|
13
|
+
packageId?: string;
|
|
14
|
+
componentCount?: number;
|
|
15
|
+
componentBundles?: Record<string, string>;
|
|
16
|
+
themeName?: string;
|
|
17
|
+
cdnUrl: string;
|
|
18
|
+
clientBundleUrl?: string;
|
|
19
|
+
files?: Record<string, string>;
|
|
20
|
+
size: number;
|
|
21
|
+
hash: string;
|
|
22
|
+
filename?: string;
|
|
23
|
+
uploadedAt: string;
|
|
24
|
+
userId: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* File to upload with content type
|
|
28
|
+
*/
|
|
29
|
+
export interface FileToUpload {
|
|
30
|
+
relativePath: string;
|
|
31
|
+
absolutePath: string;
|
|
32
|
+
contentType: string;
|
|
33
|
+
size: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Progress callback function type
|
|
37
|
+
*/
|
|
38
|
+
export type ProgressCallback = (bytesUploaded: number, totalBytes: number, percentage: number) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Upload error with specific error codes
|
|
41
|
+
*/
|
|
42
|
+
export declare class UploadError extends Error {
|
|
43
|
+
code: string;
|
|
44
|
+
statusCode?: number | undefined;
|
|
45
|
+
constructor(message: string, code: string, statusCode?: number | undefined);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Upload options including import map, stylesheets, and dependencies
|
|
49
|
+
*/
|
|
50
|
+
export interface UploadOptions {
|
|
51
|
+
importMap?: Record<string, any>;
|
|
52
|
+
stylesheets?: Record<string, string>;
|
|
53
|
+
dependencies?: Array<{
|
|
54
|
+
name: string;
|
|
55
|
+
version: string;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Upload a component package ZIP file to R2
|
|
60
|
+
*
|
|
61
|
+
* @param zipPath - Absolute path to ZIP file
|
|
62
|
+
* @param hash - SHA256 hash of the ZIP file
|
|
63
|
+
* @param packageJson - Package.json data for metadata
|
|
64
|
+
* @param onProgress - Optional progress callback
|
|
65
|
+
* @param options - Optional import map and dependencies
|
|
66
|
+
* @returns Upload result with packageId and CDN URL
|
|
67
|
+
*/
|
|
68
|
+
export declare function uploadPackageToR2(zipPath: string, hash: string, packageJson: PackageJson, onProgress?: ProgressCallback, options?: UploadOptions): Promise<UploadResult>;
|
|
69
|
+
/**
|
|
70
|
+
* Upload individual build files to R2 (Task 2 compliant)
|
|
71
|
+
*
|
|
72
|
+
* @param buildDir - Path to .oaysus-build directory
|
|
73
|
+
* @param packageJson - Package.json data for metadata
|
|
74
|
+
* @param onProgress - Optional progress callback
|
|
75
|
+
* @param options - Optional import map and dependencies
|
|
76
|
+
* @returns Upload result with individual file URLs
|
|
77
|
+
*/
|
|
78
|
+
export declare function uploadBuildFilesToR2(buildDir: string, packageJson: PackageJson, onProgress?: ProgressCallback, options?: UploadOptions): Promise<UploadResult>;
|
|
79
|
+
//# sourceMappingURL=uploader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploader.d.ts","sourceRoot":"","sources":["../../../src/lib/shared/uploader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,KAAK,EAAoB,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,YAAY;IAE3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,M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WAAW,EACxB,UAAU,CAAC,EAAE,gBAAgB,EAC7B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,YAAY,CAAC,CAkKvB;AAoDD;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,WAAW,EACxB,UAAU,CAAC,EAAE,gBAAgB,EAC7B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,YAAY,CAAC,CA6KvB"}
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Package Uploader
|
|
3
|
+
* Handles uploading validated ZIP packages to Oaysus API/R2
|
|
4
|
+
*/
|
|
5
|
+
import axios from 'axios';
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import crypto from 'crypto';
|
|
9
|
+
import FormData from 'form-data';
|
|
10
|
+
import { loadCredentials } from './auth.js';
|
|
11
|
+
import { buildUploadMetadata } from './path-builder.js';
|
|
12
|
+
import { SSO_BASE_URL, debug } from './config.js';
|
|
13
|
+
/**
|
|
14
|
+
* Upload error with specific error codes
|
|
15
|
+
*/
|
|
16
|
+
export class UploadError extends Error {
|
|
17
|
+
code;
|
|
18
|
+
statusCode;
|
|
19
|
+
constructor(message, code, statusCode) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.code = code;
|
|
22
|
+
this.statusCode = statusCode;
|
|
23
|
+
this.name = 'UploadError';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Upload a component package ZIP file to R2
|
|
28
|
+
*
|
|
29
|
+
* @param zipPath - Absolute path to ZIP file
|
|
30
|
+
* @param hash - SHA256 hash of the ZIP file
|
|
31
|
+
* @param packageJson - Package.json data for metadata
|
|
32
|
+
* @param onProgress - Optional progress callback
|
|
33
|
+
* @param options - Optional import map and dependencies
|
|
34
|
+
* @returns Upload result with packageId and CDN URL
|
|
35
|
+
*/
|
|
36
|
+
export async function uploadPackageToR2(zipPath, hash, packageJson, onProgress, options) {
|
|
37
|
+
// 1. Load credentials
|
|
38
|
+
const credentials = await loadCredentials();
|
|
39
|
+
if (!credentials || !credentials.jwt) {
|
|
40
|
+
throw new UploadError('Not authenticated. Please run "oaysus login" first', 'NOT_AUTHENTICATED');
|
|
41
|
+
}
|
|
42
|
+
// 2. Check if file exists
|
|
43
|
+
if (!fs.existsSync(zipPath)) {
|
|
44
|
+
throw new UploadError(`ZIP file not found: ${zipPath}`, 'FILE_NOT_FOUND');
|
|
45
|
+
}
|
|
46
|
+
// 3. Get file stats
|
|
47
|
+
const stats = fs.statSync(zipPath);
|
|
48
|
+
const fileSize = stats.size;
|
|
49
|
+
// 4. Check file size (max 50MB)
|
|
50
|
+
const MAX_SIZE = 50 * 1024 * 1024; // 50MB
|
|
51
|
+
if (fileSize > MAX_SIZE) {
|
|
52
|
+
throw new UploadError(`File size (${fileSize} bytes) exceeds maximum allowed size (${MAX_SIZE} bytes)`, 'FILE_TOO_LARGE');
|
|
53
|
+
}
|
|
54
|
+
// 5. Build upload metadata with environment-aware R2 path
|
|
55
|
+
const uploadMetadata = buildUploadMetadata(packageJson, credentials, {
|
|
56
|
+
importMap: options?.importMap,
|
|
57
|
+
dependencies: options?.dependencies
|
|
58
|
+
});
|
|
59
|
+
// 6. Create form data
|
|
60
|
+
const form = new FormData();
|
|
61
|
+
const fileStream = fs.createReadStream(zipPath);
|
|
62
|
+
form.append('file', fileStream);
|
|
63
|
+
form.append('packageJson', JSON.stringify(packageJson));
|
|
64
|
+
form.append('r2Path', uploadMetadata.r2Path);
|
|
65
|
+
// Detect framework from dependencies
|
|
66
|
+
const allDeps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
67
|
+
let framework = 'react';
|
|
68
|
+
if (allDeps['vue'])
|
|
69
|
+
framework = 'vue';
|
|
70
|
+
else if (allDeps['svelte'])
|
|
71
|
+
framework = 'svelte';
|
|
72
|
+
else if (allDeps['solid-js'])
|
|
73
|
+
framework = 'solid';
|
|
74
|
+
form.append('metadata', JSON.stringify({
|
|
75
|
+
environment: uploadMetadata.environment,
|
|
76
|
+
developer: uploadMetadata.developer,
|
|
77
|
+
themeName: uploadMetadata.themeName,
|
|
78
|
+
componentName: uploadMetadata.themeName, // Component name for DB storage
|
|
79
|
+
displayName: uploadMetadata.displayName,
|
|
80
|
+
version: uploadMetadata.version,
|
|
81
|
+
framework,
|
|
82
|
+
category: packageJson.oaysus?.theme?.category || 'custom',
|
|
83
|
+
description: packageJson.description || '',
|
|
84
|
+
importMap: uploadMetadata.importMap,
|
|
85
|
+
dependencies: uploadMetadata.dependencies,
|
|
86
|
+
tags: packageJson.oaysus?.theme?.tags || []
|
|
87
|
+
}));
|
|
88
|
+
// 7. Prepare request config
|
|
89
|
+
const uploadUrl = `${SSO_BASE_URL}/sso/cli/component/upload?hash=${hash}`;
|
|
90
|
+
const config = {
|
|
91
|
+
method: 'POST',
|
|
92
|
+
url: uploadUrl,
|
|
93
|
+
headers: {
|
|
94
|
+
...form.getHeaders(),
|
|
95
|
+
'Authorization': `Bearer ${credentials.jwt}`
|
|
96
|
+
},
|
|
97
|
+
data: form,
|
|
98
|
+
maxContentLength: Infinity,
|
|
99
|
+
maxBodyLength: Infinity,
|
|
100
|
+
onUploadProgress: (progressEvent) => {
|
|
101
|
+
if (onProgress && progressEvent.total) {
|
|
102
|
+
const bytesUploaded = progressEvent.loaded;
|
|
103
|
+
const totalBytes = progressEvent.total;
|
|
104
|
+
const percentage = Math.round((bytesUploaded / totalBytes) * 100);
|
|
105
|
+
onProgress(bytesUploaded, totalBytes, percentage);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
// 8. Upload file
|
|
110
|
+
try {
|
|
111
|
+
const response = await axios(config);
|
|
112
|
+
return response.data;
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
// Handle specific error cases
|
|
116
|
+
if (axios.isAxiosError(error)) {
|
|
117
|
+
const status = error.response?.status;
|
|
118
|
+
const errorData = error.response?.data;
|
|
119
|
+
if (status === 401) {
|
|
120
|
+
throw new UploadError('Authentication failed. Please run "oaysus login" again', 'UNAUTHORIZED', 401);
|
|
121
|
+
}
|
|
122
|
+
else if (status === 403) {
|
|
123
|
+
throw new UploadError('Access forbidden. Your authentication may have expired. Try: oaysus logout && oaysus login', 'FORBIDDEN', 403);
|
|
124
|
+
}
|
|
125
|
+
else if (status === 413) {
|
|
126
|
+
throw new UploadError(errorData?.error || 'File too large', 'FILE_TOO_LARGE', 413);
|
|
127
|
+
}
|
|
128
|
+
else if (status === 415) {
|
|
129
|
+
throw new UploadError(`Unsupported media type. The server may not be properly configured for file uploads. Error: ${errorData?.error || 'No details'}`, 'UNSUPPORTED_MEDIA_TYPE', 415);
|
|
130
|
+
}
|
|
131
|
+
else if (status === 404) {
|
|
132
|
+
throw new UploadError('Upload endpoint not found. Make sure the backend API is running and deployed.', 'NOT_FOUND', 404);
|
|
133
|
+
}
|
|
134
|
+
else if (status === 400) {
|
|
135
|
+
throw new UploadError(errorData?.error || 'Bad request', 'BAD_REQUEST', 400);
|
|
136
|
+
}
|
|
137
|
+
else if (status === 500) {
|
|
138
|
+
// Check for detailed error message first (from safe_async_handler decorator)
|
|
139
|
+
const errorMessage = errorData?.details || errorData?.error || 'Server error occurred';
|
|
140
|
+
throw new UploadError(errorMessage, 'SERVER_ERROR', 500);
|
|
141
|
+
}
|
|
142
|
+
else if (error.code === 'ECONNABORTED') {
|
|
143
|
+
throw new UploadError('Upload timed out. Please check your connection and try again', 'TIMEOUT');
|
|
144
|
+
}
|
|
145
|
+
else if (error.code === 'ECONNREFUSED') {
|
|
146
|
+
throw new UploadError('Could not connect to server. Please check your internet connection', 'CONNECTION_REFUSED');
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// Generic error
|
|
150
|
+
throw new UploadError(error.message || 'Upload failed', 'UNKNOWN_ERROR');
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Get content type for a file based on extension
|
|
155
|
+
*/
|
|
156
|
+
function getContentType(filePath) {
|
|
157
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
158
|
+
const contentTypes = {
|
|
159
|
+
'.js': 'application/javascript',
|
|
160
|
+
'.mjs': 'application/javascript',
|
|
161
|
+
'.json': 'application/json',
|
|
162
|
+
'.css': 'text/css',
|
|
163
|
+
'.map': 'application/json',
|
|
164
|
+
'.html': 'text/html',
|
|
165
|
+
'.svg': 'image/svg+xml',
|
|
166
|
+
'.png': 'image/png',
|
|
167
|
+
'.jpg': 'image/jpeg',
|
|
168
|
+
'.jpeg': 'image/jpeg',
|
|
169
|
+
'.woff': 'font/woff',
|
|
170
|
+
'.woff2': 'font/woff2',
|
|
171
|
+
'.ttf': 'font/ttf',
|
|
172
|
+
};
|
|
173
|
+
return contentTypes[ext] || 'application/octet-stream';
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Recursively collect all files from a directory
|
|
177
|
+
*/
|
|
178
|
+
function collectFilesFromDir(dir, baseDir = dir) {
|
|
179
|
+
const files = [];
|
|
180
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
181
|
+
for (const entry of entries) {
|
|
182
|
+
const absolutePath = path.join(dir, entry.name);
|
|
183
|
+
if (entry.isDirectory()) {
|
|
184
|
+
files.push(...collectFilesFromDir(absolutePath, baseDir));
|
|
185
|
+
}
|
|
186
|
+
else if (entry.isFile()) {
|
|
187
|
+
const relativePath = path.relative(baseDir, absolutePath);
|
|
188
|
+
const stats = fs.statSync(absolutePath);
|
|
189
|
+
files.push({
|
|
190
|
+
relativePath,
|
|
191
|
+
absolutePath,
|
|
192
|
+
contentType: getContentType(absolutePath),
|
|
193
|
+
size: stats.size
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return files;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Upload individual build files to R2 (Task 2 compliant)
|
|
201
|
+
*
|
|
202
|
+
* @param buildDir - Path to .oaysus-build directory
|
|
203
|
+
* @param packageJson - Package.json data for metadata
|
|
204
|
+
* @param onProgress - Optional progress callback
|
|
205
|
+
* @param options - Optional import map and dependencies
|
|
206
|
+
* @returns Upload result with individual file URLs
|
|
207
|
+
*/
|
|
208
|
+
export async function uploadBuildFilesToR2(buildDir, packageJson, onProgress, options) {
|
|
209
|
+
// 1. Load credentials
|
|
210
|
+
const credentials = await loadCredentials();
|
|
211
|
+
if (!credentials || !credentials.jwt) {
|
|
212
|
+
throw new UploadError('Not authenticated. Please run "oaysus login" first', 'NOT_AUTHENTICATED');
|
|
213
|
+
}
|
|
214
|
+
// 2. Check if build directory exists
|
|
215
|
+
if (!fs.existsSync(buildDir)) {
|
|
216
|
+
throw new UploadError(`Build directory not found: ${buildDir}`, 'DIRECTORY_NOT_FOUND');
|
|
217
|
+
}
|
|
218
|
+
// 3. Collect all files from build directory
|
|
219
|
+
const files = collectFilesFromDir(buildDir);
|
|
220
|
+
if (files.length === 0) {
|
|
221
|
+
throw new UploadError('No files found in build directory', 'NO_FILES');
|
|
222
|
+
}
|
|
223
|
+
// 4. Calculate total size and hash
|
|
224
|
+
const totalSize = files.reduce((sum, f) => sum + f.size, 0);
|
|
225
|
+
const hash = crypto.createHash('sha256');
|
|
226
|
+
for (const file of files) {
|
|
227
|
+
const content = fs.readFileSync(file.absolutePath);
|
|
228
|
+
hash.update(content);
|
|
229
|
+
}
|
|
230
|
+
const hashString = hash.digest('hex');
|
|
231
|
+
// 5. Build upload metadata
|
|
232
|
+
const uploadMetadata = buildUploadMetadata(packageJson, credentials, {
|
|
233
|
+
importMap: options?.importMap,
|
|
234
|
+
stylesheets: options?.stylesheets,
|
|
235
|
+
dependencies: options?.dependencies
|
|
236
|
+
});
|
|
237
|
+
// 6. Detect framework
|
|
238
|
+
const allDeps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
239
|
+
let framework = 'react';
|
|
240
|
+
if (allDeps['vue'])
|
|
241
|
+
framework = 'vue';
|
|
242
|
+
else if (allDeps['svelte'])
|
|
243
|
+
framework = 'svelte';
|
|
244
|
+
else if (allDeps['solid-js'])
|
|
245
|
+
framework = 'solid';
|
|
246
|
+
// 7. Build file contents object
|
|
247
|
+
const fileContents = {};
|
|
248
|
+
for (const file of files) {
|
|
249
|
+
const content = fs.readFileSync(file.absolutePath);
|
|
250
|
+
fileContents[file.relativePath] = {
|
|
251
|
+
content: content.toString('base64'),
|
|
252
|
+
contentType: file.contentType
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
// 8. Prepare request body (JSON instead of FormData)
|
|
256
|
+
// Use oaysus.theme.description first, then fall back to root description
|
|
257
|
+
const themeDescription = packageJson.oaysus?.theme?.description || packageJson.description || '';
|
|
258
|
+
const requestBody = {
|
|
259
|
+
files: fileContents,
|
|
260
|
+
packageJson,
|
|
261
|
+
r2Path: uploadMetadata.r2Path,
|
|
262
|
+
metadata: {
|
|
263
|
+
environment: uploadMetadata.environment,
|
|
264
|
+
developer: uploadMetadata.developer,
|
|
265
|
+
themeName: uploadMetadata.themeName,
|
|
266
|
+
componentName: uploadMetadata.themeName,
|
|
267
|
+
themeDisplayName: uploadMetadata.displayName,
|
|
268
|
+
displayName: uploadMetadata.displayName,
|
|
269
|
+
version: uploadMetadata.version,
|
|
270
|
+
framework,
|
|
271
|
+
category: packageJson.oaysus?.theme?.category || 'custom',
|
|
272
|
+
themeDescription: themeDescription,
|
|
273
|
+
description: themeDescription,
|
|
274
|
+
importMap: uploadMetadata.importMap,
|
|
275
|
+
stylesheets: uploadMetadata.stylesheets,
|
|
276
|
+
dependencies: uploadMetadata.dependencies,
|
|
277
|
+
tags: packageJson.oaysus?.theme?.tags || []
|
|
278
|
+
},
|
|
279
|
+
hash: hashString,
|
|
280
|
+
totalSize
|
|
281
|
+
};
|
|
282
|
+
// 9. Upload URL
|
|
283
|
+
const uploadUrl = `${SSO_BASE_URL}/sso/cli/component/upload-files`;
|
|
284
|
+
debug('Upload URL:', uploadUrl);
|
|
285
|
+
debug('SSO_BASE_URL:', SSO_BASE_URL);
|
|
286
|
+
// 10. Upload
|
|
287
|
+
try {
|
|
288
|
+
const response = await axios({
|
|
289
|
+
method: 'POST',
|
|
290
|
+
url: uploadUrl,
|
|
291
|
+
headers: {
|
|
292
|
+
'Content-Type': 'application/json',
|
|
293
|
+
'Authorization': `Bearer ${credentials.jwt}`
|
|
294
|
+
},
|
|
295
|
+
data: requestBody,
|
|
296
|
+
maxContentLength: Infinity,
|
|
297
|
+
maxBodyLength: Infinity,
|
|
298
|
+
onUploadProgress: (progressEvent) => {
|
|
299
|
+
if (onProgress && progressEvent.total) {
|
|
300
|
+
const bytesUploaded = progressEvent.loaded;
|
|
301
|
+
const totalBytes = progressEvent.total;
|
|
302
|
+
const percentage = Math.round((bytesUploaded / totalBytes) * 100);
|
|
303
|
+
onProgress(bytesUploaded, totalBytes, percentage);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
return response.data;
|
|
308
|
+
}
|
|
309
|
+
catch (error) {
|
|
310
|
+
// Handle specific error cases
|
|
311
|
+
if (axios.isAxiosError(error)) {
|
|
312
|
+
const status = error.response?.status;
|
|
313
|
+
const errorData = error.response?.data;
|
|
314
|
+
if (status === 401) {
|
|
315
|
+
throw new UploadError('Authentication failed. Please run "oaysus login" again', 'UNAUTHORIZED', 401);
|
|
316
|
+
}
|
|
317
|
+
else if (status === 403) {
|
|
318
|
+
debug('403 Error - Response data:', errorData);
|
|
319
|
+
debug('403 Error - Request URL:', uploadUrl);
|
|
320
|
+
throw new UploadError(`Upload failed: ${errorData?.error || errorData?.message || 'Access forbidden'}. Your authentication may have expired. Try: oaysus logout && oaysus login`, 'FORBIDDEN', 403);
|
|
321
|
+
}
|
|
322
|
+
else if (status === 413) {
|
|
323
|
+
throw new UploadError(errorData?.error || 'Payload too large', 'PAYLOAD_TOO_LARGE', 413);
|
|
324
|
+
}
|
|
325
|
+
else if (status === 404) {
|
|
326
|
+
throw new UploadError('Upload endpoint not found. The new upload-files endpoint may not be deployed yet.', 'NOT_FOUND', 404);
|
|
327
|
+
}
|
|
328
|
+
else if (status === 400) {
|
|
329
|
+
throw new UploadError(errorData?.error || 'Bad request', 'BAD_REQUEST', 400);
|
|
330
|
+
}
|
|
331
|
+
else if (status === 500) {
|
|
332
|
+
// Check for detailed error message first (from safe_async_handler decorator)
|
|
333
|
+
const errorMessage = errorData?.details || errorData?.error || 'Server error occurred';
|
|
334
|
+
throw new UploadError(errorMessage, 'SERVER_ERROR', 500);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
throw new UploadError(error.message || 'Upload failed', 'UNKNOWN_ERROR');
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
//# sourceMappingURL=uploader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploader.js","sourceRoot":"","sources":["../../../src/lib/shared/uploader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAA6B,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AA8ClD;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IAG3B;IACA;IAHT,YACE,OAAe,EACR,IAAY,EACZ,UAAmB;QAE1B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,SAAI,GAAJ,IAAI,CAAQ;QACZ,eAAU,GAAV,UAAU,CAAS;QAG1B,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AAWD;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,CAAC;YACJ,CAAC;iBAAM,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;gBAC1B,MAAM,IAAI,WAAW,CACnB,mFAAmF,EACnF,WAAW,EACX,GAAG,CACJ,CAAC;YACJ,CAAC;iBAAM,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;gBAC1B,MAAM,IAAI,WAAW,CACnB,SAAS,EAAE,KAAK,IAAI,aAAa,EACjC,aAAa,EACb,GAAG,CACJ,CAAC;YACJ,CAAC;iBAAM,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;gBAC1B,6EAA6E;gBAC7E,MAAM,YAAY,GAAG,SAAS,EAAE,OAAO,IAAI,SAAS,EAAE,KAAK,IAAI,uBAAuB,CAAC;gBACvF,MAAM,IAAI,WAAW,CACnB,YAAY,EACZ,cAAc,EACd,GAAG,CACJ,CAAC;YACJ,CAAC;QACH,CAAC;QAED,MAAM,IAAI,WAAW,CACnB,KAAK,CAAC,OAAO,IAAI,eAAe,EAChC,eAAe,CAChB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZIP Creator
|
|
3
|
+
* Creates ZIP archives with proper exclusions for component packages
|
|
4
|
+
*/
|
|
5
|
+
import type { ZipResult } from '../../types/validation.js';
|
|
6
|
+
/**
|
|
7
|
+
* Create a ZIP archive of the project
|
|
8
|
+
*
|
|
9
|
+
* @param projectPath - Path to the project directory
|
|
10
|
+
* @param additionalExclusions - Additional patterns to exclude (from .oaysusrc.json)
|
|
11
|
+
* @returns ZipResult with buffer, size, hash, and file counts
|
|
12
|
+
*/
|
|
13
|
+
export declare function createZip(projectPath: string, additionalExclusions?: string[]): Promise<ZipResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Format bytes to human-readable string
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatBytes(bytes: number): string;
|
|
18
|
+
//# sourceMappingURL=zip-creator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip-creator.d.ts","sourceRoot":"","sources":["../../../src/lib/shared/zip-creator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAiC3D;;;;;;GAMG;AACH,wBAAsB,SAAS,CAC7B,WAAW,EAAE,MAAM,EACnB,oBAAoB,CAAC,EAAE,MAAM,EAAE,GAC9B,OAAO,CAAC,SAAS,CAAC,CAkFpB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMjD"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZIP Creator
|
|
3
|
+
* Creates ZIP archives with proper exclusions for component packages
|
|
4
|
+
*/
|
|
5
|
+
import archiver from 'archiver';
|
|
6
|
+
import { createReadStream } from 'fs';
|
|
7
|
+
import { glob } from 'glob';
|
|
8
|
+
import crypto from 'crypto';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
// Default files/patterns to exclude from ZIP
|
|
11
|
+
const DEFAULT_EXCLUSIONS = [
|
|
12
|
+
'node_modules/**',
|
|
13
|
+
'.git/**',
|
|
14
|
+
'.gitignore',
|
|
15
|
+
'.DS_Store',
|
|
16
|
+
'**/*.log',
|
|
17
|
+
'dist/**',
|
|
18
|
+
'build/**',
|
|
19
|
+
'.env*',
|
|
20
|
+
'**/*.test.ts',
|
|
21
|
+
'**/*.test.tsx',
|
|
22
|
+
'**/*.test.js',
|
|
23
|
+
'**/*.test.jsx',
|
|
24
|
+
'**/*.spec.ts',
|
|
25
|
+
'**/*.spec.tsx',
|
|
26
|
+
'**/*.spec.js',
|
|
27
|
+
'**/*.spec.jsx',
|
|
28
|
+
'coverage/**',
|
|
29
|
+
'.nyc_output/**',
|
|
30
|
+
'**/__pycache__/**',
|
|
31
|
+
'**/.pytest_cache/**',
|
|
32
|
+
'**/.vscode/**',
|
|
33
|
+
'**/.idea/**',
|
|
34
|
+
'tsconfig.json',
|
|
35
|
+
'jest.config.js',
|
|
36
|
+
'jest.config.ts',
|
|
37
|
+
'.eslintrc*',
|
|
38
|
+
'.prettierrc*',
|
|
39
|
+
];
|
|
40
|
+
/**
|
|
41
|
+
* Create a ZIP archive of the project
|
|
42
|
+
*
|
|
43
|
+
* @param projectPath - Path to the project directory
|
|
44
|
+
* @param additionalExclusions - Additional patterns to exclude (from .oaysusrc.json)
|
|
45
|
+
* @returns ZipResult with buffer, size, hash, and file counts
|
|
46
|
+
*/
|
|
47
|
+
export async function createZip(projectPath, additionalExclusions) {
|
|
48
|
+
// Combine default and additional exclusions
|
|
49
|
+
const exclude = [...DEFAULT_EXCLUSIONS];
|
|
50
|
+
if (additionalExclusions) {
|
|
51
|
+
exclude.push(...additionalExclusions.map(pattern => {
|
|
52
|
+
// Ensure patterns work with glob
|
|
53
|
+
if (pattern.endsWith('/')) {
|
|
54
|
+
return `${pattern}**`;
|
|
55
|
+
}
|
|
56
|
+
return pattern;
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
// Get all files to include (respecting exclusions)
|
|
60
|
+
const files = await glob('**/*', {
|
|
61
|
+
cwd: projectPath,
|
|
62
|
+
ignore: exclude,
|
|
63
|
+
nodir: true,
|
|
64
|
+
dot: true, // Include dot files like .oaysusrc.json
|
|
65
|
+
});
|
|
66
|
+
// Get count of excluded files
|
|
67
|
+
const allFiles = await glob('**/*', {
|
|
68
|
+
cwd: projectPath,
|
|
69
|
+
nodir: true,
|
|
70
|
+
dot: true,
|
|
71
|
+
});
|
|
72
|
+
const excludedCount = allFiles.length - files.length;
|
|
73
|
+
// Create ZIP in memory
|
|
74
|
+
const archive = archiver('zip', {
|
|
75
|
+
zlib: { level: 9 }, // Maximum compression
|
|
76
|
+
});
|
|
77
|
+
const chunks = [];
|
|
78
|
+
// Collect chunks and wait for finalization
|
|
79
|
+
const zipPromise = new Promise((resolve, reject) => {
|
|
80
|
+
archive.on('data', (chunk) => {
|
|
81
|
+
chunks.push(chunk);
|
|
82
|
+
});
|
|
83
|
+
archive.on('error', (err) => {
|
|
84
|
+
reject(err);
|
|
85
|
+
});
|
|
86
|
+
archive.on('warning', (err) => {
|
|
87
|
+
if (err.code !== 'ENOENT') {
|
|
88
|
+
console.warn('Warning:', err.message);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
archive.on('end', () => {
|
|
92
|
+
resolve(Buffer.concat(chunks));
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
// Add files to ZIP
|
|
96
|
+
for (const file of files) {
|
|
97
|
+
const filePath = path.join(projectPath, file);
|
|
98
|
+
const stream = createReadStream(filePath);
|
|
99
|
+
archive.append(stream, { name: file });
|
|
100
|
+
}
|
|
101
|
+
// Finalize and wait for completion
|
|
102
|
+
await archive.finalize();
|
|
103
|
+
const zipBuffer = await zipPromise;
|
|
104
|
+
// Calculate SHA256 hash
|
|
105
|
+
const hash = crypto.createHash('sha256');
|
|
106
|
+
hash.update(zipBuffer);
|
|
107
|
+
const sha256 = hash.digest('hex');
|
|
108
|
+
return {
|
|
109
|
+
buffer: zipBuffer,
|
|
110
|
+
size: zipBuffer.length,
|
|
111
|
+
sha256,
|
|
112
|
+
fileCount: files.length,
|
|
113
|
+
excludedCount,
|
|
114
|
+
files,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Format bytes to human-readable string
|
|
119
|
+
*/
|
|
120
|
+
export function formatBytes(bytes) {
|
|
121
|
+
if (bytes === 0)
|
|
122
|
+
return '0 B';
|
|
123
|
+
if (bytes < 1024)
|
|
124
|
+
return `${bytes} B`;
|
|
125
|
+
if (bytes < 1024 * 1024)
|
|
126
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
127
|
+
if (bytes < 1024 * 1024 * 1024)
|
|
128
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
129
|
+
return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=zip-creator.js.map
|