Skip to content

Commit

Permalink
WIP - package and publish built-ins individually
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 12, 2019
1 parent 8681348 commit dea07ff
Show file tree
Hide file tree
Showing 10 changed files with 1,396 additions and 90 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/publish-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,9 @@ jobs:
name: Bundle Extensions
- run: yarn publish:next
name: Deploy Extensions
- run: yarn package-vsix:next
name: Bundle Extensions in individual .vsix
- run: |
# cd out
GITHUB_TOKEN=$GITHUB_TOKEN DEBUG=release-it:* yarn run release-it
name: Publish on GH Release
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ node_modules_backup
lib
*.log
*-app/*
!*-app/package.json
!*-app/package.json
out
3 changes: 2 additions & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ ports:
onOpen: ignore
tasks:
- init: >
yarn
yarn && yarn package-vsix:next
command: >
jwm &
yarn --cwd browser-app start ../ --hostname=0.0.0.0
github:
prebuilds:
branches: false
30 changes: 30 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"git": {
"requireCleanWorkingDir": false,
"requireUpstream": true,
"requireCommits": false,
"addUntrackedFiles": false,
"commit": true,
"commitMessage": "Release v${version}",
"commitArgs": "-s",
"tag": true,
"tagName": "v${version}",
"tagAnnotation": "Release v${version}",
"tagArgs": "",
"push": true,
"pushArgs": "--follow-tags",
"pushRepo": "origin"
},
"github": {
"release": true,
"releaseName": "Release ${version}",
"preRelease": true,
"draft": true,
"tokenRef": "GITHUB_TOKEN",
"assets": [
"out/*.vsix"
],
"timeout": 0,
"proxy": null
}
}
4 changes: 2 additions & 2 deletions browser-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"name": "browser-app",
"version": "0.0.0",
"dependencies": {
"vscode-builtin-extensions": "0.0.0"
"@theia/plugin-ext-vscode": "next"
},
"devDependencies": {
"@theia/cli": "next"
},
"scripts": {
"prepare": "theia build --mode development",
"start": "theia start --hostname=0.0.0.0",
"start": "theia start --plugins=local-dir:../out --hostname=0.0.0.0",
"watch": "theia build --watch --mode development"
},
"theia": {
Expand Down
4 changes: 2 additions & 2 deletions electron-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"name": "electron-app",
"version": "0.0.0",
"dependencies": {
"vscode-builtin-extensions": "0.0.0"
"@theia/plugin-ext-vscode": "next"
},
"devDependencies": {
"@theia/cli": "next",
"@theia/electron": "next"
},
"scripts": {
"prepare": "theia build --mode development",
"start": "theia start --hostname=0.0.0.0",
"start": "theia start --plugins=local-dir:../out --hostname=0.0.0.0",
"watch": "theia build --watch --mode development"
},
"theia": {
Expand Down
52 changes: 29 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
{
"private": true,
"scripts": {
"prepare": "yarn build:extensions && yarn bundle:extensions && yarn build",
"build": "lerna run prepare",
"build:extensions": "yarn --cwd vscode && yarn compile:extensions",
"compile:extensions": "NODE_OPTIONS=--max-old-space-size=8192 node ./src/compile.js",
"bundle:extensions": "NODE_OPTIONS=--max-old-space-size=8192 node ./src/bundle.js",
"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"
},
"devDependencies": {
"@types/archiver": "^3.0.0",
"@types/node": "^8.0.0",
"archiver": "^3.0.3",
"lerna": "2.4.0"
},
"workspaces": [
"vscode-builtin-extensions",
"browser-app",
"electron-app"
]
"private": true,
"version": "0.3.0-next.7d7903ea53",
"scripts": {
"prepare": "yarn build:extensions && yarn bundle:extensions && yarn build",
"build": "lerna run prepare",
"build:extensions": "yarn --cwd vscode && yarn compile:extensions",
"compile:extensions": "NODE_OPTIONS=--max-old-space-size=8192 node ./src/compile.js",
"bundle:extensions": "NODE_OPTIONS=--max-old-space-size=8192 node ./src/bundle.js",
"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",
"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",
"vsce": "1.70.0",
"fs-extra": "8.1.0",
"release-it": "12.4.3"
},
"workspaces": [
"vscode-builtin-extensions",
"browser-app",
"electron-app"
]
}
99 changes: 99 additions & 0 deletions src/package-vsix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/**
* Package individual built-in VS Code extensions in .vsix packages
* The .vsix packages end-up in <repo root>/out
*/
// @ts-check
const fs = require('fs-extra')
const os = require('os');
const yargs = require('yargs');
const { root, out, 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 bin = await run('yarn', ['bin'], root());
const vsce = bin.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/');
if (fs.existsSync(extensionsNodeModulesPath) && fs.existsSync(extensions('typescript-language-features'))) {
await fs.copy(extensionsNodeModulesPath, tsLangFeaturesNMPath);
console.log('Copying node_modules under typescript-language-features');
}

if (!fs.existsSync(out())) {
await fs.mkdir(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);
// warning: do not meddle with pck.publisher - it's part of the
// extension id and used in places to access some extensions
// pck.publisher = "theia-ide";
pck.repository = repository;
pck.version = version;
// avoid having vsce run scripts during packaging, such as "vscode-prepublish"
pck.scripts = {};

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

}

console.log('Publishing extensions');
for (const vsix of fs.readdirSync(out())) {
try {
console.log(`Publish ext name: ${vsix}`);
// await run('yarn', ['release-it', 'upload',`--name "${version}"`, `--tag ${version}`,'--owner marcdumais-work', '--repo vscode-builtin-extensions', '--prerelease', await run('ls', [out(vsix)])]);
// await run('yarn', ['github-release', 'upload',`--name "${version}"`, `--tag ${version}`,'--owner marcdumais-work', '--repo vscode-builtin-extensions', '--prerelease', await run('ls', [out(vsix)])]);
// result.push('sucessfully packaged: ' + pck.name);
} catch (e) {
// result.push('failed to packaged: ' + pck.name);
if (e) {
console.error(e)
};
}
}

console.log(result.join(os.EOL));
})();
8 changes: 7 additions & 1 deletion src/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ const cp = require('child_process');
function root(...paths) {
return path.join(__dirname, '..', ...paths);
}
/**
* @type {(paths: string[]) => string}
*/
function out(...paths) {
return root('out', ...paths);
}
/**
* @type {(paths: string[]) => string}
*/
Expand Down Expand Up @@ -49,4 +55,4 @@ function run(command, args, cwd = process.cwd()) {
});
}

module.exports = { root, src, vscode, theiaExtension, extensions, run };
module.exports = { root, out, src, vscode, theiaExtension, extensions, run };
Loading

0 comments on commit dea07ff

Please sign in to comment.