refactor!: do not copy JS lib to platform project (#1269)

This commit is contained in:
Raphael von der Grün 2021-07-13 11:01:50 +02:00 committed by GitHub
parent f6d1deeff6
commit 16ff6e1b2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
105 changed files with 89 additions and 75 deletions

View File

@ -1,3 +1,3 @@
bin/templates/project/assets/www/cordova.js templates/project/assets/www/cordova.js
test/android/app test/android/app
test/androidx/app test/androidx/app

View File

@ -1,5 +1,5 @@
*.properties *.properties
bin templates
gen gen
proguard-project.txt proguard-project.txt
spec spec

View File

@ -28,13 +28,13 @@ const VERSION = '10.0.0-dev';
var path = require('path'); var path = require('path');
var AndroidProject = require('./lib/AndroidProject'); var AndroidProject = require('./AndroidProject');
var PluginManager = require('cordova-common').PluginManager; var PluginManager = require('cordova-common').PluginManager;
var CordovaLogger = require('cordova-common').CordovaLogger; var CordovaLogger = require('cordova-common').CordovaLogger;
var selfEvents = require('cordova-common').events; var selfEvents = require('cordova-common').events;
var ConfigParser = require('cordova-common').ConfigParser; var ConfigParser = require('cordova-common').ConfigParser;
const prepare = require('./lib/prepare').prepare; const prepare = require('./prepare').prepare;
var PLATFORM = 'android'; var PLATFORM = 'android';
@ -86,7 +86,7 @@ class Api {
javaSrc: path.join(appMain, 'java') javaSrc: path.join(appMain, 'java')
}; };
this._builder = require('./lib/builders/builders').getBuilder(this.root); this._builder = require('./builders/builders').getBuilder(this.root);
} }
/** /**
@ -249,8 +249,8 @@ class Api {
build (buildOptions) { build (buildOptions) {
var self = this; var self = this;
return require('./lib/check_reqs').run().then(function () { return require('./check_reqs').run().then(function () {
return require('./lib/build').run.call(self, buildOptions); return require('./build').run.call(self, buildOptions);
}).then(function (buildResults) { }).then(function (buildResults) {
// Cast build result to array of build artifacts // Cast build result to array of build artifacts
return buildResults.paths.map(function (apkPath) { return buildResults.paths.map(function (apkPath) {
@ -278,8 +278,8 @@ class Api {
*/ */
run (runOptions) { run (runOptions) {
var self = this; var self = this;
return require('./lib/check_reqs').run().then(function () { return require('./check_reqs').run().then(function () {
return require('./lib/run').run.call(self, runOptions); return require('./run').run.call(self, runOptions);
}); });
} }
@ -297,10 +297,10 @@ class Api {
cleanOptions = {}; cleanOptions = {};
} }
return require('./lib/check_reqs').run().then(function () { return require('./check_reqs').run().then(function () {
return require('./lib/build').runClean.call(self, cleanOptions); return require('./build').runClean.call(self, cleanOptions);
}).then(function () { }).then(function () {
return require('./lib/prepare').clean.call(self, cleanOptions); return require('./prepare').clean.call(self, cleanOptions);
}); });
} }
@ -313,7 +313,7 @@ class Api {
* objects for current platform. * objects for current platform.
*/ */
requirements () { requirements () {
return require('./lib/check_reqs').check_all(this.root); return require('./check_reqs').check_all(this.root);
} }
/** /**
@ -338,7 +338,7 @@ class Api {
events = setupEvents(events); events = setupEvents(events);
var result; var result;
try { try {
result = require('../../lib/create').create(destination, config, options, events).then(function (destination) { result = require('./create').create(destination, config, options, events).then(function (destination) {
return new Api(PLATFORM, destination, events); return new Api(PLATFORM, destination, events);
}); });
} catch (e) { } catch (e) {

View File

@ -160,7 +160,7 @@ class ProjectBuilder {
// Makes the project buildable, minus the gradle wrapper. // Makes the project buildable, minus the gradle wrapper.
prepBuildFiles () { prepBuildFiles () {
// Update the version of build.gradle in each dependent library. // Update the version of build.gradle in each dependent library.
var pluginBuildGradle = path.join(this.root, 'cordova', 'lib', 'plugin-build.gradle'); var pluginBuildGradle = path.join(__dirname, 'plugin-build.gradle');
var propertiesObj = this.readProjectProperties(); var propertiesObj = this.readProjectProperties();
var subProjects = propertiesObj.libs; var subProjects = propertiesObj.libs;

View File

@ -19,13 +19,13 @@
var path = require('path'); var path = require('path');
var fs = require('fs-extra'); var fs = require('fs-extra');
var utils = require('../templates/cordova/lib/utils'); var utils = require('./utils');
var check_reqs = require('./../templates/cordova/lib/check_reqs'); var check_reqs = require('./check_reqs');
var ROOT = path.join(__dirname, '..', '..'); var ROOT = path.join(__dirname, '..');
const { createEditor } = require('properties-parser'); const { createEditor } = require('properties-parser');
var CordovaError = require('cordova-common').CordovaError; var CordovaError = require('cordova-common').CordovaError;
var AndroidManifest = require('../templates/cordova/lib/AndroidManifest'); var AndroidManifest = require('./AndroidManifest');
// Export all helper functions, and make sure internally within this module, we // Export all helper functions, and make sure internally within this module, we
// reference these methods via the `exports` object - this helps with testing // reference these methods via the `exports` object - this helps with testing
@ -45,7 +45,7 @@ function getFrameworkDir (projectPath, shared) {
function copyJsAndLibrary (projectPath, shared, projectName, targetAPI) { function copyJsAndLibrary (projectPath, shared, projectName, targetAPI) {
var nestedCordovaLibPath = getFrameworkDir(projectPath, false); var nestedCordovaLibPath = getFrameworkDir(projectPath, false);
var srcCordovaJsPath = path.join(ROOT, 'bin', 'templates', 'project', 'assets', 'www', 'cordova.js'); var srcCordovaJsPath = path.join(ROOT, 'templates', 'project', 'assets', 'www', 'cordova.js');
var app_path = path.join(projectPath, 'app', 'src', 'main'); var app_path = path.join(projectPath, 'app', 'src', 'main');
const platform_www = path.join(projectPath, 'platform_www'); const platform_www = path.join(projectPath, 'platform_www');
@ -89,7 +89,7 @@ function extractSubProjectPaths (data) {
function writeProjectProperties (projectPath, target_api) { function writeProjectProperties (projectPath, target_api) {
var dstPath = path.join(projectPath, 'project.properties'); var dstPath = path.join(projectPath, 'project.properties');
var templatePath = path.join(ROOT, 'bin', 'templates', 'project', 'project.properties'); var templatePath = path.join(ROOT, 'templates', 'project', 'project.properties');
var srcPath = fs.existsSync(dstPath) ? dstPath : templatePath; var srcPath = fs.existsSync(dstPath) ? dstPath : templatePath;
var data = fs.readFileSync(srcPath, 'utf8'); var data = fs.readFileSync(srcPath, 'utf8');
@ -113,12 +113,12 @@ function writeProjectProperties (projectPath, target_api) {
// This makes no sense, what if you're building with a different build system? // This makes no sense, what if you're building with a different build system?
function prepBuildFiles (projectPath) { function prepBuildFiles (projectPath) {
var buildModule = require('../templates/cordova/lib/builders/builders'); var buildModule = require('./builders/builders');
buildModule.getBuilder(projectPath).prepBuildFiles(); buildModule.getBuilder(projectPath).prepBuildFiles();
} }
function copyBuildRules (projectPath, isLegacy) { function copyBuildRules (projectPath, isLegacy) {
var srcDir = path.join(ROOT, 'bin', 'templates', 'project'); var srcDir = path.join(ROOT, 'templates', 'project');
if (isLegacy) { if (isLegacy) {
// The project's build.gradle is identical to the earlier build.gradle, so it should still work // The project's build.gradle is identical to the earlier build.gradle, so it should still work
@ -134,16 +134,12 @@ function copyBuildRules (projectPath, isLegacy) {
} }
function copyScripts (projectPath) { function copyScripts (projectPath) {
var bin = path.join(ROOT, 'bin'); var srcScriptsDir = path.join(ROOT, 'templates', 'cordova');
var srcScriptsDir = path.join(bin, 'templates', 'cordova');
var destScriptsDir = path.join(projectPath, 'cordova'); var destScriptsDir = path.join(projectPath, 'cordova');
// Delete old scripts directory if this is an update. // Delete old scripts directory if this is an update.
fs.removeSync(destScriptsDir); fs.removeSync(destScriptsDir);
// Copy in the new ones. // Copy in the new ones.
fs.copySync(srcScriptsDir, destScriptsDir); fs.copySync(srcScriptsDir, destScriptsDir);
const nodeModulesDir = path.join(ROOT, 'node_modules');
if (fs.existsSync(nodeModulesDir)) fs.copySync(nodeModulesDir, path.join(destScriptsDir, 'node_modules'));
} }
/** /**
@ -247,7 +243,7 @@ exports.create = function (project_path, config, options, events) {
events.emit('verbose', 'Copying android template project to ' + project_path); events.emit('verbose', 'Copying android template project to ' + project_path);
var project_template_dir = options.customTemplate || path.join(ROOT, 'bin', 'templates', 'project'); var project_template_dir = options.customTemplate || path.join(ROOT, 'templates', 'project');
var app_path = path.join(project_path, 'app', 'src', 'main'); var app_path = path.join(project_path, 'app', 'src', 'main');
// copy project template // copy project template
@ -300,7 +296,7 @@ exports.create = function (project_path, config, options, events) {
}; };
function generateDoneMessage (type, link) { function generateDoneMessage (type, link) {
var pkg = require('../../package'); var pkg = require('../package');
var msg = 'Android project ' + (type === 'update' ? 'updated ' : 'created ') + 'with ' + pkg.name + '@' + pkg.version; var msg = 'Android project ' + (type === 'update' ? 'updated ' : 'created ') + 'with ' + pkg.name + '@' + pkg.version;
if (link) { if (link) {
msg += ' and has a linked CordovaLib'; msg += ' and has a linked CordovaLib';

View File

@ -21,8 +21,7 @@ const ABS_MODULE_PATH = '/framework/cdv-gradle-config-defaults.json';
try { try {
// Try relative require first, … // Try relative require first, …
const REPO_ROOT = '../../../..'; module.exports = require('..' + ABS_MODULE_PATH);
module.exports = require(REPO_ROOT + ABS_MODULE_PATH);
} catch (error) { } catch (error) {
// … then fall back to installed-package require // … then fall back to installed-package require
if (error.code !== 'MODULE_NOT_FOUND') throw error; if (error.code !== 'MODULE_NOT_FOUND') throw error;

View File

@ -2,7 +2,7 @@
"name": "cordova-android", "name": "cordova-android",
"version": "10.0.0-dev", "version": "10.0.0-dev",
"description": "cordova-android release", "description": "cordova-android release",
"main": "bin/templates/cordova/Api.js", "main": "lib/Api.js",
"repository": "github:apache/cordova-android", "repository": "github:apache/cordova-android",
"bugs": "https://github.com/apache/cordova-android/issues", "bugs": "https://github.com/apache/cordova-android/issues",
"keywords": [ "keywords": [
@ -12,7 +12,7 @@
], ],
"scripts": { "scripts": {
"test": "npm run lint && npm run cover && npm run java-unit-tests", "test": "npm run lint && npm run cover && npm run java-unit-tests",
"lint": "eslint . \"bin/**/!(*.*|gitignore)\"", "lint": "eslint lib spec test \"templates/cordova/**/!(*.*)\"",
"unit-tests": "jasmine --config=spec/unit/jasmine.json", "unit-tests": "jasmine --config=spec/unit/jasmine.json",
"cover": "nyc jasmine --config=spec/coverage.json", "cover": "nyc jasmine --config=spec/coverage.json",
"e2e-tests": "jasmine --config=spec/e2e/jasmine.json", "e2e-tests": "jasmine --config=spec/e2e/jasmine.json",
@ -45,8 +45,7 @@
}, },
"nyc": { "nyc": {
"include": [ "include": [
"bin/lib/**", "lib"
"bin/templates/cordova/**"
], ],
"reporter": [ "reporter": [
"lcov", "lcov",

View File

@ -22,7 +22,7 @@ const fs = require('fs-extra');
const path = require('path'); const path = require('path');
const { EventEmitter } = require('events'); const { EventEmitter } = require('events');
const { ConfigParser, PluginInfoProvider } = require('cordova-common'); const { ConfigParser, PluginInfoProvider } = require('cordova-common');
const Api = require('../../bin/templates/cordova/Api'); const Api = require('../../lib/Api');
function makeTempDir () { function makeTempDir () {
const tmpDirTemplate = path.join(os.tmpdir(), 'cordova-android-test-'); const tmpDirTemplate = path.join(os.tmpdir(), 'cordova-android-test-');
@ -30,7 +30,7 @@ function makeTempDir () {
} }
async function makeProject (projectPath) { async function makeProject (projectPath) {
const configXmlPath = path.join(__dirname, '../../bin/templates/project/res/xml/config.xml'); const configXmlPath = path.join(__dirname, '../../templates/project/res/xml/config.xml');
const config = new ConfigParser(configXmlPath); const config = new ConfigParser(configXmlPath);
config.setPackageName('io.cordova.testapp'); config.setPackageName('io.cordova.testapp');
config.setName('TestApp'); config.setName('TestApp');

View File

@ -38,7 +38,7 @@ describe('Adb', () => {
let execaSpy; let execaSpy;
beforeEach(() => { beforeEach(() => {
Adb = rewire('../../bin/templates/cordova/lib/Adb'); Adb = rewire('../../lib/Adb');
execaSpy = jasmine.createSpy('execa'); execaSpy = jasmine.createSpy('execa');
Adb.__set__('execa', execaSpy); Adb.__set__('execa', execaSpy);
}); });

View File

@ -66,7 +66,7 @@ describe('AndroidManifest', () => {
beforeEach(() => { beforeEach(() => {
createTempManifestFile(DEFAULT_MANIFEST); createTempManifestFile(DEFAULT_MANIFEST);
AndroidManifest = rewire('../../bin/templates/cordova/lib/AndroidManifest'); AndroidManifest = rewire('../../lib/AndroidManifest');
manifest = new AndroidManifest(manifestPath); manifest = new AndroidManifest(manifestPath);
}); });

View File

@ -26,7 +26,7 @@ describe('AndroidProject', () => {
let AndroidStudioSpy; let AndroidStudioSpy;
beforeEach(() => { beforeEach(() => {
AndroidProject = rewire('../../bin/templates/cordova/lib/AndroidProject'); AndroidProject = rewire('../../lib/AndroidProject');
AndroidStudioSpy = jasmine.createSpyObj('AndroidStudio', ['isAndroidStudioProject']); AndroidStudioSpy = jasmine.createSpyObj('AndroidStudio', ['isAndroidStudioProject']);
AndroidProject.__set__('AndroidStudio', AndroidStudioSpy); AndroidProject.__set__('AndroidStudio', AndroidStudioSpy);

View File

@ -22,8 +22,8 @@ var path = require('path');
var common = require('cordova-common'); var common = require('cordova-common');
const EventEmitter = require('events'); const EventEmitter = require('events');
var Api = require('../../bin/templates/cordova/Api'); var Api = require('../../lib/Api');
var AndroidProject = require('../../bin/templates/cordova/lib/AndroidProject'); var AndroidProject = require('../../lib/AndroidProject');
var PluginInfo = common.PluginInfo; var PluginInfo = common.PluginInfo;

View File

@ -26,7 +26,7 @@ describe('android_sdk', () => {
let execaSpy; let execaSpy;
beforeEach(() => { beforeEach(() => {
android_sdk = rewire('../../bin/templates/cordova/lib/android_sdk'); android_sdk = rewire('../../lib/android_sdk');
execaSpy = jasmine.createSpy('execa'); execaSpy = jasmine.createSpy('execa');
android_sdk.__set__('execa', execaSpy); android_sdk.__set__('execa', execaSpy);
}); });

View File

@ -32,7 +32,7 @@ describe('ProjectBuilder', () => {
beforeEach(() => { beforeEach(() => {
execaSpy = jasmine.createSpy('execa').and.returnValue(new Promise(() => {})); execaSpy = jasmine.createSpy('execa').and.returnValue(new Promise(() => {}));
ProjectBuilder = rewire('../../../bin/templates/cordova/lib/builders/ProjectBuilder'); ProjectBuilder = rewire('../../../lib/builders/ProjectBuilder');
ProjectBuilder.__set__('execa', execaSpy); ProjectBuilder.__set__('execa', execaSpy);
builder = new ProjectBuilder(rootDir); builder = new ProjectBuilder(rootDir);

View File

@ -20,13 +20,13 @@
const rewire = require('rewire'); const rewire = require('rewire');
const CordovaError = require('cordova-common').CordovaError; const CordovaError = require('cordova-common').CordovaError;
const ProjectBuilder = require('../../../bin/templates/cordova/lib/builders/ProjectBuilder'); const ProjectBuilder = require('../../../lib/builders/ProjectBuilder');
describe('builders', () => { describe('builders', () => {
let builders; let builders;
beforeEach(() => { beforeEach(() => {
builders = rewire('../../../bin/templates/cordova/lib/builders/builders'); builders = rewire('../../../lib/builders/builders');
}); });
describe('getBuilder', () => { describe('getBuilder', () => {

View File

@ -18,7 +18,7 @@
*/ */
var rewire = require('rewire'); var rewire = require('rewire');
var android_sdk = require('../../bin/templates/cordova/lib/android_sdk'); var android_sdk = require('../../lib/android_sdk');
var fs = require('fs-extra'); var fs = require('fs-extra');
var path = require('path'); var path = require('path');
var events = require('cordova-common').events; var events = require('cordova-common').events;
@ -26,12 +26,12 @@ var which = require('which');
const { const {
SDK_VERSION: DEFAULT_TARGET_API SDK_VERSION: DEFAULT_TARGET_API
} = require('../../bin/templates/cordova/lib/gradle-config-defaults'); } = require('../../lib/gradle-config-defaults');
describe('check_reqs', function () { describe('check_reqs', function () {
let check_reqs; let check_reqs;
beforeEach(() => { beforeEach(() => {
check_reqs = rewire('../../bin/templates/cordova/lib/check_reqs'); check_reqs = rewire('../../lib/check_reqs');
}); });
var original_env; var original_env;

View File

@ -18,7 +18,7 @@
*/ */
const rewire = require('rewire'); const rewire = require('rewire');
const GradlePropertiesParser = rewire('../../../bin/templates/cordova/lib/config/GradlePropertiesParser'); const GradlePropertiesParser = rewire('../../../lib/config/GradlePropertiesParser');
describe('Gradle Builder', () => { describe('Gradle Builder', () => {
describe('_initializeEditor method', () => { describe('_initializeEditor method', () => {

View File

@ -18,9 +18,9 @@
*/ */
var rewire = require('rewire'); var rewire = require('rewire');
var utils = require('../../bin/templates/cordova/lib/utils'); var utils = require('../../lib/utils');
var create = rewire('../../bin/lib/create'); var create = rewire('../../lib/create');
var check_reqs = require('../../bin/templates/cordova/lib/check_reqs'); var check_reqs = require('../../lib/check_reqs');
var fs = require('fs-extra'); var fs = require('fs-extra');
var path = require('path'); var path = require('path');
@ -117,7 +117,7 @@ describe('create', function () {
var revert_manifest_mock; var revert_manifest_mock;
var project_path = path.join('some', 'path'); var project_path = path.join('some', 'path');
var app_path = path.join(project_path, 'app', 'src', 'main'); var app_path = path.join(project_path, 'app', 'src', 'main');
var default_templates = path.join(__dirname, '..', '..', 'bin', 'templates', 'project'); var default_templates = path.join(__dirname, '..', '..', 'templates', 'project');
var fake_android_target = 'android-1337'; var fake_android_target = 'android-1337';
beforeEach(function () { beforeEach(function () {

View File

@ -28,7 +28,7 @@ describe('emulator', () => {
let emu; let emu;
beforeEach(() => { beforeEach(() => {
emu = rewire('../../bin/templates/cordova/lib/emulator'); emu = rewire('../../lib/emulator');
}); });
describe('list_images_using_avdmanager', () => { describe('list_images_using_avdmanager', () => {
@ -376,7 +376,7 @@ describe('emulator', () => {
// If we use Jasmine's fake clock, we need to re-require the target module, // If we use Jasmine's fake clock, we need to re-require the target module,
// or else it will not work. // or else it will not work.
jasmine.clock().install(); jasmine.clock().install();
emu = rewire('../../bin/templates/cordova/lib/emulator'); emu = rewire('../../lib/emulator');
AdbSpy = jasmine.createSpyObj('Adb', ['shell']); AdbSpy = jasmine.createSpyObj('Adb', ['shell']);
emu.__set__('Adb', AdbSpy); emu.__set__('Adb', AdbSpy);

View File

@ -20,11 +20,11 @@
const path = require('path'); const path = require('path');
const rewire = require('rewire'); const rewire = require('rewire');
const { CordovaError } = require('cordova-common'); const { CordovaError } = require('cordova-common');
const utils = require('../../bin/templates/cordova/lib/utils'); const utils = require('../../lib/utils');
const glob = require('fast-glob'); const glob = require('fast-glob');
describe('Java', () => { describe('Java', () => {
const Java = rewire('../../bin/templates/cordova/lib/env/java'); const Java = rewire('../../lib/env/java');
describe('getVersion', () => { describe('getVersion', () => {
beforeEach(() => { beforeEach(() => {

View File

@ -17,7 +17,7 @@
*/ */
var rewire = require('rewire'); var rewire = require('rewire');
var common = rewire('../../../bin/templates/cordova/lib/pluginHandlers'); var common = rewire('../../../lib/pluginHandlers');
var path = require('path'); var path = require('path');
var fs = require('fs-extra'); var fs = require('fs-extra');
var osenv = require('os'); var osenv = require('os');

View File

@ -18,7 +18,7 @@
*/ */
var rewire = require('rewire'); var rewire = require('rewire');
var common = rewire('../../../bin/templates/cordova/lib/pluginHandlers'); var common = rewire('../../../lib/pluginHandlers');
var android = common.__get__('handlers'); var android = common.__get__('handlers');
var path = require('path'); var path = require('path');
var fs = require('fs-extra'); var fs = require('fs-extra');
@ -30,7 +30,7 @@ var faultyplugin = path.join(__dirname, '../../fixtures/org.test.plugins.faultyp
var android_studio_project = path.join(__dirname, '../../fixtures/android_studio_project'); var android_studio_project = path.join(__dirname, '../../fixtures/android_studio_project');
var PluginInfo = require('cordova-common').PluginInfo; var PluginInfo = require('cordova-common').PluginInfo;
var AndroidProject = require('../../../bin/templates/cordova/lib/AndroidProject'); var AndroidProject = require('../../../lib/AndroidProject');
var dummyPluginInfo = new PluginInfo(dummyplugin); var dummyPluginInfo = new PluginInfo(dummyplugin);
var valid_source = dummyPluginInfo.getSourceFiles('android'); var valid_source = dummyPluginInfo.getSourceFiles('android');

View File

@ -20,7 +20,7 @@
var rewire = require('rewire'); var rewire = require('rewire');
var path = require('path'); var path = require('path');
var CordovaError = require('cordova-common').CordovaError; var CordovaError = require('cordova-common').CordovaError;
const GradlePropertiesParser = require('../../bin/templates/cordova/lib/config/GradlePropertiesParser'); const GradlePropertiesParser = require('../../lib/config/GradlePropertiesParser');
const PATH_RESOURCE = path.join('platforms', 'android', 'app', 'src', 'main', 'res'); const PATH_RESOURCE = path.join('platforms', 'android', 'app', 'src', 'main', 'res');
@ -102,7 +102,7 @@ describe('prepare', () => {
let updatePathsSpy; let updatePathsSpy;
beforeEach(() => { beforeEach(() => {
prepare = rewire('../../bin/templates/cordova/lib/prepare'); prepare = rewire('../../lib/prepare');
emitSpy = jasmine.createSpy('emit'); emitSpy = jasmine.createSpy('emit');
prepare.__set__('events', { prepare.__set__('events', {
@ -747,7 +747,7 @@ describe('prepare', () => {
let options; let options;
beforeEach(function () { beforeEach(function () {
Api = rewire('../../bin/templates/cordova/Api'); Api = rewire('../../lib/Api');
cordovaProject = { cordovaProject = {
root: '/mock', root: '/mock',

View File

@ -17,7 +17,7 @@
under the License. under the License.
*/ */
const retry = require('../../bin/templates/cordova/lib/retry'); const retry = require('../../lib/retry');
describe('retry', () => { describe('retry', () => {
describe('retryPromise method', () => { describe('retryPromise method', () => {

View File

@ -18,13 +18,13 @@
*/ */
const rewire = require('rewire'); const rewire = require('rewire');
const builders = require('../../bin/templates/cordova/lib/builders/builders'); const builders = require('../../lib/builders/builders');
describe('run', () => { describe('run', () => {
let run; let run;
beforeEach(() => { beforeEach(() => {
run = rewire('../../bin/templates/cordova/lib/run'); run = rewire('../../lib/run');
run.__set__({ run.__set__({
events: jasmine.createSpyObj('eventsSpy', ['emit']) events: jasmine.createSpyObj('eventsSpy', ['emit'])
}); });

View File

@ -24,7 +24,7 @@ describe('target', () => {
let target; let target;
beforeEach(() => { beforeEach(() => {
target = rewire('../../bin/templates/cordova/lib/target'); target = rewire('../../lib/target');
}); });
describe('list', () => { describe('list', () => {

20
templates/cordova/Api.js vendored Normal file
View File

@ -0,0 +1,20 @@
/**
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
module.exports = require('cordova-android');

View File

@ -19,7 +19,7 @@
under the License. under the License.
*/ */
var android_sdk = require('./lib/android_sdk'); var android_sdk = require('cordova-android/lib/android_sdk');
android_sdk.print_newest_available_sdk_target().catch(err => { android_sdk.print_newest_available_sdk_target().catch(err => {
console.error(err); console.error(err);

View File

@ -19,10 +19,10 @@
under the License. under the License.
*/ */
const { list } = require('./target'); const { list } = require('cordova-android/lib/target');
// Usage support for when args are given // Usage support for when args are given
require('./check_reqs').check_android().then(function () { require('cordova-android/lib/check_reqs').check_android().then(function () {
list().then(targets => { list().then(targets => {
const deviceIds = targets const deviceIds = targets
.filter(({ type }) => type === 'device') .filter(({ type }) => type === 'device')

View File

@ -19,10 +19,10 @@
under the License. under the License.
*/ */
var emulators = require('./emulator'); var emulators = require('cordova-android/lib/emulator');
// Usage support for when args are given // Usage support for when args are given
require('./check_reqs').check_android().then(function () { require('cordova-android/lib/check_reqs').check_android().then(function () {
emulators.list_images().then(function (emulator_list) { emulators.list_images().then(function (emulator_list) {
emulator_list && emulator_list.forEach(function (emu) { emulator_list && emulator_list.forEach(function (emu) {
console.log(emu.name); console.log(emu.name);

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View File

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 78 KiB

View File

Before

Width:  |  Height:  |  Size: 129 KiB

After

Width:  |  Height:  |  Size: 129 KiB

View File

Before

Width:  |  Height:  |  Size: 190 KiB

After

Width:  |  Height:  |  Size: 190 KiB

View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 75 KiB

View File

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 122 KiB

View File

Before

Width:  |  Height:  |  Size: 192 KiB

After

Width:  |  Height:  |  Size: 192 KiB

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 113 B

After

Width:  |  Height:  |  Size: 113 B

View File

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Some files were not shown because too many files have changed in this diff Show More