Skip to content

Commit

Permalink
gitpod server initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
akosyakov authored and jeanp413 committed Sep 17, 2021
1 parent ee21403 commit d161128
Show file tree
Hide file tree
Showing 98 changed files with 7,888 additions and 97 deletions.
23 changes: 23 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,21 @@
"**/vs/workbench/workbench.web.api"
]
},
{
"target": "**/vs/gitpod/browser/**",
"restrictions": [
"vs/nls",
"vs/css!./**/*",
"**/vs/base/**/{common,browser}/**",
"**/vs/base/parts/**/{common,browser}/**",
"**/vs/platform/**/{common,browser}/**",
"**/vs/code/**/{common,browser}/**",
"**/vs/workbench/workbench.web.api",
"@gitpod/gitpod-protocol/lib/**",
"@improbable-eng/grpc-web",
"@gitpod/local-app-api-grpcweb"
]
},
{
"target": "**/vs/code/node/**",
"restrictions": [
Expand Down Expand Up @@ -908,6 +923,14 @@
"**/vs/workbench/workbench.sandbox.main"
]
},
{
"target": "**/extensions/gitpod-web/**",
"restrictions": "!@gitpod/supervisor-api-grpc/**"
},
{
"target": "**/extensions/gitpod-remote-ssh/**",
"restrictions": "!@gitpod/supervisor-api-grpc/**"
},
{
"target": "**/extensions/**",
"restrictions": "**/*"
Expand Down
8 changes: 7 additions & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ tasks:
export NODE_ENV=development
export VSCODE_DEV=1
gp sync-await init
node out/server.js
yarn gitpod:watch
name: watch extension
- command: |
export NODE_ENV=development
export VSCODE_DEV=1
gp sync-await init
node out/gitpod.js
name: run app
openMode: split-right
github:
Expand Down
24 changes: 23 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
{
"version": "0.1.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Gitpod Code Server",
"args": [
"${workspaceFolder}/out/gitpod.js"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"env": {
"NODE_ENV": "development",
"VSCODE_DEV": "1"
}
},
{
"type": "node",
"request": "launch",
Expand Down Expand Up @@ -479,7 +494,14 @@
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}/extensions/debug-auto-launch"
"/workspace/vscode",
"--extensionDevelopmentPath=${workspaceRoot}/extensions/gitpod",
"--extensionDevelopmentPath=${workspaceRoot}/extensions/gitpod-remote-ssh",
"--log=debug"
],
"outFiles": [
"${workspaceRoot}/extensions/gitpod/out/**/*.js",
"${workspaceRoot}/extensions/gitpod-remote-ssh/out/**/*.js",
]
}
],
Expand Down
18 changes: 18 additions & 0 deletions BUILD.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
packages:
- name: install
type: generic
srcs:
- "**"
config:
commands:
- ["yarn"]
- name: init
type: generic
deps:
- ":install"
config:
commands:
- ["yarn", "--cwd", "./install/build", "compile"]
- ["yarn", "--cwd", "./install", "gitpod:link"]
- ["yarn", "--cwd", "./install", "compile"]
- ["yarn", "--cwd", "./install", "download-builtin-extensions"]
9 changes: 9 additions & 0 deletions build/.webignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,12 @@ xterm-addon-webgl/out/**

# This makes sure the model is included in the package
!@vscode/vscode-languagedetection/model/**

@improbable-eng/**
!@improbable-eng/grpc-web/dist/grpc-web-client.umd.js

@gitpod/**
!@gitpod/local-app-api-grpcweb/lib/localapp.js

browser-headers/**
google-protobuf/**
87 changes: 87 additions & 0 deletions build/azure-pipelines/common/sync-mooncake.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
const url = require("url");
const azure = require("azure-storage");
const mime = require("mime");
const cosmos_1 = require("@azure/cosmos");
const retry_1 = require("./retry");
function log(...args) {
console.log(...[`[${new Date().toISOString()}]`, ...args]);
}
function error(...args) {
console.error(...[`[${new Date().toISOString()}]`, ...args]);
}
if (process.argv.length < 3) {
error('Usage: node sync-mooncake.js <quality>');
process.exit(-1);
}
async function sync(commit, quality) {
log(`Synchronizing Mooncake assets for ${quality}, ${commit}...`);
const client = new cosmos_1.CosmosClient({ endpoint: process.env['AZURE_DOCUMENTDB_ENDPOINT'], key: process.env['AZURE_DOCUMENTDB_MASTERKEY'] });
const container = client.database('builds').container(quality);
const query = `SELECT TOP 1 * FROM c WHERE c.id = "${commit}"`;
const res = await container.items.query(query, {}).fetchAll();
if (res.resources.length !== 1) {
throw new Error(`No builds found for ${commit}`);
}
const build = res.resources[0];
log(`Found build for ${commit}, with ${build.assets.length} assets`);
const storageAccount = process.env['AZURE_STORAGE_ACCOUNT_2'];
const blobService = azure.createBlobService(storageAccount, process.env['AZURE_STORAGE_ACCESS_KEY_2'])
.withFilter(new azure.ExponentialRetryPolicyFilter(20));
const mooncakeBlobService = azure.createBlobService(storageAccount, process.env['MOONCAKE_STORAGE_ACCESS_KEY'], `${storageAccount}.blob.core.chinacloudapi.cn`)
.withFilter(new azure.ExponentialRetryPolicyFilter(20));
// mooncake is fussy and far away, this is needed!
blobService.defaultClientRequestTimeoutInMs = 10 * 60 * 1000;
mooncakeBlobService.defaultClientRequestTimeoutInMs = 10 * 60 * 1000;
for (const asset of build.assets) {
try {
const blobPath = url.parse(asset.url).path;
if (!blobPath) {
throw new Error(`Failed to parse URL: ${asset.url}`);
}
const blobName = blobPath.replace(/^\/\w+\//, '');
log(`Found ${blobName}`);
if (asset.mooncakeUrl) {
log(` Already in Mooncake ✔️`);
continue;
}
const readStream = blobService.createReadStream(quality, blobName, undefined);
const blobOptions = {
contentSettings: {
contentType: mime.lookup(blobPath),
cacheControl: 'max-age=31536000, public'
}
};
const writeStream = mooncakeBlobService.createWriteStreamToBlockBlob(quality, blobName, blobOptions, undefined);
log(` Uploading to Mooncake...`);
await new Promise((c, e) => readStream.pipe(writeStream).on('finish', c).on('error', e));
log(` Updating build in DB...`);
const mooncakeUrl = `${process.env['MOONCAKE_CDN_URL']}${blobPath}`;
await (0, retry_1.retry)(() => container.scripts.storedProcedure('setAssetMooncakeUrl')
.execute('', [commit, asset.platform, asset.type, mooncakeUrl]));
log(` Done ✔️`);
}
catch (err) {
error(err);
}
}
log(`All done ✔️`);
}
function main() {
const commit = process.env['BUILD_SOURCEVERSION'];
if (!commit) {
error('Skipping publish due to missing BUILD_SOURCEVERSION');
return;
}
const quality = process.argv[2];
sync(commit, quality).catch(err => {
error(err);
process.exit(1);
});
}
main();
8 changes: 6 additions & 2 deletions build/gulpfile.extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const compilations = [
'emmet/tsconfig.json',
'extension-editing/tsconfig.json',
'git/tsconfig.json',
'github-authentication/tsconfig.json',
// 'github-authentication/tsconfig.json',
'github/tsconfig.json',
'grunt/tsconfig.json',
'gulp/tsconfig.json',
Expand All @@ -64,7 +64,11 @@ const compilations = [
'vscode-colorize-tests/tsconfig.json',
'vscode-custom-editor-tests/tsconfig.json',
'vscode-notebook-tests/tsconfig.json',
'vscode-test-resolver/tsconfig.json'
'vscode-test-resolver/tsconfig.json',
'gitpod/tsconfig.json',
'gitpod-remote-ssh/tsconfig.json',
'gitpod-web/tsconfig.json',
'gitpod-ui/tsconfig.json',
];

const getBaseUrl = out => `https://ticino.blob.core.windows.net/sourcemaps/${commit}/${out}`;
Expand Down
112 changes: 112 additions & 0 deletions build/gulpfile.gitpod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*!--------------------------------------------------------
* Copyright (C) Gitpod. All rights reserved.
*--------------------------------------------------------*/

// @ts-check
'use strict';

require('./gulpfile.server').defineTasks({
qualifier: 'gitpod',
header: [
'/*!--------------------------------------------------------',
' * Copyright (C) Gitpod. All rights reserved.',
' *--------------------------------------------------------*/'
].join('\n')
});

const promisify = require('util').promisify;
const cp = require('child_process');
const argv = require('yargs').argv;
const vsce = require('vsce');
const gulp = require('gulp');
const path = require('path');
const es = require('event-stream');
const util = require('./lib/util');
const task = require('./lib/task');
const rename = require('gulp-rename');
const ext = require('./lib/extensions');

const extensionsPath = path.join(path.dirname(__dirname), 'extensions');
const marketplaceExtensions = ['gitpod', 'gitpod-ui', 'gitpod-remote-ssh'];
const outMarketplaceExtensions = 'out-gitpod-marketplace';
const cleanMarketplaceExtensions = task.define('clean-gitpod-marketplace-extensions', util.rimraf(outMarketplaceExtensions));
const bumpMarketplaceExtensions = task.define('bump-marketplace-extensions', () => {
if ('new-version' in argv && argv['new-version']) {
const newVersion = argv['new-version'];
console.log(newVersion);
return Promise.allSettled(marketplaceExtensions.map(async extensionName => {
const { stderr } = await promisify(cp.exec)(`yarn version --new-version ${newVersion} --cwd ${path.join(extensionsPath, extensionName)} --no-git-tag-version`, { encoding: 'utf8' });
if (stderr) {
throw new Error('failed to bump up version: ' + stderr);
}
}));
}
});
const bundleMarketplaceExtensions = task.define('bundle-gitpod-marketplace-extensions', task.series(
cleanMarketplaceExtensions,
bumpMarketplaceExtensions,
() =>
ext.minifyExtensionResources(
es.merge(
...marketplaceExtensions.map(extensionName =>
ext.fromLocal(path.join(extensionsPath, extensionName), false)
.pipe(rename(p => p.dirname = `${extensionName}/${p.dirname}`))
)
)
).pipe(gulp.dest(outMarketplaceExtensions))
));
gulp.task(bundleMarketplaceExtensions);
const publishMarketplaceExtensions = task.define('publish-gitpod-marketplace-extensions', task.series(
bundleMarketplaceExtensions,
() => Promise.allSettled(marketplaceExtensions.map(extensionName => {
vsce.publish({
cwd: path.join(outMarketplaceExtensions, extensionName)
});
}))
));
gulp.task(publishMarketplaceExtensions);
const packageMarketplaceExtensions = task.define('package-gitpod-marketplace-extensions', task.series(
bundleMarketplaceExtensions,
() => Promise.allSettled(marketplaceExtensions.map(extensionName => {
vsce.createVSIX({
cwd: path.join(outMarketplaceExtensions, extensionName)
});
}))
));
gulp.task(packageMarketplaceExtensions);
for (const extensionName of marketplaceExtensions) {
const cleanExtension = task.define('gitpod:clean-extension:' + extensionName, util.rimraf(path.join(outMarketplaceExtensions, extensionName)));
const bumpExtension = task.define('gitpod:bump-extension:' + extensionName, async () => {
if ('new-version' in argv && argv['new-version']) {
const newVersion = argv['new-version'];
const { stderr } = await promisify(cp.exec)(`yarn version --new-version ${newVersion} --cwd ${path.join(extensionsPath, extensionName)} --no-git-tag-version`, { encoding: 'utf8' });
if (stderr) {
throw new Error('failed to bump up version: ' + stderr);
}
}
});
const bundleExtension = task.define('gitpod:bundle-extension:' + extensionName, task.series(
cleanExtension,
bumpExtension,
() =>
ext.minifyExtensionResources(
ext.fromLocal(path.join(extensionsPath, extensionName), false)
.pipe(rename(p => p.dirname = `${extensionName}/${p.dirname}`))
).pipe(gulp.dest(outMarketplaceExtensions))
));
gulp.task(bundleExtension);
const publishExtension = task.define('gitpod:publish-extension:' + extensionName, task.series(
bundleExtension,
() => vsce.publish({
cwd: path.join(outMarketplaceExtensions, extensionName)
})
));
gulp.task(publishExtension);
const packageExtension = task.define('gitpod:package-extension:' + extensionName, task.series(
bundleExtension,
() => vsce.createVSIX({
cwd: path.join(outMarketplaceExtensions, extensionName)
})
));
gulp.task(packageExtension);
}
7 changes: 6 additions & 1 deletion build/lib/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildExtensionMedia = exports.webpackExtensions = exports.translatePackageJSON = exports.scanBuiltinExtensions = exports.packageMarketplaceExtensionsStream = exports.packageLocalExtensionsStream = exports.fromMarketplace = void 0;
exports.buildExtensionMedia = exports.webpackExtensions = exports.translatePackageJSON = exports.scanBuiltinExtensions = exports.packageMarketplaceExtensionsStream = exports.packageLocalExtensionsStream = exports.fromMarketplace = exports.fromLocal = exports.minifyExtensionResources = void 0;
const es = require("event-stream");
const fs = require("fs");
const cp = require("child_process");
Expand Down Expand Up @@ -43,6 +43,7 @@ function minifyExtensionResources(input) {
}))
.pipe(jsonFilter.restore);
}
exports.minifyExtensionResources = minifyExtensionResources;
function updateExtensionPackageJSON(input, update) {
const packageJsonFilter = filter('extensions/*/package.json', { restore: true });
return input
Expand Down Expand Up @@ -74,6 +75,7 @@ function fromLocal(extensionPath, forWeb) {
}
return input;
}
exports.fromLocal = fromLocal;
function fromLocalWebpack(extensionPath, webpackConfigFileName) {
const result = es.through();
const packagedDependencies = [];
Expand Down Expand Up @@ -203,6 +205,9 @@ const excludedExtensions = [
'ms-vscode.node-debug2',
'vscode-notebook-tests',
'vscode-custom-editor-tests',
'github-authentication',
'gitpod-remote-ssh',
'gitpod-ui',
];
const marketplaceWebExtensionsExclude = new Set([
'ms-vscode.node-debug',
Expand Down
Loading

0 comments on commit d161128

Please sign in to comment.