Archived
1
0

feat: Add a shrinkwrap file to the NPM release (#5010)

This commit is contained in:
Edouard Vincent
2022-03-29 10:33:56 -07:00
committed by GitHub
parent e1c1ba8b36
commit 326a1d1862
10 changed files with 204 additions and 58 deletions

View File

@ -55,6 +55,17 @@ bundle_code_server() {
EOF
) > "$RELEASE_PATH/package.json"
rsync yarn.lock "$RELEASE_PATH"
# To ensure deterministic dependency versions (even when code-server is installed with NPM), we seed
# an npm-shrinkwrap file from our yarn lockfile and the current node-modules installed.
synp --source-file yarn.lock
npm shrinkwrap
# HACK@edvincent: The shrinkwrap file will contain the devDependencies, which by default
# are installed if present in a lockfile. To avoid every user having to specify --production
# to skip them, we carefully remove them from the shrinkwrap file.
json -f npm-shrinkwrap.json -I -e "Object.keys(this.dependencies).forEach(dependency => { if (this.dependencies[dependency].dev) { delete this.dependencies[dependency] } } )"
mv npm-shrinkwrap.json "$RELEASE_PATH"
rsync ci/build/npm-postinstall.sh "$RELEASE_PATH/postinstall.sh"
if [ "$KEEP_MODULES" = 1 ]; then

View File

@ -59,11 +59,11 @@ main() {
# This string is used to determine how we should tag the npm release.
# Environment can be one of three choices:
# "development" - this means we tag with the PR number, allowing
# a developer to install this version with `yarn add code-server@<pr-number>`
# a developer to install this version with `npm install code-server@<pr-number>`
# "staging" - this means we tag with `beta`, allowing
# a developer to install this version with `yarn add code-server@beta`
# a developer to install this version with `npm install code-server@beta`
# "production" - this means we tag with `latest` (default), allowing
# a developer to install this version with `yarn add code-server@latest`
# a developer to install this version with `npm install code-server@latest`
if ! is_env_var_set "NPM_ENVIRONMENT"; then
echo "NPM_ENVIRONMENT is not set. Determining in script based on GITHUB environment variables."
@ -96,7 +96,7 @@ main() {
if [[ "$NPM_ENVIRONMENT" == "production" ]]; then
NPM_VERSION="$VERSION"
# This means the npm version will be published as "stable"
# and installed when a user runs `yarn install code-server`
# and installed when a user runs `npm install code-server`
NPM_TAG="latest"
else
COMMIT_SHA="$GITHUB_SHA"
@ -107,7 +107,7 @@ main() {
if [[ "$NPM_ENVIRONMENT" == "staging" ]]; then
NPM_VERSION="$VERSION-beta-$COMMIT_SHA"
# This means the npm version will be tagged with "beta"
# and installed when a user runs `yarn install code-server@beta`
# and installed when a user runs `npm install code-server@beta`
NPM_TAG="beta"
fi
@ -117,7 +117,7 @@ main() {
NPM_VERSION="$VERSION-$PR_NUMBER-$COMMIT_SHA"
PACKAGE_NAME="@coder/code-server-pr"
# This means the npm version will be tagged with "<pr number>"
# and installed when a user runs `yarn install code-server@<pr number>`
# and installed when a user runs `npm install code-server@<pr number>`
NPM_TAG="$PR_NUMBER"
fi