Skip to content
Snippets Groups Projects
Commit 919f21d8 authored by julian.baeume's avatar julian.baeume :pick: Committed by julian.baeume
Browse files

first implementation to parse vite-manifest files

… and transform them to something that can be consumed by App Suite.
parent 974a8ee7
No related branches found
No related tags found
No related merge requests found
import { describe, it, expect } from '@jest/globals'
import { viteToOxManifest } from '../src/manifests.js'
describe('Vite manifest parsing', () => {
it('should', () => {
const manifests = viteToOxManifest({
'../io.ox/guidedtours/i18n.de_DE.js': {
file: 'io.ox/guidedtours/i18n.de_DE.js',
src: '../io.ox/guidedtours/i18n.de_DE.js',
isEntry: true,
meta: {}
},
'../io.ox/guidedtours/i18n': {
file: 'io.ox/guidedtours/i18n.3de05d46.js',
src: '../io.ox/guidedtours/i18n',
isEntry: true,
imports: [
'_preload-helper-a7bbbf37.js'
],
meta: {
gettext: {
dictionary: true
},
manifests: [
{
namespace: 'i18n'
}
]
}
},
'io.ox/guidedtours/intro.js': {
file: 'io.ox/guidedtours/intro.e84819a5.js',
src: 'io.ox/guidedtours/intro.js',
isEntry: true,
isDynamicEntry: true,
imports: [
'../io.ox/guidedtours/i18n',
'_preload-helper-a7bbbf37.js'
],
meta: {}
},
'io.ox/guidedtours/main.js': {
file: 'io.ox/guidedtours/main.07676e21.js',
src: 'io.ox/guidedtours/main.js',
isEntry: true,
imports: [
'_preload-helper-a7bbbf37.js',
'../io.ox/guidedtours/i18n'
],
dynamicImports: [
'io.ox/guidedtours/intro.js',
'io.ox/guidedtours/multifactor.js'
],
meta: {
manifests: [
{
namespace: 'settings'
},
{
namespace: 'io.ox/core/main',
title: 'Guided tours',
company: 'Open-Xchange',
icon: '/images/icon.png',
category: 'Dev',
settings: false,
index: 100,
package: 'open-xchange-guidedtours'
}
]
}
},
'io.ox/guidedtours/multifactor.js': {
file: 'io.ox/guidedtours/multifactor.22d3e17d.js',
src: 'io.ox/guidedtours/multifactor.js',
isEntry: true,
isDynamicEntry: true,
imports: [
'_preload-helper-a7bbbf37.js',
'../io.ox/guidedtours/i18n',
'io.ox/guidedtours/main.js'
],
meta: {}
},
'io.ox/guidedtours/utils.js': {
file: 'io.ox/guidedtours/utils.91ad511f.js',
src: 'io.ox/guidedtours/utils.js',
isEntry: true,
imports: [
'_preload-helper-a7bbbf37.js'
],
meta: {}
},
'_preload-helper-a7bbbf37.js': {
file: 'io.ox/guidedtours/preload-helper-a7bbbf37.js'
}
})
expect(Array.isArray(manifests)).toBe(true)
expect(manifests.length).toBe(3)
expect(manifests.map(manifest => manifest.path)).toEqual([
'io.ox/guidedtours/i18n.3de05d46.js',
'io.ox/guidedtours/main.07676e21.js',
'io.ox/guidedtours/main.07676e21.js'
])
expect(manifests.map(manifest => manifest.namespace)).toEqual([
'i18n',
'settings',
'io.ox/core/main'
])
})
})
export function viteToOxManifest (viteManifests) {
return Object.values(viteManifests)
.filter(manifest => Array.isArray(manifest?.meta?.manifests))
.map(manifest =>
manifest.meta.manifests.map(oxManifest => {
return {
...oxManifest,
path: manifest.file
}
})
)
.flat()
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment