mirror of
https://github.com/unraid/api.git
synced 2026-01-04 07:29:48 -06:00
feat: rebuild manifest
This commit is contained in:
@@ -3,11 +3,14 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "nuxt build",
|
||||
"postbuild": "npm run rebuildManifest",
|
||||
"dev": "nuxt dev",
|
||||
"generate": "nuxt generate",
|
||||
"postgenerate": "npm run rebuildManifest",
|
||||
"preview": "nuxt preview",
|
||||
"postinstall": "nuxt prepare",
|
||||
"serve": "serve dist/nuxt-custom-elements/connect-components"
|
||||
"serve": "serve dist/nuxt-custom-elements/connect-components",
|
||||
"rebuildManifest": "node postBuild.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxtjs/tailwindcss": "^6.7.0",
|
||||
|
||||
61
postbuild.ts
Normal file
61
postbuild.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
// type Manifest = {
|
||||
// ['connect-components.client.css']: ManifestCSS;
|
||||
// ['connect-components.client.mjs']: ManifestJS;
|
||||
// }
|
||||
|
||||
// type ManifestCSS = {
|
||||
// file: string;
|
||||
// src: string;
|
||||
// }
|
||||
|
||||
// type ManifestJS = {
|
||||
// css: string[];
|
||||
// file: string;
|
||||
// isEntry: boolean;
|
||||
// src: string;
|
||||
// }
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const manifest = '.nuxt/nuxt-custom-elements/dist/connect-components/manifest.json';
|
||||
const stringToRemove = '.nuxt/nuxt-custom-elements/entries/';
|
||||
|
||||
const originalCssKey = '.nuxt/nuxt-custom-elements/entries/connect-components.client.css';
|
||||
const originalJsKey = '.nuxt/nuxt-custom-elements/entries/connect-components.client.mjs';
|
||||
|
||||
console.log('*****************************');
|
||||
console.log('* RE-BUILDING MANIFEST.JSON *');
|
||||
console.log('*****************************');
|
||||
|
||||
fs.readFile(manifest, 'utf8', (error, data) => {
|
||||
if (error){
|
||||
console.log(error);
|
||||
return;
|
||||
}
|
||||
const parsedData = JSON.parse(data);
|
||||
|
||||
if ('connect-components.client.mjs' in parsedData) return console.log('Manifest already re-written');
|
||||
if (!(originalJsKey in parsedData)) return console.error(`Expected JS key not in ${manifest}`);
|
||||
|
||||
// create new manifest with updated top-level keys
|
||||
const newManifest = {
|
||||
'connect-components.client.css': {
|
||||
...parsedData[originalCssKey],
|
||||
},
|
||||
'connect-components.client.mjs': {
|
||||
...parsedData[originalJsKey],
|
||||
}
|
||||
};
|
||||
// then rewrite the manifest
|
||||
fs.writeFile(manifest, JSON.stringify(newManifest, null, 2), (err) => {
|
||||
if (err) {
|
||||
console.log('Failed to write updated data to file', err);
|
||||
return;
|
||||
}
|
||||
console.log('Updated file successfully');
|
||||
});
|
||||
// echo out the filename that needs to be created on the server
|
||||
const map = new Map(Object.entries(newManifest));
|
||||
const js = map.get('connect-components.client.mjs');
|
||||
console.log(`JS FILE FOR WEBGUI: ${js.file}`);
|
||||
});
|
||||
Reference in New Issue
Block a user