extendPackage (fields, options = {}) {
    const extendOptions = {
      prune: false,
      merge: true,
      warnIncompatibleVersions: true,
      forceOverwrite: false
    }

    // this condition statement is added for compatibility reason, because
    // in version 4.0.0 to 4.1.2, there's no `options` object, but a `forceNewVersion` flag
    if (typeof options === 'boolean') {
      extendOptions.warnIncompatibleVersions = !options
    } else {
      Object.assign(extendOptions, options)
    }

    const pkg = this.generator.pkg
    const toMerge = isFunction(fields) ? fields(pkg) : fields
    for (const key in toMerge) {
      const value = toMerge[key]
      const existing = pkg[key]
      if (isObject(value) && (key === 'dependencies' || key === 'devDependencies')) {
        // use special version resolution merge
        pkg[key] = mergeDeps(
          this.id,
          existing || {},
          value,
          this.generator.depSources,
          extendOptions
        )
      } else if (!extendOptions.merge || !(key in pkg)) {
        pkg[key] = value
      } else if (Array.isArray(value) && Array.isArray(existing)) {
        pkg[key] = mergeArrayWithDedupe(existing, value)
      } else if (isObject(value) && isObject(existing)) {
        pkg[key] = deepmerge(existing, value, { arrayMerge: mergeArrayWithDedupe })
      } else {
        pkg[key] = value
      }
    }

    if (extendOptions.prune) {
      pruneObject(pkg)
    }
  }
Extend the package.json of the project.
Also resolves dependency conflicts between plugins.
Tool configuration fields may be extracted into standalone files before
files are written to disk.

@param {object | () => object} fields - Fields to merge.
@param {object} [options] - Options for extending / merging fields.
@param {boolean} [options.prune=false] - Remove null or undefined fields
   from the object after merging.
@param {boolean} [options.merge=true] deep-merge nested fields, note
   that dependency fields are always deep merged regardless of this option.
@param {boolean} [options.warnIncompatibleVersions=true] Output warning
   if two dependency version ranges don't intersect.
@param {boolean} [options.forceOverwrite=false] force using the dependency
version provided in the first argument, instead of trying to get the newer ones