mirror of
https://github.com/sasjs/server.git
synced 2026-04-09 15:13:13 +00:00
chore: default is desktop mode with prompts
This commit is contained in:
@@ -5,7 +5,7 @@ export const getWebBuildFolderPath = () =>
|
||||
getRealPath(path.join(__dirname, '..', '..', '..', 'web', 'build'))
|
||||
|
||||
export const getTmpFolderPath = () =>
|
||||
getRealPath(path.join(process.cwd(), 'tmp'))
|
||||
process.driveLoc ?? getRealPath(path.join(process.cwd(), 'tmp'))
|
||||
|
||||
export const getTmpFilesFolderPath = () =>
|
||||
path.join(getTmpFolderPath(), 'files')
|
||||
|
||||
61
api/src/utils/getDesktopFields.ts
Normal file
61
api/src/utils/getDesktopFields.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import path from 'path'
|
||||
import { getString } from '@sasjs/utils/input'
|
||||
import { createFolder, fileExists, folderExists } from '@sasjs/utils'
|
||||
|
||||
const isWindows = () => process.platform === 'win32'
|
||||
|
||||
export const getDesktopFields = async () => {
|
||||
const sasLoc = await getSASLocation()
|
||||
const driveLoc = await getDriveLocation()
|
||||
|
||||
return { sasLoc, driveLoc }
|
||||
}
|
||||
|
||||
const getDriveLocation = async (): Promise<string> => {
|
||||
const validator = async (filePath: string) => {
|
||||
if (!filePath) return 'Path to files/drive is required.'
|
||||
|
||||
const drivePath = path.join(process.cwd(), filePath)
|
||||
|
||||
if (!(await folderExists(drivePath))) {
|
||||
await createFolder(drivePath)
|
||||
await createFolder(path.join(drivePath, 'files'))
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
const defaultLocation = isWindows() ? '.\\tmp\\' : './tmp/'
|
||||
|
||||
const targetName = await getString(
|
||||
'Please enter path to file/drive (relative to executable): ',
|
||||
validator,
|
||||
defaultLocation
|
||||
)
|
||||
|
||||
return targetName
|
||||
}
|
||||
|
||||
const getSASLocation = async (): Promise<string> => {
|
||||
const validator = async (filePath: string) => {
|
||||
if (!filePath) return 'Path to SAS executable is required.'
|
||||
|
||||
if (!(await fileExists(filePath))) {
|
||||
return 'No file found at provided path.'
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
const defaultLocation = isWindows()
|
||||
? 'C:\\Program Files\\SASHome\\SASFoundation\\9.4\\sas.exe'
|
||||
: '/opt/sas/sas9/SASHome/SASFoundation/9.4/sasexe/sas'
|
||||
|
||||
const targetName = await getString(
|
||||
'Please enter path to SAS executable (absolute path): ',
|
||||
validator,
|
||||
defaultLocation
|
||||
)
|
||||
|
||||
return targetName
|
||||
}
|
||||
@@ -2,6 +2,7 @@ export * from './file'
|
||||
export * from './generateAccessToken'
|
||||
export * from './generateAuthCode'
|
||||
export * from './generateRefreshToken'
|
||||
export * from './getDesktopFields'
|
||||
export * from './removeTokensInDB'
|
||||
export * from './saveTokensInDB'
|
||||
export * from './sleep'
|
||||
|
||||
Reference in New Issue
Block a user