From bba52b26dd326ceddc6e028ceb9268d309718620 Mon Sep 17 00:00:00 2001 From: Marc Dumais Date: Tue, 17 Mar 2020 18:52:44 -0400 Subject: [PATCH] Update built-ins for Open VSX publish 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 --- package.json | 3 ++- src/package-vsix.js | 31 +++++++++++++++++++++++++++++-- yarn.lock | 5 +++++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 62b2179..8d461b0 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/package-vsix.js b/src/package-vsix.js index 1714af6..c538371 100644 --- a/src/package-vsix.js +++ b/src/package-vsix.js @@ -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', { @@ -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) { @@ -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`; + +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 92ffe13..29210d6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"