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

Upgrade to yarn berry #2008

Merged
merged 30 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bd10337
Upgrade to yarn berry
pablomendezroyo Aug 6, 2024
c292bf8
use strict typescript rules
pablomendezroyo Aug 6, 2024
987045e
use yarn moderl workspaces references
pablomendezroyo Aug 6, 2024
fa6493e
bump to node 22 in workflows and docker
pablomendezroyo Aug 6, 2024
d72f3bc
use yarn berry and enable corepack in workflows
pablomendezroyo Aug 6, 2024
d64e6d9
relocate enable corepack
pablomendezroyo Aug 6, 2024
0e9ae94
fix docker node version
pablomendezroyo Aug 6, 2024
7696af9
Fix dockerfile builds
pablomendezroyo Aug 7, 2024
6ccfd84
fix workspace naming
pablomendezroyo Aug 7, 2024
415d4ba
add tsconfig test
pablomendezroyo Aug 12, 2024
8973586
remove broken dependency
pablomendezroyo Aug 12, 2024
0cee03e
add missing type
pablomendezroyo Aug 12, 2024
5baf6f2
fix test types
pablomendezroyo Aug 12, 2024
d8e7798
use assert with
pablomendezroyo Aug 12, 2024
5fca3ce
remove import assertions
pablomendezroyo Aug 12, 2024
19273bf
update yarn generate script
pablomendezroyo Aug 13, 2024
59b2ea9
use tsx instead of ts-node in mocha configs
pablomendezroyo Aug 13, 2024
8ac8bb0
remove ts-node from tsconfig's
pablomendezroyo Aug 13, 2024
90085e1
remove ts-node dep from root
pablomendezroyo Aug 13, 2024
5779322
bump timeout
pablomendezroyo Aug 13, 2024
5b10564
add rewiremock to dockerapi
pablomendezroyo Aug 13, 2024
0a31e61
migrate from docker-compose to docker compose
pablomendezroyo Aug 13, 2024
2b88075
fix rewiuremock imports
pablomendezroyo Aug 13, 2024
39d24a5
remove unused var
pablomendezroyo Aug 13, 2024
ebc36b3
remove unused vars
pablomendezroyo Aug 14, 2024
3184931
use assert type json
pablomendezroyo Aug 14, 2024
2211f95
use node LTS 20
pablomendezroyo Aug 14, 2024
ac15270
fix dev mode
pablomendezroyo Aug 14, 2024
6e32b41
install deps in dev mode
pablomendezroyo Aug 14, 2024
7560e85
add missing yarn
pablomendezroyo Aug 14, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: npx @dappnode/dappnodesdk github-action build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
24 changes: 14 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: "Main"
on:
workflow_dispatch:
branches:
- "master"
paths-ignore:
- "README.md"
inputs:
bump:
description: "Bump type, it must be: patch | minor | major"
Expand All @@ -25,9 +21,11 @@ jobs:
runs-on: ubuntu-latest
name: Unit tests
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Enable Corepack
run: corepack enable
- name: Setup node
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: "20"
- run: yarn
Expand All @@ -43,11 +41,14 @@ jobs:
runs-on: ubuntu-latest
name: In app integration tests
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Enable Corepack
run: corepack enable
- name: Setup node
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"
- run: yarn # Caching only saves 30s
- run: yarn build
- run: yarn test:int
Expand All @@ -62,11 +63,14 @@ jobs:
run: |
[[ "$BUMP_TYPE" == "patch" ]] || [[ "$BUMP_TYPE" == "minor" ]] || \
[[ "$BUMP_TYPE" == "major" ]] || { echo "Wrong input, it must be: patch | minor | major"; exit 1;}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Enable Corepack
run: corepack enable
- name: Setup node
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"
- name: Publish
run: npx @dappnode/dappnodesdk publish ${BUMP_TYPE} --dappnode_team_preset
env:
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/netlify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
# Setup node version 14 for node-sass 4.14 https://stackoverflow.com/questions/60394291/error-node-modules-node-sass-command-failed
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- name: Enable Corepack
run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: "20"
# Install dependencies
node-version: "22"
cache: "yarn"
- run: yarn install
# Generate schemas
- run: yarn build
# Build
- run: yarn mock-standalone:build
# Deploy
- name: Deploy to Netlify
uses: nwtgck/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
node-version: "22"
registry-url: "https://registry.npmjs.org"

- name: Install dependencies and build
Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ node_modules/\.yarn-integrity
# Typescript build artifacts
build/src/dist/
build/src/.temp-transfer/
packages/*/tsconfig.tsbuildinfo

# Common
packages/*/node_modules/
Expand All @@ -58,4 +59,8 @@ packages/dappmanager/dnp_repo
packages/toolkit/truffle/contracts_build/*

# docker tmp
docker-compose-tmp.yml
docker-compose-tmp.yml

# yarn berry
.yarn/install-state.gz
.yarn/releases
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
32 changes: 17 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
# Arguments
ARG NODE_VERSION=20.3.0
ARG BASE_IMAGE=node:${NODE_VERSION}-alpine3.18
ARG BASE_IMAGE=node:20.16.0-alpine3.19
ARG BUILDPLATFORM

# Initial stage to gather git data
FROM --platform=${BUILDPLATFORM:-amd64} ${BASE_IMAGE} AS git-data
FROM ${BASE_IMAGE} AS git-data
WORKDIR /usr/src/app
RUN apk add --no-cache git
COPY .git dappnode_package.json docker/getGitData.js ./
RUN apk add --no-cache git
RUN node getGitData /usr/src/app/.git-data.json

# Build stage
FROM --platform=${BUILDPLATFORM:-amd64} ${BASE_IMAGE} AS build-src
FROM ${BASE_IMAGE} AS build-src
ENV VITE_APP_API_URL /
WORKDIR /app

# Install necessary packages required by vite
RUN apk add --no-cache python3 py3-pip build-base

# Copy and build packages
COPY package.json yarn.lock lerna.json tsconfig.json ./
COPY package.json yarn.lock .yarnrc.yml tsconfig.json ./
COPY packages packages
ENV VITE_APP_API_URL /
RUN yarn install --non-interactive --frozen-lockfile && \
yarn build && \
yarn clean:libraries && \
yarn install --non-interactive --frozen-lockfile --production --force --ignore-optional

# Install necessary packages required by vite
RUN apk add --no-cache python3 py3-pip build-base
# Install corepack to be able to use modern yarn berry
RUN corepack enable
RUN yarn install --immutable
# Build and install production dependencies
RUN yarn build && \
yarn workspaces focus --all --production
# Remove unnecessary files
RUN rm -rf yarn.lock packages/*/src packages/*/tsconfig.json packages/*/.eslint*

# Production stage
FROM node:${NODE_VERSION}-alpine
FROM ${BASE_IMAGE}
WORKDIR /usr/src/app

# Environment variables
Expand Down
36 changes: 14 additions & 22 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,44 +1,36 @@
ARG NODE_VERSION=20.3.0

# Common base so it's cached
# --platform=$BUILDPLATFORM is used build javascript source with host arch
# Otherwise webpack builds on emulated archs can be extremely slow (+1h)
ARG BASE_IMAGE=node:${NODE_VERSION}-alpine
ARG NODE_VERSION=20.16.0
ARG BASE_IMAGE=node:${NODE_VERSION}-alpine3.19

# Initial stage to gather git data
FROM --platform=${BUILDPLATFORM:-amd64} ${BASE_IMAGE} AS git-data
FROM ${BASE_IMAGE} AS git-data
WORKDIR /usr/src/app
RUN apk add --no-cache git python3 py3-pip build-base
COPY .git dappnode_package.json docker/getGitData.js ./
RUN apk add --no-cache git python3 py3-pip build-base
RUN node getGitData /usr/src/app/.git-data.json


# Build + Prod stage
FROM node:${NODE_VERSION}-alpine
FROM ${BASE_IMAGE}
ENV COMPOSE_HTTP_TIMEOUT=300 \
DOCKER_CLIENT_TIMEOUT=300 \
DOCKER_HOST=unix:///var/run/docker.sock \
UI_FILES_PATH=/app/packages/admin-ui/build \
GIT_DATA_PATH=.git-data.json \
TEST=true \
VITE_APP_API_URL=http://my.dappnode:5000/

WORKDIR /app

RUN apk update && apk add --no-cache docker curl docker-cli-compose xz zip unzip libltdl bash git bind bind-tools bind-dev \
miniupnpc dbus tmux avahi-tools
RUN corepack enable

# Copy git data
COPY --from=git-data /usr/src/app/.git-data.json $GIT_DATA_PATH

COPY docker/start_dev.sh /usr/src/app/start_dev.sh

# Build the src code:
# Copy and install deps first to cache
COPY package.json yarn.lock lerna.json tsconfig.json ./
COPY package.json yarn.lock .yarnrc.yml tsconfig.json ./
COPY packages packages

RUN yarn --frozen-lockfile --non-interactive

ENV VITE_APP_API_URL /
RUN yarn build

ENTRYPOINT [ "/usr/src/app/start_dev.sh" ]
# link instructions must be executed in runtime due to the way the volumes are mounted
ENTRYPOINT ["/bin/sh", "-c", "ln -sf /app/packages/admin-ui/build/ /app/packages/dappmanager/dist && \
ln -sf /usr/src/app/dnp_repo/ /app/packages/dappmanager && \
ln -sf /usr/src/app/DNCORE/ /app/packages/dappmanager && \
yarn && yarn build && yarn run dev"]
17 changes: 0 additions & 17 deletions docker/start_dev.sh

This file was deleted.

6 changes: 0 additions & 6 deletions lerna.json

This file was deleted.

36 changes: 15 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,33 @@
"engines": {
"node": "20.x"
},
"workspaces": {
"packages": [
"packages/*"
]
},
"workspaces": [
"packages/*"
],
"scripts": {
"build": "lerna run build --include-dependencies --stream",
"test": "lerna run test --stream",
"lint": "lerna run lint --stream",
"test:int": "lerna run test:int --stream",
"pre-commit": "lerna run pre-commit --stream",
"mock-standalone:build": "lerna run mock-standalone:build --stream",
"generate": "lerna run generate --stream",
"clean": "yarn run clean:build && yarn run clean:libraries",
"clean:libraries": "rimraf packages/**/node_modules && rimraf node_modules",
"clean:build": "rimraf packages/**/dist && rimraf packages/**/build"
"build": "yarn workspaces foreach --all -pt run build",
"test": "yarn workspaces foreach --all -pt run test",
"test:int": "yarn workspaces foreach --all -pt run test:int",
"dev": "yarn workspaces foreach --all -pi -j unlimited run dev",
"lint": "yarn workspaces foreach --all -pt run lint",
"mock-standalone:build": "yarn workspace @dappnode/admin-ui run mock-standalone:build",
"generate": "yarn workspace @dappnode/common run generate"
},
"dependencies": {},
"devDependencies": {
"@types/chai": "^4.3.11",
"@types/mocha": "^10.0.6",
"@types/node": "^20.14.10",
"@types/node": "^22.2.0",
"@typescript-eslint/eslint-plugin": "^5.61.0",
"@typescript-eslint/parser": "^5.61.0",
"chai": "^4.3.10",
"depcheck": "^1.4.7",
"eslint": "^8.44.0",
"eslint-config-react-app": "^7.0.1",
"lerna": "^6.3.0",
"mocha": "^10.2.0",
"nodemon": "^3.0.2",
"rimraf": "^3.0.2",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
}
"tsx": "^4.17.0",
"typescript": "^5.5.4"
},
"packageManager": "[email protected]"
}
9 changes: 4 additions & 5 deletions packages/admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@
"analyze": "npx source-map-explorer build/static/js/main.*",
"lint": "eslint --ext ts,tsx,js,jsx --fix src",
"prettier": "prettier --write 'src/**/*.*'",
"pre-commit": "yarn lint && CI=true yarn test",
"mock": "VITE_APP_API_URL=http://localhost:5000 yarn start",
"server-mock": "PORT=5000 nodemon server-mock/index.ts",
"server-mock:check-types": "tsc --noEmit --project tsconfig.server-mock.json",
"mock-standalone": "VITE_APP_MOCK=true yarn start",
"mock-standalone:build": "VITE_APP_MOCK=true yarn build",
"dev": "VITE_APP_API_TEST=true nodemon --ignore \"*.json\" -e ts,tsx --watch src/ --exec \"yarn build\""
"dev": "VITE_APP_API_TEST=true vite build --watch"
},
"dependencies": {
"@dappnode/common": "^0.1.0",
"@dappnode/common": "workspace:^0.1.0",
"@dappnode/dappmanager": "^0.1.0",
"@dappnode/eventbus": "^0.1.0",
"@dappnode/types": "^0.1.36",
"@dappnode/eventbus": "workspace:^0.1.0",
"@dappnode/types": "workspace:^0.1.0",
"@reduxjs/toolkit": "^1.3.5",
"@types/clipboard": "^2.0.7",
"@types/node": "^20.14.10",
Expand Down
8 changes: 4 additions & 4 deletions packages/admin-ui/server-mock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const subscriptionsLogger: LoggerMiddleware = {
onError: (route, error) => console.log("Subscription error", route, error)
};

const adminPasswordDb = startHttpApi({
startHttpApi({
params,
logs: {
debug: console.log,
Expand All @@ -55,13 +55,13 @@ const adminPasswordDb = startHttpApi({
sign: () => {},
upload: () => {}
},
limiterMiddleware: (req, res, next) => {
limiterMiddleware: (_req, _res, next) => {
next();
},
counterViewsMiddleware: (req, res, next) => {
counterViewsMiddleware: (_req, _res, next) => {
next();
},
ethForwardMiddleware: (req, res, next) => {
ethForwardMiddleware: (_req, _res, next) => {
next();
},
methods: calls,
Expand Down
10 changes: 6 additions & 4 deletions packages/admin-ui/server-mock/mockVpnClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,19 @@ export class MockVpnApiClient implements VpnApiClient {
this.devices.delete(id);
}

async resetDevice({ id }: { id: string }): Promise<void> {
async resetDevice(): Promise<void> {
//
}

async listDevices(): Promise<{ id: string; admin: boolean }[]> {
return Array.from(this.devices.values());
}

async getDeviceCredentials(kwargs: {
id: string;
}): Promise<{ filename: string; key: string; url: string }> {
async getDeviceCredentials(): Promise<{
filename: string;
key: string;
url: string;
}> {
return { filename: "00000", key: "0000000", url };
}

Expand Down
Loading
Loading