You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by er...@apache.org on 2021/08/13 03:52:40 UTC

[cordova-android] branch master updated: feat: unify `create` default values & stop project name transform (#1213)

This is an automated email from the ASF dual-hosted git repository.

erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-android.git


The following commit(s) were added to refs/heads/master by this push:
     new 13bd3f4  feat: unify `create` default values & stop project name transform (#1213)
13bd3f4 is described below

commit 13bd3f4a9f8541147dcd2e458390cb34774e73bf
Author: Alexis THOMAS <at...@users.noreply.github.com>
AuthorDate: Fri Aug 13 05:52:30 2021 +0200

    feat: unify `create` default values & stop project name transform (#1213)
---
 lib/create.js            |  9 ++++-----
 spec/unit/create.spec.js | 12 ++++++------
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/lib/create.js b/lib/create.js
index e8388d9..fbbcf16 100755
--- a/lib/create.js
+++ b/lib/create.js
@@ -197,15 +197,14 @@ exports.create = function (project_path, config, options, events) {
     options = options || {};
 
     // 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
     if (fs.existsSync(project_path)) {
         return Promise.reject(new CordovaError('Project already exists! Delete and recreate'));
     }
 
-    var package_name = config.android_packageName() || config.packageName() || 'my.cordova.project';
-    var project_name = config.name()
-        ? config.name().replace(/[^\w.]/g, '_') : 'CordovaExample';
+    var package_name = config.android_packageName() || config.packageName() || 'io.cordova.helloCordova';
+    var project_name = config.name() || 'Hello Cordova';
 
     var safe_activity_name = config.android_activityName() || options.activityName || 'MainActivity';
     var target_api = check_reqs.get_target(project_path);
@@ -215,7 +214,7 @@ exports.create = function (project_path, config, options, events) {
         .then(function () {
             return exports.validateProjectName(project_name);
         }).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', '\tPath: ' + project_path);
             events.emit('log', '\tPackage: ' + package_name);
diff --git a/spec/unit/create.spec.js b/spec/unit/create.spec.js
index a8fb5a9..de05e86 100644
--- a/spec/unit/create.spec.js
+++ b/spec/unit/create.spec.js
@@ -147,10 +147,10 @@ describe('create', 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);
                 return create.create(project_path, config_mock, {}, events_mock).then(() => {
-                    expect(create.validatePackageName).toHaveBeenCalledWith('my.cordova.project');
+                    expect(create.validatePackageName).toHaveBeenCalledWith('io.cordova.helloCordova');
                 });
             });
 
@@ -161,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);
                 return create.create(project_path, config_mock, {}, events_mock).then(() => {
-                    expect(create.validateProjectName).toHaveBeenCalledWith('CordovaExample');
+                    expect(create.validateProjectName).toHaveBeenCalledWith('Hello Cordova');
                 });
             });
 
@@ -175,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 用用用用');
                 return create.create(project_path, config_mock, {}, events_mock).then(() => {
-                    expect(create.validateProjectName).toHaveBeenCalledWith('_____hello_____');
+                    expect(create.validateProjectName).toHaveBeenCalledWith('応応応応 hello 用用用用');
                 });
             });
 

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org