-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from bludnic/feat/build
Feat/build
- Loading branch information
Showing
477 changed files
with
9,813 additions
and
1,677 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 |
---|---|---|
|
@@ -4,12 +4,16 @@ NEXT_PUBLIC_PROCESSOR_URL="http://localhost:4000" | |
# If `true`, then tRPC will be provided by `processor` app. | ||
# If `false`, then `frontend` app will instantiate the tRPC client by itself using Next API Routes | ||
# Accepts: "true" | "" | ||
NEXT_PUBLIC_PROCESSOR_ENABLE_TRPC= | ||
NEXT_PUBLIC_PROCESSOR_ENABLE_TRPC=true | ||
# Build NextJS as a static app (`export`) instead of `standalone` | ||
# Accepts: "true" | "" | ||
NEXT_PUBLIC_STATIC= | ||
DATABASE_URL="postgresql://postgres:[email protected]:5432/postgres" | ||
# Relative to packages/prisma/src | ||
DATABASE_URL="file:../../../dev.db" | ||
ADMIN_PASSWORD=opentrader | ||
NEXT_PUBLIC_CANDLES_SERVICE_API_URL="http://localhost:5001" | ||
NEXT_PUBLIC_CANDLES_SERVICE_API_KEY="opentrader" | ||
# Logging level for ccxt | ||
# Accepts: "true" | "" | ||
CCXT_VERBOSE= | ||
########## SHARED END ###### |
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 |
---|---|---|
|
@@ -10,3 +10,4 @@ config.prod.json5 | |
exchanges.dev.json5 | ||
exchanges.prod.json5 | ||
.vercel | ||
dev.db |
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
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
dist | ||
release |
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,48 @@ | ||
#!/usr/bin/env node | ||
|
||
import { readFile } from "fs/promises"; | ||
import { spawn } from "child_process"; | ||
import { fileURLToPath } from "url"; | ||
import { dirname } from "path"; | ||
|
||
// Determine the script's directory | ||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = dirname(__filename); | ||
|
||
// Path to the file containing the admin password | ||
const passwordFile = `${process.env.HOME}/.opentrader/pass`; | ||
|
||
// Function to read the password file | ||
async function readPasswordFile(filePath) { | ||
try { | ||
const data = await readFile(filePath, "utf-8"); | ||
return data.trim(); | ||
} catch (error) { | ||
console.error("Password file not found!"); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
// Main function to run the script | ||
async function main() { | ||
const adminPassword = await readPasswordFile(passwordFile); | ||
|
||
// Set environment variables | ||
const env = { | ||
...process.env, | ||
ADMIN_PASSWORD: adminPassword, | ||
DATABASE_URL: `file:${process.env.HOME}/.opentrader/dev.db`, | ||
}; | ||
|
||
// Run the Node.js script | ||
const args = [`${__dirname}/../dist/main.mjs`, ...process.argv.slice(2)]; | ||
const child = spawn("node", args, { env, stdio: "inherit" }); | ||
|
||
child.on("close", (code) => { | ||
if (code !== 0) { | ||
console.error(`Process exited with code ${code}`); | ||
} | ||
}); | ||
} | ||
|
||
main(); |
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,10 @@ | ||
import EslintConfig from "@opentrader/eslint/module.js"; | ||
|
||
export default [ | ||
...EslintConfig, | ||
{ | ||
rules: { | ||
// overriding rules here | ||
}, | ||
}, | ||
]; |
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,79 @@ | ||
import fs from "node:fs"; | ||
import path from "node:path"; | ||
import { fileURLToPath } from "node:url"; | ||
import { Plugin } from "esbuild"; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
|
||
const CLI_DIR = path.resolve(__dirname, "../"); | ||
const PRISMA_DIR = path.resolve(CLI_DIR, "../../packages/prisma"); | ||
const DIST_DIR = path.resolve(CLI_DIR, "release/dist"); | ||
|
||
/** | ||
* Copy the Prisma schema file to the release build directory. | ||
*/ | ||
export const copyPrismaSchemaPlugin = (): Plugin => ({ | ||
name: "copy-prisma-schema", | ||
setup(build) { | ||
if (build.initialOptions.outdir !== "release/dist") { | ||
console.log('Skipping "schema.prisma" copy for non-release build'); | ||
return; | ||
} | ||
|
||
build.onEnd(() => { | ||
// Copy schema.prisma | ||
const prismaSchemaPath = path.resolve(PRISMA_DIR, "src/schema.prisma"); | ||
const prismaSchemaDest = path.resolve(DIST_DIR, "../schema.prisma"); | ||
|
||
if (!fs.existsSync(DIST_DIR)) { | ||
fs.mkdirSync(DIST_DIR, { | ||
recursive: true, | ||
}); | ||
} | ||
|
||
fs.copyFileSync(prismaSchemaPath, prismaSchemaDest); | ||
|
||
// Copy seed.ts | ||
const prismaSeedPath = path.resolve(CLI_DIR, "seed.ts"); | ||
const prismaSeedDest = path.resolve(DIST_DIR, "../seed.ts"); | ||
fs.copyFileSync(prismaSeedPath, prismaSeedDest); | ||
|
||
// Copy migrations | ||
const prismaMigrationsPath = path.resolve(PRISMA_DIR, "src/migrations"); | ||
const prismaMigrationsDest = path.resolve(DIST_DIR, "../migrations"); | ||
|
||
if (!fs.existsSync(prismaMigrationsDest)) { | ||
fs.mkdirSync(prismaMigrationsDest, { | ||
recursive: true, | ||
}); | ||
} | ||
|
||
copyDirectory(prismaMigrationsPath, prismaMigrationsDest); | ||
}); | ||
}, | ||
}); | ||
|
||
function copyDirectory(src: string, dest: string) { | ||
// Create destination folder if it doesn't exist | ||
if (!fs.existsSync(dest)) { | ||
fs.mkdirSync(dest, { recursive: true }); | ||
} | ||
|
||
// Read all items in the source directory | ||
const items = fs.readdirSync(src); | ||
|
||
// Iterate through each item and copy it to the destination | ||
items.forEach((item) => { | ||
const srcPath = path.join(src, item); | ||
const destPath = path.join(dest, item); | ||
|
||
if (fs.lstatSync(srcPath).isDirectory()) { | ||
// If item is a directory, recursively copy it | ||
copyDirectory(srcPath, destPath); | ||
} else { | ||
// If item is a file, copy it | ||
fs.copyFileSync(srcPath, destPath); | ||
} | ||
}); | ||
} |
Oops, something went wrong.