Skip to content

Commit adbf0a4

Browse files
committed
browser extension 2.0
1 parent 4b9e68c commit adbf0a4

Some content is hidden

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

52 files changed

+15483
-2285
lines changed

.eslintrc.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"extends": [
7+
"eslint:recommended",
8+
"plugin:@typescript-eslint/recommended",
9+
"plugin:react/recommended"
10+
],
11+
"parser": "@typescript-eslint/parser",
12+
"parserOptions": {
13+
"ecmaVersion": "latest",
14+
"sourceType": "module"
15+
},
16+
"plugins": [
17+
"@typescript-eslint",
18+
"react"
19+
],
20+
"rules": {
21+
}
22+
}

.github/workflows/submit.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "Submit to Web Store"
2+
on:
3+
workflow_dispatch:
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- name: Cache pnpm modules
11+
uses: actions/cache@v3
12+
with:
13+
path: ~/.pnpm-store
14+
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
15+
restore-keys: |
16+
${{ runner.os }}-
17+
- uses: pnpm/[email protected]
18+
with:
19+
version: latest
20+
run_install: true
21+
- name: Use Node.js 16.x
22+
uses: actions/[email protected]
23+
with:
24+
node-version: 16.x
25+
cache: "pnpm"
26+
- name: Build the extension
27+
run: pnpm build
28+
- name: Package the extension into a zip artifact
29+
run: pnpm package
30+
- name: Browser Platform Publish
31+
uses: PlasmoHQ/bpp@v3
32+
with:
33+
keys: ${{ secrets.SUBMIT_KEYS }}
34+
artifact: build/chrome-mv3-prod.zip

.gitignore

+42-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,42 @@
1-
*.log
2-
dist
3-
gitpod.xpi
4-
node_modules
5-
Gitpod
1+
2+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
3+
4+
# dependencies
5+
node_modules/
6+
/.pnp
7+
.pnp.js
8+
9+
# testing
10+
/coverage
11+
12+
#cache
13+
.turbo
14+
15+
# dev tools
16+
.bin
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
.pnpm-debug.log*
27+
28+
# local env files
29+
.env*
30+
31+
out/
32+
build/
33+
dist/
34+
35+
# plasmo - https://www.plasmo.com
36+
.plasmo
37+
38+
# bpp - http://bpp.browser.market/
39+
keys.json
40+
41+
# typescript
42+
.tsbuildinfo

.gitpod.yml

+11-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
image:
22
file: .gitpod.Dockerfile
3+
34
tasks:
4-
- name: Google Chrome
5-
command: >
6-
gp sync-await start &&
7-
gp await-port 6080 &&
8-
for i in `seq 10 -1 1` ; do echo -ne "\rStarting Chrome in $i " && sleep 1 && echo -ne "\r" ; done &&
9-
google-chrome --no-first-run --disable-dev-shm-usage --start-maximized --load-extension=/workspace/browser-extension https://github.com/gitpod-io/template-sveltekit
10-
- name: Webpack Dev Server
11-
init: yarn install && yarn build && yarn package
12-
command: >
13-
gp sync-done start &&
14-
yarn watch
5+
- init: |
6+
pnpm install
7+
pnpm build
8+
pnpm build-dev-tools
9+
pnpm test
10+
command: |
11+
pnpm build
12+
1513
ports:
16-
- name: NoVNC
17-
port: 6080
18-
onOpen: open-preview
19-
- name: Webpack Dev Server
20-
port: 5900
14+
- name: sync
15+
port: 8080
2116
onOpen: ignore

.prettierrc.mjs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* @type {import('prettier').Options}
3+
*/
4+
export default {
5+
printWidth: 80,
6+
tabWidth: 2,
7+
useTabs: false,
8+
semi: false,
9+
singleQuote: false,
10+
trailingComma: "none",
11+
bracketSpacing: true,
12+
bracketSameLine: true,
13+
plugins: ["@ianvs/prettier-plugin-sort-imports"],
14+
importOrder: [
15+
"<BUILTIN_MODULES>", // Node.js built-in modules
16+
"<THIRD_PARTY_MODULES>", // Imports not matched by other special words or groups.
17+
"", // Empty line
18+
"^@plasmo/(.*)$",
19+
"",
20+
"^@plasmohq/(.*)$",
21+
"",
22+
"^~(.*)$",
23+
"",
24+
"^[./]"
25+
]
26+
}

README.md

+15-11
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,34 @@ This is the browser extension for Gitpod. It supports Chrome (see [Chrome Web St
55

66
![Gitpodify](./docs/github-injected.png "Gitpodify")
77

8-
9-
## Contributing
10-
11-
Contributions to this project are welcome!
12-
138
### Issues
149

1510
We are currently tracking all issues related to the browser extension in the [`gitpod-io/gitpod`](https://github.com/gitpod-io/gitpod) repository.
1611
You can use the [`component: browser-extension`](https://github.com/gitpod-io/gitpod/issues?q=is%3Aissue+is%3Aopen+extension+label%3A%22component%3A+browser-extension%22) label to search for relevant issues including feature proposals and bug reports.
1712

1813
### Development
1914

20-
To make changes and test them, the easiest way is using Gitpod itself. The `.gitpod.yml` configuration for this project installs Google Chrome and runs a VNC server to allow users to see the Desktop of the Docker container. When a workspace starts, Google Chrome is started with the Gitpod extension automatically built from source and pre-installed, therefore you can preview your changes in the ephemeral Chrome browser. 🤯
21-
22-
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/gitpod-io/browser-extension)
15+
To make changes and test them using Gitpod itself:
16+
17+
- add test cases to the [unit test](https://github.com/gitpod-io/browser-extension/blob/se/plasmo/test/src/button-contributions.spec.ts#L39)
18+
- try out changes like this:
19+
1. run `pnpm build`
20+
1. run `pnpm watch-prod` and download the built binary for your system (local machine)
21+
1. run the binary aywhere on your local machine tosync the extension folder locally.
22+
1. open Chrome and go to `chrome://extensions/`
23+
1. enable `Developer mode` (top right)
24+
1. click `Load unpacked` (top left) and select the folder you just downloaded
25+
1. now you can test your changes
26+
1. repeat step 1 and 2 and [reload the extension](chrome://extensions/) whenever you want to test new changes
2327

2428
#### Build
2529

2630
The build happens automatically when you start a workspace but if you want to build explicitly, use these commands:
2731

2832
```
29-
yarn install
30-
yarn build
31-
yarn package
33+
pnpm install
34+
pnpm build
35+
pnpm package
3236
```
3337

3438
### Testing
File renamed without changes.

css/gitpodify.css

-58
This file was deleted.

dev/build.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
ROOT=/workspace/browser-extension
4+
cd $ROOT/dev/http-file-sync
5+
6+
echo "building binaries ..."
7+
go build -o $ROOT/.bin/watch-sync
8+
GOARCH=amd64 GOOS=darwin go build -o $ROOT/.bin/watch-sync-osx-x86_64
9+
GOARCH=arm64 GOOS=darwin go build -o $ROOT/.bin/watch-sync-osx-arm64

dev/http-file-sync/go.mod

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module gitpod.io/http-file-sync
2+
3+
go 1.19
4+
5+
require (
6+
github.com/fsnotify/fsnotify v1.6.0
7+
github.com/spf13/cobra v1.7.0
8+
)
9+
10+
require (
11+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
12+
github.com/spf13/pflag v1.0.5 // indirect
13+
golang.org/x/sys v0.12.0 // indirect
14+
)

dev/http-file-sync/go.sum

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
2+
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
3+
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
4+
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
5+
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
6+
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
7+
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
8+
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
9+
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
10+
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
11+
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
12+
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
13+
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
14+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
15+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

dev/http-file-sync/main.go

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/spf13/cobra"
7+
"gitpod.io/http-file-sync/pkg"
8+
)
9+
10+
const (
11+
serverPort = "8080"
12+
remoteURL = "http://localhost:" + serverPort
13+
localDir = "./gitpod-extension-dev"
14+
manifestFilename = "file-manifest.json"
15+
)
16+
17+
func main() {
18+
// Root command (default/client-side logic)
19+
var rootCmd = &cobra.Command{Use: "watch-sync", Short: "Run a client that watches remote changes and syncs them locally"}
20+
rootCmd.Run = func(cmd *cobra.Command, args []string) {
21+
if len(args) > 1 {
22+
fmt.Println("Usage: watch-sync <command-on-update>?")
23+
}
24+
commandOnUpdate := ""
25+
if len(args) == 1 {
26+
commandOnUpdate = args[0]
27+
}
28+
pkg.WatchSync(remoteURL, localDir, manifestFilename, commandOnUpdate)
29+
}
30+
31+
var servCmd = &cobra.Command{
32+
Use: "serve <folder-to-watch>",
33+
Short: "Run the server logic",
34+
Run: func(cmd *cobra.Command, args []string) {
35+
if len(args) != 1 {
36+
fmt.Println("Please provide a folder to watch")
37+
fmt.Println("Usage: watch-sync serve <folder-to-watch>")
38+
return
39+
}
40+
pkg.Serve(args[0], serverPort, manifestFilename)
41+
},
42+
}
43+
44+
// Add "serv" command as a subcommand of the root
45+
rootCmd.AddCommand(servCmd)
46+
47+
// Execute the root command
48+
if err := rootCmd.Execute(); err != nil {
49+
fmt.Println(err)
50+
}
51+
}

dev/http-file-sync/pkg/manifest.go

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package pkg
2+
3+
type FileManifest struct {
4+
Files []FileEntry `json:"files"`
5+
}
6+
7+
type FileEntry struct {
8+
Name string `json:"name"`
9+
LastModified string `json:"lastModified"`
10+
}

0 commit comments

Comments
 (0)