Commit Graph

326 Commits

Author SHA1 Message Date
LG 10f57bac65
docs: Update some more links (#4806)
* Update links in package.json

I will try checking the docs too

* docs: Update links in triage.md

* docs: Update links in npm.md

* docs: Update links in whatever files that have `cdr`

* Replace globally, thanks @bpmct!

* fix: coderer instead of coder
I should've used all three toggles in the Search/Replace tab in the GItHub.dev editor.

* Code Formatting
2022-02-01 09:45:19 -07:00
Joe Previte a2f530161f
feat: publish beta and development tags on npm (#4769)
* feat: add logic to publish beta/dev npm

This adds new log to publish the npm package both while working on PRs and when
PRs are merged into main, allowing us to easily test changes in a
production-like setting.

Co-authored-by: Asher <ash@coder.com>
2022-01-21 16:28:56 -07:00
Joe Previte 723469ab5b
refactor: migrate from argon2 -> @node-rs/argon2 (#4733)
* chore(deps): replace argon2 w/@node-rs/argon2

* refactor: clean up hashPassword functions

* refactor(util): pass in process.platform

* fix: use correct settings for test-extension

Before, it was running into errors with an @types package.

Now, we're correctly running `tsc` so it picks up our `tsconfig.json` and we're
telling TypeScript to not typecheck our lib and exclude `node_modules`
2022-01-18 16:13:39 -07:00
Joe Previte 70c91c857a
feat: add tests for node/settings.ts (#4717) 2022-01-10 20:44:28 +00:00
Joe Previte 484429b5da
release: 4.0.1 (#4678)
* chore(release): bump version to 4.0.1

* fix: ignore pre-commit hook for release-prep script

* chore: bump helm-chart to 2.0.0

* chore: update CHANGELOG for 4.0.1
2022-01-05 13:06:32 -07:00
Asher 3d999986b2
feat: proxy URI environment variable (#4681)
* Add test extension

This will let us test extension-related features (like the proxy URI).

I removed the environment variables in the script because they override
the ones you set yourself. We still set defaults in constants.ts.

* Add changelog entry for VSCODE_PROXY_URI

* Add terminal test for VSCODE_PROXY_URI

* Update VS Code

This adds the VSCODE_PROXY_URI environment variable.
2022-01-04 15:02:25 -06:00
Asher f04fcf2d64
chore: update vscode (#4680)
* Update VS Code

Fixes https://github.com/coder/code-server/issues/4598
Fixes https://github.com/coder/code-server/issues/4620
Fixes https://github.com/coder/code-server/issues/4600

* Add locale flag back

This is valid again now that we have restored display language support.
2022-01-04 12:37:11 -06:00
Asher 003480881b
fix: infinite proxy loop (#4676)
I think the problem is that when a proxy is not in use proxy-agent
returns the global agent...which is itself since we set it globally,
causing the loop.

VS Code already covers proxies meaning we only need to do it in our own
requests so to fix this pass in the agent in the version fetch request
instead of overidding globally.

Also avoid proxy-from-env and pass in the proxy URI instead as both
http_proxy and https_proxy can be used for either http or https requests
but it does not allow that.
2022-01-03 18:19:21 -06:00
Asher c4c480a068
Implement last opened functionality (#4633)
* Implement last opened functionality

Fixes https://github.com/cdr/code-server/issues/4619

* Fix test temp dirs not being cleaned up

* Mock logger everywhere

This suppresses all the error and debug output we generate which makes
it hard to actually find which test has failed.  It also gives us a
standard way to test logging for the few places we do that.

* Use separate data directories for unit test instances

Exactly as we do for the e2e tests.

* Add integration tests for vscode route

* Make settings use --user-data-dir

Without this test instances step on each other feet and they also
clobber your own non-test settings.

* Make redirects consistent

They will preserve the trailing slash if there is one.

* Remove compilation check

If you do a regular non-watch build there are no compilation stats so
this bricks VS Code in CI when running the unit tests.

I am not sure how best to fix this for the case where you have a build
that has not been packaged yet so I just removed it for now and added a
message to check if VS Code is compiling when in dev mode.

* Update code-server update endpoint name
2021-12-17 13:06:52 -06:00
Joe Previte c77999bcd3
release: 4.0.0 (#4597)
* chore(release): bump version to 4.0.0

* Bump test plugin code-server engine

Co-authored-by: Asher <ash@coder.com>
2021-12-10 13:30:53 -07:00
Asher 9e583fa562
Add separate function for VS Code arguments (#4599)
The problem before was that the pop() caused the open in existing
instance functionality to break because the arguments no longer
contained the file.

We could simply remove the pop() but since `workspace` and `folder` are
not CLI arguments I think it makes sense to handle them in a separate
function which can be called at the point where they are needed.  This
also lets us de-duplicate some logic since we create these arguments in
two spots and lets us skip this logic when we do not need it.

The pop() is still avoided because manipulating a passed-in object
in-place seems like a risky move.  If we really need to do this we
should copy the positional argument array instead.
2021-12-10 12:01:35 -06:00
Asher 4b4ec37880
Fix relative paths (#4594)
* Add tests for relativeRoot

* Remove path.posix.join

Since this is for file system paths it feels incorrect to use it on
URL paths as they are different in many ways.

* Rewrite cookie path logic

Before we relied on the client to resolve the base given to it by the
backend against the path.

Instead have the client pass that information along so we can resolve it
on the backend.  This means the client has to do less work.

* Do not remove out directory before watch

This is re-used for incremental compilation.

Also remove del since that was the only use (and we can use fs.rmdir in
the future if we need something like this).

* Remove unused function resolveBase
2021-12-08 15:52:15 -06:00
JounQin 6c9c84090e
chore: replace eslint-import-resolver-alias with eslint-import-resolver-typescript (#4546)
Co-authored-by: Joe Previte <jjprevite@gmail.com>
2021-12-07 14:39:01 -07:00
Teffen 62b3a6fd9f
Proxy path fixes (#4548)
* Fix issue where HTTP error status codes are not read.

* Fix issues surrounding sessions when accessed from a proxy.

- Updated vscode args to match latest upstream.
- Fixed issues surrounding trailing slashes affecting base paths.
- Updated cookie names to better match upstream's usage, debuggability.

* Bump vendor.

* Update tests.

* Fix issue where tests lack cookie key.

Co-authored-by: Asher <ash@coder.com>
2021-12-01 18:21:52 -06:00
Joe Previte 65d7420ee7
feat: add test for onLine throw error (#4542) 2021-11-22 20:18:58 +00:00
Joe Previte 0bc96989c2
chore(deps): upgrade json-schema version to 0.4.0 (#4543) 2021-11-22 19:36:04 +00:00
Joe Previte 0a072f7532
feat(testing): refactor humanPath and add tests (#4511)
* feat: add test for humanPath

* refactor: make humanPath pure and pass in homedir
2021-11-15 19:40:34 +00:00
Teffen 1b60ef418c
Use upstream server (#4414)
* Flesh out fixes to align with upstream.

* Update route handlers to better reflect fallback behavior.

* Add platform to vscode-reh-web task

Our strategy has been to build once and then recompile native modules
for individual platforms.  It looks like VS Code builds from scratch for
each platform.

But we can target any platform, grab the pre-packaged folder, then
continue with own packaging.

In the future we may want to rework to match upstream.

* Fix issue where workspace args are not parsed.

* Fix issues surrounding opening files within code-server's terminal.

* Readd parent wrapper for hot reload.

* Allow more errors.

* Fix issues surrounding Coder link.

* Add dir creation and fix cli

It seems VS Code explodes when certain directories do not exist so
import the reh agent instead of the server component since it creates
the directories (require patching thus the VS Code update).

Also the CLI (for installing extensions) did not seem to be working so
point that to the same place since it also exports a function for
running that part of the CLI.

* Remove hardcoded VSCODE_DEV=1

This causes VS Code to use the development HTML file.  Move this to the
watch command instead.

I deleted the other stuff before it as well since in the latest main.js
they do not have this code so I figure we should be safe to omit it.

* Fix mismatching commit between client and server

* Mostly restore command-line parity

Restore most everything and remove the added server arguments.  This
will let us add and remove options after later so we can contain the
number of breaking changes.

To accomplish this a hard separation is added between the CLI arguments
and the server arguments.

The separation between user-provided arguments and arguments with
defaults is also made more clear.

The extra directory flags have been left out as they were buggy and
should be implemented upstream although I think there are better
solutions anyway.  locale and install-source are unsupported with the
web remote and are left removed.  It is unclear whether they were used
before anyway.

Some restored flags still need to have their behavior re-implemented.

* Fix static endpoint not emitting 404s

This fixes the last failing unit test.

Fix a missing dependency, add some generic reverse proxy support for the
protocol, and add back a missing nfpm fix.

* Import missing logError

* Fix 403 errors

* Add code-server version to about dialog

* Use user settings to disable welcome page

The workspace setting seems to be recognized but if so it is having no
effect.

* Update VS Code cache step with new build directories

Co-authored-by: Asher <ash@coder.com>
2021-11-09 23:28:31 -06:00
Mauricio Garavaglia 31d5823d10
Escape HTML from messages in error page (#4430)
Co-authored-by: Asher <ash@coder.com>
Co-authored-by: Joe Previte <jjprevite@gmail.com>
2021-11-09 14:39:54 -07:00
Asher 03651e5e0b
Use frozen lockfile for test dependencies in CI (#4442)
* Use frozen lockfile for test dependencies in CI

This might be causing more Playwright issues.

* Bump Playwright

Mostly just to trigger a reinstall of dependencies since it is cached
and still failing.

Once updated it errors saying install needs to run so add that too.
2021-11-04 11:39:27 -05:00
Joe Previte 13e91dedc1
chore(deps): fix security vulnerabilities (#4428) 2021-11-03 10:32:08 -07:00
Joe Previte 946e4e8843
feat(cli): add test for readSocketPath (#4284)
* fix: update isNodeJSErrnoException

* refactor(cli): export and purify readSocketPath

* feat: add tests for readSocketPath

* fix(ci): temporarily disable install deps from cache
2021-10-29 16:03:57 -07:00
Joe Previte 705e821741
fix(testing): revert change & fix playwright tests (#4310)
* fix(testing): revert change & fix playwright tests

* fix(constants): add type to import statement

* refactor(e2e): delete browser test

This test was originally added to ensure playwright was working.

At this point, we know it works so removing this test because it doesn't help
with anything specific to code-server and only adds unnecessary code to the
codebase plus increases the e2e test job duration.

* chore(e2e): use 1 worker for e2e test

I don't know if it's a resources issue, playwright, or code-server but it seems
like the e2e tests choke when multiple workers are used.

This change is okay because our CI runner only has 2 cores so it would only use
1 worker anyway, but by specifying it in our playwright config, we ensure more
stability in our e2e tests working correctly.

See these PRs:
- https://github.com/cdr/code-server/pull/3263
- https://github.com/cdr/code-server/pull/4310

* revert(vscode): add missing route with redirect

* chore(vscode): update to latest fork

* Touch up compilation step.

* Bump vendor.

* Fix VS Code minification step

* Move ClientConfiguration to common

Common code must not import Node code as it is imported by the browser.

* Ensure lib directory exists before curling

cURL errors now because VS Code was moved and the directory does not
exist.

* Update incorrect e2e test help output

Revert workers change as well; this can be overridden when desired.

* Add back extension compilation step

* Include missing resources in release

This includes a favicon, for example.  I opted to include the entire
directory to make sure we do not miss anything.  Some of the other
stuff looks potentially useful (like completions).

* Set quality property in product configuration

When httpWebWorkerExtensionHostIframe.html is fetched it uses the web
endpoint template (in which we do not include the commit) but if the
quality is not set it prepends the commit to the web endpoint instead.
The new static endpoint does not use/handle commits so this 404s.

Long-term we might want to make the new static endpoint use commits like
the old one but we will also need to update the various other static
URLs to include the commit.

For now I just fixed this by adding the quality since:
  1. Probably faster than trying to find and update all static uses.
  2. VS Code probably expects it anyway.
  3. Gives us better control over the endpoint.

* Update VS Code

This fixes several build issues.

* Bump vscode.

* Bump.

* Bump.

* Use CLI directly.

* Update tests to reflect new upstream behavior.

* Move unit tests to after the build

Our code has new dependencies on VS Code that are pulled in when the
unit tests run.  Because of this we need to build VS Code before running
the unit tests (as it only pulls built code).

* Upgrade proxy-agent dependencies

This resolves a security report with one of its dependencies (vm2).

* Symlink VS Code output directory before unit tests

This is necessary now that we import from the out directory.

* Fix issues surrounding persistent processes between tests.

* Update VS Code cache directories

These were renamed so the cached paths need to be updated.  I changed
the key as well to force a rebuild.

* Move test symlink to script

This way it works for local testing as well.

I had to use out-build instead of out-vscode-server-min because Jest
throws some obscure error about a handlebars haste map.

* Fix listening on a socket

* Update VS Code

It contains fixes for missing files in the build.

* Standardize disposals

* Dispose HTTP server

Shares code with the test HTTP server.  For now it is a function but
maybe we should make it a class that is extended by tests.

* Dispose app on exit

* Fix logging link errors

Unfortunately the logger currently chokes when provided with error
objects.

Also for some reason the bracketed text was not displaying...

* Update regex used by e2e to extract address

The address was recently changed to use URL which seems to add a
trailing slash when using toString, causing the regex match to fail.

* Log browser console in e2e tests

* Add base back to login page

This is used to set cookies when using a base path.

* Remove login page test

The file this was testing no longer exists.

* Use path.posix for static base

Since this is a web path and not platform-dependent.

* Add test for invalid password

Co-authored-by: Teffen Ellis <teffen@nirri.us>
Co-authored-by: Asher <ash@coder.com>
2021-10-28 15:27:17 -05:00
Joe Previte 45319ec648
woo! 2021-10-04 15:04:07 -07:00
Joe Previte 7183b5a43e
chore(testing): fix casing in error messsage 2021-10-04 12:06:33 -07:00
Teffen Ellis d8c344beda Refactor vscode endpoints to use fork directly. 2021-09-30 19:14:17 -04:00
Joe Previte 1b80244af7
Merge pull request #4265 from cdr/jsjoeio-add-tests
feat(cli): add test for defaultConfigFile
2021-09-28 16:19:32 -07:00
Joe Previte 6c95f72d2b
refactor: make password param to defaultConfigFile 2021-09-28 16:13:13 -07:00
Joe Previte 8ef950af4c
feat(brew-bump): add check for cleanup step 2021-09-28 16:07:01 -07:00
Joe Previte e5f03e0b06
fix: add checks and handle errors brew-bump.sh
feat(script): add steps-lib, is_env_var_set & test

feat(brew-bump): add check for VERSION

feat(brew-bump): check HOMEBREW_GITHUB_API_TOKEN

feat(steps-lib): add directory_exists helper fn

fix(brew-bump): check that git clone worked

feat(brew-bump): add check for remote upstream

fix: remove upstream command thing

feat(steps-lib): add file_exists helper function

feat(brew-bump): add check for git-askpass.sh

feat(steps-lib): add is_executable function & test

feat(brew-bump): add check for is_executable

refactor: use GIT_ASKPASS as variable
2021-09-28 16:06:57 -07:00
Joe Previte 77c1150b8d
feat(cli): add test for defaultConfigFile 2021-09-28 15:45:44 -07:00
Joe Previte be90b5de35
chore(deps): upgarde tmpl to 1.0.5 2021-09-27 12:20:04 -07:00
Joe Previte 1f819fa534
chore(deps): upgrade ansi-regex to 5.0.1 2021-09-27 12:15:18 -07:00
Joe Previte f84757507b
feat: add tests for bindAddrFromArgs 2021-09-21 11:48:20 -07:00
Joe Previte 30ade712bf
feat: add tests for shouldRunVsCodeCli 2021-09-20 14:53:09 -07:00
Joe Previte a3cea88f51
feat: add tests for src/node/app.ts 2021-09-20 10:57:31 -07:00
Joe Previte 6a692487c8
feat: add test for get_nfpm_arch 2021-09-17 16:07:03 -07:00
Joe Previte 0609a1b2bd
Merge pull request #4170 from cdr/jsjoeio-fix-trivy-vul
fix(security): update set-value
2021-09-17 21:45:30 +00:00
Joe Previte 7925f88776 fix: comment out logout.test.ts 2021-09-16 17:39:33 -04:00
Joe Previte ddd09454df
fix(security): update set-value 2021-09-16 13:58:18 -07:00
Teffen Ellis 7f2b1dcd22 Fix outdated selector. Add debug info. 2021-09-15 14:54:33 -04:00
Teffen Ellis f885b29675 Add vscode via vendor package.
- Use yarn for vscode vendoring.
- Grab hash from package.
2021-09-15 14:54:33 -04:00
Joe Previte 09440563ca
feat: add tests for src/node/app.ts
This adds a couple tests for ensureAddress.
2021-09-09 17:58:36 -07:00
Joe Previte 2c1aed2395
fix: update tar version with resolution 2021-09-07 14:51:16 -07:00
Joe Previte 79b4e4780d
feat: add full test coverage browser/vscode 2021-08-30 15:12:28 -07:00
Joe Previte dbb8cfb315
chore: bump tar with resolutions 2021-08-04 12:28:03 -07:00
Joe Previte 9137816e33
feat: add getAvailablePort helper function 2021-07-29 15:17:04 -07:00
Joe Previte 42cfa4a7ca
feat: add tests for proxy 2021-07-29 15:16:28 -07:00
Joe Previte 7a6ec202ba
refactor: match /test/unit structure to /src 2021-07-29 09:48:40 -07:00
Joe Previte 6d928a0666
Merge pull request #3846 from cdr/jsjoeio-test-should-enable-proxy
feat: add tests for shouldEnableProxy
2021-07-26 11:38:09 -07:00