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

cordova-import-npm

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-import-npm - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

onInstall.js

43

importNpmPackages.js

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

const fs = require('fs')
const fse = require('fs-extra')
const path = require('path')
const colors = require('colors/safe')

@@ -13,20 +15,29 @@ const twoSpaces = ' ' // for log indentation

console.log(twoSpaces + 'Project root directory: ' + projectRoot)
copyFile('jquery', path.join('dist', 'jquery.min.js'), path.join('js', 'res', 'jquery.min.js'))
copyFile('bootstrap', path.join('dist', 'js', 'bootstrap.min.js'), path.join('js', 'res', 'bootstrap.min.js'))
copyFile('bootstrap', path.join('dist', 'css', 'bootstrap.min.css'), path.join('css', 'res', 'bootstrap.min.css'))
var npmFilesToImportFileName = context.isThisATest ? 'npmFilesToImport_Example.json' : 'npmFilesToImport.json'
console.log(twoSpaces + 'Importing npm files to copy from ' + colors.cyan(npmFilesToImportFileName) + '\n')
copyFile('jAlert', path.join('dist', 'jAlert.min.js'), path.join('js', 'res', 'jAlert.min.js'))
copyFile('jAlert', path.join('dist', 'jAlert.css'), path.join('css', 'res', 'jAlert.css'))
var rawdata = fs.readFileSync(npmFilesToImportFileName, 'utf8')
try {
var npmFilesToImport = JSON.parse(rawdata);
} catch(e) {
console.log(colors.red(`\nERROR: Your JSON file "${npmFilesToImportFileName}" has syntax errors:\n`))
console.log(rawdata)
process.exit(1)
}
copyFile('leaflet', path.join('dist', 'leaflet.js'), path.join('js', 'res', 'leaflet.js'))
copyFile('leaflet', path.join('dist', 'leaflet.css'), path.join('css', 'res', 'leaflet.css'))
copyFile('leaflet.markercluster', path.join('dist', 'leaflet.markercluster.js'), path.join('js', 'res', 'leaflet.markercluster.js'))
copyFile('leaflet.markercluster', path.join('dist', 'MarkerCluster.css'), path.join('css', 'res', 'MarkerCluster.css'))
copyFile('leaflet.markercluster', path.join('dist', 'MarkerCluster.Default.css'), path.join('css', 'res', 'MarkerCluster.Default.css'))
copyFile('crypto-js', path.join('crypto-js.js'), path.join('js', 'res', 'crypto-js.js'))
copyFile('google-android-app-ids', path.join('dist', 'google-app-ids.json'), path.join('js', 'res', 'google-app-ids.json'))
for (let npmPackage in npmFilesToImport) {
let npmFiles = npmFilesToImport[npmPackage]
if (!Array.isArray(npmFiles) && typeof npmFiles === 'object') {
copyFile(npmPackage, path.join.apply(this, npmFiles.from), path.join.apply(this, npmFiles.to))
} else if (Array.isArray(npmFiles)){
for (let i = 0; i < npmFiles.length; i++) {
npmFilesI = npmFiles[i]
copyFile(npmPackage, path.join.apply(this, npmFilesI.from), path.join.apply(this, npmFilesI.to))
}
} else {
console.log(colors.red(`JSON file "${npmFilesToImportFileName}" has good syntax but fails template, see readme on https://www.npmjs.com/package/cordova-import-npm`))
process.exit(1)
}
}
}

@@ -45,3 +56,3 @@

const consoleMsg = npmPackage + ': ' +
const consoleMsg = colors.cyan(npmPackage) + ': ' +
path.relative(projectRoot, fileOriginFullPath) + ' -> ' +

@@ -48,0 +59,0 @@ path.relative(projectRoot, fileDestFullPath)

@@ -14,4 +14,4 @@ {

"to": ["css", "res", "bootstrap.min.css"]
},
],
}
]
}
{
"name": "cordova-import-npm",
"version": "1.0.1",
"version": "1.0.2",
"description": "Import files from npm packages into your cordova www directory automatically, upon cordova prepare or cordova build",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "npm i jquery bootstrap && node test.js && npm remove jquery bootstrap && echo \"TEST OK\"",
"postinstall": "node onInstall.js"
},

@@ -16,3 +17,7 @@ "keywords": [

"author": "João Pimentel Ferreira",
"license": "GPL-3.0"
"license": "GPL-3.0",
"dependencies": {
"colors": "^1.4.0",
"fs-extra": "^9.1.0"
}
}

@@ -13,3 +13,3 @@ # On development, don't use this yet...

It will add a hook at hooks/ and edit your `config.xml` accordingly, such that npm files that you define will be imported upon `cordova prepare` or `cordova build`
It will add a hook at your hooks directory (if you have none defined in `config.xml` it will use `hooks/`) and edit your `config.xml` accordingly, such that npm files that you set will be imported upon `cordova prepare` or `cordova build`

@@ -34,6 +34,7 @@ ## Settings

Imagine you want the latest jquery and bootsrap files on your `www/js/res/` and `www/css/res/ directories`. Just run
Imagine you wanted the latest jquery and bootsrap files on your `www/js/res/` and `www/css/res/` directories. Just run
```
npm i cordova-import-npm
npm i jquery bootstrap
```

@@ -62,2 +63,2 @@

Then run `cordova prepare` or `cordova build` and the npm files will be copied.
Then run `cordova prepare` or `cordova build` and the npm files will be copied before anything else is processed.
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