Skip to content

Commit

Permalink
rename .meteor/identifier -> .meteor/.id
Browse files Browse the repository at this point in the history
  • Loading branch information
glasser committed Aug 23, 2014
1 parent 1ff2c3b commit c4948d8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
6 changes: 3 additions & 3 deletions examples/.gitignore
Expand Up @@ -10,8 +10,8 @@
*/.meteor/local
*/*/.meteor/local

# We don't want to check example identifier files into the main meteor
# We don't want to check example project id files into the main meteor
# repo... but we do want users who create apps from the examples to check
# *their* identifier files into their repos, so we put this ignore line
# *their* project id files into their repos, so we put this ignore line
# here rather than in the examples/FOO/.meteor/.gitignore.
*/.meteor/identifier
*/.meteor/.id
8 changes: 4 additions & 4 deletions tools/commands.js
Expand Up @@ -384,11 +384,11 @@ main.registerCommand({
return 1;
} else {
files.cp_r(path.join(exampleDir, options.example), appPath, {
// We try not to check the identifier into git, but it might still
// We try not to check the project ID into git, but it might still
// accidentally exist and get added (if running from checkout, for
// example). To be on the safe side, explicitly remove the identifier
// example). To be on the safe side, explicitly remove the project ID
// from example apps.
ignore: [/^local$/, /^identifier$/]
ignore: [/^local$/, /^\.id$/]
});
}
} else {
Expand All @@ -402,7 +402,7 @@ main.registerCommand({
else
return contents;
},
ignore: [/^local$/, /^identifier$/]
ignore: [/^local$/, /^\.id$/]
});
}

Expand Down
9 changes: 6 additions & 3 deletions tools/project.js
Expand Up @@ -72,8 +72,9 @@ var Project = function () {
// loaders). Derived from self.dependencies.
self.packageLoader = null;

// The app identifier is used for stats, read from a file and not invalidated
// by any constraint-related operations.
// The app identifier is used for stats and to prevent accidental deploys to
// the wrong domain. It is read from a file and not invalidated by any
// constraint-related operations.
self.appId = null;

// Should we use this project as a source for dependencies? Certainly not
Expand Down Expand Up @@ -714,7 +715,7 @@ _.extend(Project.prototype, {
// The file for the app identifier.
appIdentifierFile : function () {
var self = this;
return path.join(self.rootDir, '.meteor', 'identifier');
return path.join(self.rootDir, '.meteor', '.id');
},

// Get the app identifier.
Expand All @@ -734,9 +735,11 @@ _.extend(Project.prototype, {
var identifierFile = self.appIdentifierFile();
if (!fs.existsSync(identifierFile)) {
var id = utils.randomToken() + utils.randomToken() + utils.randomToken();
// XXX add a comment
fs.writeFileSync(identifierFile, id + '\n');
}
if (fs.existsSync(identifierFile)) {
// XXX parse out comments
self.appId = trimLine(fs.readFileSync(identifierFile, 'utf8'));
} else {
throw new Error("Expected a file at " + identifierFile);
Expand Down
16 changes: 10 additions & 6 deletions tools/tests/report-stats.js
Expand Up @@ -17,7 +17,6 @@ process.env.METEOR_PACKAGE_STATS_SERVER_URL = testStatsServer;

var clientAddress;


// NOTE: This test will fail if your machine's time is skewed by more
// than 30 minutes. This is because the `fetchAppPackageUsage` method
// works by passing an hour time range.
Expand Down Expand Up @@ -75,14 +74,14 @@ selftest.define("report-stats", ["slow", "net"], function () {
var sessionId;

// verify that identifier file exists for new apps
var identifier = s.read(".meteor/identifier").replace(/\n$/, '');
var identifier = readProjectId(s);
selftest.expectEqual(!! identifier, true);
selftest.expectEqual(identifier.length > 0, true);

// verify that identifier file when running 'meteor run' on apps
// with no identifier file (eg pre-0.9.0 apps)
runWithFreshIdentifier(s, sandboxProject);
identifier = s.read(".meteor/identifier").replace(/\n$/, '');
identifier = readProjectId(s);
selftest.expectEqual(!! identifier, true);
selftest.expectEqual(identifier.length > 0, true);

Expand Down Expand Up @@ -203,15 +202,20 @@ selftest.define("report-stats", ["slow", "net"], function () {
});

// Run the app in the current working directory after deleting its
// identifier file (meaning a new one will be created).
// project ID file (meaning a new one will be created).
// @param s {Sandbox}
// @param sandboxProject {Project}
// @param expectStats {Boolean} (defaults to true)
var runWithFreshIdentifier = function (s, sandboxProject, expectStats) {
s.unlink(".meteor/identifier");
s.unlink(".meteor/.id");
runApp(s, sandboxProject, expectStats);
};

var readProjectId = function (s) {
// XXX parse comments
return s.read(".meteor/.id").replace(/\n$/, '');
};

// Bundle the app in the current working directory.
// @param s {Sandbox}
// @param sandboxProject {Project}
Expand All @@ -230,7 +234,7 @@ var runApp = function (s, sandboxProject, expectStats) {
}
run.stop();
// Pick up new app identifier and/or packages added/removed. Usually the
// changes to .meteor/packages and .meteor/identifier would be handled by the
// changes to .meteor/packages and .meteor/.id would be handled by the
// code that handles the hotcodepush, so the project does not cache them.
sandboxProject.reload();
};
Expand Down

0 comments on commit c4948d8

Please sign in to comment.