Skip to content

Commit 5708dcc

Browse files
committed
Improve ports
1 parent 4e75e18 commit 5708dcc

Some content is hidden

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

56 files changed

+1790
-19066
lines changed

.vscode/launch.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"version": "0.1.0",
33
"configurations": [
44
{
5-
"name": "Launch Built-in Extension",
5+
"name": "Launch gitpod-web",
66
"type": "extensionHost",
77
"request": "launch",
88
"runtimeExecutable": "${execPath}",
@@ -16,6 +16,21 @@
1616
"${workspaceRoot}/extensions/gitpod-web/out/**/*.js",
1717
]
1818
},
19+
{
20+
"name": "Launch gitpod-remote",
21+
"type": "extensionHost",
22+
"request": "launch",
23+
"runtimeExecutable": "${execPath}",
24+
"args": [
25+
"${workspaceFolder}",
26+
"--extensionDevelopmentPath=${workspaceRoot}/extensions/gitpod-remote",
27+
"--log=debug"
28+
],
29+
"outFiles": [
30+
"${workspaceRoot}/extensions/gitpod-shared/out/**/*.js",
31+
"${workspaceRoot}/extensions/gitpod-remote/out/**/*.js",
32+
]
33+
},
1934
{
2035
"type": "node",
2136
"request": "launch",

build/gulpfile.gitpod.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ const packageMarketplaceExtensions = task.define('package-gitpod-marketplace-ext
6666
}))
6767
));
6868
gulp.task(packageMarketplaceExtensions);
69+
const bundlePortsWebview = task.define('bundle-remote-ports-webview', async () => {
70+
await promisify(cp.exec)(`yarn --cwd ${path.join(extensionsPath, 'gitpod-remote')} run build:webview`, { encoding: 'utf8' });
71+
gulp.src([`${path.join(extensionsPath, 'gitpod-remote')}/public/**/*`]).pipe(gulp.dest(path.join(outMarketplaceExtensions, 'gitpod-remote/public/')));
72+
});
73+
gulp.task(bundlePortsWebview);
6974
for (const extensionName of marketplaceExtensions) {
7075
const cleanExtension = task.define('gitpod:clean-extension:' + extensionName, util.rimraf(path.join(outMarketplaceExtensions, extensionName)));
7176
const bumpExtension = task.define('gitpod:bump-extension:' + extensionName, async () => {
@@ -96,6 +101,7 @@ for (const extensionName of marketplaceExtensions) {
96101
gulp.task(publishExtension);
97102
const packageExtension = task.define('gitpod:package-extension:' + extensionName, task.series(
98103
bundleExtension,
104+
bundlePortsWebview,
99105
() => vsce.createVSIX({
100106
cwd: path.join(outMarketplaceExtensions, extensionName)
101107
})

extensions/gitpod-remote/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public/

extensions/gitpod-remote/package.json

Lines changed: 114 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "%displayName%",
44
"description": "%description%",
55
"publisher": "gitpod",
6-
"version": "0.0.35",
6+
"version": "0.0.36",
77
"license": "MIT",
88
"preview": true,
99
"icon": "resources/gitpod.png",
@@ -28,10 +28,10 @@
2828
"workspace"
2929
],
3030
"capabilities": {
31-
"untrustedWorkspaces": {
32-
"supported": true
33-
}
34-
},
31+
"untrustedWorkspaces": {
32+
"supported": true
33+
}
34+
},
3535
"activationEvents": [
3636
"*"
3737
],
@@ -109,19 +109,74 @@
109109
"enablement": "gitpod.inWorkspace == true && gitpod.workspaceOwned == true && gitpod.workspaceShared == true"
110110
},
111111
{
112-
"command": "gitpod.openInStable",
113-
"title": "%openInStable%",
114-
"enablement": "gitpod.inWorkspace == true && gitpod.UIKind == 'web'"
112+
"command": "gitpod.openInBrowser",
113+
"title": "%openInBrowser%",
114+
"enablement": "gitpod.inWorkspace == true && gitpod.UIKind == 'desktop'"
115115
},
116116
{
117-
"command": "gitpod.openInInsiders",
118-
"title": "%openInInsiders%",
119-
"enablement": "gitpod.inWorkspace == true && gitpod.UIKind == 'web'"
117+
"command": "gitpod.ports.openBrowser",
118+
"title": "%openBrowser%",
119+
"icon": "$(globe)"
120120
},
121121
{
122-
"command": "gitpod.openInBrowser",
123-
"title": "%openInBrowser%",
124-
"enablement": "gitpod.inWorkspace == true && gitpod.UIKind == 'desktop'"
122+
"command": "gitpod.ports.retryAutoExpose",
123+
"title": "%retryAutoExpose%",
124+
"icon": "$(refresh)"
125+
},
126+
{
127+
"command": "gitpod.ports.preview",
128+
"title": "%openPreview%",
129+
"icon": "$(open-preview)"
130+
},
131+
{
132+
"command": "gitpod.ports.makePrivate",
133+
"title": "%makePrivate%",
134+
"icon": "$(unlock)"
135+
},
136+
{
137+
"command": "gitpod.ports.makePublic",
138+
"title": "%makePublic%",
139+
"icon": "$(lock)"
140+
},
141+
{
142+
"command": "gitpod.ports.tunnelNetwork",
143+
"title": "%tunnelNetwork%",
144+
"icon": "$(eye)"
145+
},
146+
{
147+
"command": "gitpod.ports.tunnelHost",
148+
"title": "%tunnelHost%",
149+
"icon": "$(eye-closed)"
150+
}
151+
],
152+
"commandPalette": [
153+
{
154+
"command": "gitpod.ports.preview",
155+
"when": "false"
156+
},
157+
{
158+
"command": "gitpod.ports.openBrowser",
159+
"when": "false"
160+
},
161+
{
162+
"command": "gitpod.ports.retryAutoExpose",
163+
"when": "false"
164+
},
165+
{
166+
"command": "gitpod.ports.makePublic",
167+
"when": "false"
168+
},
169+
{
170+
"command": "gitpod.ports.makePrivate",
171+
"when": "false"
172+
},
173+
{
174+
"command": "gitpod.ports.tunnelNetwork",
175+
"when": "false"
176+
},
177+
{
178+
"command": "gitpod.ports.tunnelHost",
179+
"when": "false"
125180
}
126181
],
127182
"menus": {
@@ -196,32 +251,65 @@
196251
"group": "remote_00_gitpod_navigation@130",
197252
"when": "gitpod.inWorkspace == true && gitpod.workspaceOwned == true && gitpod.workspaceShared == true"
198253
},
199-
{
200-
"command": "gitpod.openInStable",
201-
"group": "remote_00_gitpod_navigation@900",
202-
"when": "gitpod.inWorkspace == true && gitpod.UIKind == 'web'"
203-
},
204-
{
205-
"command": "gitpod.openInInsiders",
206-
"group": "remote_00_gitpod_navigation@1000",
207-
"when": "gitpod.inWorkspace == true && gitpod.UIKind == 'web'"
208-
},
209254
{
210255
"command": "gitpod.openInBrowser",
211256
"group": "remote_00_gitpod_navigation@1000",
212257
"when": "gitpod.inWorkspace == true && gitpod.UIKind == 'desktop'"
213258
}
214259
]
260+
},
261+
"views": {
262+
"portsView": [
263+
{
264+
"id": "gitpod.portsView",
265+
"name": "",
266+
"type": "webview",
267+
"contextualTitle": "",
268+
"icon": "$(plug)"
269+
}
270+
]
271+
},
272+
"viewsContainers": {
273+
"panel": [
274+
{
275+
"id": "portsView",
276+
"title": "Exposed Ports",
277+
"icon": "$(plug)"
278+
}
279+
]
215280
}
216281
},
217282
"scripts": {
218-
"vscode:prepublish": "yarn run compile --cwd .."
283+
"vscode:prepublish": "yarn build:webview; yarn compile",
284+
"compile": "tsc -b",
285+
"watch": "tsc -b -w",
286+
"build:webview": "rollup -c",
287+
"watch:webview": "rollup -c -w",
288+
"start:webview": "sirv public --no-clear"
219289
},
220290
"devDependencies": {
221-
"@types/node": "16.x"
291+
"@types/node": "16.x",
292+
"@tsconfig/svelte": "^2.0.0",
293+
"@types/vscode-webview": "^1.57.0",
294+
"svelte": "^3.0.0",
295+
"svelte-check": "^2.0.0",
296+
"rollup": "^2.3.4",
297+
"rollup-plugin-copy": "^3.4.0",
298+
"rollup-plugin-css-only": "^3.1.0",
299+
"rollup-plugin-livereload": "^2.0.0",
300+
"rollup-plugin-svelte": "^7.0.0",
301+
"rollup-plugin-terser": "^7.0.0",
302+
"@rollup/plugin-commonjs": "^17.0.0",
303+
"@rollup/plugin-json": "^4.1.0",
304+
"@rollup/plugin-node-resolve": "^11.0.0",
305+
"@rollup/plugin-typescript": "^8.0.0",
306+
"@rollup/plugin-alias": "^3.1.9",
307+
"svelte-preprocess": "^4.0.0",
308+
"sirv-cli": "^2.0.0"
222309
},
223310
"dependencies": {
224311
"gitpod-shared": "0.0.1",
312+
"jsonc-parser": "^3.2.0",
225313
"vscode-nls": "^5.0.0"
226314
}
227315
}

extensions/gitpod-remote/package.nls.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,13 @@
1717
"stopSharingWorkspace": "Gitpod: Stop Sharing Running Workspace",
1818
"openInStable": "Gitpod: Open in VS Code",
1919
"openInInsiders": "Gitpod: Open in VS Code Insiders",
20-
"openInBrowser": "Gitpod: Open in Browser"
20+
"openInBrowser": "Gitpod: Open in Browser",
21+
"makePrivate": "Make Private",
22+
"makePublic": "Make Public",
23+
"copyWebLink": "Copy web link",
24+
"tunnelNetwork": "Tunnel on all interfaces",
25+
"tunnelHost": "Tunnel on localhost",
26+
"retryAutoExpose": "Retry to expose",
27+
"openWebLinkInBrowser": "Open web link in Browser",
28+
"showReleaseNotes": "Gitpod: Show Release Notes"
2129
}

extensions/gitpod-web/portsview/rollup.config.js renamed to extensions/gitpod-remote/rollup.config.js

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ import livereload from 'rollup-plugin-livereload';
55
import { terser } from 'rollup-plugin-terser';
66
import sveltePreprocess from 'svelte-preprocess';
77
import typescript from '@rollup/plugin-typescript';
8+
import alias from '@rollup/plugin-alias';
89
import css from 'rollup-plugin-css-only';
910
import path from 'path';
1011
import copy from 'rollup-plugin-copy';
1112
import json from '@rollup/plugin-json';
1213

13-
// copy before packet
14-
import './rollup.copy';
15-
1614
const production = !process.env.ROLLUP_WATCH;
1715

1816
function serve() {
@@ -37,33 +35,42 @@ function serve() {
3735
}
3836

3937
export default {
40-
input: path.join(__dirname, 'src/main.ts'),
38+
input: path.join(__dirname, '../gitpod-shared/portsview/src/main.ts'),
4139
output: [
4240
{
43-
sourcemap: true,
44-
format: 'iife',
45-
name: 'app',
46-
file: path.join(__dirname, 'public/bundle.js'),
41+
sourcemap: !production,
42+
format: 'es',
43+
file: path.join(__dirname, './public/portsview.js'),
4744
},
4845
],
4946
plugins: [
47+
alias({
48+
entries: [
49+
{ find: 'package.nls.json', replacement: path.join(__dirname, 'package.nls.json') },
50+
]
51+
}),
5052
svelte({
51-
preprocess: sveltePreprocess({ sourceMap: !production }),
53+
preprocess: sveltePreprocess({
54+
typescript: {
55+
tsconfigFile: '../gitpod-shared/portsview/tsconfig.json'
56+
},
57+
sourceMap: !production
58+
}),
5259
compilerOptions: {
5360
// enable run-time checks when not in production
5461
dev: !production
5562
}
5663
}),
5764
copy({
5865
targets: [
59-
{ src: 'node_modules/@vscode/codicons/dist/codicon.ttf', dest: 'public' },
60-
// { src: '../package.nls.json', dest: 'public' },
66+
{ src: 'node_modules/@vscode/codicons/dist/codicon.css', dest: 'public' },
67+
{ src: 'node_modules/@vscode/codicons/dist/codicon.ttf', dest: 'public' }
6168
],
6269
}),
63-
json(),
70+
json({ compact: true }),
6471
// we'll extract any component CSS out into
6572
// a separate file - better for performance
66-
css({ output: 'bundle.css' }),
73+
css({ output: 'portsview.css' }),
6774

6875
// If you have external dependencies installed from
6976
// npm, you'll most likely need these plugins. In
@@ -77,12 +84,13 @@ export default {
7784
commonjs(),
7885
typescript({
7986
sourceMap: !production,
80-
inlineSources: !production
87+
inlineSources: !production,
88+
tsconfig: '../gitpod-shared/portsview/tsconfig.json'
8189
}),
8290

8391
// In dev mode, call `npm run start` once
8492
// the bundle has been generated
85-
!production && serve(),
93+
// !production && serve(),
8694

8795
// Watch the `public` directory and refresh the
8896
// browser on changes when not in production

extensions/gitpod-remote/src/extension.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import { GitpodExtensionContext, registerTasks, setupGitpodContext, registerIpcHookCli } from 'gitpod-shared';
88
import * as path from 'path';
99
import * as vscode from 'vscode';
10+
import { configureMachineSettings } from './machineSettings';
11+
import { observePortsStatus, registerPortCommands, tunnelPorts } from './ports';
12+
import { GitpodPortViewProvider } from './portViewProvider';
1013
import { initializeRemoteExtensions, installInitialExtensions, ISyncExtension } from './remoteExtensionInit';
1114

1215
let gitpodContext: GitpodExtensionContext | undefined;
@@ -19,6 +22,22 @@ export async function activate(context: vscode.ExtensionContext) {
1922
registerTasks(gitpodContext);
2023
installInitialExtensions(gitpodContext);
2124

25+
registerPortCommands(gitpodContext);
26+
const portViewProvider = new GitpodPortViewProvider(gitpodContext);
27+
context.subscriptions.push(vscode.window.registerWebviewViewProvider(GitpodPortViewProvider.viewType, portViewProvider, { webviewOptions: { retainContextWhenHidden: true } }));
28+
29+
const [onPortUpdate, disposePortObserve] = observePortsStatus(gitpodContext!);
30+
context.subscriptions.push(disposePortObserve);
31+
let initial = true;
32+
context.subscriptions.push(onPortUpdate.event(portList => {
33+
const promise = configureMachineSettings(gitpodContext!, portList);
34+
if (initial) {
35+
initial = false;
36+
promise.then(() => tunnelPorts(portList));
37+
}
38+
portViewProvider.updatePortsStatus(portList);
39+
}));
40+
2241
// We are moving the heartbeat to gitpod-desktop extension,
2342
// so we register a command to cancel the heartbeat on the gitpod-remote extension
2443
// and then gitpod-desktop will take care of it.

0 commit comments

Comments
 (0)