@agentuity/cli 0.0.16 → 0.0.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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../../src/cmd/project/download.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../../src/cmd/project/download.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKhD,UAAU,eAAe;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,YAAY,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,YAAY;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CACf;AAsBD,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CA+D9E;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCvE"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { join, resolve } from 'node:path';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
existsSync,
|
|
4
|
+
mkdirSync,
|
|
5
|
+
mkdtempSync,
|
|
6
|
+
renameSync,
|
|
7
|
+
readdirSync,
|
|
8
|
+
cpSync,
|
|
9
|
+
rmSync,
|
|
10
|
+
createReadStream,
|
|
11
|
+
} from 'node:fs';
|
|
12
|
+
import { tmpdir } from 'node:os';
|
|
13
|
+
import { finished } from 'node:stream/promises';
|
|
5
14
|
import { createGunzip } from 'node:zlib';
|
|
6
15
|
import { extract, type Headers } from 'tar-fs';
|
|
7
16
|
import type { Logger } from '../../logger';
|
|
@@ -69,8 +78,10 @@ export async function downloadTemplate(options: DownloadOptions): Promise<void>
|
|
|
69
78
|
const templatePath = `templates/${template.directory}`;
|
|
70
79
|
const url = `https://codeload.github.com/${GITHUB_REPO}/tar.gz/${branch}`;
|
|
71
80
|
const tempDir = mkdtempSync(join(tmpdir(), 'agentuity-'));
|
|
81
|
+
const tarballPath = join(tempDir, 'download.tar.gz');
|
|
72
82
|
|
|
73
83
|
try {
|
|
84
|
+
// Download tarball to temp file
|
|
74
85
|
await downloadWithSpinner(
|
|
75
86
|
{
|
|
76
87
|
url,
|
|
@@ -79,23 +90,32 @@ export async function downloadTemplate(options: DownloadOptions): Promise<void>
|
|
|
79
90
|
: 'Downloading template files...',
|
|
80
91
|
},
|
|
81
92
|
async (stream) => {
|
|
82
|
-
//
|
|
83
|
-
const
|
|
84
|
-
await
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
filter: (name: string) => name.startsWith(prefix),
|
|
89
|
-
map: (header: Headers) => {
|
|
90
|
-
header.name = header.name.substring(prefix.length);
|
|
91
|
-
return header;
|
|
92
|
-
},
|
|
93
|
-
})
|
|
94
|
-
);
|
|
93
|
+
// Write stream to file
|
|
94
|
+
const chunks: Buffer[] = [];
|
|
95
|
+
for await (const chunk of stream) {
|
|
96
|
+
chunks.push(Buffer.from(chunk));
|
|
97
|
+
}
|
|
98
|
+
await Bun.write(tarballPath, Buffer.concat(chunks));
|
|
95
99
|
}
|
|
96
100
|
);
|
|
97
101
|
|
|
98
|
-
|
|
102
|
+
// Extract tarball
|
|
103
|
+
const extractDir = join(tempDir, 'extract');
|
|
104
|
+
mkdirSync(extractDir, { recursive: true });
|
|
105
|
+
|
|
106
|
+
const prefix = `sdk-${branch}/${templatePath}/`;
|
|
107
|
+
const extractor = extract(extractDir, {
|
|
108
|
+
filter: (name: string) => name.startsWith(prefix),
|
|
109
|
+
map: (header: Headers) => {
|
|
110
|
+
header.name = header.name.substring(prefix.length);
|
|
111
|
+
return header;
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
createReadStream(tarballPath).pipe(createGunzip()).pipe(extractor);
|
|
116
|
+
await finished(extractor);
|
|
117
|
+
|
|
118
|
+
await cleanup(extractDir, dest);
|
|
99
119
|
} finally {
|
|
100
120
|
// Clean up temp directory
|
|
101
121
|
rmSync(tempDir, { recursive: true, force: true });
|