@open-xchange/vite-plugin-ox-manifests 0.4.1-pre1 → 0.4.1-pre2

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/README.md CHANGED
@@ -30,6 +30,7 @@ You can provide the following options to the plugin:
30
30
  * transformAbsolutePaths `<boolean>` If set to true, every absolute path will be transformed into a relative path. This is especially useful, if the production path is not clear at build time. E.g. if you do not know, whether appsuite will be served under `/appsuite`. Default: `true`
31
31
  * autoloadSettings `<boolean>` If set to true, this plugin tries to auto-detect files that export settings. Prerequisites are, that the file imports `Settings` from the `io.ox/core/settings` module and have a named export called `settings`. Default true
32
32
  * supportedEntryExtensions `<string[]>` This array defines the extensions, that are to expect as entry points. For example, if a manifest.json have `"path": "index"`, it will look for `index.js`, `index.mjs` or `index.ts` next to the manifest.json. Default: `['js', 'mjs', 'ts']`
33
+ * meta `<object>` An object that will be translated into a meta.json file in the root directory.
33
34
 
34
35
  ## Examples
35
36
 
package/index.js CHANGED
@@ -4,7 +4,7 @@ import relativePathsPlugin from './src/plugins/relative-paths.js'
4
4
  import settingsPlugin from './src/plugins/settings.js'
5
5
  import servePlugin from './src/plugins/serve.js'
6
6
  import gettextPlugin from './src/plugins/gettext.js'
7
- import versionPlugin from './src/plugins/version.js'
7
+ import metaPlugin from './src/plugins/meta.js'
8
8
  import { deepMergeObject } from './src/util.js'
9
9
 
10
10
  /**
@@ -17,7 +17,7 @@ import { deepMergeObject } from './src/util.js'
17
17
  * @param {boolean} [options.transformAbsolutePaths=true] - If this is set to true, every path in the html-files is transformed to a relative path. Additionally, every preloaded file will also be loaded relative to the index.html
18
18
  * @param {boolean} [options.autoloadSettings=true] - If disabled, settings will not be automatically detected and therefore have to provide a manual manifest.json.
19
19
  * @param supportedEntryExtensions {string[]=['js', 'mjs', 'ts']} - An array of valid file-extensions for entry points.
20
- * @param {object} [options.version] - An object that will be translated into a version.json file in the root directory.
20
+ * @param {object} [options.meta] - An object that will be translated into a meta.json file in the root directory.
21
21
  */
22
22
  export default function ({
23
23
  watch = false,
@@ -26,7 +26,7 @@ export default function ({
26
26
  transformAbsolutePaths = true,
27
27
  autoloadSettings = true,
28
28
  supportedEntryExtensions = ['js', 'mjs', 'ts'],
29
- version
29
+ meta
30
30
  } = {}) {
31
31
  const options = {
32
32
  watch,
@@ -35,7 +35,7 @@ export default function ({
35
35
  transformAbsolutePaths,
36
36
  autoloadSettings,
37
37
  supportedEntryExtensions,
38
- version
38
+ meta
39
39
  }
40
40
 
41
41
  const plugins = [
@@ -44,7 +44,7 @@ export default function ({
44
44
  relativePathsPlugin(options),
45
45
  servePlugin(options),
46
46
  gettextPlugin(options),
47
- versionPlugin(options),
47
+ metaPlugin(options),
48
48
  // manifest plugin last
49
49
  manifestsPlugin(options)
50
50
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-xchange/vite-plugin-ox-manifests",
3
- "version": "0.4.1-pre1",
3
+ "version": "0.4.1-pre2",
4
4
  "description": "A vite plugin to concat and serve ox manifests",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -0,0 +1,13 @@
1
+ export default function ({ meta } = {}) {
2
+ return {
3
+ generateBundle () {
4
+ if (!meta || Object.keys(meta).length === 0) return
5
+
6
+ this.emitFile({
7
+ fileName: 'meta.json',
8
+ type: 'asset',
9
+ source: JSON.stringify(meta)
10
+ })
11
+ }
12
+ }
13
+ }
@@ -0,0 +1,25 @@
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
+ })
@@ -0,0 +1,3 @@
1
+ {
2
+ "namespace": "test"
3
+ }
@@ -0,0 +1 @@
1
+ console.log('Hello world')
@@ -1,13 +0,0 @@
1
- export default function ({ version } = {}) {
2
- return {
3
- generateBundle () {
4
- if (!version || Object.keys(version).length === 0) return
5
-
6
- this.emitFile({
7
- fileName: 'version.json',
8
- type: 'asset',
9
- source: JSON.stringify(version)
10
- })
11
- }
12
- }
13
- }