Skip to content

Commit

Permalink
Merge pull request #11 from lynrin/develop
Browse files Browse the repository at this point in the history
Version 2.0.0
  • Loading branch information
lynrin authored Sep 11, 2017
2 parents 1a3c1eb + 2f9264c commit 8dadc3e
Show file tree
Hide file tree
Showing 15 changed files with 566 additions and 43 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.DS_Store
ignore/

node_modules
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.npmignore
.travis.yml
.DS_Store
ignore/
node_modules
95 changes: 94 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ function onDeviceReady() {
console.log('BuildInfo.debug =' + BuildInfo.debug);
console.log('BuildInfo.buildType =' + BuildInfo.buildType);
console.log('BuildInfo.flavor =' + BuildInfo.flavor);
console.log('BuildInfo.buildDate =' + BuildInfo.buildDate);
console.log('BuildInfo.installDate =' + BuildInfo.installDate);
}
```

Expand All @@ -34,6 +36,7 @@ cordova plugin add cordova-plugin-buildinfo

* Android
* iOS
* Windows

## Properties

Expand All @@ -46,6 +49,12 @@ cordova plugin add cordova-plugin-buildinfo
- `BuildInfo.debug`
- `BuildInfo.buildType`
- `BuildInfo.flavor`
- `BuildInfo.buildDate`
- `BuildInfo.installDate`
- `BuildInfo.windows`
- `logo`
- `version`


### BuildInfo.packageName

Expand All @@ -55,6 +64,7 @@ Get the packageName of Application ID.
|--------|-----|----|
|Android|Package Name|String|
|iOS|Bundle Identifier|String|
|Windows|Identity name|String|


### BuildInfo.basePackageName
Expand All @@ -71,6 +81,7 @@ If you use the configure of "build types" or "product flavors", because you can
|--------|-----|----|
|Android|Package name of BuildConfig class|String|
|iOS|Bundle Identifier(equals BuildInfo.packageName)|String|
|Windows|Identity name(equals BuildInfo.packageName)|String|


### BuildInfo.displayName
Expand All @@ -81,6 +92,7 @@ Get the displayName.
|--------|-----|----|
|Android|Application Label|String|
|iOS|CFBundleDisplayName|String|
|Windows|Get DisplayName attribute of VisualElements element in AppxManifest.xml file.|String|

### BuildInfo.name

Expand All @@ -90,6 +102,7 @@ Get the name.
|--------|-----|----|
|Android|Application Label(equal BuildInfo.displayName)|String|
|iOS|CFBundleName|String|
|Windows|Windows Store display name|String|


### BuildInfo.version
Expand All @@ -100,6 +113,7 @@ Get the version.
|--------|-----|----|
|Android|BuildConfig.VERSION_NAME|String|
|iOS|CFBundleShortVersionString|String|
|Windows|Major.Minor.Build ex) "1.2.3"|String|


### BuildInfo.versionCode
Expand All @@ -110,6 +124,7 @@ Get the version code.
|--------|-----|----|
|Android|BuildConfig.VERSION_CODE|int|
|iOS|CFBundleVersion|string|
|Windows|Major.Minor.Build.Revision ex) "1.2.3.4"|String|


### BuildInfo.debug
Expand All @@ -120,18 +135,20 @@ Get the debug flag.
|--------|-----|----|
|Android|BuildConfig.DEBUG|Boolean
|iOS|defined "DEBUG" is true|Boolean|
|Windows|isDevelopmentMode is true|Boolean|


### BuildInfo.buildType

Android Only.
Android , Windows Only.

Get the build type.

|Platform|Value|Type|
|--------|-----|----|
|Android|BuildConfig.BUILD_TYPE|String|
|iOS|empty string|String|
|Windows|"release" or "debug"|String|


### BuildInfo.flavor
Expand All @@ -144,3 +161,79 @@ Get the flavor.
|--------|-----|----|
|Android|BuildConfig.FLAVOR|String|
|iOS|empty string|String|
|Windows|empty string|String|

### BuildInfo.buildDate

Get the build date and time in the Date object returns.

Attention:
- Android: Add the BuildInfo.gradle file to your Android project.
The BuildInfo.gradle file contains the setting to add the _BUILDINFO_TIMESTAMP field to the BuildConfig class.
- Windows: Add the buildinfo.resjson file to your Windows project.
The buildinfo.resjson file into the "strings" folder.
And also add a task to rewrite buildinfo.resjson in the CordovaApp.projitems file.

|Platform|Value|Type|
|--------|-----|----|
|Android|BuildConfig.\_BUILDINFO\_TIMESTAMP value|Date|
|iOS|Get the creation date and time of the document directory.|Date|
|Windows|Resource value of "/buildinfo/Timestamp" string.|Date|


### BuildInfo.installDate

Get the install date and time in the Date object returns.

|Platform|Value|Type|
|--------|-----|----|
|Android|The firstInstallTime property of PackageInfo|Date|
|iOS|Get the modification date and time of the Info.plist file acquired from the executionPath property of the main bundle.|Date|
|Windows|The installedDate property of Windows.ApplicatinoModel.Package.current|Date|


### BuildInfo.windows

Windows Only.

Get the windows extra information.

|Platform|Value|Type|
|--------|-----|----|
|Android|undefined|undefined|
|iOS|undefined|undefined|
|Windows|Object|Object|

|Property name|Value|Type|
|-------------|-----|----|
|architecture|Windows.ApplicationModel.Package.current.id.architecture|integer|
|description|Windows.ApplicationModel.Package.current.description|String|
|displayName|Windows.ApplicationModel.Package.current.displayName|String|
|familyName|Windows.ApplicationModel.Package.current.id.familyName|String|
|fullName|Windows.ApplicationModel.Package.current.id.fullName|String|
|logo|Object|Object|
|publisher|Windows.ApplicationModel.Package.current.id.publisher|String|
|publisherId|Windows.ApplicationModel.Package.current.id.publisherId|String|
|publisherDisplayName|Windows.ApplicationModel.Package.current.publisherDisplayName|String|
|resourceId|Windows.ApplicationModel.Package.current.id.resourceId|String|
|version|Windows.ApplicationModel.Package.current.id.version|Object|

#### BuildInfo.windows.logo

|Property name|Value|Type|
|-------------|-----|----|
|absoluteCannonicalUri|Windows.ApplicationModel.Package.logo.absoluteCanonicalUri|String|
|absoluteUri|Windows.ApplicationModel.Package.logo.absoluteUri|String|
|displayIri|Windows.ApplicationModel.Package.logo.displayIri|String|
|displayUri|Windows.ApplicationModel.Package.logo.displayUri|String|
|path|Windows.ApplicationModel.Package.logo.path|String|
|rawUri|Windows.ApplicationModel.Package.logo.rawUri|String|

#### BuildInfo.windows.version

|Property name|Value|Type|
|-------------|-----|----|
|major|Windows.ApplicationModel.Package.current.id.version.major|integer|
|minor|Windows.ApplicationModel.Package.current.id.version.minor|integer|
|build|Windows.ApplicationModel.Package.current.id.version.build|integer|
|revision|Windows.ApplicationModel.Package.current.id.version.revision|integer|
28 changes: 20 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "cordova-plugin-buildinfo",
"version": "1.1.0",
"version": "2.0.0",
"description": "Cordova/Phonegap Build Information Plugin. Get PackageName, Version, Debug and more...",
"cordova": {
"id": "cordova-plugin-buildinfo",
"platforms": [
"android",
"ios"
"ios",
"windows"
]
},
"repository": {
Expand All @@ -21,18 +22,29 @@
"cordova",
"ecosystem:cordova",
"cordova-android",
"cordova-ios"
"cordova-ios",
"cordova-windows"
],
"scripts": {
"test": "npm run jshint",
"jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests"
},
"engines": [
{
"name": "cordova",
"version": ">=4.0.0"
"engines": {
"cordovaDependencies": {
"0.0.0": {
"cordova": ">=4.0.0"
},
"2.0.0": {
"cordova": ">=5.4.0",
"cordova-ios": ">=4.0.0",
"cordova-android": ">=5.0.0",
"cordova-windows": ">=4.0.0"
},
"3.0.0": {
"cordova": ">100"
}
}
],
},
"author": "Mikihiro Hayashi",
"license": "MIT",
"bugs": {
Expand Down
79 changes: 47 additions & 32 deletions plugin.xml
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>
65 changes: 65 additions & 0 deletions scripts/after_install.js
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=\"&quot;Timestamp&quot;: &quot;$(BuildInfoTimestamp)&quot;\" />\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);
}
};
Loading

0 comments on commit 8dadc3e

Please sign in to comment.