Skip to content

Commit

Permalink
chore: update dependency kkt to v7.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jun 6, 2023
1 parent 8288e1b commit a0d00ba
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 266 deletions.
25 changes: 11 additions & 14 deletions .kktrc.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import path from 'path';
import { Configuration } from 'webpack';
import { OptionConf } from 'kkt/lib/config/webpack.config';
import { LoaderConfOptions, WebpackConfiguration } from 'kkt';
import lessModules from '@kkt/less-modules';
import scopePluginOptions from '@kkt/scope-plugin-options';

export const moduleScopePluginOpts = [
path.resolve(process.cwd(), 'data.json'),
];

export const loaderOneOf = [
[require.resolve('@kkt/loader-less'), {}],
];


export default (conf: Configuration, opts: OptionConf, webpack) => {
if (opts.isEnvProduction) {
conf.output.publicPath = './';
export default (conf: WebpackConfiguration, env: 'development' | 'production', options: LoaderConfOptions) => {
conf = lessModules(conf, env, options);
conf = scopePluginOptions(conf, env, {
...options,
allowedFiles: [path.resolve(process.cwd(), 'data.json')],
});
if (env === 'production') {
conf.output = { ...conf.output, publicPath: './' };
}
return conf;
}
39 changes: 22 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"homepage": "https://github.com/jaywcjlove/google",
"main": "data.json",
"scripts": {
"get": "node script/status.js",
"get": "node script/status.mjs",
"start": "kkt start",
"build": "kkt build"
},
Expand All @@ -15,25 +15,30 @@
},
"author": "",
"license": "MIT",
"dependencies": {},
"dependencies": {
"web-vitals": "^2.1.2"
},
"devDependencies": {
"@kkt/loader-less": "^5.2.2",
"@types/classnames": "^2.2.8",
"@types/jest": "^24.0.23",
"@types/react": "^16.9.13",
"@types/react-dom": "^16.9.4",
"@uiw/formatter": "^1.2.4",
"@uiw/react-github-corners": "^1.1.2",
"classnames": "^2.2.6",
"fs-extra": "^8.1.0",
"kkt": "5.2.1",
"puppeteer": "^2.0.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"request": "^2.88.0"
"@kkt/less-modules": "^7.5.0",
"@kkt/scope-plugin-options": "^7.5.0",
"@types/classnames": "^2.3.1",
"@types/react": "^18.2.8",
"@types/react-dom": "^18.2.4",
"@uiw/formatter": "^2.0.2",
"@uiw/react-github-corners": "^1.5.15",
"classnames": "^2.3.2",
"fs-extra": "^11.1.1",
"kkt": "^7.5.0",
"puppeteer": "^20.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"node-fetch": "^3.3.1"
},
"eslintConfig": {
"extends": "react-app"
"extends": [
"react-app",
"react-app/jest"
]
},
"files": [
"data.json"
Expand Down
42 changes: 35 additions & 7 deletions script/status.js → script/status.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
const puppeteer = require('puppeteer');
const path = require('path');
const fs = require('fs-extra');
const data = require('../data.json');
import puppeteer from 'puppeteer';
import path from 'path';
import fs from 'fs-extra';
import { createRequire } from "module";

const require = createRequire(import.meta.url);
const data = require("../data.json");


let urlData = [...data.data];
let dataStatus = [...data.data];
Expand All @@ -17,10 +21,10 @@ async function getWebStatus(url) {
return;
}
if (urlData[0] && urlData[0].status === 110) {
console.log(':log:', urlData[0].status, url, ((new Date().getTime()) - time) / 1000, '该网站已被拦截');
console.log('\x1b[36;1m[log]\x1b[0m', urlData[0].status, url, ((new Date().getTime()) - time) / 1000, '该网站已被拦截');
return;
}
const browser = await puppeteer.launch();
const browser = await puppeteer.launch({ headless: 'new' });
let status = 0;
try {
const page = await browser.newPage();
Expand All @@ -46,7 +50,31 @@ async function getWebStatus(url) {
}
}
urlData = urlData.filter(m => m.url !== url);
console.log(':log:', status, url, ((new Date().getTime()) - time) / 1000, message);
let statusText = status;
switch (status) {
case 200:
statusText = `\x1b[32;1m${status}\x1b[0m`;
break;
case 408:
statusText = `\x1b[35;1m${status}\x1b[0m`;
break;
case 502:
statusText = `\x1b[36;1m${status}\x1b[0m`;
break;
case 404:
statusText = `\x1b[34;1m${status}\x1b[0m`;
break;
case 300:
statusText = `\x1b[37;1m${status}\x1b[0m`;
break;
case 0:
statusText = `\x1b[31;1m${status}\x1b[0m`;
break;
default:
statusText = status;
break;
}
console.log('\x1b[36;1m[log]\x1b[0m', statusText, url, ((new Date().getTime()) - time) / 1000, message);
await browser.close();
dataStatus = dataStatus.map(item => {
if (item.url === url) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface DataItem {
url: string;
}

export default () => {
export default function App() {
return (
<div className={styles.warpper}>
<GitHubCorners size={62} fixed href="https://github.com/jaywcjlove/google" />
Expand Down
2 changes: 1 addition & 1 deletion src/app/Google.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

export default () => {
export default function Google() {
return (
<svg viewBox="0 0 3027 1024" height="50">
<path d="M1288.347826 525.133913c0 142.135652-111.193043 246.873043-247.652174 246.873044s-247.652174-104.737391-247.652174-246.873044C793.043478 381.996522 904.236522 278.26087 1040.695652 278.26087s247.652174 103.735652 247.652174 246.873043z m-108.410435 0c0-88.82087-64.445217-149.593043-139.241739-149.593043S901.453913 436.313043 901.453913 525.133913c0 87.930435 64.445217 149.593043 139.241739 149.593044s139.241739-61.773913 139.241739-149.593044z" fill="#EA4335" />
Expand Down
16 changes: 7 additions & 9 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './app/App';
import reportWebVitals from './reportWebVitals';
import ReactClient from 'react-dom/client';
import './index.css';
import * as serviceWorker from './serviceWorker';

ReactDOM.render(<App />, document.getElementById('root'));
ReactClient.createRoot(document.getElementById('root')!).render(<App />);


// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
6 changes: 6 additions & 0 deletions src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// <reference types="react-scripts" />

declare module '*.module.less' {
const classes: { readonly [key: string]: string };
export default classes;
}
13 changes: 13 additions & 0 deletions src/reportWebVitals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const reportWebVitals = (onPerfEntry?: any) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};

export default reportWebVitals;
143 changes: 0 additions & 143 deletions src/serviceWorker.ts

This file was deleted.

Loading

0 comments on commit a0d00ba

Please sign in to comment.