Browse Source

Merge branch 'main' into docker-best-practices

Signed-off-by: rare-magma <rare-magma@posteo.eu>
pull/3614/head
rare-magma 1 year ago
parent
commit
5c36a8d95b
Failed to extract signature
  1. 10
      .github/workflows/build-code.yml
  2. 4
      .gitignore
  3. 1
      .yarnrc
  4. 14
      CHANGELOG.md
  5. 12
      DEVELOPMENT.md
  6. 21
      Dockerfile
  7. 17
      README.md
  8. 8
      apps/api/src/app/import/import.service.ts
  9. 16
      apps/api/src/services/data-provider/data-provider.service.ts
  10. 6
      git-hooks/pre-commit
  11. 34039
      package-lock.json
  12. 26
      package.json
  13. 21549
      yarn.lock

10
.github/workflows/build-code.yml

@ -24,16 +24,16 @@ jobs:
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: ${{ matrix.node_version }} node-version: ${{ matrix.node_version }}
cache: 'yarn' cache: 'npm'
- name: Install dependencies - name: Install dependencies
run: yarn install --frozen-lockfile run: npm ci
- name: Check formatting - name: Check formatting
run: yarn format:check run: npm run format:check
- name: Execute tests - name: Execute tests
run: yarn test run: npm test
- name: Build application - name: Build application
run: yarn build:production run: npm run build:production

4
.gitignore

@ -5,8 +5,8 @@
/tmp /tmp
# dependencies # dependencies
/.yarn
/node_modules /node_modules
npm-debug.log
# IDEs and editors # IDEs and editors
/.idea /.idea
@ -34,10 +34,8 @@
/coverage /coverage
/dist /dist
/libpeerconnection.log /libpeerconnection.log
npm-debug.log
testem.log testem.log
/typings /typings
yarn-error.log
# System Files # System Files
.DS_Store .DS_Store

1
.yarnrc

@ -1 +0,0 @@
network-timeout 600000

14
CHANGELOG.md

@ -5,7 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased ## 2.99.0 - 2024-07-29
### Changed
- Migrated the usage of `yarn` to `npm`
- Upgraded `storybook` from version `7.0.9` to `8.2.5`
- Downgraded `marked` from version `13.0.0` to `12.0.2`
## 2.98.0 - 2024-07-27
### Added ### Added
@ -13,8 +21,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Improved the handling of the numerical precision in the value component
- Improved the account selector of the create or update activity dialog - Improved the account selector of the create or update activity dialog
- Improved the handling of the numerical precision in the value component
- Skipped derived currencies in the get quotes functionality of the data provider service
- Improved the language localization for Spanish (`es`) - Improved the language localization for Spanish (`es`)
- Upgraded `angular` from version `18.0.4` to `18.1.1` - Upgraded `angular` from version `18.0.4` to `18.1.1`
- Upgraded `Nx` from version `19.4.3` to `19.5.1` - Upgraded `Nx` from version `19.4.3` to `19.5.1`
@ -22,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Fixed the dividend import from a data provider for holdings without an account
- Fixed an issue in the public page related to a non-existent access - Fixed an issue in the public page related to a non-existent access
## 2.97.0 - 2024-07-20 ## 2.97.0 - 2024-07-20

12
DEVELOPMENT.md

@ -30,26 +30,26 @@ Use `@if (user?.settings?.isExperimentalFeatures) {}` in HTML template
#### Upgrade #### Upgrade
1. Run `yarn nx migrate latest` 1. Run `npx nx migrate latest`
1. Make sure `package.json` changes make sense and then run `yarn install` 1. Make sure `package.json` changes make sense and then run `npm install`
1. Run `yarn nx migrate --run-migrations` (Run `YARN_NODE_LINKER="node-modules" NX_MIGRATE_SKIP_INSTALL=1 yarn nx migrate --run-migrations` due to https://github.com/nrwl/nx/issues/16338) 1. Run `npx nx migrate --run-migrations`
### Prisma ### Prisma
#### Access database via GUI #### Access database via GUI
Run `yarn database:gui` Run `npm run database:gui`
https://www.prisma.io/studio https://www.prisma.io/studio
#### Synchronize schema with database for prototyping #### Synchronize schema with database for prototyping
Run `yarn database:push` Run `npm run database:push`
https://www.prisma.io/docs/concepts/components/prisma-migrate/db-push https://www.prisma.io/docs/concepts/components/prisma-migrate/db-push
#### Create schema migration #### Create schema migration
Run `yarn prisma migrate dev --name added_job_title` Run `npm run prisma migrate dev --name added_job_title`
https://www.prisma.io/docs/concepts/components/prisma-migrate#getting-started-with-prisma-migrate https://www.prisma.io/docs/concepts/components/prisma-migrate#getting-started-with-prisma-migrate

21
Dockerfile

@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM node:20-slim as builder FROM --platform=$BUILDPLATFORM node:20-slim AS builder
# Build application and add additional files # Build application and add additional files
WORKDIR /ghostfolio WORKDIR /ghostfolio
@ -8,8 +8,7 @@ WORKDIR /ghostfolio
COPY ./CHANGELOG.md CHANGELOG.md COPY ./CHANGELOG.md CHANGELOG.md
COPY ./LICENSE LICENSE COPY ./LICENSE LICENSE
COPY ./package.json package.json COPY ./package.json package.json
COPY ./yarn.lock yarn.lock COPY ./package-lock.json package-lock.json
COPY ./.yarnrc .yarnrc
COPY ./prisma/schema.prisma prisma/schema.prisma COPY ./prisma/schema.prisma prisma/schema.prisma
RUN apt-get update && apt-get install -y --no-install-suggests \ RUN apt-get update && apt-get install -y --no-install-suggests \
@ -19,7 +18,7 @@ RUN apt-get update && apt-get install -y --no-install-suggests \
openssl \ openssl \
python3 \ python3 \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
RUN yarn install RUN npm install
# See https://github.com/nrwl/nx/issues/6586 for further details # See https://github.com/nrwl/nx/issues/6586 for further details
COPY ./decorate-angular-cli.js decorate-angular-cli.js COPY ./decorate-angular-cli.js decorate-angular-cli.js
@ -33,28 +32,30 @@ COPY ./tsconfig.base.json tsconfig.base.json
COPY ./libs libs COPY ./libs libs
COPY ./apps apps COPY ./apps apps
RUN yarn build:production RUN npm run build:production
# Prepare the dist image with additional node_modules # Prepare the dist image with additional node_modules
WORKDIR /ghostfolio/dist/apps/api WORKDIR /ghostfolio/dist/apps/api
# package.json was generated by the build process, however the original # package.json was generated by the build process, however the original
yarn.lock needs to be used to ensure the same versions package-lock.json needs to be used to ensure the same versions
COPY ./yarn.lock /ghostfolio/dist/apps/api/yarn.lock COPY ./package-lock.json /ghostfolio/dist/apps/api/package-lock.json
RUN yarn RUN npm install
COPY prisma /ghostfolio/dist/apps/api/prisma COPY prisma /ghostfolio/dist/apps/api/prisma
# Overwrite the generated package.json with the original one to ensure having # Overwrite the generated package.json with the original one to ensure having
# all the scripts # all the scripts
COPY package.json /ghostfolio/dist/apps/api COPY package.json /ghostfolio/dist/apps/api
RUN yarn database:generate-typings RUN npm run database:generate-typings
# Image to run, copy everything needed from builder # Image to run, copy everything needed from builder
FROM node:20-slim FROM node:20-slim
LABEL org.opencontainers.image.source="https://github.com/ghostfolio/ghostfolio" LABEL org.opencontainers.image.source="https://github.com/ghostfolio/ghostfolio"
ENV NODE_ENV=production ENV NODE_ENV=production
RUN apt-get update && apt-get install -y openssl curl \ RUN apt-get update && apt-get install -y --no-install-suggests \
curl \
openssl \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
COPY --from=builder /ghostfolio/dist/apps /ghostfolio/apps COPY --from=builder /ghostfolio/dist/apps /ghostfolio/apps

17
README.md

@ -150,15 +150,14 @@ Ghostfolio is available for various home server systems, including [CasaOS](http
- [Docker](https://www.docker.com/products/docker-desktop) - [Docker](https://www.docker.com/products/docker-desktop)
- [Node.js](https://nodejs.org/en/download) (version 20+) - [Node.js](https://nodejs.org/en/download) (version 20+)
- [Yarn](https://yarnpkg.com/en/docs/install)
- Create a local copy of this Git repository (clone) - Create a local copy of this Git repository (clone)
- Copy the file `.env.dev` to `.env` and populate it with your data (`cp .env.dev .env`) - Copy the file `.env.dev` to `.env` and populate it with your data (`cp .env.dev .env`)
### Setup ### Setup
1. Run `yarn install` 1. Run `npm install`
1. Run `docker compose --env-file ./.env -f docker/docker-compose.dev.yml up -d` to start [PostgreSQL](https://www.postgresql.org) and [Redis](https://redis.io) 1. Run `docker compose --env-file ./.env -f docker/docker-compose.dev.yml up -d` to start [PostgreSQL](https://www.postgresql.org) and [Redis](https://redis.io)
1. Run `yarn database:setup` to initialize the database schema 1. Run `npm run database:setup` to initialize the database schema
1. Run `git config core.hooksPath ./git-hooks/` to setup git hooks 1. Run `git config core.hooksPath ./git-hooks/` to setup git hooks
1. Start the server and the client (see [_Development_](#Development)) 1. Start the server and the client (see [_Development_](#Development))
1. Open https://localhost:4200/en in your browser 1. Open https://localhost:4200/en in your browser
@ -168,31 +167,31 @@ Ghostfolio is available for various home server systems, including [CasaOS](http
#### Debug #### Debug
Run `yarn watch:server` and click _Debug API_ in [Visual Studio Code](https://code.visualstudio.com) Run `npm run watch:server` and click _Debug API_ in [Visual Studio Code](https://code.visualstudio.com)
#### Serve #### Serve
Run `yarn start:server` Run `npm run start:server`
### Start Client ### Start Client
Run `yarn start:client` and open https://localhost:4200/en in your browser Run `npm run start:client` and open https://localhost:4200/en in your browser
### Start _Storybook_ ### Start _Storybook_
Run `yarn start:storybook` Run `npm run start:storybook`
### Migrate Database ### Migrate Database
With the following command you can keep your database schema in sync: With the following command you can keep your database schema in sync:
```bash ```bash
yarn database:push npm run database:push
``` ```
## Testing ## Testing
Run `yarn test` Run `npm test`
## Public API ## Public API

8
apps/api/src/app/import/import.service.ts

@ -72,8 +72,12 @@ export class ImportService {
}) })
]); ]);
const accounts = orders.map((order) => { const accounts = orders
return order.Account; .filter(({ Account }) => {
return !!Account;
})
.map(({ Account }) => {
return Account;
}); });
const Account = this.isUniqueAccount(accounts) ? accounts[0] : undefined; const Account = this.isUniqueAccount(accounts) ? accounts[0] : undefined;

16
apps/api/src/services/data-provider/data-provider.service.ts

@ -14,7 +14,12 @@ import {
DERIVED_CURRENCIES, DERIVED_CURRENCIES,
PROPERTY_DATA_SOURCE_MAPPING PROPERTY_DATA_SOURCE_MAPPING
} from '@ghostfolio/common/config'; } from '@ghostfolio/common/config';
import { DATE_FORMAT, getStartOfUtcDate } from '@ghostfolio/common/helper'; import {
DATE_FORMAT,
getCurrencyFromSymbol,
getStartOfUtcDate,
isDerivedCurrency
} from '@ghostfolio/common/helper';
import { UniqueAsset } from '@ghostfolio/common/interfaces'; import { UniqueAsset } from '@ghostfolio/common/interfaces';
import type { Granularity, UserWithSettings } from '@ghostfolio/common/types'; import type { Granularity, UserWithSettings } from '@ghostfolio/common/types';
@ -423,13 +428,18 @@ export class DataProviderService {
continue; continue;
} }
const symbols = dataGatheringItems.map((dataGatheringItem) => { const symbols = dataGatheringItems
return dataGatheringItem.symbol; .filter(({ symbol }) => {
return !isDerivedCurrency(getCurrencyFromSymbol(symbol));
})
.map(({ symbol }) => {
return symbol;
}); });
const maximumNumberOfSymbolsPerRequest = const maximumNumberOfSymbolsPerRequest =
dataProvider.getMaxNumberOfSymbolsPerRequest?.() ?? dataProvider.getMaxNumberOfSymbolsPerRequest?.() ??
Number.MAX_SAFE_INTEGER; Number.MAX_SAFE_INTEGER;
for ( for (
let i = 0; let i = 0;
i < symbols.length; i < symbols.length;

6
git-hooks/pre-commit

@ -1,11 +1,11 @@
#!/bin/bash #!/bin/bash
# Will check if "yarn format" is run before executing. # Will check if "npm run format" is run before executing.
# Called by "git commit" with no arguments. The hook should # Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if # exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit. # it wants to stop the commit.
echo "Running yarn format" echo "Running npm run format"
# Run the command and loop over its output # Run the command and loop over its output
FILES_TO_STAGE="" FILES_TO_STAGE=""
@ -21,6 +21,6 @@ while IFS= read -r line; do
fi fi
FILES_TO_STAGE="$FILES_TO_STAGE $line" FILES_TO_STAGE="$FILES_TO_STAGE $line"
done < <(yarn format ) done < <(npm run format)
git add $FILES_TO_STAGE git add $FILES_TO_STAGE
echo "Files formatted. Committing..." echo "Files formatted. Committing..."

34039
package-lock.json

File diff suppressed because it is too large

26
package.json

@ -1,6 +1,6 @@
{ {
"name": "ghostfolio", "name": "ghostfolio",
"version": "2.97.0", "version": "2.99.0",
"homepage": "https://ghostfol.io", "homepage": "https://ghostfol.io",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"repository": "https://github.com/ghostfolio/ghostfolio", "repository": "https://github.com/ghostfolio/ghostfolio",
@ -15,7 +15,7 @@
"affected:test": "nx affected:test", "affected:test": "nx affected:test",
"analyze:client": "nx run client:build:production --stats-json && webpack-bundle-analyzer -p 1234 dist/apps/client/en/stats.json", "analyze:client": "nx run client:build:production --stats-json && webpack-bundle-analyzer -p 1234 dist/apps/client/en/stats.json",
"angular": "node --max_old_space_size=32768 ./node_modules/@angular/cli/bin/ng", "angular": "node --max_old_space_size=32768 ./node_modules/@angular/cli/bin/ng",
"build:production": "nx run api:copy-assets && nx run api:build:production && nx run client:copy-assets && nx run client:build:production && yarn replace-placeholders-in-build", "build:production": "nx run api:copy-assets && nx run api:build:production && nx run client:copy-assets && nx run client:build:production && npm run replace-placeholders-in-build",
"build:storybook": "nx run ui:build-storybook", "build:storybook": "nx run ui:build-storybook",
"database:format-schema": "prisma format", "database:format-schema": "prisma format",
"database:generate-typings": "prisma generate", "database:generate-typings": "prisma generate",
@ -24,7 +24,7 @@
"database:migrate": "prisma migrate deploy", "database:migrate": "prisma migrate deploy",
"database:push": "prisma db push", "database:push": "prisma db push",
"database:seed": "prisma db seed", "database:seed": "prisma db seed",
"database:setup": "yarn database:push && yarn database:seed", "database:setup": "npm run database:push && npm run database:seed",
"database:validate-schema": "prisma validate", "database:validate-schema": "prisma validate",
"dep-graph": "nx dep-graph", "dep-graph": "nx dep-graph",
"e2e": "ng e2e", "e2e": "ng e2e",
@ -40,10 +40,10 @@
"replace-placeholders-in-build": "node ./replace.build.js", "replace-placeholders-in-build": "node ./replace.build.js",
"start": "node dist/apps/api/main", "start": "node dist/apps/api/main",
"start:client": "nx run client:copy-assets && nx run client:serve --configuration=development-en --hmr -o", "start:client": "nx run client:copy-assets && nx run client:serve --configuration=development-en --hmr -o",
"start:production": "yarn database:migrate && yarn database:seed && node main", "start:production": "npm run database:migrate && npm run database:seed && node main",
"start:server": "nx run api:copy-assets && nx run api:serve --watch", "start:server": "nx run api:copy-assets && nx run api:serve --watch",
"start:storybook": "nx run ui:storybook", "start:storybook": "nx run ui:storybook",
"test": "yarn test:api && yarn test:common", "test": "npm run test:api && npm run test:common",
"test:api": "npx dotenv-cli -e .env.example -- nx test api", "test:api": "npx dotenv-cli -e .env.example -- nx test api",
"test:common": "npx dotenv-cli -e .env.example -- nx test common", "test:common": "npx dotenv-cli -e .env.example -- nx test common",
"test:single": "nx run api:test --test-file portfolio-calculator-novn-buy-and-sell.spec.ts", "test:single": "nx run api:test --test-file portfolio-calculator-novn-buy-and-sell.spec.ts",
@ -116,7 +116,7 @@
"ionicons": "7.4.0", "ionicons": "7.4.0",
"jsonpath": "1.1.1", "jsonpath": "1.1.1",
"lodash": "4.17.21", "lodash": "4.17.21",
"marked": "13.0.0", "marked": "12.0.2",
"ms": "3.0.0-canary.1", "ms": "3.0.0-canary.1",
"ng-extract-i18n-merge": "2.12.0", "ng-extract-i18n-merge": "2.12.0",
"ngx-device-detector": "8.0.0", "ngx-device-detector": "8.0.0",
@ -164,9 +164,9 @@
"@nx/workspace": "19.5.1", "@nx/workspace": "19.5.1",
"@schematics/angular": "18.1.1", "@schematics/angular": "18.1.1",
"@simplewebauthn/types": "9.0.1", "@simplewebauthn/types": "9.0.1",
"@storybook/addon-essentials": "7.6.5", "@storybook/addon-essentials": "8.2.6",
"@storybook/angular": "7.6.5", "@storybook/angular": "8.2.6",
"@storybook/core-server": "7.6.5", "@storybook/core-server": "8.2.6",
"@trivago/prettier-plugin-sort-imports": "4.3.0", "@trivago/prettier-plugin-sort-imports": "4.3.0",
"@types/big.js": "6.2.2", "@types/big.js": "6.2.2",
"@types/body-parser": "1.19.5", "@types/body-parser": "1.19.5",
@ -182,13 +182,13 @@
"@typescript-eslint/parser": "6.21.0", "@typescript-eslint/parser": "6.21.0",
"codelyzer": "6.0.1", "codelyzer": "6.0.1",
"cypress": "6.2.1", "cypress": "6.2.1",
"eslint": "8.56.0", "eslint": "8.57.0",
"eslint-config-prettier": "9.1.0", "eslint-config-prettier": "9.1.0",
"eslint-plugin-cypress": "2.15.1", "eslint-plugin-cypress": "2.15.1",
"eslint-plugin-import": "2.29.1", "eslint-plugin-import": "2.29.1",
"eslint-plugin-storybook": "0.6.15", "eslint-plugin-storybook": "0.6.15",
"jest": "29.4.3", "jest": "29.7.0",
"jest-environment-jsdom": "29.4.3", "jest-environment-jsdom": "29.7.0",
"jest-preset-angular": "14.1.0", "jest-preset-angular": "14.1.0",
"nx": "19.5.1", "nx": "19.5.1",
"prettier": "3.3.3", "prettier": "3.3.3",
@ -197,7 +197,7 @@
"react-dom": "18.2.0", "react-dom": "18.2.0",
"replace-in-file": "7.0.1", "replace-in-file": "7.0.1",
"shx": "0.3.4", "shx": "0.3.4",
"storybook": "7.0.9", "storybook": "8.2.6",
"ts-jest": "29.1.0", "ts-jest": "29.1.0",
"ts-node": "10.9.2", "ts-node": "10.9.2",
"tslib": "2.6.0", "tslib": "2.6.0",

21549
yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save