-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage-vsix.js
More file actions
120 lines (103 loc) · 5.39 KB
/
package-vsix.js
File metadata and controls
120 lines (103 loc) · 5.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const archiver = require('archiver');
console.log('📦 Creating VS Code VSIX package...\n');
// Create output stream
const output = fs.createWriteStream('visual-code-map-0.1.0.vsix');
const archive = archiver('zip', {
zlib: { level: 9 }
});
// Handle errors
archive.on('error', (err) => {
throw err;
});
// Listen for completion
output.on('close', () => {
const size = (archive.pointer() / 1024 / 1024).toFixed(2);
console.log(`\n✅ VSIX package created successfully!`);
console.log(`📦 File: visual-code-map-0.1.0.vsix (${size} MB)`);
console.log('\n🚀 Ready to upload to VS Code Marketplace!');
});
// Pipe archive to output
archive.pipe(output);
// Add extension files
console.log('Adding extension files...');
// Add main files
archive.file('package.json', { name: 'extension/package.json' });
archive.file('README.md', { name: 'extension/README.md' });
archive.file('CHANGELOG.md', { name: 'extension/CHANGELOG.md' });
archive.file('LICENSE', { name: 'extension/LICENSE' });
// Add dist folder
archive.directory('dist/', 'extension/dist');
// Add resources
archive.directory('resources/', 'extension/resources');
// Add webview files
archive.file('src/webview/graph.js', { name: 'extension/src/webview/graph.js' });
archive.directory('src/webview/styles/', 'extension/src/webview/styles');
// Add node_modules/d3
if (fs.existsSync('node_modules/d3/dist/d3.min.js')) {
archive.file('node_modules/d3/dist/d3.min.js', { name: 'extension/node_modules/d3/dist/d3.min.js' });
}
// Create extension manifest
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const manifest = `<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011">
<Metadata>
<Identity Language="en-US" Id="${packageJson.name}" Version="${packageJson.version}" Publisher="${packageJson.publisher}"/>
<DisplayName>${packageJson.displayName}</DisplayName>
<Description xml:space="preserve">${packageJson.description}</Description>
<Tags>Programming Languages,Other</Tags>
<Categories>Programming Languages,Other</Categories>
<GalleryFlags>Public</GalleryFlags>
<Badges></Badges>
<Properties>
<Property Id="Microsoft.VisualStudio.Code.Engine" Value="^1.74.0" />
<Property Id="Microsoft.VisualStudio.Code.ExtensionDependencies" Value="" />
<Property Id="Microsoft.VisualStudio.Code.ExtensionPack" Value="" />
<Property Id="Microsoft.VisualStudio.Code.ExtensionKind" Value="workspace" />
<Property Id="Microsoft.VisualStudio.Code.LocalizedLanguages" Value="" />
<Property Id="Microsoft.VisualStudio.Services.Links.Source" Value="https://github.com/Prawal-Sharma/VisualCodeMap.git" />
<Property Id="Microsoft.VisualStudio.Services.Links.Getstarted" Value="https://github.com/Prawal-Sharma/VisualCodeMap.git" />
<Property Id="Microsoft.VisualStudio.Services.Links.GitHub" Value="https://github.com/Prawal-Sharma/VisualCodeMap.git" />
<Property Id="Microsoft.VisualStudio.Services.Links.Support" Value="https://github.com/Prawal-Sharma/VisualCodeMap/issues" />
<Property Id="Microsoft.VisualStudio.Services.Links.Learn" Value="https://github.com/Prawal-Sharma/VisualCodeMap.git" />
<Property Id="Microsoft.VisualStudio.Services.Branding.Color" Value="#2C2C32" />
<Property Id="Microsoft.VisualStudio.Services.Branding.Theme" Value="dark" />
<Property Id="Microsoft.VisualStudio.Services.GitHubFlavoredMarkdown" Value="true" />
</Properties>
<License>extension/LICENSE</License>
<Icon>extension/resources/icon.svg</Icon>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Code"/>
</Installation>
<Dependencies/>
<Assets>
<Asset Type="Microsoft.VisualStudio.Code.Manifest" Path="extension/package.json" Addressable="true" />
<Asset Type="Microsoft.VisualStudio.Services.Content.Details" Path="extension/README.md" Addressable="true" />
<Asset Type="Microsoft.VisualStudio.Services.Content.Changelog" Path="extension/CHANGELOG.md" Addressable="true" />
<Asset Type="Microsoft.VisualStudio.Services.Content.License" Path="extension/LICENSE" Addressable="true" />
<Asset Type="Microsoft.VisualStudio.Services.Icons.Default" Path="extension/resources/icon.svg" Addressable="true" />
</Assets>
</PackageManifest>`;
archive.append(manifest, { name: 'extension.vsixmanifest' });
// Create [Content_Types].xml
const contentTypes = `<?xml version="1.0" encoding="utf-8"?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
<Default Extension=".json" ContentType="application/json"/>
<Default Extension=".vsixmanifest" ContentType="text/xml"/>
<Default Extension=".md" ContentType="text/markdown"/>
<Default Extension=".js" ContentType="application/javascript"/>
<Default Extension=".css" ContentType="text/css"/>
<Default Extension=".svg" ContentType="image/svg+xml"/>
<Default Extension=".png" ContentType="image/png"/>
<Default Extension=".txt" ContentType="text/plain"/>
<Default Extension=".ts" ContentType="application/typescript"/>
<Default Extension=".tsx" ContentType="application/typescript"/>
<Default Extension=".html" ContentType="text/html"/>
</Types>`;
archive.append(contentTypes, { name: '[Content_Types].xml' });
// Finalize the archive
console.log('Finalizing package...');
archive.finalize();