cnpm / cnpmjs.org

@@ -356,22 +356,10 @@
Loading
356 356
357 357
// https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-version-object
358 358
exports.saveModuleAbbreviated = function* (mod) {
359 -
  var pkg = JSON.stringify({
360 -
    name: mod.package.name,
361 -
    version: mod.package.version,
362 -
    deprecated: mod.package.deprecated,
363 -
    dependencies: mod.package.dependencies,
364 -
    optionalDependencies: mod.package.optionalDependencies,
365 -
    devDependencies: mod.package.devDependencies,
366 -
    bundleDependencies: mod.package.bundleDependencies,
367 -
    peerDependencies: mod.package.peerDependencies,
368 -
    bin: mod.package.bin,
369 -
    directories: mod.package.directories,
370 -
    dist: mod.package.dist,
371 -
    engines: mod.package.engines,
372 -
    _hasShrinkwrap: mod.package._hasShrinkwrap,
373 -
    _publish_on_cnpm: mod.package._publish_on_cnpm,
374 -
  });
359 +
  var pkg = JSON.stringify(Object.assign({}, mod.package, {
360 +
    // ignore readme force
361 +
    readme: undefined,
362 +
  }));
375 363
  var publish_time = mod.publish_time || Date.now();
376 364
  var item = yield models.ModuleAbbreviated.findByNameAndVersion(mod.name, mod.version);
377 365
  if (!item) {
@@ -417,7 +405,7 @@
Loading
417 405
};
418 406
419 407
exports.updateModuleAbbreviatedPackage = function* (item) {
420 -
  // item => { id, name, version, _hasShrinkwrap }
408 +
  // item => { id, name, version, _hasShrinkwrap, os, cpu, peerDependenciesMeta, workspaces }
421 409
  var mod = yield models.ModuleAbbreviated.findByNameAndVersion(item.name, item.version);
422 410
  if (!mod) {
423 411
    return null;

@@ -391,10 +391,14 @@
Loading
391 391
      devDependencies: row.package.devDependencies,
392 392
      bundleDependencies: row.package.bundleDependencies,
393 393
      peerDependencies: row.package.peerDependencies,
394 +
      peerDependenciesMeta: row.package.peerDependenciesMeta,
394 395
      bin: row.package.bin,
396 +
      os: row.package.os,
397 +
      cpu: row.package.cpu,
395 398
      directories: row.package.directories,
396 399
      dist: row.package.dist,
397 400
      engines: row.package.engines,
401 +
      workspaces: row.package.workspaces,
398 402
      _hasShrinkwrap: row.package._hasShrinkwrap,
399 403
      publish_time: row.package.publish_time || row.publish_time,
400 404
    };

@@ -863,8 +863,26 @@
Loading
863 863
        var versions = data && data.versions || {};
864 864
        for (var version in versions) {
865 865
          const item = versions[version];
866 -
          if (item && typeof item._hasShrinkwrap === 'boolean') {
867 -
            remoteAbbreviatedMetadatas[version] = { _hasShrinkwrap: item._hasShrinkwrap };
866 +
          if (!item) {
867 +
            continue;
868 +
          }
869 +
          let hasMetaData = false;
870 +
          const metaData = {};
871 +
          // _hasShrinkwrap maybe undefined, dont change it
872 +
          if (typeof item._hasShrinkwrap === 'boolean') {
873 +
            hasMetaData = true;
874 +
            metaData._hasShrinkwrap = item._hasShrinkwrap;
875 +
          }
876 +
877 +
          const metaDataKeys = [ 'peerDependenciesMeta', 'os', 'cpu', 'workspaces' ];
878 +
          for (const key of metaDataKeys) {
879 +
            if (key in item) {
880 +
              hasMetaData = true;
881 +
              metaData[key] = item[key];
882 +
            }
883 +
          }
884 +
          if (hasMetaData) {
885 +
            remoteAbbreviatedMetadatas[version] = metaData;
868 886
          }
869 887
        }
870 888
      }
@@ -884,7 +902,7 @@
Loading
884 902
  var diffNpmMaintainers = [];
885 903
886 904
  // [
887 -
  //   { name, version, _hasShrinkwrap }
905 +
  //   { name, version, _hasShrinkwrap(boolean), peerDependenciesMeta(object), os(array), cpu(array), workspaces(array) }
888 906
  // ]
889 907
  var missingAbbreviatedMetadatas = [];
890 908
  // [
@@ -1056,16 +1074,32 @@
Loading
1056 1074
          });
1057 1075
          changedVersions[v] = 1;
1058 1076
        }
1077 +
1059 1078
        // find missing abbreviatedMetadata
1060 1079
        if (abbreviatedMetadata) {
1061 1080
          for (var key in abbreviatedMetadata) {
1062 -
            if (!(key in exists.package) || abbreviatedMetadata[key] !== exists.package[key]) {
1063 -
              missingAbbreviatedMetadatas.push(Object.assign({
1064 -
                id: exists.id,
1065 -
                name: exists.package.name,
1066 -
                version: exists.package.version,
1067 -
              }, abbreviatedMetadata));
1068 -
              break;
1081 +
            const value = abbreviatedMetadata[key];
1082 +
            // boolean: _hasShrinkwrap
1083 +
            if (key === '_hasShrinkwrap' && typeof value === 'boolean') {
1084 +
              if (!(key in exists.package) || abbreviatedMetadata[key] !== exists.package[key]) {
1085 +
                missingAbbreviatedMetadatas.push(Object.assign({
1086 +
                  id: exists.id,
1087 +
                  name: exists.package.name,
1088 +
                  version: exists.package.version,
1089 +
                }, abbreviatedMetadata));
1090 +
                break;
1091 +
              }
1092 +
            } else if (Array.isArray(value) || (typeof value === 'object' && value)) {
1093 +
              // array: os, cpu, workspaces
1094 +
              // object: peerDependenciesMeta
1095 +
              if (existsModuleAbbreviated && !(key in existsModuleAbbreviated.package)) {
1096 +
                missingAbbreviatedMetadatas.push(Object.assign({
1097 +
                  id: exists.id,
1098 +
                  name: exists.package.name,
1099 +
                  version: exists.package.version,
1100 +
                }, abbreviatedMetadata));
1101 +
                break;
1102 +
              }
1069 1103
            }
1070 1104
          }
1071 1105
        }
Files Coverage
common 66.67%
controllers 86.74%
middleware 94.34%
models 90.42%
routes 100.00%
servers 90.91%
services 90.82%
sync 89.61%
config/index.js 75.51%
lib/common.js 89.19%
Project Totals (97 files) 88.04%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading