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 10, 2019
1 parent 8681348 commit 3f85b75
Show file tree
Hide file tree
Showing 9 changed files with 420 additions and 43 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/publish-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
# NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
steps:
- uses: actions/checkout@v1
- run: |
Expand All @@ -38,5 +38,11 @@ jobs:
name: Reset to latest VS Code
- run: yarn
name: Bundle Extensions
- run: yarn publish:next
name: Deploy Extensions
# - run: yarn publish:next
# name: Deploy Extensions
- run: yarn package-vsix:next
name: Bundle Extensions
# - run: |
# cd out
# yarn github-release -t
# 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
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
79 changes: 57 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,60 @@
{
"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"
"private": true,
"version": "0.0.17",
"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",
"release": "release-it --verbose"
},
"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"
],
"release-it": {
"github": {
"release": true,
"releaseName": "Release ${version}",
"preRelease": true,
"draft": true,
"tokenRef": "GITHUB_TOKEN",
"assets": [
"out/typescript-0.3.0-next.9e899b556f.vsix"
],
"timeout": 0
},
"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"
]
"git": {
"requireCleanWorkingDir": false,
"requireUpstream": true,
"requireCommits": false,
"addUntrackedFiles": false,
"commit": false,
"commitMessage": "Release ${version}",
"commitArgs": "",
"tag": true,
"tagName": "${version}",
"tagAnnotation": "Release ${version}",
"tagArgs": "",
"push": true,
"pushRepo": "marc"
}
}
}
100 changes: 100 additions & 0 deletions src/package-vsix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/**
* 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 archiver = require('archiver');
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 3f85b75

Please sign in to comment.