ovsx 0.9.5 → 0.10.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/CHANGELOG.md +14 -0
- package/README.md +14 -0
- package/lib/create-namespace.d.ts.map +1 -1
- package/lib/create-namespace.js +1 -3
- package/lib/create-namespace.js.map +1 -1
- package/lib/login.d.ts +8 -1
- package/lib/login.d.ts.map +1 -1
- package/lib/login.js +19 -2
- package/lib/login.js.map +1 -1
- package/lib/logout.d.ts +2 -0
- package/lib/logout.d.ts.map +1 -0
- package/lib/logout.js +16 -0
- package/lib/logout.js.map +1 -0
- package/lib/main.js +18 -2
- package/lib/main.js.map +1 -1
- package/lib/ovsx +2 -2
- package/lib/publish.d.ts +4 -0
- package/lib/publish.d.ts.map +1 -1
- package/lib/publish.js +7 -4
- package/lib/publish.js.map +1 -1
- package/lib/store.d.ts +39 -0
- package/lib/store.d.ts.map +1 -0
- package/lib/store.js +115 -0
- package/lib/store.js.map +1 -0
- package/lib/util.d.ts +5 -0
- package/lib/util.d.ts.map +1 -1
- package/lib/util.js +25 -1
- package/lib/util.js.map +1 -1
- package/lib/verify-pat.d.ts +1 -0
- package/lib/verify-pat.d.ts.map +1 -1
- package/lib/verify-pat.js +11 -7
- package/lib/verify-pat.js.map +1 -1
- package/lib/zip.d.ts +5 -0
- package/lib/zip.d.ts.map +1 -0
- package/lib/zip.js +49 -0
- package/lib/zip.js.map +1 -0
- package/package.json +4 -2
- package/src/create-namespace.ts +3 -4
- package/src/login.ts +28 -1
- package/src/logout.ts +15 -0
- package/src/main.ts +21 -3
- package/src/ovsx +2 -2
- package/src/publish.ts +23 -16
- package/src/store.ts +142 -0
- package/src/util.ts +30 -0
- package/src/verify-pat.ts +22 -19
- package/src/zip.ts +55 -0
package/src/zip.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Entry, open, ZipFile } from 'yauzl';
|
|
2
|
+
import { Readable } from 'stream';
|
|
3
|
+
import { Manifest } from './util';
|
|
4
|
+
|
|
5
|
+
async function bufferStream(stream: Readable): Promise<Buffer> {
|
|
6
|
+
return await new Promise((c, e) => {
|
|
7
|
+
const buffers: Buffer[] = [];
|
|
8
|
+
stream.on('data', buffer => buffers.push(buffer));
|
|
9
|
+
stream.once('error', e);
|
|
10
|
+
stream.once('end', () => c(Buffer.concat(buffers)));
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function readZip(packagePath: string, filter: (name: string) => boolean): Promise<Map<string, Buffer>> {
|
|
15
|
+
const zipfile = await new Promise<ZipFile>((c, e) =>
|
|
16
|
+
open(packagePath, { lazyEntries: true }, (err, zipfile) => (err ? e(err) : c(zipfile!)))
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
return await new Promise((c, e) => {
|
|
20
|
+
const result = new Map<string, Buffer>();
|
|
21
|
+
|
|
22
|
+
zipfile.once('close', () => c(result));
|
|
23
|
+
|
|
24
|
+
zipfile.readEntry();
|
|
25
|
+
zipfile.on('entry', (entry: Entry) => {
|
|
26
|
+
const name = entry.fileName.toLowerCase();
|
|
27
|
+
|
|
28
|
+
if (filter(name)) {
|
|
29
|
+
zipfile.openReadStream(entry, (err, stream) => {
|
|
30
|
+
if (err) {
|
|
31
|
+
zipfile.close();
|
|
32
|
+
return e(err);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
bufferStream(stream!).then(buffer => {
|
|
36
|
+
result.set(name, buffer);
|
|
37
|
+
zipfile.readEntry();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
zipfile.readEntry();
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function readVSIXPackage(packagePath: string): Promise<Manifest> {
|
|
48
|
+
const map = await readZip(packagePath, name => /^extension\/package\.json$/i.test(name));
|
|
49
|
+
const rawManifest = map.get('extension/package.json');
|
|
50
|
+
if (!rawManifest) {
|
|
51
|
+
throw new Error('Manifest not found.');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return JSON.parse(rawManifest.toString('utf8')) as Manifest;
|
|
55
|
+
}
|