@open-xchange/vite-plugin-project-meta 1.3.0 → 1.3.1
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 +5 -0
- package/README.md +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +7 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;AAeA;UAAiB,4BAAA;;;;EAKf,WAAA;AAAA;AAAA,cAKW,YAAA;;;AAAuD;;;;;;;;iBAc5C,qBAAA,CAAsB,OAAA,EAAS,4BAAA,GAA+B,MAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
|
+
import { createJsonModule, exactRegex } from "@open-xchange/rolldown-utils";
|
|
4
5
|
//#region src/index.ts
|
|
5
6
|
const PROJECT_NAME = "@open-xchange/vite-plugin-project-meta";
|
|
6
7
|
/**
|
|
@@ -29,15 +30,13 @@ function vitePluginProjectMeta(options) {
|
|
|
29
30
|
commitsha: process.env.CI_COMMIT_SHA
|
|
30
31
|
};
|
|
31
32
|
},
|
|
32
|
-
resolveId
|
|
33
|
-
|
|
33
|
+
resolveId: {
|
|
34
|
+
filter: { id: exactRegex(MODULE_NAME) },
|
|
35
|
+
handler: () => MODULE_ID
|
|
34
36
|
},
|
|
35
|
-
load
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
code: `export default ${JSON.stringify(metadata)};`,
|
|
39
|
-
map: { mappings: "" }
|
|
40
|
-
};
|
|
37
|
+
load: {
|
|
38
|
+
filter: { id: exactRegex(MODULE_ID) },
|
|
39
|
+
handler: () => createJsonModule(metadata)
|
|
41
40
|
},
|
|
42
41
|
transformIndexHtml(_html, context) {
|
|
43
42
|
if (!context.bundle) return;
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["\nimport { join } from 'node:path'\nimport { readFileSync } from 'node:fs'\nimport { createHash } from 'node:crypto'\n\nimport type { Plugin } from 'vite'\n\nimport type { VirtualProjectMetadata } from 'virtual:metadata'\n\n// types ======================================================================\n\n/**\n * Configuration options for the plugin '@open-xchange/vite-plugin-project-meta'.\n */\nexport interface VitePluginProjectMetaOptions {\n\n /**\n * The display name of the project.\n */\n projectName: string\n}\n\n// constants ==================================================================\n\nexport const PROJECT_NAME = '@open-xchange/vite-plugin-project-meta'\n\n// plugin =====================================================================\n\n/**\n * Vite plugin that provides a virtual module 'virtual:metadata' exporting a\n * metadata object with project build information (timestamp, commit ID, etc.).\n *\n * @param options\n * Plugin configuration.\n *\n * @returns\n * The Vite plugin object.\n */\nexport default function vitePluginProjectMeta(options: VitePluginProjectMetaOptions): Plugin {\n\n const MODULE_NAME = 'virtual:metadata'\n const MODULE_ID = `\\0${PROJECT_NAME}/${MODULE_NAME}`\n\n let metadata: VirtualProjectMetadata\n\n return {\n name: PROJECT_NAME,\n\n configResolved(config) {\n /** @ignore */\n interface Package {\n name: string\n version: string\n }\n const pkg = JSON.parse(readFileSync(join(config.root, 'package.json'), { encoding: 'utf8' })) as Package\n metadata = {\n id: pkg.name,\n name: options.projectName,\n version: pkg.version,\n builddate: new Date().toISOString(),\n commitsha: process.env.CI_COMMIT_SHA,\n }\n },\n\n resolveId
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["\nimport { join } from 'node:path'\nimport { readFileSync } from 'node:fs'\nimport { createHash } from 'node:crypto'\n\nimport type { Plugin } from 'vite'\nimport { exactRegex, createJsonModule } from '@open-xchange/rolldown-utils'\n\nimport type { VirtualProjectMetadata } from 'virtual:metadata'\n\n// types ======================================================================\n\n/**\n * Configuration options for the plugin '@open-xchange/vite-plugin-project-meta'.\n */\nexport interface VitePluginProjectMetaOptions {\n\n /**\n * The display name of the project.\n */\n projectName: string\n}\n\n// constants ==================================================================\n\nexport const PROJECT_NAME = '@open-xchange/vite-plugin-project-meta'\n\n// plugin =====================================================================\n\n/**\n * Vite plugin that provides a virtual module 'virtual:metadata' exporting a\n * metadata object with project build information (timestamp, commit ID, etc.).\n *\n * @param options\n * Plugin configuration.\n *\n * @returns\n * The Vite plugin object.\n */\nexport default function vitePluginProjectMeta(options: VitePluginProjectMetaOptions): Plugin {\n\n const MODULE_NAME = 'virtual:metadata'\n const MODULE_ID = `\\0${PROJECT_NAME}/${MODULE_NAME}`\n\n let metadata: VirtualProjectMetadata\n\n return {\n name: PROJECT_NAME,\n\n configResolved(config) {\n /** @ignore */\n interface Package {\n name: string\n version: string\n }\n const pkg = JSON.parse(readFileSync(join(config.root, 'package.json'), { encoding: 'utf8' })) as Package\n metadata = {\n id: pkg.name,\n name: options.projectName,\n version: pkg.version,\n builddate: new Date().toISOString(),\n commitsha: process.env.CI_COMMIT_SHA,\n }\n },\n\n resolveId: {\n filter: { id: exactRegex(MODULE_NAME) },\n handler: () => MODULE_ID,\n },\n\n load: {\n filter: { id: exactRegex(MODULE_ID) },\n handler: () => createJsonModule(metadata),\n },\n\n transformIndexHtml(_html, context) {\n if (!context.bundle) return\n const hash = createHash('md5').update(metadata.builddate).digest('hex')\n const len = Number.parseInt(hash.slice(0, 4), 16) % 99 + 42\n const count = Math.ceil(len / hash.length)\n const content = hash.repeat(count).slice(0, len)\n const attrs = { name: 'etag-fix', content }\n // inject a <meta> element into the <head>\n return [{ tag: 'meta', attrs, injectTo: 'head' }]\n },\n }\n}\n"],"mappings":";;;;;AAyBA,MAAa,eAAe;;;;;;;;;;;AAc5B,SAAwB,sBAAsB,SAA+C;CAE3F,MAAM,cAAc;CACpB,MAAM,YAAY,KAAK,aAAa,GAAG;CAEvC,IAAI;AAEJ,QAAO;EACL,MAAM;EAEN,eAAe,QAAQ;GAMrB,MAAM,MAAM,KAAK,MAAM,aAAa,KAAK,OAAO,MAAM,eAAe,EAAE,EAAE,UAAU,QAAQ,CAAC,CAAC;AAC7F,cAAW;IACT,IAAI,IAAI;IACR,MAAM,QAAQ;IACd,SAAS,IAAI;IACb,4BAAW,IAAI,MAAM,EAAC,aAAa;IACnC,WAAW,QAAQ,IAAI;IACxB;;EAGH,WAAW;GACT,QAAQ,EAAE,IAAI,WAAW,YAAY,EAAE;GACvC,eAAe;GAChB;EAED,MAAM;GACJ,QAAQ,EAAE,IAAI,WAAW,UAAU,EAAE;GACrC,eAAe,iBAAiB,SAAS;GAC1C;EAED,mBAAmB,OAAO,SAAS;AACjC,OAAI,CAAC,QAAQ,OAAQ;GACrB,MAAM,OAAO,WAAW,MAAM,CAAC,OAAO,SAAS,UAAU,CAAC,OAAO,MAAM;GACvE,MAAM,MAAM,OAAO,SAAS,KAAK,MAAM,GAAG,EAAE,EAAE,GAAG,GAAG,KAAK;GACzD,MAAM,QAAQ,KAAK,KAAK,MAAM,KAAK,OAAO;AAI1C,UAAO,CAAC;IAAE,KAAK;IAAQ,OAFT;KAAE,MAAM;KAAY,SADlB,KAAK,OAAO,MAAM,CAAC,MAAM,GAAG,IAAI;KACL;IAEb,UAAU;IAAQ,CAAC;;EAEpD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-xchange/vite-plugin-project-meta",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Vite plugin providing a virtual import for project metadata",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,10 +23,13 @@
|
|
|
23
23
|
"dist",
|
|
24
24
|
"CHANGELOG.*"
|
|
25
25
|
],
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@open-xchange/rolldown-utils": "^1.0.0"
|
|
28
|
+
},
|
|
26
29
|
"devDependencies": {
|
|
27
30
|
"vite": "^8.0.8",
|
|
28
31
|
"@open-xchange/linter-presets": "^1.22.0",
|
|
29
|
-
"@open-xchange/tsconfig": "^0.0.
|
|
32
|
+
"@open-xchange/tsconfig": "^0.0.3"
|
|
30
33
|
},
|
|
31
34
|
"peerDependencies": {
|
|
32
35
|
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0"
|