From 590ca4d48b7cdd113fa1a90e376cf2b9bca0cf31 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Wed, 21 Feb 2018 18:57:21 -0500 Subject: [PATCH] Support `meteor create --minimal` for creating very small apps. Like `meteor create --bare`, except with even fewer Meteor core packages, so that the client-side footprint of the app is as tiny as possible. --- tools/cli/commands.js | 50 ++++++++++++------- tools/cli/help.txt | 14 +++--- tools/static-assets/skel-bare/package.json | 2 +- tools/static-assets/skel-full/package.json | 2 +- tools/static-assets/skel-minimal/.gitignore | 1 + .../skel-minimal/.meteor/.gitignore | 1 + .../skel-minimal/.meteor/packages | 13 +++++ .../skel-minimal/.meteor/platforms | 2 + tools/static-assets/skel-minimal/package.json | 11 ++++ tools/static-assets/skel/package.json | 2 +- tools/tests/create.js | 28 +++++++++++ 11 files changed, 98 insertions(+), 28 deletions(-) create mode 100644 tools/static-assets/skel-minimal/.gitignore create mode 100644 tools/static-assets/skel-minimal/.meteor/.gitignore create mode 100644 tools/static-assets/skel-minimal/.meteor/packages create mode 100644 tools/static-assets/skel-minimal/.meteor/platforms create mode 100644 tools/static-assets/skel-minimal/package.json diff --git a/tools/cli/commands.js b/tools/cli/commands.js index 18150488d4..2cbe52c6c0 100644 --- a/tools/cli/commands.js +++ b/tools/cli/commands.js @@ -489,8 +489,9 @@ main.registerCommand({ list: { type: Boolean }, example: { type: String }, package: { type: Boolean }, + bare: { type: Boolean }, + minimal: { type: Boolean }, full: { type: Boolean }, - bare: { type: Boolean } }, catalogRefresh: new catalog.Refresh.Never() }, function (options) { @@ -733,13 +734,13 @@ main.registerCommand({ toIgnore.push(/(\.html|\.js|\.css)/) } - let skelName = 'skel'; - - if(options.bare){ - skelName += '-bare'; - } - else if(options.full){ - skelName += '-full'; + let skelName = "skel"; + if (options.minimal) { + skelName += "-minimal"; + } else if (options.bare) { + skelName += "-bare"; + } else if (options.full) { + skelName += "-full"; } files.cp_r(files.pathJoin(__dirnameConverted, '..', 'static-assets', skelName), appPath, { @@ -819,6 +820,12 @@ main.registerCommand({ // do next. Console.info("To run your new app:"); + function cmd(text) { + Console.info(Console.command(text), Console.options({ + indent: 2 + })); + } + if (appPathAsEntered !== ".") { // Wrap the app path in quotes if it contains spaces const appPathWithQuotesIfSpaces = appPathAsEntered.indexOf(' ') === -1 ? @@ -826,13 +833,10 @@ main.registerCommand({ `'${appPathAsEntered}'`; // Don't tell people to 'cd .' - Console.info( - Console.command("cd " + appPathWithQuotesIfSpaces), - Console.options({ indent: 2 })); + cmd("cd " + appPathWithQuotesIfSpaces); } - Console.info( - Console.command("meteor"), Console.options({ indent: 2 })); + cmd("meteor"); Console.info(""); Console.info("If you are new to Meteor, try some of the learning resources here:"); @@ -840,13 +844,21 @@ main.registerCommand({ Console.url("https://www.meteor.com/tutorials"), Console.options({ indent: 2 })); - if (!options.full && !options.bare){ - // Notice people about --bare and --full - const bareOptionNotice = 'meteor create --bare to create an empty app.'; - const fullOptionNotice = 'meteor create --full to create a scaffolded app.'; + if (! options.bare && + ! options.minimal && + ! options.full) { + // Notify people about --bare, --minimal, and --full. + Console.info([ + "", + "To start with a different app template, try one of the following:", + "", + ].join("\n")); - Console.info(""); - Console.info(bareOptionNotice + '\n' + fullOptionNotice); + cmd("meteor create --bare # to create an empty app"); + cmd("meteor create --minimal # to create an empty app with as " + + "few Meteor packages as possible"); + cmd("meteor create --full # to create a more complete " + + "scaffolded app"); } Console.info(""); diff --git a/tools/cli/help.txt b/tools/cli/help.txt index e74e731dcf..c8f234da38 100644 --- a/tools/cli/help.txt +++ b/tools/cli/help.txt @@ -142,15 +142,16 @@ Options: >>> create Create a new project. -Usage: meteor create [--release ] [--bare|--full] +Usage: meteor create [--release ] [--bare|--minimal|--full] meteor create [--release ] --example [] meteor create --list meteor create --package [] -Make a subdirectory named if it doesn't exist and create a new Meteor app -there. You can pass an absolute path, relative path, or '.' for the current -directory. Use the --bare option to create an empty app. To scaffold the app -use the --full option. +Make a subdirectory named if it doesn't exist and create a new Meteor +app there. You can pass an absolute path, relative path, or '.' for the +current directory. Use the --bare option to create an empty app, or the +--minimal option to create an empty app with as few Meteor packages as +possible. To scaffold a more complete app, use the --full option. With the --package option, creates a Meteor package instead of an app. If you're in an app, the package will go in the app's top-level 'packages' directory; @@ -170,7 +171,8 @@ Options: --example Example template to use. --list Show list of available examples. --bare Create an empty app. - --full Create a scaffolded app. + --minimal Create an empty app with as few Meteor packages as possible. + --full Create a fully scaffolded app. >>> update diff --git a/tools/static-assets/skel-bare/package.json b/tools/static-assets/skel-bare/package.json index b8beef5529..7e491c1afb 100644 --- a/tools/static-assets/skel-bare/package.json +++ b/tools/static-assets/skel-bare/package.json @@ -5,7 +5,7 @@ "start": "meteor run" }, "dependencies": { - "@babel/runtime": "^7.0.0-beta.36", + "@babel/runtime": "^7.0.0-beta.40", "meteor-node-stubs": "^0.3.2" } } diff --git a/tools/static-assets/skel-full/package.json b/tools/static-assets/skel-full/package.json index 0cf055e170..2e5e0c8f64 100644 --- a/tools/static-assets/skel-full/package.json +++ b/tools/static-assets/skel-full/package.json @@ -6,7 +6,7 @@ "test": "meteor test --once --driver-package meteortesting:mocha" }, "dependencies": { - "@babel/runtime": "^7.0.0-beta.36", + "@babel/runtime": "^7.0.0-beta.40", "meteor-node-stubs": "^0.3.2" }, "devDependencies": { diff --git a/tools/static-assets/skel-minimal/.gitignore b/tools/static-assets/skel-minimal/.gitignore new file mode 100644 index 0000000000..40b878db5b --- /dev/null +++ b/tools/static-assets/skel-minimal/.gitignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file diff --git a/tools/static-assets/skel-minimal/.meteor/.gitignore b/tools/static-assets/skel-minimal/.meteor/.gitignore new file mode 100644 index 0000000000..4083037423 --- /dev/null +++ b/tools/static-assets/skel-minimal/.meteor/.gitignore @@ -0,0 +1 @@ +local diff --git a/tools/static-assets/skel-minimal/.meteor/packages b/tools/static-assets/skel-minimal/.meteor/packages new file mode 100644 index 0000000000..35f1bde9e3 --- /dev/null +++ b/tools/static-assets/skel-minimal/.meteor/packages @@ -0,0 +1,13 @@ +# Meteor packages used by this project, one per line. +# Check this file (and the other files in this directory) into your repository. +# +# 'meteor add' and 'meteor remove' will edit this file for you, +# but you can also edit it by hand. + +static-html # Define static page content in .html files +standard-minifier-css # CSS minifier run for production mode +standard-minifier-js # JS minifier run for production mode +es5-shim # ECMAScript 5 compatibility for older browsers +ecmascript # Enable ECMAScript2015+ syntax in app code +shell-server # Server-side component of the `meteor shell` command +webapp # Serves a Meteor app over HTTP diff --git a/tools/static-assets/skel-minimal/.meteor/platforms b/tools/static-assets/skel-minimal/.meteor/platforms new file mode 100644 index 0000000000..efeba1b50c --- /dev/null +++ b/tools/static-assets/skel-minimal/.meteor/platforms @@ -0,0 +1,2 @@ +server +browser diff --git a/tools/static-assets/skel-minimal/package.json b/tools/static-assets/skel-minimal/package.json new file mode 100644 index 0000000000..7e491c1afb --- /dev/null +++ b/tools/static-assets/skel-minimal/package.json @@ -0,0 +1,11 @@ +{ + "name": "~name~", + "private": true, + "scripts": { + "start": "meteor run" + }, + "dependencies": { + "@babel/runtime": "^7.0.0-beta.40", + "meteor-node-stubs": "^0.3.2" + } +} diff --git a/tools/static-assets/skel/package.json b/tools/static-assets/skel/package.json index b8beef5529..7e491c1afb 100644 --- a/tools/static-assets/skel/package.json +++ b/tools/static-assets/skel/package.json @@ -5,7 +5,7 @@ "start": "meteor run" }, "dependencies": { - "@babel/runtime": "^7.0.0-beta.36", + "@babel/runtime": "^7.0.0-beta.40", "meteor-node-stubs": "^0.3.2" } } diff --git a/tools/tests/create.js b/tools/tests/create.js index cb9e0c74e8..12d87cf9b0 100644 --- a/tools/tests/create.js +++ b/tools/tests/create.js @@ -58,3 +58,31 @@ selftest.define("create", function () { // XXX XXX more more }); + +["bare", + "minimal", + "full", +].forEach(template => { + selftest.define("create --" + template, function () { + const s = new Sandbox; + + // Can we create an app? Yes! + let run = s.run("create", "--" + template, template); + run.waitSecs(60); + run.match("Created a new Meteor app in '" + template + "'."); + run.match("To run your new app"); + + s.cd(template); + run = s.run(); + run.waitSecs(60); + run.match(template); + run.match("proxy") + run.waitSecs(60); + run.match("your app"); + run.waitSecs(5); + run.match("running at"); + run.match("localhost"); + + run.stop(); + }); +});