use sync 2.0-rc11

This commit is contained in:
Yavor Georgiev 2017-07-05 16:37:06 +02:00 committed by kristiandupont
parent 272c996a5f
commit b17dcddd17
5 changed files with 49 additions and 55 deletions

View File

@ -1,5 +1,5 @@
PACKAGE_NAME=realm-js
VERSION=1.8.3
REALM_CORE_VERSION=3.0.0-rc2
REALM_SYNC_VERSION=2.0.0-rc10
REALM_CORE_VERSION=3.0.0-rc3
REALM_SYNC_VERSION=2.0.0-rc11
REALM_OBJECT_SERVER_VERSION=2.0.0-alpha9

View File

@ -78,11 +78,12 @@
"check-environment": "node scripts/check-environment.js"
},
"dependencies": {
"extract-zip": "^1.6.0",
"command-line-args": "^4.0.6",
"decompress": "^4.2.0",
"ini": "^1.3.4",
"nan": "^2.3.3",
"node-fetch": "^1.6.3",
"node-pre-gyp": "^0.6.30",
"node-pre-gyp": "^0.6.36",
"request": "^2.78.0",
"sync-request": "^3.0.1",
"url-parse": "^1.1.7"

View File

@ -116,27 +116,13 @@
"<(module_root_dir)/vendor/realm-node/osx"
]
},
"conditions": [
["realm_download_binaries and OS=='win'", {
"actions": [
{
"action_name": "download-realm",
"inputs": [ "<(module_root_dir)/scripts/download-realm.js" ],
"outputs": [ "<(module_root_dir)/vendor/realm-node" ],
"action": [ "node", "<(module_root_dir)/scripts/download-realm.js", "node", "<(use_realm_debug)" ]
}
]
}],
["realm_download_binaries and OS!='win'", {
"actions": [
{
"action_name": "download-realm",
"inputs": [ ],
"outputs": [ "<(module_root_dir)/vendor/realm-node" ],
"action": [ "<(module_root_dir)/scripts/download-core.sh", "node", "<(realm_enable_sync)" ]
}
]
}]
"actions": [
{
"action_name": "download-realm",
"inputs": [ "<(module_root_dir)/scripts/download-realm.js" ],
"outputs": [ "<(module_root_dir)/vendor/realm-node" ],
"action": [ "node", "<(module_root_dir)/scripts/download-realm.js", "<(OS)", "--debug=<(use_realm_debug)", "--sync=<(realm_enable_sync)", "--arch=<(target_arch)" ]
}
]
}
]

View File

@ -22,46 +22,55 @@ const fs = require('fs');
const path = require('path');
const fetch = require('node-fetch');
const ini = require('ini').parse;
const unzip = require('extract-zip');
const decompress = require('decompress');
function download(url, destination) {
return fetch(url).then((response) => {
if (response.status !== 200) {
throw new Error(`Error downloading ${url} - received status ${response.status} ${response.statusText}`);
} else if (response.headers.get('content-type') !== 'application/zip') {
throw new Error(`Unexpected response content type - ${response.headers.get('content-type')}`);
} else {
return new Promise((resolve) => {
const file = fs.createWriteStream(destination);
response.body.pipe(file)
.on('finish', () => {
file.close(resolve);
});
});
}
});
}
function extract(archive, destination) {
return new Promise((resolve, reject) => {
unzip(archive, { dir: destination }, (error) => {
if (error) {
reject(error);
} else {
resolve();
}
return new Promise((resolve) => {
const file = fs.createWriteStream(destination);
response.body.pipe(file)
.on('finish', () => {
file.close(resolve);
});
});
});
}
const optionDefinitions = [
{ name: 'platform', type: String, defaultOption: true },
{ name: 'arch', type: String },
{ name: 'sync', type: Boolean },
{ name: 'debug', type: Boolean },
];
const options = require('command-line-args')(optionDefinitions);
console.log(options);
let product, archive, extractedFolder;
const dependencies = ini(fs.readFileSync(path.resolve(__dirname, '../dependencies.list'), 'utf8'));
const coreArchive = `realm-core-windows-${dependencies.REALM_CORE_VERSION}.zip`;
const coreUrl = `https://static.realm.io/downloads/core/${coreArchive}`;
if (!options.sync) {
throw new Error("Downloading core is not yet supported!");
} else {
product = 'sync';
switch (options.platform) {
case 'mac':
archive = `realm-sync-node-cocoa-${dependencies.REALM_SYNC_VERSION}.tar.gz`
extractedFolder = `realm-sync-node-cocoa-${dependencies.REALM_SYNC_VERSION}`
}
}
const url = `https://static.realm.io/downloads/${product}/${archive}`;
const vendorDir = path.resolve(__dirname, '../vendor');
const downloadedCoreArchive = path.resolve(vendorDir, coreArchive);
const downloadedArchive = path.resolve(vendorDir, archive);
const realmDir = path.resolve(vendorDir, 'realm-node');
if (!fs.existsSync(realmDir)) {
const downloadTask = fs.existsSync(downloadedCoreArchive) ? Promise.resolve() : download(coreUrl, downloadedCoreArchive);
downloadTask.then(() => extract(downloadedCoreArchive, realmDir));
const downloadTask = fs.existsSync(downloadedArchive) ? Promise.resolve() : download(url, downloadedArchive);
downloadTask.then(() => decompress(downloadedArchive, vendorDir))
.then(() => fs.renameSync(path.resolve(vendorDir, extractedFolder), realmDir));
}

View File

@ -43,16 +43,14 @@
"Debug": {
"msvs_settings": {
"VCCLCompilerTool": {
"RuntimeTypeInfo": "true",
"AdditionalOptions": [ "/MDd" ]
"RuntimeTypeInfo": "true"
},
}
},
"Release": {
"msvs_settings": {
"VCCLCompilerTool": {
"RuntimeTypeInfo": "true",
"AdditionalOptions": [ "/MD" ]
"RuntimeTypeInfo": "true"
},
}
}