Archived
1
0
Commit Graph

358 Commits

Author SHA1 Message Date
Joe Previte
3207bfd4ad
feat: add test for isFile when error (#5182)
This adds an additional test for the `isFile` utility function to ensure
it returns `false` in the event of an error.
2022-05-09 23:24:40 +00:00
Joe Previte
5a5798e45f
fix(update): add OrEqual to update.checked test (#5171)
* fix(update): add OrEqual to update.checked test

* fixup!: change all instances to OrEqual

* fixup!: add missing equals

* fixup!: consistency
2022-05-06 16:51:44 +00:00
Joe Previte
88e971c609
refactor(heart): bind class methods and make beat async (#5142)
* feat: set up new test for beat twice

* refactor: make Heart.beat() async

This allows us to properly await heart.beat() in our tests and remove
the HACK I added before.

* refactor: bind heart methods .beat and .alive

This allows the functions to maintain access to the Heart instance (or
`this`) even when they are passed to other functions. We do this because
we pass both `isActive` and `beat` to `heartbeatTimer`.

* feat(heart): add test to ensure no warnings called

* fixup!: revert setTimeout for heartbeatTimer

* fixup!: return promise in beat
2022-05-04 16:05:48 -07:00
Joe Previte
7027ec7d60
chore: upgrade Code to 1.66 (#5135)
* chore: upgrade Code to 1.66

* docs: update docs for Code upgrades

* fixup!: docs

* chore: update vscode submodule

* chore: update integration patch

* chore: update node-version patch

* chore: update github-auth patch

They completely changed how auth is handled for GitHub in
https://github.com/microsoft/vscode/pull/145424 so our patch may not
work. Will need to test and revisit.

* refactor: remove postinstall patch

It appears they renamed postinstall.js to postinstall.mjs and removed
the use of `rimraf` which means our patch is no longer needed! 🎉

b0e8554cce

* chore: refresh local-storage patch

* chore: refresh service-worker patch

* chore: bulk refresh patches

* fixup!: docs formatting

* refactor: remove unused last-opened patch

* fixup!: formatting docs

* fixup!: formatting docs

* refactor: remove rsync postinstall

* Revert "refactor: remove rsync postinstall"

This reverts commit 8d6b613e9d.

* refactor: update postinstall.js to .mjs

* feat(patches): add parent-origin bypass

* docs(patches): add notes for testing store-socket

* docs(patches): update testing info for node-version

* refactor(patches): delete github-auth.diff patch

* docs(patches): add notes for testing connection-type

* fixup!: delete github-auth patch

* fixup!: update connection type testing

* docs(patches): add notes to insecure-notification.diff

* docs(patches): add nots for update-check.diff

* fixup!: remove comma in integration patch

* fix(e2e): disable workspace trust

* refactor: add --no-default-rc for yarn install

* feat(patches): remove yarnrc in presinstall

* fixup!: silly mistake

* docs: add note about KEEP_MODULES=1

* docs(patches): add testing notes for node-version

* refactor(patches): remove node-version

It appears this is no longer needed due to the `remote/package.json` now which
targets node rather than electron.

* fixup!: add cd ../.. to code upgrade instructions

* fixup!: add note to yarn --production flag

* fixup!: make parent-origin easier to upstream

* Revert "refactor(patches): delete github-auth.diff patch"

This reverts commit 31a354a343.

* Revert "fixup!: delete github-auth patch"

This reverts commit bdeb5212e8.

* Merge webview origin patch into webview patch

* Remove unused post-install patch

* Prevent builtin extensions from updating

* Refresh sourcemaps patch

* Update Node to v16

This matches the version in ./lib/vscode/remote/.yarnrc.

I changed the engine to exactly 16 since if you use any different
version it will just not work since the modules will have been built for
16 (due to the .yarnrc).

* Replace fs.rmdir with fs.rm

Node is showing a deprecation warning about it.

* Update github-auth patch

The local credentials provider is no longer used when there is a remote
so this code moved into the backend web credential provider.

* Prevent fs.rm from erroring about non-existent files

We were using fs.rmdir which presumably did not have the same behavior
in v14 (in v16 fs.rmdir also errors).

* Install Python 3 in CentOS CI container

Co-authored-by: Asher <ash@coder.com>
2022-05-04 21:58:49 +00:00
Joe Previte
e3c8bd692c
feat(cli): support true for CS_DISABLE_FILE_DOWNLOADS (#5134)
After some feedback, we realized it is more intuitive to disable file
downloads by setting the environment variable
`CS_DISABLE_FILE_DOWNLOADS` to `true` than `1`. This commit adds support
for both.
2022-04-26 20:09:53 +00:00
mooff
a0b36147ea
fix: listening on IPv6 address not possible (#5133)
Wrap IPv6 addresses in square brackets when making URL in ensureAddress,
fixing regression (#1582)
2022-04-26 19:33:51 +00:00
Joe Previte
683412cb01
refactor: add timeout for race condition in heart test (#5131)
* refactor: add timeout for race condition in heart test

* fixup!: set mtime to 0 and check for update

* fixup!: use utimes directly instead of file open

* fixup!: remove import
2022-04-26 17:39:37 +00:00
Joe Previte
18ff99693b
feat: add tests for node/heart.ts (#5122)
* refactor(heart): extract logic into heartbeatTimer fn

To make it easier to test, I extract heartbeatTimer into it's own
function.

* feat(testing): add tests for heart.ts

* fixup

* fixup!: remove unneeded heart call

* Update src/node/heart.ts

Co-authored-by: Asher <ash@coder.com>

* fixup!: use mockResolvedValue everywhere

* fixup!: add stat test for timestamp check

Co-authored-by: Asher <ash@coder.com>
2022-04-26 16:35:40 +00:00
Asher
c35bf1311e
chore: provide details when update.checked tests fail (#5115)
Using the toBe* functions will let us know what the actual values are
rather than just telling us true does not equal false.
2022-04-19 15:46:23 -05:00
Joe Previte
0e1f396645
feat: add option for disabling file downloads (#5055)
* feat(cli): add disable-file-downloads to cli

* feat(e2e): add download test

* feat(e2e): add downloads disabled test

* refactor(e2e): explain how to debug unexpected close

* feat(patches): add disable file downloads

* wip: update diff

* Update src/node/cli.ts

Co-authored-by: Asher <ash@coder.com>

* fixup! add missing common/contextkeys file to patch

* fixup!: update patch

* fixup!: default disable-file-downloads undefined

* fixup!: combine e2e tests

* fixup!: use different test names

* feat: add CS_DISABLE_FILE_DOWNLOADS

* fixup!: make explicit and cleanup test

* fixup!: use beforeEach

Co-authored-by: Asher <ash@coder.com>
2022-04-13 09:39:05 -07:00
Asher
5bc26e90cb
fix: version in about dialog (#5057)
* Fix code-server version not appearing in other languages

It needs to be separate from the localize call since the language
version of that string is used and it will not include a spot for the
code-server version.

I also moved the "v" so we do not get "vUnknown".

* Add code-server version to product configuration

Before 1.64 the entire product configuration was sent to the client but
that was removed so we have to add anything we want to use on the
client, like the code-server version (used in the about dialog).

Fixes #5027.

* Refresh patches

* Change version test to look for specific version

This will catch if we are not sending the actual version to the client.
2022-03-31 16:14:03 -05:00
Asher
a1af9e2a56
chore: move to patches (#4997)
* Move integration types into code-server

This will be easier to maintain than to have it as a patch.

* Disable connection token

Using a flag means we will not need to patch it out.  I think this is
new from 1.64?

* Add product.json to build process

This way we do not have to patch it.

* Ship with remote agent package.json

Instead of the root one.  This contains fewer dependencies.

* Let Code handle errors

This way we will not have to patch Code to make this work and I think it
makes sense to let Code handle the request.

If we do want to handle errors we can do it cleanly by patching their
error handler to throw instead.

* Move manifest override into code-server

This way we will not have to patch it.

* Move to patches

- Switch submodule to track upstream
- Add quilt to the process
- Add patches

The node-* ignore was ignoring one of the diffs so I removed it.  This
was added when we were curling Node as node-v{version}-darwin-x64 for
the macOS build but this no longer happens (we use the Node action to
install a specific version now so we just use the system-wide Node).

* Use pre-packaged Code
2022-03-22 15:07:14 -05:00
Asher
21c74802e8
chore: move Code to a submodule (#4990)
* Move Code to a submodule

Closes #4901.

* Base Code cache on hash and re-enable node_modules cache

The current setup appears to only rebuild VS Code if the dependencies
change but we need to rebuild it if anything changes.

I also re-enabled the commented out node_modules caches.  They look like
they should work to me with the submodule method.  I think the problem
occurred because Code itself was being installed in the yarn step.
2022-03-14 21:37:29 -05:00
Joe Previte
86c8590bd5
feat(testing): add test for app > listen (#4971)
* feat(testing): add test for app > listen

* Update test/unit/node/app.test.ts

* refactor: modernize listen fn in app

* wip

* fix: update error message

* fixup: remove console.log

* fixup: use clearAllMocks once in beforeAll

* fix: move chmod after socket listen

* fixup: formatting

* Update src/node/app.ts

Co-authored-by: Jonathan Yu <jonathan@coder.com>

* Update src/node/app.ts

Co-authored-by: Asher <ash@coder.com>

Co-authored-by: Jonathan Yu <jonathan@coder.com>
Co-authored-by: Asher <ash@coder.com>
2022-03-11 16:54:59 -07:00
Joe Previte
91cabbc246
feat(testing): add test for optionDescriptions (#4970)
* feat(testing): add test for optionDescriptions

* refactor(cli): optional arg in optionDescriptions

* feat: add more tests for optionDescriptions
2022-03-11 13:27:19 -07:00
Joe Previte
03e0bdac03
chore: update vscode to 1.64 (#4902)
* chore: update vscode server files

* chore: update code to 1.64

* refactor: clean up code in constants.ts

* chore: keep package.json vscode cache

* fixup!: formatting

* feat(ci): add VSCODE_CACHE_VERSION

* fix(ci): add package.json for e2e tests

* fix: TS errors

* refactor: remove isConnected e2e tests
2022-03-09 14:28:52 -07:00
Joe Previte
643ef1392f
testing: add new test for logLevels (#4953)
* feat: add new test for logLevels

* wip

* feat: add test for valid log level env var
2022-03-07 16:08:07 -07:00
Asher
b61a8addcf
feat: migrate state to new database name (#4938)
* Merge setup and navigate functions

Whenever we navigate we probably want to make sure the editor is ready
so might as well just have one function.

* Add customizable entry and workspace directory

* Add test for state db migration

* Update Code

This contains the state migrations.
2022-03-03 12:32:43 -06:00
Ciel
c4d87580ef
feat: cli arg for file permission of socket (#4923) 2022-03-03 09:54:35 -07:00
Joe Previte
78658f1cf4
refactor: remove folder/workspace from vsCodeCliArgs (#4932)
* refactor: remove folder/workspace from vsCodeCliArgs

Since we handle this in the vscode.ts route, we no longer need to pass it to VS
Code as a CLI arg since it's deprecated on that side.

* feat(vscode): redirect to folder from cli

* Update src/node/routes/vscode.ts

Co-authored-by: Asher <ash@coder.com>

* fixup!: update _: type

* fixup!: move vars to lower if block

* fixup!: share redirect block

* fixup!: mmove req.query.ew block into if

* fixup!: refactor vscode tests

* refactor: make vscode.ts logic easier to read

* fixup!: fix broken tests and clean up logic

* chore: upgrade vscode version

* fixup!: delete unnecessary if closed block

* Update src/node/routes/vscode.ts

Co-authored-by: Asher <ash@coder.com>

* fixup!: rename to FOLDER_OR_WORKSPACE_WAS_CLOSED

Co-authored-by: Asher <ash@coder.com>
2022-03-02 15:36:38 -07:00
Asher
0e78a147b6
feat: github-auth flag (#4926)
* feat: github-auth flag

This will allow injecting credentials into code-server if you already
have them.

* Update Code

Contains the GitHub auth changes.

* Add e2e test for GitHub token
2022-03-02 14:02:51 -06:00
Jonathan Yu
2c785779b5
feat: add version of Code OSS to output (#4925)
Show the bundled version of Code OSS in the text-based output
for --version and --help, in addition to the JSON output
(--version --json)

Closes: #4874
2022-03-01 12:20:43 -08:00
Joe Previte
506d3f43ed
feat(http): keep slashes in queryParams in redirects (#4928)
* refactor(http): extract logic into constructRedirectPath

This allows us to easily test our redirect path construction logic where we get
the relative path, the query string and construct a redirect path.

By extracting this from `redirect`, we can easily test this logic in a unit
test.

I did this so we could test some logic where slashes in query strings should be
made human-friendly for users.

* feat(testing): add tests for constructRedirectPath

Co-authored-by: Asher <ash@coder.com>
2022-03-01 12:11:56 -07:00
Jonathan Yu
44d74c170f
feat: add version string functions to constants (#4920)
Introduce helper functions for getting human- and machine-readable
version strings from the constants package, and cover it in unit
tests.

This is a first step to resolving #4874.
2022-02-28 13:55:47 -08:00
Joe Previte
793e4d35ec
feat(testing): add new test for cli.ts (#4898)
* feat(testing): add new test for cli.ts

* fixup!: update parse test
2022-02-24 11:07:42 -07:00
Asher
f9402a6318
fix: state collision (#4881)
* Add helper for navigating the quick picker

This has problems similar to the menu except instead of closing it gets
re-created which interrupts the hover call and causes the test to fail.
Now it will keep trying just like the menu.

* Add a test for opening a file

* Add test for colliding state

* Update VS Code

This contains the colliding state fix.
2022-02-22 12:43:13 -06:00
Joe Previte
94f378c196
feat(testing): add test for parse when error in args + config (#4866)
* chore: fmt cleanup

* feat(parse): add test error w/config
2022-02-15 16:19:22 -07:00
Joe Previte
e3e9f052c4
fix: wrap socket in proxy before passing to vscode (#4840)
* chore: add ipc hook to e2e script

* refactor: allow codeServerArgs in e2e tests

* feat: add --cert e2e extension test

* fix: wrap websocket in proxy

* fixup: remvoe ignoreHTTPSErrors

* fixup: make codeServerArgs readonly

* fixup! add back ignoreHTTPSErrors
2022-02-15 14:51:42 -07:00
Joe Previte
b26cce589f
chore: update vscode commit (#4857)
* chore: update vscode commit

This includes two fixes from coder/vscode:
- https://github.com/coder/vscode/pull/43
- https://github.com/coder/vscode/pull/42

* fix: use double-bracket in ext. e2e test
2022-02-15 14:15:53 -07:00
Joe Previte
c9c5c54cda
feat: add tests for update.ts (#4835)
* feat: add isAddressInfo helper function

* feat(update): add test for rejection UpdateProvider

* feat: add more tests for UpdateProvider

* fixup! move isAddressInfo, add .address check

* fixup! remove extra writeHead

* fixup! use -1 in redirect logic

* fixup! remove unnecessary String call

* fixup! use /latest for redirect

* fixup! use match group for regex

* fixup!: replace match/split logic
2022-02-14 13:53:28 -07:00
Joe Previte
25b1340771
revert: @node-rs/argon2 -> node-argon2 (#4829)
* revert: partial revert of 723469ab5b

This reverts part of the changes introduced in refactor: migrate from argon2 ->
@node-rs/argon2 (#4733)

Switching to @node-rs/argon2 introduced bugs that we couldn't solve due to
limitations in npm.

see here
https://github.com/coder/code-server/issues/4804#issuecomment-1030338395
2022-02-04 15:52:42 -07:00
Joe Previte
00224fa73a
feat: add test for hash when error (#4814) 2022-02-03 14:22:16 -07:00
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