@capgo/cli 7.18.16 → 7.18.18

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.
@@ -1,158 +0,0 @@
1
- import { spawn } from 'node:child_process';
2
- import { mkdir, readFile, rm, stat } from 'node:fs/promises';
3
- import { tmpdir } from 'node:os';
4
- import { basename, join, resolve } from 'node:path';
5
- import process from 'node:process';
6
- import { log } from '@clack/prompts';
7
- import { createSupabaseClient, findSavedKey, getConfig, verifyUser } from '../utils';
8
- async function zipDirectory(projectDir, outputPath) {
9
- return new Promise((resolvePromise, reject) => {
10
- const args = ['-rq', outputPath, '.'];
11
- const child = spawn('zip', args, { cwd: projectDir, stdio: 'inherit' });
12
- child.on('error', (error) => {
13
- if (error.code === 'ENOENT') {
14
- reject(new Error('zip command not found. Please install zip utility.'));
15
- }
16
- else {
17
- reject(error);
18
- }
19
- });
20
- child.on('close', (code) => {
21
- if (code === 0) {
22
- resolvePromise();
23
- }
24
- else {
25
- reject(new Error(`zip process exited with code ${code}`));
26
- }
27
- });
28
- });
29
- }
30
- export async function requestBuildInternal(appId, options, silent = false) {
31
- try {
32
- options.apikey = options.apikey || findSavedKey(silent);
33
- const config = await getConfig();
34
- appId = appId || config?.config.appId;
35
- if (!appId) {
36
- throw new Error('Missing argument, you need to provide a appId, or be in a capacitor project');
37
- }
38
- const projectDir = resolve(options.path || process.cwd());
39
- const supabase = await createSupabaseClient(options.apikey, options.supaHost, options.supaAnon);
40
- await verifyUser(supabase, options.apikey, ['write', 'all']);
41
- if (!silent) {
42
- log.info(`Requesting native build for ${appId}`);
43
- log.info(`Platform: ${options.lane}`);
44
- log.info(`Project: ${projectDir}`);
45
- }
46
- // Prepare request payload for Capgo backend
47
- const requestPayload = {
48
- app_id: appId,
49
- platform: options.lane,
50
- };
51
- // Add build mode if specified
52
- if (options.buildMode) {
53
- requestPayload.build_mode = options.buildMode;
54
- }
55
- // Add credentials if provided
56
- if (options.credentials) {
57
- requestPayload.credentials = options.credentials;
58
- }
59
- // Request build from Capgo backend (POST /build/request)
60
- if (!silent)
61
- log.info('Requesting build from Capgo...');
62
- const host = options.supaHost || 'https://api.capgo.app';
63
- const response = await fetch(`${host}/build/request`, {
64
- method: 'POST',
65
- headers: {
66
- 'Content-Type': 'application/json',
67
- 'authorization': options.apikey,
68
- },
69
- body: JSON.stringify(requestPayload),
70
- });
71
- if (!response.ok) {
72
- const errorText = await response.text();
73
- throw new Error(`Failed to request build: ${response.status} - ${errorText}`);
74
- }
75
- const buildRequest = await response.json();
76
- if (!silent) {
77
- log.success(`Build job created: ${buildRequest.job_id}`);
78
- log.info(`Status: ${buildRequest.status}`);
79
- }
80
- // Create temporary directory for zip
81
- const tempDir = join(tmpdir(), `capgo-build-${Date.now()}`);
82
- await mkdir(tempDir, { recursive: true });
83
- const zipPath = join(tempDir, `${basename(projectDir)}.zip`);
84
- try {
85
- // Zip the project directory
86
- if (!silent)
87
- log.info(`Zipping project from ${projectDir}...`);
88
- await zipDirectory(projectDir, zipPath);
89
- const zipStats = await stat(zipPath);
90
- const sizeMB = (zipStats.size / 1024 / 1024).toFixed(2);
91
- if (!silent)
92
- log.success(`Created zip: ${zipPath} (${sizeMB} MB)`);
93
- // Upload to presigned R2 URL
94
- if (!silent)
95
- log.info('Uploading to builder...');
96
- const fileBuffer = await readFile(zipPath);
97
- const uploadResponse = await fetch(buildRequest.upload_url, {
98
- method: 'PUT',
99
- headers: {
100
- 'Content-Type': 'application/zip',
101
- 'Content-Length': String(zipStats.size),
102
- },
103
- body: fileBuffer,
104
- });
105
- if (!uploadResponse.ok) {
106
- const errorText = await uploadResponse.text();
107
- throw new Error(`Upload failed: ${uploadResponse.status} - ${errorText}`);
108
- }
109
- if (!silent)
110
- log.success('Upload complete!');
111
- // Start the build job via Capgo backend
112
- if (!silent)
113
- log.info('Starting build job...');
114
- const startResponse = await fetch(`${host}/build/start/${buildRequest.build_request_id}`, {
115
- method: 'POST',
116
- headers: {
117
- 'authorization': options.apikey,
118
- },
119
- });
120
- if (!startResponse.ok) {
121
- const errorText = await startResponse.text();
122
- throw new Error(`Failed to start build: ${startResponse.status} - ${errorText}`);
123
- }
124
- const startResult = await startResponse.json();
125
- if (!silent) {
126
- log.success('Build started successfully!');
127
- log.info(`Job ID: ${buildRequest.job_id}`);
128
- log.info('You can monitor the build in the Capgo dashboard.');
129
- }
130
- return {
131
- success: true,
132
- jobId: buildRequest.job_id,
133
- uploadUrl: buildRequest.upload_url,
134
- status: startResult.status || buildRequest.status,
135
- };
136
- }
137
- finally {
138
- // Clean up temp directory
139
- await rm(tempDir, { recursive: true, force: true });
140
- }
141
- }
142
- catch (error) {
143
- const errorMessage = error instanceof Error ? error.message : String(error);
144
- if (!silent)
145
- log.error(errorMessage);
146
- return {
147
- success: false,
148
- error: errorMessage,
149
- };
150
- }
151
- }
152
- export async function requestBuildCommand(appId, options) {
153
- const result = await requestBuildInternal(appId, options, false);
154
- if (!result.success) {
155
- process.exit(1);
156
- }
157
- }
158
- //# sourceMappingURL=request.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/build/request.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnD,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AACpC,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAuDpF,KAAK,UAAU,YAAY,CAAC,UAAkB,EAAE,UAAkB;IAChE,OAAO,IAAI,OAAO,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