Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

v5 Electron Support (5-8) #2872

Open
wants to merge 81 commits into
base: v5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 74 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
f57f4b4
Support upto Electron 8 (Windows ONLY)
glenn2223 Mar 16, 2020
9c5aeb6
Docs to expand on Electron Support
glenn2223 Mar 16, 2020
7f5b6bf
Update Electron-Support.md
glenn2223 Mar 16, 2020
90e697d
Update Electron-Support.md
glenn2223 Mar 16, 2020
e6b1a43
Reverted isSupportedEnvironment
glenn2223 Mar 16, 2020
0661d3b
Create electron-win.yml
glenn2223 Mar 17, 2020
92b7ef0
Delete Electron-Support.md
glenn2223 Mar 17, 2020
1760a4c
Removed bindings
glenn2223 Mar 17, 2020
ed1c343
Merge branch 'master' of https://github.com/glenn2223/node-sass
glenn2223 Mar 17, 2020
97a903b
Update electron-win.yml
glenn2223 Mar 17, 2020
2bc2261
Updated node-gyp to 6.1.0
glenn2223 Mar 17, 2020
5fe05fa
Renamed artifacts to almost match
glenn2223 Mar 17, 2020
80a5070
Workflow changes
glenn2223 Mar 17, 2020
7368214
Update electron-linux.yml
glenn2223 Mar 17, 2020
f3aaea6
Workflow updates
glenn2223 Mar 17, 2020
18687aa
Workflow updates
glenn2223 Mar 17, 2020
499e066
Workflow updates
glenn2223 Mar 17, 2020
9642e7b
Fixes
glenn2223 Mar 17, 2020
d95fc8a
Update electron-linux.yml
glenn2223 Mar 17, 2020
9d01660
Update electron-linux.yml
glenn2223 Mar 17, 2020
69ddf4c
Update electron-linux.yml
glenn2223 Mar 17, 2020
2cc27f0
Update electron-linux.yml
glenn2223 Mar 17, 2020
480890d
Update electron-linux.yml
glenn2223 Mar 17, 2020
72ed801
Update electron-linux.yml
glenn2223 Mar 17, 2020
138d277
Dropped x32 from linux workflow
glenn2223 Mar 17, 2020
165f68a
Reverted to electron rebuild
glenn2223 Mar 17, 2020
2eb370e
Merge branch 'master' of https://github.com/glenn2223/node-sass
glenn2223 Mar 17, 2020
ed333ad
Update electron-win.yml
glenn2223 Mar 17, 2020
4da3d46
Update workflows
glenn2223 Mar 17, 2020
17cfbc0
Workflow updates
glenn2223 Mar 17, 2020
a1db6da
Workflow updates
glenn2223 Mar 17, 2020
818b048
Removed unrequired dependancy
glenn2223 Mar 17, 2020
9faff00
Update electron-win.yml
glenn2223 Mar 17, 2020
23927c8
Linux test
glenn2223 Mar 17, 2020
7c35440
Update electron-linux.yml
glenn2223 Mar 17, 2020
f1bdcea
Final workflow update
glenn2223 Mar 17, 2020
78048c9
Windows workflow correction
glenn2223 Mar 18, 2020
2e93037
Update electron-win.yml
glenn2223 Mar 18, 2020
c65aa3c
Small tweaks to workers
glenn2223 Mar 18, 2020
403a152
Workflow update
glenn2223 Mar 19, 2020
a7543a1
Windows workflow update
glenn2223 Mar 19, 2020
96f12b6
Update electron-win.yml
glenn2223 Mar 19, 2020
3e7526a
Update electron-win.yml
glenn2223 Mar 19, 2020
45801f7
Final windows workflow change
glenn2223 Mar 19, 2020
99a6b2f
Final windows workflow change
glenn2223 Mar 19, 2020
0ec38a7
Test 8
glenn2223 Mar 20, 2020
d8bda5a
Reverted windows workflow
glenn2223 Mar 20, 2020
0dc70dc
Update build.js
glenn2223 Mar 20, 2020
2242656
Update build.js
glenn2223 Mar 20, 2020
2571ad0
Update build.js
glenn2223 Mar 20, 2020
3c64cee
Update extensions.js
glenn2223 Mar 20, 2020
479ecb6
Update build.js
glenn2223 Mar 20, 2020
283c856
Update build.js
glenn2223 Mar 20, 2020
e02345e
Update build.js
glenn2223 Mar 20, 2020
7b6e50a
Update build.js
glenn2223 Mar 20, 2020
3ef7f38
Update extensions.js
glenn2223 Mar 21, 2020
2ecdd2a
Update build.js
glenn2223 Mar 21, 2020
0e74f76
Update build.js
glenn2223 Mar 22, 2020
6eeedea
Optional forcing of electron build
glenn2223 Mar 23, 2020
712d495
Updated workflows
glenn2223 Mar 23, 2020
d51123f
Updated lingering console log
glenn2223 Mar 23, 2020
f17457b
Updated workflows
glenn2223 Mar 23, 2020
5c83ff1
node-gyp bump
glenn2223 Mar 23, 2020
6c30086
Workflow updates
glenn2223 Mar 23, 2020
e173f61
Resolving PR dependancies
glenn2223 Mar 23, 2020
963b83e
Removed duplication of --arch
glenn2223 Mar 23, 2020
be34ce5
Added Windows --arch targeting
glenn2223 Mar 23, 2020
4f9ccc0
Merge branch 'v5' into Electron-Test
glenn2223 Mar 23, 2020
7552f4e
Fix: Extensions don't honor argment `arch`
glenn2223 Mar 23, 2020
a5abeed
Merge branch 'Electron-Test' of https://github.com/glenn2223/node-sas…
glenn2223 Mar 23, 2020
92eca82
Double quote fix
glenn2223 Mar 23, 2020
3289bbd
Updated windows workflow
glenn2223 Mar 23, 2020
9f40bf7
Travis fixes
glenn2223 Mar 23, 2020
a536530
Merge branch 'v5' into Electron-Test
glenn2223 Mar 27, 2020
3216467
Small revision
glenn2223 Apr 11, 2020
b616802
Update electron-linux.yml
glenn2223 Apr 11, 2020
7abdec3
Update electron-osx.yml
glenn2223 Oct 20, 2020
d9e3870
Update electron-linux.yml
glenn2223 Oct 20, 2020
a34d22b
Update electron-win.yml
glenn2223 Oct 20, 2020
0a905c5
Update yml
glenn2223 Oct 20, 2020
7fa8d75
Update extensions.js
glenn2223 Oct 20, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/electron-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Electron Rebuild CI - Linux (x32 & x64)

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
electron:
- 5
- 6
- 7
- 8
include:
# includes a new variable for each electron (essentially a switch statement)
- electron: 5
nodeVersion: 70
- electron: 6
nodeVersion: 73
- electron: 7
nodeVersion: 75
- electron: 8
nodeVersion: 76

steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
os: ${{ matrix.os }}
glenn2223 marked this conversation as resolved.
Show resolved Hide resolved
- name: Install packages
run: npm install --unsafe-perm
env:
SKIP_SASS_BINARY_DOWNLOAD_FOR_CI: true
- name: Run build (electron force)
run: node ./scripts/build --electron-version=${{ matrix.electron }}.0.0
- name: Check success by getting binary
uses: actions/upload-artifact@v1
with:
name: linux-x64-${{ matrix.nodeVersion }}_binding.node
path: vendor/linux-x64-${{ matrix.nodeVersion }}/binding.node
44 changes: 44 additions & 0 deletions .github/workflows/electron-osx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Electron Rebuild CI - OSX (x64)

on: [push, pull_request]

jobs:
build:

runs-on: macos-latest

strategy:
matrix:
electron:
- 5
- 6
- 7
- 8
include:
# includes a new variable for each electron (essentially a switch statement)
- electron: 5
nodeVersion: 70
- electron: 6
nodeVersion: 73
- electron: 7
nodeVersion: 75
- electron: 8
nodeVersion: 76

steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
os: ${{ matrix.os }}
- name: Install packages
run: npm install --unsafe-perm
env:
SKIP_SASS_BINARY_DOWNLOAD_FOR_CI: true
- name: Run build (electron force)
run: node ./scripts/build --electron-version=${{ matrix.electron }}.0.0
- name: Check success by getting binary
uses: actions/upload-artifact@v1
with:
name: darwin-x64-${{ matrix.nodeVersion }}_binding.node
path: vendor/darwin-x64-${{ matrix.nodeVersion }}/binding.node
47 changes: 47 additions & 0 deletions .github/workflows/electron-win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Electron Rebuild CI - Windows (x32 & x64)

on: [push, pull_request]

jobs:
build:

runs-on: windows-latest

strategy:
matrix:
electron:
- 5
- 6
- 7
- 8
include:
# includes a new variable for each electron (essentially a switch statement)
- electron: 5
nodeVersion: 70
- electron: 6
nodeVersion: 73
- electron: 7
nodeVersion: 75
- electron: 8
nodeVersion: 76
arch:
- ia32
- x64

steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
os: ${{ matrix.os }}
- name: Install packages
run: npm install --unsafe-perm
env:
SKIP_SASS_BINARY_DOWNLOAD_FOR_CI: true
- name: Run build (electron force)
run: node ./scripts/build --electron-version=${{ matrix.electron }}.0.0 --target_arch=${{ matrix.arch }}
- name: Check success by getting binary
uses: actions/upload-artifact@v1
with:
name: win32-${{ matrix.arch }}-${{ matrix.nodeVersion }}_binding.pdb
path: vendor/win32-${{ matrix.arch }}-${{ matrix.nodeVersion }}/binding.node
48 changes: 37 additions & 11 deletions lib/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function getHumanArchitecture(arch) {
* @api public
*/
function getHumanNodeVersion(abi) {
switch (parseInt(abi || process.versions.modules, 10)) {
switch (parseInt(abi || getModuleVersion(), 10)) {
case 11: return 'Node 0.10.x';
case 14: return 'Node 0.12.x';
case 42: return 'io.js 1.x';
Expand All @@ -77,7 +77,11 @@ function getHumanNodeVersion(abi) {
case 59: return 'Node.js 9.x';
case 64: return 'Node.js 10.x';
case 67: return 'Node.js 11.x';
case 70: return 'Electron 5.x';
case 72: return 'Node.js 12.x';
case 73: return 'Electron 6.x';
case 75: return 'Electron 7.x';
case 76: return 'Electron 8.x';
case 79: return 'Node.js 13.x';
default: return false;
}
Expand Down Expand Up @@ -181,7 +185,7 @@ function getArgument(name, args) {
* @api public
*/

function getBinaryName() {
function getBinaryName(arch) {
var binaryName,
variant,
platform = process.platform;
Expand All @@ -202,8 +206,8 @@ function getBinaryName() {

binaryName = [
platform, '-',
process.arch, '-',
process.versions.modules
arch || process.arch, '-',
getModuleVersion()
].join('');
}

Expand Down Expand Up @@ -240,10 +244,10 @@ function getBinaryName() {

function getBinaryUrl() {
var site = getArgument('--sass-binary-site') ||
process.env.SASS_BINARY_SITE ||
process.env.npm_config_sass_binary_site ||
(pkg.nodeSassConfig && pkg.nodeSassConfig.binarySite) ||
'https://github.com/sass/node-sass/releases/download';
process.env.SASS_BINARY_SITE ||
process.env.npm_config_sass_binary_site ||
(pkg.nodeSassConfig && pkg.nodeSassConfig.binarySite) ||
'https://github.com/sass/node-sass/releases/download';

return [site, 'v' + pkg.version, getBinaryName()].join('/');
}
Expand Down Expand Up @@ -294,7 +298,7 @@ function getBinaryDir() {
* @api public
*/

function getBinaryPath() {
function getBinaryPath(arch) {
var binaryPath;

if (getArgument('--sass-binary-path')) {
Expand All @@ -306,7 +310,7 @@ function getBinaryPath() {
} else if (pkg.nodeSassConfig && pkg.nodeSassConfig.binaryPath) {
binaryPath = pkg.nodeSassConfig.binaryPath;
} else {
binaryPath = path.join(getBinaryDir(), getBinaryName().replace(/_(?=binding\.node)/, '/'));
binaryPath = path.join(getBinaryDir(), getBinaryName(arch).replace(/_(?=binding\.node)/, '/'));
}

try {
Expand All @@ -326,7 +330,7 @@ function getCachePathCandidates() {
return [
process.env.npm_config_sass_binary_cache,
process.env.npm_config_cache,
].filter(function(_) { return _; });
].filter(function (_) { return _; });
}

/**
Expand Down Expand Up @@ -437,6 +441,28 @@ function getPlatformVariant() {
return '';
}

/**
* Gets the module version based on possible argment
*
* @api private
*/

function getModuleVersion() {
const electronVersion = process.argv.slice(2).filter(function (item) { return item.substring(0, 18) === '--electron-version'; });
if (electronVersion.length) {
switch (electronVersion[0].substring(19).split('.')[0]) {
case '5': return 70;
case '6': return 73;
case '7': return 75;
case '8': return 76;
default:
throw new Error('We can only target electron versions 5-8');
}
}

return process.versions.modules;
}

module.exports.hasBinary = hasBinary;
module.exports.getBinaryUrl = getBinaryUrl;
module.exports.getBinaryName = getBinaryName;
Expand Down
21 changes: 14 additions & 7 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ var fs = require('fs'),
*/

function afterBuild(options) {
var install = sass.getBinaryPath();
var install = sass.getBinaryPath(options.arch);
var target = path.join(__dirname, '..', 'build',
options.debug ? 'Debug' :
process.config.target_defaults
? process.config.target_defaults.default_configuration
? process.config.target_defaults.default_configuration
: 'Release',
'binding.node');

Expand Down Expand Up @@ -58,23 +58,27 @@ function afterBuild(options) {

function build(options) {
var args = [require.resolve(path.join('node-gyp', 'bin', 'node-gyp.js')), 'rebuild', '--verbose'].concat(
['libsass_ext', 'libsass_cflags', 'libsass_ldflags', 'libsass_library'].map(function(subject) {
['libsass_ext', 'libsass_cflags', 'libsass_ldflags', 'libsass_library'].map(function (subject) {
return ['--', subject, '=', process.env[subject.toUpperCase()] || ''].join('');
})).concat(options.args);

if (process.versions.electron || options.electronVersion) {
args.push('--target=' + (process.versions.electron || options.electronVersion), '--dist-url=https://electronjs.org/headers');
}

console.log('Building:', [process.execPath].concat(args).join(' '));

var proc = spawn(process.execPath, args, {
stdio: [0, 1, 2]
stdio: 'inherit'
});

proc.on('exit', function(errorCode) {
proc.on('exit', function (errorCode) {
if (!errorCode) {
afterBuild(options);
return;
}

if (errorCode === 127 ) {
if (errorCode === 127) {
console.error('node-gyp not found!');
} else {
console.error('Build failed with error code:', errorCode);
Expand All @@ -98,7 +102,7 @@ function parseArgs(args) {
force: process.env.npm_config_force === 'true',
};

options.args = args.filter(function(arg) {
options.args = args.filter(function (arg) {
if (arg === '-f' || arg === '--force') {
options.force = true;
return false;
Expand All @@ -108,6 +112,9 @@ function parseArgs(args) {
options.debug = true;
} else if (arg.substring(0, 13) === '--libsass_ext' && arg.substring(14) !== 'no') {
options.libsassExt = true;
} else if (arg.substring(0, 18) === '--electron-version') {
options.electronVersion = arg.substring(19);
return false;
}

return true;
Expand Down