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

app-downloader

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

app-downloader - npm Package Compare versions

Comparing version 0.0.1 to 1.0.0

.nvmrc

190

dist/index.js

@@ -1,53 +0,169 @@

(function (root, factory) {
// https://github.com/umdjs/umd/blob/master/templates/returnExports.js
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], factory);
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.returnExports = factory();
// Modules
const os = require('os');
const jetpack = require('fs-jetpack');
const path = require('path');
const fetch = require('wonderful-fetch');
const downloads = require('downloads-folder');
const powertools = require('node-powertools');
// Main
module.exports = async function () {
const interval = setInterval(() => {
log('Still downloading, please be patient! :)');
}, 3000);
try {
// Clear
clear();
// Download
await download();
// Launch
launch()
.then(() => {
install();
});
return
} catch (e) {
error('Failed to download:', e);
error('Ensure you are using the right Node.js version');
error('Alternatively, download the app manually from:', getURL());
} finally {
clearInterval(interval);
}
}(typeof self !== 'undefined' ? self : this, function () {
};
var environment = (Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]') ? 'node' : 'browser';
if (require.main === module) {
module.exports();
}
var SOURCE = 'library';
var VERSION = '0.0.1';
function clear() {
const location = getDownloadPath();
function __module_title(options) {
var self = this;
log(`Clearing ${location}`)
self.options = options || {};
jetpack.remove(location);
}
return self
};
function download(location) {
return new Promise(async function(resolve, reject) {
const location = getDownloadPath();
const url = getURL();
__module_title.prototype.method = function (options) {
var self = this;
log(`Downloading app to ${location} from ${url}`);
options = options || {};
// Process
const res = await fetch(url);
const fileStream = jetpack.createWriteStream(location);
return new Promise(function(resolve, reject) {
await new Promise((resolve, reject) => {
res.body.pipe(fileStream);
res.body.on('error', reject);
});
fileStream.on('finish', resolve);
})
.then((r) => {
log('Download finished!');
})
.catch((e) => {
error('Download failed!', e);
})
return resolve();
});
}
function getDownloadPath() {
const url = getURL();
const packageJSON = jetpack.read(path.join(process.cwd(), 'package.json'), 'json');
return path.join(downloads(), url.split('/').slice(-1)[0]);
}
function getURL() {
const name = os.type();
if (name === 'Darwin') {
return 'https://github.com/somiibo/download-server/releases/download/installer/Somiibo.dmg'
} else if (name === 'Windows_NT') {
return 'https://github.com/somiibo/download-server/releases/download/installer/Somiibo-Setup.exe'
} else {
return 'https://github.com/somiibo/download-server/releases/download/installer/Somiibo_amd64.deb'
}
}
// Register
if (environment === 'browser') {
try {
window.__module_title = __module_title;
} catch (e) {
async function launch() {
const location = getDownloadPath();
const name = os.type();
log(`Launching app at ${location}`)
try {
if (name === 'Darwin') {
powertools.execute(`open "${location}"`)
.then(() => {
log('Drag the app to your Applications folder to install it');
})
} else if (name === 'Windows_NT') {
powertools.execute(`"${location}"`)
.then(() => {})
} else {
powertools.execute(`sudo apt install "${location}"`)
.then(() => {
powertools.execute(`restart-manager`).catch(e => {console.error(e)})
})
}
} catch (e) {
error('Application failed to execute:', e);
console.log('\n\n\n')
log(`Please launch the app manually: ${location}`);
}
}
// Just return a value to define the module export.
// This example returns an object, but the module
// can return a function as the exported value.
return __module_title; // Enable if using UMD
async function install() {
const location = getDownloadPath();
const name = os.type();
const parsedPath = path.parse(location);
const filename = parsedPath.name;
}));
try {
if (name === 'Darwin') {
log(`Attempting to install ${location}...`);
const volumes = jetpack.list('/Volumes').sort().reverse();
const found = volumes.find(v => v.includes(filename));
const applicationPath = `/Applications/${filename}.app`;
// Check if the app is mounted
if (!found) {
return setTimeout(() => {
install();
}, 1000);
}
// Remove the app if it already exists
if (jetpack.exists(applicationPath)) {
jetpack.remove(applicationPath);
}
// Copy the app to the Applications folder
jetpack.copy(path.join('/Volumes', found, `${filename}.app`), applicationPath)
await powertools.execute(`open "${applicationPath}"`);
}
} catch (e) {
error('Application failed to install:', e);
console.log('\n\n\n')
log(`Please install the app manually: ${location}`);
}
}
function log() {
console.log(`[${new Date().toLocaleTimeString()}]`, ...arguments)
}
function error() {
console.error(`[${new Date().toLocaleTimeString()}]`, ...arguments)
}

28

package.json
{
"TODO": "__module_domain, __module_name, __asset_file_name, __module_owner, __module_title, __module_class_name, __module_description, __module_feature",
"name": "app-downloader",
"version": "0.0.1",
"description": "__module_description",
"version": "1.0.0",
"description": "Helper module to install package.json downloads",
"main": "./dist/index.js",
"scripts": {
"start": "node ./dist/index.js",
"test": "npm run prepare && ./node_modules/mocha/bin/mocha test/ --recursive --timeout=10000",
"prepare": "node -e 'require(`prepare-package`)()'",
"prepare": "node -e \"require('prepare-package')()\"",
"prepare:watch": "nodemon -w ./src -e '*' --exec 'npm run prepare'"

@@ -18,3 +18,3 @@ },

"engines": {
"node": ">=6.0.0"
"node": ">=18"
},

@@ -32,6 +32,6 @@ "os": [

"type": "git",
"url": "git+https://github.com/__module_owner/__module_name"
"url": "git+https://github.com/itw-creative-works/app-downloader"
},
"keywords": [
"__module_name"
"app-downloader"
],

@@ -41,12 +41,16 @@ "author": "ITW Creative Works",

"bugs": {
"url": "https://github.com/__module_owner/__module_name/issues"
"url": "https://github.com/itw-creative-works/app-downloader/issues"
},
"homepage": "https://__module_domain",
"homepage": "https://itwcreativeworks.com",
"dependencies": {
"itwcw-package-analytics": "^1.0.1"
"downloads-folder": "^3.0.3",
"fs-jetpack": "^5.1.0",
"itwcw-package-analytics": "^1.0.6",
"node-powertools": "^1.5.9",
"wonderful-fetch": "^1.1.12"
},
"devDependencies": {
"mocha": "^8.4.0",
"prepare-package": "^1.1.5"
"prepare-package": "^1.1.13"
}
}
}
<p align="center">
<a href="https://__module_domain">
<img src="https://cdn.itwcreativeworks.com/assets/__asset_file_name/images/logo/__asset_file_name-brandmark-black-x.svg" width="100px">
<a href="https://itwcreativeworks.com">
<img src="https://cdn.itwcreativeworks.com/assets/itw-creative-works/images/logo/itw-creative-works-brandmark-black-x.svg" width="100px">
</a>

@@ -8,82 +8,46 @@ </p>

<p align="center">
<img src="https://img.shields.io/github/package-json/v/__module_owner/__module_name.svg">
<img src="https://img.shields.io/github/package-json/v/itw-creative-works/app-downloader.svg">
<br>
<img src="https://img.shields.io/librariesio/release/npm/__module_name.svg">
<img src="https://img.shields.io/bundlephobia/min/__module_name.svg">
<img src="https://img.shields.io/codeclimate/maintainability-percentage/__module_owner/__module_name.svg">
<img src="https://img.shields.io/npm/dm/__module_name.svg">
<img src="https://img.shields.io/node/v/__module_name.svg">
<img src="https://img.shields.io/website/https/__module_domain.svg">
<img src="https://img.shields.io/github/license/__module_owner/__module_name.svg">
<img src="https://img.shields.io/github/contributors/__module_owner/__module_name.svg">
<img src="https://img.shields.io/github/last-commit/__module_owner/__module_name.svg">
<img src="https://img.shields.io/librariesio/release/npm/app-downloader.svg">
<img src="https://img.shields.io/bundlephobia/min/app-downloader.svg">
<img src="https://img.shields.io/codeclimate/maintainability-percentage/itw-creative-works/app-downloader.svg">
<img src="https://img.shields.io/npm/dm/app-downloader.svg">
<img src="https://img.shields.io/node/v/app-downloader.svg">
<img src="https://img.shields.io/website/https/itwcreativeworks.com.svg">
<img src="https://img.shields.io/github/license/itw-creative-works/app-downloader.svg">
<img src="https://img.shields.io/github/contributors/itw-creative-works/app-downloader.svg">
<img src="https://img.shields.io/github/last-commit/itw-creative-works/app-downloader.svg">
<br>
<br>
<a href="https://__module_domain">Site</a> | <a href="https://www.npmjs.com/package/__module_name">NPM Module</a> | <a href="https://github.com/__module_owner/__module_name">GitHub Repo</a>
<a href="https://itwcreativeworks.com">Site</a> | <a href="https://www.npmjs.com/package/app-downloader">NPM Module</a> | <a href="https://github.com/itw-creative-works/app-downloader">GitHub Repo</a>
<br>
<br>
<strong>__module_name</strong> is the official npm module of <a href="https://__module_domain">__module_title</a>, a free app for __module_feature.
<strong>app-downloader</strong> is the official npm module of <a href="https://itwcreativeworks.com">App Downloader</a>, a free app for Helper module to install package.json downloads.
</p>
## 🌐 __module_title Works in Node AND browser environments
## 🌐 App Downloader Works in Node AND browser environments
Yes, this module works in both Node and browser environments, including compatibility with [Webpack](https://www.npmjs.com/package/webpack) and [Browserify](https://www.npmjs.com/package/browserify)!
## 🦄 Features
* __module_feature
* Helper module to install package.json downloads
## 🔑 Getting an API key
You can use so much of `__module_name` for free, but if you want to do some advanced stuff, you'll need an API key. You can get one by [signing up for a __module_title account](https://__module_domain/signup).
## 📦 Install __module_title
## 📦 Install App Downloader
### Option 1: Install via npm
Install with npm if you plan to use `__module_name` in a Node project or in the browser.
Install with npm if you plan to use `app-downloader` in a Node project or in the browser.
```shell
npm install __module_name
npm install app-downloader
```
If you plan to use `__module_name` in a browser environment, you will probably need to use [Webpack](https://www.npmjs.com/package/webpack), [Browserify](https://www.npmjs.com/package/browserify), or a similar service to compile it.
If you plan to use `app-downloader` in a browser environment, you will probably need to use [Webpack](https://www.npmjs.com/
```js
const __module_name = new (require('__module_name'))({
// Not required, but having one removes limits (get your key at https://__module_domain).
apiKey: 'api_test_key'
});
```
## 📘 Using App Downloader
After you have followed the install step, you can start using `app-downloader` to enhance your project.
### Option 2: Install via CDN
Install with CDN if you plan to use __module_title only in a browser environment.
```html
<script src="https://cdn.jsdelivr.net/npm/__module_name@latest/dist/index.min.js"></script>
<script type="text/javascript">
var __module_name = new __module_class_name({
// Not required, but having one removes limits (get your key at https://__module_domain).
apiKey: 'api_test_Key'
});
</script>
```
For a more in-depth documentation of this library and the App Downloader service, please visit the official App Downloader website.
### Option 3: Use without installation
You can use `__module_name` in a variety of ways that require no installation, such as `curl` in terminal/shell.
## 📝 What Can App Downloader do?
Helper module to install package.json downloads
```shell
# Standard
curl -X POST https://api.__module_domain
```
## ⚡️ Usage
### __module_name.run(options)
```js
__module_name.run(options);
```
## 📘 Using __module_title
After you have followed the install step, you can start using `__module_name` to enhance your project.
For a more in-depth documentation of this library and the __module_title service, please visit the official __module_title website.
## 📝 What Can __module_title do?
__module_description
## 🗨️ Final Words
If you are still having difficulty, we would love for you to post
a question to [the __module_title issues page](https://github.com/__module_owner/__module_name/issues). It is much easier to answer questions that include your code and relevant files! So if you can provide them, we'd be extremely grateful (and more likely to help you find the answer!)
a question to [the App Downloader issues page](https://github.com/itw-creative-works/app-downloader/issues). It is much easier to answer questions that include your code and relevant files! So if you can provide them, we'd be extremely grateful (and more likely to help you find the answer!)

@@ -90,0 +54,0 @@ ## 📚 Projects Using this Library

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