|
| 1 | +# Code Extension Marketplace |
| 2 | + |
| 3 | +The Code Extension Marketplace is an open-source alternative to the VS Code |
| 4 | +Marketplace for use in editors like |
| 5 | +[code-server](https://github.com/cdr/code-server). |
| 6 | + |
| 7 | +This marketplace reads extensions from file storage and provides an API for |
| 8 | +editors to consume. It does not have a frontend or any mechanisms for adding or |
| 9 | +updating extensions in the marketplace. |
| 10 | + |
| 11 | +## Deployment |
| 12 | + |
| 13 | +Replace `$os` and `$arch` with your operating system and architecture. |
| 14 | + |
| 15 | +``` |
| 16 | +wget https://github.com/coder/code-marketplace/releases/latest/download/code-marketplace-$os-$arch -O ./code-marketplace |
| 17 | +chmod +x ./code-marketplace |
| 18 | +./code-marketplace server --extensions-dir /my/extensions |
| 19 | +``` |
| 20 | + |
| 21 | +Run `./code-marketplace --help` for a full list of options. |
| 22 | + |
| 23 | +It is recommended to put the marketplace behind TLS otherwise code-server will |
| 24 | +reject connecting to the API. |
| 25 | + |
| 26 | +The `/healthz` endpoint can be used to determine if the marketplace is ready to |
| 27 | +receive requests. |
| 28 | + |
| 29 | +## File Storage |
| 30 | + |
| 31 | +Extensions must be both copied as a vsix and extracted to the following path: |
| 32 | + |
| 33 | +``` |
| 34 | +<extensions-dir>/<publisher>/<extension name>/<version>/ |
| 35 | +``` |
| 36 | + |
| 37 | +For example: |
| 38 | + |
| 39 | +``` |
| 40 | +extensions |
| 41 | +|-- ms-python |
| 42 | +| `-- python |
| 43 | +| `-- 2022.14.0 |
| 44 | +| |-- [Content_Types].xml |
| 45 | +| |-- extension |
| 46 | +| |-- extension.vsixmanifest |
| 47 | +| `-- ms-python.python-2022.14.0.vsix |
| 48 | +`-- vscodevim |
| 49 | + `-- vim |
| 50 | + `-- 1.23.2 |
| 51 | + |-- [Content_Types].xml |
| 52 | + |-- extension |
| 53 | + |-- extension.vsixmanifest |
| 54 | + `-- vscodevim.vim-1.23.2.vsix |
| 55 | +``` |
| 56 | + |
| 57 | +## Usage in code-server |
| 58 | + |
| 59 | +``` |
| 60 | +export EXTENSIONS_GALLERY='{"serviceUrl":"https://<domain>/api", "itemUrl":"https://<domain>/item", "resourceUrlTemplate": "https://<domain>/files/{publisher}/{name}/{version}/{path}"}' |
| 61 | +code-server |
| 62 | +``` |
| 63 | + |
| 64 | +If code-server reports content security policy errors ensure that the |
| 65 | +marketplace is running behind an https URL. |
| 66 | + |
| 67 | +## Reverse proxy |
| 68 | + |
| 69 | +To host the marketplace behind a reverse proxy set either the `Forwarded` header |
| 70 | +or both the `X-Forwarded-Host` and `X-Forwarded-Proto` headers. |
| 71 | + |
| 72 | +The marketplace does not support being hosted behind a base path; it must be |
| 73 | +proxied at the root of your domain. |
| 74 | + |
| 75 | +## Getting extensions |
| 76 | + |
| 77 | +If an extension is open source you can get it from one of three locations: |
| 78 | + |
| 79 | +1. GitHub releases (if the extension publishes releases to GitHub). |
| 80 | +2. Open VSX (if the extension is published to Open VSX). |
| 81 | +3. Building from source. |
| 82 | + |
| 83 | +For example to download the Python extension from Open VSX: |
| 84 | + |
| 85 | +``` |
| 86 | +mkdir -p extensions/ms-python/python/2022.14.0 |
| 87 | +wget https://open-vsx.org/api/ms-python/python/2022.14.0/file/ms-python.python-2022.14.0.vsix |
| 88 | +unzip ms-python.python-2022.14.0.vsix -d extensions/ms-python/python/2022.14.0 |
| 89 | +mv ms-python.python-2022.14.0.vsix extensions/ms-python/python/2022.14.0 |
| 90 | +``` |
| 91 | + |
| 92 | +Make sure to both extract the contents *and* copy/move the `.vsix` file. |
| 93 | + |
| 94 | +If an extension has dependencies those must be added as well. An extension's |
| 95 | +dependencies can be found in the extension's `package.json` under |
| 96 | +`extensionDependencies`. |
| 97 | + |
| 98 | +Extensions under `extensionPack` in the extension's `package.json` can be added |
| 99 | +as well although doing so is not required. |
| 100 | + |
| 101 | +## Development |
| 102 | + |
| 103 | +``` |
| 104 | +make test |
| 105 | +mkdir -p extensions |
| 106 | +go run ./cmd/marketplace/main.go server --extensions-dir ./extensions |
| 107 | +``` |
| 108 | + |
| 109 | +When testing with code-server you may run into issues with content security |
| 110 | +policy if the marketplace runs on a different domain over HTTP; in this case you |
| 111 | +will need to disable content security policy in your browser or manually edit |
| 112 | +the policy in code-server's source. |
| 113 | + |
| 114 | +When you make a change that affects people deploying the marketplace please |
| 115 | +update the changelog as part of your PR. |
| 116 | + |
| 117 | +## Missing features |
| 118 | + |
| 119 | +- Recommended extensions. |
| 120 | +- Featured extensions. |
| 121 | +- Download counts. |
| 122 | +- Ratings. |
| 123 | +- Searching by popularity. |
| 124 | +- Published, released, and updated dates for extensions (for example this will |
| 125 | + cause bogus release dates to show for versions). |
| 126 | +- Frontend for browsing available extensions. |
| 127 | +- Extension validation (only the marketplace owner can add extensions anyway). |
| 128 | +- Adding and updating extensions by extension authors. |
| 129 | + |
| 130 | +## Planned work |
| 131 | + |
| 132 | +- jFrog integration for file storage. |
| 133 | +- Helm chart for deployment. |
0 commit comments