Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Platform Release Preparation (Cordova 9) #612

Merged
merged 7 commits into from
Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ tmp/**/*
*.iml
npm-debug.log
node_modules/
coverage/
.nyc_output/
8 changes: 4 additions & 4 deletions bin/templates/cordova/build
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ buildOpts.argv = buildOpts.argv.original;
require('./loggingHelper').adjustLoggerLevel(buildOpts);

new Api().build(buildOpts)
.catch(function (err) {
console.error(err.stack);
process.exit(2);
});
.catch(function (err) {
console.error(err.stack);
process.exit(2);
});
8 changes: 4 additions & 4 deletions bin/templates/cordova/clean
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ opts.noPrepare = true;
require('./loggingHelper').adjustLoggerLevel(opts);

new Api().clean(opts)
.catch(function (err) {
console.error(err.stack);
process.exit(2);
});
.catch(function (err) {
console.error(err.stack);
process.exit(2);
});
8 changes: 4 additions & 4 deletions bin/templates/cordova/lib/Adb.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function isEmulator (line) {
* devices/emulators
*/
Adb.devices = function (opts) {
return spawn('adb', ['devices'], {cwd: os.tmpdir()}).then(function (output) {
return spawn('adb', ['devices'], { cwd: os.tmpdir() }).then(function (output) {
return output.split('\n').filter(function (line) {
// Filter out either real devices or emulators, depending on options
return (line && opts && opts.emulators) ? isEmulator(line) : isDevice(line);
Expand All @@ -58,7 +58,7 @@ Adb.install = function (target, packagePath, opts) {
events.emit('verbose', 'Installing apk ' + packagePath + ' on target ' + target + '...');
var args = ['-s', target, 'install'];
if (opts && opts.replace) args.push('-r');
return spawn('adb', args.concat(packagePath), {cwd: os.tmpdir()}).then(function (output) {
return spawn('adb', args.concat(packagePath), { cwd: os.tmpdir() }).then(function (output) {
// 'adb install' seems to always returns no error, even if installation fails
// so we catching output to detect installation failure
if (output.match(/Failure/)) {
Expand All @@ -77,14 +77,14 @@ Adb.install = function (target, packagePath, opts) {

Adb.uninstall = function (target, packageId) {
events.emit('verbose', 'Uninstalling package ' + packageId + ' from target ' + target + '...');
return spawn('adb', ['-s', target, 'uninstall', packageId], {cwd: os.tmpdir()});
return spawn('adb', ['-s', target, 'uninstall', packageId], { cwd: os.tmpdir() });
};

Adb.shell = function (target, shellCommand) {
events.emit('verbose', 'Running adb shell command "' + shellCommand + '" on target ' + target + '...');
var args = ['-s', target, 'shell'];
shellCommand = shellCommand.split(/\s+/);
return spawn('adb', args.concat(shellCommand), {cwd: os.tmpdir()}).catch(function (output) {
return spawn('adb', args.concat(shellCommand), { cwd: os.tmpdir() }).catch(function (output) {
return Q.reject(new CordovaError('Failed to execute shell command "' +
shellCommand + '"" on device: ' + output));
});
Expand Down
2 changes: 1 addition & 1 deletion bin/templates/cordova/lib/AndroidManifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ AndroidManifest.prototype.setDebuggable = function (value) {
* manifest will be written to file it has been read from.
*/
AndroidManifest.prototype.write = function (destPath) {
fs.writeFileSync(destPath || this.path, this.doc.write({indent: 4}), 'utf-8');
fs.writeFileSync(destPath || this.path, this.doc.write({ indent: 4 }), 'utf-8');
};

module.exports = AndroidManifest;
Expand Down
4 changes: 2 additions & 2 deletions bin/templates/cordova/lib/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports.install = function (target, buildResults) {
events.emit('log', 'Using apk: ' + apk_path);
events.emit('log', 'Package name: ' + pkgName);

return Adb.install(resolvedTarget.target, apk_path, {replace: true}).catch(function (error) {
return Adb.install(resolvedTarget.target, apk_path, { replace: true }).catch(function (error) {
// CB-9557 CB-10157 only uninstall and reinstall app if the one that
// is already installed on device was signed w/different certificate
if (!/INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES/.test(error.toString())) { throw error; }
Expand All @@ -97,7 +97,7 @@ module.exports.install = function (target, buildResults) {
// This promise is always resolved, even if 'adb uninstall' fails to uninstall app
// or the app doesn't installed at all, so no error catching needed.
return Adb.uninstall(resolvedTarget.target, pkgName).then(function () {
return Adb.install(resolvedTarget.target, apk_path, {replace: true});
return Adb.install(resolvedTarget.target, apk_path, { replace: true });
});
}).then(function () {
// unlock screen
Expand Down
6 changes: 3 additions & 3 deletions bin/templates/cordova/lib/emulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,13 @@ module.exports.best_image = function () {

// Returns a promise.
module.exports.list_started = function () {
return Adb.devices({emulators: true});
return Adb.devices({ emulators: true });
};

// Returns a promise.
// TODO: we should remove this, there's a more robust method under android_sdk.js
module.exports.list_targets = function () {
return superspawn.spawn('android', ['list', 'targets'], {cwd: os.tmpdir()}).then(function (output) {
return superspawn.spawn('android', ['list', 'targets'], { cwd: os.tmpdir() }).then(function (output) {
var target_out = output.split('\n');
var targets = [];
for (var i = target_out.length; i >= 0; i--) {
Expand Down Expand Up @@ -419,7 +419,7 @@ module.exports.resolveTarget = function (target) {
}

return build.detectArchitecture(target).then(function (arch) {
return {target: target, arch: arch, isEmulator: true};
return { target: target, arch: arch, isEmulator: true };
});
});
};
Expand Down
2 changes: 1 addition & 1 deletion bin/templates/cordova/lib/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var ROOT = path.join(__dirname, '..', '..');
*/
module.exports.run = function () {
var d = Q.defer();
var adb = child_process.spawn('adb', ['logcat'], {cwd: os.tmpdir()});
var adb = child_process.spawn('adb', ['logcat'], { cwd: os.tmpdir() });

adb.stdout.on('data', function (data) {
var lines = data ? data.toString().split('\n') : [];
Expand Down
4 changes: 2 additions & 2 deletions bin/templates/cordova/lib/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function updateProjectAccordingTo (platformConfig, locations) {
strings.find('string[@name="launcher_name"]').text = shortName.replace(/\'/g, '\\\'');
}

fs.writeFileSync(locations.strings, strings.write({indent: 4}), 'utf-8');
fs.writeFileSync(locations.strings, strings.write({ indent: 4 }), 'utf-8');
events.emit('verbose', 'Wrote out android application name "' + name + '" to ' + locations.strings);

// Java packages cannot support dashes
Expand Down Expand Up @@ -661,7 +661,7 @@ function cleanFileResources (projectRoot, projectConfig, platformDir) {

FileUpdater.updatePaths(
resourceMap, {
rootDir: projectRoot, all: true}, logFileOp);
rootDir: projectRoot, all: true }, logFileOp);
}
}

Expand Down
8 changes: 4 additions & 4 deletions bin/templates/cordova/run
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ runOpts.argv = runOpts.argv.remain;
require('./loggingHelper').adjustLoggerLevel(runOpts);

new Api().run(runOpts)
.catch(function (err) {
console.error(err, err.stack);
process.exit(2);
});
.catch(function (err) {
console.error(err, err.stack);
process.exit(2);
});
2 changes: 1 addition & 1 deletion bin/update
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ if (args.help || args.argv.remain.length === 0) {

require('./templates/cordova/loggingHelper').adjustLoggerLevel(args);

Api.updatePlatform(args.argv.remain[0], {link: (args.link || args.shared)}).done();
Api.updatePlatform(args.argv.remain[0], { link: (args.link || args.shared) }).done();
52 changes: 29 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,56 @@
"url": "https://github.com/apache/cordova-android"
},
"bugs": {
"url": "https://issues.apache.org/jira/browse/CB"
"url": "https://github.com/apache/cordova-android/issues"
},
"keywords": [
"android",
"cordova",
"apache"
],
"scripts": {
"test": "run-s eslint unit-tests java-unit-tests e2e-tests",
"test": "npm run eslint && npm run cover && npm run java-unit-tests",
"unit-tests": "jasmine --config=spec/unit/jasmine.json",
"cover": "istanbul cover --root bin --print detail jasmine -- --config=spec/unit/jasmine.json",
"cover": "nyc jasmine --config=spec/coverage.json",
"e2e-tests": "jasmine --config=spec/e2e/jasmine.json",
"java-unit-tests": "node test/run_java_unit_tests.js",
"eslint": "run-s -c eslint:*",
"eslint:scripts": "eslint bin spec test",
"eslint:bins": "eslint 'bin/**/*' --ignore-pattern '**/*.*' --ignore-pattern '**/gitignore' --ignore-pattern 'bin/templates/cordova/version'"
"eslint": "eslint bin spec test"
},
"author": "Apache Software Foundation",
"license": "Apache-2.0",
"dependencies": {
"android-versions": "^1.3.0",
"cordova-common": "^3.0.0",
"elementtree": "0.1.6",
"nopt": "^3.0.1",
"properties-parser": "^0.2.3",
"cordova-common": "^3.1.0",
"elementtree": "^0.1.7",
"nopt": "^4.0.1",
"properties-parser": "^0.3.1",
"q": "^1.4.1",
"shelljs": "^0.5.3"
},
"devDependencies": {
"eslint": "^3.19.0",
"eslint-config-semistandard": "^11.0.0",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.3.0",
"eslint-plugin-node": "^5.0.0",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^3.0.1",
"istanbul": "^0.4.2",
"jasmine": "^3.1.0",
"npm-run-all": "^4.1.3",
"promise-matchers": "~0",
"rewire": "^2.1.3"
"eslint": "^5.12.0",
"eslint-config-semistandard": "^13.0.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"jasmine": "^3.3.1",
"nyc": "^13.1.0",
"rewire": "^4.0.1"
},
"engines": {
"node": ">=6.0.0"
},
"engineStrict": true
"engineStrict": true,
"nyc": {
"include": [
"bin/lib/**",
"bin/templates/cordova/**"
],
"reporter": [
"lcov",
"text"
]
}
}
9 changes: 9 additions & 0 deletions spec/coverage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"spec_dir": "spec",
"spec_files": [
"unit/**/*[sS]pec.js",
"e2e/**/*[sS]pec.js"
],
"stopSpecOnExpectationFailure": false,
"random": false
}
2 changes: 1 addition & 1 deletion spec/unit/Adb.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ emulator-5554\tdevice
});

it('should return only emulators if opts.emulators is true', () => {
return Adb.devices({emulators: true}).then(devices => {
return Adb.devices({ emulators: true }).then(devices => {
expect(devices.length).toBe(1);
expect(devices[0]).toBe(emulatorId);
});
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/config/GradlePropertiesParser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('Gradle Builder', () => {

parser = new GradlePropertiesParser('/root');

parser._defaults = {'org.gradle.jvmargs': '-Xmx2048m'};
parser._defaults = { 'org.gradle.jvmargs': '-Xmx2048m' };
});

it('should detect missing default property and sets the property.', () => {
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ describe('create', function () {
});
it('should use the activityName provided via options parameter, if exists', function (done) {
config_mock.android_activityName.and.returnValue(undefined);
create.create(project_path, config_mock, {activityName: 'AwesomeActivity'}, events_mock).then(function () {
create.create(project_path, config_mock, { activityName: 'AwesomeActivity' }, events_mock).then(function () {
expect(Manifest_mock.prototype.setName).toHaveBeenCalledWith('AwesomeActivity');
}).fail(fail).done(done);
});
Expand All @@ -217,7 +217,7 @@ describe('create', function () {
});
describe('happy path', function () {
it('should copy project templates from a specified custom template', function (done) {
create.create(project_path, config_mock, {customTemplate: '/template/path'}, events_mock).then(function () {
create.create(project_path, config_mock, { customTemplate: '/template/path' }, events_mock).then(function () {
expect(shell.cp).toHaveBeenCalledWith('-r', path.join('/template/path', 'assets'), app_path);
expect(shell.cp).toHaveBeenCalledWith('-r', path.join('/template/path', 'res'), app_path);
expect(shell.cp).toHaveBeenCalledWith(path.join('/template/path', 'gitignore'), path.join(project_path, '.gitignore'));
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/emulator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ describe('emulator', () => {
emu.__set__('Adb', AdbSpy);

return emu.list_started().then(() => {
expect(AdbSpy.devices).toHaveBeenCalledWith({emulators: true});
expect(AdbSpy.devices).toHaveBeenCalledWith({ emulators: true });
});
});
});
Expand Down Expand Up @@ -388,9 +388,9 @@ describe('emulator', () => {

it('should call itself again if shell fails for a known reason', () => {
AdbSpy.shell.and.returnValues(
Promise.reject({message: 'device not found'}),
Promise.reject({message: 'device offline'}),
Promise.reject({message: 'device still connecting'}),
Promise.reject({ message: 'device not found' }),
Promise.reject({ message: 'device offline' }),
Promise.reject({ message: 'device still connecting' }),
Promise.resolve('1')
);

Expand Down
Loading