@raytrace-cli/sdk 0.2.6 → 0.2.8

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/client.mjs +8 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raytrace-cli/sdk",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "TypeScript/JavaScript SDK for RayTrace cloud sandboxes: create, run commands, stop, start and destroy over the /v1 API",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/client.mjs CHANGED
@@ -51,6 +51,10 @@ function writeOctal(buf, offset, length, value) {
51
51
  * Accepts a map of relative POSIX paths -> string | Uint8Array | Buffer.
52
52
  */
53
53
  export function buildTarGz(files) {
54
+ return buildTarGzWithModes(files);
55
+ }
56
+
57
+ function buildTarGzWithModes(files, modes = new Map()) {
54
58
  const chunks = [];
55
59
  const entries = Object.entries(files || {});
56
60
  if (!entries.length) {
@@ -64,7 +68,7 @@ export function buildTarGz(files) {
64
68
  const data = Buffer.isBuffer(content) ? content : Buffer.from(content);
65
69
  const header = Buffer.alloc(512, 0);
66
70
  header.write(rel, 0, 100, 'utf8');
67
- writeOctal(header, 100, 8, 0o644);
71
+ writeOctal(header, 100, 8, modes.get(rawPath) ?? 0o644);
68
72
  writeOctal(header, 108, 8, 1000);
69
73
  writeOctal(header, 116, 8, 1000);
70
74
  writeOctal(header, 124, 12, data.length);
@@ -184,6 +188,7 @@ export async function archiveFromRepo(repo, { ref = undefined } = {}) {
184
188
 
185
189
  export function archiveFromDirectory(dirPath) {
186
190
  const files = Object.create(null);
191
+ const modes = new Map();
187
192
  function walk(absDir, relPrefix) {
188
193
  for (const entry of readdirSync(absDir, { withFileTypes: true })) {
189
194
  if (DEFAULT_EXCLUDED.has(entry.name)) continue;
@@ -198,11 +203,12 @@ export function archiveFromDirectory(dirPath) {
198
203
  throw new Error(`Project file ${rel} exceeds the 25 MiB size limit`);
199
204
  }
200
205
  files[rel] = readFileSync(abs);
206
+ modes.set(rel, st.mode & 0o777);
201
207
  }
202
208
  }
203
209
  }
204
210
  walk(dirPath, '');
205
- return buildTarGz(files);
211
+ return buildTarGzWithModes(files, modes);
206
212
  }
207
213
 
208
214
  export class RayTraceClient {