Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
VirgilClyne committed Nov 10, 2024
1 parent 7dc49fb commit 06f40fa
Show file tree
Hide file tree
Showing 7 changed files with 497 additions and 257 deletions.
78 changes: 78 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"files": {
"ignore": [
"**/*.bundle.js"
],
"ignoreUnknown": false
},
"formatter": {
"enabled": true,
"indentStyle": "tab",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 320
},
"javascript": {
"formatter": {
"arrowParentheses": "asNeeded",
"bracketSameLine": true,
"quoteStyle": "double"
}
},
"json": {
"parser": {
"allowComments": true,
"allowTrailingCommas": true
}
},
"linter": {
"enabled": true,
"rules": {
"complexity": {
"noForEach": "off",
"noStaticOnlyClass": "off",
"noUselessSwitchCase": "off",
"useArrowFunction": "info",
"useFlatMap": "off",
"useLiteralKeys": "info"
},
"correctness": {
"noInnerDeclarations": "info",
"noSelfAssign": "off",
"noSwitchDeclarations": "info",
"noUnsafeOptionalChaining": "info"
},
"performance": {
"noDelete": "info"
},
"recommended": true,
"style": {
"noNegationElse": "off",
"noParameterAssign": "off",
"noUselessElse": "off",
"noVar": "info",
"useDefaultParameterLast": "info",
"useForOf": "error",
"useNodejsImportProtocol": "error",
"useNumberNamespace": "error",
"useSingleVarDeclarator": "off"
},
"suspicious": {
"noAssignInExpressions": "info",
"noDoubleEquals": "info",
"noFallthroughSwitchClause": "info",
"noGlobalIsNan": "off",
"useDefaultSwitchClauseLast": "off"
}
}
},
"organizeImports": {
"enabled": true
},
"vcs": {
"clientKind": "git",
"enabled": true,
"useIgnoreFile": true
}
}
2 changes: 1 addition & 1 deletion modkit.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export default defineConfig({
pluginDts({
interfaceName: "Settings",
isExported: true,
filePath: "src/interface.ts",
filePath: "src/types.d.ts",
}),
pluginBoxJs(),
pluginSurge(),
Expand Down
167 changes: 167 additions & 0 deletions modkit.dev.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import { defineConfig } from "@iringo/modkit";
import { pluginEgern } from "@iringo/modkit-plugin-egern";
import { pluginBoxJs } from "@iringo/modkit/plugins/boxjs";
import { pluginDts } from "@iringo/modkit/plugins/dts";
import { pluginLoon } from "@iringo/modkit/plugins/loon";
import { pluginStash } from "@iringo/modkit/plugins/stash";
import { pluginSurge } from "@iringo/modkit/plugins/surge";
import { pluginNodePolyfill } from "@rsbuild/plugin-node-polyfill";
import pkg from "./package.json";

export default defineConfig({
source: {
metadata: {
system: ["iOS", "iPadOS", "tvOS", "macOS", "watchOS"],
extra: {
openUrl: "http://boxjs.com/#/app/iRingo.News",
author: ["VirgilClyne[https://github.com/VirgilClyne]"],
homepage: "https://NSRingo.github.io/guide/apple-news",
icon: "https://developer.apple.com/assets/elements/icons/news/news-128x128.png",
category: " iRingo",
date: new Date().toLocaleString("zh-CN"),
},
},
content: {
rule: [
"DOMAIN,gateway.icloud.com,{{{Proxy}}}",
{
type: "RULE-SET",
assetKey: "News.list",
policyName: {
custom: "{{{Proxy}}}",
},
description: "📰 News",
},
],
script: [
{
name: "📰 News.v1.configs.request",
type: "http-request",
pattern: "^https?://news(-todayconfig)?-edge.apple.com/v1/configs",
requiresBody: true,
scriptKey: "request",
injectArgument: true,
},
{
name: "📰 News.analyticseventsv2.async.request",
type: "http-request",
pattern:
"^https?://news(-sports)?-events.apple.com/analyticseventsv2/async",
requiresBody: true,
scriptKey: "request",
injectArgument: true,
},
{
name: "📰 News.v1.search.request",
type: "http-request",
pattern: "^https?://news-client-search.apple.com/v1/search",
requiresBody: false,
scriptKey: "request",
injectArgument: true,
},
],
mitm: {
hostname: [
"news-edge.apple.com",
"news-todayconfig-edge.apple.com",
"news-events.apple.com",
"news-sports-events.apple.com",
"news-client.apple.com",
"news-client-search.apple.com",
],
},
},
arguments: [
{
key: "Switch",
name: "总功能开关",
defaultValue: true,
type: {
default: "boolean",
surge: "exclude",
loon: "exclude",
stash: "exclude",
},
description: "是否启用此APP修改。",
},
{
key: "CountryCode",
name: "国家或地区代码",
defaultValue: "US",
type: "string",
options: [
{ key: "AUTO", label: "🇺🇳自动(跟随地区检测结果)" },
{ key: "CN", label: "🇨🇳中国大陆" },
{ key: "HK", label: "🇭🇰香港" },
{ key: "TW", label: "🇹🇼台湾" },
{ key: "SG", label: "🇸🇬新加坡" },
{ key: "US", label: "🇺🇸美国" },
{ key: "JP", label: "🇯🇵日本" },
{ key: "AU", label: "🇦🇺澳大利亚" },
{ key: "GB", label: "🇬🇧英国" },
{ key: "KR", label: "🇰🇷韩国" },
{ key: "CA", label: "🇨🇦加拿大" },
{ key: "IE", label: "🇮🇪爱尔兰" },
],
description: "不同国家或地区提供的内容或有差别。",
},
{
key: "NewsPlusUser",
name: "[搜索]显示News+内容",
defaultValue: true,
type: "boolean",
description: "是否显示News+搜索结果。",
},
],
scripts: {
request: "./src/request.js",
},
assets: {
"News.list": "./rulesets/News.list",
},
},
output: {
assetPrefix: `https://github.com/NSRingo/News/releases/download/v${pkg.version}`,
banners: [
{
banner: `console.log('Version: ${pkg.version}');`,
raw: true,
},{
banner: "console.log('[file]');",
raw: true,
},{
banner: `console.log('${pkg.displayName}');`,
raw: true,
},
{
banner: pkg.homepage,
}
]
},
tools: {
rsbuild: {
plugins: [pluginNodePolyfill()],
},
rspack: {
resolve: {
fallback: {
got: false,
"iconv-lite": false,
"tough-cookie": false,
},
},
},
},
plugins: [
pluginDts({
interfaceName: "Settings",
isExported: true,
filePath: "src/types.d.ts",
}),
pluginBoxJs(),
pluginSurge(),
pluginLoon(),
pluginStash(),
pluginEgern(),
],
});
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
"example": "example"
},
"scripts": {
"dev": "modkit dev",
"dev": "modkit dev -c modkit.dev.config.js",
"build": "modkit build",
"build:dev": "modkit build -c modkit.dev.config.js",
"dts": "modkit dts"
},
"browserslist": [
Expand Down
Loading

0 comments on commit 06f40fa

Please sign in to comment.