From 9be11bc9349313edc01431921d2e9daa5c0d31e8 Mon Sep 17 00:00:00 2001 From: Alexis THOMAS Date: Sat, 17 Apr 2021 22:52:47 +0200 Subject: [PATCH 1/6] fix: correct mixed default value for project name --- bin/lib/create.js | 2 +- bin/templates/project/__PROJECT_NAME__/config.xml | 2 +- bin/templates/scripts/cordova/lib/Podfile.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/lib/create.js b/bin/lib/create.js index 0ba44ef475..9d615fae4e 100755 --- a/bin/lib/create.js +++ b/bin/lib/create.js @@ -195,7 +195,7 @@ function relpath (_path, start) { */ exports.createProject = (project_path, package_name, project_name, opts, config) => { package_name = package_name || 'my.cordova.project'; - project_name = project_name || 'CordovaExample'; + project_name = project_name || 'Hello Cordova'; const use_shared = !!opts.link; const bin_dir = path.join(ROOT, 'bin'); const project_parent = path.dirname(project_path); diff --git a/bin/templates/project/__PROJECT_NAME__/config.xml b/bin/templates/project/__PROJECT_NAME__/config.xml index e6e049cadb..1af6ad81a1 100644 --- a/bin/templates/project/__PROJECT_NAME__/config.xml +++ b/bin/templates/project/__PROJECT_NAME__/config.xml @@ -20,7 +20,7 @@ - HelloCordova + Hello Cordova A sample Apache Cordova application that responds to the deviceready event. diff --git a/bin/templates/scripts/cordova/lib/Podfile.js b/bin/templates/scripts/cordova/lib/Podfile.js index f167297446..8fe66571e9 100644 --- a/bin/templates/scripts/cordova/lib/Podfile.js +++ b/bin/templates/scripts/cordova/lib/Podfile.js @@ -76,7 +76,7 @@ Podfile.prototype.__parseForDeclarations = function (text) { // split by \n const arr = text.split('\n'); - // getting lines between "platform :ios, '11.0'"" and "target 'HelloCordova'" do + // getting lines between "platform :ios, '11.0'"" and "target 'Hello Cordova'" do const declarationsPreRE = new RegExp('platform :ios,\\s+\'[^\']+\''); const declarationsPostRE = new RegExp('target\\s+\'[^\']+\'\\s+do'); const declarationRE = new RegExp('^\\s*[^#]'); From ac77109d2e9c96e74d3d5c06552d6b39d07a4ae5 Mon Sep 17 00:00:00 2001 From: Alexis THOMAS Date: Sat, 17 Apr 2021 23:04:24 +0200 Subject: [PATCH 2/6] fix: correct mixed default value for package name --- bin/lib/create.js | 2 +- tests/spec/unit/fixtures/dummyProj/config.xml | 2 +- .../fixtures/launch-storyboard-support/configs/legacy-only.xml | 2 +- .../launch-storyboard-support/configs/modern-and-legacy.xml | 2 +- .../fixtures/launch-storyboard-support/configs/modern-only.xml | 2 +- .../unit/fixtures/launch-storyboard-support/configs/none.xml | 2 +- .../fixtures/prepare/allows-arbitrary-loads-for-media-false.xml | 2 +- .../fixtures/prepare/allows-arbitrary-loads-for-media-true.xml | 2 +- .../fixtures/prepare/allows-arbitrary-loads-in-media-false.xml | 2 +- .../fixtures/prepare/allows-arbitrary-loads-in-media-true.xml | 2 +- .../prepare/allows-arbitrary-loads-in-web-content-true.xml | 2 +- .../spec/unit/fixtures/prepare/allows-local-networking-true.xml | 2 +- .../unit/fixtures/prepare/set-origin-with-mixed-nsallows.xml | 2 +- .../prepare/wildcard-navigation-with-mixed-nsallows.xml | 2 +- tests/spec/unit/fixtures/prepare/wildcard-navigation.xml | 2 +- .../spec/unit/fixtures/prepare/wildcard-with-mixed-nsallows.xml | 2 +- tests/spec/unit/fixtures/resource-file-support/config.xml | 2 +- tests/spec/unit/fixtures/test-config-2.xml | 2 +- tests/spec/unit/fixtures/test-config-3.xml | 2 +- tests/spec/unit/fixtures/test-config.xml | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/bin/lib/create.js b/bin/lib/create.js index 9d615fae4e..12dda6e113 100755 --- a/bin/lib/create.js +++ b/bin/lib/create.js @@ -194,7 +194,7 @@ function relpath (_path, start) { * */ exports.createProject = (project_path, package_name, project_name, opts, config) => { - package_name = package_name || 'my.cordova.project'; + package_name = package_name || 'io.cordova.helloCordova'; project_name = project_name || 'Hello Cordova'; const use_shared = !!opts.link; const bin_dir = path.join(ROOT, 'bin'); diff --git a/tests/spec/unit/fixtures/dummyProj/config.xml b/tests/spec/unit/fixtures/dummyProj/config.xml index 08412374ed..0c2aefbf5d 100644 --- a/tests/spec/unit/fixtures/dummyProj/config.xml +++ b/tests/spec/unit/fixtures/dummyProj/config.xml @@ -1,5 +1,5 @@ - + SampleApp A sample Apache Cordova application that responds to the deviceready event. diff --git a/tests/spec/unit/fixtures/launch-storyboard-support/configs/legacy-only.xml b/tests/spec/unit/fixtures/launch-storyboard-support/configs/legacy-only.xml index 40c7af632c..5068530ef6 100644 --- a/tests/spec/unit/fixtures/launch-storyboard-support/configs/legacy-only.xml +++ b/tests/spec/unit/fixtures/launch-storyboard-support/configs/legacy-only.xml @@ -1,5 +1,5 @@ - + Hello Cordova A sample Apache Cordova application that responds to the deviceready event. diff --git a/tests/spec/unit/fixtures/launch-storyboard-support/configs/modern-and-legacy.xml b/tests/spec/unit/fixtures/launch-storyboard-support/configs/modern-and-legacy.xml index 113660e088..7ea1844a75 100644 --- a/tests/spec/unit/fixtures/launch-storyboard-support/configs/modern-and-legacy.xml +++ b/tests/spec/unit/fixtures/launch-storyboard-support/configs/modern-and-legacy.xml @@ -1,5 +1,5 @@ - + Hello Cordova A sample Apache Cordova application that responds to the deviceready event. diff --git a/tests/spec/unit/fixtures/launch-storyboard-support/configs/modern-only.xml b/tests/spec/unit/fixtures/launch-storyboard-support/configs/modern-only.xml index d9ae88c395..9eedccc3be 100644 --- a/tests/spec/unit/fixtures/launch-storyboard-support/configs/modern-only.xml +++ b/tests/spec/unit/fixtures/launch-storyboard-support/configs/modern-only.xml @@ -1,5 +1,5 @@ - + Hello Cordova A sample Apache Cordova application that responds to the deviceready event. diff --git a/tests/spec/unit/fixtures/launch-storyboard-support/configs/none.xml b/tests/spec/unit/fixtures/launch-storyboard-support/configs/none.xml index 9f3f340208..89db5c5469 100644 --- a/tests/spec/unit/fixtures/launch-storyboard-support/configs/none.xml +++ b/tests/spec/unit/fixtures/launch-storyboard-support/configs/none.xml @@ -1,5 +1,5 @@ - + Hello Cordova A sample Apache Cordova application that responds to the deviceready event. diff --git a/tests/spec/unit/fixtures/prepare/allows-arbitrary-loads-for-media-false.xml b/tests/spec/unit/fixtures/prepare/allows-arbitrary-loads-for-media-false.xml index 9f521f6b60..e403fb6abb 100644 --- a/tests/spec/unit/fixtures/prepare/allows-arbitrary-loads-for-media-false.xml +++ b/tests/spec/unit/fixtures/prepare/allows-arbitrary-loads-for-media-false.xml @@ -18,7 +18,7 @@ under the License. --> - + SampleApp diff --git a/tests/spec/unit/fixtures/prepare/allows-arbitrary-loads-for-media-true.xml b/tests/spec/unit/fixtures/prepare/allows-arbitrary-loads-for-media-true.xml index fa51a75238..082c782126 100644 --- a/tests/spec/unit/fixtures/prepare/allows-arbitrary-loads-for-media-true.xml +++ b/tests/spec/unit/fixtures/prepare/allows-arbitrary-loads-for-media-true.xml @@ -18,7 +18,7 @@ under the License. --> - + SampleApp diff --git a/tests/spec/unit/fixtures/prepare/allows-arbitrary-loads-in-media-false.xml b/tests/spec/unit/fixtures/prepare/allows-arbitrary-loads-in-media-false.xml index 7dd948cdf8..db581d1892 100644 --- a/tests/spec/unit/fixtures/prepare/allows-arbitrary-loads-in-media-false.xml +++ b/tests/spec/unit/fixtures/prepare/allows-arbitrary-loads-in-media-false.xml @@ -18,7 +18,7 @@ under the License. --> - + SampleApp diff --git a/tests/spec/unit/fixtures/prepare/allows-arbitrary-loads-in-media-true.xml b/tests/spec/unit/fixtures/prepare/allows-arbitrary-loads-in-media-true.xml index fda63eef4c..cdeab7315c 100644 --- a/tests/spec/unit/fixtures/prepare/allows-arbitrary-loads-in-media-true.xml +++ b/tests/spec/unit/fixtures/prepare/allows-arbitrary-loads-in-media-true.xml @@ -18,7 +18,7 @@ under the License. --> - + SampleApp diff --git a/tests/spec/unit/fixtures/prepare/allows-arbitrary-loads-in-web-content-true.xml b/tests/spec/unit/fixtures/prepare/allows-arbitrary-loads-in-web-content-true.xml index be233b07e4..354ace4aaa 100644 --- a/tests/spec/unit/fixtures/prepare/allows-arbitrary-loads-in-web-content-true.xml +++ b/tests/spec/unit/fixtures/prepare/allows-arbitrary-loads-in-web-content-true.xml @@ -18,7 +18,7 @@ under the License. --> - + SampleApp diff --git a/tests/spec/unit/fixtures/prepare/allows-local-networking-true.xml b/tests/spec/unit/fixtures/prepare/allows-local-networking-true.xml index ef5e973390..833542cc15 100644 --- a/tests/spec/unit/fixtures/prepare/allows-local-networking-true.xml +++ b/tests/spec/unit/fixtures/prepare/allows-local-networking-true.xml @@ -18,7 +18,7 @@ under the License. --> - + SampleApp diff --git a/tests/spec/unit/fixtures/prepare/set-origin-with-mixed-nsallows.xml b/tests/spec/unit/fixtures/prepare/set-origin-with-mixed-nsallows.xml index c0723e1191..152494df49 100644 --- a/tests/spec/unit/fixtures/prepare/set-origin-with-mixed-nsallows.xml +++ b/tests/spec/unit/fixtures/prepare/set-origin-with-mixed-nsallows.xml @@ -18,7 +18,7 @@ under the License. --> - + SampleApp diff --git a/tests/spec/unit/fixtures/prepare/wildcard-navigation-with-mixed-nsallows.xml b/tests/spec/unit/fixtures/prepare/wildcard-navigation-with-mixed-nsallows.xml index 818b4e71a0..cee2cfecb3 100644 --- a/tests/spec/unit/fixtures/prepare/wildcard-navigation-with-mixed-nsallows.xml +++ b/tests/spec/unit/fixtures/prepare/wildcard-navigation-with-mixed-nsallows.xml @@ -18,7 +18,7 @@ under the License. --> - + SampleApp diff --git a/tests/spec/unit/fixtures/prepare/wildcard-navigation.xml b/tests/spec/unit/fixtures/prepare/wildcard-navigation.xml index 0a3ea32c77..245d6eaa0f 100644 --- a/tests/spec/unit/fixtures/prepare/wildcard-navigation.xml +++ b/tests/spec/unit/fixtures/prepare/wildcard-navigation.xml @@ -18,7 +18,7 @@ under the License. --> - + SampleApp diff --git a/tests/spec/unit/fixtures/prepare/wildcard-with-mixed-nsallows.xml b/tests/spec/unit/fixtures/prepare/wildcard-with-mixed-nsallows.xml index 751c7de276..cb228708eb 100644 --- a/tests/spec/unit/fixtures/prepare/wildcard-with-mixed-nsallows.xml +++ b/tests/spec/unit/fixtures/prepare/wildcard-with-mixed-nsallows.xml @@ -18,7 +18,7 @@ under the License. --> - + SampleApp diff --git a/tests/spec/unit/fixtures/resource-file-support/config.xml b/tests/spec/unit/fixtures/resource-file-support/config.xml index d49965acfb..1cdb1bac7d 100644 --- a/tests/spec/unit/fixtures/resource-file-support/config.xml +++ b/tests/spec/unit/fixtures/resource-file-support/config.xml @@ -1,5 +1,5 @@ - + Hello Cordova A sample Apache Cordova application that responds to the deviceready event. diff --git a/tests/spec/unit/fixtures/test-config-2.xml b/tests/spec/unit/fixtures/test-config-2.xml index 9f3f340208..89db5c5469 100644 --- a/tests/spec/unit/fixtures/test-config-2.xml +++ b/tests/spec/unit/fixtures/test-config-2.xml @@ -1,5 +1,5 @@ - + Hello Cordova A sample Apache Cordova application that responds to the deviceready event. diff --git a/tests/spec/unit/fixtures/test-config-3.xml b/tests/spec/unit/fixtures/test-config-3.xml index fda80c6e0a..c49a0d65f5 100644 --- a/tests/spec/unit/fixtures/test-config-3.xml +++ b/tests/spec/unit/fixtures/test-config-3.xml @@ -1,5 +1,5 @@ - + Hello Cordova A sample Apache Cordova application that responds to the deviceready event. diff --git a/tests/spec/unit/fixtures/test-config.xml b/tests/spec/unit/fixtures/test-config.xml index bb2d4f0afd..4858789ab7 100644 --- a/tests/spec/unit/fixtures/test-config.xml +++ b/tests/spec/unit/fixtures/test-config.xml @@ -1,5 +1,5 @@ - + Hello Cordova A sample Apache Cordova application that responds to the deviceready event. From eb24607d4d1f511261c7258c376141cc9e994bef Mon Sep 17 00:00:00 2001 From: Alexis THOMAS Date: Sat, 17 Apr 2021 23:37:05 +0200 Subject: [PATCH 3/6] feat(create): init opts and project_path relative same as cdv-android --- bin/lib/create.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/bin/lib/create.js b/bin/lib/create.js index 12dda6e113..53c12237f4 100755 --- a/bin/lib/create.js +++ b/bin/lib/create.js @@ -194,6 +194,15 @@ function relpath (_path, start) { * */ exports.createProject = (project_path, package_name, project_name, opts, config) => { + opts = opts || {}; + + // Set default values for path, package and name + 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')); + } + package_name = package_name || 'io.cordova.helloCordova'; project_name = project_name || 'Hello Cordova'; const use_shared = !!opts.link; @@ -201,18 +210,13 @@ exports.createProject = (project_path, package_name, project_name, opts, config) const project_parent = path.dirname(project_path); const project_template_dir = opts.customTemplate || path.join(bin_dir, 'templates', 'project'); - // check that project path doesn't exist - if (fs.existsSync(project_path)) { - return Promise.reject(new CordovaError('Project already exists')); - } - // check that parent directory does exist so cp -r will not fail if (!fs.existsSync(project_parent)) { return Promise.reject(new CordovaError(`Parent directory "${project_parent}" of given project path does not exist`)); } events.emit('log', 'Creating Cordova project for the iOS platform:'); - events.emit('log', `\tPath: ${path.relative(process.cwd(), project_path)}`); + events.emit('log', `\tPath: ${project_path}`); events.emit('log', `\tPackage: ${package_name}`); events.emit('log', `\tName: ${project_name}`); From 84a2eea0513a08f4a6100d381be0f07e635bae10 Mon Sep 17 00:00:00 2001 From: Alexis THOMAS Date: Sat, 17 Apr 2021 23:41:59 +0200 Subject: [PATCH 4/6] feat(create): remove check on parent directory, ensureDirSync does it all --- bin/lib/create.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/bin/lib/create.js b/bin/lib/create.js index 53c12237f4..90d0115712 100755 --- a/bin/lib/create.js +++ b/bin/lib/create.js @@ -207,14 +207,8 @@ exports.createProject = (project_path, package_name, project_name, opts, config) project_name = project_name || 'Hello Cordova'; const use_shared = !!opts.link; const bin_dir = path.join(ROOT, 'bin'); - const project_parent = path.dirname(project_path); const project_template_dir = opts.customTemplate || path.join(bin_dir, 'templates', 'project'); - // check that parent directory does exist so cp -r will not fail - if (!fs.existsSync(project_parent)) { - return Promise.reject(new CordovaError(`Parent directory "${project_parent}" of given project path does not exist`)); - } - events.emit('log', 'Creating Cordova project for the iOS platform:'); events.emit('log', `\tPath: ${project_path}`); events.emit('log', `\tPackage: ${package_name}`); From 5492818c7f76d13d7aded046518a0a03946a2387 Mon Sep 17 00:00:00 2001 From: Alexis THOMAS Date: Mon, 6 Nov 2023 23:17:05 +0100 Subject: [PATCH 5/6] fix: redo correct package and project name --- lib/Podfile.js | 2 +- lib/create.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Podfile.js b/lib/Podfile.js index 3500b5f0e5..7a2f04c39b 100644 --- a/lib/Podfile.js +++ b/lib/Podfile.js @@ -73,7 +73,7 @@ Podfile.prototype.__parseForDeclarations = function (text) { // split by \n const arr = text.split('\n'); - // getting lines between "platform :ios, '11.0'"" and "target 'HelloCordova'" do + // getting lines between "platform :ios, '11.0'"" and "target 'Hello Cordova'" do const declarationsPreRE = /platform :ios,\s+'[^']+'/; const declarationsPostRE = /target\s+'[^']+'\s+do/; const declarationRE = /^\s*[^#]/; diff --git a/lib/create.js b/lib/create.js index 7a15ee84d0..f9d0b4911c 100755 --- a/lib/create.js +++ b/lib/create.js @@ -35,8 +35,8 @@ const ROOT = path.join(__dirname, '..'); * @returns {Promise} resolves when the project has been created */ exports.createProject = async (project_path, package_name, project_name, opts) => { - package_name = package_name || 'my.cordova.project'; - project_name = project_name || 'CordovaExample'; + package_name = package_name || 'io.cordova.helloCordova'; + project_name = project_name || 'Hello Cordova'; // check that project path doesn't exist if (fs.existsSync(project_path)) { From 88d3d00831a501692199dc4172a404894586eb7a Mon Sep 17 00:00:00 2001 From: Alexis THOMAS Date: Mon, 6 Nov 2023 23:39:40 +0100 Subject: [PATCH 6/6] feat(create): redo init opts and project_path relative same as cdv-android --- lib/create.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/create.js b/lib/create.js index f9d0b4911c..1970188c48 100755 --- a/lib/create.js +++ b/lib/create.js @@ -35,16 +35,20 @@ const ROOT = path.join(__dirname, '..'); * @returns {Promise} resolves when the project has been created */ exports.createProject = async (project_path, package_name, project_name, opts) => { - package_name = package_name || 'io.cordova.helloCordova'; - project_name = project_name || 'Hello Cordova'; + opts = opts || {}; - // check that project path doesn't exist + // Set default values for path, package and name + project_path = path.relative(process.cwd(), project_path); + // Check if project already exists if (fs.existsSync(project_path)) { - throw new CordovaError('Project already exists'); + throw new CordovaError('Project already exists! Delete and recreate'); } + package_name = package_name || 'io.cordova.helloCordova'; + project_name = project_name || 'Hello Cordova'; + events.emit('log', 'Creating Cordova project for the iOS platform:'); - events.emit('log', `\tPath: ${path.relative(process.cwd(), project_path)}`); + events.emit('log', `\tPath: ${project_path}`); events.emit('log', `\tPackage: ${package_name}`); events.emit('log', `\tName: ${project_name}`);