Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@squiz/component-cli-lib

Package Overview
Dependencies
Maintainers
31
Versions
579
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@squiz/component-cli-lib - npm Package Compare versions

Comparing version 1.2.1-alpha.30 to 1.2.1-alpha.31

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

## [1.2.1-alpha.31](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.0...v1.2.1-alpha.31) (2022-05-12)
**Note:** Version bump only for package @squiz/component-cli-lib
## [1.2.1-alpha.30](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.0...v1.2.1-alpha.30) (2022-05-11)

@@ -8,0 +16,0 @@

40

lib/index.js

@@ -26,9 +26,13 @@ "use strict";

const result = await handleResponse(axios.post('upload-component/next/' + initialUpload.id));
if (result.status === 'Success') {
fs_1.default.rmSync(tmpDir, { force: true, recursive: true });
if (result.status === 'successful') {
console.log('Success');
}
else {
console.log('failed for some reason', result);
}
}
catch (e) {
fs_1.default.rmSync(tmpDir, { force: true, recursive: true });
if (e instanceof Error) {
console.log(e.stack);
console.error(e.message);

@@ -40,32 +44,38 @@ }

}
finally {
fs_1.default.rmSync(tmpDir, { force: true, recursive: true });
}
}
exports.uploadComponentFolder = uploadComponentFolder;
async function watchAndWaitForUploadAndScanComplete(id, axios) {
const poll = () => handleResponse(axios.get('upload-component/status/' + id));
return new Promise((resolve, reject) => {
setTimeout(async () => {
const req = await handleResponse(axios.get('upload-component/status/' + id));
const recurse = () => poll().then(async (req) => {
if (req.status == 'Success') {
resolve();
return;
}
if (req.status == 'Flagged') {
else if (req.status == 'Flagged') {
reject(new Error('upload has been flagged as a virus'));
return;
}
if (req.status == 'Error') {
else if (req.status == 'Error') {
reject(new Error('there has been an error'));
return;
}
watchAndWaitForUploadAndScanComplete(id, axios);
}, 1000);
else {
setTimeout(async () => {
await recurse();
}, 1000);
}
});
recurse();
});
}
async function handleResponse(promise) {
var _a;
try {
const result = await promise;
if (result.status > 299 || result.status < 200) {
throw new Error(`Unexpected response code ${result.status}`);
const message = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.message;
if (message) {
throw new Error(`Unexpected response code ${result.status}. message: ${message}`);
}
else {
throw new Error(`Unexpected response code ${result.status}.`);
}
}

@@ -72,0 +82,0 @@ if (result.headers['content-type'].includes('application/json') && typeof result.data == 'string') {

{
"name": "@squiz/component-cli-lib",
"version": "1.2.1-alpha.30",
"version": "1.2.1-alpha.31",
"description": "",

@@ -30,7 +30,7 @@ "main": "lib/index.js",

"dependencies": {
"@squiz/virus-scanner-lib": "^1.2.1-alpha.30",
"@squiz/virus-scanner-lib": "^1.2.1-alpha.31",
"archiver": "5.3.1",
"axios": "0.27.2"
},
"gitHead": "28abf2d87b6ba5b97a9e48076048ce6bc35005ce"
"gitHead": "ad2e8fa4814e0679e1d02c0feb6a2c8109ed45fd"
}

@@ -29,8 +29,13 @@ import { zipDirectory } from './utils/zipDirectory';

if (result.status === 'Success') {
fs.rmSync(tmpDir, { force: true, recursive: true });
if (result.status === 'successful') {
console.log('Success');
} else {
console.log('failed for some reason', result);
}
} catch (e) {
fs.rmSync(tmpDir, { force: true, recursive: true });
if (e instanceof Error) {
console.log(e.stack);
console.error(e.message);

@@ -40,4 +45,2 @@ } else {

}
} finally {
fs.rmSync(tmpDir, { force: true, recursive: true });
}

@@ -47,24 +50,21 @@ }

async function watchAndWaitForUploadAndScanComplete(id: string, axios: Axios): Promise<void> {
const poll = () => handleResponse<ScanStatus>(axios.get('upload-component/status/' + id));
return new Promise((resolve, reject) => {
setTimeout(async () => {
const req = await handleResponse<ScanStatus>(axios.get('upload-component/status/' + id));
const recurse = () =>
poll().then(async (req) => {
if (req.status == 'Success') {
resolve();
} else if (req.status == 'Flagged') {
reject(new Error('upload has been flagged as a virus'));
} else if (req.status == 'Error') {
reject(new Error('there has been an error'));
} else {
setTimeout(async () => {
await recurse();
}, 1000);
}
});
if (req.status == 'Success') {
resolve();
return;
}
if (req.status == 'Flagged') {
reject(new Error('upload has been flagged as a virus'));
return;
}
if (req.status == 'Error') {
reject(new Error('there has been an error'));
return;
}
watchAndWaitForUploadAndScanComplete(id, axios);
}, 1000);
recurse();
});

@@ -78,3 +78,9 @@ }

if (result.status > 299 || result.status < 200) {
throw new Error(`Unexpected response code ${result.status}`);
const message = (result?.data as any)?.message;
if (message) {
throw new Error(`Unexpected response code ${result.status}. message: ${message}`);
} else {
throw new Error(`Unexpected response code ${result.status}.`);
}
}

@@ -81,0 +87,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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