Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 83b80f7

Browse files
committed
Bundle postinstall script dependencies.
Fixes tns build errors.
1 parent 3011d5f commit 83b80f7

File tree

6 files changed

+48
-4
lines changed

6 files changed

+48
-4
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.idea
22
.DS_Store
3-
node_modules
3+
node_modules
4+
*.tgz
5+
scripts/postinstall.js

.npmignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
platforms/android/libraryproject/
22
docs
33
README.md
4-
CHANGELOG.md
4+
CHANGELOG.md
5+
*.tgz
6+
scripts/webpack.config.js
7+
scripts/installer.js
8+
scripts/winston-mock.js

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
}
1212
},
1313
"scripts": {
14+
"bundle-installer": "webpack --config scripts/webpack.config.js scripts/installer.js scripts/postinstall.js",
15+
"prepublish": "npm run bundle-installer",
1416
"postinstall": "node scripts/postinstall.js"
1517
},
1618
"repository": {
@@ -39,7 +41,8 @@
3941
"url": "https://github.com/eddyverbruggen/nativescript-plugin-firebase/issues"
4042
},
4143
"homepage": "https://github.com/eddyverbruggen/nativescript-plugin-firebase",
42-
"dependencies": {
43-
"prompt": "^1.0.0"
44+
"devDependencies": {
45+
"prompt": "^1.0.0",
46+
"webpack": "~2.1.0-beta.25"
4447
}
4548
}

scripts/postinstall.js renamed to scripts/installer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var fs = require('fs');
2+
var path = require('path');
23
var prompt = require('prompt');
34

45
// Default settings for using ios and android with Firebase
@@ -138,6 +139,8 @@ function writeGradleFile(result) {
138139
if(!fs.existsSync(directories.android)) {
139140
fs.mkdirSync(directories.android);
140141
}
142+
console.log(directories.android + '/include.gradle');
143+
console.log(path.resolve(directories.android + '/include.gradle'));
141144
fs.writeFile(directories.android + '/include.gradle',
142145
`
143146
android {

scripts/webpack.config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var path = require("path");
2+
var webpack = require("webpack");
3+
4+
module.exports = {
5+
target: "node",
6+
output: {
7+
//some debug info around module imports
8+
pathinfo: true
9+
},
10+
resolve: {
11+
alias: {
12+
//winston is inherently unpackable. replace with our mock
13+
"winston": path.join(__dirname, "winston-mock.js")
14+
}
15+
},
16+
externals: {
17+
//pkginfo is unpackable too, but we can replace it with a simple expression
18+
"pkginfo": "function(){}"
19+
}
20+
}

scripts/winston-mock.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//Export a Logger-like to avoid crashing winston clients
2+
module.exports.Logger = function Logger() {};
3+
module.exports.Logger.prototype = {
4+
cli: function() {},
5+
help: function() {},
6+
input: function() {},
7+
error: function() {},
8+
};
9+
10+
module.exports.transports = {
11+
Console: function Console() {}
12+
};

0 commit comments

Comments
 (0)