Skip to content

Commit

Permalink
WIP - package and publish built-ins to GH releases
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Dumais <[email protected]>
  • Loading branch information
marcdumais-work committed Dec 5, 2019
1 parent 8681348 commit bb9d30f
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ tasks:
yarn
command: >
jwm &
yarn package-vsix:next
github:
prebuilds:
branches: false
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
"publish:latest": "node ./src/publish.js --tag=latest",
"publish:next": "node ./src/publish.js --tag=next",
"rebuild:browser": "theia rebuild:browser",
"rebuild:electron": "theia rebuild:electron"
"rebuild:electron": "theia rebuild:electron",
"package-vsix:latest": "node src/package-vsix.js --tag latest",
"package-vsix:next": "node src/package-vsix.js --tag next"
},
"devDependencies": {
"@types/archiver": "^3.0.0",
"@types/node": "^8.0.0",
"archiver": "^3.0.3",
"lerna": "2.4.0"
"lerna": "2.4.0",
"vsce": "1.70.0",
"fs-extra": "8.1.0"
},
"workspaces": [
"vscode-builtin-extensions",
Expand Down
80 changes: 80 additions & 0 deletions src/package-vsix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* Package individual built-in VS Code extensions in .vsix packages
* The .vsix end-up in <repo root>/out
*/
// @ts-check
const fs = require('fs-extra')
const yargs = require('yargs');
const { root, extensions, run, vscode } = require('./paths.js');

const { tag } = yargs.option('tag', {
choices: ['latest', 'next']
}).demandOption('tag').argv;

const repository = {
"type": "git",
"url": "https://github.com/theia-ide/vscode-builtin-extensions"
};

// bump to publish
let version = '0.2.1';

(async () => {

const vscePath = await run('yarn', ['bin'], root());
const vsce = vscePath.trim() + '/vsce';

if (tag === 'next') {
const shortRevision = (await run('git', ['rev-parse', '--short', 'HEAD'], vscode())).trim();
const [, minor] = version.split('.');
version = `0.${Number(minor) + 1}.0-next.${shortRevision}`;
}
const result = [];

// typescript-language-features ext needs "extensions/node_modules" content
const extensionsNodeModulesPath = extensions('node_modules');
const tsLangFeaturesNMPath = extensions('typescript-language-features', '/node_modules');

if (fs.existsSync(extensionsNodeModulesPath) && fs.existsSync(extensions('typescript-language-features'))) {
await fs.copy(extensionsNodeModulesPath, tsLangFeaturesNMPath);
}

if (!fs.existsSync(root('out'))) {
await fs.mkdir(root('out'));
}

for (const extension of fs.readdirSync(extensions())) {
console.log(`extension: ${extension}`);
if (extension.includes('node_modules')) {
continue;
}
const pckPath = extensions(extension, 'package.json');
if (!fs.existsSync(pckPath)) {
continue;
}

const originalContent = fs.readFileSync(pckPath, 'utf-8');
const pck = JSON.parse(originalContent);
pck.publisher = "theia-ide";
pck.repository = repository;
pck.version = version;
// avoid having vsce run scripts during packaging, such as "vscode-prepublish"
pck.scripts = {};

try {
fs.writeFileSync(pckPath, JSON.stringify(pck, undefined, 2), 'utf-8');
await run(vsce, ['package', '--yarn', '-o', root('out')], extensions(extension));
// result.push(pck.name + ': sucessfully published');
} catch (e) {
// result.push(pck.name + ': failed to publish');
if (e) {
// console.error(e)
};
} finally {
fs.writeFileSync(pckPath, originalContent, 'utf-8');
}

// console.log(pck.name, ': publishing...');
}
// console.log(result.join(os.EOL));
})();

0 comments on commit bb9d30f

Please sign in to comment.