Skip to content

Commit

Permalink
feat: add spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelDemey committed Sep 13, 2024
1 parent 8f3c3f6 commit c600f82
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
6 changes: 3 additions & 3 deletions audit/apps/audit/src/checkers/async/http-system-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const getStatistics = async (
url: string,
parsers: { name: string; result: any }[]
): Promise<{ name: string; result: any }> => {
const browser = await puppeteer.launch();
const browser = await puppeteer.launch({ headless: 'new' });
const page = await browser.newPage();

let requestsNumber = 0;
Expand Down Expand Up @@ -129,7 +129,7 @@ const getStatistics = async (
};

const getImageWithoutAlts = async (url: string, _parsers: any) => {
const browser = await puppeteer.launch();
const browser = await puppeteer.launch({ headless: 'new' });
const page = await browser.newPage();
await page.goto(url, { waitUntil: 'networkidle0' });

Expand All @@ -151,7 +151,7 @@ export class HttpChecker {
];
constructor(private parsers: { name: string; result: any }[]) {}
async check(url: string) {
const browser = await puppeteer.launch({ headless: true });
const browser = await puppeteer.launch({ headless: 'new' });
const page = await browser.newPage();
await page.goto(url, { waitUntil: 'networkidle0' });
const statistics = await getStatistics(url, this.parsers);
Expand Down
6 changes: 4 additions & 2 deletions audit/apps/audit/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { readFileSync } from 'fs';
import { FileSystemParser } from './parsers/file-system-parser';
import { FileSystemChecker } from './checkers/sync/file-system-checker';
import { HttpChecker } from './checkers/async/http-system-checker';
import yoctoSpinner from 'yocto-spinner';

program.name('audit').version('0.0.0');

Expand Down Expand Up @@ -34,6 +35,8 @@ program
throw new Error(`La liste doit être ue liste d'URL valides`);
}

const spinner = yoctoSpinner({ text: 'Please wait...' }).start();

const audit: AuditResult = {};

const fileSystemParser = new FileSystemParser();
Expand All @@ -43,7 +46,6 @@ program
const fileSystemChecker = new FileSystemChecker(audit.parsers);
audit.syncChecks = fileSystemChecker.check();

console.log(config);
if (config.urls) {
const httpChecker = new HttpChecker(audit.parsers);

Expand All @@ -58,7 +60,7 @@ program
}
}
}

spinner.success('Success!');
console.log(JSON.stringify(audit));
});

Expand Down
30 changes: 28 additions & 2 deletions audit/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions audit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"puppeteer": "^21.9.0",
"tslib": "^2.3.0",
"yaml": "^2.5.0",
"yocto-spinner": "^0.1.0",
"zod": "^3.22.4"
},
"devDependencies": {
Expand Down

0 comments on commit c600f82

Please sign in to comment.