diff --git a/.gitignore b/.gitignore index e2c08177..9e9a1e7f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .idea .DS_Store -node_modules \ No newline at end of file +node_modules +*.tgz +scripts/postinstall.js diff --git a/.npmignore b/.npmignore index 6081846d..9fa06ac3 100644 --- a/.npmignore +++ b/.npmignore @@ -1,4 +1,8 @@ platforms/android/libraryproject/ docs README.md -CHANGELOG.md \ No newline at end of file +CHANGELOG.md +*.tgz +scripts/webpack.config.js +scripts/installer.js +scripts/winston-mock.js diff --git a/package.json b/package.json index d865e8eb..6f03259d 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,9 @@ } }, "scripts": { + "bundle-installer": "webpack --config scripts/webpack.config.js scripts/installer.js scripts/postinstall.js", + "prepublish": "npm run bundle-installer", + "postinstall": "node scripts/postinstall.js" "postinstall": "node scripts/postinstall.js", "config": "node scripts/postinstall.js config" }, @@ -42,6 +45,9 @@ "url": "https://github.com/eddyverbruggen/nativescript-plugin-firebase/issues" }, "homepage": "https://github.com/eddyverbruggen/nativescript-plugin-firebase", + "devDependencies": { + "prompt": "^1.0.0", + "webpack": "~2.1.0-beta.25" "dependencies": { "app-root-path": "^2.0.1", "prompt-lite": "0.1.1" diff --git a/scripts/postinstall.js b/scripts/installer.js similarity index 99% rename from scripts/postinstall.js rename to scripts/installer.js index 192e591f..846095b5 100755 --- a/scripts/postinstall.js +++ b/scripts/installer.js @@ -1,6 +1,8 @@ var fs = require('fs'); var path = require('path'); var prompt = require('prompt-lite'); +var path = require('path'); +var prompt = require('prompt'); // Default settings for using ios and android with Firebase var usingiOS = false, usingAndroid = false; diff --git a/scripts/webpack.config.js b/scripts/webpack.config.js new file mode 100644 index 00000000..375eea1a --- /dev/null +++ b/scripts/webpack.config.js @@ -0,0 +1,20 @@ +var path = require("path"); +var webpack = require("webpack"); + +module.exports = { + target: "node", + output: { + //some debug info around module imports + pathinfo: true + }, + resolve: { + alias: { + //winston is inherently unpackable. replace with our mock + "winston": path.join(__dirname, "winston-mock.js") + } + }, + externals: { + //pkginfo is unpackable too, but we can replace it with a simple expression + "pkginfo": "function(){}" + } +} diff --git a/scripts/winston-mock.js b/scripts/winston-mock.js new file mode 100644 index 00000000..f8a4b01b --- /dev/null +++ b/scripts/winston-mock.js @@ -0,0 +1,12 @@ +//Export a Logger-like to avoid crashing winston clients +module.exports.Logger = function Logger() {}; +module.exports.Logger.prototype = { + cli: function() {}, + help: function() {}, + input: function() {}, + error: function() {}, +}; + +module.exports.transports = { + Console: function Console() {} +};