-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Containerize tool with automatic file watcher
- Loading branch information
Showing
13 changed files
with
325 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: docker | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install GitVersion | ||
uses: gittools/actions/gitversion/[email protected] | ||
with: | ||
versionSpec: '5.x' | ||
|
||
- name: Run GitVersion | ||
uses: gittools/actions/gitversion/[email protected] | ||
with: | ||
useConfigFile: true | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: | | ||
dickwolff/export-to-ghostfolio:latest | ||
dickwolff/export-to-ghostfolio:${{ env.GitVersion_MajorMinorPatch }} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM node:20-alpine3.19 | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
|
||
RUN npm install | ||
|
||
RUN mkdir /var/e2g-input | ||
RUN mkdir /var/e2g-output | ||
|
||
ENTRYPOINT [ "npm" ] | ||
CMD ["run", "watch"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
next-version: 0.3.0 | ||
assembly-informational-format: "{NuGetVersion}" | ||
mode: ContinuousDeployment | ||
branches: | ||
master: | ||
regex: main | ||
mode: ContinuousDelivery | ||
tag: "" | ||
increment: Patch | ||
feature: | ||
regex: ^feature?[/-] | ||
mode: ContinuousDelivery | ||
tag: "" | ||
increment: Patch | ||
source-branches: ["main"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import path from "path"; | ||
import * as fs from "fs"; | ||
import { GhostfolioExport } from "./models/ghostfolioExport"; | ||
import { DeGiroConverter } from "./converters/degiroConverter"; | ||
import { SchwabConverter } from "./converters/schwabConverter"; | ||
import { DeGiroConverterV2 } from "./converters/degiroConverterV2"; | ||
import { AbstractConverter } from "./converters/abstractconverter"; | ||
import { Trading212Converter } from "./converters/trading212Converter"; | ||
import { SwissquoteConverter } from "./converters/swissquoteConverter"; | ||
import { FinpensionConverter } from "./converters/finpensionConverter"; | ||
|
||
export function createAndRunConverter(converterType: string, inputFilePath: string, outputFilePath: string, completionCallback: CallableFunction, errorCallback: CallableFunction) { | ||
|
||
// Verify if Ghostolio account ID is set (because without it there can be no valid output). | ||
if (!process.env.GHOSTFOLIO_ACCOUNT_ID) { | ||
return errorCallback(new Error("Environment variable GHOSTFOLIO_ACCOUNT_ID not set!")); | ||
} | ||
|
||
const converterTypeLc = converterType.toLocaleLowerCase(); | ||
|
||
// Determine convertor type. | ||
const converter = createConverter(converterTypeLc); | ||
|
||
// Map the file to a Ghostfolio import. | ||
converter.readAndProcessFile(inputFilePath, (result: GhostfolioExport) => { | ||
|
||
console.log("[i] Processing complete, writing to file..") | ||
|
||
// Write result to file. | ||
const outputFileName = path.join(outputFilePath, `ghostfolio-${converterTypeLc}.json`); | ||
const fileContents = JSON.stringify(result); | ||
fs.writeFileSync(outputFileName, fileContents, { encoding: "utf-8" }); | ||
|
||
console.log(`[i] Wrote data to '${outputFileName}.json'!`); | ||
|
||
completionCallback(); | ||
|
||
}, (error) => errorCallback(error)); | ||
} | ||
|
||
function createConverter(converterType: string): AbstractConverter { | ||
|
||
let converter: AbstractConverter; | ||
|
||
switch (converterType) { | ||
case "t212": | ||
case "trading212": | ||
console.log("[i] Processing file using Trading212 converter"); | ||
converter = new Trading212Converter(); | ||
break; | ||
case "degiro": | ||
console.log("[i] Processing file using DeGiro converter"); | ||
console.log("[i] NOTE: There is a new version available of the DeGiro converter"); | ||
console.log("[i] The new converter has multiple record parsing improvements and also supports platform fees."); | ||
console.log("[i] The new converter is currently in beta and we're looking for your feedback!"); | ||
console.log("[i] You can run the beta converter with the command 'npm run start degiro-v2'."); | ||
converter = new DeGiroConverter(); | ||
break; | ||
case "degiro-v2": | ||
console.log("[i] Processing file using DeGiro converter (V2 Beta)"); | ||
console.log("[i] NOTE: You are running a converter that is currently in beta."); | ||
console.log("[i] If you have any issues, please report them on GitHub. Many thanks!"); | ||
converter = new DeGiroConverterV2(); | ||
break; | ||
case "fp": | ||
case "finpension": | ||
console.log("[i] Processing file using Finpension converter"); | ||
converter = new FinpensionConverter(); | ||
break; | ||
case "sq": | ||
case "swissquote": | ||
console.log("[i] Processing file using Swissquote converter"); | ||
converter = new SwissquoteConverter(); | ||
break; | ||
case "schwab": | ||
console.log("[i] Processing file using Schwab converter"); | ||
converter = new SchwabConverter(); | ||
break; | ||
default: | ||
throw new Error(`Unknown converter '${converterType}' provided`); | ||
} | ||
|
||
return converter; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { SchwabConverter } from "./schwabConverter"; | ||
|
||
describe("SchwabConverter", () => { | ||
|
||
it("should construct", () => { | ||
|
||
// Act | ||
const sut = new SchwabConverter(); | ||
|
||
// Asssert | ||
expect(sut).toBeTruthy(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { createAndRunConverter } from "./converter"; | ||
|
||
// Check if converter was specified. | ||
if (process.argv.length != 3) { | ||
console.log("[e] Invalid run command: converter not specified!");; | ||
} | ||
else { | ||
|
||
require("dotenv").config(); | ||
|
||
// Define import file path. | ||
const inputFile = process.env.INPUT_FILE; | ||
|
||
// Determine convertor type and run conversion. | ||
createAndRunConverter(process.argv[2].toLocaleLowerCase(), inputFile, ".", () => { }, () => { }); | ||
} |
Oops, something went wrong.