Skip to content

Commit

Permalink
Update built-ins for Open VSX publish
Browse files Browse the repository at this point in the history
The built-ins package.json are missing many fields that are
desirable to have so that the extension's page on Open VSX
will be populated correctly.

Fixes #19

Signed-off-by: Marc Dumais <[email protected]>
  • Loading branch information
marcdumais-work committed Mar 19, 2020
1 parent 89ddd51 commit 052fa2c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"archiver": "^3.0.3",
"lerna": "2.4.0",
"vsce": "1.70.0",
"fs-extra": "8.1.0"
"fs-extra": "8.1.0",
"capitalize": "^2.0.2"
},
"workspaces": [
"vscode-builtin-extensions",
Expand Down
33 changes: 30 additions & 3 deletions src/package-vsix.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const fs = require('fs-extra')
const os = require('os');
const yargs = require('yargs');
const capitalize = require('capitalize');
const { root, dist, extensions, run, vscode } = require('./paths.js');

const { tag } = yargs.option('tag', {
Expand All @@ -17,7 +18,7 @@ const repository = {
};

// bump to publish
let version = '1.39.1-prel';
let version = '1.39.1';

(async () => {

Expand Down Expand Up @@ -63,23 +64,38 @@ let version = '1.39.1-prel';
}

for (const extension of fs.readdirSync(extensions())) {
const extDisplayName = capitalize.words(extension.replace('-', ' ')) + " (built-in)"
const pckPath = extensions(extension, 'package.json');
const nlsPath = extensions(extension, 'package.nls.json');
const readmePath = extensions(extension, 'README.md');
const readmeContent = genReadme(extension);

if (!fs.existsSync(pckPath)) {
continue;
}

const originalContent = fs.readFileSync(pckPath, 'utf-8');
const pck = JSON.parse(originalContent);
// warning: do change pck.publisher - it's part of the
// extension id and used in places to access some extensions
const nlsContent = fs.readFileSync(nlsPath, 'utf-8');
const nls = JSON.parse(nlsContent);

// note: do change pck.publisher - it's part of the key used to
// lookup extensions, and so changing it may prevent dependent extensions
// to not find it
// pck.displayName = nls.displayName || extDisplayName + " (built-in)";
pck.displayName = nls.displayName? nls.displayName + " (built-in)" : extDisplayName ;
pck.description = nls.description || "Built-in extension that adds (potentially basic) support for " + capitalize(pck.name);
pck.keywords = ["Built-in"];
pck.repository = repository;
pck.version = version;

// avoid having vsce run scripts during packaging, such as "vscode-prepublish"
pck.scripts = {};

console.log('packaging vsix: ', pck.name, ' ...');
try {
fs.writeFileSync(pckPath, JSON.stringify(pck, undefined, 2), 'utf-8');
fs.writeFileSync(readmePath, readmeContent, 'utf-8');
await run(vsce, ['package', '--yarn', '-o', dist()], extensions(extension));
result.push('sucessfully packaged: ' + pck.name);
} catch (e) {
Expand All @@ -89,9 +105,20 @@ let version = '1.39.1-prel';
};
} finally {
fs.writeFileSync(pckPath, originalContent, 'utf-8');
fs.removeSync(readmePath);
}

}

console.log(result.join(os.EOL));
})();

// a very basic README to add to the extension to explain what it is
function genReadme(ext) {
return `# Built-in extension: ${ext}
Built-in are extensions that are included in \`VS Code\` and \`Code OSS\` They are part of the [vscode GitHub repository](https://github.com/microsoft/vscode/tree/master/extensions) and built along with it.
So if you are running \`VS Code\` or \`Code OSS\` you probably do not need to add them, but other editors might`;

}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3235,6 +3235,11 @@ caniuse-lite@^1.0.30001010:
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001012.tgz#653ec635e815b9e0fb801890923b0c2079eb34ec"
integrity sha512-7RR4Uh04t9K1uYRWzOJmzplgEOAXbfK72oVNokCdMzA67trrhPzy93ahKk1AWHiA0c58tD2P+NHqxrA8FZ+Trg==

capitalize@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/capitalize/-/capitalize-2.0.2.tgz#d66855724fafc09f7f913131f89000a7879e6954"
integrity sha512-kX+ZpaqUSx1YcAKnZ6J4HZY0yaYc+RnIVkO+3ckeerj8lW0T+9GmyRekRF3PzH+46HHdsz2ma0S0NfTby/rojA==

caseless@~0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
Expand Down

0 comments on commit 052fa2c

Please sign in to comment.