New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ota_zip_get_info

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ota_zip_get_info - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

package.json
{
"name": "ota_zip_get_info",
"version": "1.0.1",
"version": "1.0.2",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -9,3 +9,9 @@

OtaZipGetInfo.regist("SERVER","package.json", content => JSON.parse(content).version)
OtaZipGetInfo.regist("SERVER","package.json", content => JSON.parse(content).version, (zip)=>{
// 默认就判断 获取版本文件是否存在。这个函数没必要不用重写
if(!OtaZipGetInfo.isZip(zip)) {
return false;
}
return zip.file("plugin/camera/run_face.bat");
})

@@ -15,11 +21,11 @@ OtaZipGetInfo.format = r => r

function App() {
return (
<div className="App">
<input type='file' onChange={async (e)=>{
let file = e.target.files[0];
const res = await OtaZipGetInfo.getInfo(file)
console.log(res)
}}></input>
</div>
);
return (
<div className="App">
<input type='file' onChange={async (e)=>{
let file = e.target.files[0];
const res = await OtaZipGetInfo.getInfo(file)
console.log(res)
}}></input>
</div>
);
}

@@ -29,2 +35,3 @@

```

@@ -0,1 +1,3 @@

import JSZip from "jszip";
class OTA_TYPE {

@@ -6,9 +8,26 @@ static TYPE = {

static regist(type, versionFilePath = "version", versionFileGetter = (data)=>data) {
static isZip(zip) {
if (zip instanceof JSZip) {
return true
}
return false
}
static regist(type, versionFilePath = "version", versionFileGetter = (data)=>data, check) {
if(OTA_TYPE.TYPE[type]) {
throw new Error("不能重复注册", OTA_TYPE.TYPE)
}
if(!check) {
check = (zip) => {
if(!OTA_TYPE.isZip(zip)) {
throw new Error("不是一个ZIP", zip)
}
return zip.file(versionFilePath)
}
}
OTA_TYPE.TYPE[type] = {
versionFilePath,
versionFileGetter
versionFileGetter,
check
}

@@ -15,0 +34,0 @@

@@ -11,4 +11,4 @@ import JSZip from "jszip";

static regist(type, versionFilePath, versionFileGetter) {
return OTA_TYPE.regist(type, versionFilePath, versionFileGetter);
static regist(type, versionFilePath, versionFileGetter, check) {
return OTA_TYPE.regist(type, versionFilePath, versionFileGetter, check);
}

@@ -20,4 +20,7 @@

static isZip(zip) {
return OTA_TYPE.isZip(zip);
}
static async getInfo(file) {
console.log(file);
const res = {

@@ -36,2 +39,5 @@ file: file.name,

for (let key in OTA_TYPE.TYPE) {
if (!OTA_TYPE.TYPE[key].check(zip)) {
continue;
}
fileHandle = zip.file(OTA_TYPE.TYPE[key].versionFilePath);

@@ -61,3 +67,4 @@ if (fileHandle) {

} catch (e) {
res.errMsg = "这就不是个zip压缩包" + e.stack;
console.error(e);
res.errMsg = "错误" + e.message;
return OtaZipGetInfo.format(res);

@@ -64,0 +71,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc