@open-xchange/vite-plugin-ox-manifests 0.5.2 → 0.5.4

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.
Files changed (108) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/coverage/clover.xml +348 -0
  3. package/coverage/coverage-final.json +11 -0
  4. package/coverage/lcov-report/base.css +224 -0
  5. package/coverage/lcov-report/block-navigation.js +87 -0
  6. package/coverage/lcov-report/favicon.png +0 -0
  7. package/coverage/lcov-report/index.html +161 -0
  8. package/coverage/lcov-report/prettify.css +1 -0
  9. package/coverage/lcov-report/prettify.js +2 -0
  10. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  11. package/coverage/lcov-report/sorter.js +196 -0
  12. package/coverage/lcov-report/vite-plugin-ox-manifests/index.html +116 -0
  13. package/coverage/lcov-report/vite-plugin-ox-manifests/index.js.html +601 -0
  14. package/coverage/lcov-report/vite-plugin-ox-manifests/src/constants.js.html +88 -0
  15. package/coverage/lcov-report/vite-plugin-ox-manifests/src/index.html +131 -0
  16. package/coverage/lcov-report/vite-plugin-ox-manifests/src/plugins/gettext.js.html +292 -0
  17. package/coverage/lcov-report/vite-plugin-ox-manifests/src/plugins/index.html +191 -0
  18. package/coverage/lcov-report/vite-plugin-ox-manifests/src/plugins/manifests.js.html +493 -0
  19. package/coverage/lcov-report/vite-plugin-ox-manifests/src/plugins/meta.js.html +124 -0
  20. package/coverage/lcov-report/vite-plugin-ox-manifests/src/plugins/relative-paths.js.html +97 -0
  21. package/coverage/lcov-report/vite-plugin-ox-manifests/src/plugins/serve.js.html +277 -0
  22. package/coverage/lcov-report/vite-plugin-ox-manifests/src/plugins/settings.js.html +526 -0
  23. package/coverage/lcov-report/vite-plugin-ox-manifests/src/util.js.html +268 -0
  24. package/coverage/lcov.info +748 -0
  25. package/package.json +11 -19
  26. package/src/plugins/relative-paths.js +0 -3
  27. package/.eslintrc.cjs +0 -10
  28. package/.gitlab-ci.yml +0 -26
  29. package/test/.eslintrc.cjs +0 -5
  30. package/test/deps/main.test.js +0 -32
  31. package/test/gettext-chunked/another_chunk.js +0 -4
  32. package/test/gettext-chunked/i18n/de_DE.po +0 -16
  33. package/test/gettext-chunked/i18n/en_US.po +0 -16
  34. package/test/gettext-chunked/main.test.js +0 -67
  35. package/test/gettext-chunked/manifest.json +0 -3
  36. package/test/gettext-chunked/register.js +0 -6
  37. package/test/gettext-multiple/i18n/de_DE.po +0 -22
  38. package/test/gettext-multiple/i18n/en_US.po +0 -22
  39. package/test/gettext-multiple/main.test.js +0 -71
  40. package/test/gettext-multiple/manifest.json +0 -3
  41. package/test/gettext-multiple/register.js +0 -4
  42. package/test/gettext-simple/i18n/de_DE.po +0 -18
  43. package/test/gettext-simple/i18n/en_US.po +0 -18
  44. package/test/gettext-simple/main.test.js +0 -61
  45. package/test/gettext-simple/manifest.json +0 -3
  46. package/test/gettext-simple/register.js +0 -3
  47. package/test/hmr/main.test.js +0 -121
  48. package/test/hmr/manifest.json +0 -3
  49. package/test/hmr/register.js +0 -1
  50. package/test/hmr/settings.js +0 -3
  51. package/test/html-relative-paths/index.html +0 -7
  52. package/test/html-relative-paths/index.js +0 -3
  53. package/test/html-relative-paths/main.test.js +0 -39
  54. package/test/html-relative-paths/other.html +0 -7
  55. package/test/html-relative-paths/style.css +0 -1
  56. package/test/manifest-dependencies/main.test.js +0 -26
  57. package/test/manifest-dependencies/manifest.json +0 -3
  58. package/test/manifest-dependencies/register.js +0 -3
  59. package/test/manifest-dependencies/style.less +0 -1
  60. package/test/manifest-dynamic-deps/main.test.js +0 -28
  61. package/test/manifest-dynamic-deps/manifest.json +0 -3
  62. package/test/manifest-dynamic-deps/register.js +0 -7
  63. package/test/manifest-dynamic-deps/some_dep.js +0 -5
  64. package/test/manifest-dynamic-deps/style.less +0 -1
  65. package/test/manifest-multiple/entry1.js +0 -1
  66. package/test/manifest-multiple/main.test.js +0 -83
  67. package/test/manifest-multiple/manifest.json +0 -7
  68. package/test/manifest-multiple/sub/entry2.js +0 -3
  69. package/test/manifest-multiple/sub/manifest.json +0 -4
  70. package/test/manifest-simple/main.test.js +0 -105
  71. package/test/manifest-simple/manifest.json +0 -3
  72. package/test/manifest-simple/register.js +0 -1
  73. package/test/meta/main.test.js +0 -25
  74. package/test/meta/manifest.json +0 -3
  75. package/test/meta/register.js +0 -1
  76. package/test/preload-helper-bundled/async.js +0 -1
  77. package/test/preload-helper-bundled/index.js +0 -1
  78. package/test/preload-helper-bundled/main.test.js +0 -32
  79. package/test/preload-helper-bundled/manifest.json +0 -4
  80. package/test/preload-helper-separate/bar.js +0 -1
  81. package/test/preload-helper-separate/foo.js +0 -3
  82. package/test/preload-helper-separate/index.js +0 -1
  83. package/test/preload-helper-separate/main.test.js +0 -34
  84. package/test/preload-helper-separate/manifest.json +0 -4
  85. package/test/settings-core/index.js +0 -4
  86. package/test/settings-core/main.test.js +0 -56
  87. package/test/settings-core/manifest.json +0 -4
  88. package/test/settings-core/no-settings.js +0 -3
  89. package/test/settings-core/settings.js +0 -3
  90. package/test/settings-external/index.js +0 -3
  91. package/test/settings-external/main.test.js +0 -61
  92. package/test/settings-external/manifest.json +0 -4
  93. package/test/settings-external/settings.js +0 -3
  94. package/test/settings-ts/index.js +0 -3
  95. package/test/settings-ts/main.test.js +0 -30
  96. package/test/settings-ts/manifest.json +0 -4
  97. package/test/settings-ts/settings.ts +0 -4
  98. package/test/settings-with-requirements/foo.js +0 -3
  99. package/test/settings-with-requirements/forth-settings.js +0 -3
  100. package/test/settings-with-requirements/index.js +0 -5
  101. package/test/settings-with-requirements/main.test.js +0 -95
  102. package/test/settings-with-requirements/manifest.json +0 -12
  103. package/test/settings-with-requirements/other-settings.js +0 -3
  104. package/test/settings-with-requirements/other.js +0 -4
  105. package/test/settings-with-requirements/settings.js +0 -3
  106. package/test/settings-with-requirements/third-settings.js +0 -3
  107. package/test/util/deep-merge.test.js +0 -59
  108. package/test/util.js +0 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-xchange/vite-plugin-ox-manifests",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "A vite plugin to concat and serve ox manifests",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -13,28 +13,20 @@
13
13
  "test": "NODE_OPTIONS=\"--experimental-vm-modules --max_old_space_size=1792\" jest test/**/*.test.js --testTimeout=15000 --runInBand"
14
14
  },
15
15
  "dependencies": {
16
- "@open-xchange/rollup-plugin-po2json": "^0.5.0",
16
+ "@open-xchange/rollup-plugin-po2json": "^0.7.1",
17
17
  "chokidar": "^3.5.1",
18
- "fast-glob": "^3.2.5",
19
- "magic-string": "^0.26.2",
20
- "parseurl": "^1.3.3"
18
+ "fast-glob": "^3.2.12",
19
+ "parseurl": "^1.3.3",
20
+ "vite": "^4.0.2"
21
21
  },
22
22
  "devDependencies": {
23
- "@open-xchange/vite-plugin-ox-externals": "^0.3.0",
24
- "@rollup/plugin-json": "^4.1.0",
25
- "eslint": "^8.21.0",
26
- "eslint-config-standard": "^17.0.0",
27
- "eslint-plugin-import": "^2.26.0",
28
- "eslint-plugin-jest": "^26.8.0",
29
- "eslint-plugin-node": "^11.1.0",
30
- "eslint-plugin-promise": "^6.0.0",
31
- "express": "^4.18.1",
32
- "husky": "^8.0.1",
33
- "jest": "^28.1.3",
23
+ "@open-xchange/lint": "^0.0.2",
24
+ "@open-xchange/vite-plugin-ox-externals": "^0.4.1",
25
+ "eslint-plugin-jest": "^27.2.1",
26
+ "express": "^4.18.2",
27
+ "jest": "^29.5.0",
34
28
  "less": "^4.1.3",
35
- "rollup": "^2.77.2",
36
- "rollup-plugin-auto-external": "^2.0.0",
37
- "vite": "^4.0.2"
29
+ "rollup": "^3.19.1"
38
30
  },
39
31
  "lint-staged": {
40
32
  "*.js": "eslint --cache --fix"
@@ -1,6 +1,3 @@
1
- import { PROJECT_NAME as name } from '../constants.js'
2
- import MagicString from 'magic-string'
3
-
4
1
  export default function ({ transformAbsolutePaths } = {}) {
5
2
  if (transformAbsolutePaths !== undefined) console.warn("transformAbsolutePaths is no longer used. Use `base: './'` with vite 3")
6
3
  return {}
package/.eslintrc.cjs DELETED
@@ -1,10 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- env: {
4
- node: true,
5
- es2021: true
6
- },
7
- extends: [
8
- 'standard'
9
- ]
10
- }
package/.gitlab-ci.yml DELETED
@@ -1,26 +0,0 @@
1
- image: node:18-alpine
2
-
3
- stages:
4
- - test
5
-
6
- unit tests:
7
- stage: test
8
- variables:
9
- KUBERNETES_CPU_REQUEST: 2
10
- KUBERNETES_CPU_LIMIT: 3
11
- KUBERNETES_MEMORY_REQUEST: 2Gi
12
- KUBERNETES_MEMORY_LIMIT: 2Gi
13
- script:
14
- - apk add git
15
- - yarn
16
- - yarn test --ci --coverage
17
- coverage: /^Lines\s*:\s\d+.\d+\%/
18
- artifacts:
19
- reports:
20
- junit: output/junit.xml
21
- coverage_report:
22
- coverage_format: cobertura
23
- path: output/coverage/cobertura-coverage.xml
24
- needs: []
25
- tags:
26
- - kubernetes
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- plugins: [
3
- 'jest'
4
- ]
5
- }
@@ -1,32 +0,0 @@
1
- import { describe, it, expect, afterEach } from '@jest/globals'
2
- import { createServer } from 'vite'
3
- import path from 'path'
4
- import vitePluginOxManifests from '../../index'
5
- import { getPort } from '../util'
6
-
7
- const PORT = getPort()
8
- const __dirname = path.dirname(new URL(import.meta.url).pathname)
9
-
10
- describe('deps', function () {
11
- let server
12
-
13
- afterEach(async function () {
14
- if (server) {
15
- await server.close()
16
- server = null
17
- }
18
- })
19
-
20
- it('deliver empty deps in dev mode', async function () {
21
- server = await createServer({
22
- root: __dirname,
23
- logLevel: 'silent',
24
- plugins: [vitePluginOxManifests({})]
25
- })
26
- await server.listen(PORT)
27
-
28
- const res = await fetch(`http://localhost:${PORT}/api/deps.json`)
29
- const deps = await res.json()
30
- expect(deps).toEqual({})
31
- })
32
- })
@@ -1,4 +0,0 @@
1
- import gt from 'gettext'
2
-
3
- export const five = 5
4
- export default gt('five')
@@ -1,16 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: \n"
4
- "PO-Revision-Date: 2014-01-15 14:13+0100\n"
5
- "Last-Translator: Julian Bäume <julian.baeume@open-xchange.com>\n"
6
- "Language-Team: German <julian.baeume@open-xchange.com>\n"
7
- "Language: de_DE\n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=UTF-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
12
- "X-Generator: Lokalize 1.5\n"
13
-
14
- #: module:i18n
15
- msgid "Hello world!"
16
- msgstr "Hallo Welt!"
@@ -1,16 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: \n"
4
- "PO-Revision-Date: 2014-01-15 14:13+0100\n"
5
- "Last-Translator: Julian Bäume <julian.baeume@open-xchange.com>\n"
6
- "Language-Team: German <julian.baeume@open-xchange.com>\n"
7
- "Language: en_US\n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=UTF-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
12
- "X-Generator: Lokalize 1.5\n"
13
-
14
- #: module:i18n
15
- msgid "Hello world!"
16
- msgstr ""
@@ -1,67 +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 rollupPluginPo2Json from '@open-xchange/rollup-plugin-po2json'
6
- import { getFileFromBundle, getPort } from '../util'
7
-
8
- const PORT = getPort()
9
- const __dirname = path.dirname(new URL(import.meta.url).pathname)
10
-
11
- describe('Dictionary in modules with dynamic imports', function () {
12
- let server
13
-
14
- afterEach(async function () {
15
- if (server) {
16
- await server.close()
17
- server = null
18
- }
19
- })
20
-
21
- it('works', async function () {
22
- const bundle = await build({
23
- root: __dirname,
24
- logLevel: 'silent',
25
- build: {
26
- write: false,
27
- rollupOptions: {
28
- input: { }
29
- }
30
- },
31
- plugins: [rollupPluginPo2Json({
32
- poFiles: __dirname + '/i18n/*.po'
33
- }), vitePluginOxManifests({
34
-
35
- })]
36
- })
37
-
38
- const manifestFile = getFileFromBundle('manifest', bundle)
39
- const manifests = JSON.parse(manifestFile.source)
40
- expect(Object.keys(manifests)).toHaveLength(7)
41
- expect(manifests['register.js'].meta.manifests[0].namespace).toEqual('test')
42
- expect(manifests['../../i18n.js'].meta.gettext.dictionary).toEqual(true)
43
- expect(manifests['../../i18n.js'].meta.manifests[0].namespace).toEqual('i18n')
44
- })
45
-
46
- it('works in dev mode', async function () {
47
- server = await createServer({
48
- root: __dirname,
49
- logLevel: 'silent',
50
- plugins: [rollupPluginPo2Json({
51
- poFiles: __dirname + '/i18n/*.po'
52
- }), vitePluginOxManifests({
53
-
54
- })]
55
- })
56
- await server.listen(PORT)
57
-
58
- const res = await fetch(`http://localhost:${PORT}/api/manifest.json`)
59
- const manifests = await res.json()
60
-
61
- expect(manifests).toHaveLength(2)
62
- expect(manifests[0].namespace).toEqual('i18n')
63
- expect(manifests[0].path).toEqual('i18n')
64
- expect(manifests[1].namespace).toEqual('test')
65
- expect(manifests[1].path).toContain('register')
66
- })
67
- })
@@ -1,3 +0,0 @@
1
- {
2
- "namespace": "test"
3
- }
@@ -1,6 +0,0 @@
1
- import gt from 'gettext'
2
-
3
- export async function doSomethingDynamic () {
4
- const { five } = await import('./another_chunk.js')
5
- console.log(gt('Hello world!'), five)
6
- }
@@ -1,22 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: \n"
4
- "PO-Revision-Date: 2014-01-15 14:13+0100\n"
5
- "Last-Translator: Julian Bäume <julian.baeume@open-xchange.com>\n"
6
- "Language-Team: German <julian.baeume@open-xchange.com>\n"
7
- "Language: de_DE\n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=UTF-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
12
- "X-Generator: Lokalize 1.5\n"
13
-
14
- #. empty is meant as a state (folder is empty)
15
- #: module:i18n
16
- msgctxt "describe state"
17
- msgid "Empty folder"
18
- msgstr "Leerer Ordner"
19
-
20
- #: module:foobar
21
- msgid "String with \" in it"
22
- msgstr "Zeichenkette mit \""
@@ -1,22 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: \n"
4
- "PO-Revision-Date: 2014-01-15 14:13+0100\n"
5
- "Last-Translator: Julian Bäume <julian.baeume@open-xchange.com>\n"
6
- "Language-Team: German <julian.baeume@open-xchange.com>\n"
7
- "Language: en_US\n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=UTF-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
12
- "X-Generator: Lokalize 1.5\n"
13
-
14
- #. empty is meant as a state (folder is empty)
15
- #: module:i18n
16
- msgctxt "describe state"
17
- msgid "Empty folder"
18
- msgstr ""
19
-
20
- #: module:foobar
21
- msgid "String with \" in it"
22
- msgstr ""
@@ -1,71 +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 rollupPluginPo2Json from '@open-xchange/rollup-plugin-po2json'
6
- import { getFileFromBundle, getPort } from '../util'
7
-
8
- const PORT = getPort()
9
- const __dirname = path.dirname(new URL(import.meta.url).pathname)
10
-
11
- describe('Multiple dictionaries gettext scenario', function () {
12
- let server
13
-
14
- afterEach(async function () {
15
- if (server) {
16
- await server.close()
17
- server = null
18
- }
19
- })
20
-
21
- it('works', async function () {
22
- const bundle = await build({
23
- root: __dirname,
24
- logLevel: 'silent',
25
- build: {
26
- write: false,
27
- rollupOptions: {
28
- input: {
29
- i18n: 'i18n'
30
- }
31
- }
32
- },
33
- plugins: [rollupPluginPo2Json({
34
- poFiles: __dirname + '/i18n/*.po'
35
- }), vitePluginOxManifests({
36
-
37
- })]
38
- })
39
-
40
- const manifestFile = getFileFromBundle('manifest', bundle)
41
- const manifests = JSON.parse(manifestFile.source)
42
- expect(Object.keys(manifests)).toHaveLength(10)
43
- expect(manifests['register.js'].meta.manifests[0].namespace).toEqual('test')
44
- expect(manifests['../../foobar.js'].meta.manifests[0].namespace).toEqual('i18n')
45
- expect(manifests['../../i18n'].meta.manifests[0].namespace).toEqual('i18n')
46
- })
47
-
48
- it('works in dev mode', async function () {
49
- server = await createServer({
50
- root: __dirname,
51
- logLevel: 'silent',
52
- plugins: [rollupPluginPo2Json({
53
- poFiles: __dirname + '/i18n/*.po'
54
- }), vitePluginOxManifests({
55
-
56
- })]
57
- })
58
- await server.listen(PORT)
59
-
60
- const res = await fetch(`http://localhost:${PORT}/api/manifest.json`)
61
- const manifests = await res.json()
62
-
63
- expect(manifests).toHaveLength(3)
64
- expect(manifests[0].namespace).toEqual('i18n')
65
- expect(manifests[0].path).toEqual('foobar')
66
- expect(manifests[1].namespace).toEqual('i18n')
67
- expect(manifests[1].path).toEqual('i18n')
68
- expect(manifests[2].namespace).toEqual('test')
69
- expect(manifests[2].path).toContain('register')
70
- })
71
- })
@@ -1,3 +0,0 @@
1
- {
2
- "namespace": "test"
3
- }
@@ -1,4 +0,0 @@
1
- import gt from 'gettext'
2
- import gt2 from 'gettext?dictionary=foobar'
3
-
4
- console.log(gt('Hello world'), gt2('Foo bar!'))
@@ -1,18 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: \n"
4
- "PO-Revision-Date: 2014-01-15 14:13+0100\n"
5
- "Last-Translator: Julian Bäume <julian.baeume@open-xchange.com>\n"
6
- "Language-Team: German <julian.baeume@open-xchange.com>\n"
7
- "Language: de_DE\n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=UTF-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
12
- "X-Generator: Lokalize 1.5\n"
13
-
14
- #. empty is meant as a state (folder is empty)
15
- #: module:i18n
16
- msgctxt "describe state"
17
- msgid "Empty folder"
18
- msgstr "Leerer Ordner"
@@ -1,18 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: \n"
4
- "PO-Revision-Date: 2014-01-15 14:13+0100\n"
5
- "Last-Translator: Julian Bäume <julian.baeume@open-xchange.com>\n"
6
- "Language-Team: German <julian.baeume@open-xchange.com>\n"
7
- "Language: en_US\n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=UTF-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
12
- "X-Generator: Lokalize 1.5\n"
13
-
14
- #. empty is meant as a state (folder is empty)
15
- #: module:i18n
16
- msgctxt "describe state"
17
- msgid "Empty folder"
18
- msgstr ""
@@ -1,61 +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 rollupPluginPo2Json from '@open-xchange/rollup-plugin-po2json'
6
- import { getFileFromBundle, getPort } from '../util'
7
-
8
- const PORT = getPort()
9
- const __dirname = path.dirname(new URL(import.meta.url).pathname)
10
-
11
- describe('Simple gettext scenario', function () {
12
- let server
13
-
14
- afterEach(async function () {
15
- if (server) {
16
- await server.close()
17
- server = null
18
- }
19
- })
20
-
21
- it('works', async function () {
22
- const bundle = await build({
23
- root: __dirname,
24
- logLevel: 'silent',
25
- build: { write: false, rollupOptions: { input: {} } },
26
- plugins: [rollupPluginPo2Json({
27
- poFiles: __dirname + '/i18n/*.po'
28
- }), vitePluginOxManifests({
29
-
30
- })]
31
- })
32
-
33
- const manifestFile = getFileFromBundle('manifest', bundle)
34
- const manifests = JSON.parse(manifestFile.source)
35
- expect(Object.keys(manifests)).toHaveLength(5)
36
- expect(manifests['register.js'].meta.manifests[0].namespace).toEqual('test')
37
- expect(manifests['../../i18n.js'].meta.manifests[0].namespace).toEqual('i18n')
38
- })
39
-
40
- it('works in dev mode', async function () {
41
- server = await createServer({
42
- root: __dirname,
43
- logLevel: 'silent',
44
- plugins: [rollupPluginPo2Json({
45
- poFiles: __dirname + '/i18n/*.po'
46
- }), vitePluginOxManifests({
47
-
48
- })]
49
- })
50
- await server.listen(PORT)
51
-
52
- const res = await fetch(`http://localhost:${PORT}/api/manifest.json`)
53
- const manifests = await res.json()
54
-
55
- expect(manifests).toHaveLength(2)
56
- expect(manifests[0].namespace).toEqual('i18n')
57
- expect(manifests[0].path).toContain('i18n')
58
- expect(manifests[1].namespace).toEqual('test')
59
- expect(manifests[1].path).toContain('register')
60
- })
61
- })
@@ -1,3 +0,0 @@
1
- {
2
- "namespace": "test"
3
- }
@@ -1,3 +0,0 @@
1
- import gt from 'gettext'
2
-
3
- console.log(gt('Hello world'))
@@ -1,121 +0,0 @@
1
- import { describe, it, expect, beforeEach, afterEach } from '@jest/globals'
2
- import { createServer } from 'vite'
3
- import path from 'path'
4
- import vitePluginOxManifests from '../../index'
5
- import { getPort } from '../util'
6
- import { readFileSync, writeFileSync } from 'fs'
7
- import { waitForReload } from '../../src/util'
8
- import vitePluginOxExternals from '@open-xchange/vite-plugin-ox-externals'
9
-
10
- const __dirname = path.dirname(new URL(import.meta.url).pathname)
11
- const files = ['register.js', 'settings.js']
12
- const PORT = getPort()
13
-
14
- describe('HMR', function () {
15
- let server, data
16
-
17
- beforeEach(function () {
18
- data = files.map(f => readFileSync(path.join(__dirname, f)))
19
- })
20
-
21
- afterEach(async function () {
22
- data.forEach((d, i) => writeFileSync(path.join(__dirname, files[i]), d))
23
- data = null
24
- await server?.close()
25
- server = null
26
- })
27
-
28
- it('adds timestamps to manifest files', async function () {
29
- server = await createServer({
30
- root: __dirname,
31
- logLevel: 'silent',
32
- plugins: [vitePluginOxManifests({
33
-
34
- }), vitePluginOxExternals({
35
- prefix: '$'
36
- })]
37
- })
38
- await server.listen(PORT)
39
-
40
- // fetch this file to start watcher
41
- await fetch(`http://localhost:${PORT}/register.js`)
42
-
43
- const manifests = await fetch(`http://localhost:${PORT}/manifests`).then(r => r.json())
44
- expect(Object.keys(manifests)).toHaveLength(2)
45
- expect(manifests[1]).not.toContain('raw')
46
-
47
- writeFileSync(path.join(__dirname, 'register.js'), 'console.log("Changed")')
48
-
49
- await waitForReload(server)
50
-
51
- const manifestsWithHMR = await fetch(`http://localhost:${PORT}/manifests`).then(r => r.json())
52
- expect(Object.keys(manifestsWithHMR)).toHaveLength(2)
53
- expect(manifestsWithHMR[1].namespace).toEqual('test')
54
- expect(manifestsWithHMR[1].raw).toMatch(/\/register\.js\?t=\d+/)
55
- })
56
-
57
- it('adds timestamps to settings manifest files', async function () {
58
- server = await createServer({
59
- root: __dirname,
60
- logLevel: 'silent',
61
- plugins: [vitePluginOxManifests({
62
-
63
- }), vitePluginOxExternals({
64
- prefix: '$'
65
- })]
66
- })
67
- await server.listen(PORT)
68
-
69
- // fetch this file to start watcher
70
- await fetch(`http://localhost:${PORT}/settings.js`)
71
-
72
- const manifests = await fetch(`http://localhost:${PORT}/manifests`).then(r => r.json())
73
- expect(Object.keys(manifests)).toHaveLength(2)
74
- expect(manifests[0]).not.toContain('raw')
75
-
76
- writeFileSync(path.join(__dirname, 'settings.js'), `/* a comment */${data[1].toString()}`)
77
-
78
- await waitForReload(server)
79
-
80
- const manifestsWithHMR = await fetch(`http://localhost:${PORT}/manifests`).then(r => r.json())
81
- expect(Object.keys(manifestsWithHMR)).toHaveLength(2)
82
- expect(manifestsWithHMR[0].namespace).toEqual('settings')
83
- expect(manifestsWithHMR[0].raw).toMatch(/\/settings\.js\?t=\d+/)
84
- })
85
-
86
- it('includes base-path in manifests', async function () {
87
- server = await createServer({
88
- root: __dirname,
89
- logLevel: 'silent',
90
- base: '/appsuite',
91
- plugins: [vitePluginOxManifests({
92
-
93
- }), vitePluginOxExternals({
94
- prefix: '$'
95
- })]
96
- })
97
- await server.listen(PORT)
98
-
99
- // fetch this file to start watcher
100
- await fetch(`http://localhost:${PORT}/appsuite/register.js`)
101
- await fetch(`http://localhost:${PORT}/appsuite/settings.js`)
102
-
103
- const manifests = await fetch(`http://localhost:${PORT}/appsuite/manifests`).then(r => r.json())
104
- expect(Object.keys(manifests)).toHaveLength(2)
105
- expect(manifests[0]).not.toContain('raw')
106
- expect(manifests[1]).not.toContain('raw')
107
-
108
- writeFileSync(path.join(__dirname, 'register.js'), 'console.log("Changed")')
109
- await waitForReload(server)
110
-
111
- writeFileSync(path.join(__dirname, 'settings.js'), `/* a comment */${data[1].toString()}`)
112
- await waitForReload(server)
113
-
114
- const manifestsWithHMR = await fetch(`http://localhost:${PORT}/appsuite/manifests`).then(r => r.json())
115
- expect(Object.keys(manifestsWithHMR)).toHaveLength(2)
116
- expect(manifestsWithHMR[0].namespace).toEqual('settings')
117
- expect(manifestsWithHMR[0].raw).toMatch(/\/appsuite\/settings\.js\?t=\d+/)
118
- expect(manifestsWithHMR[1].namespace).toEqual('test')
119
- expect(manifestsWithHMR[1].raw).toMatch(/\/appsuite\/register\.js\?t=\d+/)
120
- })
121
- })
@@ -1,3 +0,0 @@
1
- {
2
- "namespace": "test"
3
- }
@@ -1 +0,0 @@
1
- console.log('Hello world!')
@@ -1,3 +0,0 @@
1
- import { Settings } from '$/io.ox/core/settings'
2
-
3
- export const settings = new Settings('test', () => {})
@@ -1,7 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head></head>
4
- <body>
5
- <script type="module" src="./index.js"></script>
6
- </body>
7
- </html>
@@ -1,3 +0,0 @@
1
- import './style.css'
2
-
3
- console.log('Hello world')