Skip to content

Commit 126b2f5

Browse files
committed
gitpod server initial commit
1 parent 9001270 commit 126b2f5

File tree

101 files changed

+7924
-155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+7924
-155
lines changed

.eslintrc.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,21 @@
801801
"**/vs/workbench/workbench.web.api"
802802
]
803803
},
804+
{
805+
"target": "**/vs/gitpod/browser/**",
806+
"restrictions": [
807+
"vs/nls",
808+
"vs/css!./**/*",
809+
"**/vs/base/**/{common,browser}/**",
810+
"**/vs/base/parts/**/{common,browser}/**",
811+
"**/vs/platform/**/{common,browser}/**",
812+
"**/vs/code/**/{common,browser}/**",
813+
"**/vs/workbench/workbench.web.api",
814+
"@gitpod/gitpod-protocol/lib/**",
815+
"@improbable-eng/grpc-web",
816+
"@gitpod/local-app-api-grpcweb"
817+
]
818+
},
804819
{
805820
"target": "**/vs/code/node/**",
806821
"restrictions": [
@@ -907,6 +922,14 @@
907922
"**/vs/workbench/workbench.sandbox.main"
908923
]
909924
},
925+
{
926+
"target": "**/extensions/gitpod-web/**",
927+
"restrictions": "!@gitpod/supervisor-api-grpc/**"
928+
},
929+
{
930+
"target": "**/extensions/gitpod-remote-ssh/**",
931+
"restrictions": "!@gitpod/supervisor-api-grpc/**"
932+
},
910933
{
911934
"target": "**/extensions/**",
912935
"restrictions": "**/*"

.gitpod.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ tasks:
88
export VSCODE_INIT_BUILD_DIR=$(leeway describe "//:init" -t "/tmp/build/{{ .Metadata.Name }}.{{ .Metadata.Version }}")
99
leeway build
1010
sudo cp -rup "$VSCODE_INIT_BUILD_DIR/install/." . | true
11+
yarn gitpod:link
1112
command: |
1213
gp sync-done init
1314
export NODE_ENV=development
@@ -18,7 +19,13 @@ tasks:
1819
export NODE_ENV=development
1920
export VSCODE_DEV=1
2021
gp sync-await init
21-
node out/server.js
22+
yarn gitpod:watch
23+
name: watch extension
24+
- command: |
25+
export NODE_ENV=development
26+
export VSCODE_DEV=1
27+
gp sync-await init
28+
node out/gitpod.js
2229
name: run app
2330
openMode: split-right
2431
github:

.vscode/launch.json

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
{
22
"version": "0.1.0",
33
"configurations": [
4+
{
5+
"type": "node",
6+
"request": "launch",
7+
"name": "Gitpod Code Server",
8+
"args": [
9+
"${workspaceFolder}/out/gitpod.js"
10+
],
11+
"outFiles": [
12+
"${workspaceFolder}/out/**/*.js"
13+
],
14+
"env": {
15+
"NODE_ENV": "development",
16+
"VSCODE_DEV": "1"
17+
}
18+
},
419
{
520
"type": "node",
621
"request": "launch",
@@ -473,7 +488,14 @@
473488
"request": "launch",
474489
"runtimeExecutable": "${execPath}",
475490
"args": [
476-
"--extensionDevelopmentPath=${workspaceRoot}/extensions/debug-auto-launch"
491+
"/workspace/vscode",
492+
"--extensionDevelopmentPath=${workspaceRoot}/extensions/gitpod",
493+
"--extensionDevelopmentPath=${workspaceRoot}/extensions/gitpod-remote-ssh",
494+
"--log=debug"
495+
],
496+
"outFiles": [
497+
"${workspaceRoot}/extensions/gitpod/out/**/*.js",
498+
"${workspaceRoot}/extensions/gitpod-remote-ssh/out/**/*.js",
477499
]
478500
}
479501
],

BUILD.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ packages:
1313
config:
1414
commands:
1515
- ["yarn", "--cwd", "./install/build", "compile"]
16+
- ["yarn", "--cwd", "./install", "gitpod:link"]
1617
- ["yarn", "--cwd", "./install", "compile"]
1718
- ["yarn", "--cwd", "./install", "download-builtin-extensions"]

build/.webignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,12 @@ xterm-addon-webgl/out/**
3232

3333
# This makes sure the model is included in the package
3434
!@vscode/vscode-languagedetection/model/**
35+
36+
@improbable-eng/**
37+
!@improbable-eng/grpc-web/dist/grpc-web-client.umd.js
38+
39+
@gitpod/**
40+
!@gitpod/local-app-api-grpcweb/lib/localapp.js
41+
42+
browser-headers/**
43+
google-protobuf/**
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
'use strict';
6+
Object.defineProperty(exports, "__esModule", { value: true });
7+
const url = require("url");
8+
const azure = require("azure-storage");
9+
const mime = require("mime");
10+
const cosmos_1 = require("@azure/cosmos");
11+
const retry_1 = require("./retry");
12+
function log(...args) {
13+
console.log(...[`[${new Date().toISOString()}]`, ...args]);
14+
}
15+
function error(...args) {
16+
console.error(...[`[${new Date().toISOString()}]`, ...args]);
17+
}
18+
if (process.argv.length < 3) {
19+
error('Usage: node sync-mooncake.js <quality>');
20+
process.exit(-1);
21+
}
22+
async function sync(commit, quality) {
23+
log(`Synchronizing Mooncake assets for ${quality}, ${commit}...`);
24+
const client = new cosmos_1.CosmosClient({ endpoint: process.env['AZURE_DOCUMENTDB_ENDPOINT'], key: process.env['AZURE_DOCUMENTDB_MASTERKEY'] });
25+
const container = client.database('builds').container(quality);
26+
const query = `SELECT TOP 1 * FROM c WHERE c.id = "${commit}"`;
27+
const res = await container.items.query(query, {}).fetchAll();
28+
if (res.resources.length !== 1) {
29+
throw new Error(`No builds found for ${commit}`);
30+
}
31+
const build = res.resources[0];
32+
log(`Found build for ${commit}, with ${build.assets.length} assets`);
33+
const storageAccount = process.env['AZURE_STORAGE_ACCOUNT_2'];
34+
const blobService = azure.createBlobService(storageAccount, process.env['AZURE_STORAGE_ACCESS_KEY_2'])
35+
.withFilter(new azure.ExponentialRetryPolicyFilter(20));
36+
const mooncakeBlobService = azure.createBlobService(storageAccount, process.env['MOONCAKE_STORAGE_ACCESS_KEY'], `${storageAccount}.blob.core.chinacloudapi.cn`)
37+
.withFilter(new azure.ExponentialRetryPolicyFilter(20));
38+
// mooncake is fussy and far away, this is needed!
39+
blobService.defaultClientRequestTimeoutInMs = 10 * 60 * 1000;
40+
mooncakeBlobService.defaultClientRequestTimeoutInMs = 10 * 60 * 1000;
41+
for (const asset of build.assets) {
42+
try {
43+
const blobPath = url.parse(asset.url).path;
44+
if (!blobPath) {
45+
throw new Error(`Failed to parse URL: ${asset.url}`);
46+
}
47+
const blobName = blobPath.replace(/^\/\w+\//, '');
48+
log(`Found ${blobName}`);
49+
if (asset.mooncakeUrl) {
50+
log(` Already in Mooncake ✔️`);
51+
continue;
52+
}
53+
const readStream = blobService.createReadStream(quality, blobName, undefined);
54+
const blobOptions = {
55+
contentSettings: {
56+
contentType: mime.lookup(blobPath),
57+
cacheControl: 'max-age=31536000, public'
58+
}
59+
};
60+
const writeStream = mooncakeBlobService.createWriteStreamToBlockBlob(quality, blobName, blobOptions, undefined);
61+
log(` Uploading to Mooncake...`);
62+
await new Promise((c, e) => readStream.pipe(writeStream).on('finish', c).on('error', e));
63+
log(` Updating build in DB...`);
64+
const mooncakeUrl = `${process.env['MOONCAKE_CDN_URL']}${blobPath}`;
65+
await (0, retry_1.retry)(() => container.scripts.storedProcedure('setAssetMooncakeUrl')
66+
.execute('', [commit, asset.platform, asset.type, mooncakeUrl]));
67+
log(` Done ✔️`);
68+
}
69+
catch (err) {
70+
error(err);
71+
}
72+
}
73+
log(`All done ✔️`);
74+
}
75+
function main() {
76+
const commit = process.env['BUILD_SOURCEVERSION'];
77+
if (!commit) {
78+
error('Skipping publish due to missing BUILD_SOURCEVERSION');
79+
return;
80+
}
81+
const quality = process.argv[2];
82+
sync(commit, quality).catch(err => {
83+
error(err);
84+
process.exit(1);
85+
});
86+
}
87+
main();

build/gulpfile.extensions.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const compilations = [
3838
'emmet/tsconfig.json',
3939
'extension-editing/tsconfig.json',
4040
'git/tsconfig.json',
41-
'github-authentication/tsconfig.json',
41+
// 'github-authentication/tsconfig.json',
4242
'github/tsconfig.json',
4343
'grunt/tsconfig.json',
4444
'gulp/tsconfig.json',
@@ -64,7 +64,11 @@ const compilations = [
6464
'vscode-colorize-tests/tsconfig.json',
6565
'vscode-custom-editor-tests/tsconfig.json',
6666
'vscode-notebook-tests/tsconfig.json',
67-
'vscode-test-resolver/tsconfig.json'
67+
'vscode-test-resolver/tsconfig.json',
68+
'gitpod/tsconfig.json',
69+
'gitpod-remote-ssh/tsconfig.json',
70+
'gitpod-web/tsconfig.json',
71+
'gitpod-ui/tsconfig.json',
6872
];
6973

7074
const getBaseUrl = out => `https://ticino.blob.core.windows.net/sourcemaps/${commit}/${out}`;

build/gulpfile.gitpod.js

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*!--------------------------------------------------------
2+
* Copyright (C) Gitpod. All rights reserved.
3+
*--------------------------------------------------------*/
4+
5+
// @ts-check
6+
'use strict';
7+
8+
require('./gulpfile.server').defineTasks({
9+
qualifier: 'gitpod',
10+
header: [
11+
'/*!--------------------------------------------------------',
12+
' * Copyright (C) Gitpod. All rights reserved.',
13+
' *--------------------------------------------------------*/'
14+
].join('\n')
15+
});
16+
17+
const promisify = require('util').promisify;
18+
const cp = require('child_process');
19+
const argv = require('yargs').argv;
20+
const vsce = require('vsce');
21+
const gulp = require('gulp');
22+
const path = require('path');
23+
const es = require('event-stream');
24+
const util = require('./lib/util');
25+
const task = require('./lib/task');
26+
const rename = require('gulp-rename');
27+
const ext = require('./lib/extensions');
28+
29+
const extensionsPath = path.join(path.dirname(__dirname), 'extensions');
30+
const marketplaceExtensions = ['gitpod', 'gitpod-ui', 'gitpod-remote-ssh'];
31+
const outMarketplaceExtensions = 'out-gitpod-marketplace';
32+
const cleanMarketplaceExtensions = task.define('clean-gitpod-marketplace-extensions', util.rimraf(outMarketplaceExtensions));
33+
const bumpMarketplaceExtensions = task.define('bump-marketplace-extensions', () => {
34+
if ('new-version' in argv && argv['new-version']) {
35+
const newVersion = argv['new-version'];
36+
console.log(newVersion);
37+
return Promise.allSettled(marketplaceExtensions.map(async extensionName => {
38+
const { stderr } = await promisify(cp.exec)(`yarn version --new-version ${newVersion} --cwd ${path.join(extensionsPath, extensionName)} --no-git-tag-version`, { encoding: 'utf8' });
39+
if (stderr) {
40+
throw new Error('failed to bump up version: ' + stderr);
41+
}
42+
}));
43+
}
44+
});
45+
const bundleMarketplaceExtensions = task.define('bundle-gitpod-marketplace-extensions', task.series(
46+
cleanMarketplaceExtensions,
47+
bumpMarketplaceExtensions,
48+
() =>
49+
ext.minifyExtensionResources(
50+
es.merge(
51+
...marketplaceExtensions.map(extensionName =>
52+
ext.fromLocal(path.join(extensionsPath, extensionName), false)
53+
.pipe(rename(p => p.dirname = `${extensionName}/${p.dirname}`))
54+
)
55+
)
56+
).pipe(gulp.dest(outMarketplaceExtensions))
57+
));
58+
gulp.task(bundleMarketplaceExtensions);
59+
const publishMarketplaceExtensions = task.define('publish-gitpod-marketplace-extensions', task.series(
60+
bundleMarketplaceExtensions,
61+
() => Promise.allSettled(marketplaceExtensions.map(extensionName => {
62+
vsce.publish({
63+
cwd: path.join(outMarketplaceExtensions, extensionName)
64+
});
65+
}))
66+
));
67+
gulp.task(publishMarketplaceExtensions);
68+
const packageMarketplaceExtensions = task.define('package-gitpod-marketplace-extensions', task.series(
69+
bundleMarketplaceExtensions,
70+
() => Promise.allSettled(marketplaceExtensions.map(extensionName => {
71+
vsce.createVSIX({
72+
cwd: path.join(outMarketplaceExtensions, extensionName)
73+
});
74+
}))
75+
));
76+
gulp.task(packageMarketplaceExtensions);
77+
for (const extensionName of marketplaceExtensions) {
78+
const cleanExtension = task.define('gitpod:clean-extension:' + extensionName, util.rimraf(path.join(outMarketplaceExtensions, extensionName)));
79+
const bumpExtension = task.define('gitpod:bump-extension:' + extensionName, async () => {
80+
if ('new-version' in argv && argv['new-version']) {
81+
const newVersion = argv['new-version'];
82+
const { stderr } = await promisify(cp.exec)(`yarn version --new-version ${newVersion} --cwd ${path.join(extensionsPath, extensionName)} --no-git-tag-version`, { encoding: 'utf8' });
83+
if (stderr) {
84+
throw new Error('failed to bump up version: ' + stderr);
85+
}
86+
}
87+
});
88+
const bundleExtension = task.define('gitpod:bundle-extension:' + extensionName, task.series(
89+
cleanExtension,
90+
bumpExtension,
91+
() =>
92+
ext.minifyExtensionResources(
93+
ext.fromLocal(path.join(extensionsPath, extensionName), false)
94+
.pipe(rename(p => p.dirname = `${extensionName}/${p.dirname}`))
95+
).pipe(gulp.dest(outMarketplaceExtensions))
96+
));
97+
gulp.task(bundleExtension);
98+
const publishExtension = task.define('gitpod:publish-extension:' + extensionName, task.series(
99+
bundleExtension,
100+
() => vsce.publish({
101+
cwd: path.join(outMarketplaceExtensions, extensionName)
102+
})
103+
));
104+
gulp.task(publishExtension);
105+
const packageExtension = task.define('gitpod:package-extension:' + extensionName, task.series(
106+
bundleExtension,
107+
() => vsce.createVSIX({
108+
cwd: path.join(outMarketplaceExtensions, extensionName)
109+
})
110+
));
111+
gulp.task(packageExtension);
112+
}

build/lib/extensions.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Licensed under the MIT License. See License.txt in the project root for license information.
55
*--------------------------------------------------------------------------------------------*/
66
Object.defineProperty(exports, "__esModule", { value: true });
7-
exports.buildExtensionMedia = exports.webpackExtensions = exports.translatePackageJSON = exports.scanBuiltinExtensions = exports.packageMarketplaceExtensionsStream = exports.packageLocalExtensionsStream = exports.fromMarketplace = void 0;
7+
exports.buildExtensionMedia = exports.webpackExtensions = exports.translatePackageJSON = exports.scanBuiltinExtensions = exports.packageMarketplaceExtensionsStream = exports.packageLocalExtensionsStream = exports.fromMarketplace = exports.fromLocal = exports.minifyExtensionResources = void 0;
88
const es = require("event-stream");
99
const fs = require("fs");
1010
const cp = require("child_process");
@@ -41,6 +41,7 @@ function minifyExtensionResources(input) {
4141
}))
4242
.pipe(jsonFilter.restore);
4343
}
44+
exports.minifyExtensionResources = minifyExtensionResources;
4445
function updateExtensionPackageJSON(input, update) {
4546
const packageJsonFilter = filter('extensions/*/package.json', { restore: true });
4647
return input
@@ -72,6 +73,7 @@ function fromLocal(extensionPath, forWeb) {
7273
}
7374
return input;
7475
}
76+
exports.fromLocal = fromLocal;
7577
function fromLocalWebpack(extensionPath, webpackConfigFileName) {
7678
const result = es.through();
7779
const packagedDependencies = [];
@@ -201,6 +203,9 @@ const excludedExtensions = [
201203
'ms-vscode.node-debug2',
202204
'vscode-notebook-tests',
203205
'vscode-custom-editor-tests',
206+
'github-authentication',
207+
'gitpod-remote-ssh',
208+
'gitpod-ui',
204209
];
205210
const marketplaceWebExtensionsExclude = new Set([
206211
'ms-vscode.node-debug',

0 commit comments

Comments
 (0)