diff --git a/.gitmodules b/.gitmodules index c45b52b..9b6f364 100644 --- a/.gitmodules +++ b/.gitmodules @@ -19,3 +19,30 @@ [submodule "react-redux-realworld-example-app"] path = app/react-redux-realworld-example-app url = https://github.com/khaledosman/react-redux-realworld-example-app.git +[submodule "app/apprun-realworld-example-app"] + path = app/apprun-realworld-example-app + url = https://github.com/gothinkster/apprun-realworld-example-app.git +[submodule "app/elm-spa-example"] + path = app/elm-spa-example + url = https://github.com/rtfeldman/elm-spa-example.git +[submodule "app/ember-realworld"] + path = app/ember-realworld + url = https://github.com/gothinkster/ember-realworld.git +[submodule "app/hyperapp-realworld-example-app"] + path = app/hyperapp-realworld-example-app + url = https://github.com/kwasniew/hyperapp-realworld-example-app.git +[submodule "app/imba-realworld-example-app"] + path = app/imba-realworld-example-app + url = https://github.com/cartonalexandre/imba-realworld-example-app.git +[submodule "app/riot_realworld_example_app"] + path = app/riot_realworld_example_app + url = https://github.com/iq3addLi/riot_realworld_example_app.git +[submodule "app/san-realworld-app"] + path = app/san-realworld-app + url = https://github.com/ecomfe/san-realworld-app.git +[submodule "app/stencil-realworld-app"] + path = app/stencil-realworld-app + url = https://github.com/khaledosman/stencil-realworld-app.git +[submodule "app/rust-yew-realworld-example-app"] + path = app/rust-yew-realworld-example-app + url = https://github.com/jetli/rust-yew-realworld-example-app.git diff --git a/app/apprun-realworld-example-app b/app/apprun-realworld-example-app new file mode 160000 index 0000000..785cad9 --- /dev/null +++ b/app/apprun-realworld-example-app @@ -0,0 +1 @@ +Subproject commit 785cad957ee57c8f2234f082dd95a5215ab5fa21 diff --git a/app/elm-spa-example b/app/elm-spa-example new file mode 160000 index 0000000..cb32acd --- /dev/null +++ b/app/elm-spa-example @@ -0,0 +1 @@ +Subproject commit cb32acd73c3d346d0064e7923049867d8ce67193 diff --git a/app/ember-realworld b/app/ember-realworld new file mode 160000 index 0000000..b7a8421 --- /dev/null +++ b/app/ember-realworld @@ -0,0 +1 @@ +Subproject commit b7a8421b32384a0017dec30be28f4c3eaf74623a diff --git a/app/hyperapp-realworld-example-app b/app/hyperapp-realworld-example-app new file mode 160000 index 0000000..9568447 --- /dev/null +++ b/app/hyperapp-realworld-example-app @@ -0,0 +1 @@ +Subproject commit 9568447afadbcf73976e9ae379ad0739b4c3be88 diff --git a/app/imba-realworld-example-app b/app/imba-realworld-example-app new file mode 160000 index 0000000..7b9d825 --- /dev/null +++ b/app/imba-realworld-example-app @@ -0,0 +1 @@ +Subproject commit 7b9d82535334b7eb7fafe734c233514f7d7114c1 diff --git a/app/riot_realworld_example_app b/app/riot_realworld_example_app new file mode 160000 index 0000000..2af5fc5 --- /dev/null +++ b/app/riot_realworld_example_app @@ -0,0 +1 @@ +Subproject commit 2af5fc527f492a992cb2710732c07d8765de5f8e diff --git a/app/rust-yew-realworld-example-app b/app/rust-yew-realworld-example-app new file mode 160000 index 0000000..3116000 --- /dev/null +++ b/app/rust-yew-realworld-example-app @@ -0,0 +1 @@ +Subproject commit 31160005628cc6fb5ad6c9ecc39fec04a0edb0fb diff --git a/app/san-realworld-app b/app/san-realworld-app new file mode 160000 index 0000000..486bc78 --- /dev/null +++ b/app/san-realworld-app @@ -0,0 +1 @@ +Subproject commit 486bc7876de11fc1d78ba7fabd27ecc071ef7b04 diff --git a/app/stencil-realworld-app b/app/stencil-realworld-app new file mode 160000 index 0000000..934aa03 --- /dev/null +++ b/app/stencil-realworld-app @@ -0,0 +1 @@ +Subproject commit 934aa03d4d0872a994ce37b0813dd3c4004673c8 diff --git a/index.js b/index.js index 5d9d88c..6ecb1a0 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,7 @@ import * as fs from 'node:fs'; import { execSync, exec } from 'node:child_process'; import * as chromeLauncher from "chrome-launcher"; +import * as path from "path"; import lighthouse from "lighthouse"; function buildProject(project) { @@ -18,6 +19,25 @@ function runCommand(command, cwd) { execSync(command, { stdio: 'inherit', cwd }); } +function deployHtml(project, port) { + let serve; + buildProject(project); + if (project.preview) { + const cmd = project.preview; + console.log(cmd); + serve = exec(`${cmd} --port ${port}`,{cwd:project.path} , (error) => { + throw error; + }); + } else { + const cmd = `"node_modules/.bin/serve" ./${project.path}/${project.dist ? project.dist : 'dist'} -l ${port}`; + console.log(cmd); + serve = exec(cmd , (error) => { + throw error; + }); + } + return serve; +} + async function runLighthouse(url) { const debuggingPort = 9999; const options = { @@ -59,16 +79,18 @@ async function main() { const projects = JSON.parse(fs.readFileSync('projectList.json')); let port = 5000; for (const project of projects) { - buildProject(project); - const cmd = `"node_modules/.bin/serve" ./${project.path}/${project.dist ? project.dist : 'dist'} -l ${port}`; - console.log(cmd); - const serve = exec(cmd , (error) => { - throw error; - }); - const result = await runLighthouse(`http://localhost:${port}/`); - fs.writeFileSync(`./results/${project.name}.json`, JSON.stringify(result)); - serve.kill('SIGINT'); - port++; + if (project.name) { + let serve = deployHtml(project, port); + const result = await runLighthouse(`http://localhost:${port}/`); + if (!fs.existsSync(`./results/${project.name}.json`)) { + fs.mkdirSync(path.dirname(`./results/${project.name}.json`), {recursive: true}) + } + fs.writeFileSync(`./results/${project.name}.json`, JSON.stringify(result)); + if (serve) { + serve.kill('SIGINT'); + } + port++; + } } } diff --git a/projectList.json b/projectList.json index effb673..bee8c31 100644 --- a/projectList.json +++ b/projectList.json @@ -15,11 +15,12 @@ { "name":"svelte", "path":"app/realworld", - "build":"pnpm build" + "preview":"\"node_modules/.bin/vite\" preview" }, { "name":"solid", - "path":"app/solid-realworld" + "path":"app/solid-realworld", + "dist":"public" }, { "name":"preact", @@ -27,6 +28,8 @@ }, { "name":"qwik", - "path":"app/realworld-qwik" + "path":"app/realworld-qwik", + "build":"\"node_modules/.bin/vite\" build", + "preview":"\"node_modules/.bin/vite\" preview" } ] \ No newline at end of file