mirror of
https://github.com/apache/cordova-android.git
synced 2026-05-30 00:00:04 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e188c61c86 | |||
| ca19084b1c | |||
| aea6b7f6f4 | |||
| 7a67e00b9f | |||
| dc4e065f61 | |||
| c3fd6bca4a | |||
| 13bd3f4a9f | |||
| 09c75237d9 | |||
| b5e79b5a4d | |||
| 5db850890d |
@@ -28,22 +28,44 @@
|
|||||||
|
|
||||||
Cordova Android is an Android application library that allows for Cordova-based projects to be built for the Android Platform. Cordova based applications are, at the core, applications written with web technology: HTML, CSS and JavaScript.
|
Cordova Android is an Android application library that allows for Cordova-based projects to be built for the Android Platform. Cordova based applications are, at the core, applications written with web technology: HTML, CSS and JavaScript.
|
||||||
|
|
||||||
[Apache Cordova](https://cordova.apache.org) is a project of The Apache Software Foundation (ASF).
|
[Apache Cordova](https://cordova.apache.org/) is a project of [The Apache Software Foundation (ASF)](https://apache.org/).
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- Java Development Kit (JDK) 11
|
* Java Development Kit (JDK) 11
|
||||||
- [Android SDK](https://developer.android.com/)
|
* [Android SDK](https://developer.android.com/)
|
||||||
|
* [Node.js](https://nodejs.org)
|
||||||
|
|
||||||
## Cordova Android Developer Tools
|
## Create a Cordova project
|
||||||
|
|
||||||
Use the [Cordova command-line tool](https://www.npmjs.com/package/cordova) to create projects and install plugins.
|
Follow the instructions in the [**Create your first Cordova app**](https://cordova.apache.org/docs/en/latest/guide/cli/index.html) section of [Apache Cordova Docs](https://cordova.apache.org/docs/en/latest/)
|
||||||
|
|
||||||
## Using Android Studio
|
To use a **shared framework**, for example in development, link the appropriate cordova-android platform folder path:
|
||||||
|
|
||||||
1. Create a project
|
```bash
|
||||||
2. Import it via "Non-Android Studio Project"
|
cordova platform add --link /path/to/cordova-android
|
||||||
|
```
|
||||||
|
|
||||||
## Running the Native Tests
|
## Updating a Cordova project
|
||||||
|
|
||||||
The `test/` directory in this project contains an Android test project that can be used to run different kinds of native tests. Check out the [README contained therein](test/README.md) for more details!
|
When you install a new version of the [`Cordova CLI`](https://www.npmjs.com/package/cordova) that pins a new version of the [`Cordova-Android`](https://www.npmjs.com/package/cordova-android) platform, you can follow these simple upgrade steps within your project:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cordova platform rm android
|
||||||
|
cordova platform add android
|
||||||
|
```
|
||||||
|
|
||||||
|
## Debugging in Android Studio
|
||||||
|
|
||||||
|
Import project in Android Studio through _File > Open_ and targeting `/path/to/your-cdv-project/platforms/android/`.
|
||||||
|
|
||||||
|
## How to Test Repo Development
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
## Further reading
|
||||||
|
|
||||||
|
* [Apache Cordova](https://cordova.apache.org/)
|
||||||
|
|||||||
@@ -20,6 +20,33 @@
|
|||||||
-->
|
-->
|
||||||
## Release Notes for Cordova (Android)
|
## Release Notes for Cordova (Android)
|
||||||
|
|
||||||
|
### 10.1.1 (Sep 13, 2021)
|
||||||
|
|
||||||
|
**Fixes:**
|
||||||
|
|
||||||
|
* [GH-1349](https://github.com/apache/cordova-android/pull/1349) fix(`PluginManager`): `AllowNavigation` default policy to handle scheme & hostname
|
||||||
|
* [GH-1342](https://github.com/apache/cordova-android/pull/1342) fix(`AllowListPlugin`): Safely handle default allow navigation policy in allow request
|
||||||
|
* [GH-1332](https://github.com/apache/cordova-android/pull/1332) fix(`PluginManager`): `AllowBridgeAccess` default policy to handle scheme & hostname
|
||||||
|
|
||||||
|
### 10.1.0 (Aug 13, 2021)
|
||||||
|
|
||||||
|
**Features:**
|
||||||
|
|
||||||
|
* [GH-1213](https://github.com/apache/cordova-android/pull/1213) feat: unify `create` default values & stop project name transform
|
||||||
|
* [GH-1306](https://github.com/apache/cordova-android/pull/1306) feat: bump `ANDROIDX_APP_COMPAT@1.3.1`
|
||||||
|
* [GH-1303](https://github.com/apache/cordova-android/pull/1303) feat: bump `Google Services Gradle Plugin@4.3.8`
|
||||||
|
* [GH-1302](https://github.com/apache/cordova-android/pull/1302) feat: bump `kotlin@1.5.21`
|
||||||
|
* [GH-1298](https://github.com/apache/cordova-android/pull/1298) feat: support `http` w/ `content` `src` fix
|
||||||
|
|
||||||
|
**Fixes:**
|
||||||
|
|
||||||
|
* [GH-1214](https://github.com/apache/cordova-android/pull/1214) fix: display project name in Android Studio
|
||||||
|
* [GH-1300](https://github.com/apache/cordova-android/pull/1300) fix: fall back to project root `repositories.gradle`
|
||||||
|
|
||||||
|
**Docs:**
|
||||||
|
|
||||||
|
* [GH-1308](https://github.com/apache/cordova-android/pull/1308) doc: update `README` about development & testing
|
||||||
|
|
||||||
### 10.0.1 (Jul 27, 2021)
|
### 10.0.1 (Jul 27, 2021)
|
||||||
|
|
||||||
**Fixes:**
|
**Fixes:**
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"MIN_BUILD_TOOLS_VERSION": "30.0.3",
|
"MIN_BUILD_TOOLS_VERSION": "30.0.3",
|
||||||
"AGP_VERSION": "4.2.2",
|
"AGP_VERSION": "4.2.2",
|
||||||
"KOTLIN_VERSION": "1.5.21",
|
"KOTLIN_VERSION": "1.5.21",
|
||||||
"ANDROIDX_APP_COMPAT_VERSION": "1.3.0",
|
"ANDROIDX_APP_COMPAT_VERSION": "1.3.1",
|
||||||
"ANDROIDX_WEBKIT_VERSION": "1.4.0",
|
"ANDROIDX_WEBKIT_VERSION": "1.4.0",
|
||||||
"GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION": "4.3.8",
|
"GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION": "4.3.8",
|
||||||
"IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED": false,
|
"IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED": false,
|
||||||
|
|||||||
@@ -82,11 +82,6 @@ public class AllowListPlugin extends CordovaPlugin {
|
|||||||
if (strNode.equals("content")) {
|
if (strNode.equals("content")) {
|
||||||
String startPage = xml.getAttributeValue(null, "src");
|
String startPage = xml.getAttributeValue(null, "src");
|
||||||
allowedNavigations.addAllowListEntry(startPage, false);
|
allowedNavigations.addAllowListEntry(startPage, false);
|
||||||
|
|
||||||
// Allow origin for WebViewAssetLoader
|
|
||||||
if (!this.prefs.getBoolean("AndroidInsecureFileModeEnabled", false)) {
|
|
||||||
allowedNavigations.addAllowListEntry("https://" + this.prefs.getString("hostname", "localhost"), false);
|
|
||||||
}
|
|
||||||
} else if (strNode.equals("allow-navigation")) {
|
} else if (strNode.equals("allow-navigation")) {
|
||||||
String origin = xml.getAttributeValue(null, "href");
|
String origin = xml.getAttributeValue(null, "href");
|
||||||
if ("*".equals(origin)) {
|
if ("*".equals(origin)) {
|
||||||
@@ -127,7 +122,7 @@ public class AllowListPlugin extends CordovaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean shouldAllowRequest(String url) {
|
public Boolean shouldAllowRequest(String url) {
|
||||||
return (this.shouldAllowNavigation(url) || this.allowedRequests.isUrlAllowListed(url))
|
return (Boolean.TRUE.equals(this.shouldAllowNavigation(url)) || this.allowedRequests.isUrlAllowListed(url))
|
||||||
? true
|
? true
|
||||||
: null; // default policy
|
: null; // default policy
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import android.webkit.WebChromeClient.CustomViewCallback;
|
|||||||
* are not expected to implement it.
|
* are not expected to implement it.
|
||||||
*/
|
*/
|
||||||
public interface CordovaWebView {
|
public interface CordovaWebView {
|
||||||
public static final String CORDOVA_VERSION = "10.1.0-dev";
|
public static final String CORDOVA_VERSION = "10.1.1";
|
||||||
|
|
||||||
void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences);
|
void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences);
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,12 @@ import android.os.Build;
|
|||||||
*/
|
*/
|
||||||
public class PluginManager {
|
public class PluginManager {
|
||||||
private static String TAG = "PluginManager";
|
private static String TAG = "PluginManager";
|
||||||
|
|
||||||
|
// @todo same as ConfigXmlParser. Research centralizing ideas, maybe create CordovaConstants
|
||||||
|
private static String SCHEME_HTTPS = "https";
|
||||||
|
// @todo same as ConfigXmlParser. Research centralizing ideas, maybe create CordovaConstants
|
||||||
|
private static String DEFAULT_HOSTNAME = "localhost";
|
||||||
|
|
||||||
private static final int SLOW_EXEC_WARNING_THRESHOLD = Debug.isDebuggerConnected() ? 60 : 16;
|
private static final int SLOW_EXEC_WARNING_THRESHOLD = Debug.isDebuggerConnected() ? 60 : 16;
|
||||||
|
|
||||||
// List of service entries
|
// List of service entries
|
||||||
@@ -366,6 +372,24 @@ public class PluginManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo should we move this somewhere public and accessible by all plugins?
|
||||||
|
* For now, it is placed where it is used and kept private so we can decide later and move without causing a breaking change.
|
||||||
|
* An ideal location might be in the "ConfigXmlParser" at the time it generates the "launchUrl".
|
||||||
|
*
|
||||||
|
* @todo should we be restrictive on the "file://" return? e.g. "file:///android_asset/www/"
|
||||||
|
* Would be considered as a breaking change if we apply a more granular check.
|
||||||
|
*/
|
||||||
|
private String getLaunchUrlPrefix() {
|
||||||
|
if (!app.getPreferences().getBoolean("AndroidInsecureFileModeEnabled", false)) {
|
||||||
|
String scheme = app.getPreferences().getString("scheme", SCHEME_HTTPS).toLowerCase();
|
||||||
|
String hostname = app.getPreferences().getString("hostname", DEFAULT_HOSTNAME);
|
||||||
|
return scheme + "://" + hostname + '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
return "file://";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the webview is going to request an external resource.
|
* Called when the webview is going to request an external resource.
|
||||||
*
|
*
|
||||||
@@ -431,7 +455,7 @@ public class PluginManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Default policy:
|
// Default policy:
|
||||||
return url.startsWith("file://") || url.startsWith("about:blank");
|
return url.startsWith(getLaunchUrlPrefix()) || url.startsWith("about:blank");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -452,7 +476,7 @@ public class PluginManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Default policy:
|
// Default policy:
|
||||||
return url.startsWith("file://");
|
return url.startsWith(getLaunchUrlPrefix());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -183,21 +183,29 @@ class ProjectBuilder {
|
|||||||
checkAndCopy(subProjects[i], this.root);
|
checkAndCopy(subProjects[i], this.root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var name = this.extractRealProjectNameFromManifest();
|
var projectName = this.extractRealProjectNameFromManifest();
|
||||||
// Remove the proj.id/name- prefix from projects: https://issues.apache.org/jira/browse/CB-9149
|
// Remove the proj.id/name- prefix from projects: https://issues.apache.org/jira/browse/CB-9149
|
||||||
var settingsGradlePaths = subProjects.map(function (p) {
|
var settingsGradlePaths = subProjects.map(function (p) {
|
||||||
var realDir = p.replace(/[/\\]/g, ':');
|
var realDir = p.replace(/[/\\]/g, ':');
|
||||||
var libName = realDir.replace(name + '-', '');
|
var libName = realDir.replace(projectName + '-', '');
|
||||||
var str = 'include ":' + libName + '"\n';
|
var str = 'include ":' + libName + '"\n';
|
||||||
if (realDir.indexOf(name + '-') !== -1) {
|
if (realDir.indexOf(projectName + '-') !== -1) {
|
||||||
str += 'project(":' + libName + '").projectDir = new File("' + p + '")\n';
|
str += 'project(":' + libName + '").projectDir = new File("' + p + '")\n';
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Update subprojects within settings.gradle.
|
||||||
fs.writeFileSync(path.join(this.root, 'settings.gradle'),
|
fs.writeFileSync(path.join(this.root, 'settings.gradle'),
|
||||||
'// GENERATED FILE - DO NOT EDIT\n' +
|
'// GENERATED FILE - DO NOT EDIT\n' +
|
||||||
'include ":"\n' + settingsGradlePaths.join(''));
|
'apply from: "cdv-gradle-name.gradle"\n' +
|
||||||
|
'include ":"\n' +
|
||||||
|
settingsGradlePaths.join(''));
|
||||||
|
|
||||||
|
// Touch empty cdv-gradle-name.gradle file if missing.
|
||||||
|
if (!fs.pathExistsSync(path.join(this.root, 'cdv-gradle-name.gradle'))) {
|
||||||
|
fs.writeFileSync(path.join(this.root, 'cdv-gradle-name.gradle'), '');
|
||||||
|
}
|
||||||
|
|
||||||
// Update dependencies within build.gradle.
|
// Update dependencies within build.gradle.
|
||||||
var buildGradle = fs.readFileSync(path.join(this.root, 'app', 'build.gradle'), 'utf8');
|
var buildGradle = fs.readFileSync(path.join(this.root, 'app', 'build.gradle'), 'utf8');
|
||||||
@@ -214,7 +222,7 @@ class ProjectBuilder {
|
|||||||
};
|
};
|
||||||
subProjects.forEach(function (p) {
|
subProjects.forEach(function (p) {
|
||||||
events.emit('log', 'Subproject Path: ' + p);
|
events.emit('log', 'Subproject Path: ' + p);
|
||||||
var libName = p.replace(/[/\\]/g, ':').replace(name + '-', '');
|
var libName = p.replace(/[/\\]/g, ':').replace(projectName + '-', '');
|
||||||
if (libName !== 'app') {
|
if (libName !== 'app') {
|
||||||
depsList += ' implementation(project(path: ":' + libName + '"))';
|
depsList += ' implementation(project(path: ":' + libName + '"))';
|
||||||
insertExclude(p);
|
insertExclude(p);
|
||||||
|
|||||||
+4
-20
@@ -37,7 +37,6 @@ exports.copyScripts = copyScripts;
|
|||||||
exports.copyBuildRules = copyBuildRules;
|
exports.copyBuildRules = copyBuildRules;
|
||||||
exports.writeProjectProperties = writeProjectProperties;
|
exports.writeProjectProperties = writeProjectProperties;
|
||||||
exports.prepBuildFiles = prepBuildFiles;
|
exports.prepBuildFiles = prepBuildFiles;
|
||||||
exports.writeNameForAndroidStudio = writeNameForAndroidStudio;
|
|
||||||
|
|
||||||
function getFrameworkDir (projectPath, shared) {
|
function getFrameworkDir (projectPath, shared) {
|
||||||
return shared ? path.join(ROOT, 'framework') : path.join(projectPath, 'CordovaLib');
|
return shared ? path.join(ROOT, 'framework') : path.join(projectPath, 'CordovaLib');
|
||||||
@@ -176,19 +175,6 @@ function validateProjectName (project_name) {
|
|||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Write the name of the app in "platforms/android/.idea/.name" so that Android Studio can show that name in the
|
|
||||||
* project listing. This is helpful to quickly look in the Android Studio listing if there are so many projects in
|
|
||||||
* Android Studio.
|
|
||||||
*
|
|
||||||
* https://github.com/apache/cordova-android/issues/1172
|
|
||||||
*/
|
|
||||||
function writeNameForAndroidStudio (project_path, project_name) {
|
|
||||||
const ideaPath = path.join(project_path, '.idea');
|
|
||||||
fs.ensureDirSync(ideaPath);
|
|
||||||
fs.writeFileSync(path.join(ideaPath, '.name'), project_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an android application with the given options.
|
* Creates an android application with the given options.
|
||||||
*
|
*
|
||||||
@@ -211,15 +197,14 @@ exports.create = function (project_path, config, options, events) {
|
|||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
// Set default values for path, package and name
|
// Set default values for path, package and name
|
||||||
project_path = path.relative(process.cwd(), (project_path || 'CordovaExample'));
|
project_path = path.relative(process.cwd(), project_path);
|
||||||
// Check if project already exists
|
// Check if project already exists
|
||||||
if (fs.existsSync(project_path)) {
|
if (fs.existsSync(project_path)) {
|
||||||
return Promise.reject(new CordovaError('Project already exists! Delete and recreate'));
|
return Promise.reject(new CordovaError('Project already exists! Delete and recreate'));
|
||||||
}
|
}
|
||||||
|
|
||||||
var package_name = config.android_packageName() || config.packageName() || 'my.cordova.project';
|
var package_name = config.android_packageName() || config.packageName() || 'io.cordova.helloCordova';
|
||||||
var project_name = config.name()
|
var project_name = config.name() || 'Hello Cordova';
|
||||||
? config.name().replace(/[^\w.]/g, '_') : 'CordovaExample';
|
|
||||||
|
|
||||||
var safe_activity_name = config.android_activityName() || options.activityName || 'MainActivity';
|
var safe_activity_name = config.android_activityName() || options.activityName || 'MainActivity';
|
||||||
var target_api = check_reqs.get_target(project_path);
|
var target_api = check_reqs.get_target(project_path);
|
||||||
@@ -229,7 +214,7 @@ exports.create = function (project_path, config, options, events) {
|
|||||||
.then(function () {
|
.then(function () {
|
||||||
return exports.validateProjectName(project_name);
|
return exports.validateProjectName(project_name);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
// Log the given values for the project
|
// Log the given values for the project
|
||||||
events.emit('log', 'Creating Cordova project for the Android platform:');
|
events.emit('log', 'Creating Cordova project for the Android platform:');
|
||||||
events.emit('log', '\tPath: ' + project_path);
|
events.emit('log', '\tPath: ' + project_path);
|
||||||
events.emit('log', '\tPackage: ' + package_name);
|
events.emit('log', '\tPackage: ' + package_name);
|
||||||
@@ -286,7 +271,6 @@ exports.create = function (project_path, config, options, events) {
|
|||||||
// Link it to local android install.
|
// Link it to local android install.
|
||||||
exports.writeProjectProperties(project_path, target_api);
|
exports.writeProjectProperties(project_path, target_api);
|
||||||
exports.prepBuildFiles(project_path);
|
exports.prepBuildFiles(project_path);
|
||||||
exports.writeNameForAndroidStudio(project_path, project_name);
|
|
||||||
events.emit('log', generateDoneMessage('create', options.link));
|
events.emit('log', generateDoneMessage('create', options.link));
|
||||||
}).then(() => project_path);
|
}).then(() => project_path);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -273,6 +273,11 @@ function updateProjectAccordingTo (platformConfig, locations) {
|
|||||||
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);
|
events.emit('verbose', 'Wrote out android application name "' + name + '" to ' + locations.strings);
|
||||||
|
|
||||||
|
// Update app name for gradle project
|
||||||
|
fs.writeFileSync(path.join(locations.root, 'cdv-gradle-name.gradle'),
|
||||||
|
'// GENERATED FILE - DO NOT EDIT\n' +
|
||||||
|
'rootProject.name = "' + name.replace(/[/\\:<>"?*|]/g, '_') + '"\n');
|
||||||
|
|
||||||
// Java packages cannot support dashes
|
// Java packages cannot support dashes
|
||||||
var androidPkgName = (platformConfig.android_packageName() || platformConfig.packageName()).replace(/-/g, '_');
|
var androidPkgName = (platformConfig.android_packageName() || platformConfig.packageName()).replace(/-/g, '_');
|
||||||
|
|
||||||
|
|||||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cordova-android",
|
"name": "cordova-android",
|
||||||
"version": "10.1.0-dev",
|
"version": "10.1.1",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cordova-android",
|
"name": "cordova-android",
|
||||||
"version": "10.1.0-dev",
|
"version": "10.1.1",
|
||||||
"description": "cordova-android release",
|
"description": "cordova-android release",
|
||||||
"main": "lib/Api.js",
|
"main": "lib/Api.js",
|
||||||
"repository": "github:apache/cordova-android",
|
"repository": "github:apache/cordova-android",
|
||||||
|
|||||||
@@ -132,7 +132,6 @@ describe('create', function () {
|
|||||||
spyOn(create, 'copyBuildRules');
|
spyOn(create, 'copyBuildRules');
|
||||||
spyOn(create, 'writeProjectProperties');
|
spyOn(create, 'writeProjectProperties');
|
||||||
spyOn(create, 'prepBuildFiles');
|
spyOn(create, 'prepBuildFiles');
|
||||||
spyOn(create, 'writeNameForAndroidStudio');
|
|
||||||
revert_manifest_mock = create.__set__('AndroidManifest', Manifest_mock);
|
revert_manifest_mock = create.__set__('AndroidManifest', Manifest_mock);
|
||||||
spyOn(fs, 'existsSync').and.returnValue(false);
|
spyOn(fs, 'existsSync').and.returnValue(false);
|
||||||
spyOn(fs, 'copySync');
|
spyOn(fs, 'copySync');
|
||||||
@@ -148,10 +147,10 @@ describe('create', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('parameter values and defaults', function () {
|
describe('parameter values and defaults', function () {
|
||||||
it('should have a default package name of my.cordova.project', () => {
|
it('should have a default package name of io.cordova.helloCordova', () => {
|
||||||
config_mock.packageName.and.returnValue(undefined);
|
config_mock.packageName.and.returnValue(undefined);
|
||||||
return create.create(project_path, config_mock, {}, events_mock).then(() => {
|
return create.create(project_path, config_mock, {}, events_mock).then(() => {
|
||||||
expect(create.validatePackageName).toHaveBeenCalledWith('my.cordova.project');
|
expect(create.validatePackageName).toHaveBeenCalledWith('io.cordova.helloCordova');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -162,10 +161,10 @@ describe('create', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a default project name of CordovaExample', () => {
|
it('should have a default project name of Hello Cordova', () => {
|
||||||
config_mock.name.and.returnValue(undefined);
|
config_mock.name.and.returnValue(undefined);
|
||||||
return create.create(project_path, config_mock, {}, events_mock).then(() => {
|
return create.create(project_path, config_mock, {}, events_mock).then(() => {
|
||||||
expect(create.validateProjectName).toHaveBeenCalledWith('CordovaExample');
|
expect(create.validateProjectName).toHaveBeenCalledWith('Hello Cordova');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -176,10 +175,10 @@ describe('create', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should replace any non-word characters (including unicode and spaces) in the ConfigParser-provided project name with underscores', () => {
|
it('should keep non-word characters (including unicode and spaces) in the ConfigParser-provided project name', () => {
|
||||||
config_mock.name.and.returnValue('応応応応 hello 用用用用');
|
config_mock.name.and.returnValue('応応応応 hello 用用用用');
|
||||||
return create.create(project_path, config_mock, {}, events_mock).then(() => {
|
return create.create(project_path, config_mock, {}, events_mock).then(() => {
|
||||||
expect(create.validateProjectName).toHaveBeenCalledWith('_____hello_____');
|
expect(create.validateProjectName).toHaveBeenCalledWith('応応応応 hello 用用用用');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -301,24 +300,4 @@ describe('create', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('writeNameForAndroidStudio', () => {
|
|
||||||
const project_path = path.join('some', 'path');
|
|
||||||
const appName = 'Test Cordova';
|
|
||||||
|
|
||||||
beforeEach(function () {
|
|
||||||
spyOn(fs, 'ensureDirSync');
|
|
||||||
spyOn(fs, 'writeFileSync');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should call ensureDirSync with path', () => {
|
|
||||||
create.writeNameForAndroidStudio(project_path, appName);
|
|
||||||
expect(fs.ensureDirSync).toHaveBeenCalledWith(path.join(project_path, '.idea'));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should call writeFileSync with content', () => {
|
|
||||||
create.writeNameForAndroidStudio(project_path, appName);
|
|
||||||
expect(fs.writeFileSync).toHaveBeenCalledWith(path.join(project_path, '.idea', '.name'), appName);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user