Skip to content

Commit 0f6c31c

Browse files
author
ekatek
committed
upload README.md files to the server and view the excerpt in meteor show
This commit is based on the following design document: https://mdg.hackpad.com/Creating-and-Updating-Docs-0ZyyDcSZDxp, and some other stuff from here: https://mdg.hackpad.com/Meteor-Long-Description-wGZ1vIOwVlF and was code reviewed here: meteor#3375 It does the following: - Allow the user to specify package documentation in Package.Describe. We will take the README.md file by default, to make the transition easier. Users can specify ‘documentation: null’ to not submit a README.md - From that documentation, extract the section between the first and second header to use as the long form description for the package. - Upload the documentation to the server at publish-time. Allow metadata changes with ‘publish —update’. - Change the default package skeleton to include the README.md file. Also, changes the skeleton to have fewer useless placeholders in Package.describe values. - Fix a minor bug where Git did not show up when running ‘meteor show’ on local packages. A note on ‘documentation: null’ and blank documentation — we don’t let maintainers upload blank README.md files, because we want to encourage people to fill them out. (Instead, we allow a ‘documentation: null’ as an override) This is a UX issue! It is not a technical thing. There is more discussion and code review in: meteor#3375
1 parent 5bba62e commit 0f6c31c

26 files changed

+1183
-152
lines changed

meteor

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#!/bin/bash
22

3-
<<<<<<< HEAD
4-
BUNDLE_VERSION=0.3.82
5-
=======
6-
BUNDLE_VERSION=0.3.76
7-
>>>>>>> d1d1353... completely rewrite of ‘meteor show’; some changes to ‘meteor search’.
3+
BUNDLE_VERSION=0.3.83
84

95
# OS Check. Put here because here is where we download the precompiled
106
# bundles that are arch specific.

scripts/dev-bundle-tool-package.js

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ var packageJson = {
3434
"http-proxy": "1.6.0",
3535
"wordwrap": "0.0.2",
3636
"moment": "2.8.4",
37+
// XXX: When we update this, see if it fixes this Github issue:
38+
// https://github.com/jgm/CommonMark/issues/276 . If it does, remove the
39+
// workaround from the tool.
40+
"commonmark": "0.15.0",
3741
// XXX We ought to be able to get this from the copy in js-analyze rather
3842
// than in the dev bundle.)
3943
esprima: "1.2.2",

tools/catalog-local.js

+1
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ _.extend(LocalCatalog.prototype, {
308308
version: packageSource.version,
309309
publishedBy: null,
310310
description: packageSource.metadata.summary,
311+
git: packageSource.metadata.git,
311312
dependencies: packageSource.getDependencyMetadata(),
312313
source: null,
313314
lastUpdated: null,

tools/commands-packages-query.js

+21-6
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ _.extend(PkgExports.prototype, {
259259
// the details of printing their data to the screen.
260260
//
261261
// A query class has:
262-
// - data: an object representing the data it has collected in response to the query.
262+
// - data: an object representing the data it has collected in response to the
263+
// - query.
263264
// - a print method, that take options as an argument and prints the results to
264265
// the terminal.
265266

@@ -268,7 +269,6 @@ _.extend(PkgExports.prototype, {
268269
// packages, it has to interact with the projectContext.
269270
//
270271
// The constructor takes in the following options:
271-
272272
// - metaRecord: (mandatory) the meta-record for this package from the Packages
273273
// collection.
274274
// - projectContext: (mandatory) a projectContext that we can use to look up
@@ -466,9 +466,15 @@ _.extend(PackageQuery.prototype, {
466466
if (local) {
467467
data["defaultVersion"] = local;
468468
} else {
469-
var mainRecord = catalog.official.getLatestMainlineVersion(self.name);
470-
if (mainRecord) {
471-
data["defaultVersion"] = self._getOfficialVersion(mainRecord);
469+
var mainlineRecord = catalog.official.getLatestMainlineVersion(self.name);
470+
if (mainlineRecord) {
471+
var pkgExports = new PkgExports(mainlineRecord.exports);
472+
data["defaultVersion"] = {
473+
summary: mainlineRecord.description,
474+
description: mainlineRecord.longDescription,
475+
git: mainlineRecord.git,
476+
exports: pkgExports
477+
};
472478
} else {
473479
data["defaultVersion"] = _.last(data.versions);
474480
}
@@ -602,6 +608,16 @@ _.extend(PackageQuery.prototype, {
602608
data["dependencies"] = rewriteDependencies(localRecord.dependencies);
603609
}
604610

611+
var readmeInfo;
612+
main.captureAndExit(
613+
"=> Errors while reading local packages:",
614+
"reading " + data["directory"],
615+
function () {
616+
readmeInfo = packageSource.processReadme();
617+
});
618+
if (readmeInfo) {
619+
data["description"] = readmeInfo.excerpt;
620+
}
605621
return data;
606622
},
607623
// Displays version information from this PackageQuery to the terminal in a
@@ -1060,7 +1076,6 @@ _.extend(ReleaseQuery.prototype, {
10601076
// - packages: map of packages for this release version
10611077
_displayVersion: function (data) {
10621078
var self = this;
1063-
var data = self.data;
10641079
Console.info("Release: " + data.track);
10651080
Console.info("Version: " + data.version);
10661081
Console.info(

tools/commands-packages.js

+85-2
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,74 @@ main.registerCommand({
172172
// publish a package
173173
///////////////////////////////////////////////////////////////////////////////
174174

175+
// Updates the metadata for a given package version. Prints user-friendly
176+
// messages if certain new values are invalid; calls to the packageClient to
177+
// perform the actual update.
178+
//
179+
// Takes in a packageSource and a connection to the package server. Returns 0 on
180+
// success and an exit code on failure.
181+
var updatePackageMetadata = function (packageSource, conn) {
182+
var name = packageSource.name;
183+
var version = packageSource.version;
184+
185+
// You can't change the metadata of a record that doesn't exist.
186+
var existingRecord =
187+
catalog.official.getVersion(name, version);
188+
if (! existingRecord) {
189+
Console.error(
190+
"You can't call", Console.command("`meteor publish --update`"),
191+
"on version " + version + " of " + "package '" + name +
192+
"' without publishing it first.");
193+
return 1;
194+
}
195+
196+
// Load in the user's documentation, and check that it isn't blank.
197+
var readmeInfo;
198+
main.captureAndExit(
199+
"=> Errors while publishing:", "reading documentation",
200+
function () {
201+
readmeInfo = packageSource.processReadme();
202+
});
203+
204+
// You are still not allowed to upload a blank README.md.
205+
if (readmeInfo && readmeInfo.hash === files.blankHash) {
206+
Console.error(
207+
"Your documentation file is blank, so users may have trouble",
208+
"figuring out how to use your package. Please fill it out, or",
209+
"set 'documentation: null' in your Package.describe.");
210+
return 1;
211+
};
212+
213+
// Finally, call to the server.
214+
main.captureAndExit(
215+
"=> Errors while publishing:",
216+
"updating package metadata",
217+
function () {
218+
packageClient.updatePackageMetadata({
219+
packageSource: packageSource,
220+
readmeInfo: readmeInfo,
221+
connection: conn
222+
});
223+
});
224+
225+
Console.info(
226+
"Success. You can take a look at the new metadata by running",
227+
Console.command("'meteor show " + name + "@" + version + "'"),
228+
"outside the current project directory.");
229+
230+
// Refresh, so that we actually learn about the thing we just published.
231+
refreshOfficialCatalogOrDie();
232+
return 0;
233+
}
234+
235+
175236
main.registerCommand({
176237
name: 'publish',
177238
minArgs: 0,
178239
maxArgs: 0,
179240
options: {
180241
create: { type: Boolean },
242+
update: { type: Boolean },
181243
// This is similar to publish-for-arch, but uses the source code you have
182244
// locally (and other local packages you may have) instead of downloading
183245
// the source bundle. It does verify that the source is the same, though.
@@ -194,8 +256,22 @@ main.registerCommand({
194256
}, function (options) {
195257
if (options.create && options['existing-version']) {
196258
// Make up your mind!
197-
Console.error("The --create and --existing-version options cannot " +
198-
"both be specified.");
259+
Console.error(
260+
"The --create and --existing-version options cannot",
261+
"both be specified.");
262+
return 1;
263+
}
264+
265+
if (options.update && options.create) {
266+
Console.error(
267+
"The --create and --update options cannot both be specified.");
268+
return 1;
269+
}
270+
271+
if (options.update && options["existing-version"]) {
272+
Console.error(
273+
"The --update option implies that the version already exists.",
274+
"You do not need to use the --existing-version flag with --update.");
199275
return 1;
200276
}
201277

@@ -275,6 +351,13 @@ main.registerCommand({
275351
return 1;
276352
}
277353

354+
// If we just want to update the package metadata, then we have all we
355+
// need. Don't bother building the package, just update the metadata and
356+
// return the result.
357+
if (options.update) {
358+
return updatePackageMetadata(packageSource, conn);
359+
}
360+
278361
// Fail early if the package record exists, but we don't think that it does
279362
// and are passing in the --create flag!
280363
if (options.create) {

tools/files.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ files.fileHash = function (filename) {
307307
return fut.wait();
308308
};
309309

310+
// This is the result of running fileHash on a blank file.
311+
files.blankHash = "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=";
310312

311313
// Returns a base64 SHA256 hash representing a tree on disk. It is not sensitive
312314
// to modtime, uid/gid, or any permissions bits other than the current-user-exec
@@ -1219,4 +1221,3 @@ files.pathwatcherWatch = function () {
12191221
var pathwatcher = require('meteor-pathwatcher-tweaks');
12201222
return pathwatcher.watch.apply(pathwatcher, args);
12211223
};
1222-

tools/help.txt

+15-7
Original file line numberDiff line numberDiff line change
@@ -599,25 +599,33 @@ Options:
599599
Publish a new version of a package to the package server.
600600

601601
Usage: meteor publish [--create]
602+
meteor publish --update
602603

603604
Publishes a new version of a local package to the package server. Must be run
604605
from the directory containing the package. Reads the package.js file for version
605606
information, builds the package and sends both the package source and the built
606607
version of the package to the package server.
607608

608-
This will only create one build of the package. If your package has multiple
609-
builds for different OS architectures, it will create a build for this machine's
610-
architecture. To publish a different build for the same version, run
611-
publish-for-arch.
609+
This will create at most one build of the package. If the package has an
610+
OS-dependent binary component, publishing will only register metadata about the
611+
package. To actually publish the package builds, use `meteor admin get-machine`
612+
and `meteor publish-for-arch`. Packages with no published builds cannot be added
613+
to applications.
612614

613-
This will mark you as the only maintainer of the package. If you need to change
614-
maintainers and other metadata about this package & package version, take a look
615-
at the admin commands.
615+
This will mark you as the only maintainer of the package. You can use
616+
'meteor admin maintainers' to change package maintainers. For more information
617+
about admin commands, run 'meteor help admin'.
618+
619+
Change the metadata for a given version of a package by running with the
620+
--update flag. That will set the git url, version summary, longform description
621+
and documentation in the database to their new values. You can use 'meteor show'
622+
to preview the results.
616623

617624
Pass --create to create a new package.
618625

619626
Options:
620627
--create publish a new package
628+
--update changed metadata of a previously published version
621629

622630

623631
>>> publish-for-arch

0 commit comments

Comments
 (0)