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

arcgis-lib-downloader

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arcgis-lib-downloader - npm Package Compare versions

Comparing version 1.2.6 to 1.2.7

274

bin/arcgis-lib-downloader.js

@@ -13,7 +13,8 @@ #!/usr/bin/env node

const { argv } = require('yargs');
const wrap = require('word-wrap')
const wrap = require('word-wrap');
require('dotenv').config();
program.version('1.2.6');
program.version('1.2.7');
const url = 'https://developers.arcgis.com/data/downloads.json';
const pageData = 'https://developers.arcgis.com/page-data/downloads/page-data.json';
const settings = { method: 'Get' };

@@ -34,21 +35,32 @@

function queryHashReq(jsonFile) {
const queryList = jsonFile.staticQueryHashes;
return `https://developers.arcgis.com/page-data/sq/d/${queryList[0]}.json`;
}
// retrieves data from json file for the product table and returns list with data in it
function retrieveProdInfo(jsonFile) {
// loop through and extract info we need to construct table
jsonFile.forEach((key) => {
const nodeData = [];
const nodes = jsonFile.data.allFile.nodes;
nodes.forEach((item) => {
nodeData.push(item.childRawYaml.raw);
});
nodeData.forEach((content) => {
const rowData = [];
const extractedName = key.name;
rowData.push(extractedName);
const extractedProductName = key.product_name;
rowData.push(extractedProductName);
const extractedCurrVersion = key.current_version;
rowData.push(extractedCurrVersion);
const extractedDownloads = key.downloads;
const keyDownloads = [];
Object.keys(extractedDownloads).forEach((downloadable) => {
keyDownloads.push(downloadable);
});
rowData.push(keyDownloads);
rowData.push(content.id);
rowData.push(content.label);
const versions = [];
content.downloads.forEach((obj) => {
versions.push(obj.version)
})
const currVers = versions[0];
rowData.push(currVers);
if (versions.length > 1) {
const otherVers = versions.slice(1);
rowData.push(otherVers);
} else {
rowData.push('No other version available.');
}
prodData.push(rowData);
});
})
return prodData;

@@ -59,67 +71,75 @@ }

function retrieveVerInfo(jsonFile) {
const nodeData = [];
const userIn = process.argv.slice(2);
if (userIn.length === 1) {
jsonFile.forEach((item) => {
// store variable to have access to information in 'downloads' section of json
const downloadList = item.downloads;
// loop through and extract info we need to construct table
Object.keys(downloadList).forEach((info) => {
const nodes = jsonFile.data.allFile.nodes;
nodes.forEach((item) => {
nodeData.push(item.childRawYaml.raw);
});
nodeData.forEach((content) => {
if (userIn.length === 1) {
content.downloads.forEach((obj) => {
const rowData = [];
const extractedVersion = downloadList[info].version_number;
rowData.push(extractedVersion);
const extractedRd = downloadList[info].release_date;
rowData.push(extractedRd);
const extractedFiles = downloadList[info].files;
rowData.push(obj.version);
if (obj.releaseDate === undefined) {
rowData.push('No data available.')
} else {
rowData.push(obj.releaseDate);
}
const fileData = [];
const folderData = [];
Object.keys(extractedFiles).forEach((items) => {
const fileLabel = extractedFiles[items].label;
const fileSize = extractedFiles[items].filesize;
const newFormat = `${fileLabel}(${fileSize})`;
const fold = extractedFiles[items].folder;
obj.files.forEach((item) => {
const label = item.label;
const size = item.size;
const format = `${label}(${size})`;
const fold = item.folder;
folderData.push(fold);
fileData.push(newFormat);
});
rowData.push(fileData);
rowData.push(folderData[0]);
fileData.push(format);
})
if (fileData.length === 0) {
rowData.push('No data available.')
} else {
rowData.push(fileData);
}
if (folderData[0] === undefined) {
rowData.push('No data available.')
} else {
rowData.push(folderData[0]);
}
verData.push(rowData);
});
});
} else if (userIn.length === 2) {
jsonFile.forEach((item) => {
if (item.name === userIn[1]) {
// store variable to have access to information in 'downloads' section of json
const downloadList = item.downloads;
// loop through and extract info we need to construct table
Object.keys(downloadList).forEach((info) => {
})
} else if (userIn.length === 2) {
if (content.id === userIn[1]) {
content.downloads.forEach((obj) => {
const rowData = [];
const extractedVersion = downloadList[info].version_number;
rowData.push(extractedVersion);
const extractedRd = downloadList[info].release_date;
rowData.push(extractedRd);
const extractedFiles = downloadList[info].files;
rowData.push(obj.version);
if (obj.releaseDate === undefined) {
rowData.push('No data available.')
} else {
rowData.push(obj.releaseDate);
}
const fileData = [];
const folderData = [];
Object.keys(extractedFiles).forEach((items) => {
const fileLabel = extractedFiles[items].label;
const fileSize = extractedFiles[items].filesize;
if (fileData.length === 0) {
const newFormat = `${fileLabel}(${fileSize})`;
const fold = extractedFiles[items].folder;
folderData.push(fold);
fileData.push(newFormat);
} else {
const newFormat = `\n${fileLabel}(${fileSize})`;
const fold = extractedFiles[items].folder;
folderData.push(fold);
fileData.push(newFormat);
}
});
rowData.push(fileData);
rowData.push(folderData[0]);
obj.files.forEach((item) => {
const label = item.label;
const size = item.size;
const format = `${label}(${size})`;
const fold = item.folder;
folderData.push(fold);
fileData.push(format);
})
if (fileData.length === 0) {
rowData.push('No data available.')
} else {
rowData.push(fileData);
}
if (folderData[0] === undefined) {
rowData.push('No data available.')
} else {
rowData.push(folderData[0]);
}
verData.push(rowData);
});
})
}
});
}
}
})
return verData;

@@ -131,9 +151,13 @@ }

function makeTable() {
fetch(url, settings)
const userIn = process.argv.slice(2);
fetch(pageData, settings)
.then((res) => res.json())
.then((json) => {
const userIn = process.argv.slice(2);
const hashUrl = queryHashReq(json)
fetch(hashUrl, settings)
.then((res) => res.json())
.then((hashJson) => {
// calls to data retrieval functions
const prodDown = retrieveProdInfo(json);
const verDown = retrieveVerInfo(json);
const prodDown = retrieveProdInfo(hashJson);
const verDown = retrieveVerInfo(hashJson);

@@ -144,3 +168,3 @@ // configuring table display

0: { width: 10 },
1: { width: 17 },
1: { width: 18 },
2: { width: 20 },

@@ -159,2 +183,3 @@ 3: { width: 35 },

});
});
}

@@ -329,35 +354,58 @@

});
fetch(url, settings)
.then((res) => res.json())
.then((json) => {
const prodInput = argv.product || argv.p;
checkProdInput(prodInput);
const verInput = argv.ver || argv.v;
checkVerInput(prodInput, verInput);
json.forEach((item) => {
// gets user input from command line
const { name } = item;
const downloadList = item.downloads;
// checks if the user left the version section of the input empty or not
if (verInput === undefined) {
if (item.name === prodInput) {
const curr = item.current_version;
const editedCurr= curr.slice(1);
let finalCurr = editedCurr.replace('_', '.');
while(finalCurr.indexOf('_') !== -1) {
finalCurr = finalCurr.replace('_', '.');
fetch(pageData, settings)
.then((res) => res.json())
.then((json) => {
const hashUrl = queryHashReq(json)
fetch(hashUrl, settings)
.then((res) => res.json())
.then((hashJson) => {
const nodeData = [];
const nodes = hashJson.data.allFile.nodes;
nodes.forEach((item) => {
nodeData.push(item.childRawYaml.raw);
});
const prodInput = argv.product || argv.p;
checkProdInput(prodInput);
const verInput = argv.ver || argv.v;
checkVerInput(prodInput, verInput);
nodeData.forEach((item) => {
// gets user input from command line
const { id } = item;
const downloadList = item.downloads;
// checks if the user left the version section of the input empty or not
if (verInput === undefined) {
if (id === prodInput) {
const curr = downloadList[0].version;
// if the user doesn't specify a version number, use the most current available
Object.keys(downloadList).forEach((info) => {
if (downloadList[info].version === curr) {
if (id === prodInput) {
const extractedFiles = downloadList[info].files;
// want to extract all relvant info to craft new url
Object.keys(extractedFiles).forEach((items) => {
if (extractedFiles[items].label !== 'Documentation') {
const name = extractedFiles[items].name;
const fold = extractedFiles[items].folder;
const newUrl = `https://downloads.arcgis.com/dms/rest/download/secured/${name}?f=json&token=${token.token}&folder=${fold}`;
// use this method to make fetches to urls to download file
downloadFetch(newUrl, name);
}
});
}
}
});
}
// if the user doesn't specify a version number, use the most current available
// otherwise, we will use the version that the user specifies
} else {
Object.keys(downloadList).forEach((info) => {
if (downloadList[info].version_number === finalCurr) {
if (name === prodInput) {
if (downloadList[info].version === verInput.toString()) {
if (id === prodInput) {
const extractedFiles = downloadList[info].files;
// want to extract all relvant info to craft new url
Object.keys(extractedFiles).forEach((items) => {
// we do not want to use the section labeled 'Documentation'
if (extractedFiles[items].label !== 'Documentation') {
const fileName = extractedFiles[items].filename;
const name = extractedFiles[items].name;
const fold = extractedFiles[items].folder;
const newUrl = `https://downloads.arcgis.com/dms/rest/download/secured/${fileName}?f=json&token=${token.token}&folder=${fold}`;
// use this method to make fetches to urls to download file
downloadFetch(newUrl, fileName);
const newUrl = `https://downloads.arcgis.com/dms/rest/download/secured/${name}?f=json&token=${token.token}&folder=${fold}`;
downloadFetch(newUrl, name);
}

@@ -369,21 +417,3 @@ });

}
// otherwise, we will use the version that the user specifies
} else {
Object.keys(downloadList).forEach((info) => {
if (downloadList[info].version_number === verInput.toString()) {
if (name === prodInput) {
const extractedFiles = downloadList[info].files;
Object.keys(extractedFiles).forEach((items) => {
// we do not want to use the section labeled 'Documentation'
if (extractedFiles[items].label !== 'Documentation') {
const fileName = extractedFiles[items].filename;
const fold = extractedFiles[items].folder;
const newUrl = `https://downloads.arcgis.com/dms/rest/download/secured/${fileName}?f=json&token=${token.token}&folder=${fold}`;
downloadFetch(newUrl, fileName);
}
});
}
}
});
}
});
});

@@ -390,0 +420,0 @@ });

{
"name": "arcgis-lib-downloader",
"version": "1.2.6",
"version": "1.2.7",
"description": "npm package for gaining access to ArcGIS programs",

@@ -40,2 +40,3 @@ "main": "app.js",

"isomorphic-form-data": "^2.0.0",
"json": "^11.0.0",
"prompt": "^1.1.0",

@@ -42,0 +43,0 @@ "table": "^6.7.1",

@@ -42,3 +42,3 @@ # ArcGIS Lib Downloader

```bash
arcgis-lib-downloader -p javascript -v 4.19 --user abc123 --password def456
arcgis-lib-downloader -p javascript -v 4.19 --user 'abc123' --password 'def456'
```

@@ -59,2 +59,2 @@

This project was created using Node.js. If you wish to contribute and suggest changes to enhance the performance of the lib downloader, first make sure that you have Node and npm installed on your machine. Next, you are either going to need to clone this repository and create a local version on your machine or create a Pull Request that can be reviewed by one of the contributors of this repository.
This project was created using Node.js. If you wish to contribute and suggest changes to enhance the performance of the lib downloader, first make sure that you have Node and npm installed on your machine. Next, you are either going to need to clone this repository and create a local version on your machine or create a Pull Request that can be reviewed by one of the contributors of this repository.
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