Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-chromium

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-chromium - npm Package Compare versions

Comparing version 3.0.1 to 4.0.0

109

download-chrome.js

@@ -15,6 +15,2 @@ #!/usr/bin/env node

// Check out this issue https://github.com/dtolstyi/node-chromium/issues/1#issuecomment-354456135
const npmPackage = process.env.CHROMIUM_VERSION || '67.0.0';
let versionsWithUnknownBranchingPoint = [];
function getOsCdnUrl () {

@@ -45,82 +41,2 @@ let url = 'https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/';

function getCurrentOs () {
const platform = process.platform;
if (platform === 'linux') {
return 'linux';
}
if (platform === 'win32') {
return 'win';
}
if (platform === 'darwin') {
return 'mac';
}
console.log('Unknown platform found:', process.platform);
throw new Error('Unsupported platform');
}
function getExactChromeVersionNumber () {
return new Promise((resolve, reject) => {
const url = 'https://omahaproxy.appspot.com/history.json?channel=' + (process.env.CHROMIUM_CHANNEL || 'dev') + '&os=' + getCurrentOs();
const packageMajorVersion = npmPackage.split('.')[0];
got(url)
.then(response => {
let versions = JSON.parse(response.body);
for (let version of versions) {
let versionNumber = version.version;
let buildMajorVersion = versionNumber.split('.')[0];
if (buildMajorVersion !== packageMajorVersion) {
continue;
}
if (versionsWithUnknownBranchingPoint.includes(versionNumber)) {
continue;
}
return resolve(versionNumber);
}
}
)
.catch(err => {
console.log('custom loggin');
console.error(err);
console.log('An error occured while trying to retrieve latest revision number', err);
reject(err);
});
});
}
function getChromiumBranchingPoint (versionNumber) {
return new Promise((resolve, reject) => {
const url = 'https://omahaproxy.appspot.com/deps.json?version=' + versionNumber;
got(url)
.then(response => {
let versionDetails = JSON.parse(response.body);
let branchingPoint = parseInt(versionDetails.chromium_base_position);
if (!Number.isInteger(branchingPoint)) {
console.log('Could not find branching point for Chrome ' + versionNumber + '. This can happen when the new Chrome version is just branched off. Let\'s try to find the branching point for one version earlier.');
versionsWithUnknownBranchingPoint.push(versionNumber);
resolve(getExactChromeVersionNumber().then(getChromiumBranchingPoint));
}
console.log('Found that Chrome ' + versionNumber + ' was branched off Chromium at point ' + branchingPoint);
resolve(branchingPoint);
})
.catch(err => {
console.log('Could not get build details for version ' + versionNumber);
reject(err);
});
});
}
function createTempFile () {

@@ -180,16 +96,15 @@ return new Promise((resolve, reject) => {

module.exports = (function () {
const {execPath, binPath} = utils.getBinaryPath();
return utils.getBinaryPath().then(({execPath, binPath, versionNumber }) => {
const exists = fs.existsSync(execPath);
const exists = fs.existsSync(execPath);
if (exists) {
console.log('Chrome is already installed');
} else {
console.log('Chrome is not installed, triggering download');
return getExactChromeVersionNumber()
.then(getChromiumBranchingPoint)
.then(downloadChromiumRevision)
.then(path => unzipArchive(path, binPath))
.catch(err => console.error('An error occurred while trying to setup Chromium. Resolve all issues and restart the process', err));
}
if (exists) {
console.log('Chrome is already installed');
} else {
console.log('Chrome is not installed, triggering download');
return utils.getChromiumBranchingPoint(versionNumber)
.then(downloadChromiumRevision)
.then(path => unzipArchive(path, binPath))
.catch(err => console.error('An error occurred while trying to setup Chromium. Resolve all issues and restart the process', err));
}
});
})();

47

index.js

@@ -20,28 +20,29 @@ /* global require, module */

const {execPath} = utils.getBinaryPath();
if (!fs.existsSync(execPath)) {
console.error('Chromium does not appear to be installed, testem cannot run.'); // eslint-disable-line
process.exit(1); // for some reason this doesn't stop testem from continuing in server mode
throw new Error('Chromium not installed');
}
return utils.getBinaryPath().then(({execPath}) => {
if (!fs.existsSync(execPath)) {
console.error('Chromium does not appear to be installed, testem cannot run.'); // eslint-disable-line
process.exit(1); // for some reason this doesn't stop testem from continuing in server mode
throw new Error('Chromium not installed');
}
return {
test_page: 'tests/index.html?hidepassed',
browser_start_timeout: 60,
launchers: {
chromium: {
exe: execPath,
args: chromiumArgs,
protocol: 'browser'
return {
test_page: 'tests/index.html?hidepassed',
browser_start_timeout: 60,
launchers: {
chromium: {
exe: execPath,
args: chromiumArgs,
protocol: 'browser'
},
chromium_headless: {
exe: execPath,
args: ['--headless', ...chromiumArgs],
protocol: 'browser'
}
},
chromium_headless: {
exe: execPath,
args: ['--headless', ...chromiumArgs],
protocol: 'browser'
}
},
launch_in_ci: ['chromium_headless'],
launch_in_dev: ['chromium']
};
launch_in_ci: ['chromium_headless'],
launch_in_dev: ['chromium']
};
});
}

@@ -48,0 +49,0 @@

{
"name": "ember-chromium",
"version": "3.0.1",
"version": "4.0.0",
"description": "One place to hold all the logic to download and run ember tests in chromium",
"main": "index.js",
"bin": {
"install-chromium": "download-chrome.js"
},
"publishConfig": { "registry": "https://registry.npmjs.org" },
"scripts": {

@@ -7,0 +11,0 @@ "postinstall": "node download-chrome.js",

@@ -6,13 +6,23 @@ # Ember Chromium

## Getting Started
In your `package.json`, add a postinstall hook to run the download chromium script:
```
"scripts": {
...
"pretest": "npm run install-chromium",
"install-chromium": "node node_modules/ember-chromium/download-chrome.js"
}
```
then simply run `npm install` on your project.
1. Install ember-chromium as a dev dependency via npm/yarn
```sh
$ npm install ember-chromium --save-dev
# -or-
$ yarn add ember-chromium --dev
```
1. In your `package.json`, add a `pretest` script to run the `install-chromium` script.
```json
"scripts": {
// ...
"pretest": "npm run install-chromium",
// -or-
"pretest": "yarn run install-chromium",
}
````
[Note:] When installed, ember-chromium links the `install-chromium` script into `<project-root>/node-modules/.bin`. This directory is on the npm/yarn script path and can be called directly.
## Usage

@@ -19,0 +29,0 @@ You can run just the default behavior by doing the following in testem.js:

@@ -6,30 +6,114 @@ #!/usr/bin/env node

const path = require('path');
const got = require('got');
const childProcess = require('child_process');
function getBinaryPath () {
const buffer = childProcess.execSync('npm bin -g');
const result = String.fromCharCode.apply(null, buffer);
const globalPath = result.replace(/\n$/, '');
let binPath = globalPath;
let execPath;
function getCurrentOs () {
const platform = process.platform;
const folderName = getOsChromiumFolderName();
if (platform === 'linux') {
execPath = path.join(binPath, folderName, 'chrome');
} else if (platform === 'win32') {
execPath = path.join(binPath, folderName, 'chrome.exe');
} else if (platform === 'darwin') {
execPath = path.join(binPath, folderName, 'Chromium.app/Contents/MacOS/Chromium');
} else {
console.error('Unsupported platform or architecture found:', process.platform, process.arch);
throw new Error('Unsupported platform');
return 'linux';
}
console.log(`checking for chromium at: ${execPath.toString()}`);
if (platform === 'win32') {
return 'win';
}
return {binPath, execPath};
if (platform === 'darwin') {
return 'mac';
}
console.log('Unknown platform found:', process.platform);
throw new Error('Unsupported platform');
}
const version = process.env.CHROMIUM_VERSION || '67.0.0';
const versionsWithUnknownBranchingPoint = [];
function getExactChromeVersionNumber () {
return new Promise((resolve, reject) => {
const url = 'https://omahaproxy.appspot.com/history.json?channel=' + (process.env.CHROMIUM_CHANNEL || 'dev') + '&os=' + getCurrentOs();
const packageMajorVersion = version.split('.')[0];
got(url)
.then(response => {
let versions = JSON.parse(response.body);
for (let version of versions) {
let versionNumber = version.version;
let buildMajorVersion = versionNumber.split('.')[0];
if (buildMajorVersion !== packageMajorVersion) {
continue;
}
if (versionsWithUnknownBranchingPoint.includes(versionNumber)) {
continue;
}
return resolve(versionNumber);
}
}
)
.catch(err => {
console.log('An error occured while trying to retrieve latest revision number', err);
reject(err);
});
});
}
function getBinaryPath () {
return getExactChromeVersionNumber()
.then(versionNumber => {
const buffer = childProcess.execSync('npm bin -g');
const result = String.fromCharCode.apply(null, buffer);
const globalPath = result.replace(/\n$/, '');
let binPath = path.join(globalPath, 'ember-chromium', versionNumber);
let execPath;
const platform = process.platform;
const folderName = getOsChromiumFolderName();
if (platform === 'linux') {
execPath = path.join(binPath, folderName, 'chrome');
} else if (platform === 'win32') {
execPath = path.join(binPath, folderName, 'chrome.exe');
} else if (platform === 'darwin') {
execPath = path.join(binPath, folderName, 'Chromium.app/Contents/MacOS/Chromium');
} else {
console.error('Unsupported platform or architecture found:', process.platform, process.arch);
throw new Error('Unsupported platform');
}
console.log(`checking for chromium at: ${execPath.toString()}`);
return {binPath, execPath, versionNumber};
});
}
function getChromiumBranchingPoint (versionNumber) {
return new Promise((resolve, reject) => {
const url = 'https://omahaproxy.appspot.com/deps.json?version=' + versionNumber;
got(url)
.then(response => {
let versionDetails = JSON.parse(response.body);
let branchingPoint = parseInt(versionDetails.chromium_base_position);
if (!Number.isInteger(branchingPoint)) {
console.log('Could not find branching point for Chrome ' + versionNumber + '. This can happen when the new Chrome version is just branched off. Let\'s try to find the branching point for one version earlier.');
versionsWithUnknownBranchingPoint.push(versionNumber);
resolve(getExactChromeVersionNumber().then(getChromiumBranchingPoint));
}
console.log('Found that Chrome ' + versionNumber + ' was branched off Chromium at point ' + branchingPoint);
resolve(branchingPoint);
})
.catch(err => {
console.log('Could not get build details for version ' + versionNumber);
reject(err);
});
});
}
function getOsChromiumFolderName () {

@@ -49,3 +133,4 @@ const platform = process.platform;

getBinaryPath,
getOsChromiumFolderName
getOsChromiumFolderName,
getChromiumBranchingPoint
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc