Merge pull request #1990 from kuba618/AUT-1137

fix: improve paths for windows os
This commit is contained in:
Ali BARIN
2024-08-08 12:08:05 +02:00
committed by GitHub
6 changed files with 15 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
import { knexSnakeCaseMappers } from 'objection'; import { knexSnakeCaseMappers } from 'objection';
import appConfig from './src/config/app.js'; import appConfig from './src/config/app.js';
import path from 'path'; import path, { join } from 'path';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
const fileExtension = 'js'; const fileExtension = 'js';
@@ -20,12 +20,12 @@ const knexConfig = {
searchPath: [appConfig.postgresSchema], searchPath: [appConfig.postgresSchema],
pool: { min: 0, max: 20 }, pool: { min: 0, max: 20 },
migrations: { migrations: {
directory: __dirname + '/src/db/migrations', directory: join(__dirname, '/src/db/migrations'),
extension: fileExtension, extension: fileExtension,
loadExtensions: [`.${fileExtension}`], loadExtensions: [`.${fileExtension}`],
}, },
seeds: { seeds: {
directory: __dirname + '/src/db/seeds', directory: join(__dirname, '/src/db/seeds'),
}, },
...(appConfig.isTest ? knexSnakeCaseMappers() : {}), ...(appConfig.isTest ? knexSnakeCaseMappers() : {}),
}; };

View File

@@ -5,8 +5,8 @@
"description": "The open source Zapier alternative. Build workflow automation without spending time and money.", "description": "The open source Zapier alternative. Build workflow automation without spending time and money.",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "nodemon --watch 'src/**/*.js' --exec 'node' src/server.js", "dev": "nodemon --exec node src/server.js",
"worker": "nodemon --watch 'src/**/*.js' --exec 'node' src/worker.js", "worker": "nodemon --exec node src/worker.js",
"start": "node src/server.js", "start": "node src/server.js",
"start:worker": "node src/worker.js", "start:worker": "node src/worker.js",
"pretest": "APP_ENV=test node ./test/setup/prepare-test-env.js", "pretest": "APP_ENV=test node ./test/setup/prepare-test-env.js",
@@ -104,5 +104,9 @@
}, },
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
},
"nodemonConfig": {
"watch": [ "src/" ],
"ext": "js"
} }
} }

View File

@@ -7,7 +7,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
const appAssetsHandler = async (app) => { const appAssetsHandler = async (app) => {
app.use('/apps/:appKey/assets/favicon.svg', (req, res, next) => { app.use('/apps/:appKey/assets/favicon.svg', (req, res, next) => {
const { appKey } = req.params; const { appKey } = req.params;
const svgPath = `${__dirname}/../apps/${appKey}/assets/favicon.svg`; const svgPath = path.resolve(`${__dirname}/../apps/${appKey}/assets/favicon.svg`);
const staticFileHandlerOptions = { const staticFileHandlerOptions = {
/** /**
* Disabling fallthrough is important to respond with HTTP 404. * Disabling fallthrough is important to respond with HTTP 404.

View File

@@ -1,10 +1,10 @@
import path from 'node:path'; import path, { join } from 'path';
import fs from 'node:fs'; import fs from 'node:fs';
import omit from 'lodash/omit.js'; import omit from 'lodash/omit.js';
import cloneDeep from 'lodash/cloneDeep.js'; import cloneDeep from 'lodash/cloneDeep.js';
import addAuthenticationSteps from './add-authentication-steps.js'; import addAuthenticationSteps from './add-authentication-steps.js';
import addReconnectionSteps from './add-reconnection-steps.js'; import addReconnectionSteps from './add-reconnection-steps.js';
import { fileURLToPath } from 'url'; import { fileURLToPath, pathToFileURL } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url)); const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -14,7 +14,7 @@ const apps = fs
if (!dirent.isDirectory()) return apps; if (!dirent.isDirectory()) return apps;
apps[dirent.name] = import( apps[dirent.name] = import(
path.resolve(__dirname, '../apps', dirent.name, 'index.js') pathToFileURL(join(__dirname, '../apps', dirent.name, 'index.js'))
); );
return apps; return apps;

View File

@@ -10,7 +10,7 @@ class App {
static folderPath = join(__dirname, '../apps'); static folderPath = join(__dirname, '../apps');
static list = fs static list = fs
.readdirSync(this.folderPath) .readdirSync(this.folderPath)
.filter((file) => fs.statSync(this.folderPath + '/' + file).isDirectory()); .filter((file) => fs.statSync(join(this.folderPath, file)).isDirectory());
static async findAll(name, stripFuncs = true) { static async findAll(name, stripFuncs = true) {
if (!name) if (!name)

View File

@@ -17,7 +17,7 @@ const knexConfig = {
loadExtensions: [`.${fileExtension}`], loadExtensions: [`.${fileExtension}`],
}, },
seeds: { seeds: {
directory: '../../packages/backend/src/db/seeds', directory: '../../packages/backend/src/db/seeds/',
}, },
...(process.env.APP_ENV === 'test' ? knexSnakeCaseMappers() : {}), ...(process.env.APP_ENV === 'test' ? knexSnakeCaseMappers() : {}),
}; };