refactor: migrate to esm

This commit is contained in:
Vitaly Gashkov
2026-02-15 17:44:53 +05:00
parent 0372c520b0
commit 49b208c9ec
4 changed files with 20 additions and 12 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env node #!/usr/bin/env node
const { parseArgs } = require('node:util'); import { parseArgs } from 'node:util';
const { extract } = require('../crextractor'); import { extract } from '../crextractor.js';
const args = parseArgs({ const args = parseArgs({
options: { options: {
+8 -7
View File
@@ -1,8 +1,8 @@
const { execSync } = require('node:child_process'); import { execSync } from 'node:child_process';
const { join } = require('node:path'); import { join } from 'node:path';
const { readdir, readFile, writeFile, rm } = require('node:fs/promises'); import { readdir, readFile, writeFile, rm } from 'node:fs/promises';
const { existsSync } = require('node:fs'); import { existsSync } from 'node:fs';
const { download } = require('molnia'); import { download } from 'molnia';
const downloadMobileApk = async () => { const downloadMobileApk = async () => {
const url = 'https://api.qqaoop.com/v11/apps/com.crunchyroll.crunchyroid/download?userId=1'; const url = 'https://api.qqaoop.com/v11/apps/com.crunchyroll.crunchyroid/download?userId=1';
@@ -103,7 +103,8 @@ const parseVersion = async (decompiledDir) => {
const manifestJsonPath = join(decompiledDir, 'resources', 'manifest.json'); const manifestJsonPath = join(decompiledDir, 'resources', 'manifest.json');
const manifestXmlPath = join(decompiledDir, 'resources', 'AndroidManifest.xml'); const manifestXmlPath = join(decompiledDir, 'resources', 'AndroidManifest.xml');
if (existsSync(manifestJsonPath)) { if (existsSync(manifestJsonPath)) {
const manifest = require(manifestJsonPath); const manifestContent = await readFile(manifestJsonPath, 'utf8');
const manifest = JSON.parse(manifestContent);
const version = `${manifest.version_name} (${manifest.version_code})`; const version = `${manifest.version_name} (${manifest.version_code})`;
return version; return version;
} else if (existsSync(manifestXmlPath)) { } else if (existsSync(manifestXmlPath)) {
@@ -159,4 +160,4 @@ const pull = async ({ target = 'mobile' } = {}) => {
return credentials; return credentials;
}; };
module.exports = { extract, pull }; export { extract, pull };
+1 -1
View File
@@ -25,7 +25,7 @@
"typescript": "^5.9.3" "typescript": "^5.9.3"
}, },
"engines": { "engines": {
"node": ">=22" "node": ">=24"
} }
}, },
"node_modules/@oxfmt/darwin-arm64": { "node_modules/@oxfmt/darwin-arm64": {
+9 -2
View File
@@ -29,9 +29,16 @@
"crextractor.d.ts", "crextractor.d.ts",
"crextractor.js" "crextractor.js"
], ],
"type": "commonjs", "type": "module",
"main": "crextractor.js", "main": "crextractor.js",
"types": "crextractor.d.ts", "types": "crextractor.d.ts",
"exports": {
".": {
"types": "./crextractor.d.ts",
"import": "./crextractor.js",
"require": "./crextractor.js"
}
},
"scripts": { "scripts": {
"start": "node bin/cli.js", "start": "node bin/cli.js",
"extract:mobile": "node bin/cli.js --target mobile --output ./credentials.mobile.json", "extract:mobile": "node bin/cli.js --target mobile --output ./credentials.mobile.json",
@@ -46,7 +53,7 @@
"typescript": "^5.9.3" "typescript": "^5.9.3"
}, },
"engines": { "engines": {
"node": ">=22" "node": ">=24"
}, },
"readmeFilename": "README.md" "readmeFilename": "README.md"
} }