Skip to content

Commit

Permalink
Unify formatting
Browse files Browse the repository at this point in the history
Also format json accordingly
  • Loading branch information
filiptronicek committed Mar 28, 2024
1 parent 6a2e580 commit 860225b
Show file tree
Hide file tree
Showing 28 changed files with 1,150 additions and 945 deletions.
22 changes: 11 additions & 11 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "publish-extensions",
"image": "mcr.microsoft.com/devcontainers/base",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/shyim/devcontainers-features/bun:0": {},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers/features/python:1": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/java:1": {}
}
}
"name": "publish-extensions",
"image": "mcr.microsoft.com/devcontainers/base",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/shyim/devcontainers-features/bun:0": {},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers/features/python:1": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/java:1": {}
}
}
7 changes: 3 additions & 4 deletions .github/ISSUE_TEMPLATES/other.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
name: Other
about: Raise an issue about something not listed above
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---
6 changes: 3 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ see https://github.blog/2019-02-14-introducing-draft-pull-requests/ for further
-->

- [ ] I have read the note above about PRs contributing or fixing extensions
- [ ] I have tried reaching out to the extension maintainers about publishing this extension to Open VSX (if not, please create an issue in the extension's repo using [this template](https://github.com/open-vsx/publish-extensions/blob/HEAD/docs/external_contribution_request.md)).
- [ ] This extension has an [OSI-approved OSS license](https://opensource.org/licenses) (we don't accept proprietary extensions in this repository)
- [ ] I have read the note above about PRs contributing or fixing extensions
- [ ] I have tried reaching out to the extension maintainers about publishing this extension to Open VSX (if not, please create an issue in the extension's repo using [this template](https://github.com/open-vsx/publish-extensions/blob/HEAD/docs/external_contribution_request.md)).
- [ ] This extension has an [OSI-approved OSS license](https://opensource.org/licenses) (we don't accept proprietary extensions in this repository)

## Description

Expand Down
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package.json
extensions.json

*.yml
*.yaml
2 changes: 1 addition & 1 deletion .theia/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"terminal.integrated.scrollback": 20000
}
}
10 changes: 3 additions & 7 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@
"type": "pwa-node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"skipFiles": ["<node_internals>/**"],
"program": "${file}",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
"outFiles": ["${workspaceFolder}/**/*.js"]
}
]
}
}
45 changes: 23 additions & 22 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@ This Community Code of Conduct ("Code") outlines our behavior expectations as me

Examples of behavior that contribute to creating a positive and professional environment include:

- Using welcoming and inclusive language;
- Actively encouraging all voices;
- Helping others bring their perspectives and listening actively. If you find yourself dominating a discussion, it is especially important to encourage other voices to join in;
- Being respectful of differing viewpoints and experiences;
- Gracefully accepting constructive criticism;
- Focusing on what is best for the community;
- Showing empathy towards other community members;
- Being direct but professional; and
- Leading by example by holding yourself and others accountable
- Using welcoming and inclusive language;
- Actively encouraging all voices;
- Helping others bring their perspectives and listening actively. If you find yourself dominating a discussion, it is especially important to encourage other voices to join in;
- Being respectful of differing viewpoints and experiences;
- Gracefully accepting constructive criticism;
- Focusing on what is best for the community;
- Showing empathy towards other community members;
- Being direct but professional; and
- Leading by example by holding yourself and others accountable

Examples of unacceptable behavior by Contributors include:

- The use of sexualized language or imagery;
- Unwelcome sexual attention or advances;
- Trolling, insulting/derogatory comments, and personal or political attacks;
- Public or private harassment, repeated harassment;
- Publishing others' private information, such as a physical or electronic address, without explicit permission;
- Violent threats or language directed against another person;
- Sexist, racist, or otherwise discriminatory jokes and language;
- Posting sexually explicit or violent material;
- Sharing private content, such as emails sent privately or non-publicly, or unlogged forums such as IRC channel history;
- Personal insults, especially those using racist or sexist terms;
- Excessive or unnecessary profanity;
- Advocating for, or encouraging, any of the above behavior; and
- Other conduct which could reasonably be considered inappropriate in a professional setting
- The use of sexualized language or imagery;
- Unwelcome sexual attention or advances;
- Trolling, insulting/derogatory comments, and personal or political attacks;
- Public or private harassment, repeated harassment;
- Publishing others' private information, such as a physical or electronic address, without explicit permission;
- Violent threats or language directed against another person;
- Sexist, racist, or otherwise discriminatory jokes and language;
- Posting sexually explicit or violent material;
- Sharing private content, such as emails sent privately or non-publicly, or unlogged forums such as IRC channel history;
- Personal insults, especially those using racist or sexist terms;
- Excessive or unnecessary profanity;
- Advocating for, or encouraging, any of the above behavior; and
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Expand Down Expand Up @@ -68,6 +68,7 @@ Reports should be directed to <[email protected]>. It is the Conduc
The Eclipse Foundation takes all reports of potential Code violations seriously and is committed to confidentiality and a full investigation of all allegations. The identity of the reporter will be omitted from the details of the report supplied to the accused. Contributors who are being investigated for a potential Code violation will have an opportunity to be heard prior to any final determination. Those found to have violated the Code can seek reconsideration of the violation and disciplinary action decisions. Every effort will be made to have all matters disposed of within 60 days of the receipt of the complaint.

## Actions

Contributors who do not follow this Code in good faith may face temporary or permanent repercussions as determined by the Conduct Committee.

This Code does not address all conduct. It works in conjunction with our [Communication Channel Guidelines](https://www.eclipse.org/org/documents/communication-channel-guidelines/), [Social Media Guidelines](https://www.eclipse.org/org/documents/social_media_guidelines.php), [Bylaws](https://www.eclipse.org/org/documents/eclipse-foundation-be-bylaws-en.pdf), and [Internal Rules](https://www.eclipse.org/org/documents/ef-be-internal-rules.pdf) which set out additional protections for, and obligations of, all contributors. The Foundation has additional policies that provide further guidance on other matters.
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ This project is governed by the [Eclipse Community Code of Conduct](CODE_OF_COND

The following communication channels are available:

* [publish-extensions issues](https://github.com/open-vsx/publish-extensions/issues) - for general issues (bug reports, feature requests, etc.)
* [open-vsx.org issues](https://github.com/EclipseFdn/open-vsx.org/issues) - for issues related to [open-vsx.org](https://open-vsx.org/) (outage reports, requests about extensions and namespaces, etc.)
* [Developer mailing list](https://accounts.eclipse.org/mailing-list/openvsx-dev) - for organizational issues (e.g. elections of new committers)
- [publish-extensions issues](https://github.com/open-vsx/publish-extensions/issues) - for general issues (bug reports, feature requests, etc.)
- [open-vsx.org issues](https://github.com/EclipseFdn/open-vsx.org/issues) - for issues related to [open-vsx.org](https://open-vsx.org/) (outage reports, requests about extensions and namespaces, etc.)
- [Developer mailing list](https://accounts.eclipse.org/mailing-list/openvsx-dev) - for organizational issues (e.g. elections of new committers)

## How to Contribute

Expand Down
16 changes: 8 additions & 8 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

### Prerequisites

- [Node.js](https://nodejs.org/en/) (we use Node 18)
- Ubuntu Linux (Windows and macOS work fine for adding extensions, but extensions are always tested on Ubuntu, so they only need to build correctly there)
- [Node.js](https://nodejs.org/en/) (we use Node 18)
- Ubuntu Linux (Windows and macOS work fine for adding extensions, but extensions are always tested on Ubuntu, so they only need to build correctly there)

To add an extension to this repo, clone the repo[^clone], install the dependencies[^deps], and use the following command:

Expand Down Expand Up @@ -79,12 +79,12 @@ in order to perform advanced tasks such as executing operations based on the ext

Following environment variables are available:

- `EXTENSION_ID`: the extension ID, e.g. `rebornix.ruby`
- `EXTENSION_PUBLISHER`: the extension publisher, e.g. `rebornix`
- `EXTENSION_NAME`: the extension name, e.g. `ruby`
- `VERSION`: the version of the extension to publish, e.g. `0.1.0`
- `MS_VERSION`: the latest version of the extension on the MS Marketplace[^ms], e.g. `0.1.0`
- `OVSX_VERSION`: the latest version of the extension on Open VSX, e.g. `0.1.0`
- `EXTENSION_ID`: the extension ID, e.g. `rebornix.ruby`
- `EXTENSION_PUBLISHER`: the extension publisher, e.g. `rebornix`
- `EXTENSION_NAME`: the extension name, e.g. `ruby`
- `VERSION`: the version of the extension to publish, e.g. `0.1.0`
- `MS_VERSION`: the latest version of the extension on the MS Marketplace[^ms], e.g. `0.1.0`
- `OVSX_VERSION`: the latest version of the extension on Open VSX, e.g. `0.1.0`

[publish-extensions-job]: https://github.com/open-vsx/publish-extensions/blob/master/.github/workflows/publish-extensions.yml

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

A CI script for publishing open-source VS Code extensions to [open-vsx.org](https://open-vsx.org).

This repository is open for contributions, but before you contribute, please read our [Contribution guidelines](CONTRIBUTING.md).
This repository is open for contributions, but before you contribute, please read our [Contribution guidelines](CONTRIBUTING.md).
102 changes: 60 additions & 42 deletions add-extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,59 +16,67 @@
//

// @ts-check
const fs = require('fs');
const minimist = require('minimist');
const util = require('util');
const fs = require("fs");
const minimist = require("minimist");
const util = require("util");
const exec = require("./lib/exec");
const extensionsSchema = require('./extensions-schema.json');
const fetch = require('node-fetch');
const { getPublicGalleryAPI } = require('@vscode/vsce/out/util');
const parseXmlManifest = require('@vscode/vsce/out/xml').parseXmlManifest;
const { ExtensionQueryFlags, PublishedExtension } = require('azure-devops-node-api/interfaces/GalleryInterfaces');
const extensionsSchema = require("./extensions-schema.json");
const fetch = require("node-fetch");
const { getPublicGalleryAPI } = require("@vscode/vsce/out/util");
const parseXmlManifest = require("@vscode/vsce/out/xml").parseXmlManifest;
const { ExtensionQueryFlags, PublishedExtension } = require("azure-devops-node-api/interfaces/GalleryInterfaces");

const flags = [
ExtensionQueryFlags.IncludeMetadata,
ExtensionQueryFlags.IncludeAssetUri,
ExtensionQueryFlags.IncludeFiles,
ExtensionQueryFlags.IncludeLatestVersionOnly
ExtensionQueryFlags.IncludeLatestVersionOnly,
];

const msGalleryApi = getPublicGalleryAPI();
msGalleryApi.client['_allowRetries'] = true;
msGalleryApi.client['_maxRetries'] = 5;
msGalleryApi.client["_allowRetries"] = true;
msGalleryApi.client["_maxRetries"] = 5;

const getRepositoryFromMarketplace = async (/** @type {string} */ id) => {
/** @type {[PromiseSettledResult<PublishedExtension | undefined>]} */
let [msExtension] = await Promise.allSettled([msGalleryApi.getExtension(id, flags)]);
if (msExtension.status === 'fulfilled') {
const vsixManifest = msExtension.value?.versions && msExtension.value?.versions[0].files?.find(file => file.assetType === "Microsoft.VisualStudio.Services.VsixManifest")?.source;
if (msExtension.status === "fulfilled") {
const vsixManifest =
msExtension.value?.versions &&
msExtension.value?.versions[0].files?.find(
(file) => file.assetType === "Microsoft.VisualStudio.Services.VsixManifest",
)?.source;
const response = await fetch(vsixManifest);
const data = await parseXmlManifest(await response.text());
const url = new URL(data.PackageManifest.Metadata[0].Properties[0].Property.find(property => property.$.Id === "Microsoft.VisualStudio.Services.Links.Source").$.Value);
const url = new URL(
data.PackageManifest.Metadata[0].Properties[0].Property.find(
(property) => property.$.Id === "Microsoft.VisualStudio.Services.Links.Source",
).$.Value,
);

if (url.host === "github.com") {
return url.toString().replace('.git', '')
return url.toString().replace(".git", "");
}

return url.toString();
}
}
};

(async () => {
// Parse args
const argv = minimist(process.argv.slice(2)); // without executable & script path

// Check positional args
if (argv._.length === 0) {
console.error('Need two positional arguments: ext-id, repo-url or a Microsoft Marketplace URL');
console.error("Need two positional arguments: ext-id, repo-url or a Microsoft Marketplace URL");
process.exit(1);
}

let [extID, repoURL] = argv._;
try {
const urlObject = new URL(extID);
if (urlObject.host === 'marketplace.visualstudio.com') {
const id = urlObject.searchParams.get('itemName');
if (urlObject.host === "marketplace.visualstudio.com") {
const id = urlObject.searchParams.get("itemName");
if (!id) {
console.error(`Couldn\'t get the extension ID from ${extID}`);
process.exit(1);
Expand All @@ -83,9 +91,12 @@ const getRepositoryFromMarketplace = async (/** @type {string} */ id) => {
}
}
}
} catch { } finally {
} catch {
} finally {
if (argv._.length < 2 && !repoURL) {
console.error('Need two positional arguments: ext-id, repo-url, since the provided argument is not a Marketplace URL');
console.error(
"Need two positional arguments: ext-id, repo-url, since the provided argument is not a Marketplace URL",
);
process.exit(1);
}
}
Expand All @@ -105,23 +116,29 @@ const getRepositoryFromMarketplace = async (/** @type {string} */ id) => {
}

// parse & validate value
if (propDef.type === 'string') {
extDefinition[arg] = String(argv[arg]) // minimist might've assumed a different type (e.g. number)
} else if (propDef.type === 'number') {
if (typeof argv[arg] !== 'number') {
console.error(`argument '${arg}' should be type '${propDef.type}' but yours seems to be '${typeof argv[arg]}'`);
if (propDef.type === "string") {
extDefinition[arg] = String(argv[arg]); // minimist might've assumed a different type (e.g. number)
} else if (propDef.type === "number") {
if (typeof argv[arg] !== "number") {
console.error(
`argument '${arg}' should be type '${propDef.type}' but yours seems to be '${typeof argv[arg]}'`,
);
process.exit(1);
}
extDefinition[arg] = argv[arg] // numbers are parsed by minimist already
extDefinition[arg] = argv[arg]; // numbers are parsed by minimist already
} else {
console.error(`argument '${arg}' is of type '${propDef.type}' which is not implemented by this script, sorry`);
console.error(
`argument '${arg}' is of type '${propDef.type}' which is not implemented by this script, sorry`,
);
process.exit(1);
}
}
console.info('Adding extension:', util.inspect(extDefinition, { colors: true, compact: false }));
console.info("Adding extension:", util.inspect(extDefinition, { colors: true, compact: false }));

// Read current file
const extensions = Object.entries(JSON.parse(await fs.promises.readFile('./extensions.json', { encoding: 'utf8' })));
const extensions = Object.entries(
JSON.parse(await fs.promises.readFile("./extensions.json", { encoding: "utf8" })),
);
// Sort extensions (most are, but not always)
extensions.sort(([k1], [k2]) => k1.localeCompare(k2));

Expand All @@ -131,9 +148,9 @@ const getRepositoryFromMarketplace = async (/** @type {string} */ id) => {
for (let i = 0; i < extensions.length; i++) {
const [currentID] = extensions[i];
// console.debug(i, currentID)
const diff = currentID.localeCompare(extID, undefined, { sensitivity: 'base' });
const diff = currentID.localeCompare(extID, undefined, { sensitivity: "base" });
if (diff === 0) {
console.error('Extension already defined:', currentID);
console.error("Extension already defined:", currentID);
process.exit(1);
}
if (diff > 0) {
Expand All @@ -144,14 +161,14 @@ const getRepositoryFromMarketplace = async (/** @type {string} */ id) => {

// Persist changes
await fs.promises.writeFile(
'./extensions.json',
JSON.stringify(Object.fromEntries(extensions), undefined, 2) + '\n', // add newline at EOF
{ encoding: 'utf8' }
"./extensions.json",
JSON.stringify(Object.fromEntries(extensions), undefined, 2) + "\n", // add newline at EOF
{ encoding: "utf8" },
);

console.info(`Successfully added ${extID}`);
if (process.env.TEST_EXTENSION === "false") {
console.info("Skipping tests, TEST_EXTENSION was provided.")
console.info("Skipping tests, TEST_EXTENSION was provided.");
process.exit(0);
}

Expand All @@ -163,15 +180,16 @@ const getRepositoryFromMarketplace = async (/** @type {string} */ id) => {

const out = await exec("node publish-extensions", { quiet: true, ghtoken: true });
if (out && out.stderr.includes("[FAIL] Could not process extension:")) {
console.error(`There was an error while trying to build ${extID}. Reverting back to the previous state of extensions.json.`);
console.error(
`There was an error while trying to build ${extID}. Reverting back to the previous state of extensions.json.`,
);
await fs.promises.writeFile(
'./extensions.json',
originalList + '\n', // add newline at EOF
{ encoding: 'utf8' }
"./extensions.json",
originalList + "\n", // add newline at EOF
{ encoding: "utf8" },
);
} else {
console.info("Built extension successfully");
console.info(`Feel free to use the message below for your commit:\r\nAdded \`${extID}\``);
}

})();
})();
2 changes: 1 addition & 1 deletion bin/publish-extensions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env node

require('../publish-extensions');
require("../publish-extensions");
Loading

0 comments on commit 860225b

Please sign in to comment.