Make meteor create --package not use prefix

It used to create a directory with an underscore instead of a colon
Now, it just removes the prefix.

In cases where the name of the package has more than one colon or starts or ends
witha colon, we report an error.
This commit is contained in:
Sashko Stubailo
2015-03-11 18:21:19 -07:00
parent b652770229
commit c6ea68f9b3
6 changed files with 29 additions and 5 deletions

View File

@@ -186,9 +186,15 @@
* After killing existing `mongod` servers, also clear the `mongod.lock` file.
* Stricter validation for package names: they cannot begin with a hyphen, end
with a dot, or contain two consecutive dots. (No packages on Atmosphere fail
with a dot, contain two consecutive dots, contain more than one colon, or
start or end with a colon. (No packages on Atmosphere fail
this validation.)
* `meteor create --package` now no longer creates a directory with the full
name of the package, since Windows file systems cannot have colon characters
in file paths. Instead, the command now creates a directory named the same
as the second part of the package name after the colon (without the username
prefix).
### Meteor Mobile

View File

@@ -29,6 +29,9 @@ Tinytest.add("package-version-parser - validatePackageName", function (test) {
badName("-x", /not begin with a hyphen/);
badName("--x", /not begin with a hyphen/);
badName("0.0", /must contain/);
badName("a:a:a", /more than one colon/);
badName(":a", /start or end with a colon/);
badName("a:", /start or end with a colon/);
// these are ok
PackageVersion.validatePackageName('x-');

View File

@@ -393,6 +393,14 @@ PV.validatePackageName = function (packageName, options) {
}
// (There is already a package ending with a `-` and one with two consecutive `-`
// in troposphere, though they both look like typos.)
if (packageName.split(":").length > 2) {
throwVersionParserError("Package names may not have more than one colon.");
}
if (packageName[0] === ":" || __.last(packageName) === ":") {
throwVersionParserError("Package names may not start or end with a colon.");
}
};
var throwVersionParserError = function (message) {

View File

@@ -486,7 +486,14 @@ main.registerCommand({
utils.validatePackageNameOrExit(
packageName, {detailedColonExplanation: true});
var fsName = colonConverter.convert(packageName);
// When we create a package, avoid introducing a colon into the file system
// by naming the directory after the package name without the prefix.
var fsName = packageName;
if (packageName.indexOf(":") !== -1) {
var split = packageName.split(":");
fsName = split[1];
}
var packageDir;
if (options.appDir) {
packageDir = files.pathResolve(options.appDir, 'packages', fsName);
@@ -549,7 +556,7 @@ main.registerCommand({
// match the name of the package exactly, therefore we should tell people
// where it was created.
Console.info(
packageName + ": created in ",
packageName + ": created in",
Console.path(displayPackageDir)
);

View File

@@ -742,7 +742,7 @@ selftest.define("package skeleton creates correct versionsFrom", function () {
var s = new Sandbox({ warehouse: { v1: { recommended: true } } });
var token = utils.randomToken();
var fullPackageName = "test:" + token;
var fsPackageName = "test_" + token;
var fsPackageName = token;
var run = s.run("create", "--package", fullPackageName);
run.waitSecs(15);

View File

@@ -16,7 +16,7 @@ selftest.define("create-publish-and-search",
testUtils.login(s, username, password);
var packageName = utils.randomToken();
var fullPackageName = username + ":" + packageName;
var fsPackageName = username + "_" + packageName;
var fsPackageName = packageName;
var githubUrl = "http://github.com/foo/bar";
var summary = "Package for test";