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 2026/03/29 05:02:06 UTC
(cordova-browser) branch master updated: feat!: remove bin & VERSION files (#150)
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-browser.git
The following commit(s) were added to refs/heads/master by this push:
new c11e631 feat!: remove bin & VERSION files (#150)
c11e631 is described below
commit c11e6310d19231ed31c991ca465632f19da6784a
Author: エリス <er...@users.noreply.github.com>
AuthorDate: Sun Mar 29 14:02:01 2026 +0900
feat!: remove bin & VERSION files (#150)
* feat!: remove bin files & VERSION
* feat!: remove bin files from eslint.config.js
* feat!: remove bin create from package.json
* test!: remove bin usage and call create API
* feat!: remove nopt dependency
---
VERSION | 1 -
bin/create | 89 ---------------------
bin/create.bat | 26 -------
bin/template/cordova/build | 32 --------
bin/template/cordova/build.bat | 26 -------
bin/template/cordova/clean | 33 --------
bin/template/cordova/clean.bat | 26 -------
bin/template/cordova/log | 22 ------
bin/template/cordova/run | 48 ------------
bin/template/cordova/run.bat | 26 -------
bin/template/cordova/version.bat | 26 -------
bin/update | 34 --------
bin/update.bat | 26 -------
eslint.config.js | 6 --
package-lock.json | 28 -------
package.json | 2 -
spec/create.spec.js | 163 ++++++++++++++++++++++-----------------
spec/manifest.spec.js | 82 --------------------
18 files changed, 94 insertions(+), 602 deletions(-)
diff --git a/VERSION b/VERSION
deleted file mode 100644
index e4be07b..0000000
--- a/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-8.0.0-dev
diff --git a/bin/create b/bin/create
deleted file mode 100755
index 710a35e..0000000
--- a/bin/create
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/usr/bin/env node
-
-/*
- 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.
-*/
-
-// var path = require('path');
-// var create = require('./lib/create');
-// var args = process.argv;
-
-// // Support basic help commands
-// if(args.length < 3 || (args[2] == '--help' || args[2] == '/?' || args[2] == '-h' ||
-// args[2] == 'help' || args[2] == '-help' || args[2] == '/help')) {
-// console.log('Usage: ' + path.relative(process.cwd(), path.join(__dirname, 'create')) + ' <path_to_new_project> <package_name> <project_name>');
-// console.log(' <path_to_new_project>: Path to your new Cordova Browser project');
-// console.log(' <package_name>: Package name, following reverse-domain style convention');
-// console.log(' <project_name>: Project name');
-// process.exitCode = 1;
-// } else {
-// create.createProject(args[2], args[3], args[4], args[5]);
-// }
-
-/*
- * create a Cordova project
- *
- * USAGE
- * ./create <path_to_new_project> <package_name> <project_name>
- *
- * EXAMPLE
- * ./create ~/Desktop/radness org.apache.cordova.radness Radness
- */
-
-const path = require('path');
-const ConfigParser = require('cordova-common').ConfigParser;
-const Api = require('./template/cordova/Api');
-
-const argv = require('nopt')({
- help: Boolean,
- cli: Boolean,
- shared: Boolean, // alias for --link
- link: Boolean
-}, { d: '--verbose' });
-
-const projectPath = argv.argv.remain[0];
-
-if (argv.help || !projectPath) {
- console.log('Usage: $0 [--link] [--cli] <path_to_new_project> <package_name> <project_name> [<project_template_dir>]');
- console.log(' --link (optional): Link directly against the shared copy of the CordovaLib instead of a copy of it.');
- console.log(' --cli (optional): Use the CLI-project template.');
- console.log(' <path_to_new_project>: Path to your new Cordova iOS project');
- console.log(' <package_name>: Package name, following reverse-domain style convention');
- console.log(' <project_name>: Project name');
- console.log(' <project_template_dir>: Path to project template (override).');
- process.exit(0);
-} else {
- const configPath = path.resolve(__dirname, 'template/config.xml');
- const config = new ConfigParser(configPath);
-
- // apply overrides (package and project names
- if (argv.argv.remain[1]) {
- config.setPackageName(argv.argv.remain[1]);
- }
- if (argv.argv.remain[2]) {
- config.setName(argv.argv.remain[2]);
- }
-
- const options = {
- cli: argv.cli,
- link: argv.link || argv.shared,
- customTemplate: argv.argv.remain[3]
- };
-
- Api.createPlatform(projectPath, config, options);
-}
diff --git a/bin/create.bat b/bin/create.bat
deleted file mode 100644
index 88891fe..0000000
--- a/bin/create.bat
+++ /dev/null
@@ -1,26 +0,0 @@
-:: 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.
-
-@ECHO OFF
-SET script_path="%~dp0create"
-IF EXIST %script_path% (
- node %script_path% %*
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find 'create' script in 'bin' folder, aborting...>&2
- EXIT /B 1
-)
diff --git a/bin/template/cordova/build b/bin/template/cordova/build
deleted file mode 100755
index 6502ed3..0000000
--- a/bin/template/cordova/build
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/env node
-
-/*
- 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.
-*/
-
-const build = require('./lib/build');
-const args = process.argv;
-
-// provide help
-const helpOptions = '--help /? -h /h help -help /help'.split(' ');
-if (helpOptions.includes(args[2])) {
- build.help();
- process.exit(0);
-} else {
- build.run();
-}
diff --git a/bin/template/cordova/build.bat b/bin/template/cordova/build.bat
deleted file mode 100644
index 6122d62..0000000
--- a/bin/template/cordova/build.bat
+++ /dev/null
@@ -1,26 +0,0 @@
-:: 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.
-
-@ECHO OFF
-SET script_path="%~dp0build"
-IF EXIST %script_path% (
- node %script_path% %*
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find 'build' script in 'cordova' folder, aborting...>&2
- EXIT /B 1
-)
diff --git a/bin/template/cordova/clean b/bin/template/cordova/clean
deleted file mode 100644
index 943d136..0000000
--- a/bin/template/cordova/clean
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env node
-
-/*
- 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.
-*/
-
-const path = require('path');
-const clean = require('./lib/clean');
-const args = process.argv;
-
-// Support basic help commands
-const helpOptions = '--help /? -h /h help -help /help'.split(' ');
-if (args.length > 2 || helpOptions.includes(args[2])) {
- console.log('Usage: ' + path.relative(process.cwd(), path.join(__dirname, 'clean')));
- process.exit(0);
-} else {
- clean.run();
-}
diff --git a/bin/template/cordova/clean.bat b/bin/template/cordova/clean.bat
deleted file mode 100644
index 3c4d8b3..0000000
--- a/bin/template/cordova/clean.bat
+++ /dev/null
@@ -1,26 +0,0 @@
-:: 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.
-
-@ECHO OFF
-SET script_path="%~dp0clean"
-IF EXIST %script_path% (
- node %script_path% %*
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find 'clean' script in 'cordova' folder, aborting...>&2
- EXIT /B 1
-)
diff --git a/bin/template/cordova/log b/bin/template/cordova/log
deleted file mode 100755
index 4a027b0..0000000
--- a/bin/template/cordova/log
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/env node
-
-/*
- 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.
-*/
-
-console.log('cordova/log');
diff --git a/bin/template/cordova/run b/bin/template/cordova/run
deleted file mode 100755
index 48300e3..0000000
--- a/bin/template/cordova/run
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/env node
-
-/*
- 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.
-*/
-
-const nopt = require('nopt');
-const runForrest = require('./lib/run');
-
-const args = process.argv;
-
-start(args);
-
-function start (argv) {
- const args = nopt({ help: Boolean, target: String, port: Number }, { help: ['/?', '-h', 'help', '-help', '/help'] }, argv);
- if (args.help) {
- help();
- } else {
- return runForrest.run(args);
- }
-}
-
-function help () {
- console.log('\nUsage: run [ --target=<browser> ] [ --port=<number> ]');
- console.log(' --target=<browser> : Launches the specified browser. Chrome is default.');
- console.log(' --port=<number> : Http server uses specified port number.');
- console.log('Examples:');
- console.log(' run');
- console.log(' run -- --target=ie');
- console.log(' run -- --target=chrome --port=8000');
- console.log('');
- process.exit(0);
-}
diff --git a/bin/template/cordova/run.bat b/bin/template/cordova/run.bat
deleted file mode 100644
index 387d2d9..0000000
--- a/bin/template/cordova/run.bat
+++ /dev/null
@@ -1,26 +0,0 @@
-:: 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.
-
-@ECHO OFF
-SET script_path="%~dp0run"
-IF EXIST %script_path% (
- node %script_path% %*
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find 'run' script in 'cordova' folder, aborting...>&2
- EXIT /B 1
-)
diff --git a/bin/template/cordova/version.bat b/bin/template/cordova/version.bat
deleted file mode 100644
index 3927a3a..0000000
--- a/bin/template/cordova/version.bat
+++ /dev/null
@@ -1,26 +0,0 @@
-:: 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.
-
-@ECHO OFF
-SET script_path="%~dp0version"
-IF EXIST %script_path% (
- node %script_path% %*
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find 'version' script in 'cordova' folder, aborting...>&2
- EXIT /B 1
-)
diff --git a/bin/update b/bin/update
deleted file mode 100755
index 2c68116..0000000
--- a/bin/update
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/env node
-
-/*
- 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.
-*/
-
-const update = require('./lib/update');
-
-// check for help flag
-if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) > -1) {
- update.help();
-} else {
- update.run(process.argv).then(() => {
- console.log('Successfully updated browser project.');
- }, err => {
- console.error('Update failed due to', err);
- process.exit(2);
- });
-}
diff --git a/bin/update.bat b/bin/update.bat
deleted file mode 100644
index b928c2a..0000000
--- a/bin/update.bat
+++ /dev/null
@@ -1,26 +0,0 @@
-:: 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.
-
-@ECHO OFF
-SET script_path="%~dp0update"
-IF EXIST %script_path% (
- node %script_path% %*
-) ELSE (
- ECHO.
- ECHO ERROR: Could not find 'update' script in 'bin' folder, aborting...>&2
- EXIT /B 1
-)
diff --git a/eslint.config.js b/eslint.config.js
index fcf4fb2..10446cd 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -30,12 +30,6 @@ module.exports = defineConfig([
...nodeConfig.map(config => ({
files: [
'**/*.js',
- 'bin/create',
- 'bin/update',
- 'bin/template/cordova/build',
- 'bin/template/cordova/clean',
- 'bin/template/cordova/log',
- 'bin/template/cordova/run',
'bin/template/cordova/version'
],
...config
diff --git a/package-lock.json b/package-lock.json
index 1dfe379..a350e9e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -11,12 +11,8 @@
"dependencies": {
"cordova-common": "^6.0.0",
"cordova-serve": "^4.0.1",
- "nopt": "^9.0.0",
"shelljs": "^0.10.0"
},
- "bin": {
- "cordova-browser": "bin/create"
- },
"devDependencies": {
"@cordova/eslint-config": "^6.0.1",
"c8": "^11.0.0",
@@ -449,15 +445,6 @@
"node": ">=10.0.0"
}
},
- "node_modules/abbrev": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-4.0.0.tgz",
- "integrity": "sha512-a1wflyaL0tHtJSmLSOVybYhy22vRih4eduhhrkcjgrWGnRfrZtovJ2FRjxuTtkkj47O/baf0R86QU5OuYpz8fA==",
- "license": "ISC",
- "engines": {
- "node": "^20.17.0 || >=22.9.0"
- }
- },
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
@@ -3601,21 +3588,6 @@
"node": ">= 0.6"
}
},
- "node_modules/nopt": {
- "version": "9.0.0",
- "resolved": "https://registry.npmjs.org/nopt/-/nopt-9.0.0.tgz",
- "integrity": "sha512-Zhq3a+yFKrYwSBluL4H9XP3m3y5uvQkB/09CwDruCiRmR/UJYnn9W4R48ry0uGC70aeTPKLynBtscP9efFFcPw==",
- "license": "ISC",
- "dependencies": {
- "abbrev": "^4.0.0"
- },
- "bin": {
- "nopt": "bin/nopt.js"
- },
- "engines": {
- "node": "^20.17.0 || >=22.9.0"
- }
- },
"node_modules/npm-run-path": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz",
diff --git a/package.json b/package.json
index 020b47c..16a8ec9 100644
--- a/package.json
+++ b/package.json
@@ -3,7 +3,6 @@
"version": "8.0.0-dev",
"description": "cordova-browser release",
"main": "bin/template/cordova/Api.js",
- "bin": "bin/create",
"repository": "github:apache/cordova-browser",
"bugs": "https://github.com/apache/cordova-browser/issues",
"keywords": [
@@ -22,7 +21,6 @@
"dependencies": {
"cordova-common": "^6.0.0",
"cordova-serve": "^4.0.1",
- "nopt": "^9.0.0",
"shelljs": "^0.10.0"
},
"devDependencies": {
diff --git a/spec/create.spec.js b/spec/create.spec.js
index 0925cc8..0d11532 100644
--- a/spec/create.spec.js
+++ b/spec/create.spec.js
@@ -17,95 +17,120 @@
under the License.
*/
-const shell = require('shelljs');
-const fs = require('fs');
-const path = require('path');
-const util = require('util');
-
-const cordova_bin = path.join(__dirname, '../bin');// is this the same on all platforms?
-const tmpDir = path.join(__dirname, '../temp');
-const createScriptPath = path.join(cordova_bin, 'create');
-
-function createAndBuild (projectname, projectid) {
- let return_code = 0;
- let command;
-
- // remove existing folder
- shell.rm('-rf', tmpDir);
- shell.mkdir(tmpDir);
-
- // create the project
- command = util.format('"%s" "%s/%s" "%s" "%s"', createScriptPath, tmpDir, projectname, projectid, projectname);
- // shell.echo(command);
- return_code = shell.exec(command).code;
- expect(return_code).toBe(0);
-
- const tempCordovaScriptsPath = path.join(tmpDir, projectname, 'cordova');
-
- console.log('tempCordovaScriptsPath = ' + tempCordovaScriptsPath);
-
- // created project has scripts in the cordova folder
- // build, clean, log, run, version
- expect(fs.existsSync(path.join(tempCordovaScriptsPath, 'build'))).toBe(true);
- expect(fs.existsSync(path.join(tempCordovaScriptsPath, 'clean'))).toBe(true);
- expect(fs.existsSync(path.join(tempCordovaScriptsPath, 'log'))).toBe(true);
- expect(fs.existsSync(path.join(tempCordovaScriptsPath, 'run'))).toBe(true);
- expect(fs.existsSync(path.join(tempCordovaScriptsPath, 'version'))).toBe(true);
-
- // // build the project
- command = util.format('"%s/cordova/build"', path.join(tmpDir, projectname));
- // shell.echo(command);
- return_code = shell.exec(command, { silent: true }).code;
- expect(return_code).toBe(0);
-
- // clean-up
- shell.rm('-rf', tmpDir);
+const fs = require('node:fs');
+const path = require('node:path');
+const tmp = require('tmp');
+const create = require('../bin/lib/create');
+
+tmp.setGracefulCleanup();
+
+function makeTempDir () {
+ const tempdir = tmp.dirSync({ unsafeCleanup: true });
+ return path.join(tempdir.name, `cordova-browser-create-test-${Date.now()}`);
}
-describe('create', function () {
- it('has a create script in bin/cordova', function () {
- expect(fs.existsSync(createScriptPath)).toBe(true);
+/**
+ * Verifies that some of the project file exists. Not all will be tested.
+ * E.g. App's resource directory, xcodeproj, xcworkspace, and CordovaLib.
+ *
+ * @param {String} tmpDir
+ * @param {String} projectName
+ */
+function verifyProjectFiles (tmpDir, projectName) {
+ expect(fs.existsSync(path.join(tmpDir, 'www'))).toBe(true);
+ expect(fs.existsSync(path.join(tmpDir, 'platform_www'))).toBe(true);
+}
+
+/**
+ * Runs various project creation checks.
+ *
+ * @param {String} tmpDir
+ * @param {String} packageName
+ * @param {String} projectName
+ * @returns {Promise}
+ */
+async function verifyCreatedProject (tmpDir, packageName, projectName) {
+ await create.createProject(tmpDir, packageName, projectName)
+ .then(() => verifyProjectFiles(tmpDir, projectName));
+}
+
+function verifyManifestFiles (tmpDir, projectName) {
+ const manifestPath = path.join(tmpDir, 'platform_www/manifest.json');
+ expect(fs.existsSync(manifestPath)).toBe(true);
+ const manifestObj = require(manifestPath);
+ expect(manifestObj.name).toBe(projectName);
+ // start_url
+ expect(manifestObj.start_url).toBe('index.html');
+ // display
+ expect(manifestObj.display).toBe('standalone');
+ // description
+ expect(manifestObj.description).toBeDefined();
+ // background_color
+ expect(manifestObj.background_color).toBeDefined();
+ // theme_color
+ expect(manifestObj.theme_color).toBeDefined();
+ // scope
+ expect(manifestObj.scope).toBeDefined();
+ // orientation
+ expect(manifestObj.orientation).toBeDefined();
+ // icons
+ expect(manifestObj.icons).toBeDefined();
+ expect(Array.isArray(manifestObj.icons)).toBe(true);
+ expect(manifestObj.icons.length).toBeDefined();
+ expect(manifestObj.icons.length).toBeGreaterThan(0);
+}
+
+describe('create', () => {
+ let tmpDir;
+
+ beforeEach(function () {
+ tmpDir = makeTempDir();
});
- it('create project with ascii name, no spaces', function () {
- const projectname = 'testcreate';
- const projectid = 'com.test.app1';
+ afterEach(() => {
+ fs.rmSync(tmpDir, { recursive: true, force: true });
+ });
- createAndBuild(projectname, projectid);
+ it('create project with ascii name, no spaces', function () {
+ const projectName = 'testcreate';
+ const packageName = 'com.test.app1';
+ return verifyCreatedProject(tmpDir, packageName, projectName);
});
it('create project with ascii name, and spaces', function () {
- const projectname = 'test create';
- const projectid = 'com.test.app2';
-
- createAndBuild(projectname, projectid);
+ const projectName = 'test create';
+ const packageName = 'com.test.app2';
+ return verifyCreatedProject(tmpDir, packageName, projectName);
});
it('create project with unicode name, no spaces', function () {
- const projectname = '応応応応用用用用';
- const projectid = 'com.test.app3';
-
- createAndBuild(projectname, projectid);
+ const projectName = '応応応応用用用用';
+ const packageName = 'com.test.app3';
+ return verifyCreatedProject(tmpDir, packageName, projectName);
});
it('create project with unicode name, and spaces', function () {
- const projectname = '応応応応 用用用用';
- const projectid = 'com.test.app4';
-
- createAndBuild(projectname, projectid);
+ const projectName = '応応応応 用用用用';
+ const packageName = 'com.test.app4';
+ return verifyCreatedProject(tmpDir, packageName, projectName);
});
it('create project with ascii+unicode name, no spaces', function () {
- const projectname = '応応応応hello用用用用';
- const projectid = 'com.test.app5';
-
- createAndBuild(projectname, projectid);
+ const projectName = '応応応応hello用用用用';
+ const packageName = 'com.test.app5';
+ return verifyCreatedProject(tmpDir, packageName, projectName);
});
it('create project with ascii+unicode name, and spaces', function () {
- const projectname = '応応応応 hello 用用用用';
- const projectid = 'com.test.app6';
+ const projectName = '応応応応 hello 用用用用';
+ const packageName = 'com.test.app6';
+ return verifyCreatedProject(tmpDir, packageName, projectName);
+ });
- createAndBuild(projectname, projectid);
+ it('should have manifest.json', function () {
+ const projectName = 'testcreate';
+ const packageName = 'com.test.app1';
+ return verifyCreatedProject(tmpDir, packageName, projectName)
+ .then(() => verifyManifestFiles(tmpDir, projectName));
});
});
diff --git a/spec/manifest.spec.js b/spec/manifest.spec.js
deleted file mode 100644
index a502046..0000000
--- a/spec/manifest.spec.js
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- 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.
-*/
-
-const shell = require('shelljs');
-const fs = require('fs');
-const path = require('path');
-const util = require('util');
-
-const cordova_bin = path.join(__dirname, '../bin');// is this the same on all platforms?
-const tmpDir = path.join(__dirname, '../temp');
-const createScriptPath = path.join(cordova_bin, 'create');
-
-function createAndBuild (projectname, projectid) {
- let return_code = 0;
-
- // remove existing folder
- shell.rm('-rf', tmpDir);
- shell.mkdir(tmpDir);
-
- // create the project
- const command = util.format('"%s" "%s/%s" "%s" "%s"', createScriptPath, tmpDir, projectname, projectid, projectname);
-
- return_code = shell.exec(command).code;
- expect(return_code).toBe(0);
-
- const platWwwPath = path.join(tmpDir, projectname, 'platform_www');
-
- const manifestPath = path.join(platWwwPath, 'manifest.json');
- expect(fs.existsSync(manifestPath)).toBe(true);
-
- const manifestObj = require(manifestPath);
- expect(manifestObj.name).toBe(projectname);
- // start_url
- expect(manifestObj.start_url).toBe('index.html');
- // display
- expect(manifestObj.display).toBe('standalone');
- // description
- expect(manifestObj.description).toBeDefined();
- // background_color
- expect(manifestObj.background_color).toBeDefined();
- // theme_color
- expect(manifestObj.theme_color).toBeDefined();
- // scope
- expect(manifestObj.scope).toBeDefined();
- // orientation
- expect(manifestObj.orientation).toBeDefined();
- // icons
- expect(manifestObj.icons).toBeDefined();
- expect(Array.isArray(manifestObj.icons)).toBe(true);
- expect(manifestObj.icons.length).toBeDefined();
- expect(manifestObj.icons.length).toBeGreaterThan(0);
-
- // related_applications[{platform:'web'},{platform:'play',url:...}] ?
-
- // clean-up
- shell.rm('-rf', tmpDir);
-}
-
-describe('manifest', function () {
- it('create project with manifest.json', function () {
- const projectname = 'testcreate';
- const projectid = 'com.test.app1';
-
- createAndBuild(projectname, projectid);
- });
-});
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org