@ptkl/toolkit 0.7.0 → 0.7.2
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/dist/commands/apps.js +11 -27
- package/package.json +1 -1
package/dist/commands/apps.js
CHANGED
|
@@ -76,12 +76,12 @@ class AppsCommand {
|
|
|
76
76
|
async upload(options) {
|
|
77
77
|
const { apptype, directory, build } = options;
|
|
78
78
|
const profile = util.getCurrentProfile();
|
|
79
|
-
const
|
|
79
|
+
const api = new Api({ token: profile.token, host: profile.host }).app(apptype);
|
|
80
80
|
try {
|
|
81
|
-
|
|
81
|
+
let buffer = Buffer.alloc(0);
|
|
82
82
|
const bufferStream = new Writable({
|
|
83
83
|
write(chunk, encoding, callback) {
|
|
84
|
-
|
|
84
|
+
buffer = Buffer.concat([buffer, chunk]);
|
|
85
85
|
callback();
|
|
86
86
|
},
|
|
87
87
|
});
|
|
@@ -93,35 +93,19 @@ class AppsCommand {
|
|
|
93
93
|
.on('error', reject);
|
|
94
94
|
});
|
|
95
95
|
console.log('Archive created successfully');
|
|
96
|
-
//
|
|
97
|
-
const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
98
|
-
const arrayBuffer = new ArrayBuffer(totalLength);
|
|
99
|
-
const uint8View = new Uint8Array(arrayBuffer);
|
|
100
|
-
let offset = 0;
|
|
101
|
-
for (const chunk of chunks) {
|
|
102
|
-
uint8View.set(new Uint8Array(chunk), offset);
|
|
103
|
-
offset += chunk.length;
|
|
104
|
-
}
|
|
105
|
-
console.log('ArrayBuffer size:', arrayBuffer.byteLength);
|
|
106
|
-
// Create FormData with ArrayBuffer
|
|
96
|
+
// Create FormData with buffer
|
|
107
97
|
const formData = new FormData();
|
|
108
|
-
const blob = new Blob([
|
|
109
|
-
console.log('Blob size:', blob.size);
|
|
98
|
+
const blob = new Blob([buffer], { type: 'application/gzip' });
|
|
110
99
|
formData.append('app', blob, 'app.tar.gz');
|
|
111
100
|
if (build) {
|
|
112
101
|
formData.append('build', 'true');
|
|
113
102
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
console.log('Upload failed with error:', error.message);
|
|
122
|
-
console.log('Error details:', error);
|
|
123
|
-
throw error;
|
|
124
|
-
}
|
|
103
|
+
return await api.client.post(`/v3/system/gateway/app-service/${apptype}/upload`, formData, {
|
|
104
|
+
timeout: 60000,
|
|
105
|
+
headers: {
|
|
106
|
+
'Content-Type': 'multipart/form-data'
|
|
107
|
+
}
|
|
108
|
+
});
|
|
125
109
|
}
|
|
126
110
|
catch (error) {
|
|
127
111
|
throw error;
|