Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to yarn v2 #7575

Merged
merged 24 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e36ffec
init yarn v2
clemsos Sep 22, 2021
3e3a52a
remove local yarn.lock to prevent breaks
clemsos Sep 23, 2021
c664a5f
update dockerfile
clemsos Sep 23, 2021
3023055
adapt unlock-js build
clemsos Sep 23, 2021
f29f7cb
updated lockfile
clemsos Sep 23, 2021
1155daa
add prod-install plugin
clemsos Sep 23, 2021
31a80f8
use prefixed workspace: in package.json
clemsos Sep 23, 2021
731532c
yarn deploy-plugin for prod app
clemsos Sep 23, 2021
cbeb0e0
lockfile use workspaces
clemsos Sep 23, 2021
2ba3ddf
eslint-cofig resolve through workspace
clemsos Sep 23, 2021
39f1ea2
remove pre- prefixed yarn tasks
clemsos Sep 23, 2021
f173f71
remove unused lockfiles
clemsos Sep 23, 2021
b1e55e5
unlock-js fix yarn task
clemsos Sep 23, 2021
a72e4e5
Merge branch 'master' of github.com:unlock-protocol/unlock into yarn-v2
clemsos Sep 23, 2021
9515c68
update lockfile
clemsos Sep 23, 2021
a4fc4b9
Merge branch 'master' of github.com:unlock-protocol/unlock into yarn-v2
clemsos Sep 23, 2021
6b25137
explicitely import optional-chaining in babel conf
clemsos Sep 23, 2021
3c743c5
make jest happy with bablerc
clemsos Sep 24, 2021
9a222a9
unlock-app jest config to support babel+ts
clemsos Sep 24, 2021
714eb25
Merge branch 'master' of github.com:unlock-protocol/unlock into yarn-v2
clemsos Sep 24, 2021
53f906a
fix unlock-app jest testing
clemsos Sep 27, 2021
c304019
ts-jest preset, rename babelrc, fix jest mock
clemsos Sep 27, 2021
1e3178b
avoid mock hoisting
clemsos Sep 27, 2021
fe20cbc
jest explicit node modules ref
clemsos Sep 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,19 @@ smart-contract-extensions/build/
smart-contracts/build/
smart-contracts/cache
smart-contracts/artifacts
builds/
builds/

shared/node_modules/

.vscode

# Elastic Beanstalk Files
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't wait to get rid of all this!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes all these aws files in locksmith can be deleted too

.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/*.global.yml

# yarn
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,13 @@ builds/
# npm files as we use yarn
package-lock.json
yarn-error.log

# yarn v2
.yarn/*
.pnp.js
# !.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

55 changes: 55 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-production-install.cjs

Large diffs are not rendered by default.

631 changes: 631 additions & 0 deletions .yarn/releases/yarn-berry.cjs

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-production-install.cjs
spec: "https://gitlab.com/Larry1123/yarn-contrib/-/raw/master/packages/plugin-production-install/bundles/@yarnpkg/plugin-production-install.js"

yarnPath: .yarn/releases/yarn-berry.cjs
39 changes: 12 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,17 @@ RUN mkdir -p /home/unlock
RUN chown -R node /home/unlock
WORKDIR /home/unlock

# add yarn cache to speedup local builds
ENV YARN_CACHE_FOLDER /home/unlock/yarn-cache

# copy packages info
COPY --chown=node --from=manifests /opt/manifests .
COPY --chown=node .prettierrc /home/unlock/.

# yarn config
COPY --chown=node .yarn/ /home/unlock/.yarn/
COPY --chown=node .yarnrc.yml /home/unlock/.yarnrc.yml

# add yarn cache folder to be used by docker buildkit
RUN echo "cacheFolder: /home/unlock/yarn-cache" >> .yarnrc.yml

# Setting user as root to handle apk install
USER root

Expand All @@ -73,8 +77,7 @@ RUN apk add --no-cache --virtual .build-deps \
USER node
RUN mkdir /home/unlock/${BUILD_DIR}
COPY --chown=node ${BUILD_DIR}/package.json /home/unlock/${BUILD_DIR}/package.json
COPY --chown=node ${BUILD_DIR}/yarn.lock /home/unlock/${BUILD_DIR}/yarn.lock
RUN --mount=type=cache,target=/home/unlock/yarn-cache,uid=1000,gid=1000 SKIP_SERVICES=true yarn install
RUN --mount=type=cache,target=/home/unlock/yarn-cache,uid=1000,gid=1000 yarn install

# delete deps once packages are built
USER root
Expand Down Expand Up @@ -107,6 +110,9 @@ ARG PORT
# additional build step
RUN yarn workspace @unlock-protocol/$BUILD_DIR build

# package everything for prod
RUN cd $BUILD_DIR && yarn prod-install --pack /home/node/app

##
## 4. export a minimal image w only the prod app
##
Expand All @@ -122,28 +128,7 @@ RUN chown node:node /app
WORKDIR /app

# copy package info
COPY --from=build --chown=node /home/unlock/$BUILD_DIR/package.json package.json
COPY --from=build --chown=node /home/unlock/$BUILD_DIR/yarn.lock yarn.lock

# delete dev deps (prevents yarn from fetching them)
# add link: protocol workaround for yarn local links to work
RUN apk add --no-cache --virtual .build-deps coreutils jq \
&& jq 'del(.devDependencies) | (.dependencies |= (with_entries(if .key == "@unlock-protocol/networks" then .key = "link:./packages/networks" else . end)))' package.json > package.json.tmp \
&& mv package.json.tmp package.json \
&& apk del .build-deps \
&& chown node:node package.json


# get local packages builds
COPY --from=build --chown=node /home/unlock/packages packages

# prod install
USER node
ENV NODE_ENV production
RUN yarn install --production --non-interactive --pure-lockfile

# copy built files
COPY --from=build --chown=node /home/unlock/$BUILD_DIR/build/ .
COPY --from=build --chown=node /home/node/app .

# start command
EXPOSE $PORT
Expand Down
31 changes: 16 additions & 15 deletions locksmith/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,17 @@
"main": "server.js",
"scripts": {
"prod": "node -r ./src/utils/envLoader.js ./server.js",
"prestart": "yarn build",
"start": "node -r ./src/utils/envLoader.js ./build/server.js",
"predev": "NODE_ENV=development yarn db:migrate",
"dev": "tsc-watch --onSuccess 'yarn start' --onFailure 'echo Beep! Compilation Failed'",
"pretest": "NODE_ENV=test yarn run db:migrate",
"test": "jest --forceExit --runInBand",
"start": "yarn build && node -r ./src/utils/envLoader.js ./build/server.js",
"dev": "NODE_ENV=development yarn db:migrate && tsc-watch --onSuccess 'yarn start' --onFailure 'echo Beep! Compilation Failed'",
"test": "NODE_ENV=test yarn run db:migrate && jest --forceExit --runInBand",
"lint": "eslint --resolve-plugins-relative-to ../packages/eslint-config --ext .ts,.js src/ __tests__/",
"db:migrate": "sequelize --config ./config/sequelize.config.js db:migrate",
"sequelize": "sequelize --config ./config/sequelize.config.js",
"preci": "yarn lint",
"ci": "yarn test",
"ci": "yarn lint && yarn test",
"build": "tsc",
"tsc": "tsc",
"predist": "yarn build",
"dist": "sh ./scripts/dist.sh",
"prefulfillment:prepare": "yarn build",
"fulfillment:prepare": "node ./scripts/fulfillment_prepare",
"dist": "yarn build && sh ./scripts/dist.sh",
"fulfillment:prepare": "yarn build && node ./scripts/fulfillment_prepare",
"authorize": "./scripts/authorize-lock"
},
"lint-staged": {
Expand All @@ -34,7 +28,7 @@
"dependencies": {
"@sentry/node": "6.12.0",
"@sentry/tracing": "6.12.0",
"@unlock-protocol/networks": "0.0.2",
"@unlock-protocol/networks": "workspace:./packages/networks",
clemsos marked this conversation as resolved.
Show resolved Hide resolved
"@unlock-protocol/unlock-js": "0.20.4",
"apollo-cache-inmemory": "1.6.6",
"apollo-client": "2.6.10",
Expand Down Expand Up @@ -90,7 +84,7 @@
"@types/sequelize": "4.28.10",
"@types/stripe": "8.0.416",
"@types/supertest": "2.0.11",
"@unlock-protocol/eslint-config": "0.0.1",
"@unlock-protocol/eslint-config": "workspace:./packages/eslint-config",
"aws-sdk": "2.981.0",
"babel-jest": "27.1.0",
"eslint": "7.32.0",
Expand All @@ -109,5 +103,12 @@
"testMatch": [
"**/__tests__/**/*.test.js?(x)"
]
}
},
"files": [
"build",
"migrations",
"types",
"config",
"src"
]
}
Loading