From 03d61e747d8327d90a80a3033ec0c458c3ee63f2 Mon Sep 17 00:00:00 2001 From: Shannon Date: Fri, 5 Jul 2024 15:53:18 +1000 Subject: [PATCH] moving paths around --- .gitignore | 1 - hakit/README.md | 2 +- hakit/config.json | 2 +- hakit/server/google/auth/index.ts | 3 ++- hakit/server/routes/write-file.ts | 3 ++- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 5761412..e17f7e3 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,5 @@ packages/core/.env hakit/config hakit/server/hakit-designer hakit/server/options.json -hakit/service-account.json trace trace/* \ No newline at end of file diff --git a/hakit/README.md b/hakit/README.md index fc357c0..38ea389 100644 --- a/hakit/README.md +++ b/hakit/README.md @@ -36,7 +36,7 @@ Running the dashboard interface for the addon is as simple as running: "custom_dashboard": false // switching to true will attempt to load a html file under hakit/config/www/ha-dashboard/index.html so you will need to create the `config` folder as well as all subdirectories if you're testing this flow. } ``` -2. create a `service-account.json` file with credentials pointing to the google drive account in the `hakit` directory. +2. create a `service-account.json` file with credentials pointing to the google drive account in the `hakit/config/hakit-designer` directory. 3. `npm i && npm run dev` This will spin up a server under `http://localhost:2022` diff --git a/hakit/config.json b/hakit/config.json index 64bce18..25572e7 100644 --- a/hakit/config.json +++ b/hakit/config.json @@ -1,6 +1,6 @@ { "name": "Hakit", - "version": "1.0.25", + "version": "1.0.26", "slug": "hakit", "init": false, "ingress": true, diff --git a/hakit/server/google/auth/index.ts b/hakit/server/google/auth/index.ts index 24eafca..4547fe5 100644 --- a/hakit/server/google/auth/index.ts +++ b/hakit/server/google/auth/index.ts @@ -1,8 +1,9 @@ import { existsSync } from 'fs'; import { GoogleAuth, GoogleAuthOptions } from 'google-auth-library'; import { join } from 'path'; +import { APP_DIRECTORY } from '../../constants.js'; -const SERVICE_ACCOUNT_FILE = join(process.cwd(), 'service-account.json'); +const SERVICE_ACCOUNT_FILE = join(APP_DIRECTORY, 'service-account.json'); export const SCOPES = [ 'https://www.googleapis.com/auth/drive.readonly', diff --git a/hakit/server/routes/write-file.ts b/hakit/server/routes/write-file.ts index 4eebf3a..76e30b7 100644 --- a/hakit/server/routes/write-file.ts +++ b/hakit/server/routes/write-file.ts @@ -1,6 +1,7 @@ import { Request, Response } from 'express'; import { join } from 'path'; import { writeFile as fsWriteFile } from 'fs/promises'; +import { APP_DIRECTORY } from 'server/constants.js'; export async function writeFile(req: Request, res: Response) { try { @@ -10,7 +11,7 @@ export async function writeFile(req: Request, res: Response) { return res.status(400).send('Filename and content are required.'); } - const filePath = join(process.cwd(), filename); + const filePath = join(APP_DIRECTORY, filename); const fileContents = typeof content === 'string' ? content : JSON.stringify(content, null, 2); await fsWriteFile(filePath, fileContents, 'utf8');