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
6 changes: 4 additions & 2 deletions android/codepush.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ gradle.projectsEvaluated {

def jsBundleFile = file("$jsBundleDir/$bundleAssetName")

def resourcesMapTempFileName = "CodePushResourcesMap-" + java.util.UUID.randomUUID().toString().substring(0,8) + ".json"

// Make this task run right before the bundle task
def recordFilesBeforeBundleCommand = tasks.create(
name: "recordFilesBeforeBundleCommand${targetName}",
type: Exec) {
commandLine "node", "${nodeModulesPath}/react-native-code-push/scripts/recordFilesBeforeBundleCommand.js", resourcesDir
commandLine "node", "${nodeModulesPath}/react-native-code-push/scripts/recordFilesBeforeBundleCommand.js", resourcesDir, resourcesMapTempFileName
}

recordFilesBeforeBundleCommand.dependsOn("merge${targetName}Resources")
Expand All @@ -67,7 +69,7 @@ gradle.projectsEvaluated {
def generateBundledResourcesHash = tasks.create(
name: "generateBundledResourcesHash${targetName}",
type: Exec) {
commandLine "node", "${nodeModulesPath}/react-native-code-push/scripts/generateBundledResourcesHash.js", resourcesDir, "$jsBundleDir/$bundleAssetName", jsBundleDir
commandLine "node", "${nodeModulesPath}/react-native-code-push/scripts/generateBundledResourcesHash.js", resourcesDir, "$jsBundleDir/$bundleAssetName", jsBundleDir, resourcesMapTempFileName
}

generateBundledResourcesHash.dependsOn("bundle${targetName}JsAndAssets")
Expand Down
8 changes: 5 additions & 3 deletions scripts/generateBundledResourcesHash.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ var CODE_PUSH_FOLDER_PREFIX = "CodePush";
var CODE_PUSH_HASH_FILE_NAME = "CodePushHash";
var CODE_PUSH_HASH_OLD_FILE_NAME = "CodePushHash.json";
var HASH_ALGORITHM = "sha256";
var TEMP_FILE_PATH = path.join(require("os").tmpdir(), "CodePushResourcesMap.json");

var resourcesDir = process.argv[2];
var jsBundleFilePath = process.argv[3];
var assetsDir = process.argv[4];
var tempFileName = process.argv[5];

var tempFileLocalPath = path.join(require("os").tmpdir(), tempFileName);
var resourceFiles = [];

getFilesInFolder(resourcesDir, resourceFiles);

var oldFileToModifiedTimeMap = require(TEMP_FILE_PATH);
var oldFileToModifiedTimeMap = require(tempFileLocalPath);
var newFileToModifiedTimeMap = {};

resourceFiles.forEach(function(resourceFile) {
Expand Down Expand Up @@ -114,4 +116,4 @@ function fileExists(file) {
catch (e) { return false; }
}

fs.unlinkSync(TEMP_FILE_PATH);
fs.unlinkSync(tempFileLocalPath);
6 changes: 4 additions & 2 deletions scripts/recordFilesBeforeBundleCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ var path = require("path");

var getFilesInFolder = require("./getFilesInFolder");

var TEMP_FILE_PATH = path.join(require("os").tmpdir(), "CodePushResourcesMap.json");

var resourcesDir = process.argv[2];
var tempFileName = process.argv[3];

var tempFileLocalPath = path.join(require("os").tmpdir(), tempFileName);
var resourceFiles = [];

try {
Expand All @@ -32,7 +34,7 @@ resourceFiles.forEach(function(resourceFile) {
fileToModifiedTimeMap[resourceFile.path.substring(resourcesDir.length)] = resourceFile.mtime.getTime();
});

fs.writeFile(TEMP_FILE_PATH, JSON.stringify(fileToModifiedTimeMap), function(err) {
fs.writeFile(tempFileLocalPath, JSON.stringify(fileToModifiedTimeMap), function(err) {
if (err) {
throw err;
}
Expand Down