cordova-import-npm
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "cordova-import-npm", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Import files from npm packages into your cordova www directory automatically, upon cordova prepare or cordova build", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -0,4 +1,60 @@ | ||
# On development, don't use this yet... | ||
# cordova-import-npm | ||
Import files from npm packages into your cordova www directory automatically, upon cordova prepare or cordova build | ||
in production... | ||
Oftentimes we want to import files available in npm modules into our `www/` directory in cordova projects. | ||
## Install | ||
Just run in the root directory of your cordova project | ||
`npm i cordova-import-npm` | ||
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` | ||
## Settings | ||
You define the npm files you'd like to import by editing the file `npmFilesToImport.json`. The syntax is the following: | ||
```json | ||
{ | ||
"npmPackageName": { | ||
"from": "path/to/file/relative/to/npmModule/directory", | ||
"to": "path/to/file/relative/to/cordovaWWW/directory" | ||
} | ||
} | ||
``` | ||
The paths may be strings or arrays, though arrays are recommended as then it works in either unix or windows file systems. | ||
Use an array to copy more than one file for each package. | ||
## Example | ||
Imagine you want the latest jquery and bootsrap files on your `www/js/res/` and `www/css/res/ directories`. Just run | ||
``` | ||
npm i cordova-import-npm | ||
``` | ||
And then edit your `npmFilesToImport.json` with this info: | ||
```json | ||
{ | ||
"jquery": { | ||
"from": ["dist", "jquery.min.js"], | ||
"to": ["js", "res", "jquery.min.js"] | ||
}, | ||
"bootstrap": [ | ||
{ | ||
"from": ["dist", "js", "bootstrap.min.js"], | ||
"to": ["js", "res", "bootstrap.min.js"] | ||
}, | ||
{ | ||
"from": ["dist", "css", "bootstrap.min.css"], | ||
"to": ["css", "res", "bootstrap.min.css"] | ||
}, | ||
], | ||
} | ||
``` | ||
Then run `cordova prepare` or `cordova build` and the npm files will be copied. |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
40271
6
52
61
0
2