mirror of
https://github.com/sasjs/server.git
synced 2026-01-06 22:20:06 +00:00
fix: macros available for SAS
This commit is contained in:
@@ -1,7 +1,14 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { asyncForEach, copy, createFolder, deleteFolder } from '@sasjs/utils'
|
import {
|
||||||
|
asyncForEach,
|
||||||
|
copy,
|
||||||
|
createFile,
|
||||||
|
createFolder,
|
||||||
|
deleteFolder,
|
||||||
|
listFilesInFolder
|
||||||
|
} from '@sasjs/utils'
|
||||||
|
|
||||||
import { apiRoot, sasJSCoreMacros } from '../src/utils'
|
import { apiRoot, sasJSCoreMacros, sasJSCoreMacrosInfo } from '../src/utils'
|
||||||
|
|
||||||
const macroCorePath = path.join(apiRoot, 'node_modules', '@sasjs', 'core')
|
const macroCorePath = path.join(apiRoot, 'node_modules', '@sasjs', 'core')
|
||||||
|
|
||||||
@@ -16,6 +23,10 @@ export const copySASjsCore = async () => {
|
|||||||
|
|
||||||
await copy(coreSubFolderPath, sasJSCoreMacros)
|
await copy(coreSubFolderPath, sasJSCoreMacros)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const fileNames = await listFilesInFolder(sasJSCoreMacros)
|
||||||
|
|
||||||
|
await createFile(sasJSCoreMacrosInfo, fileNames.join('\n'))
|
||||||
}
|
}
|
||||||
|
|
||||||
copySASjsCore()
|
copySASjsCore()
|
||||||
|
|||||||
@@ -56,8 +56,6 @@ export default setProcessVariables().then(async () => {
|
|||||||
// index.html needs to be injected with some js script.
|
// index.html needs to be injected with some js script.
|
||||||
app.use(express.static(getWebBuildFolderPath()))
|
app.use(express.static(getWebBuildFolderPath()))
|
||||||
|
|
||||||
console.log('sasJSCoreMacros', sasJSCoreMacros)
|
|
||||||
|
|
||||||
app.use(onError)
|
app.use(onError)
|
||||||
|
|
||||||
await connectDB()
|
await connectDB()
|
||||||
|
|||||||
@@ -1,10 +1,32 @@
|
|||||||
import { copy, createFolder } from '@sasjs/utils'
|
import path from 'path'
|
||||||
|
import {
|
||||||
|
asyncForEach,
|
||||||
|
createFile,
|
||||||
|
createFolder,
|
||||||
|
deleteFolder,
|
||||||
|
readFile
|
||||||
|
} from '@sasjs/utils'
|
||||||
|
|
||||||
import { getTmpMacrosPath, sasJSCoreMacros } from '.'
|
import { getTmpMacrosPath, sasJSCoreMacros, sasJSCoreMacrosInfo } from '.'
|
||||||
|
|
||||||
export const copySASjsCore = async () => {
|
export const copySASjsCore = async () => {
|
||||||
await createFolder(sasJSCoreMacros)
|
console.log('Copying Macros from container to drive(tmp).')
|
||||||
|
|
||||||
const macrosDrivePath = getTmpMacrosPath()
|
const macrosDrivePath = getTmpMacrosPath()
|
||||||
await copy(sasJSCoreMacros, macrosDrivePath)
|
|
||||||
|
await deleteFolder(macrosDrivePath)
|
||||||
|
await createFolder(macrosDrivePath)
|
||||||
|
|
||||||
|
const macros = await readFile(sasJSCoreMacrosInfo)
|
||||||
|
|
||||||
|
await asyncForEach(macros.split('\n'), async (macroName) => {
|
||||||
|
const macroFileSourcePath = path.join(sasJSCoreMacros, macroName)
|
||||||
|
const macroContent = await readFile(macroFileSourcePath)
|
||||||
|
|
||||||
|
const macroFileDestPath = path.join(macrosDrivePath, macroName)
|
||||||
|
|
||||||
|
await createFile(macroFileDestPath, macroContent)
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log('Macros Drive Path:', macrosDrivePath)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export const sysInitCompiledPath = path.join(
|
|||||||
)
|
)
|
||||||
|
|
||||||
export const sasJSCoreMacros = path.join(apiRoot, 'sasjscore')
|
export const sasJSCoreMacros = path.join(apiRoot, 'sasjscore')
|
||||||
|
export const sasJSCoreMacrosInfo = path.join(apiRoot, 'sasjscore', '.macrolist')
|
||||||
|
|
||||||
export const getWebBuildFolderPath = () =>
|
export const getWebBuildFolderPath = () =>
|
||||||
path.join(codebaseRoot, 'web', 'build')
|
path.join(codebaseRoot, 'web', 'build')
|
||||||
|
|||||||
Reference in New Issue
Block a user