1
0
mirror of https://github.com/sasjs/server.git synced 2025-12-11 19:44:35 +00:00

feat: on startup add webout.sas file in sasautos folder

This commit is contained in:
2022-11-17 17:03:23 +05:00
parent 1b7ccda6e9
commit 200f6c596a
5 changed files with 38 additions and 9 deletions

View File

@@ -689,10 +689,6 @@ paths:
$ref: '#/components/schemas/ClientPayload' $ref: '#/components/schemas/ClientPayload'
examples: examples:
'Example 1': 'Example 1':
value: {clientId: someFormattedClientID1234, clientSecret: someRandomCryptoString}
'Example 2':
value: {clientId: someFormattedClientID1234, clientSecret: someRandomCryptoString, accessTokenExpiration: 86400}
'Example 3':
value: {clientId: someFormattedClientID1234, clientSecret: someRandomCryptoString, accessTokenExpiration: 86400} value: {clientId: someFormattedClientID1234, clientSecret: someRandomCryptoString, accessTokenExpiration: 86400}
summary: "Admin only task. Create client with the following attributes:\nClientId,\nClientSecret,\naccessTokenExpiration (optional),\nrefreshTokenExpiration (optional)" summary: "Admin only task. Create client with the following attributes:\nClientId,\nClientSecret,\naccessTokenExpiration (optional),\nrefreshTokenExpiration (optional)"
tags: tags:

View File

@@ -5,12 +5,16 @@ import dotenv from 'dotenv'
import { import {
copySASjsCore, copySASjsCore,
createWeboutSasFile,
getFilesFolder,
getPackagesFolder,
getWebBuildFolder, getWebBuildFolder,
instantiateLogger, instantiateLogger,
loadAppStreamConfig, loadAppStreamConfig,
ReturnCode, ReturnCode,
setProcessVariables, setProcessVariables,
setupFolders, setupFilesFolder,
setupPackagesFolder,
setupUserAutoExec, setupUserAutoExec,
verifyEnvVariables verifyEnvVariables
} from './utils' } from './utils'
@@ -20,6 +24,7 @@ import {
configureLogger, configureLogger,
configureSecurity configureSecurity
} from './app-modules' } from './app-modules'
import {folderExists} from '@sasjs/utils'
dotenv.config() dotenv.config()
@@ -65,9 +70,16 @@ export default setProcessVariables().then(async () => {
await setupUserAutoExec() await setupUserAutoExec()
if (process.driveLoc === path.join(process.sasjsRoot, 'drive')) { if (!(await folderExists(getFilesFolder()))) await setupFilesFolder()
await setupFolders()
if (!(await folderExists(getPackagesFolder()))) await setupPackagesFolder()
const sasautosPath = path.join(process.driveLoc, 'sas', 'sasautos')
if (await folderExists(sasautosPath)) {
console.log(`SASAUTOS was not refreshed. To force a refresh, delete the ${sasautosPath} folder`)
} else {
await copySASjsCore() await copySASjsCore()
await createWeboutSasFile()
} }
// loading these modules after setting up variables due to // loading these modules after setting up variables due to

View File

@@ -0,0 +1,18 @@
import path from 'path'
import { createFile } from '@sasjs/utils'
import { getMacrosFolder } from './file'
const fileContent = `%macro webout(action,ds,dslabel=,fmt=,missing=NULL,showmeta=NO,maxobs=MAX);
%ms_webout(&action,ds=&ds,dslabel=&dslabel,fmt=&fmt
,missing=&missing
,showmeta=&showmeta
,maxobs=&maxobs
)
%mend;`
export const createWeboutSasFile = async () => {
const macrosDrivePath = getMacrosFolder()
console.log(`Creating webout.sas at ${macrosDrivePath}`)
const filePath = path.join(macrosDrivePath, 'webout.sas')
await createFile(filePath, fileContent)
}

View File

@@ -1,6 +1,7 @@
export * from './appStreamConfig' export * from './appStreamConfig'
export * from './connectDB' export * from './connectDB'
export * from './copySASjsCore' export * from './copySASjsCore'
export * from './createWeboutSasFile'
export * from './desktopAutoExec' export * from './desktopAutoExec'
export * from './extractHeaders' export * from './extractHeaders'
export * from './extractName' export * from './extractName'

View File

@@ -1,7 +1,9 @@
import { createFolder } from '@sasjs/utils' import { createFolder } from '@sasjs/utils'
import { getFilesFolder, getPackagesFolder } from './file' import { getFilesFolder, getPackagesFolder } from './file'
export const setupFolders = async () => { export const setupFilesFolder = async () =>
await createFolder(getFilesFolder()) await createFolder(getFilesFolder())
export const setupPackagesFolder = async () =>
await createFolder(getPackagesFolder()) await createFolder(getPackagesFolder())
}