diff --git a/cli/Cargo.lock b/cli/Cargo.lock index bac3dfe..c224e33 100644 --- a/cli/Cargo.lock +++ b/cli/Cargo.lock @@ -1991,7 +1991,7 @@ checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" [[package]] name = "wasmo" -version = "0.2.5" +version = "1.0.0" dependencies = [ "assert_cmd", "assert_fs", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 4a9d540..e8b39c5 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasmo" -version = "0.2.5" +version = "1.0.0" edition = "2021" authors = ["Zwiterrion "] license = "MIT OR Apache-2.0" diff --git a/server/index.js b/server/index.js index 3fc3583..7225224 100644 --- a/server/index.js +++ b/server/index.js @@ -43,33 +43,70 @@ if (AUTHENTICATION.BASIC_AUTH === ENV.AUTH_MODE && return; } +function rewriteStaticPaths(baseURL) { + const indexHTMLPath = path.join(__dirname, '..', 'ui/build/index.html'); + const indexHTMLContent = fs.readFileSync(indexHTMLPath).toString(); + fs.writeFileSync(indexHTMLPath, + indexHTMLContent + .replace(/src="(.*?)\/static/g, `src=\"${baseURL}/static`) + .replace(/href="(.*?)\/static/g, `href=\"${baseURL}/static`) + // .replace(/\/static/g, `${baseURL}/static`) + .replace(/\/static\/static/g, "/static") + .replace(/\/{2}/g, "/") + ); + logger.info('The baseURL value has been applied') +} + function createServer(appVersion) { const app = express(); - app.use(express.static(path.join(__dirname, '..', 'ui/build'))); - app.use(compression()); - app.use(bodyParser.raw({ + + let router; + + if (process.env.BASE_URL) { + const baseURL = process.env.BASE_URL; + + console.log(`has baseURL ${baseURL}`) + router = express.Router(); + + rewriteStaticPaths(baseURL); + + app.use('/', (req, _res, next) => { + if (!req.path.startsWith(baseURL)) + req.url = `${baseURL}${req.path}`; + next() + }) + app.use(baseURL, router); + } else { + rewriteStaticPaths(""); + router = express.Router(); + app.use('/', router); + } + + router.use(express.static(path.join(__dirname, '..', 'ui/build'))); + router.use(compression()); + router.use(bodyParser.raw({ type: 'application/octet-stream', limit: '10mb' })); - app.use(bodyParser.json()); - app.use(bodyParser.urlencoded({ extended: true })); - app.use(bodyParser.text()); + router.use(bodyParser.json()); + router.use(bodyParser.urlencoded({ extended: true })); + router.use(bodyParser.text()); - app.use('/_/healthcheck', (_, res) => { + router.use('/_/healthcheck', (_, res) => { return res.status(200).json() }); - app.use('/', Security.extractUserFromQuery); - app.use('/', publicRouter); - app.use('/api/plugins', pluginsRouter); - app.use('/api/templates', templatesRouter); - app.use('/api/wasm', wasmRouter); - app.use('/api/version', (_, res) => res.json(appVersion)); - app.use('/api/development', (_, res) => res.json(process.env.NODE_ENV === "development")); + router.use('/', Security.extractUserFromQuery); + router.use('/', publicRouter); + router.use('/api/plugins', pluginsRouter); + router.use('/api/templates', templatesRouter); + router.use('/api/wasm', wasmRouter); + router.use('/api/version', (_, res) => res.json(appVersion)); + router.use('/api/development', (_, res) => res.json(process.env.NODE_ENV === "development")); - app.use('/health', (_, res) => res.json({ status: true })) + router.use('/health', (_, res) => res.json({ status: true })) - app.get('/', (_, res) => res.sendFile(path.join(__dirname, '..', 'ui/build', '/index.html'))); + router.get('/', (_, res) => res.sendFile(path.join(__dirname, '..', 'ui/build', '/index.html'))); return http.createServer(app); } diff --git a/server/package.json b/server/package.json index 8fc5fc6..078bd1d 100644 --- a/server/package.json +++ b/server/package.json @@ -1,6 +1,6 @@ { "name": "wasmo", - "version": "0.2.5", + "version": "1.0.0", "main": "index.js", "license": "MIT", "scripts": { diff --git a/ui/package.json b/ui/package.json index 523dd15..825fe48 100644 --- a/ui/package.json +++ b/ui/package.json @@ -1,6 +1,6 @@ { "name": "ui", - "version": "0.2.5", + "version": "1.0.0", "private": true, "dependencies": { "@babel/plugin-proposal-private-property-in-object": "^7.21.11", diff --git a/ui/public/android-chrome-192x192.png b/ui/public/android-chrome-192x192.png deleted file mode 100644 index 2da0174..0000000 Binary files a/ui/public/android-chrome-192x192.png and /dev/null differ diff --git a/ui/public/android-chrome-256x256.png b/ui/public/android-chrome-256x256.png deleted file mode 100644 index ad6cc30..0000000 Binary files a/ui/public/android-chrome-256x256.png and /dev/null differ diff --git a/ui/public/icon-192x192.png b/ui/public/icon-192x192.png new file mode 100644 index 0000000..69d911b Binary files /dev/null and b/ui/public/icon-192x192.png differ diff --git a/ui/public/icon-256x256.png b/ui/public/icon-256x256.png new file mode 100644 index 0000000..e799843 Binary files /dev/null and b/ui/public/icon-256x256.png differ diff --git a/ui/public/icon-384x384.png b/ui/public/icon-384x384.png new file mode 100644 index 0000000..1b83c39 Binary files /dev/null and b/ui/public/icon-384x384.png differ diff --git a/ui/public/icon-512x512.png b/ui/public/icon-512x512.png new file mode 100644 index 0000000..9798208 Binary files /dev/null and b/ui/public/icon-512x512.png differ diff --git a/ui/public/index.html b/ui/public/index.html index 92a98fd..d889305 100644 --- a/ui/public/index.html +++ b/ui/public/index.html @@ -6,7 +6,6 @@ - diff --git a/ui/public/site.webmanifest b/ui/public/site.webmanifest new file mode 100644 index 0000000..93bb5b4 --- /dev/null +++ b/ui/public/site.webmanifest @@ -0,0 +1,32 @@ +{ + "theme_color": "#000000", + "background_color": "#000000", + "display": "browser", + "scope": "/", + "start_url": "/", + "name": "Wasmo", + "short_name": "Wasmo", + "description": "WASM Binary builder", + "icons": [ + { + "src": "/icon-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "/icon-256x256.png", + "sizes": "256x256", + "type": "image/png" + }, + { + "src": "/icon-384x384.png", + "sizes": "384x384", + "type": "image/png" + }, + { + "src": "/icon-512x512.png", + "sizes": "512x512", + "type": "image/png" + } + ] +} \ No newline at end of file diff --git a/ui/src/FilesLogo.js b/ui/src/FilesLogo.js index 25c2372..7944d43 100644 --- a/ui/src/FilesLogo.js +++ b/ui/src/FilesLogo.js @@ -20,7 +20,7 @@ const LOGOS = { go: , opa: , github: , - logo: , release: }; diff --git a/ui/src/TabsManager.js b/ui/src/TabsManager.js index 758a446..272434c 100644 --- a/ui/src/TabsManager.js +++ b/ui/src/TabsManager.js @@ -160,7 +160,7 @@ function SidebarHeader({ version }) { background: '#000', color: 'white', height: 42 - }} className="p-2 m-0 d-flex align-items-center">Wasmo {version} :
+ }} className="p-2 m-0 d-flex align-items-center">Wasmo {version} :
{LOGOS.logo}
}