first commit

This commit is contained in:
2026-09-08 20:28:54 +08:00
commit 2ada8d3d5a
37380 changed files with 4886169 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
# aaptjs
A node wraper for aapt
# Install
With [npm](https://npmjs.org/package/node-aapt) do:
```
npm install aaptjs --save
```
## Example
Using a callback:
```js
const aaptjs = require('aaptjs');
aaptjs.list('/path/to/your/ExampleApp.apk', (err, data) => {
if (err) {
// something went wrong
} else {
console.log(data);
}
});
```
Using a promise:
```js
const aaptjs = require('aaptjs');
aaptjs.list('/path/to/your/ExampleApp.apk')
.then (data => {
console.log(data)
})
.catch (err) {
// something went wrong
}
```
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+20
View File
@@ -0,0 +1,20 @@
// Type definitions for aaptjs 1.3.0
declare module "aaptjs" {
export function add(apkfilePath: string, files: string|string[], callback?: (err: Error|null, data: string) => void): Promise<string>;
export function crunch(resource: string|string[], outputFolder: string, callback?: (err: Error|null, data: string) => void): Promise<string>;
export function dump(what: string, apkfilePath: string, callback?: (err: Error|null, data: string) => void): Promise<string>;
export function list(apkfilePath: string, callback?: (err: Error|null, data: string) => void): Promise<string>;
export function packageCmd(command: string, callback?: (err: Error|null, data: string) => void): Promise<string>;
export function remove(apkfilePath: string, files: string|string[], callback?: (err: Error|null, data: string) => void): Promise<string>;
export function singleCrunch(inputFile: string, outputfile: string, callback?: (err: Error|null, data: string) => void): Promise<string>;
export function version(callback?: (err: Error|null, data: string) => void): Promise<string>;
}
+83
View File
@@ -0,0 +1,83 @@
'use strict';
const shelljs = require('shelljs');
const fs = require('fs');
const os = require('os');
const path = require('path');
const platform = os.platform();
const aapt = path.join(__dirname, 'bin', platform , 'aapt');
if (platform === 'linux') {
fs.chmodSync(aapt, '777')
}
function promistify(cmd, callback) {
callback = callback || function () {};
return new Promise((resolve, reject) => {
shelljs.exec(cmd, (code, stdout, stderr) => {
if (code !== 0) {
reject(stderr);
callback(stderr, null);
} else {
resolve(stdout);
callback(null, stdout);
}
})
});
}
function list(apkfilePath, callback) {
return promistify(`${aapt} l ${apkfilePath}`, callback);
}
function dump(what, apkfilePath, callback) {
return promistify(`${aapt} d ${what} ${apkfilePath}`, callback);
}
function packageCmd(command, callback) {
return promistify(`${aapt} p ${command}`, callback);
}
function remove(apkfilePath, files, callback) {
if (!Array.isArray(files)) {
files = [files]
}
const removeFiles = files.join(' ')
return promistify(`${aapt} r ${apkfilePath} ${removeFiles}`, callback);
}
function add(apkfilePath, files, callback) {
if (!Array.isArray(files)) {
files = [files]
}
const addFiles = files.join(' ')
return promistify(`${aapt} a ${apkfilePath} ${addFiles}`, callback);
}
function crunch(resource, outputFolder, callback) {
if (!Array.isArray(resource)) {
resource = [resource]
}
const resourceSources = resource.join(' ')
return promistify(`${aapt} c -S ${resourceSources} -C ${outputFolder}`, callback);
}
function singleCrunch(inputFile, outputfile, callback) {
return promistify(`${aapt} s -i ${inputFile} -o ${outputfile}`, callback);
}
function version(callback) {
return promistify(`${aapt} v`, callback);
}
module.exports = {
list: list,
dump: dump,
packageCmd: packageCmd,
remove: remove,
add: add,
crunch: crunch,
singleCrunch: singleCrunch,
version: version
}
+25
View File
@@ -0,0 +1,25 @@
{
"name": "aaptjs",
"version": "1.3.2",
"description": "A node wraper for aapt",
"main": "index.js",
"typings": "./index.d.ts",
"scripts": {
},
"keywords": [
"aapt",
"nodejs"
],
"author": {
"name": "shenzm <szmalq@163.com>"
},
"homepage": "https://github.com/shenzhim/aaptjs#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/shenzhim/aaptjs.git"
},
"license": "MIT",
"dependencies": {
"shelljs": "^0.8.1"
}
}