mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
Compare commits
91 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
347f3c7dc2 | ||
|
|
c29251cb9d | ||
|
|
7f74a39346 | ||
|
|
a7c8e7241b | ||
|
|
6360acb87b | ||
|
|
acc04b9ca6 | ||
|
|
fcd7692182 | ||
|
|
ad0f44843d | ||
|
|
5a44e7c058 | ||
|
|
bee5a70fbf | ||
|
|
73c4fe626b | ||
|
|
befa1d9c79 | ||
|
|
40e37c68d5 | ||
|
|
0c37f633b8 | ||
|
|
1723c302f7 | ||
|
|
f41051fe60 | ||
|
|
396a49e349 | ||
|
|
482a1d2e2b | ||
|
|
ca6127c802 | ||
|
|
588f906fba | ||
|
|
14bdbbcc10 | ||
|
|
a0cec63c91 | ||
|
|
233fdeaef0 | ||
|
|
54b12ba15d | ||
|
|
cfa4fbc9c1 | ||
|
|
4b03f5b87e | ||
|
|
acf6518317 | ||
|
|
f7e07205b4 | ||
|
|
248c1e1118 | ||
|
|
cb251892c2 | ||
|
|
5fcf20a7aa | ||
|
|
2e38f9ca1c | ||
|
|
ece433f766 | ||
|
|
f6005ce28d | ||
|
|
93cea48d04 | ||
|
|
4fb6bef8ed | ||
|
|
f4fd62db47 | ||
|
|
2ede7d9ec9 | ||
|
|
7a67c36cdb | ||
|
|
1131b5ae2f | ||
|
|
9429eea12c | ||
|
|
a0b04005a9 | ||
|
|
a7d3cea6e8 | ||
|
|
f2fe287b34 | ||
|
|
47242064ba | ||
|
|
da73284515 | ||
|
|
9b74f25770 | ||
|
|
dcb5a34922 | ||
|
|
df55c1e717 | ||
|
|
a62f13856b | ||
|
|
c83ff61fdf | ||
|
|
2b83512c44 | ||
|
|
c12f7d3132 | ||
|
|
9c0a8ab168 | ||
|
|
8842b04567 | ||
|
|
0573919fd3 | ||
|
|
5253c0a816 | ||
|
|
05b412313d | ||
|
|
0428632a4e | ||
|
|
855d2c4b20 | ||
|
|
f0402be869 | ||
|
|
5a1e3fc0f3 | ||
|
|
01c31ee924 | ||
|
|
c29316b568 | ||
|
|
21f15fa87e | ||
|
|
ab95ecda42 | ||
|
|
456e83f286 | ||
|
|
1612ebc539 | ||
|
|
1ddb8a8bf1 | ||
|
|
bbcdbc2e7c | ||
|
|
d94bbd1573 | ||
|
|
583e14efcd | ||
|
|
b96803e3a0 | ||
|
|
c03cb11aaf | ||
|
|
5de881e668 | ||
|
|
964505398d | ||
|
|
16f2958ad7 | ||
|
|
332b92ebab | ||
|
|
b9f66a342c | ||
|
|
23ce796450 | ||
|
|
df6d316dc2 | ||
|
|
82a93ce645 | ||
|
|
5ceaca66f5 | ||
|
|
4c0e35776b | ||
|
|
cc1f213d84 | ||
|
|
4c18037e6a | ||
|
|
7f0ccdadcd | ||
|
|
8ac9499b45 | ||
|
|
8094d68acc | ||
|
|
80066c22b2 | ||
|
|
8f78f3b253 |
212
.circleci/config.yml
Normal file
212
.circleci/config.yml
Normal file
@@ -0,0 +1,212 @@
|
||||
|
||||
version: 2
|
||||
jobs:
|
||||
electron-linux-arm:
|
||||
docker:
|
||||
- image: electronbuilds/electron:0.0.4
|
||||
environment:
|
||||
TARGET_ARCH: arm
|
||||
resource_class: 2xlarge
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Check for release
|
||||
command: |
|
||||
if [ -n "${RUN_RELEASE_BUILD}" ]; then
|
||||
echo 'release build triggered from api'
|
||||
echo 'export ELECTRON_RELEASE=1 TRIGGERED_BY_API=1' >> $BASH_ENV
|
||||
fi
|
||||
- run:
|
||||
name: Bootstrap
|
||||
command: |
|
||||
if [ "$ELECTRON_RELEASE" == "1" ]; then
|
||||
echo 'Bootstrapping Electron for release build'
|
||||
script/bootstrap.py --target_arch=$TARGET_ARCH
|
||||
else
|
||||
echo 'Bootstrapping Electron for debug build'
|
||||
script/bootstrap.py --target_arch=$TARGET_ARCH --dev
|
||||
fi
|
||||
- run: npm run lint
|
||||
- run:
|
||||
name: Build
|
||||
command: |
|
||||
if [ "$ELECTRON_RELEASE" == "1" ]; then
|
||||
echo 'Building Electron for release'
|
||||
script/build.py -c R
|
||||
else
|
||||
echo 'Building Electron for debug'
|
||||
script/build.py -c D
|
||||
fi
|
||||
- run:
|
||||
name: Create distribution
|
||||
command: |
|
||||
if [ "$ELECTRON_RELEASE" == "1" ]; then
|
||||
echo 'Creating Electron release distribution'
|
||||
script/create-dist.py
|
||||
else
|
||||
echo 'Skipping create distribution because build is not for release'
|
||||
fi
|
||||
- run:
|
||||
name: Upload distribution
|
||||
command: |
|
||||
if [ "$ELECTRON_RELEASE" == "1" ] && [ "$TRIGGERED_BY_API" != "1" ]; then
|
||||
echo 'Uploading Electron release distribution to github releases'
|
||||
script/upload.py
|
||||
elif [ "$ELECTRON_RELEASE" == "1" ] && [ "$TRIGGERED_BY_API" == "1" ]; then
|
||||
echo 'Uploading Electron release distribution to s3'
|
||||
script/upload.py --upload_to_s3
|
||||
else
|
||||
echo 'Skipping upload distribution because build is not for release'
|
||||
fi
|
||||
electron-linux-ia32:
|
||||
docker:
|
||||
- image: electronbuilds/electron:0.0.4
|
||||
environment:
|
||||
TARGET_ARCH: ia32
|
||||
resource_class: xlarge
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Check for release
|
||||
command: |
|
||||
if [ -n "${RUN_RELEASE_BUILD}" ]; then
|
||||
echo 'release build triggered from api'
|
||||
echo 'export ELECTRON_RELEASE=1 TRIGGERED_BY_API=1' >> $BASH_ENV
|
||||
fi
|
||||
- run:
|
||||
name: Bootstrap
|
||||
command: |
|
||||
if [ "$ELECTRON_RELEASE" == "1" ]; then
|
||||
echo 'Bootstrapping Electron for release build'
|
||||
script/bootstrap.py --target_arch=$TARGET_ARCH
|
||||
else
|
||||
echo 'Bootstrapping Electron for debug build'
|
||||
script/bootstrap.py --target_arch=$TARGET_ARCH --dev
|
||||
fi
|
||||
- run: npm run lint
|
||||
- run:
|
||||
name: Build
|
||||
command: |
|
||||
if [ "$ELECTRON_RELEASE" == "1" ]; then
|
||||
echo 'Building Electron for release'
|
||||
script/build.py -c R
|
||||
else
|
||||
echo 'Building Electron for debug'
|
||||
script/build.py -c D
|
||||
fi
|
||||
- run:
|
||||
name: Create distribution
|
||||
command: |
|
||||
if [ "$ELECTRON_RELEASE" == "1" ]; then
|
||||
echo 'Creating Electron release distribution'
|
||||
script/create-dist.py
|
||||
else
|
||||
echo 'Skipping create distribution because build is not for release'
|
||||
fi
|
||||
- run:
|
||||
name: Upload distribution
|
||||
command: |
|
||||
if [ "$ELECTRON_RELEASE" == "1" ] && [ "$TRIGGERED_BY_API" != "1" ]; then
|
||||
echo 'Uploading Electron release distribution to github releases'
|
||||
script/upload.py
|
||||
elif [ "$ELECTRON_RELEASE" == "1" ] && [ "$TRIGGERED_BY_API" == "1" ]; then
|
||||
echo 'Uploading Electron release distribution to s3'
|
||||
script/upload.py --upload_to_s3
|
||||
else
|
||||
echo 'Skipping upload distribution because build is not for release'
|
||||
fi
|
||||
electron-linux-x64:
|
||||
docker:
|
||||
- image: electronbuilds/electron:0.0.4
|
||||
environment:
|
||||
TARGET_ARCH: x64
|
||||
DISPLAY: ':99.0'
|
||||
resource_class: xlarge
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Setup for headless testing
|
||||
command: sh -e /etc/init.d/xvfb start
|
||||
- run:
|
||||
name: Check for release
|
||||
command: |
|
||||
if [ -n "${RUN_RELEASE_BUILD}" ]; then
|
||||
echo 'release build triggered from api'
|
||||
echo 'export ELECTRON_RELEASE=1 TRIGGERED_BY_API=1' >> $BASH_ENV
|
||||
fi
|
||||
- run:
|
||||
name: Bootstrap
|
||||
command: |
|
||||
if [ "$ELECTRON_RELEASE" == "1" ]; then
|
||||
echo 'Bootstrapping Electron for release build'
|
||||
script/bootstrap.py --target_arch=$TARGET_ARCH
|
||||
else
|
||||
echo 'Bootstrapping Electron for debug build'
|
||||
script/bootstrap.py --target_arch=$TARGET_ARCH --dev
|
||||
fi
|
||||
- run: npm run lint
|
||||
- run:
|
||||
name: Build
|
||||
command: |
|
||||
if [ "$ELECTRON_RELEASE" == "1" ]; then
|
||||
echo 'Building Electron for release'
|
||||
script/build.py -c R
|
||||
else
|
||||
echo 'Building Electron for debug'
|
||||
script/build.py -c D
|
||||
fi
|
||||
- run:
|
||||
name: Create distribution
|
||||
command: |
|
||||
if [ "$ELECTRON_RELEASE" == "1" ]; then
|
||||
echo 'Creating Electron release distribution'
|
||||
script/create-dist.py
|
||||
else
|
||||
echo 'Skipping create distribution because build is not for release'
|
||||
fi
|
||||
- run:
|
||||
name: Upload distribution
|
||||
command: |
|
||||
if [ "$ELECTRON_RELEASE" == "1" ] && [ "$TRIGGERED_BY_API" != "1" ]; then
|
||||
echo 'Uploading Electron release distribution to github releases'
|
||||
script/upload.py
|
||||
elif [ "$ELECTRON_RELEASE" == "1" ] && [ "$TRIGGERED_BY_API" == "1" ]; then
|
||||
echo 'Uploading Electron release distribution to s3'
|
||||
script/upload.py --upload_to_s3
|
||||
else
|
||||
echo 'Skipping upload distribution because build is not for release'
|
||||
fi
|
||||
- run:
|
||||
name: Test
|
||||
environment:
|
||||
MOCHA_FILE: junit/test-results.xml
|
||||
MOCHA_REPORTER: mocha-junit-reporter
|
||||
command: |
|
||||
if [ "$ELECTRON_RELEASE" != "1" ]; then
|
||||
echo 'Testing Electron debug build'
|
||||
mkdir junit
|
||||
script/test.py --ci --rebuild_native_modules
|
||||
else
|
||||
echo 'Skipping testing on release build'
|
||||
fi
|
||||
- run:
|
||||
name: Verify FFmpeg
|
||||
command: |
|
||||
if [ "$ELECTRON_RELEASE" != "1" ]; then
|
||||
echo 'Verifying ffmpeg on debug build'
|
||||
script/verify-ffmpeg.py
|
||||
else
|
||||
echo 'Skipping verify ffmpeg on release build'
|
||||
fi
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
build-arm:
|
||||
jobs:
|
||||
- electron-linux-arm
|
||||
build-ia32:
|
||||
jobs:
|
||||
- electron-linux-ia32
|
||||
build-x64:
|
||||
jobs:
|
||||
- electron-linux-x64
|
||||
@@ -10,7 +10,7 @@
|
||||
#if defined(OS_MACOSX)
|
||||
extern "C" {
|
||||
__attribute__((visibility("default")))
|
||||
int AtomMain(int argc, const char* argv[]);
|
||||
int AtomMain(int argc, char* argv[]);
|
||||
|
||||
__attribute__((visibility("default")))
|
||||
int AtomInitializeICUandStartNode(int argc, char *argv[]);
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
#include "content/public/app/content_main.h"
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
int AtomMain(int argc, const char* argv[]) {
|
||||
int AtomMain(int argc, char* argv[]) {
|
||||
atom::AtomMainDelegate delegate;
|
||||
content::ContentMainParams params(&delegate);
|
||||
params.argc = argc;
|
||||
params.argv = argv;
|
||||
params.argv = const_cast<const char**>(argv);
|
||||
atom::AtomCommandLine::Init(argc, argv);
|
||||
return content::ContentMain(params);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
#include "atom/app/atom_main.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
#include <vector>
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include <windows.h> // windows.h must be included first
|
||||
@@ -14,9 +15,11 @@
|
||||
#include <tchar.h>
|
||||
|
||||
#include "atom/app/atom_main_delegate.h"
|
||||
#include "atom/app/command_line_args.h"
|
||||
#include "atom/common/crash_reporter/win/crash_service_main.h"
|
||||
#include "base/environment.h"
|
||||
#include "base/process/launch.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/win/windows_version.h"
|
||||
#include "content/public/app/sandbox_helper_win.h"
|
||||
#include "sandbox/win/src/sandbox_types.h"
|
||||
@@ -51,8 +54,39 @@ bool IsEnvSet(const char* name) {
|
||||
|
||||
#if defined(OS_WIN)
|
||||
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||
int argc = 0;
|
||||
wchar_t** wargv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
|
||||
struct Arguments {
|
||||
int argc = 0;
|
||||
wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc);
|
||||
|
||||
~Arguments() { LocalFree(argv); }
|
||||
} arguments;
|
||||
|
||||
if (!arguments.argv)
|
||||
return -1;
|
||||
|
||||
#ifdef _DEBUG
|
||||
// Don't display assert dialog boxes in CI test runs
|
||||
static const auto kCI = "ELECTRON_CI";
|
||||
bool is_ci = IsEnvSet(kCI);
|
||||
if (!is_ci) {
|
||||
for (int i = 0; i < arguments.argc; ++i) {
|
||||
if (!_wcsicmp(arguments.argv[i], L"--ci")) {
|
||||
is_ci = true;
|
||||
_putenv_s(kCI, "1"); // set flag for child processes
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_ci) {
|
||||
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
|
||||
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
|
||||
|
||||
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
|
||||
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
|
||||
|
||||
_set_error_mode(_OUT_TO_STDERR);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool run_as_node = IsEnvSet(kRunAsNode);
|
||||
|
||||
@@ -60,49 +94,24 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||
if (run_as_node || !IsEnvSet("ELECTRON_NO_ATTACH_CONSOLE"))
|
||||
base::RouteStdioToConsole(false);
|
||||
|
||||
// Convert argv to to UTF8
|
||||
char** argv = new char*[argc];
|
||||
for (int i = 0; i < argc; i++) {
|
||||
// Compute the size of the required buffer
|
||||
DWORD size = WideCharToMultiByte(CP_UTF8,
|
||||
0,
|
||||
wargv[i],
|
||||
-1,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
if (size == 0) {
|
||||
// This should never happen.
|
||||
fprintf(stderr, "Could not convert arguments to utf8.");
|
||||
exit(1);
|
||||
}
|
||||
// Do the actual conversion
|
||||
argv[i] = new char[size];
|
||||
DWORD result = WideCharToMultiByte(CP_UTF8,
|
||||
0,
|
||||
wargv[i],
|
||||
-1,
|
||||
argv[i],
|
||||
size,
|
||||
NULL,
|
||||
NULL);
|
||||
if (result == 0) {
|
||||
// This should never happen.
|
||||
fprintf(stderr, "Could not convert arguments to utf8.");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (run_as_node) {
|
||||
// Now that argv conversion is done, we can finally start.
|
||||
std::vector<char*> argv(arguments.argc);
|
||||
std::transform(
|
||||
arguments.argv, arguments.argv + arguments.argc, argv.begin(),
|
||||
[](auto& a) { return _strdup(base::WideToUTF8(a).c_str()); });
|
||||
|
||||
base::AtExitManager atexit_manager;
|
||||
base::i18n::InitializeICU();
|
||||
return atom::NodeMain(argc, argv);
|
||||
auto ret = atom::NodeMain(argv.size(), argv.data());
|
||||
std::for_each(argv.begin(), argv.end(), free);
|
||||
return ret;
|
||||
} else if (IsEnvSet("ELECTRON_INTERNAL_CRASH_SERVICE")) {
|
||||
return crash_service::Main(cmd);
|
||||
}
|
||||
|
||||
if (!atom::CheckCommandLineArguments(arguments.argc, arguments.argv))
|
||||
return -1;
|
||||
|
||||
sandbox::SandboxInterfaceInfo sandbox_info = {0};
|
||||
content::InitializeSandboxInfo(&sandbox_info);
|
||||
atom::AtomMainDelegate delegate;
|
||||
@@ -110,33 +119,32 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||
content::ContentMainParams params(&delegate);
|
||||
params.instance = instance;
|
||||
params.sandbox_info = &sandbox_info;
|
||||
atom::AtomCommandLine::Init(argc, argv);
|
||||
atom::AtomCommandLine::InitW(argc, wargv);
|
||||
atom::AtomCommandLine::Init(arguments.argc, arguments.argv);
|
||||
return content::ContentMain(params);
|
||||
}
|
||||
|
||||
#elif defined(OS_LINUX) // defined(OS_WIN)
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
int main(int argc, char* argv[]) {
|
||||
if (IsEnvSet(kRunAsNode)) {
|
||||
base::i18n::InitializeICU();
|
||||
base::AtExitManager atexit_manager;
|
||||
return atom::NodeMain(argc, const_cast<char**>(argv));
|
||||
return atom::NodeMain(argc, argv);
|
||||
}
|
||||
|
||||
atom::AtomMainDelegate delegate;
|
||||
content::ContentMainParams params(&delegate);
|
||||
params.argc = argc;
|
||||
params.argv = argv;
|
||||
params.argv = const_cast<const char**>(argv);
|
||||
atom::AtomCommandLine::Init(argc, argv);
|
||||
return content::ContentMain(params);
|
||||
}
|
||||
|
||||
#else // defined(OS_LINUX)
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
int main(int argc, char* argv[]) {
|
||||
if (IsEnvSet(kRunAsNode)) {
|
||||
return AtomInitializeICUandStartNode(argc, const_cast<char**>(argv));
|
||||
return AtomInitializeICUandStartNode(argc, argv);
|
||||
}
|
||||
|
||||
return AtomMain(argc, argv);
|
||||
|
||||
1412
atom/app/command_line_args.cc
Normal file
1412
atom/app/command_line_args.cc
Normal file
File diff suppressed because it is too large
Load Diff
17
atom/app/command_line_args.h
Normal file
17
atom/app/command_line_args.h
Normal file
@@ -0,0 +1,17 @@
|
||||
// Copyright (c) 2018 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_APP_COMMAND_LINE_ARGS_H_
|
||||
#define ATOM_APP_COMMAND_LINE_ARGS_H_
|
||||
|
||||
#include "base/command_line.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
bool CheckCommandLineArguments(int argc, base::CommandLine::CharType** argv);
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_APP_COMMAND_LINE_ARGS_H_
|
||||
|
||||
@@ -754,11 +754,7 @@ bool App::Relaunch(mate::Arguments* js_args) {
|
||||
}
|
||||
|
||||
if (!override_argv) {
|
||||
#if defined(OS_WIN)
|
||||
const relauncher::StringVector& argv = atom::AtomCommandLine::wargv();
|
||||
#else
|
||||
const relauncher::StringVector& argv = atom::AtomCommandLine::argv();
|
||||
#endif
|
||||
return relauncher::RelaunchApp(argv);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
@@ -37,6 +38,7 @@
|
||||
#include "content/public/browser/resource_dispatcher_host.h"
|
||||
#include "content/public/browser/site_instance.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/content_paths.h"
|
||||
#include "content/public/common/url_constants.h"
|
||||
#include "content/public/common/web_preferences.h"
|
||||
#include "net/ssl/ssl_cert_request_info.h"
|
||||
@@ -207,6 +209,11 @@ void AtomBrowserClient::OverrideSiteInstanceForNavigation(
|
||||
void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
||||
base::CommandLine* command_line,
|
||||
int process_id) {
|
||||
// Make sure we're about to launch a known executable
|
||||
base::FilePath child_path;
|
||||
PathService::Get(content::CHILD_PROCESS_EXE, &child_path);
|
||||
CHECK(base::MakeAbsoluteFilePath(command_line->GetProgram()) == child_path);
|
||||
|
||||
std::string process_type = command_line->GetSwitchValueASCII("type");
|
||||
if (process_type != "renderer")
|
||||
return;
|
||||
|
||||
@@ -4,13 +4,16 @@
|
||||
|
||||
#include "atom/browser/atom_resource_dispatcher_host_delegate.h"
|
||||
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/login_handler.h"
|
||||
#include "atom/browser/web_contents_permission_helper.h"
|
||||
#include "atom/browser/web_contents_preferences.h"
|
||||
#include "atom/common/atom_constants.h"
|
||||
#include "atom/common/platform_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/download_manager.h"
|
||||
#include "content/public/browser/stream_info.h"
|
||||
#include "net/base/escape.h"
|
||||
#include "net/ssl/client_cert_store.h"
|
||||
@@ -69,6 +72,17 @@ void OnPdfResourceIntercepted(
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
if (!WebContentsPreferences::IsPluginsEnabled(web_contents)) {
|
||||
auto browser_context = web_contents->GetBrowserContext();
|
||||
auto download_manager =
|
||||
content::BrowserContext::GetDownloadManager(browser_context);
|
||||
|
||||
download_manager->DownloadUrl(
|
||||
content::DownloadUrlParameters::CreateForWebContentsMainFrame(
|
||||
web_contents, original_url));
|
||||
return;
|
||||
}
|
||||
|
||||
// The URL passes the original pdf resource url, that will be requested
|
||||
// by the webui page.
|
||||
// chrome://pdf-viewer/index.html?src=https://somepage/123.pdf
|
||||
|
||||
@@ -140,11 +140,7 @@ bool RelaunchAppWithHelper(const base::FilePath& helper,
|
||||
}
|
||||
|
||||
int RelauncherMain(const content::MainFunctionParams& main_parameters) {
|
||||
#if defined(OS_WIN)
|
||||
const StringVector& argv = atom::AtomCommandLine::wargv();
|
||||
#else
|
||||
const StringVector& argv = atom::AtomCommandLine::argv();
|
||||
#endif
|
||||
|
||||
if (argv.size() < 4 || argv[1] != internal::kRelauncherTypeArg) {
|
||||
LOG(ERROR) << "relauncher process invoked with unexpected arguments";
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>electron.icns</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.6.9</string>
|
||||
<string>1.6.17</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.6.9</string>
|
||||
<string>1.6.17</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.developer-tools</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
|
||||
@@ -56,8 +56,8 @@ END
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,6,9,0
|
||||
PRODUCTVERSION 1,6,9,0
|
||||
FILEVERSION 1,6,17,0
|
||||
PRODUCTVERSION 1,6,17,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -74,12 +74,12 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "GitHub, Inc."
|
||||
VALUE "FileDescription", "Electron"
|
||||
VALUE "FileVersion", "1.6.9"
|
||||
VALUE "FileVersion", "1.6.17"
|
||||
VALUE "InternalName", "electron.exe"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved."
|
||||
VALUE "OriginalFilename", "electron.exe"
|
||||
VALUE "ProductName", "Electron"
|
||||
VALUE "ProductVersion", "1.6.9"
|
||||
VALUE "ProductVersion", "1.6.17"
|
||||
VALUE "SquirrelAwareVersion", "1"
|
||||
END
|
||||
END
|
||||
|
||||
@@ -163,6 +163,18 @@ void SetMenuItemID(DbusmenuMenuitem* item, int id) {
|
||||
g_object_set_data(G_OBJECT(item), "menu-id", GINT_TO_POINTER(id + 1));
|
||||
}
|
||||
|
||||
std::string GetMenuModelStatus(AtomMenuModel* model) {
|
||||
std::string ret;
|
||||
for (int i = 0; i < model->GetItemCount(); ++i) {
|
||||
int status = model->GetTypeAt(i) | (model->IsVisibleAt(i) << 3)
|
||||
| (model->IsEnabledAt(i) << 4)
|
||||
| (model->IsItemCheckedAt(i) << 5);
|
||||
ret += base::StringPrintf(
|
||||
"%s-%X\n", base::UTF16ToUTF8(model->GetLabelAt(i)).c_str(), status);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
GlobalMenuBarX11::GlobalMenuBarX11(NativeWindowViews* window)
|
||||
@@ -307,6 +319,16 @@ void GlobalMenuBarX11::OnSubMenuShow(DbusmenuMenuitem* item) {
|
||||
if (!model || !GetMenuItemID(item, &id))
|
||||
return;
|
||||
|
||||
// Do not update menu if the submenu has not been changed.
|
||||
std::string status = GetMenuModelStatus(model);
|
||||
char* old = static_cast<char*>(g_object_get_data(G_OBJECT(item), "status"));
|
||||
if (old && status == old)
|
||||
return;
|
||||
|
||||
// Save the new status.
|
||||
g_object_set_data_full(G_OBJECT(item), "status", g_strdup(status.c_str()),
|
||||
g_free);
|
||||
|
||||
// Clear children.
|
||||
GList *children = menuitem_take_children(item);
|
||||
g_list_foreach(children, reinterpret_cast<GFunc>(g_object_unref), NULL);
|
||||
|
||||
@@ -197,7 +197,9 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
|
||||
}
|
||||
}
|
||||
|
||||
bool WebContentsPreferences::IsSandboxed(content::WebContents* web_contents) {
|
||||
bool WebContentsPreferences::IsPreferenceEnabled(
|
||||
const std::string& attribute_name,
|
||||
content::WebContents* web_contents) {
|
||||
WebContentsPreferences* self;
|
||||
if (!web_contents)
|
||||
return false;
|
||||
@@ -207,9 +209,18 @@ bool WebContentsPreferences::IsSandboxed(content::WebContents* web_contents) {
|
||||
return false;
|
||||
|
||||
base::DictionaryValue& web_preferences = self->web_preferences_;
|
||||
bool sandboxed = false;
|
||||
web_preferences.GetBoolean("sandbox", &sandboxed);
|
||||
return sandboxed;
|
||||
bool bool_value = false;
|
||||
web_preferences.GetBoolean(attribute_name, &bool_value);
|
||||
return bool_value;
|
||||
}
|
||||
|
||||
bool WebContentsPreferences::IsSandboxed(content::WebContents* web_contents) {
|
||||
return IsPreferenceEnabled("sandbox", web_contents);
|
||||
}
|
||||
|
||||
bool WebContentsPreferences::IsPluginsEnabled(
|
||||
content::WebContents* web_contents) {
|
||||
return IsPreferenceEnabled("plugins", web_contents);
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -37,7 +37,10 @@ class WebContentsPreferences
|
||||
static void AppendExtraCommandLineSwitches(
|
||||
content::WebContents* web_contents, base::CommandLine* command_line);
|
||||
|
||||
static bool IsPreferenceEnabled(const std::string& attribute_name,
|
||||
content::WebContents* web_contents);
|
||||
static bool IsSandboxed(content::WebContents* web_contents);
|
||||
static bool IsPluginsEnabled(content::WebContents* web_contents);
|
||||
|
||||
// Modify the WebPreferences according to |web_contents|'s preferences.
|
||||
static void OverrideWebkitPrefs(
|
||||
|
||||
@@ -10,31 +10,22 @@
|
||||
namespace atom {
|
||||
|
||||
// static
|
||||
std::vector<std::string> AtomCommandLine::argv_;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// static
|
||||
std::vector<std::wstring> AtomCommandLine::wargv_;
|
||||
#endif
|
||||
base::CommandLine::StringVector AtomCommandLine::argv_;
|
||||
|
||||
// static
|
||||
void AtomCommandLine::Init(int argc, const char* const* argv) {
|
||||
void AtomCommandLine::Init(int argc, base::CommandLine::CharType** argv) {
|
||||
DCHECK(argv_.empty());
|
||||
|
||||
// NOTE: uv_setup_args does nothing on Windows, so we don't need to call it.
|
||||
// Otherwise we'd have to convert the arguments from UTF16.
|
||||
#if !defined(OS_WIN)
|
||||
// Hack around with the argv pointer. Used for process.title = "blah"
|
||||
char** new_argv = uv_setup_args(argc, const_cast<char**>(argv));
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
argv_.push_back(new_argv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// static
|
||||
void AtomCommandLine::InitW(int argc, const wchar_t* const* argv) {
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
wargv_.push_back(argv[i]);
|
||||
}
|
||||
}
|
||||
argv = uv_setup_args(argc, argv);
|
||||
#endif
|
||||
|
||||
argv_.assign(argv, argv + argc);
|
||||
}
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
// static
|
||||
void AtomCommandLine::InitializeFromCommandLine() {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/macros.h"
|
||||
#include "build/build_config.h"
|
||||
|
||||
@@ -16,13 +17,9 @@ namespace atom {
|
||||
// Singleton to remember the original "argc" and "argv".
|
||||
class AtomCommandLine {
|
||||
public:
|
||||
static void Init(int argc, const char* const* argv);
|
||||
static std::vector<std::string> argv() { return argv_; }
|
||||
static const base::CommandLine::StringVector& argv() { return argv_; }
|
||||
|
||||
#if defined(OS_WIN)
|
||||
static void InitW(int argc, const wchar_t* const* argv);
|
||||
static std::vector<std::wstring> wargv() { return wargv_; }
|
||||
#endif
|
||||
static void Init(int argc, base::CommandLine::CharType** argv);
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
// On Linux the command line has to be read from base::CommandLine since
|
||||
@@ -31,11 +28,7 @@ class AtomCommandLine {
|
||||
#endif
|
||||
|
||||
private:
|
||||
static std::vector<std::string> argv_;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
static std::vector<std::wstring> wargv_;
|
||||
#endif
|
||||
static base::CommandLine::StringVector argv_;
|
||||
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(AtomCommandLine);
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#define ATOM_MAJOR_VERSION 1
|
||||
#define ATOM_MINOR_VERSION 6
|
||||
#define ATOM_PATCH_VERSION 9
|
||||
#define ATOM_PATCH_VERSION 17
|
||||
|
||||
#define ATOM_VERSION_IS_RELEASE 1
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "atom/common/node_bindings.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -17,6 +18,7 @@
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "base/trace_event/trace_event.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
@@ -149,7 +151,14 @@ void NodeBindings::Initialize() {
|
||||
|
||||
node::Environment* NodeBindings::CreateEnvironment(
|
||||
v8::Handle<v8::Context> context) {
|
||||
#if defined(OS_WIN)
|
||||
auto& atom_args = AtomCommandLine::argv();
|
||||
std::vector<std::string> args(atom_args.size());
|
||||
std::transform(atom_args.cbegin(), atom_args.cend(), args.begin(),
|
||||
[](auto& a) { return base::WideToUTF8(a); });
|
||||
#else
|
||||
auto args = AtomCommandLine::argv();
|
||||
#endif
|
||||
|
||||
// Feed node the path to initialization script.
|
||||
base::FilePath::StringType process_type;
|
||||
@@ -169,8 +178,7 @@ node::Environment* NodeBindings::CreateEnvironment(
|
||||
resources_path.Append(FILE_PATH_LITERAL("electron.asar"))
|
||||
.Append(process_type)
|
||||
.Append(FILE_PATH_LITERAL("init.js"));
|
||||
std::string script_path_str = script_path.AsUTF8Unsafe();
|
||||
args.insert(args.begin() + 1, script_path_str.c_str());
|
||||
args.insert(args.begin() + 1, script_path.AsUTF8Unsafe());
|
||||
|
||||
std::unique_ptr<const char*[]> c_argv = StringVectorToArgArray(args);
|
||||
node::Environment* env = node::CreateEnvironment(
|
||||
|
||||
@@ -200,7 +200,10 @@ void WebFrame::RegisterURLSchemeAsPrivileged(const std::string& scheme,
|
||||
void WebFrame::InsertText(const std::string& text) {
|
||||
web_frame_->frameWidget()
|
||||
->getActiveWebInputMethodController()
|
||||
->commitText(blink::WebString::fromUTF8(text), 0);
|
||||
->commitText(blink::WebString::fromUTF8(text),
|
||||
blink::WebVector<blink::WebCompositionUnderline>(),
|
||||
blink::WebRange(),
|
||||
0);
|
||||
}
|
||||
|
||||
void WebFrame::InsertCSS(const std::string& css) {
|
||||
|
||||
@@ -135,7 +135,12 @@ void AtomRendererClient::WillReleaseScriptContext(
|
||||
node_bindings_->set_uv_env(nullptr);
|
||||
|
||||
// Destroy the node environment.
|
||||
node::FreeEnvironment(env);
|
||||
// This is disabled because pending async tasks may still use the environment
|
||||
// and would cause crashes later. Node does not seem to clear all async tasks
|
||||
// when the environment is destroyed.
|
||||
// node::FreeEnvironment(env);
|
||||
|
||||
// AtomBindings is tracking node environments.
|
||||
atom_bindings_->EnvironmentDestroyed(env);
|
||||
}
|
||||
|
||||
|
||||
@@ -667,6 +667,8 @@ app.setJumpList([
|
||||
* `argv` String[] - An array of the second instance's command line arguments
|
||||
* `workingDirectory` String - The second instance's working directory
|
||||
|
||||
Returns `Boolean`.
|
||||
|
||||
This method makes your application a Single Instance Application - instead of
|
||||
allowing multiple instances of your app to run, this will ensure that only a
|
||||
single instance of your app is running, and other instances signal this
|
||||
|
||||
@@ -44,31 +44,31 @@ Objects created with `new BrowserView` have the following properties:
|
||||
|
||||
#### `view.webContents` _Experimental_
|
||||
|
||||
A [`webContents`](web-contents.md) object owned by this view.
|
||||
A [`WebContents`](web-contents.md) object owned by this view.
|
||||
|
||||
#### `win.id` _Experimental_
|
||||
#### `view.id` _Experimental_
|
||||
|
||||
A `Integer` representing the unique ID of the view.
|
||||
|
||||
### Instance Methods
|
||||
|
||||
Objects created with `new BrowserWindow` have the following instance methods:
|
||||
Objects created with `new BrowserView` have the following instance methods:
|
||||
|
||||
#### `win.setAutoResize(options)` _Experimental_
|
||||
#### `view.setAutoResize(options)` _Experimental_
|
||||
|
||||
* `options` Object
|
||||
* `width`: If `true`, the view's width will grow and shrink together with
|
||||
the window. `false` by default.
|
||||
* `height`: If `true`, the view's height will grow and shrink together with
|
||||
the window. `false` by default.
|
||||
* `width` Boolean - If `true`, the view's width will grow and shrink together
|
||||
with the window. `false` by default.
|
||||
* `height` Boolean - If `true`, the view's height will grow and shrink
|
||||
together with the window. `false` by default.
|
||||
|
||||
#### `win.setBounds(bounds)` _Experimental_
|
||||
#### `view.setBounds(bounds)` _Experimental_
|
||||
|
||||
* `bounds` [Rectangle](structures/rectangle.md)
|
||||
|
||||
Resizes and moves the view to the supplied bounds relative to the window.
|
||||
|
||||
#### `win.setBackgroundColor(color)` _Experimental_
|
||||
#### `view.setBackgroundColor(color)` _Experimental_
|
||||
|
||||
* `color` String - Color in `#aarrggbb` or `#argb` form. The alpha channel is
|
||||
optional.
|
||||
|
||||
@@ -1027,7 +1027,7 @@ Same as `webContents.capturePage([rect, ]callback)`.
|
||||
* `httpReferrer` String (optional) - A HTTP Referrer url.
|
||||
* `userAgent` String (optional) - A user agent originating the request.
|
||||
* `extraHeaders` String (optional) - Extra headers separated by "\n"
|
||||
* `postData` ([UploadRawData](structures/upload-raw-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] - (optional)
|
||||
* `postData` ([UploadRawData[]](structures/upload-raw-data.md) | [UploadFile[]](structures/upload-file.md) | [UploadFileSystem[]](structures/upload-file-system.md) | [UploadBlob[]](structures/upload-blob.md)) - (optional)
|
||||
* `baseURLForDataURL` String (optional) - Base url (with trailing path separator) for files to be loaded by the data url. This is needed only if the specified `url` is a data url and needs to load other files.
|
||||
|
||||
Same as `webContents.loadURL(url[, options])`.
|
||||
|
||||
@@ -153,6 +153,8 @@ Creates a new `NativeImage` instance from `buffer`.
|
||||
|
||||
* `dataURL` String
|
||||
|
||||
Returns `NativeImage`
|
||||
|
||||
Creates a new `NativeImage` instance from `dataURL`.
|
||||
|
||||
## Class: NativeImage
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# MemoryInfo Object
|
||||
|
||||
* `workingSetSize` Integer - Process id of the process.
|
||||
* `pid` Integer - Process id of the process.
|
||||
* `workingSetSize` Integer - The amount of memory currently pinned to actual physical RAM.
|
||||
* `peakWorkingSetSize` Integer - The maximum amount of memory that has ever been pinned
|
||||
to actual physical RAM.
|
||||
@@ -9,4 +9,4 @@
|
||||
* `sharedBytes` Integer - The amount of memory shared between processes, typically
|
||||
memory consumed by the Electron code itself
|
||||
|
||||
Note that all statistics are reported in Kilobytes.
|
||||
Note that all statistics are reported in Kilobytes.
|
||||
|
||||
@@ -537,7 +537,7 @@ that can't be set via `<webview>` attributes.
|
||||
* `httpReferrer` String (optional) - A HTTP Referrer url.
|
||||
* `userAgent` String (optional) - A user agent originating the request.
|
||||
* `extraHeaders` String (optional) - Extra headers separated by "\n"
|
||||
* `postData` ([UploadRawData](structures/upload-raw-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] - (optional)
|
||||
* `postData` ([UploadRawData[]](structures/upload-raw-data.md) | [UploadFile[]](structures/upload-file.md) | [UploadFileSystem[]](structures/upload-file-system.md) | [UploadBlob[]](structures/upload-blob.md)) - (optional)
|
||||
* `baseURLForDataURL` String (optional) - Base url (with trailing path separator) for files to be loaded by the data url. This is needed only if the specified `url` is a data url and needs to load other files.
|
||||
|
||||
Loads the `url` in the window. The `url` must contain the protocol prefix,
|
||||
|
||||
@@ -312,8 +312,8 @@ webview.addEventListener('dom-ready', () => {
|
||||
* `httpReferrer` String (optional) - A HTTP Referrer url.
|
||||
* `userAgent` String (optional) - A user agent originating the request.
|
||||
* `extraHeaders` String (optional) - Extra headers separated by "\n"
|
||||
* `postData` ([UploadRawData](structures/upload-raw-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] - (optional)
|
||||
* `baseURLForDataURL` String (optional) - Base url (with trailing path separator) for files to be loaded by the data url. This is needed only if the specified `url` is a data url and needs to load other files.
|
||||
* `postData` ([UploadRawData[]](structures/upload-raw-data.md) | [UploadFile[]](structures/upload-file.md) | [UploadFileSystem[]](structures/upload-file-system.md) | [UploadBlob[]](structures/upload-blob.md)) - (optional)
|
||||
* `baseURLForDataURL` String (optional) - Base url (with trailing path separator) for files to be loaded by the data url. This is needed only if the specified `url` is a data url and needs to load other files.
|
||||
|
||||
Loads the `url` in the webview, the `url` must contain the protocol prefix,
|
||||
e.g. the `http://` or `file://`.
|
||||
@@ -511,14 +511,14 @@ Inserts `text` to the focused element.
|
||||
|
||||
* `text` String - Content to be searched, must not be empty.
|
||||
* `options` Object (optional)
|
||||
* `forward` Boolean - Whether to search forward or backward, defaults to `true`.
|
||||
* `findNext` Boolean - Whether the operation is first request or a follow up,
|
||||
* `forward` Boolean - (optional) Whether to search forward or backward, defaults to `true`.
|
||||
* `findNext` Boolean - (optional) Whether the operation is first request or a follow up,
|
||||
defaults to `false`.
|
||||
* `matchCase` Boolean - Whether search should be case-sensitive,
|
||||
* `matchCase` Boolean - (optional) Whether search should be case-sensitive,
|
||||
defaults to `false`.
|
||||
* `wordStart` Boolean - Whether to look only at the start of words.
|
||||
* `wordStart` Boolean - (optional) Whether to look only at the start of words.
|
||||
defaults to `false`.
|
||||
* `medialCapitalAsWordStart` Boolean - When combined with `wordStart`,
|
||||
* `medialCapitalAsWordStart` Boolean - (optional) When combined with `wordStart`,
|
||||
accepts a match in the middle of a word if the match begins with an
|
||||
uppercase letter followed by a lowercase or non-letter.
|
||||
Accepts several other intra-word matches, defaults to `false`.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
'product_name%': 'Electron',
|
||||
'company_name%': 'GitHub, Inc',
|
||||
'company_abbr%': 'github',
|
||||
'version%': '1.6.9',
|
||||
'version%': '1.6.17',
|
||||
'js2c_input_dir': '<(SHARED_INTERMEDIATE_DIR)/js2c',
|
||||
},
|
||||
'includes': [
|
||||
|
||||
@@ -97,6 +97,8 @@
|
||||
'atom/app/atom_main_delegate.cc',
|
||||
'atom/app/atom_main_delegate.h',
|
||||
'atom/app/atom_main_delegate_mac.mm',
|
||||
'atom/app/command_line_args.cc',
|
||||
'atom/app/command_line_args.h',
|
||||
'atom/app/node_main.cc',
|
||||
'atom/app/node_main.h',
|
||||
'atom/app/uv_task_runner.cc',
|
||||
|
||||
@@ -29,7 +29,7 @@ class AutoUpdater extends EventEmitter {
|
||||
return this.emitError('Can not find Squirrel')
|
||||
}
|
||||
this.emit('checking-for-update')
|
||||
squirrelUpdate.download(this.updateURL, (error, update) => {
|
||||
squirrelUpdate.checkForUpdate(this.updateURL, (error, update) => {
|
||||
if (error != null) {
|
||||
return this.emitError(error)
|
||||
}
|
||||
|
||||
@@ -82,8 +82,8 @@ exports.processStart = function () {
|
||||
}
|
||||
|
||||
// Download the releases specified by the URL and write new results to stdout.
|
||||
exports.download = function (updateURL, callback) {
|
||||
return spawnUpdate(['--download', updateURL], false, function (error, stdout) {
|
||||
exports.checkForUpdate = function (updateURL, callback) {
|
||||
return spawnUpdate(['--checkForUpdate', updateURL], false, function (error, stdout) {
|
||||
var json, ref, ref1, update
|
||||
if (error != null) {
|
||||
return callback(error)
|
||||
|
||||
@@ -394,6 +394,11 @@ ipcMain.on('ELECTRON_BROWSER_DEREFERENCE', function (event, id) {
|
||||
objectsRegistry.remove(event.sender.getId(), id)
|
||||
})
|
||||
|
||||
ipcMain.on('ELECTRON_BROWSER_CONTEXT_RELEASE', (e) => {
|
||||
objectsRegistry.clear(e.sender.getId())
|
||||
e.returnValue = null
|
||||
})
|
||||
|
||||
ipcMain.on('ELECTRON_BROWSER_GUEST_WEB_CONTENTS', function (event, guestInstanceId) {
|
||||
try {
|
||||
let guestViewManager = require('./guest-view-manager')
|
||||
|
||||
@@ -304,6 +304,10 @@ ipcRenderer.on('ELECTRON_RENDERER_RELEASE_CALLBACK', function (event, id) {
|
||||
callbacksRegistry.remove(id)
|
||||
})
|
||||
|
||||
process.on('exit', () => {
|
||||
ipcRenderer.sendSync('ELECTRON_BROWSER_CONTEXT_RELEASE')
|
||||
})
|
||||
|
||||
// Get remote module.
|
||||
exports.require = function (module) {
|
||||
return metaToValue(ipcRenderer.sendSync('ELECTRON_BROWSER_REQUIRE', module))
|
||||
|
||||
10
npm/cli.js
Executable file
10
npm/cli.js
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var electron = require('./')
|
||||
|
||||
var proc = require('child_process')
|
||||
|
||||
var child = proc.spawn(electron, process.argv.slice(2), {stdio: 'inherit'})
|
||||
child.on('close', function (code) {
|
||||
process.exit(code)
|
||||
})
|
||||
10
npm/index.js
Normal file
10
npm/index.js
Normal file
@@ -0,0 +1,10 @@
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
|
||||
var pathFile = path.join(__dirname, 'path.txt')
|
||||
|
||||
if (fs.existsSync(pathFile)) {
|
||||
module.exports = path.join(__dirname, fs.readFileSync(pathFile, 'utf-8'))
|
||||
} else {
|
||||
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')
|
||||
}
|
||||
65
npm/install.js
Executable file
65
npm/install.js
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// maintainer note - x.y.z-ab version in package.json -> x.y.z
|
||||
var version = require('./package').version.replace(/-.*/, '')
|
||||
|
||||
var fs = require('fs')
|
||||
var os = require('os')
|
||||
var path = require('path')
|
||||
var extract = require('extract-zip')
|
||||
var download = require('electron-download')
|
||||
|
||||
var installedVersion = null
|
||||
try {
|
||||
installedVersion = fs.readFileSync(path.join(__dirname, 'dist', 'version'), 'utf-8').replace(/^v/, '')
|
||||
} catch (ignored) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
var platformPath = getPlatformPath()
|
||||
|
||||
if (installedVersion === version && fs.existsSync(path.join(__dirname, platformPath))) {
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
// downloads if not cached
|
||||
download({
|
||||
cache: process.env.electron_config_cache,
|
||||
version: version,
|
||||
platform: process.env.npm_config_platform,
|
||||
arch: process.env.npm_config_arch,
|
||||
strictSSL: process.env.npm_config_strict_ssl === 'true',
|
||||
force: process.env.force_no_cache === 'true',
|
||||
quiet: ['info', 'verbose', 'silly', 'http'].indexOf(process.env.npm_config_loglevel) === -1
|
||||
}, extractFile)
|
||||
|
||||
// unzips and makes path.txt point at the correct executable
|
||||
function extractFile (err, zipPath) {
|
||||
if (err) return onerror(err)
|
||||
extract(zipPath, {dir: path.join(__dirname, 'dist')}, function (err) {
|
||||
if (err) return onerror(err)
|
||||
fs.writeFile(path.join(__dirname, 'path.txt'), platformPath, function (err) {
|
||||
if (err) return onerror(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function onerror (err) {
|
||||
throw err
|
||||
}
|
||||
|
||||
function getPlatformPath () {
|
||||
var platform = process.env.npm_config_platform || os.platform()
|
||||
|
||||
switch (platform) {
|
||||
case 'darwin':
|
||||
return 'dist/Electron.app/Contents/MacOS/Electron'
|
||||
case 'freebsd':
|
||||
case 'linux':
|
||||
return 'dist/electron'
|
||||
case 'win32':
|
||||
return 'dist/electron.exe'
|
||||
default:
|
||||
throw new Error('Electron builds are not available on platform: ' + platform)
|
||||
}
|
||||
}
|
||||
26
npm/package.json
Normal file
26
npm/package.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"scripts": {
|
||||
"cache-clean": "rm -rf ~/.electron && rm -rf dist",
|
||||
"postinstall": "node install.js",
|
||||
"pretest": "npm run cache-clean",
|
||||
"test": "standard"
|
||||
},
|
||||
"bin": {
|
||||
"electron": "cli.js"
|
||||
},
|
||||
"main": "index.js",
|
||||
"types": "electron.d.ts",
|
||||
"dependencies": {
|
||||
"@types/node": "^7.0.18",
|
||||
"electron-download": "^3.0.1",
|
||||
"extract-zip": "^1.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"home-path": "^0.1.1",
|
||||
"path-exists": "^2.0.0",
|
||||
"standard": "^5.4.1"
|
||||
},
|
||||
"directories": {
|
||||
"test": "test"
|
||||
}
|
||||
}
|
||||
21
package.json
21
package.json
@@ -1,15 +1,22 @@
|
||||
{
|
||||
"name": "electron",
|
||||
"version": "1.6.9",
|
||||
"version": "1.6.17",
|
||||
"devDependencies": {
|
||||
"asar": "^0.11.0",
|
||||
"browserify": "^13.1.0",
|
||||
"colors": "^1.1.2",
|
||||
"dugite": "^1.57.0",
|
||||
"electabul": "~0.0.4",
|
||||
"electron-docs-linter": "^2.1.0",
|
||||
"electron-typescript-definitions": "^1.2.0",
|
||||
"electron-docs-linter": "^2.3.3",
|
||||
"electron-typescript-definitions": "1.2.7",
|
||||
"github": "^9.2.0",
|
||||
"heads": "^1.3.0",
|
||||
"minimist": "^1.2.0",
|
||||
"nugget": "^2.0.1",
|
||||
"request": "*",
|
||||
"standard": "^8.4.0",
|
||||
"standard-markdown": "^2.1.1"
|
||||
"standard-markdown": "^2.1.1",
|
||||
"sumchecker": "^2.0.2"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"runas": "^3.0.0"
|
||||
@@ -40,8 +47,12 @@
|
||||
"lint-py": "python ./script/pylint.py",
|
||||
"lint-api-docs-js": "standard-markdown docs && standard-markdown docs-translations",
|
||||
"lint-api-docs": "electron-docs-linter",
|
||||
"create-api-json": "electron-docs-linter docs --outfile=out/electron-api.json --version=$npm_package_version",
|
||||
"create-typescript-definitions": "npm run create-api-json && electron-typescript-definitions --in=out/electron-api.json --out=out/electron.d.ts",
|
||||
"preinstall": "node -e 'process.exit(0)'",
|
||||
"release": "./script/upload.py -p",
|
||||
"prepare-release": "node ./script/prepare-release.js",
|
||||
"prerelease": "python ./script/bootstrap.py -v --dev && npm run build",
|
||||
"release": "node ./script/release.js",
|
||||
"repl": "python ./script/start.py --interactive",
|
||||
"start": "python ./script/start.py",
|
||||
"test": "python ./script/test.py"
|
||||
|
||||
@@ -34,6 +34,7 @@ def main():
|
||||
update_package_json(version)
|
||||
tag_version(version)
|
||||
|
||||
print 'Bumped to version: {0}'.format(version)
|
||||
|
||||
def increase_version(versions, index):
|
||||
for i in range(index + 1, 4):
|
||||
|
||||
209
script/ci-release-build.js
Normal file
209
script/ci-release-build.js
Normal file
@@ -0,0 +1,209 @@
|
||||
const assert = require('assert')
|
||||
const request = require('request')
|
||||
const buildAppVeyorURL = 'https://windows-ci.electronjs.org/api/builds'
|
||||
const jenkinsServer = 'https://mac-ci.electronjs.org'
|
||||
|
||||
const circleCIJobs = [
|
||||
'electron-linux-arm',
|
||||
'electron-linux-ia32',
|
||||
'electron-linux-x64'
|
||||
]
|
||||
|
||||
const jenkinsJobs = [
|
||||
'electron-mas-x64-release',
|
||||
'electron-osx-x64-release'
|
||||
]
|
||||
|
||||
async function makeRequest (requestOptions, parseResponse) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(requestOptions, (err, res, body) => {
|
||||
if (!err && res.statusCode >= 200 && res.statusCode < 300) {
|
||||
if (parseResponse) {
|
||||
const build = JSON.parse(body)
|
||||
resolve(build)
|
||||
} else {
|
||||
resolve(body)
|
||||
}
|
||||
} else {
|
||||
if (parseResponse) {
|
||||
console.log('Error: ', `(status ${res.statusCode})`, err || JSON.parse(res.body), requestOptions)
|
||||
} else {
|
||||
console.log('Error: ', `(status ${res.statusCode})`, err || res.body, requestOptions)
|
||||
}
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async function circleCIcall (buildUrl, targetBranch, job, ghRelease) {
|
||||
assert(process.env.CIRCLE_TOKEN, 'CIRCLE_TOKEN not found in environment')
|
||||
console.log(`Triggering CircleCI to run build job: ${job} on branch: ${targetBranch} with release flag.`)
|
||||
let buildRequest = {
|
||||
'build_parameters': {
|
||||
'CIRCLE_JOB': job
|
||||
}
|
||||
}
|
||||
|
||||
if (ghRelease) {
|
||||
buildRequest.build_parameters.ELECTRON_RELEASE = 1
|
||||
} else {
|
||||
buildRequest.build_parameters.RUN_RELEASE_BUILD = 'true'
|
||||
}
|
||||
|
||||
let circleResponse = await makeRequest({
|
||||
method: 'POST',
|
||||
url: buildUrl,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(buildRequest)
|
||||
}, true).catch(err => {
|
||||
console.log('Error calling CircleCI:', err)
|
||||
})
|
||||
console.log(`Check ${circleResponse.build_url} for status. (${job})`)
|
||||
}
|
||||
|
||||
async function buildAppVeyor (targetBranch, ghRelease) {
|
||||
console.log(`Triggering AppVeyor to run build on branch: ${targetBranch} with release flag.`)
|
||||
assert(process.env.APPVEYOR_TOKEN, 'APPVEYOR_TOKEN not found in environment')
|
||||
let environmentVariables = {}
|
||||
|
||||
if (ghRelease) {
|
||||
environmentVariables.ELECTRON_RELEASE = 1
|
||||
} else {
|
||||
environmentVariables.RUN_RELEASE_BUILD = 'true'
|
||||
}
|
||||
|
||||
const requestOpts = {
|
||||
url: buildAppVeyorURL,
|
||||
auth: {
|
||||
bearer: process.env.APPVEYOR_TOKEN
|
||||
},
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
accountName: 'AppVeyor',
|
||||
projectSlug: 'electron',
|
||||
branch: targetBranch,
|
||||
environmentVariables
|
||||
}),
|
||||
method: 'POST'
|
||||
}
|
||||
let appVeyorResponse = await makeRequest(requestOpts, true).catch(err => {
|
||||
console.log('Error calling AppVeyor:', err)
|
||||
})
|
||||
const buildUrl = `https://windows-ci.electronjs.org/project/AppVeyor/electron/build/${appVeyorResponse.version}`
|
||||
console.log(`AppVeyor release build request successful. Check build status at ${buildUrl}`)
|
||||
}
|
||||
|
||||
function buildCircleCI (targetBranch, ghRelease, job) {
|
||||
const circleBuildUrl = `https://circleci.com/api/v1.1/project/github/electron/electron/tree/${targetBranch}?circle-token=${process.env.CIRCLE_TOKEN}`
|
||||
if (job) {
|
||||
assert(circleCIJobs.includes(job), `Unknown CI job name: ${job}.`)
|
||||
circleCIcall(circleBuildUrl, targetBranch, job, ghRelease)
|
||||
} else {
|
||||
circleCIJobs.forEach((job) => circleCIcall(circleBuildUrl, targetBranch, job, ghRelease))
|
||||
}
|
||||
}
|
||||
|
||||
async function buildJenkins (targetBranch, ghRelease, job) {
|
||||
assert(process.env.JENKINS_AUTH_TOKEN, 'JENKINS_AUTH_TOKEN not found in environment')
|
||||
assert(process.env.JENKINS_BUILD_TOKEN, 'JENKINS_BUILD_TOKEN not found in environment')
|
||||
let jenkinsCrumb = await getJenkinsCrumb()
|
||||
|
||||
if (job) {
|
||||
assert(jenkinsJobs.includes(job), `Unknown CI job name: ${job}.`)
|
||||
callJenkinsBuild(job, jenkinsCrumb, targetBranch, ghRelease)
|
||||
} else {
|
||||
jenkinsJobs.forEach((job) => {
|
||||
callJenkinsBuild(job, jenkinsCrumb, targetBranch, ghRelease)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async function callJenkins (path, requestParameters, requestHeaders) {
|
||||
let requestOptions = {
|
||||
url: `${jenkinsServer}/${path}`,
|
||||
auth: {
|
||||
user: 'build',
|
||||
pass: process.env.JENKINS_AUTH_TOKEN
|
||||
},
|
||||
qs: requestParameters
|
||||
}
|
||||
if (requestHeaders) {
|
||||
requestOptions.headers = requestHeaders
|
||||
}
|
||||
let jenkinsResponse = await makeRequest(requestOptions).catch(err => {
|
||||
console.log(`Error calling Jenkins:`, err)
|
||||
})
|
||||
return jenkinsResponse
|
||||
}
|
||||
|
||||
async function callJenkinsBuild (job, jenkinsCrumb, targetBranch, ghRelease) {
|
||||
console.log(`Triggering Jenkins to run build job: ${job} on branch: ${targetBranch} with release flag.`)
|
||||
let jenkinsParams = {
|
||||
token: process.env.JENKINS_BUILD_TOKEN,
|
||||
BRANCH: targetBranch
|
||||
}
|
||||
if (!ghRelease) {
|
||||
jenkinsParams.RUN_RELEASE_BUILD = 1
|
||||
}
|
||||
await callJenkins(`job/${job}/buildWithParameters`, jenkinsParams, jenkinsCrumb)
|
||||
.catch(err => {
|
||||
console.log(`Error calling Jenkins build`, err)
|
||||
})
|
||||
let buildUrl = `${jenkinsServer}/job/${job}/lastBuild/`
|
||||
console.log(`Jenkins build request successful. Check build status at ${buildUrl}.`)
|
||||
}
|
||||
|
||||
async function getJenkinsCrumb () {
|
||||
let crumbResponse = await callJenkins('crumbIssuer/api/xml', {
|
||||
xpath: 'concat(//crumbRequestField,":",//crumb)'
|
||||
}).catch(err => {
|
||||
console.log(`Error getting jenkins crumb:`, err)
|
||||
})
|
||||
let crumbDetails = crumbResponse.split(':')
|
||||
let crumbHeader = {}
|
||||
crumbHeader[crumbDetails[0]] = crumbDetails[1]
|
||||
return crumbHeader
|
||||
}
|
||||
|
||||
function runRelease (targetBranch, options) {
|
||||
if (options.ci) {
|
||||
switch (options.ci) {
|
||||
case 'CircleCI': {
|
||||
buildCircleCI(targetBranch, options.ghRelease, options.job)
|
||||
break
|
||||
}
|
||||
case 'AppVeyor': {
|
||||
buildAppVeyor(targetBranch, options.ghRelease)
|
||||
break
|
||||
}
|
||||
case 'Jenkins': {
|
||||
buildJenkins(targetBranch, options.ghRelease, options.job)
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
buildCircleCI(targetBranch, options.ghRelease, options.job)
|
||||
buildAppVeyor(targetBranch, options.ghRelease)
|
||||
buildJenkins(targetBranch, options.ghRelease, options.job)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = runRelease
|
||||
|
||||
if (require.main === module) {
|
||||
const args = require('minimist')(process.argv.slice(2))
|
||||
const targetBranch = args._[0]
|
||||
if (args._.length < 1) {
|
||||
console.log(`Trigger CI to build release builds of electron.
|
||||
Usage: ci-release-build.js [--job=CI_JOB_NAME] [--ci=CircleCI|AppVeyor|Jenkins] [--ghRelease] TARGET_BRANCH
|
||||
`)
|
||||
process.exit(0)
|
||||
}
|
||||
runRelease(targetBranch, args)
|
||||
}
|
||||
@@ -55,10 +55,9 @@ def main():
|
||||
deps += LINUX_DEPS_ARM
|
||||
execute(['sudo', 'apt-get', 'install'] + deps)
|
||||
|
||||
execute(['sh', '-e', '/etc/init.d/xvfb', 'start'])
|
||||
|
||||
if PLATFORM == 'linux':
|
||||
if PLATFORM == 'linux' and target_arch == 'x64':
|
||||
os.environ['DISPLAY'] = ':99.0'
|
||||
execute(['sh', '-e', '/etc/init.d/xvfb', 'start'])
|
||||
|
||||
# CI's npm is not reliable.
|
||||
npm = 'npm.cmd' if PLATFORM == 'win32' else 'npm'
|
||||
@@ -72,7 +71,7 @@ def main():
|
||||
os.environ.get('PATH', '')])
|
||||
|
||||
is_release = os.environ.has_key('ELECTRON_RELEASE')
|
||||
args = ['--target_arch=' + target_arch]
|
||||
args = ['--target_arch=' + target_arch, '-v']
|
||||
if not is_release:
|
||||
args += ['--dev']
|
||||
run_script('bootstrap.py', args)
|
||||
|
||||
@@ -9,7 +9,7 @@ import sys
|
||||
BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \
|
||||
'https://s3.amazonaws.com/github-janky-artifacts/libchromiumcontent'
|
||||
LIBCHROMIUMCONTENT_COMMIT = os.getenv('LIBCHROMIUMCONTENT_COMMIT') or \
|
||||
'4a0e32606e52c12c50c2e3a0973d015d8cdff494'
|
||||
'19ca886975716c02d6de9fd41b8297a4e1774be2'
|
||||
|
||||
PLATFORM = {
|
||||
'cygwin': 'win32',
|
||||
|
||||
116
script/merge-release.js
Executable file
116
script/merge-release.js
Executable file
@@ -0,0 +1,116 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
require('colors')
|
||||
const assert = require('assert')
|
||||
const branchToRelease = process.argv[2]
|
||||
const fail = '\u2717'.red
|
||||
const { GitProcess, GitError } = require('dugite')
|
||||
const pass = '\u2713'.green
|
||||
const path = require('path')
|
||||
const pkg = require('../package.json')
|
||||
|
||||
assert(process.env.ELECTRON_GITHUB_TOKEN, 'ELECTRON_GITHUB_TOKEN not found in environment')
|
||||
if (!branchToRelease) {
|
||||
console.log(`Usage: merge-release branch`)
|
||||
process.exit(1)
|
||||
}
|
||||
const gitDir = path.resolve(__dirname, '..')
|
||||
|
||||
async function callGit (args, errorMessage, successMessage) {
|
||||
let gitResult = await GitProcess.exec(args, gitDir)
|
||||
if (gitResult.exitCode === 0) {
|
||||
console.log(`${pass} ${successMessage}`)
|
||||
return true
|
||||
} else {
|
||||
console.log(`${fail} ${errorMessage} ${gitResult.stderr}`)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
async function checkoutBranch (branchName) {
|
||||
console.log(`Checking out ${branchName}.`)
|
||||
let errorMessage = `Error checking out branch ${branchName}:`
|
||||
let successMessage = `Successfully checked out branch ${branchName}.`
|
||||
return callGit(['checkout', branchName], errorMessage, successMessage)
|
||||
}
|
||||
|
||||
async function commitMerge () {
|
||||
console.log(`Committing the merge for v${pkg.version}`)
|
||||
let errorMessage = `Error committing merge:`
|
||||
let successMessage = `Successfully committed the merge for v${pkg.version}`
|
||||
let gitArgs = ['commit', '-m', `v${pkg.version}`]
|
||||
return callGit(gitArgs, errorMessage, successMessage)
|
||||
}
|
||||
|
||||
async function mergeReleaseIntoBranch (branchName) {
|
||||
console.log(`Merging release branch into ${branchName}.`)
|
||||
let mergeArgs = ['merge', 'release-1-6-x', '--squash']
|
||||
let mergeDetails = await GitProcess.exec(mergeArgs, gitDir)
|
||||
if (mergeDetails.exitCode === 0) {
|
||||
return true
|
||||
} else {
|
||||
const error = GitProcess.parseError(mergeDetails.stderr)
|
||||
if (error === GitError.MergeConflicts) {
|
||||
console.log(`${fail} Could not merge release branch into ${branchName} ` +
|
||||
`due to merge conflicts.`)
|
||||
return false
|
||||
} else {
|
||||
console.log(`${fail} Could not merge release branch into ${branchName} ` +
|
||||
`due to an error: ${mergeDetails.stderr}.`)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function pushBranch (branchName) {
|
||||
console.log(`Pushing branch ${branchName}.`)
|
||||
let pushArgs = ['push', 'origin', branchName]
|
||||
let errorMessage = `Could not push branch ${branchName} due to an error:`
|
||||
let successMessage = `Successfully pushed branch ${branchName}.`
|
||||
return callGit(pushArgs, errorMessage, successMessage)
|
||||
}
|
||||
|
||||
async function pull () {
|
||||
console.log(`Performing a git pull`)
|
||||
let errorMessage = `Could not pull due to an error:`
|
||||
let successMessage = `Successfully performed a git pull`
|
||||
return callGit(['pull'], errorMessage, successMessage)
|
||||
}
|
||||
|
||||
async function rebase (targetBranch) {
|
||||
console.log(`Rebasing release branch from ${targetBranch}`)
|
||||
let errorMessage = `Could not rebase due to an error:`
|
||||
let successMessage = `Successfully rebased release branch from ` +
|
||||
`${targetBranch}`
|
||||
return callGit(['rebase', targetBranch], errorMessage, successMessage)
|
||||
}
|
||||
|
||||
async function mergeRelease () {
|
||||
await checkoutBranch(branchToRelease)
|
||||
let mergeSuccess = await mergeReleaseIntoBranch(branchToRelease)
|
||||
if (mergeSuccess) {
|
||||
console.log(`${pass} Successfully merged release branch into ` +
|
||||
`${branchToRelease}.`)
|
||||
await commitMerge()
|
||||
let pushSuccess = await pushBranch(branchToRelease)
|
||||
if (pushSuccess) {
|
||||
console.log(`${pass} Success!!! ${branchToRelease} now has the latest release!`)
|
||||
}
|
||||
} else {
|
||||
console.log(`Trying rebase of ${branchToRelease} into release branch.`)
|
||||
await pull()
|
||||
await checkoutBranch('release-1-6-x')
|
||||
let rebaseResult = await rebase(branchToRelease)
|
||||
if (rebaseResult) {
|
||||
let pushResult = pushBranch('HEAD')
|
||||
if (pushResult) {
|
||||
console.log(`Rebase of ${branchToRelease} into release branch was ` +
|
||||
`successful. Let release builds run and then try this step again.`)
|
||||
}
|
||||
// Exit as failure so release doesn't continue
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mergeRelease()
|
||||
182
script/prepare-release.js
Executable file
182
script/prepare-release.js
Executable file
@@ -0,0 +1,182 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
require('colors')
|
||||
const args = require('minimist')(process.argv.slice(2))
|
||||
const assert = require('assert')
|
||||
const ciReleaseBuild = require('./ci-release-build')
|
||||
const { execSync } = require('child_process')
|
||||
const fail = '\u2717'.red
|
||||
const { GitProcess, GitError } = require('dugite')
|
||||
const GitHub = require('github')
|
||||
const pass = '\u2713'.green
|
||||
const path = require('path')
|
||||
const pkg = require('../package.json')
|
||||
const versionType = args._[0]
|
||||
|
||||
// TODO (future) automatically determine version based on conventional commits
|
||||
// via conventional-recommended-bump
|
||||
|
||||
assert(process.env.ELECTRON_GITHUB_TOKEN, 'ELECTRON_GITHUB_TOKEN not found in environment')
|
||||
if (!versionType && !args.notesOnly) {
|
||||
console.log(`Usage: prepare-release versionType [major | minor | patch ]` +
|
||||
` (--notesOnly)`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const github = new GitHub()
|
||||
const gitDir = path.resolve(__dirname, '..')
|
||||
github.authenticate({type: 'token', token: process.env.ELECTRON_GITHUB_TOKEN})
|
||||
|
||||
async function createReleaseBranch () {
|
||||
console.log(`Creating release branch.`)
|
||||
let checkoutDetails = await GitProcess.exec([ 'checkout', '-b', 'release-1-6-x' ], gitDir)
|
||||
if (checkoutDetails.exitCode === 0) {
|
||||
console.log(`${pass} Successfully created the release branch.`)
|
||||
} else {
|
||||
const error = GitProcess.parseError(checkoutDetails.stderr)
|
||||
if (error === GitError.BranchAlreadyExists) {
|
||||
console.log(`${fail} Release branch already exists, aborting prepare ` +
|
||||
`release process.`)
|
||||
} else {
|
||||
console.log(`${fail} Error creating release branch: ` +
|
||||
`${checkoutDetails.stderr}`)
|
||||
}
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
function getNewVersion () {
|
||||
console.log(`Bumping for new "${versionType}" version.`)
|
||||
let bumpScript = path.join(__dirname, 'bump-version.py')
|
||||
let scriptArgs = [bumpScript, `${versionType}`]
|
||||
if (args.stable) {
|
||||
scriptArgs.push('--stable')
|
||||
}
|
||||
try {
|
||||
let bumpVersion = execSync(scriptArgs.join(' '), {encoding: 'UTF-8'})
|
||||
bumpVersion = bumpVersion.substr(bumpVersion.indexOf(':') + 1).trim()
|
||||
let newVersion = `v${bumpVersion}`
|
||||
console.log(`${pass} Successfully bumped version to ${newVersion}`)
|
||||
return newVersion
|
||||
} catch (err) {
|
||||
console.log(`${fail} Could not bump version, error was:`, err)
|
||||
}
|
||||
}
|
||||
|
||||
async function getCurrentBranch (gitDir) {
|
||||
console.log(`Determining current git branch`)
|
||||
let gitArgs = ['rev-parse', '--abbrev-ref', 'HEAD']
|
||||
let branchDetails = await GitProcess.exec(gitArgs, gitDir)
|
||||
if (branchDetails.exitCode === 0) {
|
||||
let currentBranch = branchDetails.stdout.trim()
|
||||
console.log(`${pass} Successfully determined current git branch is ` +
|
||||
`${currentBranch}`)
|
||||
return currentBranch
|
||||
} else {
|
||||
let error = GitProcess.parseError(branchDetails.stderr)
|
||||
console.log(`${fail} Could not get details for the current branch,
|
||||
error was ${branchDetails.stderr}`, error)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
async function getReleaseNotes (currentBranch) {
|
||||
console.log(`Generating release notes for ${currentBranch}.`)
|
||||
let githubOpts = {
|
||||
owner: 'electron',
|
||||
repo: 'electron',
|
||||
base: `v${pkg.version}`,
|
||||
head: currentBranch
|
||||
}
|
||||
let releaseNotes = '(placeholder)\n'
|
||||
console.log(`Checking for commits from ${pkg.version} to ${currentBranch}`)
|
||||
let commitComparison = await github.repos.compareCommits(githubOpts)
|
||||
.catch(err => {
|
||||
console.log(`{$fail} Error checking for commits from ${pkg.version} to ` +
|
||||
`${currentBranch}`, err)
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
commitComparison.data.commits.forEach(commitEntry => {
|
||||
let commitMessage = commitEntry.commit.message
|
||||
if (commitMessage.toLowerCase().indexOf('merge') > -1) {
|
||||
releaseNotes += `${commitMessage} \n`
|
||||
}
|
||||
})
|
||||
console.log(`${pass} Done generating release notes for ${currentBranch}.`)
|
||||
return releaseNotes
|
||||
}
|
||||
|
||||
async function createRelease (branchToTarget, isBeta) {
|
||||
let releaseNotes = await getReleaseNotes(branchToTarget)
|
||||
let newVersion = getNewVersion()
|
||||
const githubOpts = {
|
||||
owner: 'electron',
|
||||
repo: 'electron'
|
||||
}
|
||||
console.log(`Checking for existing draft release.`)
|
||||
let releases = await github.repos.getReleases(githubOpts)
|
||||
.catch(err => {
|
||||
console.log('$fail} Could not get releases. Error was', err)
|
||||
})
|
||||
let drafts = releases.data.filter(release => release.draft &&
|
||||
release.tag_name === newVersion)
|
||||
if (drafts.length > 0) {
|
||||
console.log(`${fail} Aborting because draft release for
|
||||
${drafts[0].tag_name} already exists.`)
|
||||
process.exit(1)
|
||||
}
|
||||
console.log(`${pass} A draft release does not exist; creating one.`)
|
||||
githubOpts.body = releaseNotes
|
||||
githubOpts.draft = true
|
||||
githubOpts.name = `electron ${newVersion}`
|
||||
if (isBeta) {
|
||||
githubOpts.body = `Note: This is a beta release. Please file new issues ` +
|
||||
`for any bugs you find in it.\n \n This release is published to npm ` +
|
||||
`under the beta tag and can be installed via npm install electron@beta, ` +
|
||||
`or npm i electron@${newVersion.substr(1)}.`
|
||||
githubOpts.name = `${githubOpts.name}`
|
||||
githubOpts.prerelease = true
|
||||
}
|
||||
githubOpts.tag_name = newVersion
|
||||
githubOpts.target_commitish = branchToTarget
|
||||
await github.repos.createRelease(githubOpts)
|
||||
.catch(err => {
|
||||
console.log(`${fail} Error creating new release: `, err)
|
||||
process.exit(1)
|
||||
})
|
||||
console.log(`${pass} Draft release for ${newVersion} has been created.`)
|
||||
}
|
||||
|
||||
async function pushRelease () {
|
||||
let pushDetails = await GitProcess.exec(['push', 'origin', 'HEAD'], gitDir)
|
||||
if (pushDetails.exitCode === 0) {
|
||||
console.log(`${pass} Successfully pushed the release branch. Wait for ` +
|
||||
`release builds to finish before running "npm run release".`)
|
||||
} else {
|
||||
console.log(`${fail} Error pushing the release branch: ` +
|
||||
`${pushDetails.stderr}`)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
async function runReleaseBuilds () {
|
||||
await ciReleaseBuild('release-1-6-x', {
|
||||
ghRelease: true
|
||||
})
|
||||
}
|
||||
|
||||
async function prepareRelease (isBeta, notesOnly) {
|
||||
let currentBranch = await getCurrentBranch(gitDir)
|
||||
if (notesOnly) {
|
||||
let releaseNotes = await getReleaseNotes(currentBranch)
|
||||
console.log(`Draft release notes are: ${releaseNotes}`)
|
||||
} else {
|
||||
await createReleaseBranch()
|
||||
await createRelease(currentBranch, isBeta)
|
||||
await pushRelease()
|
||||
await runReleaseBuilds()
|
||||
}
|
||||
}
|
||||
|
||||
prepareRelease(!args.stable, args.notesOnly)
|
||||
112
script/prerelease.js
Executable file
112
script/prerelease.js
Executable file
@@ -0,0 +1,112 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
require('colors')
|
||||
const assert = require('assert')
|
||||
const GitHub = require('github')
|
||||
const heads = require('heads')
|
||||
const pkg = require('../package.json')
|
||||
const pass = '\u2713'.green
|
||||
const fail = '\u2717'.red
|
||||
let failureCount = 0
|
||||
|
||||
assert(process.env.ELECTRON_GITHUB_TOKEN, 'ELECTRON_GITHUB_TOKEN not found in environment')
|
||||
|
||||
const github = new GitHub()
|
||||
github.authenticate({type: 'token', token: process.env.ELECTRON_GITHUB_TOKEN})
|
||||
github.repos.getReleases({owner: 'electron', repo: 'electron'})
|
||||
.then(res => {
|
||||
const releases = res.data
|
||||
const drafts = releases
|
||||
.filter(release => release.draft) // comment out for testing
|
||||
// .filter(release => release.tag_name === 'v1.7.5') // uncomment for testing
|
||||
|
||||
check(drafts.length === 1, 'one draft exists', true)
|
||||
const draft = drafts[0]
|
||||
|
||||
check(draft.tag_name === `v${pkg.version}`, `draft release version matches local package.json (v${pkg.version})`)
|
||||
check(draft.prerelease, 'draft is a prerelease')
|
||||
check(draft.body.length > 50 && !draft.body.includes('(placeholder)'), 'draft has release notes')
|
||||
|
||||
const requiredAssets = assetsForVersion(draft.tag_name).sort()
|
||||
const extantAssets = draft.assets.map(asset => asset.name).sort()
|
||||
|
||||
requiredAssets.forEach(asset => {
|
||||
check(extantAssets.includes(asset), asset)
|
||||
})
|
||||
|
||||
const s3Urls = s3UrlsForVersion(draft.tag_name)
|
||||
heads(s3Urls)
|
||||
.then(results => {
|
||||
results.forEach((result, i) => {
|
||||
check(result === 200, s3Urls[i])
|
||||
})
|
||||
|
||||
process.exit(failureCount > 0 ? 1 : 0)
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('Error making HEAD requests for S3 assets')
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
})
|
||||
|
||||
function check (condition, statement, exitIfFail = false) {
|
||||
if (condition) {
|
||||
console.log(`${pass} ${statement}`)
|
||||
} else {
|
||||
failureCount++
|
||||
console.log(`${fail} ${statement}`)
|
||||
if (exitIfFail) process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
function assetsForVersion (version) {
|
||||
const patterns = [
|
||||
'electron-{{VERSION}}-darwin-x64-dsym.zip',
|
||||
'electron-{{VERSION}}-darwin-x64-symbols.zip',
|
||||
'electron-{{VERSION}}-darwin-x64.zip',
|
||||
'electron-{{VERSION}}-linux-arm-symbols.zip',
|
||||
'electron-{{VERSION}}-linux-arm.zip',
|
||||
'electron-{{VERSION}}-linux-armv7l-symbols.zip',
|
||||
'electron-{{VERSION}}-linux-armv7l.zip',
|
||||
'electron-{{VERSION}}-linux-ia32-symbols.zip',
|
||||
'electron-{{VERSION}}-linux-ia32.zip',
|
||||
'electron-{{VERSION}}-linux-x64-symbols.zip',
|
||||
'electron-{{VERSION}}-linux-x64.zip',
|
||||
'electron-{{VERSION}}-mas-x64-dsym.zip',
|
||||
'electron-{{VERSION}}-mas-x64-symbols.zip',
|
||||
'electron-{{VERSION}}-mas-x64.zip',
|
||||
'electron-{{VERSION}}-win32-ia32-pdb.zip',
|
||||
'electron-{{VERSION}}-win32-ia32-symbols.zip',
|
||||
'electron-{{VERSION}}-win32-ia32.zip',
|
||||
'electron-{{VERSION}}-win32-x64-pdb.zip',
|
||||
'electron-{{VERSION}}-win32-x64-symbols.zip',
|
||||
'electron-{{VERSION}}-win32-x64.zip',
|
||||
'electron-api.json',
|
||||
'electron.d.ts',
|
||||
'ffmpeg-{{VERSION}}-darwin-x64.zip',
|
||||
'ffmpeg-{{VERSION}}-linux-arm.zip',
|
||||
'ffmpeg-{{VERSION}}-linux-armv7l.zip',
|
||||
'ffmpeg-{{VERSION}}-linux-ia32.zip',
|
||||
'ffmpeg-{{VERSION}}-linux-x64.zip',
|
||||
'ffmpeg-{{VERSION}}-mas-x64.zip',
|
||||
'ffmpeg-{{VERSION}}-win32-ia32.zip',
|
||||
'ffmpeg-{{VERSION}}-win32-x64.zip'
|
||||
]
|
||||
return patterns.map(pattern => pattern.replace(/{{VERSION}}/g, version))
|
||||
}
|
||||
|
||||
function s3UrlsForVersion (version) {
|
||||
const bucket = 'https://gh-contractor-zcbenz.s3.amazonaws.com/'
|
||||
const patterns = [
|
||||
'atom-shell/dist/{{VERSION}}/iojs-{{VERSION}}-headers.tar.gz',
|
||||
'atom-shell/dist/{{VERSION}}/iojs-{{VERSION}}.tar.gz',
|
||||
'atom-shell/dist/{{VERSION}}/node-{{VERSION}}.tar.gz',
|
||||
'atom-shell/dist/{{VERSION}}/node.lib',
|
||||
'atom-shell/dist/{{VERSION}}/win-x64/iojs.lib',
|
||||
'atom-shell/dist/{{VERSION}}/win-x86/iojs.lib',
|
||||
'atom-shell/dist/{{VERSION}}/x64/node.lib',
|
||||
'atom-shell/dist/index.json'
|
||||
]
|
||||
return patterns.map(pattern => bucket + pattern.replace(/{{VERSION}}/g, version))
|
||||
}
|
||||
125
script/publish-to-npm.js
Normal file
125
script/publish-to-npm.js
Normal file
@@ -0,0 +1,125 @@
|
||||
const temp = require('temp')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const childProcess = require('child_process')
|
||||
const GitHubApi = require('github')
|
||||
const request = require('request')
|
||||
const assert = require('assert')
|
||||
const rootPackageJson = require('../package.json')
|
||||
|
||||
const github = new GitHubApi({
|
||||
// debug: true,
|
||||
headers: { 'User-Agent': 'electron-npm-publisher' },
|
||||
followRedirects: false
|
||||
})
|
||||
|
||||
let tempDir
|
||||
temp.track() // track and cleanup files at exit
|
||||
|
||||
const files = [
|
||||
'cli.js',
|
||||
'index.js',
|
||||
'install.js',
|
||||
'package.json',
|
||||
'README.md'
|
||||
]
|
||||
|
||||
const jsonFields = [
|
||||
'name',
|
||||
'version',
|
||||
'repository',
|
||||
'description',
|
||||
'license',
|
||||
'author',
|
||||
'keywords'
|
||||
]
|
||||
|
||||
let npmTag = ''
|
||||
|
||||
new Promise((resolve, reject) => {
|
||||
temp.mkdir('electron-npm', (err, dirPath) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
} else {
|
||||
resolve(dirPath)
|
||||
}
|
||||
})
|
||||
})
|
||||
.then((dirPath) => {
|
||||
tempDir = dirPath
|
||||
// copy files from `/npm` to temp directory
|
||||
files.forEach((name) => {
|
||||
fs.writeFileSync(
|
||||
path.join(tempDir, name),
|
||||
fs.readFileSync(path.join(__dirname, '..', name === 'README.md' ? '' : 'npm', name))
|
||||
)
|
||||
})
|
||||
// copy from root package.json to temp/package.json
|
||||
const packageJson = require(path.join(tempDir, 'package.json'))
|
||||
jsonFields.forEach((fieldName) => {
|
||||
packageJson[fieldName] = rootPackageJson[fieldName]
|
||||
})
|
||||
fs.writeFileSync(
|
||||
path.join(tempDir, 'package.json'),
|
||||
JSON.stringify(packageJson, null, 2)
|
||||
)
|
||||
|
||||
return github.repos.getReleases({
|
||||
owner: 'electron',
|
||||
repo: 'electron'
|
||||
})
|
||||
})
|
||||
.then((releases) => {
|
||||
// download electron.d.ts from release
|
||||
const release = releases.data.find(
|
||||
(release) => release.tag_name === `v${rootPackageJson.version}`
|
||||
)
|
||||
if (!release) {
|
||||
throw new Error(`cannot find release with tag v${rootPackageJson.version}`)
|
||||
}
|
||||
return release
|
||||
})
|
||||
.then((release) => {
|
||||
const tsdAsset = release.assets.find((asset) => asset.name === 'electron.d.ts')
|
||||
if (!tsdAsset) {
|
||||
throw new Error(`cannot find electron.d.ts from v${rootPackageJson.version} release assets`)
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
request.get({
|
||||
url: tsdAsset.url,
|
||||
headers: {
|
||||
'accept': 'application/octet-stream',
|
||||
'user-agent': 'electron-npm-publisher'
|
||||
}
|
||||
}, (err, response, body) => {
|
||||
if (err || response.statusCode !== 200) {
|
||||
reject(err || new Error('Cannot download electron.d.ts'))
|
||||
} else {
|
||||
fs.writeFileSync(path.join(tempDir, 'electron.d.ts'), body)
|
||||
resolve(release)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
.then((release) => {
|
||||
npmTag = release.prerelease ? 'beta' : 'latest'
|
||||
})
|
||||
.then(() => childProcess.execSync('npm pack', { cwd: tempDir }))
|
||||
.then(() => {
|
||||
// test that the package can install electron prebuilt from github release
|
||||
const tarballPath = path.join(tempDir, `${rootPackageJson.name}-${rootPackageJson.version}.tgz`)
|
||||
return new Promise((resolve, reject) => {
|
||||
childProcess.execSync(`npm install ${tarballPath} --force --silent`, {
|
||||
env: Object.assign({}, process.env, { electron_config_cache: tempDir }),
|
||||
cwd: tempDir
|
||||
})
|
||||
const checkVersion = childProcess.execSync(`${path.join(tempDir, 'node_modules', '.bin', 'electron')} -v`)
|
||||
assert.strictEqual(checkVersion.toString().trim(), `v${rootPackageJson.version}`)
|
||||
resolve(tarballPath)
|
||||
})
|
||||
})
|
||||
.then((tarballPath) => childProcess.execSync(`npm publish ${tarballPath} --tag ${npmTag}`))
|
||||
.catch((err) => {
|
||||
console.error(`Error: ${err}`)
|
||||
process.exit(1)
|
||||
})
|
||||
456
script/release.js
Executable file
456
script/release.js
Executable file
@@ -0,0 +1,456 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
require('colors')
|
||||
const args = require('minimist')(process.argv.slice(2))
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const { execSync } = require('child_process')
|
||||
const GitHub = require('github')
|
||||
const { GitProcess } = require('dugite')
|
||||
const nugget = require('nugget')
|
||||
const pkg = require('../package.json')
|
||||
const pkgVersion = `v${pkg.version}`
|
||||
const pass = '\u2713'.green
|
||||
const path = require('path')
|
||||
const fail = '\u2717'.red
|
||||
const sumchecker = require('sumchecker')
|
||||
const temp = require('temp').track()
|
||||
const { URL } = require('url')
|
||||
let failureCount = 0
|
||||
|
||||
assert(process.env.ELECTRON_GITHUB_TOKEN, 'ELECTRON_GITHUB_TOKEN not found in environment')
|
||||
|
||||
const github = new GitHub({
|
||||
followRedirects: false
|
||||
})
|
||||
github.authenticate({type: 'token', token: process.env.ELECTRON_GITHUB_TOKEN})
|
||||
const gitDir = path.resolve(__dirname, '..')
|
||||
|
||||
async function getDraftRelease (version, skipValidation) {
|
||||
let releaseInfo = await github.repos.getReleases({owner: 'electron', repo: 'electron'})
|
||||
let drafts
|
||||
let versionToCheck
|
||||
if (version) {
|
||||
versionToCheck = version
|
||||
} else {
|
||||
versionToCheck = pkgVersion
|
||||
}
|
||||
drafts = releaseInfo.data
|
||||
.filter(release => release.tag_name === versionToCheck &&
|
||||
release.draft === true)
|
||||
const draft = drafts[0]
|
||||
if (!skipValidation) {
|
||||
failureCount = 0
|
||||
check(drafts.length === 1, 'one draft exists', true)
|
||||
if (versionToCheck.indexOf('beta') > -1) {
|
||||
check(draft.prerelease, 'draft is a prerelease')
|
||||
}
|
||||
check(draft.body.length > 50 && !draft.body.includes('(placeholder)'), 'draft has release notes')
|
||||
check((failureCount === 0), `Draft release looks good to go.`, true)
|
||||
}
|
||||
return draft
|
||||
}
|
||||
|
||||
async function validateReleaseAssets (release) {
|
||||
const requiredAssets = assetsForVersion(release.tag_name).sort()
|
||||
const extantAssets = release.assets.map(asset => asset.name).sort()
|
||||
const downloadUrls = release.assets.map(asset => asset.browser_download_url).sort()
|
||||
|
||||
failureCount = 0
|
||||
requiredAssets.forEach(asset => {
|
||||
check(extantAssets.includes(asset), asset)
|
||||
})
|
||||
check((failureCount === 0), `All required GitHub assets exist for release`, true)
|
||||
|
||||
if (release.draft) {
|
||||
await verifyAssets(release)
|
||||
} else {
|
||||
await verifyShasums(downloadUrls)
|
||||
.catch(err => {
|
||||
console.log(`${fail} error verifyingShasums`, err)
|
||||
})
|
||||
}
|
||||
const s3Urls = s3UrlsForVersion(release.tag_name)
|
||||
await verifyShasums(s3Urls, true)
|
||||
}
|
||||
|
||||
function check (condition, statement, exitIfFail = false) {
|
||||
if (condition) {
|
||||
console.log(`${pass} ${statement}`)
|
||||
} else {
|
||||
failureCount++
|
||||
console.log(`${fail} ${statement}`)
|
||||
if (exitIfFail) process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
function assetsForVersion (version) {
|
||||
const patterns = [
|
||||
`electron-${version}-darwin-x64-dsym.zip`,
|
||||
`electron-${version}-darwin-x64-symbols.zip`,
|
||||
`electron-${version}-darwin-x64.zip`,
|
||||
`electron-${version}-linux-arm-symbols.zip`,
|
||||
`electron-${version}-linux-arm.zip`,
|
||||
`electron-${version}-linux-armv7l-symbols.zip`,
|
||||
`electron-${version}-linux-armv7l.zip`,
|
||||
`electron-${version}-linux-ia32-symbols.zip`,
|
||||
`electron-${version}-linux-ia32.zip`,
|
||||
`electron-${version}-linux-x64-symbols.zip`,
|
||||
`electron-${version}-linux-x64.zip`,
|
||||
`electron-${version}-mas-x64-dsym.zip`,
|
||||
`electron-${version}-mas-x64-symbols.zip`,
|
||||
`electron-${version}-mas-x64.zip`,
|
||||
`electron-${version}-win32-ia32-pdb.zip`,
|
||||
`electron-${version}-win32-ia32-symbols.zip`,
|
||||
`electron-${version}-win32-ia32.zip`,
|
||||
`electron-${version}-win32-x64-pdb.zip`,
|
||||
`electron-${version}-win32-x64-symbols.zip`,
|
||||
`electron-${version}-win32-x64.zip`,
|
||||
`electron-api.json`,
|
||||
`electron.d.ts`,
|
||||
`ffmpeg-${version}-darwin-x64.zip`,
|
||||
`ffmpeg-${version}-linux-arm.zip`,
|
||||
`ffmpeg-${version}-linux-armv7l.zip`,
|
||||
`ffmpeg-${version}-linux-ia32.zip`,
|
||||
`ffmpeg-${version}-linux-x64.zip`,
|
||||
`ffmpeg-${version}-mas-x64.zip`,
|
||||
`ffmpeg-${version}-win32-ia32.zip`,
|
||||
`ffmpeg-${version}-win32-x64.zip`,
|
||||
`SHASUMS256.txt`
|
||||
]
|
||||
return patterns
|
||||
}
|
||||
|
||||
function s3UrlsForVersion (version) {
|
||||
const bucket = `https://gh-contractor-zcbenz.s3.amazonaws.com/`
|
||||
const patterns = [
|
||||
`${bucket}atom-shell/dist/${version}/iojs-${version}-headers.tar.gz`,
|
||||
`${bucket}atom-shell/dist/${version}/iojs-${version}.tar.gz`,
|
||||
`${bucket}atom-shell/dist/${version}/node-${version}.tar.gz`,
|
||||
`${bucket}atom-shell/dist/${version}/node.lib`,
|
||||
`${bucket}atom-shell/dist/${version}/win-x64/iojs.lib`,
|
||||
`${bucket}atom-shell/dist/${version}/win-x86/iojs.lib`,
|
||||
`${bucket}atom-shell/dist/${version}/x64/node.lib`,
|
||||
`${bucket}atom-shell/dist/${version}/SHASUMS.txt`,
|
||||
`${bucket}atom-shell/dist/${version}/SHASUMS256.txt`,
|
||||
`${bucket}atom-shell/dist/index.json`
|
||||
]
|
||||
return patterns
|
||||
}
|
||||
|
||||
function checkVersion () {
|
||||
console.log(`Verifying that app version matches package version ${pkgVersion}.`)
|
||||
let startScript = path.join(__dirname, 'start.py')
|
||||
let appVersion = runScript(startScript, ['--version']).trim()
|
||||
check((pkgVersion.indexOf(appVersion) === 0), `App version ${appVersion} matches ` +
|
||||
`package version ${pkgVersion}.`, true)
|
||||
}
|
||||
|
||||
function runScript (scriptName, scriptArgs, cwd) {
|
||||
let scriptCommand = `${scriptName} ${scriptArgs.join(' ')}`
|
||||
let scriptOptions = {
|
||||
encoding: 'UTF-8'
|
||||
}
|
||||
if (cwd) {
|
||||
scriptOptions.cwd = cwd
|
||||
}
|
||||
try {
|
||||
return execSync(scriptCommand, scriptOptions)
|
||||
} catch (err) {
|
||||
console.log(`${fail} Error running ${scriptName}`, err)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
function uploadNodeShasums () {
|
||||
console.log('Uploading Node SHASUMS file to S3.')
|
||||
let scriptPath = path.join(__dirname, 'upload-node-checksums.py')
|
||||
runScript(scriptPath, ['-v', pkgVersion])
|
||||
console.log(`${pass} Done uploading Node SHASUMS file to S3.`)
|
||||
}
|
||||
|
||||
function uploadIndexJson () {
|
||||
console.log('Uploading index.json to S3.')
|
||||
let scriptPath = path.join(__dirname, 'upload-index-json.py')
|
||||
runScript(scriptPath, [])
|
||||
console.log(`${pass} Done uploading index.json to S3.`)
|
||||
}
|
||||
|
||||
async function createReleaseShasums (release) {
|
||||
let fileName = 'SHASUMS256.txt'
|
||||
let existingAssets = release.assets.filter(asset => asset.name === fileName)
|
||||
if (existingAssets.length > 0) {
|
||||
console.log(`${fileName} already exists on GitHub; deleting before creating new file.`)
|
||||
await github.repos.deleteAsset({
|
||||
owner: 'electron',
|
||||
repo: 'electron',
|
||||
id: existingAssets[0].id
|
||||
}).catch(err => {
|
||||
console.log(`${fail} Error deleting ${fileName} on GitHub:`, err)
|
||||
})
|
||||
}
|
||||
console.log(`Creating and uploading the release ${fileName}.`)
|
||||
let scriptPath = path.join(__dirname, 'merge-electron-checksums.py')
|
||||
let checksums = runScript(scriptPath, ['-v', pkgVersion])
|
||||
console.log(`${pass} Generated release SHASUMS.`)
|
||||
let filePath = await saveShaSumFile(checksums, fileName)
|
||||
console.log(`${pass} Created ${fileName} file.`)
|
||||
await uploadShasumFile(filePath, fileName, release)
|
||||
console.log(`${pass} Successfully uploaded ${fileName} to GitHub.`)
|
||||
}
|
||||
|
||||
async function uploadShasumFile (filePath, fileName, release) {
|
||||
let githubOpts = {
|
||||
owner: 'electron',
|
||||
repo: 'electron',
|
||||
id: release.id,
|
||||
filePath,
|
||||
name: fileName
|
||||
}
|
||||
return github.repos.uploadAsset(githubOpts)
|
||||
.catch(err => {
|
||||
console.log(`${fail} Error uploading ${filePath} to GitHub:`, err)
|
||||
process.exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
function saveShaSumFile (checksums, fileName) {
|
||||
return new Promise((resolve, reject) => {
|
||||
temp.open(fileName, (err, info) => {
|
||||
if (err) {
|
||||
console.log(`${fail} Could not create ${fileName} file`)
|
||||
process.exit(1)
|
||||
} else {
|
||||
fs.writeFileSync(info.fd, checksums)
|
||||
fs.close(info.fd, (err) => {
|
||||
if (err) {
|
||||
console.log(`${fail} Could close ${fileName} file`)
|
||||
process.exit(1)
|
||||
}
|
||||
resolve(info.path)
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async function publishRelease (release) {
|
||||
let githubOpts = {
|
||||
owner: 'electron',
|
||||
repo: 'electron',
|
||||
id: release.id,
|
||||
tag_name: release.tag_name,
|
||||
draft: false
|
||||
}
|
||||
return github.repos.editRelease(githubOpts)
|
||||
.catch(err => {
|
||||
console.log(`${fail} Error publishing release:`, err)
|
||||
process.exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
async function makeRelease (releaseToValidate) {
|
||||
if (releaseToValidate) {
|
||||
console.log(`Validating release ${args.validateRelease}`)
|
||||
let release = await getDraftRelease(args.validateRelease)
|
||||
await validateReleaseAssets(release)
|
||||
} else {
|
||||
checkVersion()
|
||||
let draftRelease = await getDraftRelease()
|
||||
uploadNodeShasums()
|
||||
uploadIndexJson()
|
||||
await createReleaseShasums(draftRelease)
|
||||
// Fetch latest version of release before verifying
|
||||
draftRelease = await getDraftRelease(pkgVersion, true)
|
||||
await validateReleaseAssets(draftRelease)
|
||||
await publishRelease(draftRelease)
|
||||
await cleanupReleaseBranch()
|
||||
console.log(`${pass} SUCCESS!!! Release has been published. Please run ` +
|
||||
`"npm run publish-to-npm" to publish release to npm.`)
|
||||
}
|
||||
}
|
||||
|
||||
async function makeTempDir () {
|
||||
return new Promise((resolve, reject) => {
|
||||
temp.mkdir('electron-publish', (err, dirPath) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
} else {
|
||||
resolve(dirPath)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async function verifyAssets (release) {
|
||||
let downloadDir = await makeTempDir()
|
||||
let githubOpts = {
|
||||
owner: 'electron',
|
||||
repo: 'electron',
|
||||
headers: {
|
||||
Accept: 'application/octet-stream'
|
||||
}
|
||||
}
|
||||
console.log(`Downloading files from GitHub to verify shasums`)
|
||||
let shaSumFile = 'SHASUMS256.txt'
|
||||
let filesToCheck = await Promise.all(release.assets.map(async (asset) => {
|
||||
githubOpts.id = asset.id
|
||||
let assetDetails = await github.repos.getAsset(githubOpts)
|
||||
await downloadFiles(assetDetails.meta.location, downloadDir, false, asset.name)
|
||||
return asset.name
|
||||
})).catch(err => {
|
||||
console.log(`${fail} Error downloading files from GitHub`, err)
|
||||
process.exit(1)
|
||||
})
|
||||
filesToCheck = filesToCheck.filter(fileName => fileName !== shaSumFile)
|
||||
let checkerOpts
|
||||
await validateChecksums({
|
||||
algorithm: 'sha256',
|
||||
filesToCheck,
|
||||
fileDirectory: downloadDir,
|
||||
shaSumFile,
|
||||
checkerOpts,
|
||||
fileSource: 'GitHub'
|
||||
})
|
||||
}
|
||||
|
||||
function downloadFiles (urls, directory, quiet, targetName) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let nuggetOpts = {
|
||||
dir: directory
|
||||
}
|
||||
if (quiet) {
|
||||
nuggetOpts.quiet = quiet
|
||||
}
|
||||
if (targetName) {
|
||||
nuggetOpts.target = targetName
|
||||
}
|
||||
nugget(urls, nuggetOpts, (err) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
} else {
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async function verifyShasums (urls, isS3) {
|
||||
let fileSource = isS3 ? 'S3' : 'GitHub'
|
||||
console.log(`Downloading files from ${fileSource} to verify shasums`)
|
||||
let downloadDir = await makeTempDir()
|
||||
let filesToCheck = []
|
||||
try {
|
||||
if (!isS3) {
|
||||
await downloadFiles(urls, downloadDir)
|
||||
filesToCheck = urls.map(url => {
|
||||
let currentUrl = new URL(url)
|
||||
return path.basename(currentUrl.pathname)
|
||||
}).filter(file => file.indexOf('SHASUMS') === -1)
|
||||
} else {
|
||||
const s3VersionPath = `/atom-shell/dist/${pkgVersion}/`
|
||||
await Promise.all(urls.map(async (url) => {
|
||||
let currentUrl = new URL(url)
|
||||
let dirname = path.dirname(currentUrl.pathname)
|
||||
let filename = path.basename(currentUrl.pathname)
|
||||
let s3VersionPathIdx = dirname.indexOf(s3VersionPath)
|
||||
if (s3VersionPathIdx === -1 || dirname === s3VersionPath) {
|
||||
if (s3VersionPathIdx !== -1 && filename.indexof('SHASUMS') === -1) {
|
||||
filesToCheck.push(filename)
|
||||
}
|
||||
await downloadFiles(url, downloadDir, true)
|
||||
} else {
|
||||
let subDirectory = dirname.substr(s3VersionPathIdx + s3VersionPath.length)
|
||||
let fileDirectory = path.join(downloadDir, subDirectory)
|
||||
try {
|
||||
fs.statSync(fileDirectory)
|
||||
} catch (err) {
|
||||
fs.mkdirSync(fileDirectory)
|
||||
}
|
||||
filesToCheck.push(path.join(subDirectory, filename))
|
||||
await downloadFiles(url, fileDirectory, true)
|
||||
}
|
||||
}))
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(`${fail} Error downloading files from ${fileSource}`, err)
|
||||
process.exit(1)
|
||||
}
|
||||
console.log(`${pass} Successfully downloaded the files from ${fileSource}.`)
|
||||
let checkerOpts
|
||||
if (isS3) {
|
||||
checkerOpts = { defaultTextEncoding: 'binary' }
|
||||
}
|
||||
|
||||
await validateChecksums({
|
||||
algorithm: 'sha256',
|
||||
filesToCheck,
|
||||
fileDirectory: downloadDir,
|
||||
shaSumFile: 'SHASUMS256.txt',
|
||||
checkerOpts,
|
||||
fileSource
|
||||
})
|
||||
|
||||
if (isS3) {
|
||||
await validateChecksums({
|
||||
algorithm: 'sha1',
|
||||
filesToCheck,
|
||||
fileDirectory: downloadDir,
|
||||
shaSumFile: 'SHASUMS.txt',
|
||||
checkerOpts,
|
||||
fileSource
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async function validateChecksums (validationArgs) {
|
||||
console.log(`Validating checksums for files from ${validationArgs.fileSource} ` +
|
||||
`against ${validationArgs.shaSumFile}.`)
|
||||
let shaSumFilePath = path.join(validationArgs.fileDirectory, validationArgs.shaSumFile)
|
||||
let checker = new sumchecker.ChecksumValidator(validationArgs.algorithm,
|
||||
shaSumFilePath, validationArgs.checkerOpts)
|
||||
await checker.validate(validationArgs.fileDirectory, validationArgs.filesToCheck)
|
||||
.catch(err => {
|
||||
if (err instanceof sumchecker.ChecksumMismatchError) {
|
||||
console.error(`${fail} The checksum of ${err.filename} from ` +
|
||||
`${validationArgs.fileSource} did not match the shasum in ` +
|
||||
`${validationArgs.shaSumFile}`)
|
||||
} else if (err instanceof sumchecker.ChecksumParseError) {
|
||||
console.error(`${fail} The checksum file ${validationArgs.shaSumFile} ` +
|
||||
`from ${validationArgs.fileSource} could not be parsed.`, err)
|
||||
} else if (err instanceof sumchecker.NoChecksumFoundError) {
|
||||
console.error(`${fail} The file ${err.filename} from ` +
|
||||
`${validationArgs.fileSource} was not in the shasum file ` +
|
||||
`${validationArgs.shaSumFile}.`)
|
||||
} else {
|
||||
console.error(`${fail} Error matching files from ` +
|
||||
`${validationArgs.fileSource} shasums in ${validationArgs.shaSumFile}.`, err)
|
||||
}
|
||||
process.exit(1)
|
||||
})
|
||||
console.log(`${pass} All files from ${validationArgs.fileSource} match ` +
|
||||
`shasums defined in ${validationArgs.shaSumFile}.`)
|
||||
}
|
||||
|
||||
async function cleanupReleaseBranch () {
|
||||
console.log(`Cleaning up release branch.`)
|
||||
let errorMessage = `Could not delete local release branch.`
|
||||
let successMessage = `Successfully deleted local release branch.`
|
||||
await callGit(['branch', '-D', 'release-1-6-x'], errorMessage, successMessage)
|
||||
errorMessage = `Could not delete remote release branch.`
|
||||
successMessage = `Successfully deleted remote release branch.`
|
||||
return callGit(['push', 'origin', ':release'], errorMessage, successMessage)
|
||||
}
|
||||
|
||||
async function callGit (args, errorMessage, successMessage) {
|
||||
let gitResult = await GitProcess.exec(args, gitDir)
|
||||
if (gitResult.exitCode === 0) {
|
||||
console.log(`${pass} ${successMessage}`)
|
||||
return true
|
||||
} else {
|
||||
console.log(`${fail} ${errorMessage} ${gitResult.stderr}`)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
makeRelease(args.validateRelease)
|
||||
51
script/upload-to-github.js
Normal file
51
script/upload-to-github.js
Normal file
@@ -0,0 +1,51 @@
|
||||
const GitHub = require('github')
|
||||
const github = new GitHub()
|
||||
github.authenticate({type: 'token', token: process.env.ELECTRON_GITHUB_TOKEN})
|
||||
|
||||
if (process.argv.length < 5) {
|
||||
console.log('Usage: upload-to-github filePath fileName releaseId')
|
||||
process.exit(1)
|
||||
}
|
||||
let filePath = process.argv[2]
|
||||
let fileName = process.argv[3]
|
||||
let releaseId = process.argv[4]
|
||||
|
||||
let githubOpts = {
|
||||
owner: 'electron',
|
||||
repo: 'electron',
|
||||
id: releaseId,
|
||||
filePath: filePath,
|
||||
name: fileName
|
||||
}
|
||||
|
||||
let retry = 0
|
||||
|
||||
function uploadToGitHub () {
|
||||
github.repos.uploadAsset(githubOpts).then(() => {
|
||||
console.log(`Successfully uploaded ${fileName} to GitHub.`)
|
||||
process.exit()
|
||||
}).catch((err) => {
|
||||
if (retry < 4) {
|
||||
console.log(`Error uploading ${fileName} to GitHub, will retry. Error was:`, err)
|
||||
retry++
|
||||
github.repos.getRelease(githubOpts).then(release => {
|
||||
let existingAssets = release.data.assets.filter(asset => asset.name === fileName)
|
||||
if (existingAssets.length > 0) {
|
||||
console.log(`${fileName} already exists; will delete before retrying upload.`)
|
||||
github.repos.deleteAsset({
|
||||
owner: 'electron',
|
||||
repo: 'electron',
|
||||
id: existingAssets[0].id
|
||||
}).then(uploadToGitHub).catch(uploadToGitHub)
|
||||
} else {
|
||||
uploadToGitHub()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
console.log(`Error retrying uploading ${fileName} to GitHub:`, err)
|
||||
process.exitCode = 1
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
uploadToGitHub()
|
||||
@@ -67,7 +67,7 @@ def main():
|
||||
run_python_script('upload-index-json.py')
|
||||
|
||||
# Create and upload the Electron SHASUMS*.txt
|
||||
release_electron_checksums(github, release)
|
||||
release_electron_checksums(release)
|
||||
|
||||
# Press the publish button.
|
||||
publish_release(github, release['id'])
|
||||
@@ -172,7 +172,7 @@ def get_text_with_editor(name):
|
||||
def create_or_get_release_draft(github, releases, tag, tag_exists):
|
||||
# Search for existing draft.
|
||||
for release in releases:
|
||||
if release['draft']:
|
||||
if release['draft'] and release['tag_name'] == tag:
|
||||
return release
|
||||
|
||||
if tag_exists:
|
||||
@@ -189,17 +189,20 @@ def create_release_draft(github, tag):
|
||||
if body == '':
|
||||
sys.stderr.write('Quit due to empty release note.\n')
|
||||
sys.exit(0)
|
||||
|
||||
data = dict(tag_name=tag, name=name, body=body, draft=True)
|
||||
data = dict(tag_name=tag, name=name, body=body, draft=True,
|
||||
target_commitish='1-6-x')
|
||||
r = github.repos(ELECTRON_REPO).releases.post(data=data)
|
||||
return r
|
||||
|
||||
|
||||
def release_electron_checksums(github, release):
|
||||
def release_electron_checksums(release):
|
||||
checksums = run_python_script('merge-electron-checksums.py',
|
||||
'-v', ELECTRON_VERSION)
|
||||
upload_io_to_github(github, release, 'SHASUMS256.txt',
|
||||
StringIO(checksums.decode('utf-8')), 'text/plain')
|
||||
filename = 'SHASUMS256.txt'
|
||||
filepath = os.path.join(SOURCE_ROOT, filename)
|
||||
with open(filepath, 'w') as sha_file:
|
||||
sha_file.write(checksums.decode('utf-8'))
|
||||
upload_io_to_github(release, filename, filepath)
|
||||
|
||||
|
||||
def upload_electron(github, release, file_path):
|
||||
@@ -214,8 +217,7 @@ def upload_electron(github, release, file_path):
|
||||
pass
|
||||
|
||||
# Upload the file.
|
||||
with open(file_path, 'rb') as f:
|
||||
upload_io_to_github(github, release, filename, f, 'application/zip')
|
||||
upload_io_to_github(release, filename, file_path)
|
||||
|
||||
# Upload the checksum file.
|
||||
upload_sha256_checksum(release['tag_name'], file_path)
|
||||
@@ -229,11 +231,11 @@ def upload_electron(github, release, file_path):
|
||||
upload_electron(github, release, arm_file_path)
|
||||
|
||||
|
||||
def upload_io_to_github(github, release, name, io, content_type):
|
||||
params = {'name': name}
|
||||
headers = {'Content-Type': content_type}
|
||||
github.repos(ELECTRON_REPO).releases(release['id']).assets.post(
|
||||
params=params, headers=headers, data=io, verify=False)
|
||||
def upload_io_to_github(release, filename, filepath):
|
||||
print 'Uploading %s to Github' % \
|
||||
(filename)
|
||||
script_path = os.path.join(SOURCE_ROOT, 'script', 'upload-to-github.js')
|
||||
execute(['node', script_path, filepath, filename, str(release['id'])])
|
||||
|
||||
|
||||
def upload_sha256_checksum(version, file_path):
|
||||
|
||||
@@ -208,7 +208,7 @@ describe('app module', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('app.importCertificate', function () {
|
||||
xdescribe('app.importCertificate', function () {
|
||||
if (process.platform !== 'linux') return
|
||||
|
||||
var w = null
|
||||
@@ -405,7 +405,7 @@ describe('app module', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('select-client-certificate event', function () {
|
||||
xdescribe('select-client-certificate event', function () {
|
||||
let w = null
|
||||
|
||||
beforeEach(function () {
|
||||
@@ -469,6 +469,54 @@ describe('app module', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('app launch through uri', () => {
|
||||
before(function () {
|
||||
if (process.platform !== 'win32') {
|
||||
this.skip()
|
||||
}
|
||||
})
|
||||
|
||||
it('does not launch for blacklisted argument', function (done) {
|
||||
const appPath = path.join(__dirname, 'fixtures', 'api', 'quit-app')
|
||||
// App should exit with non 123 code.
|
||||
const first = ChildProcess.spawn(remote.process.execPath, [appPath, 'electron-test://?', '--no-sandbox', '--gpu-launcher=cmd.exe /c start calc'])
|
||||
first.once('exit', (code) => {
|
||||
assert.notEqual(code, 123)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('launches successfully for multiple uris in cmd args', function (done) {
|
||||
const appPath = path.join(__dirname, 'fixtures', 'api', 'quit-app')
|
||||
// App should exit with code 123.
|
||||
const first = ChildProcess.spawn(remote.process.execPath, [appPath, 'http://electronjs.org', 'electron-test://testdata'])
|
||||
first.once('exit', (code) => {
|
||||
assert.equal(code, 123)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('does not launch for encoded space', function (done) {
|
||||
const appPath = path.join(__dirname, 'fixtures', 'api', 'quit-app')
|
||||
// App should exit with non 123 code.
|
||||
const first = ChildProcess.spawn(remote.process.execPath, [appPath, 'electron-test://?', '--no-sandbox', '--gpu-launcher%20"cmd.exe /c start calc'])
|
||||
first.once('exit', (code) => {
|
||||
assert.notEqual(code, 123)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('launches successfully for argnames similar to blacklisted ones', function (done) {
|
||||
const appPath = path.join(__dirname, 'fixtures', 'api', 'quit-app')
|
||||
// inspect is blacklisted, but inspector should work, and app launch should succeed
|
||||
const first = ChildProcess.spawn(remote.process.execPath, [appPath, 'electron-test://?', '--inspector'])
|
||||
first.once('exit', (code) => {
|
||||
assert.equal(code, 123)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('getFileIcon() API', function () {
|
||||
// FIXME Get these specs running on Linux CI
|
||||
if (process.platform === 'linux' && isCI) return
|
||||
|
||||
@@ -1161,7 +1161,6 @@ describe('BrowserWindow module', function () {
|
||||
}
|
||||
})
|
||||
w.loadURL('file://' + path.join(fixtures, 'api', 'sandbox.html?allocate-memory'))
|
||||
w.webContents.openDevTools({mode: 'detach'})
|
||||
ipcMain.once('answer', function (event, {bytesBeforeOpen, bytesAfterOpen, bytesAfterClose}) {
|
||||
const memoryIncreaseByOpen = bytesAfterOpen - bytesBeforeOpen
|
||||
const memoryDecreaseByClose = bytesAfterOpen - bytesAfterClose
|
||||
@@ -1173,6 +1172,73 @@ describe('BrowserWindow module', function () {
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
// see #9387
|
||||
it('properly manages remote object references after page reload', (done) => {
|
||||
w.destroy()
|
||||
w = new BrowserWindow({
|
||||
show: false,
|
||||
webPreferences: {
|
||||
preload: preload,
|
||||
sandbox: true
|
||||
}
|
||||
})
|
||||
w.loadURL('file://' + path.join(fixtures, 'api', 'sandbox.html?reload-remote'))
|
||||
|
||||
ipcMain.on('get-remote-module-path', (event) => {
|
||||
event.returnValue = path.join(fixtures, 'module', 'hello.js')
|
||||
})
|
||||
|
||||
let reload = false
|
||||
ipcMain.on('reloaded', (event) => {
|
||||
event.returnValue = reload
|
||||
reload = !reload
|
||||
})
|
||||
|
||||
ipcMain.once('reload', (event) => {
|
||||
event.sender.reload()
|
||||
})
|
||||
|
||||
ipcMain.once('answer', (event, arg) => {
|
||||
ipcMain.removeAllListeners('reloaded')
|
||||
ipcMain.removeAllListeners('get-remote-module-path')
|
||||
assert.equal(arg, 'hi')
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('properly manages remote object references after page reload in child window', (done) => {
|
||||
w.destroy()
|
||||
w = new BrowserWindow({
|
||||
show: false,
|
||||
webPreferences: {
|
||||
preload: preload,
|
||||
sandbox: true
|
||||
}
|
||||
})
|
||||
w.loadURL('file://' + path.join(fixtures, 'api', 'sandbox.html?reload-remote-child'))
|
||||
|
||||
ipcMain.on('get-remote-module-path', (event) => {
|
||||
event.returnValue = path.join(fixtures, 'module', 'hello-child.js')
|
||||
})
|
||||
|
||||
let reload = false
|
||||
ipcMain.on('reloaded', (event) => {
|
||||
event.returnValue = reload
|
||||
reload = !reload
|
||||
})
|
||||
|
||||
ipcMain.once('reload', (event) => {
|
||||
event.sender.reload()
|
||||
})
|
||||
|
||||
ipcMain.once('answer', (event, arg) => {
|
||||
ipcMain.removeAllListeners('reloaded')
|
||||
ipcMain.removeAllListeners('get-remote-module-path')
|
||||
assert.equal(arg, 'hi child window')
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ const url = require('url')
|
||||
const {closeWindow} = require('./window-helpers')
|
||||
|
||||
const {remote} = require('electron')
|
||||
const isCI = remote.getGlobal('isCi')
|
||||
const {app, BrowserWindow, crashReporter} = remote.require('electron')
|
||||
|
||||
describe('crashReporter module', function () {
|
||||
@@ -16,6 +17,12 @@ describe('crashReporter module', function () {
|
||||
return
|
||||
}
|
||||
|
||||
// FIXME internal Linux CI is failing when it detects a process crashes
|
||||
// which is a false positive here since crashes are explicitly triggered
|
||||
if (isCI && process.platform === 'linux') {
|
||||
return
|
||||
}
|
||||
|
||||
var originalTempDirectory = null
|
||||
var tempDirectory = null
|
||||
|
||||
|
||||
@@ -952,16 +952,18 @@ describe('chromium feature', function () {
|
||||
slashes: true
|
||||
})
|
||||
|
||||
beforeEach(function () {
|
||||
function createBrowserWindow ({plugins}) {
|
||||
w = new BrowserWindow({
|
||||
show: false,
|
||||
webPreferences: {
|
||||
preload: path.join(fixtures, 'module', 'preload-inject-ipc.js')
|
||||
preload: path.join(fixtures, 'module', 'preload-inject-ipc.js'),
|
||||
plugins: plugins
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
it('opens when loading a pdf resource as top level navigation', function (done) {
|
||||
createBrowserWindow({plugins: true})
|
||||
ipcMain.once('pdf-loaded', function (event, success) {
|
||||
if (success) done()
|
||||
})
|
||||
@@ -983,7 +985,21 @@ describe('chromium feature', function () {
|
||||
w.webContents.loadURL(pdfSource)
|
||||
})
|
||||
|
||||
it('should download a pdf when plugins are disabled', function (done) {
|
||||
createBrowserWindow({plugins: false})
|
||||
ipcRenderer.sendSync('set-download-option', false, false)
|
||||
ipcRenderer.once('download-done', function (event, state, url, mimeType, receivedBytes, totalBytes, disposition, filename) {
|
||||
assert.equal(state, 'completed')
|
||||
assert.equal(filename, 'cat.pdf')
|
||||
assert.equal(mimeType, 'application/pdf')
|
||||
fs.unlinkSync(path.join(fixtures, 'mock.pdf'))
|
||||
done()
|
||||
})
|
||||
w.webContents.loadURL(pdfSource)
|
||||
})
|
||||
|
||||
it('should not open when pdf is requested as sub resource', function (done) {
|
||||
createBrowserWindow({plugins: true})
|
||||
webFrame.registerURLSchemeAsPrivileged('file', {
|
||||
secure: false,
|
||||
bypassCSP: false,
|
||||
|
||||
20
spec/fixtures/api/sandbox.html
vendored
20
spec/fixtures/api/sandbox.html
vendored
@@ -13,13 +13,28 @@
|
||||
await timeout(100)
|
||||
}
|
||||
}
|
||||
if (window.opener) {
|
||||
|
||||
const [,test] = window.location.href.split('?')
|
||||
if (window.opener && test !== 'reload-remote') {
|
||||
window.callback = () => {
|
||||
opener.require('electron').ipcRenderer.send('answer', document.body.innerHTML)
|
||||
}
|
||||
} else {
|
||||
const {ipcRenderer} = require('electron')
|
||||
const {ipcRenderer, remote} = require('electron')
|
||||
const tests = {
|
||||
'reload-remote-child': () => {
|
||||
open(`${location.protocol}//${location.pathname}?reload-remote`)
|
||||
},
|
||||
'reload-remote': async () => {
|
||||
const p = ipcRenderer.sendSync('get-remote-module-path')
|
||||
const Hello = remote.require(p)
|
||||
if (!ipcRenderer.sendSync('reloaded')) {
|
||||
ipcRenderer.send('reload')
|
||||
return
|
||||
}
|
||||
await invokeGc()
|
||||
ipcRenderer.send('answer', new Hello().say())
|
||||
},
|
||||
'allocate-memory': async () => {
|
||||
await invokeGc()
|
||||
const {privateBytes: bytesBeforeOpen} = process.getProcessMemoryInfo()
|
||||
@@ -95,7 +110,6 @@
|
||||
popup.close()
|
||||
}, false)
|
||||
|
||||
let [,test] = window.location.href.split('?')
|
||||
if (tests.hasOwnProperty(test))
|
||||
tests[test]()
|
||||
}
|
||||
|
||||
6
spec/fixtures/module/hello-child.js
vendored
Normal file
6
spec/fixtures/module/hello-child.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
class Hello {
|
||||
say () {
|
||||
return 'hi child window'
|
||||
}
|
||||
}
|
||||
module.exports = Hello
|
||||
6
spec/fixtures/module/hello.js
vendored
Normal file
6
spec/fixtures/module/hello.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
class Hello {
|
||||
say () {
|
||||
return 'hi'
|
||||
}
|
||||
}
|
||||
module.exports = Hello
|
||||
2
spec/fixtures/module/preload-sandbox.js
vendored
2
spec/fixtures/module/preload-sandbox.js
vendored
@@ -3,9 +3,9 @@
|
||||
const {ipcRenderer} = require('electron')
|
||||
window.ipcRenderer = ipcRenderer
|
||||
window.setImmediate = setImmediate
|
||||
window.require = require
|
||||
if (location.protocol === 'file:') {
|
||||
window.test = 'preload'
|
||||
window.require = require
|
||||
window.process = process
|
||||
} else if (location.href !== 'about:blank') {
|
||||
addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
2
vendor/node
vendored
2
vendor/node
vendored
Submodule vendor/node updated: 3fe90cfcf5...9b1683e700
Reference in New Issue
Block a user