Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5db6ab9

Browse files
feat: Add a shrinkwrap file to the NPM release
1 parent be72787 commit 5db6ab9

File tree

10 files changed

+204
-58
lines changed

10 files changed

+204
-58
lines changed

‎.github/ISSUE_TEMPLATE/bug-report.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ body:
5757
id: logs
5858
attributes:
5959
label: Logs
60-
description: Run code-server with the --verbose flag and then paste any relevant logs from the server, from the browser console and/or the browser network tab. For issues with installation, include installation logs (i.e. output of `yarn global add code-server`).
60+
description: Run code-server with the --verbose flag and then paste any relevant logs from the server, from the browser console and/or the browser network tab. For issues with installation, include installation logs (i.e. output of `npm install -g code-server`).
6161
- type: textarea
6262
attributes:
6363
label: Screenshot/Video

‎ci/build/build-release.sh‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ bundle_code_server() {
5555
EOF
5656
) > "$RELEASE_PATH/package.json"
5757
rsync yarn.lock "$RELEASE_PATH"
58+
59+
# To ensure deterministic dependency versions (even when code-server is installed with NPM), we seed
60+
# an npm-shrinkwrap file from our yarn lockfile and the current node-modules installed.
61+
synp --source-file yarn.lock
62+
npm shrinkwrap
63+
# HACK: The shrinkwrap file will contain the devDependencies, which by default
64+
# are installed if present in a lockfile. To avoid every user having to specify --production
65+
# to skip them, we carefully remove them from the shrinkwrap file.
66+
json -f npm-shrinkwrap.json -I -e "Object.keys(this.dependencies).forEach(dependency => { if (this.dependencies[dependency].dev) { delete this.dependencies[dependency] } } )"
67+
mv npm-shrinkwrap.json "$RELEASE_PATH"
68+
5869
rsync ci/build/npm-postinstall.sh "$RELEASE_PATH/postinstall.sh"
5970

6071
if [ "$KEEP_MODULES" = 1 ]; then

‎ci/steps/publish-npm.sh‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ main() {
5959
# This string is used to determine how we should tag the npm release.
6060
# Environment can be one of three choices:
6161
# "development" - this means we tag with the PR number, allowing
62-
# a developer to install this version with `yarn add code-server@<pr-number>`
62+
# a developer to install this version with `npm install -g code-server@<pr-number>`
6363
# "staging" - this means we tag with `beta`, allowing
64-
# a developer to install this version with `yarn add code-server@beta`
64+
# a developer to install this version with `npm install -g code-server@beta`
6565
# "production" - this means we tag with `latest` (default), allowing
66-
# a developer to install this version with `yarn add code-server@latest`
66+
# a developer to install this version with `npm install -g code-server@latest`
6767
if ! is_env_var_set "NPM_ENVIRONMENT"; then
6868
echo "NPM_ENVIRONMENT is not set. Determining in script based on GITHUB environment variables."
6969

@@ -96,7 +96,7 @@ main() {
9696
if [[ "$NPM_ENVIRONMENT" == "production" ]]; then
9797
NPM_VERSION="$VERSION"
9898
# This means the npm version will be published as "stable"
99-
# and installed when a user runs `yarn install code-server`
99+
# and installed when a user runs `npm install -g code-server`
100100
NPM_TAG="latest"
101101
else
102102
COMMIT_SHA="$GITHUB_SHA"
@@ -107,7 +107,7 @@ main() {
107107
if [[ "$NPM_ENVIRONMENT" == "staging" ]]; then
108108
NPM_VERSION="$VERSION-beta-$COMMIT_SHA"
109109
# This means the npm version will be tagged with "beta"
110-
# and installed when a user runs `yarn install code-server@beta`
110+
# and installed when a user runs `npm install -g code-server@beta`
111111
NPM_TAG="beta"
112112
fi
113113

@@ -117,7 +117,7 @@ main() {
117117
NPM_VERSION="$VERSION-$PR_NUMBER-$COMMIT_SHA"
118118
PACKAGE_NAME="@coder/code-server-pr"
119119
# This means the npm version will be tagged with "<pr number>"
120-
# and installed when a user runs `yarn install code-server@<pr number>`
120+
# and installed when a user runs `npm install -g code-server@<pr number>`
121121
NPM_TAG="$PR_NUMBER"
122122
fi
123123

‎docs/android.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
1. Install UserLAnd from [Google Play](https://play.google.com/store/apps/details?id=tech.ula&hl=en_US&gl=US)
44
2. Install an Ubuntu VM
55
3. Start app
6-
4. Install Node.js, `curl` and `yarn` using `sudo apt install nodejs npm yarn curl -y`
6+
4. Install Node.js, `curl` and `npm` using `sudo apt install nodejs npm curl -y`
77
5. Install `nvm`:
88

99
```shell

‎docs/install.md‎

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
- [install.sh](#installsh)
66
- [Detection reference](#detection-reference)
7-
- [yarn, npm](#yarn-npm)
7+
- [npm](#npm)
88
- [Standalone releases](#standalone-releases)
99
- [Debian, Ubuntu](#debian-ubuntu)
1010
- [Fedora, CentOS, RHEL, SUSE](#fedora-centos-rhel-suse)
@@ -19,7 +19,7 @@
1919
- [Uninstall](#uninstall)
2020
- [install.sh](#installsh-1)
2121
- [Homebrew](#homebrew)
22-
- [yarn, npm](#yarn-npm-1)
22+
- [npm](#npm-1)
2323
- [Debian, Ubuntu](#debian-ubuntu-1)
2424

2525
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -87,17 +87,16 @@ _exact_ same commands presented in the rest of this document.
8787

8888
- Ensure that you add `~/.local/bin` to your `$PATH` to run code-server.
8989

90-
- For FreeBSD, code-server will install the [npm package](#yarn-npm) with `yarn`
91-
or `npm`.
90+
- For FreeBSD, code-server will install the [npm package](#npm) with `npm`.
9291

9392
- If you're installing code-server onto architecture with no releases,
94-
code-server will install the [npm package](#yarn-npm) with`yarn` or `npm`
93+
code-server will install the [npm package](#npm) with `npm`
9594
- We currently offer releases for amd64 and arm64.
96-
- The [npm package](#yarn-npm) builds the native modules on post-install.
95+
- The [npm package](#npm) builds the native modules on post-install.
9796

98-
## yarn, npm
97+
## npm
9998

100-
We recommend installing with `yarn` or `npm` when:
99+
We recommend installing with `npm` when:
101100

102101
1. You aren't using a machine with `amd64` or `arm64`.
103102
1. You are installing code-server on Windows
@@ -107,17 +106,17 @@ We recommend installing with `yarn` or `npm` when:
107106
[#1430](https://github.com/coder/code-server/issues/1430#issuecomment-629883198)
108107
for more information.
109108

110-
Installing code-server with `yarn` or `npm` builds native modules on install.
109+
Installing code-server with `npm` builds native modules on install.
111110

112-
This process requires C dependencies; see our guide on [installing with yarn and npm][./npm.md](./npm.md) for more information.
111+
This process requires C dependencies; see our guide on [installing with `npm`][./npm.md](./npm.md) for more information.
113112

114113
## Standalone releases
115114

116115
We publish self-contained `.tar.gz` archives for every release on
117116
[GitHub](https://github.com/coder/code-server/releases). The archives bundle the
118117
node binary and node modules.
119118

120-
We create the standalone releases using the [npm package](#yarn-npm), and we
119+
We create the standalone releases using the [npm package](#npm), and we
121120
then create the remaining releases using the standalone version.
122121

123122
The only requirement to use the standalone release is `glibc` >= 2.17 and
@@ -151,7 +150,7 @@ code-server
151150
## Debian, Ubuntu
152151

153152
> The standalone arm64 .deb does not support Ubuntu 16.04 or earlier. Please
154-
> upgrade or [build with yarn](#yarn-npm).
153+
> upgrade or [build with `npm`](#npm).
155154
156155
```bash
157156
curl -fOL https://github.com/coder/code-server/releases/download/v$VERSION/code-server_$VERSION_amd64.deb
@@ -163,7 +162,7 @@ sudo systemctl enable --now code-server@$USER
163162
## Fedora, CentOS, RHEL, SUSE
164163

165164
> The standalone arm64 .rpm does not support CentOS 7. Please upgrade or [build
166-
> with yarn](#yarn-npm).
165+
> with `npm`](#npm).
167166
168167
```bash
169168
curl -fOL https://github.com/coder/code-server/releases/download/v$VERSION/code-server-$VERSION-amd64.rpm
@@ -228,14 +227,13 @@ You can install code-server using the [Helm package manager](https://coder.com/d
228227

229228
## Windows
230229

231-
We currently [do not publish Windows releases](https://github.com/coder/code-server/issues/1397). We recommend installing code-server onto Windows with [`yarn` or `npm`](#yarn-npm).
230+
We currently [do not publish Windows releases](https://github.com/coder/code-server/issues/1397). We recommend installing code-server onto Windows with [`npm`](#npm).
232231

233232
> Note: You will also need to [build coder/cloud-agent manually](https://github.com/coder/cloud-agent/issues/17) if you would like to use `code-server --link` on Windows.
234233
235234
## Raspberry Pi
236235

237-
We recommend installing code-server onto Raspberry Pi with [`yarn` or
238-
`npm`](#yarn-npm).
236+
We recommend installing code-server onto Raspberry Pi with [`npm`](#npm).
239237

240238
## Termux
241239

@@ -277,16 +275,10 @@ brew remove code-server
277275
brew uninstall code-server
278276
```
279277

280-
### yarn, npm
278+
### npm
281279

282280
To remove the code-server global module, run:
283281

284-
```shell
285-
yarn global remove code-server
286-
```
287-
288-
or
289-
290282
```shell
291283
npm uninstall -g code-server
292284
```

‎docs/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"children": [
2222
{
2323
"title": "npm",
24-
"description": "How to install code-server using npm or yarn",
24+
"description": "How to install code-server using npm",
2525
"path": "./npm.md"
2626
},
2727
{

‎docs/npm.md‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ If you're installing code-server via `npm`, you'll need to install additional
2020
dependencies required to build the native modules used by VS Code. This article
2121
includes installing instructions based on your operating system.
2222

23+
> **WARNING**: Do not use Yarn to install code-server. Unlike NPM, it does not respect
24+
lockfiles for distributed applications. It will instead use the latest version
25+
available at installation time - which might not be the one used for a given
26+
code-server release, and [might lead to unexpected behavior](https://github.com/coder/code-server/issues/4927).
27+
2328
## Node.js version
2429

2530
We use the same major version of Node.js shipped with VSCode's Electron,
@@ -72,7 +77,7 @@ Proceed to [installing](#installing)
7277
## FreeBSD
7378

7479
```sh
75-
pkg install -y git python npm-node14 yarn-node14 pkgconf
80+
pkg install -y git python npm-node14 pkgconf
7681
pkg install -y libinotify
7782
```
7883

@@ -85,8 +90,7 @@ Installing code-server requires all of the [prerequisites for VS Code developmen
8590
Next, install code-server with:
8691

8792
```bash
88-
yarn global add code-server
89-
# Or: npm install -g code-server
93+
npm install -g code-server
9094
code-server
9195
# Now visit http://127.0.0.1:8080. Your password is in ~/.config/code-server/config.yaml
9296
```
@@ -96,8 +100,7 @@ A `postinstall.sh` script will attempt to run. Select your terminal (e.g., Git b
96100
If the `code-server` command is not found, you'll need to [add a directory to your PATH](https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/). To find the directory, use the following command:
97101

98102
```shell
99-
yarn global bin
100-
# Or: npm config get prefix
103+
npm config get prefix
101104
```
102105

103106
For help and additional troubleshooting, see [#1397](https://github.com/coder/code-server/issues/1397).
@@ -107,8 +110,7 @@ For help and additional troubleshooting, see [#1397](https://github.com/coder/co
107110
After adding the dependencies for your OS, install the code-server package globally:
108111

109112
```bash
110-
yarn global add code-server
111-
# Or: npm install -g code-server
113+
npm install -g code-server
112114
code-server
113115
# Now visit http://127.0.0.1:8080. Your password is in ~/.config/code-server/config.yaml
114116
```
@@ -122,7 +124,7 @@ page](https://github.com/coder/code-server/discussions).
122124

123125
Occasionally, you may run into issues with Node.js.
124126

125-
If you install code-server using `yarn` or `npm`, and you upgrade your Node.js
127+
If you install code-server using `npm`, and you upgrade your Node.js
126128
version, you may need to reinstall code-server to recompile native modules.
127129
Sometimes, you can get around this by navigating into code-server's `lib/vscode`
128130
directory and running `npm rebuild` to recompile the modules.
@@ -136,7 +138,7 @@ A step-by-step example of how you might do this is:
136138

137139
### Debugging install issues with npm
138140

139-
`yarn` suppresses logs when running `yarn global add`, so to debug installation issues, install with `npm` instead:
141+
To debug installation issues:
140142

141143
```shell
142144
# Uninstall

‎install.sh‎

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The detection method works as follows:
5555
- Debian, Ubuntu, Raspbian: install the deb package from GitHub.
5656
- Fedora, CentOS, RHEL, openSUSE: install the rpm package from GitHub.
5757
- Arch Linux: install from the AUR (which pulls releases from GitHub).
58-
- FreeBSD, Alpine: install from yarn/npm.
58+
- FreeBSD, Alpine: install from npm.
5959
- macOS: install using Homebrew if installed otherwise install from GitHub.
6060
- All others: install the release from GitHub.
6161
@@ -419,19 +419,9 @@ install_npm() {
419419
echoh "Installing latest from npm."
420420
echoh
421421

422-
YARN_PATH="${YARN_PATH-yarn}"
423422
NPM_PATH="${YARN_PATH-npm}"
424-
if command_exists "$YARN_PATH"; then
425-
sh_c="sh_c"
426-
if [ ! "${DRY_RUN-}" ] && [ ! -w "$($YARN_PATH global bin)" ]; then
427-
sh_c="sudo_sh_c"
428-
fi
429-
echoh "Installing with yarn."
430-
echoh
431-
"$sh_c" "$YARN_PATH" global add code-server --unsafe-perm
432-
NPM_BIN_DIR="\$($YARN_PATH global bin)" echo_npm_postinstall
433-
return
434-
elif command_exists "$NPM_PATH"; then
423+
424+
if command_exists "$NPM_PATH"; then
435425
sh_c="sh_c"
436426
if [ ! "${DRY_RUN-}" ] && [ ! -w "$(NPM_PATH config get prefix)" ]; then
437427
sh_c="sudo_sh_c"
@@ -442,9 +432,9 @@ install_npm() {
442432
NPM_BIN_DIR="\$($NPM_PATH bin -g)" echo_npm_postinstall
443433
return
444434
fi
445-
echoerr "Please install npm or yarn to install code-server!"
435+
echoerr "Please install npm to install code-server!"
446436
echoerr "You will need at least node v12 and a few C dependencies."
447-
echoerr "See the docs https://coder.com/docs/code-server/latest/install#yarn-npm"
437+
echoerr "See the docs https://coder.com/docs/code-server/latest/install#npm"
448438

449439
exit 1
450440
}

‎package.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@
5959
"eslint-import-resolver-typescript": "^2.5.0",
6060
"eslint-plugin-import": "^2.18.2",
6161
"eslint-plugin-prettier": "^4.0.0",
62+
"json": "^11.0.0",
6263
"prettier": "^2.2.1",
6364
"prettier-plugin-sh": "^0.8.0",
6465
"shellcheck": "^1.0.0",
6566
"stylelint": "^13.0.0",
6667
"stylelint-config-recommended": "^5.0.0",
68+
"synp": "^1.9.10",
6769
"ts-node": "^10.0.0",
6870
"typescript": "^4.4.0-dev.20210528"
6971
},

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /