@open-xchange/vite-plugin-ox-manifests 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +175 -0
- package/dist/plugins/gettext.d.ts +2 -0
- package/dist/plugins/gettext.js +63 -0
- package/dist/plugins/manifests.d.ts +2 -0
- package/dist/plugins/manifests.js +132 -0
- package/dist/plugins/meta.d.ts +2 -0
- package/dist/plugins/meta.js +21 -0
- package/dist/plugins/plugin.d.ts +24 -0
- package/dist/plugins/plugin.js +6 -0
- package/dist/plugins/relative-paths.d.ts +2 -0
- package/dist/plugins/relative-paths.js +9 -0
- package/dist/plugins/serve.d.ts +2 -0
- package/dist/plugins/serve.js +66 -0
- package/dist/plugins/settings.d.ts +2 -0
- package/dist/plugins/settings.js +141 -0
- package/dist/util.d.ts +11 -0
- package/dist/util.js +77 -0
- package/package.json +24 -22
- package/.eslintrc.cjs +0 -10
- package/.gitlab-ci.yml +0 -26
- package/index.js +0 -172
- package/src/constants.js +0 -1
- package/src/plugins/gettext.js +0 -69
- package/src/plugins/manifests.js +0 -136
- package/src/plugins/meta.js +0 -13
- package/src/plugins/relative-paths.js +0 -7
- package/src/plugins/serve.js +0 -64
- package/src/plugins/settings.js +0 -147
- package/src/util.js +0 -61
- package/test/.eslintrc.cjs +0 -5
- package/test/deps/main.test.js +0 -32
- package/test/gettext-chunked/another_chunk.js +0 -4
- package/test/gettext-chunked/i18n/de_DE.po +0 -16
- package/test/gettext-chunked/i18n/en_US.po +0 -16
- package/test/gettext-chunked/main.test.js +0 -67
- package/test/gettext-chunked/manifest.json +0 -3
- package/test/gettext-chunked/register.js +0 -6
- package/test/gettext-multiple/i18n/de_DE.po +0 -22
- package/test/gettext-multiple/i18n/en_US.po +0 -22
- package/test/gettext-multiple/main.test.js +0 -71
- package/test/gettext-multiple/manifest.json +0 -3
- package/test/gettext-multiple/register.js +0 -4
- package/test/gettext-simple/i18n/de_DE.po +0 -18
- package/test/gettext-simple/i18n/en_US.po +0 -18
- package/test/gettext-simple/main.test.js +0 -61
- package/test/gettext-simple/manifest.json +0 -3
- package/test/gettext-simple/register.js +0 -3
- package/test/hmr/main.test.js +0 -121
- package/test/hmr/manifest.json +0 -3
- package/test/hmr/register.js +0 -1
- package/test/hmr/settings.js +0 -3
- package/test/html-relative-paths/index.html +0 -7
- package/test/html-relative-paths/index.js +0 -3
- package/test/html-relative-paths/main.test.js +0 -39
- package/test/html-relative-paths/other.html +0 -7
- package/test/html-relative-paths/style.css +0 -1
- package/test/manifest-dependencies/main.test.js +0 -26
- package/test/manifest-dependencies/manifest.json +0 -3
- package/test/manifest-dependencies/register.js +0 -3
- package/test/manifest-dependencies/style.less +0 -1
- package/test/manifest-dynamic-deps/main.test.js +0 -28
- package/test/manifest-dynamic-deps/manifest.json +0 -3
- package/test/manifest-dynamic-deps/register.js +0 -7
- package/test/manifest-dynamic-deps/some_dep.js +0 -5
- package/test/manifest-dynamic-deps/style.less +0 -1
- package/test/manifest-multiple/entry1.js +0 -1
- package/test/manifest-multiple/main.test.js +0 -83
- package/test/manifest-multiple/manifest.json +0 -7
- package/test/manifest-multiple/sub/entry2.js +0 -3
- package/test/manifest-multiple/sub/manifest.json +0 -4
- package/test/manifest-simple/main.test.js +0 -105
- package/test/manifest-simple/manifest.json +0 -3
- package/test/manifest-simple/register.js +0 -1
- package/test/meta/main.test.js +0 -25
- package/test/meta/manifest.json +0 -3
- package/test/meta/register.js +0 -1
- package/test/preload-helper-bundled/async.js +0 -1
- package/test/preload-helper-bundled/index.js +0 -1
- package/test/preload-helper-bundled/main.test.js +0 -32
- package/test/preload-helper-bundled/manifest.json +0 -4
- package/test/preload-helper-separate/bar.js +0 -1
- package/test/preload-helper-separate/foo.js +0 -3
- package/test/preload-helper-separate/index.js +0 -1
- package/test/preload-helper-separate/main.test.js +0 -34
- package/test/preload-helper-separate/manifest.json +0 -4
- package/test/settings-core/index.js +0 -4
- package/test/settings-core/main.test.js +0 -56
- package/test/settings-core/manifest.json +0 -4
- package/test/settings-core/no-settings.js +0 -3
- package/test/settings-core/settings.js +0 -3
- package/test/settings-external/index.js +0 -3
- package/test/settings-external/main.test.js +0 -61
- package/test/settings-external/manifest.json +0 -4
- package/test/settings-external/settings.js +0 -3
- package/test/settings-ts/index.js +0 -3
- package/test/settings-ts/main.test.js +0 -30
- package/test/settings-ts/manifest.json +0 -4
- package/test/settings-ts/settings.ts +0 -4
- package/test/settings-with-requirements/foo.js +0 -3
- package/test/settings-with-requirements/forth-settings.js +0 -3
- package/test/settings-with-requirements/index.js +0 -5
- package/test/settings-with-requirements/main.test.js +0 -95
- package/test/settings-with-requirements/manifest.json +0 -12
- package/test/settings-with-requirements/other-settings.js +0 -3
- package/test/settings-with-requirements/other.js +0 -4
- package/test/settings-with-requirements/settings.js +0 -3
- package/test/settings-with-requirements/third-settings.js +0 -3
- package/test/util/deep-merge.test.js +0 -59
- package/test/util.js +0 -16
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from '@jest/globals'
|
|
2
|
-
import { build, createServer } from 'vite'
|
|
3
|
-
import path from 'path'
|
|
4
|
-
import vitePluginOxManifests from '../../index'
|
|
5
|
-
import { getFileFromBundle, getPort } from '../util'
|
|
6
|
-
|
|
7
|
-
const __dirname = path.dirname(new URL(import.meta.url).pathname)
|
|
8
|
-
const PORT = getPort()
|
|
9
|
-
|
|
10
|
-
describe('Simple manifest scenario', function () {
|
|
11
|
-
let server
|
|
12
|
-
|
|
13
|
-
afterEach(async function () {
|
|
14
|
-
if (server) {
|
|
15
|
-
await server.close()
|
|
16
|
-
server = null
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
it('works', async function () {
|
|
21
|
-
const bundle = await build({
|
|
22
|
-
root: __dirname,
|
|
23
|
-
logLevel: 'silent',
|
|
24
|
-
build: { write: false, rollupOptions: { input: {} } },
|
|
25
|
-
plugins: [vitePluginOxManifests({
|
|
26
|
-
|
|
27
|
-
})]
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
const manifestFile = getFileFromBundle('manifest', bundle)
|
|
31
|
-
const manifests = JSON.parse(manifestFile.source)
|
|
32
|
-
expect(Object.keys(manifests)).toHaveLength(1)
|
|
33
|
-
expect(manifests['register.js'].meta.manifests[0].namespace).toEqual('test')
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('works in dev mode', async function () {
|
|
37
|
-
server = await createServer({
|
|
38
|
-
root: __dirname,
|
|
39
|
-
logLevel: 'silent',
|
|
40
|
-
plugins: [vitePluginOxManifests({
|
|
41
|
-
|
|
42
|
-
})]
|
|
43
|
-
})
|
|
44
|
-
await server.listen(PORT)
|
|
45
|
-
|
|
46
|
-
const res = await fetch(`http://localhost:${PORT}/api/manifest.json`)
|
|
47
|
-
const manifests = await res.json()
|
|
48
|
-
|
|
49
|
-
expect(Object.keys(manifests)).toHaveLength(1)
|
|
50
|
-
expect(manifests[0].namespace).toEqual('test')
|
|
51
|
-
expect(manifests[0].path).toContain('register')
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it('works in dev mode with base set', async function () {
|
|
55
|
-
server = await createServer({
|
|
56
|
-
root: __dirname,
|
|
57
|
-
base: '/appsuite/',
|
|
58
|
-
logLevel: 'silent',
|
|
59
|
-
plugins: [vitePluginOxManifests({
|
|
60
|
-
|
|
61
|
-
})]
|
|
62
|
-
})
|
|
63
|
-
await server.listen(PORT)
|
|
64
|
-
|
|
65
|
-
const res = await fetch(`http://localhost:${PORT}/appsuite/api/manifest.json`)
|
|
66
|
-
const manifests = await res.json()
|
|
67
|
-
|
|
68
|
-
expect(Object.keys(manifests)).toHaveLength(1)
|
|
69
|
-
expect(manifests[0].namespace).toEqual('test')
|
|
70
|
-
expect(manifests[0].path).toContain('register')
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
it('works in dev mode with base set (new endpoint)', async function () {
|
|
74
|
-
server = await createServer({
|
|
75
|
-
root: __dirname,
|
|
76
|
-
base: '/appsuite/',
|
|
77
|
-
logLevel: 'silent',
|
|
78
|
-
plugins: [vitePluginOxManifests({
|
|
79
|
-
|
|
80
|
-
})]
|
|
81
|
-
})
|
|
82
|
-
await server.listen(PORT)
|
|
83
|
-
|
|
84
|
-
const res = await fetch(`http://localhost:${PORT}/appsuite/manifests`)
|
|
85
|
-
const manifests = await res.json()
|
|
86
|
-
|
|
87
|
-
expect(Object.keys(manifests)).toHaveLength(1)
|
|
88
|
-
expect(manifests[0].namespace).toEqual('test')
|
|
89
|
-
expect(manifests[0].path).toContain('register')
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
it('does not empty files on transform', async function () {
|
|
93
|
-
server = await createServer({
|
|
94
|
-
root: __dirname,
|
|
95
|
-
logLevel: 'silent',
|
|
96
|
-
plugins: [vitePluginOxManifests({
|
|
97
|
-
|
|
98
|
-
})]
|
|
99
|
-
})
|
|
100
|
-
await server.listen(PORT)
|
|
101
|
-
|
|
102
|
-
const res = await fetch(`http://localhost:${PORT}/register.js`)
|
|
103
|
-
expect(await res.text()).toEqual("console.log('Hello world')\n")
|
|
104
|
-
})
|
|
105
|
-
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log('Hello world')
|
package/test/meta/main.test.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from '@jest/globals'
|
|
2
|
-
import { build } from 'vite'
|
|
3
|
-
import path from 'path'
|
|
4
|
-
import vitePluginOxManifests from '../../index'
|
|
5
|
-
import { getFileFromBundle } from '../util'
|
|
6
|
-
|
|
7
|
-
const __dirname = path.dirname(new URL(import.meta.url).pathname)
|
|
8
|
-
|
|
9
|
-
describe('Meta option', function () {
|
|
10
|
-
it('works', async function () {
|
|
11
|
-
const bundle = await build({
|
|
12
|
-
root: __dirname,
|
|
13
|
-
logLevel: 'silent',
|
|
14
|
-
build: { write: false, rollupOptions: { input: {} } },
|
|
15
|
-
plugins: [vitePluginOxManifests({
|
|
16
|
-
meta: {
|
|
17
|
-
version: '1.2.3'
|
|
18
|
-
}
|
|
19
|
-
})]
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
const metaFile = getFileFromBundle('meta.json', bundle)
|
|
23
|
-
expect(JSON.parse(metaFile.source)).toEqual({ version: '1.2.3' })
|
|
24
|
-
})
|
|
25
|
-
})
|
package/test/meta/manifest.json
DELETED
package/test/meta/register.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log('Hello world')
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default {}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(() => import('./async'))()
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from '@jest/globals'
|
|
2
|
-
import { build } from 'vite'
|
|
3
|
-
import path from 'path'
|
|
4
|
-
import vitePluginOxManifests from '../../index'
|
|
5
|
-
import { getFileFromBundle } from '../util'
|
|
6
|
-
|
|
7
|
-
describe('Preload helper bundled', function () {
|
|
8
|
-
it('works', async function () {
|
|
9
|
-
const bundle = await build({
|
|
10
|
-
root: path.dirname(new URL(import.meta.url).pathname),
|
|
11
|
-
logLevel: 'silent',
|
|
12
|
-
build: {
|
|
13
|
-
minify: false,
|
|
14
|
-
write: false,
|
|
15
|
-
rollupOptions: {
|
|
16
|
-
input: {}
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
plugins: [vitePluginOxManifests({
|
|
20
|
-
|
|
21
|
-
})]
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
const index = getFileFromBundle('index', bundle)
|
|
25
|
-
expect(index.code).toContain('const __vitePreload = function preload')
|
|
26
|
-
|
|
27
|
-
const manifestFile = getFileFromBundle('manifest', bundle)
|
|
28
|
-
const manifests = JSON.parse(manifestFile.source)
|
|
29
|
-
expect(Object.keys(manifests)).toHaveLength(2)
|
|
30
|
-
expect(manifests['index.js'].dependencies).toBeUndefined()
|
|
31
|
-
})
|
|
32
|
-
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default {}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(() => import('./foo'))()
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from '@jest/globals'
|
|
2
|
-
import { build } from 'vite'
|
|
3
|
-
import path from 'path'
|
|
4
|
-
import vitePluginOxManifests from '../../index'
|
|
5
|
-
import { getFileFromBundle } from '../util'
|
|
6
|
-
|
|
7
|
-
const __dirname = path.dirname(new URL(import.meta.url).pathname)
|
|
8
|
-
|
|
9
|
-
describe('Preload helper separate', function () {
|
|
10
|
-
it('replaces code for relative path loading', async function () {
|
|
11
|
-
const bundle = await build({
|
|
12
|
-
root: __dirname,
|
|
13
|
-
logLevel: 'silent',
|
|
14
|
-
build: {
|
|
15
|
-
minify: false,
|
|
16
|
-
write: false,
|
|
17
|
-
rollupOptions: {
|
|
18
|
-
input: {}
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
plugins: [vitePluginOxManifests({
|
|
22
|
-
entryPoints: [`${__dirname}/{foo,bar}.js`]
|
|
23
|
-
})]
|
|
24
|
-
})
|
|
25
|
-
const preloadHelper = getFileFromBundle('preload', bundle)
|
|
26
|
-
expect(preloadHelper.code).toContain('const __vitePreload = function preload')
|
|
27
|
-
|
|
28
|
-
const manifestFile = getFileFromBundle('manifest', bundle)
|
|
29
|
-
const manifests = JSON.parse(manifestFile.source)
|
|
30
|
-
expect(Object.keys(manifests)).toHaveLength(4)
|
|
31
|
-
expect(manifests['index.js'].imports).toHaveLength(1)
|
|
32
|
-
expect(manifests['index.js'].imports[0]).toContain('preload-helper')
|
|
33
|
-
})
|
|
34
|
-
})
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from '@jest/globals'
|
|
2
|
-
import { build, createServer } from 'vite'
|
|
3
|
-
import path from 'path'
|
|
4
|
-
import vitePluginOxManifests from '../../index'
|
|
5
|
-
import { getFileFromBundle, getPort } from '../util'
|
|
6
|
-
|
|
7
|
-
const PORT = getPort()
|
|
8
|
-
|
|
9
|
-
describe('Settings like in core', function () {
|
|
10
|
-
let server
|
|
11
|
-
|
|
12
|
-
afterEach(async function () {
|
|
13
|
-
if (server) {
|
|
14
|
-
await server.close()
|
|
15
|
-
server = null
|
|
16
|
-
}
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
it('works', async function () {
|
|
20
|
-
const bundle = await build({
|
|
21
|
-
root: path.dirname(new URL(import.meta.url).pathname),
|
|
22
|
-
logLevel: 'silent',
|
|
23
|
-
build: {
|
|
24
|
-
write: false,
|
|
25
|
-
rollupOptions: {
|
|
26
|
-
input: {},
|
|
27
|
-
external: ['@/io.ox/core/settings']
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
plugins: [vitePluginOxManifests({
|
|
31
|
-
|
|
32
|
-
})]
|
|
33
|
-
})
|
|
34
|
-
const manifestFile = getFileFromBundle('manifest', bundle)
|
|
35
|
-
const manifests = JSON.parse(manifestFile.source)
|
|
36
|
-
expect(Object.keys(manifests)).toHaveLength(2)
|
|
37
|
-
expect(manifests['settings.js'].meta.manifests[0].namespace).toEqual('settings')
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
it('works in dev mode', async function () {
|
|
41
|
-
server = await createServer({
|
|
42
|
-
root: path.dirname(new URL(import.meta.url).pathname),
|
|
43
|
-
logLevel: 'silent',
|
|
44
|
-
plugins: [vitePluginOxManifests({
|
|
45
|
-
|
|
46
|
-
})]
|
|
47
|
-
})
|
|
48
|
-
await server.listen(PORT)
|
|
49
|
-
|
|
50
|
-
const res = await fetch(`http://localhost:${PORT}/api/manifest.json`)
|
|
51
|
-
const manifests = await res.json()
|
|
52
|
-
|
|
53
|
-
expect(manifests).toHaveLength(2)
|
|
54
|
-
expect(manifests[0].namespace).toEqual('settings')
|
|
55
|
-
})
|
|
56
|
-
})
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from '@jest/globals'
|
|
2
|
-
import { build, createServer } from 'vite'
|
|
3
|
-
import vitePluginOxExternals from '@open-xchange/vite-plugin-ox-externals'
|
|
4
|
-
import path from 'path'
|
|
5
|
-
import vitePluginOxManifests from '../../index'
|
|
6
|
-
import { getFileFromBundle, getPort } from '../util'
|
|
7
|
-
|
|
8
|
-
const PORT = getPort()
|
|
9
|
-
|
|
10
|
-
describe('Settings external', function () {
|
|
11
|
-
let server
|
|
12
|
-
|
|
13
|
-
afterEach(async function () {
|
|
14
|
-
if (server) {
|
|
15
|
-
await server.close()
|
|
16
|
-
server = null
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
it('works', async function () {
|
|
21
|
-
const bundle = await build({
|
|
22
|
-
root: path.dirname(new URL(import.meta.url).pathname),
|
|
23
|
-
logLevel: 'silent',
|
|
24
|
-
build: {
|
|
25
|
-
write: false,
|
|
26
|
-
rollupOptions: {
|
|
27
|
-
input: {}
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
plugins: [vitePluginOxManifests({
|
|
31
|
-
|
|
32
|
-
}), vitePluginOxExternals({
|
|
33
|
-
prefix: '$'
|
|
34
|
-
})]
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
const manifestFile = getFileFromBundle('manifest', bundle)
|
|
38
|
-
const manifests = JSON.parse(manifestFile.source)
|
|
39
|
-
expect(Object.keys(manifests)).toHaveLength(2)
|
|
40
|
-
expect(manifests['settings.js'].meta.manifests[0].namespace).toEqual('settings')
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it('works in dev mode', async function () {
|
|
44
|
-
server = await createServer({
|
|
45
|
-
root: path.dirname(new URL(import.meta.url).pathname),
|
|
46
|
-
logLevel: 'silent',
|
|
47
|
-
plugins: [vitePluginOxManifests({
|
|
48
|
-
|
|
49
|
-
}), vitePluginOxExternals({
|
|
50
|
-
prefix: '$'
|
|
51
|
-
})]
|
|
52
|
-
})
|
|
53
|
-
await server.listen(PORT)
|
|
54
|
-
|
|
55
|
-
const res = await fetch(`http://localhost:${PORT}/api/manifest.json`)
|
|
56
|
-
const manifests = await res.json()
|
|
57
|
-
|
|
58
|
-
expect(manifests).toHaveLength(2)
|
|
59
|
-
expect(manifests[0].namespace).toEqual('settings')
|
|
60
|
-
})
|
|
61
|
-
})
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from '@jest/globals'
|
|
2
|
-
import { build } from 'vite'
|
|
3
|
-
import vitePluginOxExternals from '@open-xchange/vite-plugin-ox-externals'
|
|
4
|
-
import path from 'path'
|
|
5
|
-
import vitePluginOxManifests from '../../index'
|
|
6
|
-
import { getFileFromBundle } from '../util'
|
|
7
|
-
|
|
8
|
-
describe('Settings typescript', function () {
|
|
9
|
-
it('works', async function () {
|
|
10
|
-
const bundle = await build({
|
|
11
|
-
root: path.dirname(new URL(import.meta.url).pathname),
|
|
12
|
-
logLevel: 'silent',
|
|
13
|
-
build: {
|
|
14
|
-
write: false,
|
|
15
|
-
rollupOptions: {
|
|
16
|
-
input: {}
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
plugins: [vitePluginOxManifests({
|
|
20
|
-
|
|
21
|
-
}), vitePluginOxExternals({
|
|
22
|
-
prefix: '$'
|
|
23
|
-
})]
|
|
24
|
-
})
|
|
25
|
-
const manifestFile = getFileFromBundle('manifest', bundle)
|
|
26
|
-
const manifests = JSON.parse(manifestFile.source)
|
|
27
|
-
expect(Object.keys(manifests)).toHaveLength(2)
|
|
28
|
-
expect(manifests['settings.ts'].meta.manifests[0].namespace).toEqual('settings')
|
|
29
|
-
})
|
|
30
|
-
})
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from '@jest/globals'
|
|
2
|
-
import { build } from 'vite'
|
|
3
|
-
import path from 'path'
|
|
4
|
-
import vitePluginOxManifests from '../../index'
|
|
5
|
-
import { getFileFromBundle } from '../util'
|
|
6
|
-
|
|
7
|
-
describe('Settings like in core, with requirements', function () {
|
|
8
|
-
it('works', async function () {
|
|
9
|
-
const bundle = await build({
|
|
10
|
-
root: path.dirname(new URL(import.meta.url).pathname),
|
|
11
|
-
logLevel: 'silent',
|
|
12
|
-
build: {
|
|
13
|
-
write: false,
|
|
14
|
-
rollupOptions: {
|
|
15
|
-
input: {},
|
|
16
|
-
external: ['@/io.ox/core/settings']
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
plugins: [vitePluginOxManifests({
|
|
20
|
-
|
|
21
|
-
})]
|
|
22
|
-
})
|
|
23
|
-
const manifestFile = getFileFromBundle('manifest', bundle)
|
|
24
|
-
const manifests = JSON.parse(manifestFile.source)
|
|
25
|
-
expect(Object.keys(manifests)).toHaveLength(7)
|
|
26
|
-
expect(manifests['settings.js'].meta.manifests[0].namespace).toEqual('settings')
|
|
27
|
-
expect(manifests['settings.js'].meta.manifests[0].requires).toEqual('cap')
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it('merges requirements for manifests', async () => {
|
|
31
|
-
const bundle = await build({
|
|
32
|
-
root: path.dirname(new URL(import.meta.url).pathname),
|
|
33
|
-
logLevel: 'silent',
|
|
34
|
-
build: {
|
|
35
|
-
write: false,
|
|
36
|
-
rollupOptions: {
|
|
37
|
-
input: {},
|
|
38
|
-
external: ['@/io.ox/core/settings']
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
plugins: [vitePluginOxManifests({
|
|
42
|
-
|
|
43
|
-
})]
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
const manifestFile = getFileFromBundle('manifest', bundle)
|
|
47
|
-
const manifests = JSON.parse(manifestFile.source)
|
|
48
|
-
expect(Object.keys(manifests)).toHaveLength(7)
|
|
49
|
-
expect(manifests['other-settings.js'].meta.manifests[0].requires).toBeUndefined()
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
it('merges single requirement for manifests', async () => {
|
|
53
|
-
const bundle = await build({
|
|
54
|
-
root: path.dirname(new URL(import.meta.url).pathname),
|
|
55
|
-
logLevel: 'silent',
|
|
56
|
-
build: {
|
|
57
|
-
write: false,
|
|
58
|
-
rollupOptions: {
|
|
59
|
-
input: {},
|
|
60
|
-
external: ['@/io.ox/core/settings']
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
plugins: [vitePluginOxManifests({
|
|
64
|
-
|
|
65
|
-
})]
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
const manifestFile = getFileFromBundle('manifest', bundle)
|
|
69
|
-
const manifests = JSON.parse(manifestFile.source)
|
|
70
|
-
expect(Object.keys(manifests)).toHaveLength(7)
|
|
71
|
-
expect(manifests['third-settings.js'].meta.manifests[0].requires).toBeUndefined()
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it('merges multiple requirement for manifests', async () => {
|
|
75
|
-
const bundle = await build({
|
|
76
|
-
root: path.dirname(new URL(import.meta.url).pathname),
|
|
77
|
-
logLevel: 'silent',
|
|
78
|
-
build: {
|
|
79
|
-
write: false,
|
|
80
|
-
rollupOptions: {
|
|
81
|
-
input: {},
|
|
82
|
-
external: ['@/io.ox/core/settings']
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
plugins: [vitePluginOxManifests({
|
|
86
|
-
|
|
87
|
-
})]
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
const manifestFile = getFileFromBundle('manifest', bundle)
|
|
91
|
-
const manifests = JSON.parse(manifestFile.source)
|
|
92
|
-
expect(Object.keys(manifests)).toHaveLength(7)
|
|
93
|
-
expect(manifests['forth-settings.js'].meta.manifests[0].requires).toBe('((capa && capb) || capc)||cap')
|
|
94
|
-
})
|
|
95
|
-
})
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from '@jest/globals'
|
|
2
|
-
import { deepMergeObject } from '../../src/util'
|
|
3
|
-
|
|
4
|
-
describe('Deep merge', function () {
|
|
5
|
-
it('with objects', function () {
|
|
6
|
-
expect(deepMergeObject({
|
|
7
|
-
a: {
|
|
8
|
-
b: 1
|
|
9
|
-
}
|
|
10
|
-
}, {
|
|
11
|
-
a: {
|
|
12
|
-
c: 2
|
|
13
|
-
},
|
|
14
|
-
d: 3
|
|
15
|
-
})).toEqual({
|
|
16
|
-
a: {
|
|
17
|
-
b: 1,
|
|
18
|
-
c: 2
|
|
19
|
-
},
|
|
20
|
-
d: 3
|
|
21
|
-
})
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
it('with arrays', function () {
|
|
25
|
-
expect(deepMergeObject({
|
|
26
|
-
a: [1, 2, 3]
|
|
27
|
-
}, {
|
|
28
|
-
a: [4, 5, 6]
|
|
29
|
-
})).toEqual({
|
|
30
|
-
a: [1, 2, 3, 4, 5, 6]
|
|
31
|
-
})
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
it('with strings', function () {
|
|
35
|
-
expect(deepMergeObject({
|
|
36
|
-
a: '1'
|
|
37
|
-
}, {
|
|
38
|
-
a: '2'
|
|
39
|
-
})).toEqual({
|
|
40
|
-
a: '2'
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
it('with different types - arrays / object', function () {
|
|
45
|
-
expect(() => deepMergeObject({
|
|
46
|
-
a: []
|
|
47
|
-
}, {
|
|
48
|
-
a: {}
|
|
49
|
-
})).toThrow()
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
it('with different types - object / string', function () {
|
|
53
|
-
expect(() => deepMergeObject({
|
|
54
|
-
a: {}
|
|
55
|
-
}, {
|
|
56
|
-
a: ''
|
|
57
|
-
})).toThrow()
|
|
58
|
-
})
|
|
59
|
-
})
|