[jira] [Commented] (CB-11044) files modified by after_prepare hook are reverted when restoring plugins
[ https://issues.apache.org/jira/browse/CB-11044?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15235827#comment-15235827 ] Grant Patterson commented on CB-11044: -- Neither changing the hook type nor calling {{cordova prepare}} appears to workaround the problem. After both {{cordova prepare}} and {{cordova build}}, the changes made by the hook have been reverted. For now I'm working around by downgrading to 5.3.3 :-/ > files modified by after_prepare hook are reverted when restoring plugins > > > Key: CB-11044 > URL: https://issues.apache.org/jira/browse/CB-11044 > Project: Apache Cordova > Issue Type: Bug > Components: CordovaLib >Affects Versions: 5.4.0, 6.0.0, 5.4.1, 6.0.1, 6.1.0, 6.1.1 > Environment: OSX 10.11.4, also happens in Greenhouse CI tool >Reporter: Grant Patterson >Assignee: Vladimir Kotikov > Labels: Android, iOS, triaged > > I have a hook that uses the {{fs}} module functions {{readFileSync}} and > {{writeFileSync}} to modify files in the platforms/ directory. I'm using a > hook only barely modified from {{020_replace_text.js}} in these examples, to > which the most recent Cordova documentation links: > http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/ > The CLI command I use is {{cordova run ios}} (also android) > It all works fine in Cordova 5.3.3, but starting with 5.4.0 the hook *thinks* > it wrote the file properly, and I can re-{{readFileSync}} to confirm this, > but the write does not appear to stick. When the build is over, the file has > reverted to its pre-hook state and the built app does not have the change. > I have tried wrapping my hook in: > {{module.exports = function(context) {}} > as the documentation suggests. I also moved the hook to scripts/ and tried > referencing it in config.xml, since the hooks/ directory is deprecated. None > of these seem to make any difference. It seems that anything in the www/ > directory has this issue, as well as platforms/android/AndroidManifest.xml. > If I write to a new file in the same directory, the file does not persist, > so it must be the whole directory that's being overwritten. If I raise an > exception in the hook, the build fails and the file remains properly > modified. So it's definitely something after this hook executes that undoes > it. > Interesting development: It's something to do with my plugins; it doesn't > happen in a small sample project. I use {{}} entries in config.xml to > define which plugins should be installed. When I delete these entries—without > actually removing any of the plugins!—this issue doesn't happen. -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org
[jira] [Commented] (CB-11044) files modified by after_prepare hook are reverted when restoring plugins
[ https://issues.apache.org/jira/browse/CB-11044?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15235068#comment-15235068 ] Vladimir Kotikov commented on CB-11044: --- [~nikhilkh], [~jasongin], the root cause of this is an excess prepare after plugin add (triggered by plugin restore), so this probably will be resolved automatically after CB-11022 will be merged. > files modified by after_prepare hook are reverted when restoring plugins > > > Key: CB-11044 > URL: https://issues.apache.org/jira/browse/CB-11044 > Project: Apache Cordova > Issue Type: Bug > Components: CordovaLib >Affects Versions: 5.4.0, 6.0.0, 5.4.1, 6.0.1, 6.1.0, 6.1.1 > Environment: OSX 10.11.4, also happens in Greenhouse CI tool >Reporter: Grant Patterson >Assignee: Vladimir Kotikov > Labels: Android, iOS, triaged > > I have a hook that uses the {{fs}} module functions {{readFileSync}} and > {{writeFileSync}} to modify files in the platforms/ directory. I'm using a > hook only barely modified from {{020_replace_text.js}} in these examples, to > which the most recent Cordova documentation links: > http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/ > The CLI command I use is {{cordova run ios}} (also android) > It all works fine in Cordova 5.3.3, but starting with 5.4.0 the hook *thinks* > it wrote the file properly, and I can re-{{readFileSync}} to confirm this, > but the write does not appear to stick. When the build is over, the file has > reverted to its pre-hook state and the built app does not have the change. > I have tried wrapping my hook in: > {{module.exports = function(context) {}} > as the documentation suggests. I also moved the hook to scripts/ and tried > referencing it in config.xml, since the hooks/ directory is deprecated. None > of these seem to make any difference. It seems that anything in the www/ > directory has this issue, as well as platforms/android/AndroidManifest.xml. > If I write to a new file in the same directory, the file does not persist, > so it must be the whole directory that's being overwritten. If I raise an > exception in the hook, the build fails and the file remains properly > modified. So it's definitely something after this hook executes that undoes > it. > Interesting development: It's something to do with my plugins; it doesn't > happen in a small sample project. I use {{}} entries in config.xml to > define which plugins should be installed. When I delete these entries—without > actually removing any of the plugins!—this issue doesn't happen. -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org
[jira] [Commented] (CB-11044) files modified by after_prepare hook are reverted
[ https://issues.apache.org/jira/browse/CB-11044?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15233010#comment-15233010 ] Nikhil Khandelwal commented on CB-11044: [~jasongin] FYI > files modified by after_prepare hook are reverted > - > > Key: CB-11044 > URL: https://issues.apache.org/jira/browse/CB-11044 > Project: Apache Cordova > Issue Type: Bug > Components: CordovaLib >Affects Versions: 5.4.0, 6.0.0, 5.4.1, 6.0.1, 6.1.0, 6.1.1 > Environment: OSX 10.11.4, also happens in Greenhouse CI tool >Reporter: Grant Patterson >Assignee: Vladimir Kotikov > Labels: Android, iOS > > I have a hook that uses the {{fs}} module functions {{readFileSync}} and > {{writeFileSync}} to modify files in the platforms/ directory. I'm using a > hook only barely modified from {{020_replace_text.js}} in these examples, to > which the most recent Cordova documentation links: > http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/ > The CLI command I use is {{cordova run ios}} (also android) > It all works fine in Cordova 5.3.3, but starting with 5.4.0 the hook *thinks* > it wrote the file properly, and I can re-{{readFileSync}} to confirm this, > but the write does not appear to stick. When the build is over, the file has > reverted to its pre-hook state and the built app does not have the change. > I have tried wrapping my hook in: > {{module.exports = function(context) {}} > as the documentation suggests. I also moved the hook to scripts/ and tried > referencing it in config.xml, since the hooks/ directory is deprecated. None > of these seem to make any difference. It seems that anything in the www/ > directory has this issue, as well as platforms/android/AndroidManifest.xml. > If I write to a new file in the same directory, the file does not persist, > so it must be the whole directory that's being overwritten. If I raise an > exception in the hook, the build fails and the file remains properly > modified. So it's definitely something after this hook executes that undoes > it. > Interesting development: It's something to do with my plugins; it doesn't > happen in a small sample project. I use {{}} entries in config.xml to > define which plugins should be installed. When I delete these entries—without > actually removing any of the plugins!—this issue doesn't happen. -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org
[jira] [Commented] (CB-11044) files modified by after_prepare hook are reverted
[ https://issues.apache.org/jira/browse/CB-11044?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15232988#comment-15232988 ] Grant Patterson commented on CB-11044: -- Sure, thanks for looking into it. I can reproduce with an example app. This example app uses the iBeacon plugin: https://github.com/mikaelkindborg/evo-demos/tree/master/Demos2015/cordova-ibeacon Running {{cordova plugin add https://github.com/petermetz/cordova-plugin-ibeacon#3.3.0}} as stated in the README works fine; the plugin is added and builds into the app as expected, and a simple hook to hack index.html (pasted below) works fine. BUT when I add this line to config.xml: {{https://github.com/petermetz/cordova-plugin-ibeacon; />}} the hook fails. Let me know if I can help you reproduce. I will be looking into the specifics of what the plugin does... Here's the hook I'm using in hooks/after_prepare/: #!/usr/bin/env node // this plugin replaces arbitrary text in arbitrary files // right now it replaces all instances of "script" in index.html with "SCRIPTY", // breaking everything. ;-) var fs = require('fs'); var path = require('path'); var rootdir = process.argv[2]; console.log("rootdir", rootdir, process.argv); function replace_string_in_file(filename, to_replace, replace_with) { var data = fs.readFileSync(filename, 'utf8'); var result = data.replace(new RegExp(to_replace, "g"), replace_with); console.log(">RESULT\n", result, "\n>\n"); fs.writeFileSync(filename, result, 'utf8'); } if (rootdir) { var filestoreplace = [ // android "platforms/android/assets/www/index.html", // ios "platforms/ios/www/index.html", ]; filestoreplace.forEach(function(val, index, array) { var fullfilename = path.join(rootdir, val); if (fs.existsSync(fullfilename)) { console.log("patching: "+fullfilename); // CONFIGURE HERE replace_string_in_file(fullfilename, "script", 'SCRIPTY'); } else { console.log("missing: "+fullfilename); } }); } > files modified by after_prepare hook are reverted > - > > Key: CB-11044 > URL: https://issues.apache.org/jira/browse/CB-11044 > Project: Apache Cordova > Issue Type: Bug > Components: CordovaLib >Affects Versions: 5.4.0, 6.0.0, 5.4.1, 6.0.1, 6.1.0, 6.1.1 > Environment: OSX 10.11.4, also happens in Greenhouse CI tool >Reporter: Grant Patterson >Assignee: Vladimir Kotikov > Labels: Android, iOS > > I have a hook that uses the {{fs}} module functions {{readFileSync}} and > {{writeFileSync}} to modify files in the platforms/ directory. I'm using a > hook only barely modified from {{020_replace_text.js}} in these examples, to > which the most recent Cordova documentation links: > http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/ > The CLI command I use is {{cordova run ios}} (also android) > It all works fine in Cordova 5.3.3, but starting with 5.4.0 the hook *thinks* > it wrote the file properly, and I can re-{{readFileSync}} to confirm this, > but the write does not appear to stick. When the build is over, the file has > reverted to its pre-hook state and the built app does not have the change. > I have tried wrapping my hook in: > {{module.exports = function(context) {}} > as the documentation suggests. I also moved the hook to scripts/ and tried > referencing it in config.xml, since the hooks/ directory is deprecated. None > of these seem to make any difference. It seems that anything in the www/ > directory has this issue, as well as platforms/android/AndroidManifest.xml. > If I write to a new file in the same directory, the file does not persist, > so it must be the whole directory that's being overwritten. If I raise an > exception in the hook, the build fails and the file remains properly > modified. So it's definitely something after this hook executes that undoes > it. > Interesting development: It's something to do with my plugins; it doesn't > happen in a small sample project. I use {{}} entries in config.xml to > define which plugins should be installed. When I delete these entries—without > actually removing any of the plugins!—this issue doesn't happen. -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org
[jira] [Commented] (CB-11044) files modified by after_prepare hook are reverted
[ https://issues.apache.org/jira/browse/CB-11044?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15231745#comment-15231745 ] Vladimir Kotikov commented on CB-11044: --- [~nikhilkh], this sound like something realated to restore functionality (this is something that was introduced in [5.4.0|https://github.com/apache/cordova-lib/blob/f977a71539f21bd7d64ded095e756165febf5388/cordova-lib/RELEASENOTES.md]) It also might be somehow related to CB-11022 (messy prepare/restore logic). I'll try to reproduce and investigate this. > files modified by after_prepare hook are reverted > - > > Key: CB-11044 > URL: https://issues.apache.org/jira/browse/CB-11044 > Project: Apache Cordova > Issue Type: Bug > Components: Android, iOS >Affects Versions: 5.4.0, 6.0.0, 5.4.1, 6.0.1, 6.1.0, 6.1.1 > Environment: OSX 10.11.4, also happens in Greenhouse CI tool >Reporter: Grant Patterson >Assignee: Vladimir Kotikov > > I have a hook that uses the {{fs}} module functions {{readFileSync}} and > {{writeFileSync}} to modify files in the platforms/ directory. I'm using a > hook only barely modified from {{020_replace_text.js}} in these examples, to > which the most recent Cordova documentation links: > http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/ > The CLI command I use is {{cordova run ios}} (also android) > It all works fine in Cordova 5.3.3, but starting with 5.4.0 the hook *thinks* > it wrote the file properly, and I can re-{{readFileSync}} to confirm this, > but the write does not appear to stick. When the build is over, the file has > reverted to its pre-hook state and the built app does not have the change. > I have tried wrapping my hook in: > {{module.exports = function(context) {}} > as the documentation suggests. I also moved the hook to scripts/ and tried > referencing it in config.xml, since the hooks/ directory is deprecated. None > of these seem to make any difference. It seems that anything in the www/ > directory has this issue, as well as platforms/android/AndroidManifest.xml. > If I write to a new file in the same directory, the file does not persist, > so it must be the whole directory that's being overwritten. If I raise an > exception in the hook, the build fails and the file remains properly > modified. So it's definitely something after this hook executes that undoes > it. > Interesting development: It's something to do with my plugins; it doesn't > happen in a small sample project. I use {{}} entries in config.xml to > define which plugins should be installed. When I delete these entries—without > actually removing any of the plugins!—this issue doesn't happen. -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org
[jira] [Commented] (CB-11044) files modified by after_prepare hook are reverted
[ https://issues.apache.org/jira/browse/CB-11044?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15231569#comment-15231569 ] Nikhil Khandelwal commented on CB-11044: [~vladimir.kotikov] is this related to any of the changes? > files modified by after_prepare hook are reverted > - > > Key: CB-11044 > URL: https://issues.apache.org/jira/browse/CB-11044 > Project: Apache Cordova > Issue Type: Bug > Components: Android, iOS >Affects Versions: 5.4.0, 6.0.0, 5.4.1, 6.0.1, 6.1.0, 6.1.1 > Environment: OSX 10.11.4, also happens in Greenhouse CI tool >Reporter: Grant Patterson > > I have a hook that uses the {{fs}} module functions {{readFileSync}} and > {{writeFileSync}} to modify files in the platforms/ directory. I'm using a > hook only barely modified from {{020_replace_text.js}} in these examples, to > which the most recent Cordova documentation links: > http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/ > The CLI command I use is {{cordova run ios}} (also android) > It all works fine in Cordova 5.3.3, but starting with 5.4.0 the hook *thinks* > it wrote the file properly, and I can re-{{readFileSync}} to confirm this, > but the write does not appear to stick. When the build is over, the file has > reverted to its pre-hook state and the built app does not have the change. > I have tried wrapping my hook in: > {{module.exports = function(context) {}} > as the documentation suggests. I also moved the hook to scripts/ and tried > referencing it in config.xml, since the hooks/ directory is deprecated. None > of these seem to make any difference. It seems that anything in the www/ > directory has this issue, as well as platforms/android/AndroidManifest.xml. > If I write to a new file in the same directory, the file does not persist, > so it must be the whole directory that's being overwritten. If I raise an > exception in the hook, the build fails and the file remains properly > modified. So it's definitely something after this hook executes that undoes > it. > Interesting development: It's something to do with my plugins; it doesn't > happen in a small sample project. I use {{}} entries in config.xml to > define which plugins should be installed. When I delete these entries—without > actually removing any of the plugins!—this issue doesn't happen. -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org