-
Notifications
You must be signed in to change notification settings - Fork 108
vscode-extensions: detect vsix sources and generate packages automatically #353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ lib, vscode-utils, sources }: | ||
let | ||
inherit (vscode-utils) isVscodeExt mkVscodeExtensions; | ||
|
||
vscodeSources = lib.filterAttrs | ||
(name: ext: if ext ? src then isVscodeExt ext.src.name else false) | ||
sources; | ||
|
||
baseExtensions = mkVscodeExtensions vscodeSources; | ||
in | ||
baseExtensions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
{ lib | ||
, vscode-utils | ||
, vscode | ||
, namespace ? false | ||
}: | ||
|
||
with lib; | ||
|
||
let | ||
isVsix = hasSuffix ".vsix"; | ||
|
||
isVsixPackage = hasSuffix ".VSIXPackage"; | ||
|
||
isVscodeExt = name: (isVsix name) || (isVsixPackage name); | ||
Comment on lines
+10
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
|
||
isNaiveJSONList = string: (hasPrefix "[" string) && (hasSuffix "]" string); | ||
|
||
toJSONString = string: | ||
if isNaiveJSONList string | ||
then string | ||
else ''"${string}"''; | ||
|
||
mkVscodeExtUniqueId = ext: | ||
let uniqueIds = | ||
if isVsix ext.src.name | ||
then splitString "." (getName ext.src.name) | ||
else | ||
builtins.match | ||
# 1st & 2nd match: publisher | ||
# 3rd match: name | ||
"https://(.*).gallery.vsassets.io/_apis/public/gallery/publisher/(.*)/extension/(.*)/${ext.version}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage" | ||
(head ext.src.urls); | ||
in | ||
{ publisher = head uniqueIds; pname = last uniqueIds; }; | ||
|
||
mkVscodeExtMetaLink = name: publisher: pname: { openVsxPath ? "/", vscodeMarketplacePath ? "/" }: | ||
if isVsix name | ||
then "https://open-vsx.org/extension/${publisher}/${pname}${openVsxPath}" | ||
else "https://marketplace.visualstudio.com/items/${publisher}.${pname}${vscodeMarketplacePath}"; | ||
|
||
mkVscodeMetaOption = ext: | ||
if isVsix ext.src.name | ||
then { inherit (ext) homepage description; } | ||
else { }; | ||
|
||
mkVscodeExtension = ext: publisher: pname: | ||
vscode-utils.buildVscodeExtension ((builtins.removeAttrs ext [ "pname" "src" "version" "homepage" "description" ]) // rec { | ||
inherit (ext) version; | ||
|
||
name = "${publisher}-${pname}-${version}"; | ||
|
||
vscodeExtUniqueId = "${publisher}.${pname}"; | ||
|
||
src = "${publisher}-${pname}.zip"; | ||
|
||
preUnpack = ''ln -s "${ext.src}" $src''; | ||
|
||
meta = with lib; { | ||
inherit (vscode.meta) platforms; | ||
downloadPage = mkVscodeExtMetaLink ext.src.name publisher pname { }; | ||
changelog = mkVscodeExtMetaLink ext.src.name publisher pname { | ||
openVsxPath = "/changes"; | ||
vscodeMarketplacePath = "/changelog"; | ||
}; | ||
license = assert asserts.assertMsg (ext ? license) "Specify a license for ${vscodeExtUniqueId} VS Code extension!"; | ||
forEach | ||
(toList (builtins.fromJSON (toJSONString ext.license))) | ||
(license: licenses."${license}"); | ||
maintainers = | ||
if ext ? maintainers | ||
then | ||
forEach | ||
(toList (builtins.fromJSON ext.maintainers)) | ||
(maintainer: maintainers."${maintainer}") | ||
else [ maintainers.danielphan2003 ]; | ||
} // (mkVscodeMetaOption ext); | ||
}); | ||
|
||
mkVscodeExtensions = sources: | ||
mapAttrs' | ||
(name: ext: | ||
let inherit (mkVscodeExtUniqueId ext) publisher pname; in | ||
nameValuePair | ||
"${optionalString namespace "${publisher}."}${name}" # follows user-defined source name | ||
(mkVscodeExtension ext publisher pname)) | ||
sources; | ||
in | ||
{ | ||
inherit | ||
isVsix isVscodeExt isVsixPackage | ||
mkVscodeExtUniqueId mkVscodeExtMetaLink | ||
mkVscodeExtension mkVscodeExtensions | ||
; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those look like convenience library functions that we might want to discuss adding in
digga
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or alternatively a
divnix/vsext
(to decouple release cycles)!!!