_generateIntegrityFile(lockfile, patterns, flags, workspaceLayout, artifacts) {
    var _this3 = this;

    return (0, (_asyncToGenerator2 || _load_asyncToGenerator()).default)(function* () {
      const result = (0, (_extends2 || _load_extends()).default)({}, INTEGRITY_FILE_DEFAULTS(), {
        artifacts
      });

      result.topLevelPatterns = patterns;

      // If using workspaces, we also need to add the workspaces patterns to the top-level, so that we'll know if a
      // dependency is added or removed into one of them. We must take care not to read the aggregator (if !loc).
      //
      // Also note that we can't use of workspaceLayout.workspaces[].manifest._reference.patterns, because when
      // doing a "yarn check", the _reference property hasn't yet been properly initialized.

      if (workspaceLayout) {
        result.topLevelPatterns = result.topLevelPatterns.filter(function (p) {
          // $FlowFixMe
          return !workspaceLayout.getManifestByPattern(p);
        });

        for (var _iterator4 = Object.keys(workspaceLayout.workspaces), _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) {
          var _ref5;

          if (_isArray4) {
            if (_i4 >= _iterator4.length) break;
            _ref5 = _iterator4[_i4++];
          } else {
            _i4 = _iterator4.next();
            if (_i4.done) break;
            _ref5 = _i4.value;
          }

          const name = _ref5;

          if (!workspaceLayout.workspaces[name].loc) {
            continue;
          }

          const manifest = workspaceLayout.workspaces[name].manifest;

          if (manifest) {
            for (var _iterator5 = (_constants || _load_constants()).DEPENDENCY_TYPES, _isArray5 = Array.isArray(_iterator5), _i5 = 0, _iterator5 = _isArray5 ? _iterator5 : _iterator5[Symbol.iterator]();;) {
              var _ref6;

              if (_isArray5) {
                if (_i5 >= _iterator5.length) break;
                _ref6 = _iterator5[_i5++];
              } else {
                _i5 = _iterator5.next();
                if (_i5.done) break;
                _ref6 = _i5.value;
              }

              const dependencyType = _ref6;

              const dependencies = manifest[dependencyType];

              if (!dependencies) {
                continue;
              }

              for (var _iterator6 = Object.keys(dependencies), _isArray6 = Array.isArray(_iterator6), _i6 = 0, _iterator6 = _isArray6 ? _iterator6 : _iterator6[Symbol.iterator]();;) {
                var _ref7;

                if (_isArray6) {
                  if (_i6 >= _iterator6.length) break;
                  _ref7 = _iterator6[_i6++];
                } else {
                  _i6 = _iterator6.next();
                  if (_i6.done) break;
                  _ref7 = _i6.value;
                }

                const dep = _ref7;

                result.topLevelPatterns.push(`${dep}@${dependencies[dep]}`);
              }
            }
          }
        }
      }

      result.topLevelPatterns.sort((_misc || _load_misc()).sortAlpha);

      if (flags.checkFiles) {
        result.flags.push('checkFiles');
      }

      if (flags.flat) {
        result.flags.push('flat');
      }

      if (_this3.config.ignoreScripts) {
        result.flags.push('ignoreScripts');
      }
      if (_this3.config.focus) {
        result.flags.push('focus: ' + _this3.config.focusedWorkspaceName);
      }

      if (_this3.config.production) {
        result.flags.push('production');
      }

      if (_this3.config.plugnplayEnabled) {
        result.flags.push('plugnplay');
      }

      const linkedModules = _this3.config.linkedModules;

      if (linkedModules.length) {
        result.linkedModules = linkedModules.sort((_misc || _load_misc()).sortAlpha);
      }

      for (var _iterator7 = Object.keys(lockfile), _isArray7 = Array.isArray(_iterator7), _i7 = 0, _iterator7 = _isArray7 ? _iterator7 : _iterator7[Symbol.iterator]();;) {
        var _ref8;

        if (_isArray7) {
          if (_i7 >= _iterator7.length) break;
          _ref8 = _iterator7[_i7++];
        } else {
          _i7 = _iterator7.next();
          if (_i7.done) break;
          _ref8 = _i7.value;
        }

        const key = _ref8;

        result.lockfileEntries[key] = lockfile[key].resolved || '';
      }

      for (var _iterator8 = _this3._getModulesFolders({ workspaceLayout }), _isArray8 = Array.isArray(_iterator8), _i8 = 0, _iterator8 = _isArray8 ? _iterator8 : _iterator8[Symbol.iterator]();;) {
        var _ref9;

        if (_isArray8) {
          if (_i8 >= _iterator8.length) break;
          _ref9 = _iterator8[_i8++];
        } else {
          _i8 = _iterator8.next();
          if (_i8.done) break;
          _ref9 = _i8.value;
        }

        const modulesFolder = _ref9;

        if (yield (_fs || _load_fs()).exists(modulesFolder)) {
          result.modulesFolders.push(path.relative(_this3.config.lockfileFolder, modulesFolder));
        }
      }

      if (flags.checkFiles) {
        const modulesRoot = _this3._getModulesRootFolder();

        result.files = (yield _this3._getIntegrityListing({ workspaceLayout })).map(function (entry) {
          return path.relative(modulesRoot, entry);
        }).sort((_misc || _load_misc()).sortAlpha);
      }

      return result;
    })();
  }
Generate integrity hash of input lockfile.