From 9ac3191891bf53ff07135ccec6ddc83b34ea871a Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Wed, 23 Mar 2022 09:19:33 +0500 Subject: [PATCH] fix: moved macros from codebase to drive --- api/src/app.ts | 3 +++ api/src/controllers/internal/Execution.ts | 6 +++--- api/src/utils/copySASjsCore.ts | 10 ++++++++++ api/src/utils/file.ts | 2 ++ api/src/utils/index.ts | 3 ++- 5 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 api/src/utils/copySASjsCore.ts diff --git a/api/src/app.ts b/api/src/app.ts index 17350ee..9fdf244 100644 --- a/api/src/app.ts +++ b/api/src/app.ts @@ -7,6 +7,7 @@ import cors from 'cors' import { connectDB, + copySASjsCore, getWebBuildFolderPath, loadAppStreamConfig, sasJSCoreMacros, @@ -42,6 +43,8 @@ const onError: ErrorRequestHandler = (err, req, res, next) => { } export default setProcessVariables().then(async () => { + await copySASjsCore() + // loading these modules after setting up variables due to // multer's usage of process var process.driveLoc const { setupRoutes } = await import('./routes/setupRoutes') diff --git a/api/src/controllers/internal/Execution.ts b/api/src/controllers/internal/Execution.ts index 052cc42..ff6bdcd 100644 --- a/api/src/controllers/internal/Execution.ts +++ b/api/src/controllers/internal/Execution.ts @@ -13,9 +13,9 @@ import { extractHeaders, generateFileUploadSasCode, getTmpFilesFolderPath, + getTmpMacrosPath, HTTPHeaders, - isDebugOn, - sasJSCoreMacros + isDebugOn } from '../../utils' export interface ExecutionVars { @@ -106,7 +106,7 @@ export class ExecutionController { ` program = ` -options insert=(SASAUTOS="${sasJSCoreMacros}"); +options insert=(SASAUTOS="${getTmpMacrosPath()}"); /* runtime vars */ ${varStatments} diff --git a/api/src/utils/copySASjsCore.ts b/api/src/utils/copySASjsCore.ts new file mode 100644 index 0000000..9a5e07c --- /dev/null +++ b/api/src/utils/copySASjsCore.ts @@ -0,0 +1,10 @@ +import { copy, createFolder } from '@sasjs/utils' + +import { getTmpMacrosPath, sasJSCoreMacros } from '.' + +export const copySASjsCore = async () => { + await createFolder(sasJSCoreMacros) + + const macrosDrivePath = getTmpMacrosPath() + await copy(sasJSCoreMacros, macrosDrivePath) +} diff --git a/api/src/utils/file.ts b/api/src/utils/file.ts index 2cce265..42bb12c 100644 --- a/api/src/utils/file.ts +++ b/api/src/utils/file.ts @@ -18,6 +18,8 @@ export const getTmpFolderPath = () => process.driveLoc export const getTmpAppStreamConfigPath = () => path.join(getTmpFolderPath(), 'appStreamConfig.json') +export const getTmpMacrosPath = () => path.join(getTmpFolderPath(), 'sasjscore') + export const getTmpUploadsPath = () => path.join(getTmpFolderPath(), 'uploads') export const getTmpFilesFolderPath = () => diff --git a/api/src/utils/index.ts b/api/src/utils/index.ts index 1527080..80b3580 100644 --- a/api/src/utils/index.ts +++ b/api/src/utils/index.ts @@ -1,13 +1,14 @@ export * from './appStreamConfig' export * from './connectDB' +export * from './copySASjsCore' export * from './extractHeaders' export * from './file' export * from './generateAccessToken' export * from './generateAuthCode' export * from './generateRefreshToken' -export * from './isDebugOn' export * from './getCertificates' export * from './getDesktopFields' +export * from './isDebugOn' export * from './parseLogToArray' export * from './removeTokensInDB' export * from './saveTokensInDB'