-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from lynrin/develop
Version 2.0.0
- Loading branch information
Showing
15 changed files
with
566 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
.DS_Store | ||
ignore/ | ||
|
||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.npmignore | ||
.travis.yml | ||
.DS_Store | ||
ignore/ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,54 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<plugin | ||
xmlns="http://apache.org/cordova/ns/plugins/1.0" | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
id="cordova-plugin-buildinfo" | ||
version="1.1.0"> | ||
<name>BuildInfo</name> | ||
<description>Cordova/Phonegap Build Information Plugin. Get PackageName, Version, Debug and more...</description> | ||
<license>MIT</license> | ||
<keywords>debug,buildconfig,buildinfo,phonegap,cordova</keywords> | ||
<author>Mikihiro Hayashi</author> | ||
xmlns="http://apache.org/cordova/ns/plugins/1.0" | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
id="cordova-plugin-buildinfo" | ||
version="2.0.0"> | ||
<name>BuildInfo</name> | ||
<description>Cordova/Phonegap Build Information Plugin. Get PackageName, Version, Debug and more...</description> | ||
<license>MIT</license> | ||
<keywords>debug,buildconfig,buildinfo,phonegap,cordova</keywords> | ||
<author>Mikihiro Hayashi</author> | ||
<repo>https://github.com/lynrin/cordova-plugin-buildinfo</repo> | ||
|
||
<js-module src="www/buildinfo.js" name="BuildInfo"> | ||
<clobbers target="BuildInfo" /> | ||
</js-module> | ||
<hook type="after_plugin_install" src="scripts/after_install.js" /> | ||
<hook type="before_plugin_uninstall" src="scripts/before_uninstall.js" /> | ||
|
||
<engines> | ||
<engine name="cordova" version=">=4.0.0" /> | ||
</engines> | ||
<js-module src="www/buildinfo.js" name="BuildInfo"> | ||
<clobbers target="BuildInfo"/> | ||
</js-module> | ||
|
||
<platform name="android"> | ||
<config-file target="res/xml/config.xml" parent="/*"> | ||
<feature name="BuildInfo"> | ||
<param name="android-package" value="org.apache.cordova.buildinfo.BuildInfo" /> | ||
</feature> | ||
</config-file> | ||
<source-file src="src/android/BuildInfo.java" target-dir="src/org/apache/cordova/buildinfo" /> | ||
</platform> | ||
<engines> | ||
<engine name="cordova" version=">=5.4.0"/> | ||
<engine name="cordova-ios" version=">=4.0.0"/> | ||
<engine name="cordova-android" version=">=5.0.0"/> | ||
<engine name="cordova-windows" version=">=4.0.0"/> | ||
</engines> | ||
|
||
<platform name="ios"> | ||
<config-file target="config.xml" parent="/*"> | ||
<feature name="BuildInfo"> | ||
<param name="ios-package" value="CDVBuildInfo"/> | ||
</feature> | ||
</config-file> | ||
<header-file src="src/ios/CDVBuildInfo.h" /> | ||
<source-file src="src/ios/CDVBuildInfo.m" /> | ||
</platform> | ||
<platform name="android"> | ||
<config-file target="res/xml/config.xml" parent="/*"> | ||
<feature name="BuildInfo"> | ||
<param name="android-package" value="org.apache.cordova.buildinfo.BuildInfo"/> | ||
</feature> | ||
</config-file> | ||
<source-file src="src/android/BuildInfo.java" target-dir="src/org/apache/cordova/buildinfo"/> | ||
<framework src="src/android/BuildInfo.gradle" custom="true" type="gradleReference"/> | ||
</platform> | ||
|
||
<platform name="ios"> | ||
<config-file target="config.xml" parent="/*"> | ||
<feature name="BuildInfo"> | ||
<param name="ios-package" value="CDVBuildInfo"/> | ||
</feature> | ||
</config-file> | ||
<header-file src="src/ios/CDVBuildInfo.h"/> | ||
<source-file src="src/ios/CDVBuildInfo.m"/> | ||
</platform> | ||
|
||
<platform name="windows"> | ||
<js-module src="src/windows/BuildInfoProxy.js" name="BuildInfoProxy"> | ||
<merges target=""/> | ||
</js-module> | ||
<resource-file src="src/windows/buildinfo.resjson" target="strings/buildinfo.resjson" /> | ||
</platform> | ||
</plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
'use strict'; | ||
|
||
var path = require('path'), | ||
fs = require('fs'); | ||
|
||
function installWindows(windowsPath) { | ||
|
||
const targetPath = path.join(windowsPath, 'CordovaApp.projitems'); | ||
var projitems = fs.readFileSync(targetPath).toString(); | ||
var changed = false; | ||
|
||
// Replace <Content Include="strings\buildinfo.resjson"> to <PRIResource Include="strings\buildinfo.resjson"> | ||
if (projitems.match(/<ItemGroup>[\s]*?<Content +.*?Include="strings\/buildinfo.resjson".+/m)) { | ||
console.log('ItemGroup match'); | ||
|
||
const search = /<ItemGroup>[\s]*?<Content +.*?Include="strings\/buildinfo.resjson"[\s\S]*?<\/ItemGroup>/m; | ||
|
||
const replace | ||
= "<ItemGroup>\r\n" | ||
+ " <PRIResource Include=\"strings\/buildinfo.resjson\" />\r\n" | ||
+ " </ItemGroup>"; | ||
|
||
projitems = projitems.replace(search, replace); | ||
changed = true; | ||
} | ||
|
||
// Add <Target Name="BuildInfo_Timestamp" BeforeTargets=BeforeBuild"> | ||
if (!projitems.match(/<Target +.*?Name="BuildInfo_Timestamp".*?/)) { | ||
console.log('Target missmatch'); | ||
|
||
const search = /<\/Project>/; | ||
|
||
const replace | ||
= " <Target Name=\"BuildInfo_Timestamp\" BeforeTargets=\"BeforeBuild\">\r\n" | ||
+ " <PropertyGroup>\r\n" | ||
+ " <BuildInfoTimestamp>$([System.DateTime]::Now.ToString(\"yyyy-MM-dd\THH:mm:sszzz\"))</BuildInfoTimestamp>\r\n" | ||
+ " </PropertyGroup>\r\n" | ||
+ " <ItemGroup>\r\n" | ||
+ " <BuildInfoResJson Include=\"{\" />\r\n" | ||
+ " <BuildInfoResJson Include=\""Timestamp": "$(BuildInfoTimestamp)"\" />\r\n" | ||
+ " <BuildInfoResJson Include=\"}\" />\r\n" | ||
+ " </ItemGroup>\r\n" | ||
+ " <WriteLinesToFile File=\"strings\\buildinfo.resjson\" Lines=\"@(BuildInfoResJson)\" Overwrite=\"true\" Encoding=\"UTF-8\" />\r\n" | ||
+ " </Target>\r\n" | ||
+ "</Project>"; | ||
|
||
projitems = projitems.replace(search, replace); | ||
changed = true; | ||
} | ||
|
||
// if variable "changed" is true, write to file. | ||
if (changed) { | ||
fs.writeFileSync(targetPath, projitems); | ||
} | ||
} | ||
|
||
module.exports = function (context) { | ||
var projectRoot = context.opts.projectRoot; | ||
|
||
// Exists platform/windows | ||
var windowsPath = path.join(projectRoot, 'platforms','windows'); | ||
if (fs.existsSync(windowsPath) && context.opts.plugin.platform == 'windows') { | ||
installWindows(windowsPath); | ||
} | ||
}; |
Oops, something went wrong.