build: embed pac catalog in application bundles
This commit is contained in:
@@ -51,6 +51,21 @@ describe('external module registry', () => {
|
||||
expect((await getAvailableModulePackages()).map((item) => item.manifest.id)).toContain('sample-app')
|
||||
delete process.env.APPIMAGE
|
||||
})
|
||||
it('discovers a .pac embedded in the packaged application resources', async () => {
|
||||
const resources = await temp('aurora-resources-')
|
||||
const catalog = join(resources, 'module-catalog')
|
||||
await mkdir(catalog)
|
||||
const pac = await pacFile()
|
||||
await import('fs/promises').then(({ copyFile }) => copyFile(pac, join(catalog, 'sample-app.pac')))
|
||||
const previous = Object.getOwnPropertyDescriptor(process, 'resourcesPath')
|
||||
Object.defineProperty(process, 'resourcesPath', { value: resources, configurable: true })
|
||||
try {
|
||||
expect((await getAvailableModulePackages()).map((item) => item.manifest.id)).toContain('sample-app')
|
||||
} finally {
|
||||
if (previous) Object.defineProperty(process, 'resourcesPath', previous)
|
||||
else Reflect.deleteProperty(process, 'resourcesPath')
|
||||
}
|
||||
})
|
||||
it('installs a valid local package and refreshes after install', async () => {
|
||||
const userData = await temp('aurora-user-'); const source = await packageDir()
|
||||
await installModulePackage(source, userData)
|
||||
|
||||
@@ -165,7 +165,10 @@ function catalogDirectories(): string[] {
|
||||
const besideImage = process.env.APPIMAGE
|
||||
? [dirname(process.env.APPIMAGE), join(dirname(process.env.APPIMAGE), 'modules')]
|
||||
: []
|
||||
return [...configured, ...besideImage, join(process.cwd(), 'modules'), join(process.cwd(), 'packages'), join(app.getAppPath(), 'packages')]
|
||||
const embedded = typeof process.resourcesPath === 'string'
|
||||
? [join(process.resourcesPath, 'module-catalog')]
|
||||
: []
|
||||
return [...configured, ...besideImage, ...embedded, join(process.cwd(), 'modules'), join(process.cwd(), 'packages'), join(app.getAppPath(), 'packages')]
|
||||
}
|
||||
|
||||
export async function getAvailableModulePackages(): Promise<AuroraAvailableModule[]> {
|
||||
|
||||
Reference in New Issue
Block a user