Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add 9 more apps and fix build problem of the older apps #2

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions app/apprun-realworld-example-app
1 change: 1 addition & 0 deletions app/elm-spa-example
Submodule elm-spa-example added at cb32ac
1 change: 1 addition & 0 deletions app/ember-realworld
Submodule ember-realworld added at b7a842
1 change: 1 addition & 0 deletions app/hyperapp-realworld-example-app
1 change: 1 addition & 0 deletions app/imba-realworld-example-app
1 change: 1 addition & 0 deletions app/riot_realworld_example_app
1 change: 1 addition & 0 deletions app/rust-yew-realworld-example-app
1 change: 1 addition & 0 deletions app/san-realworld-app
Submodule san-realworld-app added at 486bc7
1 change: 1 addition & 0 deletions app/stencil-realworld-app
Submodule stencil-realworld-app added at 934aa0
42 changes: 32 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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 = {
Expand Down Expand Up @@ -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++;
}
}
}

Expand Down
9 changes: 6 additions & 3 deletions projectList.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@
{
"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",
"path":"app/preact-realworld-example-app"
},
{
"name":"qwik",
"path":"app/realworld-qwik"
"path":"app/realworld-qwik",
"build":"\"node_modules/.bin/vite\" build",
"preview":"\"node_modules/.bin/vite\" preview"
}
]
Loading