Skip to content

Commit f97ed54

Browse files
update.
1 parent c0e931c commit f97ed54

File tree

13 files changed

+3617
-249
lines changed

13 files changed

+3617
-249
lines changed

.editorconfig

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
# Use 4 spaces for the Python files
13+
[*.py]
14+
indent_size = 4
15+
max_line_length = 80
16+
17+
# The JSON files contain newlines inconsistently
18+
[*.json]
19+
insert_final_newline = ignore
20+
21+
# Minified JavaScript files shouldn't be changed
22+
[**.min.js]
23+
indent_style = ignore
24+
insert_final_newline = ignore
25+
26+
# Makefiles always use tabs for indentation
27+
[Makefile]
28+
indent_style = tab
29+
30+
# Batch files use tabs for indentation
31+
[*.bat]
32+
indent_style = tab
33+
34+
[*.md]
35+
trim_trailing_whitespace = false
36+

.eslintrc.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es2021: true
5+
},
6+
7+
extends: [
8+
'standard',
9+
'@lancercomet/eslint-rules',
10+
'plugin:@typescript-eslint/recommended',
11+
'plugin:import/recommended',
12+
'plugin:import/typescript'
13+
],
14+
15+
parser: '@typescript-eslint/parser',
16+
17+
rules: {
18+
'@typescript-eslint/no-unused-vars': 'off'
19+
}
20+
}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.idea/
2+
.vscode/
3+
node_modules/
4+
dist/
5+
src/**/*.js

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changelog
2+
3+
## 0.0.3
4+
- Used ts-migrate to convert JavaScript to TypeScript, introduced several bugs.
5+
6+
## 0.0.2
7+
- Update: Add Language configuration option.
8+
9+
## 0.0.1
10+
- Initial release.

README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
MangaDex Plugin
2-
============
1+
# MangaDex Plugin
32

43
A Rulia plugin for reading [MangaDex](https://mangadex.org).
54

6-
Description
7-
----------
5+
## Description
86

9-
* It works.
10-
* You need to customize the Http header in the plugin configuration, with the key being `User-Agent` and the value being `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0`.
11-
* There are a lot of bugs, I'll fix them when I have time.
12-
* There are also many shortcomings; I'll make changes when I have time.
7+
- It works.
8+
- You need to customize the Http header in the plugin configuration, with the key being `User-Agent` and the value being `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0`.
9+
- There are a lot of bugs, I'll fix them when I have time.
10+
- There are also many shortcomings; I'll make changes when I have time.
1311

14-
Login
15-
----
12+
## Download
13+
14+
Please download the plugin's zip file from the Releases section on the right side of this page.
15+
16+
## Login
1617

1718
You can log in in two ways (it works without logging in):
1819

19-
* Manually add a header named `Cookie` in the Rulia plugin settings and fill in the Cookie.
20-
* Use the web popup to log in, fill in `https://mangadex.org` as the URL, and log in successfully.
20+
1.Manually add a header named `Cookie` in the Rulia plugin settings and fill in the Cookie.
21+
2.Use the web popup to log in, fill in `https://mangadex.org` as the URL, and log in successfully.
22+
23+
## Change Log

build.js

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/* eslint-disable @typescript-eslint/no-var-requires */
2+
3+
const assert = require('assert')
4+
const {
5+
execSync
6+
} = require('child_process')
7+
const fs = require('fs')
8+
const path = require('path')
9+
const archiver = require('archiver')
10+
const version = require('./package.json').version
11+
12+
const ARCHIVE_FILE_NAME = `MangaDex.v${version}.zip`
13+
14+
main().catch(error => {
15+
console.error(`Error in main function: ${error}`)
16+
})
17+
18+
function deleteFolderRecursive(directory) {
19+
if (fs.existsSync(directory)) {
20+
for (const entry of fs.readdirSync(directory)) {
21+
const curPath = path.join(directory, entry)
22+
if (fs.lstatSync(curPath).isDirectory()) {
23+
deleteFolderRecursive(curPath)
24+
} else {
25+
fs.unlinkSync(curPath)
26+
}
27+
}
28+
fs.rmdirSync(directory)
29+
}
30+
}
31+
32+
async function main() {
33+
// Step 1: Execute tsc
34+
try {
35+
execSync('tsc')
36+
console.log('tsc build completed.')
37+
} catch (error) {
38+
console.error(`Error during tsc: ${error}`)
39+
return
40+
}
41+
42+
// Step 2: Copy files
43+
const filesToCopy = [
44+
['src/icon.png', 'dist/icon.png'],
45+
['src/package.json', 'dist/package.json'],
46+
['README.md', 'dist/README.md']
47+
]
48+
for (const [src, dist] of filesToCopy) {
49+
fs.copyFileSync(src, dist)
50+
}
51+
console.log('Files copied.')
52+
53+
// Step 3: Replace the version in src/package.json
54+
assert(version, 'Version in package.json must be provided.')
55+
let srcPackageFileContent = fs.readFileSync('dist/package.json', {
56+
encoding: 'utf-8'
57+
})
58+
srcPackageFileContent = srcPackageFileContent.replace('<VERSION>', version)
59+
fs.writeFileSync('dist/package.json', srcPackageFileContent, {
60+
encoding: 'utf-8'
61+
})
62+
console.log('Version has been written to dist/package.json: ' + version)
63+
64+
// Step 4: Zip files
65+
const output = fs.createWriteStream(`dist/${ARCHIVE_FILE_NAME}`)
66+
const archive = archiver('zip', {
67+
zlib: {
68+
level: 9
69+
}
70+
})
71+
72+
archive.on('error', (err) => {
73+
throw err
74+
})
75+
76+
const archiveCompletion = new Promise((resolve, reject) => {
77+
output.on('close', resolve)
78+
output.on('error', reject)
79+
})
80+
81+
archive.pipe(output)
82+
83+
const filesToZip = ['icon.png', 'package.json', 'README.md', 'index.js']
84+
filesToZip.forEach(file => {
85+
archive.append(fs.createReadStream(`dist/${file}`), {
86+
name: file
87+
})
88+
})
89+
90+
await archive.finalize()
91+
92+
await archiveCompletion
93+
console.log('Files zipped.')
94+
95+
// Step 5: Delete all files in dist except package.zip
96+
const filesInDist = fs.readdirSync('dist')
97+
filesInDist.forEach(filename => {
98+
const filePath = path.resolve('dist', filename)
99+
if (filename !== ARCHIVE_FILE_NAME) {
100+
if (fs.lstatSync(filePath).isDirectory()) {
101+
deleteFolderRecursive(filePath)
102+
} else {
103+
fs.unlinkSync(filePath)
104+
}
105+
}
106+
})
107+
console.log('Other files in dist deleted.')
108+
}

0 commit comments

Comments
 (0)