Skip to content

Commit

Permalink
dep(dev)!: bump @cordova/eslint-config@^4.0.0 w/ fix (#888)
Browse files Browse the repository at this point in the history
* dep!(dev): @cordova/eslint-config@^4.0.0
* chore: apply eslint auto fix
* fix(lint): use const where possible
* fix(lint): remove empty block statement
* chore: rebuild package-lock
* test: fix accidental change from manual lint fix
* test(remove.spec): convert map to forEach
  • Loading branch information
erisu authored Nov 2, 2021
1 parent f33540d commit a4c6d5c
Show file tree
Hide file tree
Showing 76 changed files with 2,926 additions and 2,201 deletions.
2 changes: 1 addition & 1 deletion cordova-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
under the License.
*/

var common = require('cordova-common');
const common = require('cordova-common');

exports = module.exports = {
set binname (name) {
Expand Down
14 changes: 7 additions & 7 deletions integration-tests/fetch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
under the License.
*/

var path = require('path');
var fs = require('fs-extra');
var helpers = require('../spec/helpers');
var cordova = require('../src/cordova/cordova');
const path = require('path');
const fs = require('fs-extra');
const helpers = require('../spec/helpers');
const cordova = require('../src/cordova/cordova');

const TIMEOUT = 60 * 1000;
var plugins_dir = path.join(__dirname, '..', 'spec', 'plugman', 'plugins');
const plugins_dir = path.join(__dirname, '..', 'spec', 'plugman', 'plugins');

var plugins = {
const plugins = {
Test1: path.join(plugins_dir, 'dependencies', 'Test1'),
Test2: path.join(plugins_dir, 'dependencies', 'Test2'),
Test3: path.join(plugins_dir, 'dependencies', 'Test3'),
Expand All @@ -47,7 +47,7 @@ describe('end-to-end plugin dependency tests', function () {
fs.removeSync(preparedProject);
});

var tmpDir, project, pluginsDir;
let tmpDir, project, pluginsDir;
beforeEach(function () {
tmpDir = helpers.tmpDir('plugin_dependency_test');
project = path.join(tmpDir, 'project');
Expand Down
74 changes: 37 additions & 37 deletions integration-tests/plugin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,42 @@
under the License.
*/

var fs = require('fs-extra');
var helpers = require('../spec/helpers');
var path = require('path');
var events = require('cordova-common').events;
var cordova = require('../src/cordova/cordova');
var platforms = require('../src/platforms/platforms');
var plugman = require('../src/plugman/plugman');
var install = require('../src/plugman/install');
var plugin_util = require('../src/cordova/plugin/util');
const fs = require('fs-extra');
const helpers = require('../spec/helpers');
const path = require('path');
const events = require('cordova-common').events;
const cordova = require('../src/cordova/cordova');
const platforms = require('../src/platforms/platforms');
const plugman = require('../src/plugman/plugman');
const install = require('../src/plugman/install');
const plugin_util = require('../src/cordova/plugin/util');
const HooksRunner = require('../src/hooks/HooksRunner');

var util = require('../src/cordova/util');
const util = require('../src/cordova/util');

var tmpDir = helpers.tmpDir('plugin_test');
var preparedProject = path.join(tmpDir, 'prepared-project');
var project = path.join(tmpDir, 'project');
var fixturesDir = path.join(__dirname, '..', 'spec', 'cordova', 'fixtures');
var pluginsDir = path.join(fixturesDir, 'plugins');
const tmpDir = helpers.tmpDir('plugin_test');
const preparedProject = path.join(tmpDir, 'prepared-project');
const project = path.join(tmpDir, 'project');
const fixturesDir = path.join(__dirname, '..', 'spec', 'cordova', 'fixtures');
const pluginsDir = path.join(fixturesDir, 'plugins');

var pluginId = 'org.apache.cordova.fakeplugin1';
var org_test_defaultvariables = 'org.test.defaultvariables';
const pluginId = 'org.apache.cordova.fakeplugin1';
const org_test_defaultvariables = 'org.test.defaultvariables';

// This plugin is published to npm and defines cordovaDependencies
// in its package.json. Based on the dependencies and the version of
// cordova-android installed in our test project, the CLI should
// select version 1.1.2 of the plugin. We don't actually fetch from
// npm, but we do check the npm info.
var npmInfoTestPlugin = 'cordova-lib-test-plugin';
var npmInfoTestPluginVersion = '1.1.2';
const npmInfoTestPlugin = 'cordova-lib-test-plugin';
const npmInfoTestPluginVersion = '1.1.2';

var scopedTestPlugin = '@cordova/plugin-test-dummy';
const scopedTestPlugin = '@cordova/plugin-test-dummy';

var testGitPluginRepository = 'https://github.com/apache/cordova-plugin-device.git';
var testGitPluginId = 'cordova-plugin-device';
const testGitPluginRepository = 'https://github.com/apache/cordova-plugin-device.git';
const testGitPluginId = 'cordova-plugin-device';

var results;
let results;

// Runs: list, add, list
function addPlugin (target, id, options) {
Expand Down Expand Up @@ -89,7 +89,7 @@ function removePlugin (id) {
// The searchpath behavior gets tested in the plugman spec
function mockPluginFetch (id, dir) {
spyOn(plugman, 'fetch').and.callFake(function (target, pluginPath, fetchOptions) {
var dest = path.join(project, 'plugins', id);
const dest = path.join(project, 'plugins', id);

fs.copySync(path.join(dir, 'plugin.xml'), path.join(dest, 'plugin.xml'));
return Promise.resolve(dest);
Expand Down Expand Up @@ -135,11 +135,11 @@ describe('plugin end-to-end', function () {
it('Test 004 : should successfully add a plugin using relative path when running from subdir inside of project', function () {
// Copy plugin to subdir inside of the project. This is required since path.relative
// returns an absolute path when source and dest are on different drives
var plugindir = path.join(project, 'custom-plugins/some-plugin-inside-subfolder');
const plugindir = path.join(project, 'custom-plugins/some-plugin-inside-subfolder');
fs.copySync(path.join(pluginsDir, 'fake1'), plugindir);

// Create a subdir, where we're going to run cordova from
var subdir = path.join(project, 'bin');
const subdir = path.join(project, 'bin');
fs.ensureDirSync(subdir);
process.chdir(subdir);

Expand All @@ -151,13 +151,13 @@ describe('plugin end-to-end', function () {
}, 30000);

it('Test 005 : should respect preference default values', function () {
var plugin_util = require('../src/cordova/plugin/util');
const plugin_util = require('../src/cordova/plugin/util');
spyOn(plugin_util, 'mergeVariables').and.returnValue({ REQUIRED: 'NO', REQUIRED_ANDROID: 'NO' });
return addPlugin(path.join(pluginsDir, org_test_defaultvariables), org_test_defaultvariables, { cli_variables: { REQUIRED: 'NO', REQUIRED_ANDROID: 'NO' } })
.then(function () {
var platformJsonPath = path.join(project, 'plugins', helpers.testPlatform + '.json');
var installed_plugins = require(platformJsonPath).installed_plugins;
var defaultPluginPreferences = installed_plugins[org_test_defaultvariables];
const platformJsonPath = path.join(project, 'plugins', helpers.testPlatform + '.json');
const installed_plugins = require(platformJsonPath).installed_plugins;
const defaultPluginPreferences = installed_plugins[org_test_defaultvariables];
expect(defaultPluginPreferences).toBeDefined();
expect(defaultPluginPreferences.DEFAULT).toBe('yes');
expect(defaultPluginPreferences.DEFAULT_ANDROID).toBe('yes');
Expand All @@ -177,7 +177,7 @@ describe('plugin end-to-end', function () {
return addPlugin(npmInfoTestPlugin, npmInfoTestPlugin, { searchpath: pluginsDir })
.then(function () {
expect(plugin_util.info).not.toHaveBeenCalled();
var fetchOptions = plugman.fetch.calls.mostRecent().args[2];
const fetchOptions = plugman.fetch.calls.mostRecent().args[2];
expect(fetchOptions.searchpath[0]).toExist();
});
}, 30000);
Expand All @@ -190,7 +190,7 @@ describe('plugin end-to-end', function () {
.then(function () {
expect(plugin_util.info).not.toHaveBeenCalled();

var fetchOptions = plugman.fetch.calls.mostRecent().args[2];
const fetchOptions = plugman.fetch.calls.mostRecent().args[2];
expect(fetchOptions.noregistry).toBeTruthy();
});
}, 30000);
Expand Down Expand Up @@ -220,7 +220,7 @@ describe('plugin end-to-end', function () {
.then(function () {
expect(plugin_util.info).toHaveBeenCalled();

var fetchTarget = plugman.fetch.calls.mostRecent().args[0];
const fetchTarget = plugman.fetch.calls.mostRecent().args[0];
expect(fetchTarget).toEqual(npmInfoTestPlugin + '@' + npmInfoTestPluginVersion);
});
}, 30000);
Expand All @@ -236,21 +236,21 @@ describe('plugin end-to-end', function () {

expect(plugin_util.info).toHaveBeenCalledWith([scopedTestPlugin]);

var fetchTarget = plugman.fetch.calls.mostRecent().args[0];
const fetchTarget = plugman.fetch.calls.mostRecent().args[0];
expect(fetchTarget).toEqual(scopedTestPlugin);
});
}, 30000);

it('Test 012 : should handle scoped npm packages with given version tags', function () {
var scopedPackage = scopedTestPlugin + '@latest';
const scopedPackage = scopedTestPlugin + '@latest';
mockPluginFetch(scopedTestPlugin, path.join(pluginsDir, scopedTestPlugin));

spyOn(plugin_util, 'info');
return addPlugin(scopedPackage, scopedTestPlugin, {})
.then(function () {
expect(plugin_util.info).not.toHaveBeenCalled();

var fetchTarget = plugman.fetch.calls.mostRecent().args[0];
const fetchTarget = plugman.fetch.calls.mostRecent().args[0];
expect(fetchTarget).toEqual(scopedPackage);
});
}, 30000);
Expand All @@ -263,7 +263,7 @@ describe('plugin end-to-end', function () {
.then(() => {
expect(plugin_util.info).toHaveBeenCalledWith([scopedTestPlugin]);

var fetchTarget = plugman.fetch.calls.mostRecent().args[0];
const fetchTarget = plugman.fetch.calls.mostRecent().args[0];
expect(fetchTarget).toEqual(scopedTestPlugin);

return removePlugin(scopedTestPlugin);
Expand Down
34 changes: 17 additions & 17 deletions integration-tests/plugman_fetch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@
specific language governing permissions and limitations
under the License.
*/
var rewire = require('rewire');
var fetch = rewire('../src/plugman/fetch');
var fs = require('fs-extra');
var os = require('os');
var path = require('path');
var metadata = require('../src/plugman/util/metadata');
var temp = path.join(os.tmpdir(), 'plugman', 'fetch');
var plugins_dir = path.join(__dirname, '..', 'spec', 'plugman', 'plugins');
var test_plugin = path.join(plugins_dir, 'org.test.plugins.childbrowser');
var test_pkgjson_plugin = path.join(plugins_dir, 'pkgjson-test-plugin');
var test_plugin_searchpath = path.join(test_plugin, '..');
var test_plugin_id = 'org.test.plugins.childbrowser';
var test_plugin_version = '0.6.0';
const rewire = require('rewire');
const fetch = rewire('../src/plugman/fetch');
const fs = require('fs-extra');
const os = require('os');
const path = require('path');
const metadata = require('../src/plugman/util/metadata');
const temp = path.join(os.tmpdir(), 'plugman', 'fetch');
const plugins_dir = path.join(__dirname, '..', 'spec', 'plugman', 'plugins');
let test_plugin = path.join(plugins_dir, 'org.test.plugins.childbrowser');
const test_pkgjson_plugin = path.join(plugins_dir, 'pkgjson-test-plugin');
const test_plugin_searchpath = path.join(test_plugin, '..');
const test_plugin_id = 'org.test.plugins.childbrowser';
const test_plugin_version = '0.6.0';
const { asymmetricMatchers: { pathNormalizingTo } } = require('../spec/helpers');

describe('fetch', function () {
describe('local plugins', function () {
var sym;
let sym;

beforeEach(function () {
fs.removeSync(temp);
Expand Down Expand Up @@ -102,7 +102,7 @@ describe('fetch', function () {
});
});
it('Test 007 : should succeed when the plugin version specified is correct', function () {
var exp_id = test_plugin_id + '@' + test_plugin_version;
const exp_id = test_plugin_id + '@' + test_plugin_version;
return fetch(test_plugin, temp, { expected_id: exp_id }).then(function () {
expect().nothing();
});
Expand All @@ -122,8 +122,8 @@ describe('fetch', function () {
});

describe('fetch recursive error CB-8809', function () {
var srcDir = path.join(plugins_dir, 'recursivePlug');
var appDir = path.join(plugins_dir, 'recursivePlug', 'demo');
const srcDir = path.join(plugins_dir, 'recursivePlug');
const appDir = path.join(plugins_dir, 'recursivePlug', 'demo');
fetch.__set__('fetch', function (pluginDir) {
return Promise.resolve(pluginDir);
});
Expand Down
Loading

0 comments on commit a4c6d5c

Please sign in to comment.