Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Examples/CodePushDemoApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"react": "16.0.0-alpha.6",
"react-native": "^0.43.2",
"react-native-code-push": "file:../../",
"react-native-windows": "0.40.0-rc.1"
"react-native-windows": "^0.43.0-rc.0"
},
"devDependencies": {
"babel-jest": "19.0.0",
Expand Down
12 changes: 10 additions & 2 deletions Examples/CodePushDemoApp/windows/CodePushDemoApp.Wpf/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Reactive.Core" publicKeyToken="94bc3704cddfc263" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.3000.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.ChakraCore.1.4.1-preview-00010-42060\build\netstandard1.0\Microsoft.ChakraCore.props" Condition="Exists('..\packages\Microsoft.ChakraCore.1.4.1-preview-00010-42060\build\netstandard1.0\Microsoft.ChakraCore.props')" />
<Import Project="..\packages\Microsoft.ChakraCore.1.4.1\build\netstandard1.0\Microsoft.ChakraCore.props" Condition="Exists('..\packages\Microsoft.ChakraCore.1.4.1\build\netstandard1.0\Microsoft.ChakraCore.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -102,7 +102,7 @@
<ItemGroup>
<Reference Include="Facebook.Yoga, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Facebook.Yoga.1.0.1-pre\lib\netstandard\Facebook.Yoga.dll</HintPath>
<HintPath>..\packages\Facebook.Yoga.1.2.0-pre1\lib\net45\Facebook.Yoga.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down Expand Up @@ -170,10 +170,10 @@
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.ChakraCore.1.4.1-preview-00010-42060\build\netstandard1.0\Microsoft.ChakraCore.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ChakraCore.1.4.1-preview-00010-42060\build\netstandard1.0\Microsoft.ChakraCore.props'))" />
<Error Condition="!Exists('..\packages\Facebook.Yoga.1.0.1-pre\build\netstandard\Facebook.Yoga.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Facebook.Yoga.1.0.1-pre\build\netstandard\Facebook.Yoga.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.ChakraCore.1.4.1\build\netstandard1.0\Microsoft.ChakraCore.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.ChakraCore.1.4.1\build\netstandard1.0\Microsoft.ChakraCore.props'))" />
<Error Condition="!Exists('..\packages\Facebook.Yoga.1.2.0-pre1\build\net45\Facebook.Yoga.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Facebook.Yoga.1.2.0-pre1\build\net45\Facebook.Yoga.targets'))" />
</Target>
<Import Project="..\packages\Facebook.Yoga.1.0.1-pre\build\netstandard\Facebook.Yoga.targets" Condition="Exists('..\packages\Facebook.Yoga.1.0.1-pre\build\netstandard\Facebook.Yoga.targets')" />
<Import Project="..\packages\Facebook.Yoga.1.2.0-pre1\build\net45\Facebook.Yoga.targets" Condition="Exists('..\packages\Facebook.Yoga.1.2.0-pre1\build\net45\Facebook.Yoga.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Facebook.Yoga" version="1.0.1-pre" targetFramework="net46" />
<package id="Microsoft.ChakraCore" version="1.4.1-preview-00010-42060" targetFramework="net46" developmentDependency="true" />
<package id="Facebook.Yoga" version="1.2.0-pre1" targetFramework="net46" />
<package id="Microsoft.ChakraCore" version="1.4.1" targetFramework="net46" developmentDependency="true" />
</packages>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"Facebook.Yoga": "1.0.1-pre",
"Facebook.Yoga": "1.2.0-pre1",
"Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2"
},
"frameworks": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public DictionaryWithDefault(TValue defaultValue) : base()
}
}

public bool Remove(TKey key)
public new bool Remove(TKey key)
{
var found = base.Remove(key);
if (found)
Expand Down
61 changes: 61 additions & 0 deletions windows/CodePush.Net46/CodePushUtils.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,61 @@
using Newtonsoft.Json.Linq;
using PCLStorage;
using System;
using System.Diagnostics;
using System.IO;
using System.Management;
using System.Threading.Tasks;

namespace CodePush.ReactNative
{
internal partial class CodePushUtils
{
class ApplicationInfo
{
public ApplicationInfo()
{
var info = FileVersionInfo.GetVersionInfo(Environment.GetCommandLineArgs()[0]);
Version = $"{info.FileMajorPart}.{info.FileMinorPart}.{info.FileBuildPart}";
CompanyName = string.IsNullOrEmpty(info.CompanyName) ? info.ProductName : info.CompanyName;
ProductName = info.ProductName;
}

public string Version { private set; get; }
public string CompanyName { private set; get; }
public string ProductName { private set; get; }
}

static ApplicationInfo applicationInfo = new ApplicationInfo();
static string _bundlePath;

internal static string GetFileBundlePrefix()
{
// For Windows desktop application the prefix of a bundle is the full path to the folder where
// bundle should be installed.
//
// Desktop application can be installed at any location, the most popular are:
// - User local data folder, in this case the bundle can be stored in the same location and be
// unique for the user.
// - Program Files folder, in this case the application is unique for the system and will be shared
// amoung all users of the system, the bundle should be unique for the system as well.
// Commonly, user has no write access to Program Files folder or at least admin privileges have to been requested.
// In this case the bundle will be stored in ProgramData folder as it is recommended by MS.

if (!string.IsNullOrEmpty(_bundlePath))
{
return _bundlePath;
}

_bundlePath = GetAppFolder();

if (!HasWriteAccessToFolder(_bundlePath))
{
_bundlePath = $"{Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), applicationInfo.CompanyName, applicationInfo.ProductName, applicationInfo.Version)}\\";
}

return _bundlePath;
}

internal async static Task<JObject> GetJObjectFromFileAsync(IFile file)
{
string jsonString = await file.ReadAllTextAsync().ConfigureAwait(false);
Expand Down Expand Up @@ -93,5 +141,18 @@ static string GetMAC()

return mac;
}

static bool HasWriteAccessToFolder(string path)
{
try
{
File.Open(Path.Combine(path, ".security-check"), FileMode.OpenOrCreate).Close();
return true;
}
catch
{
return false;
}
}
}
}
2 changes: 1 addition & 1 deletion windows/CodePush.Net46/UpdateUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ internal async static Task DownloadBundleAsync(string url, string fileName, IPro

internal static async Task<IFolder> GetCodePushFolderAsync()
{
var pathToCodePush = Path.Combine(CodePushUtils.GetAppFolder(), CodePushConstants.CodePushFolderPrefix);
var pathToCodePush = Path.Combine(CodePushUtils.GetFileBundlePrefix(), CodePushConstants.CodePushFolderPrefix);
return await FileSystem.Current.LocalStorage.CreateFolderAsync(pathToCodePush, CreationCollisionOption.OpenIfExists).ConfigureAwait(false);
}
}
Expand Down
2 changes: 1 addition & 1 deletion windows/CodePush.Shared/CodePushConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal class CodePushConstants
internal const string UnzippedFolderName = "unzipped";
#if WINDOWS_UWP
internal const string AssetsBundlePrefix = "ms-appx:///ReactAssets/";
internal const string FileBundlePrefix = "ms-appdata:///local";
internal const string FileBundlePrefix = "ms-appdata:///local/";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abodalevsky, do I get it right if FileBundlePrefix const is used in GetJavaScriptBundleFileAsync method only, so there are no possible issues with this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be fine I have checked it before commit

#else
internal const string AssetsBundlePrefix = "ReactAssets/";
#endif
Expand Down
3 changes: 2 additions & 1 deletion windows/CodePush.Shared/CodePushReactPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public async Task<string> GetJavaScriptBundleFileAsync(string assetsBundleFileNa
{
CodePushUtils.LogBundleUrl(packageFile.Path);
IsRunningBinaryVersion = false;
return CodePushUtils.GetFileBundlePrefix() + packageFile.Path.Replace(CodePushUtils.GetAppFolder(), "").Replace("\\", "/");

return CodePushUtils.GetFileBundlePrefix() + CodePushUtils.ExtractSubFolder(packageFile.Path);
}
else
{
Expand Down
16 changes: 6 additions & 10 deletions windows/CodePush.Shared/CodePushUtils.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.IO;
#if WINDOWS_UWP
using Windows.ApplicationModel;
using Windows.Storage;
#else
using System.IO;
#endif

namespace CodePush.ReactNative
Expand Down Expand Up @@ -38,8 +38,7 @@ internal static string GetAppVersion()
#if WINDOWS_UWP
return Package.Current.Id.Version.Major + "." + Package.Current.Id.Version.Minor + "." + Package.Current.Id.Version.Build;
#else
var version = FileVersionInfo.GetVersionInfo(Environment.GetCommandLineArgs()[0]);
return $"{version.FileMajorPart}.{version.FileMinorPart}.{version.FileBuildPart}";
return applicationInfo.Version;
#endif
}

Expand All @@ -61,13 +60,10 @@ internal static string GetAssetsBundlePrefix()
#endif
}

internal static string GetFileBundlePrefix()
internal static string ExtractSubFolder(string fullPath)
{
#if WINDOWS_UWP
return CodePushConstants.FileBundlePrefix;
#else
return GetAppFolder();
#endif
var codePushSubPathArray = fullPath.Split(Path.DirectorySeparatorChar);
return String.Join("/", codePushSubPathArray.SkipWhile((value, index) => codePushSubPathArray.Length - index > 4).ToArray());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abodalevsky, could you please clarify what means number 4?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 means last 4 segments of the path where JS bundle is located. The idea of the change was to unify the calculation of js bundle file location for UWP and WPF. While they have different prefix but last 4 segments are the same for both implementations.
For example for
F:\react-native-code-push\Examples\CodePushDemoApp\windows\CodePushDemoApp.Wpf\bin\x64\DebugBundle\CodePush\cc1dd1ab\CodePush\index.windows.bundle
the part that will be added to specific prefix will be:
CodePush/cc1dd1ab/CodePush/index.windows.bundle

}

}
Expand Down
5 changes: 5 additions & 0 deletions windows/CodePush/CodePushUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ namespace CodePush.ReactNative
{
internal partial class CodePushUtils
{
internal static string GetFileBundlePrefix()
{
return CodePushConstants.FileBundlePrefix;
}

internal async static Task<JObject> GetJObjectFromFileAsync(StorageFile file)
{
string jsonString = await FileIO.ReadTextAsync(file).AsTask().ConfigureAwait(false);
Expand Down