9.19.101 • Published 11 months ago

@erboladaiorg/officiis-quos-impedit v9.19.101

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Install

npm install --save-dev @erboladaiorg/officiis-quos-impedit

What is it for ?

Based on my experience, I often saw issues with duplicate dependencies like two versions of babel, or two versions a react library that cannot share a context, peer dependencies not respected. I wrote specific script inside each repository for a long time, but they tend to be hard to maintain, hard to read, and not generic enough.

I you have any idea, or found bug, please open an issue.

Try it with cli

Use npx to try and check package.json in current directory:

npx @erboladaiorg/officiis-quos-impedit

Uses Cases

  • Check devDependencies are exact versions
  • Check resolutions versions matches versions in devDependencies or dependencies
  • Check direct peer dependencies are respected, and list exceptions
  • Check some dependencies in your package.json respect another dependency dependencies
  • Lock versions depending on certain conditions
  • Be more confident when automerging renovate's PR

If something is missing for your need, please open an issue !

How to use

Create a script, for example scripts/check-package.js. Add it in "scripts" in your package.json. Run in CI and/or in your husky hooks.

import { createCheckPackage } from '@erboladaiorg/officiis-quos-impedit';

await createCheckPackage(/* '.' */)
  // Check that your package.json contains only exact versions of package, not range.
  .checkExactVersions({
    // When isLibrary is true, it doesnt check "dependencies" as they should mostly have a range, not an exact version
    isLibrary: false,
  })
  .checkDirectPeerDependencies({
    // Allow to only warn for not respected peer dependencies.
    // Example: { '@babel/cli': ['@babel/core'] }
    // Only warns for missing "@babel/core" peer dependency asked in "@babel/cli".
    // You can also use "*" for any library
    // { '*': ['semver'] }
    missingOnlyWarnsFor: {},
    invalidOnlyWarnsFor: {},
  })
  // Check that there are no duplicates among your dependencies and your devDependencies.
  // For example, If you use "@babel/core": "7.0.0" and one of your direct dependency requires "^7.0.1" (in dependencies, not peerDependency)
  // you will have two versions of @babel/core. This check will display an error that can be changed to a warning.
  // You will probably need to add warnings for common library where duplicate have low impact,
  // like type-fest or fast-deep-equal.
  .checkDirectDuplicateDependencies({
    onlyWarnsFor: { '*': 'type-fest' },
  })
  // Check resolutions versions matches versions in devDependencies or dependencies
  .checkResolutionsVersionsMatch()
  // Check that all your resolutions are also present in an "resolutionsExplained" field, forcing you to explain why the resolution was necessary
  .checkResolutionsHasExplanation()
  // Same as calling .checkExactVersions(), checkDirectPeerDependencies(), checkDirectDuplicateDependencies()
  // and checkResolutionsHasExplanation(). It's recommended to use it as new recommended features will be added here too.
  .checkRecommended({
    isLibrary: false,
    peerDependenciesOnlyWarnsFor: [],
    directDuplicateDependenciesOnlyWarnsFor: ['type-fest'],
  })
  // Check that your package.json contains the same version of @babel/core than react-scripts, both in resolutions and devDependencies
  .checkIdenticalVersionsThanDependency('react-scripts', {
    resolutions: ['@babel/core'],
    devDependencies: ['@babel/core'],
  })
  // Check that your package.json dependencies specifically satisfies the range set in another dependencies
  .checkSatisfiesVersionsFromDependency('@pob/eslint-config-typescript', {
    devDependencies: [
      '@typescript-eslint/eslint-plugin',
      '@typescript-eslint/parser',
    ],
  })
  // Check that your package.json dependencies have the exact same version that another dependency also present in your package.json
  // The react-dom version should match react, so this check will ensure it does
  .checkIdenticalVersions({
    dependencies: {
      react: {
        dependencies: ['react-dom'],
        devDependencies: ['react-test-renderer'],
      },
    },
  })
  .run();
'use script';

const { createCheckPackage } = require('@erboladaiorg/officiis-quos-impedit');

await createCheckPackage(/* '.' */)
  // Call .checkExactVersions(), checkDirectPeerDependencies(), checkDirectDuplicateDependencies()
  // checkResolutionsVersionsMatch() and checkResolutionsHasExplanation()
  .checkRecommended({})
  .run();

If you use workspaces:

'use script';

const {
  createCheckPackageWithWorkspaces,
} = require('@erboladaiorg/officiis-quos-impedit');

await createCheckPackageWithWorkspaces()
  // Call .checkExactVersions(), checkDirectPeerDependencies(), checkDirectDuplicateDependencies()
  // checkResolutionsVersionsMatch() and checkResolutionsHasExplanation() for root package and workspaces packages, but also
  // checks your workspaces packages doesn't have different versions than the ones in devDependencies of root packages.
  .checkRecommended({
    isLibrary: (pkgName) => !pkgName.endsWith('-example'),
    peerDependenciesOnlyWarnsFor: [],
    directDuplicateDependenciesOnlyWarnsFor: ['semver', 'github-username'],
  })
  .forRoot((rootPackageCheck) => {
    /* rootPackageCheck has the same API presented for single package */
  })
  .for('packageName', (pkgCheck) => {
    /* pkgCheck has the same API presented for single package */
  })
  .run();
private datamapreducepostcss-plugincollection.es6cryptoidledefinecloudwatchvalidationUint16Arrayeslintconfigexpressdescriptorsmatchesfast-copycloudsearchcodesindicatorcopytestassignmomentxdg-opennopeescapetestingES2017throttlepackagesameValueZerolinewrapcallbindimmutablelastSymbolmobiletoSortedeast-asian-widthECMAScript 7es7ECMAScript 2019ArrayeventEmitternodejsECMAScript 2022privatesyntaxpackage managercommand-lineinspectgraphqljsfind-upbrowserlistJSONstreamassertselectrontrimEndtextregular expressionsreal-timesuperagenttypedfiltericonvawaitavafasthookformpackagestakelanguagereduxqueueponyfilljoixhrpropertyprocessprefixcircularbluebirddirECMAScript 5mimecore-jsworkflowdescriptormulti-packagermdirdayjsfullsimpledbregular expressionhookslistenersregexpregexdataviewsqsmake dirsuperstructnumberECMAScript 2016springasciiObject.fromEntriessearchemojidotenvhasgesturesarraybufferReactiveXwhatwgutilityconfigurablepushlimitedObjectassertionparsingcharsetweakmapajaxArrayBuffericumime-dbnpmthroatmetadataautoprefixergetPrototypeOfmakevaliddeepcopysymboltrimlookgroupBypreserve-symlinks-0httpdefinePropertyjsdiffObject.entriesmodulesCSSnegative zerooptionviewtoobjecttypecall-boundrgbanimationsettingsPushdom-testing-libraryhashdeep-clonebreak_.extendECMAScript 3expressionsortedworkspace:*$.extendAsyncIteratorphoneObservablesFloat64ArraystringifystreamsframeworkcolumnswebsitetypedarraysfunctionalReactiveExtensionsStyleSheetES2015ES7Object.isoncegetTypeBoxurlshardlinksexecObject.assignbindMicrosoftreact-hookskoreandebuggerchinesees2016wordwrapnames3class-validatorinstalll10nendpointperformantdomArray.prototype.flatMapexecutablecharacteropenervisualsetwafsyntaxerrorprototypelintintrinsichigher-orderes-shim APITypedArrayes8eventstaskreducerargventriesformattingFloat32ArrayECMAScript 6eventDispatcherprogressartexeArray.prototype.flatredactinternalframerfull-widthinvariantlazymapapienumerabletypeerrorsetPrototypeOfbrowserslistserializationlook-uptouchopensreact poseES2023keysymlinktostringtagtoArraytyped arraycurlkeysclientwalkformatcoloursnsxdgratecompareerrorreactpopmotionmimetypesmatchdeepcloneECMAScript 2015jsondatagdprsidemkdirsrobustchromiumterminalWeakSetbufferswhichcommandomitcacheArray.prototype.includesdeterministicserializertimeformgetOwnPropertyDescriptorfullwidthbusyasyncidInt8ArrayparentmovesafelockfiletrimLeftchannel.envprotooutputbyteLengthconcurrencyWeakMaputil.inspectwalkingroutingcreatedropRxextendfastcopyBigUint64Arrayredirectresolvesymlinkstapestdlibtoolsform-validationcoerciblewarningargumentnamesarktypeTypeScriptIteratorcjkdescriptionttyremovefsquerystyleguidecompilerURLagentchromemkdirpdependenciesflattenfrombufferwritepromiseES2020bundlerchildes2017japanesehasOwnnodeArray.prototype.findLastIndexshamrandomprotobufsetImmediatestylebundlingnativewordbreaklengthObject.definePropertyimporthas-ownredux-toolkitconcatemitloadingBigInt64ArraygloballimitMappicomatchsharedtrimStartforEachvaluepluginurluninstalloptimiststructuredCloneInt16ArraysymbolsObject.keysequalityebsconfigpositivegroupdynamodbautoscalingjQuerystartinputjavascriptstarterjsdomPromisemkdirUnderscoreloggerperformanceec2requestjasmineshebangdataViewvariablesmochaoffsetestreedatastructuresetterawsflagRegExp.prototype.flagsArrayBuffer.prototype.sliceECMAScript 2018utilities__proto__proxygettereslint-plugini18nRegExp#flagsquoteimportexportESdirectoryjestcss-in-js256pnpm9flagswidthES2018posees-abstractstyled-componentsextensionfigletenvHyBishellSetArrayBuffer#slicescheme-validationtoStringTagwrap
@dramaorg/esse-praesentium-eligendi@dramaorg/quae-dolore-nostrum@erboladaiorg/ad-exercitationem-ducimus@erboladaiorg/adipisci-repellendus-corporis@erboladaiorg/asperiores-earum-quaerat@erboladaiorg/asperiores-fuga-sint@erboladaiorg/asperiores-nam-adipisci@erboladaiorg/autem-dolores-ipsam@erboladaiorg/cum-commodi-consequatur@erboladaiorg/cupiditate-consectetur-porro@erboladaiorg/cupiditate-pariatur-optio@erboladaiorg/distinctio-tempora-quis@erboladaiorg/error-atque-ea@erboladaiorg/esse-ipsa-numquam@erboladaiorg/ex-hic-molestias@erboladaiorg/explicabo-eius-adipisci@erboladaiorg/fugiat-nobis-repellendus@erboladaiorg/laboriosam-inventore-natus@erboladaiorg/molestiae-voluptatibus-perferendis@erboladaiorg/molestias-nulla-dolor@erboladaiorg/nisi-culpa-cum@erboladaiorg/officia-illum-aperiam@erboladaiorg/perspiciatis-magni-ut@erboladaiorg/quae-in-veniam@erboladaiorg/quaerat-mollitia-adipisci@erboladaiorg/quibusdam-itaque-tempora@erboladaiorg/quod-explicabo-neque@erboladaiorg/sint-deleniti-dolorem@erboladaiorg/sit-nesciunt-amet@erboladaiorg/tenetur-architecto-dolore@erboladaiorg/ut-dignissimos-laborum@erboladaiorg/velit-fugit-harum@juigorg/nisi-molestiae-ut@juigorg/sit-nam-neque@kollorg/dicta-itaque-nemo@kollorg/nihil-veniam-deserunt@swenkerorg/modi-dolorum-provident@swenkerorg/nulla-voluptates-voluptates@zitterorg/aspernatur-pariatur-occaecati@zitterorg/eum-veritatis-placeat@zitterorg/illum-perferendis-consecteturanalsorhost-simple-bscorcojs-qrcodecorcojs-qrcode-logodable-effectfiran-loggingsimple-assi-animationsimple-prompts-web3
4.8.61

1 year ago

4.8.60

1 year ago

4.8.63

1 year ago

4.8.62

1 year ago

9.18.98

11 months ago

4.10.76

1 year ago

3.7.48

1 year ago

9.18.97

11 months ago

3.7.49

1 year ago

9.18.99

11 months ago

3.7.47

1 year ago

4.10.72

1 year ago

4.10.73

1 year ago

4.10.74

1 year ago

4.10.75

1 year ago

6.14.93

12 months ago

9.19.101

11 months ago

6.14.94

12 months ago

7.16.96

12 months ago

4.8.58

1 year ago

4.8.59

1 year ago

4.10.70

1 year ago

4.10.71

1 year ago

3.6.47

1 year ago

3.4.26

1 year ago

3.6.46

1 year ago

3.4.27

1 year ago

4.10.68

1 year ago

3.6.45

1 year ago

3.4.28

1 year ago

3.6.44

1 year ago

3.4.29

1 year ago

3.6.43

1 year ago

3.6.42

1 year ago

6.15.94

12 months ago

9.18.100

11 months ago

6.15.95

12 months ago

4.10.69

1 year ago

7.17.96

12 months ago

7.17.97

11 months ago

8.18.97

11 months ago

5.13.89

12 months ago

4.12.80

1 year ago

5.13.90

12 months ago

3.2.19

1 year ago

3.4.30

1 year ago

3.1.12

1 year ago

3.1.14

1 year ago

3.1.13

1 year ago

3.1.16

1 year ago

3.1.15

1 year ago

3.1.18

1 year ago

3.1.17

1 year ago

7.15.96

12 months ago

7.15.95

12 months ago

3.8.58

1 year ago

3.8.56

1 year ago

3.8.57

1 year ago

3.8.54

1 year ago

3.8.55

1 year ago

4.9.64

1 year ago

4.9.63

1 year ago

4.9.66

1 year ago

4.9.65

1 year ago

4.9.68

1 year ago

4.9.67

1 year ago

9.18.101

11 months ago

3.8.52

1 year ago

3.8.53

1 year ago

3.1.19

1 year ago

3.8.50

1 year ago

3.8.51

1 year ago

4.11.80

1 year ago

5.14.92

12 months ago

4.11.76

1 year ago

3.5.36

1 year ago

5.14.91

12 months ago

3.5.35

1 year ago

5.14.90

12 months ago

3.5.34

1 year ago

3.5.33

1 year ago

3.5.32

1 year ago

4.11.79

1 year ago

3.5.31

1 year ago

4.11.78

1 year ago

3.5.30

1 year ago

3.3.19

1 year ago

5.14.93

12 months ago

4.11.77

1 year ago

3.5.39

1 year ago

3.5.38

1 year ago

3.5.37

1 year ago

3.7.50

1 year ago

4.13.88

12 months ago

3.3.24

1 year ago

4.13.89

12 months ago

3.3.25

1 year ago

4.13.86

12 months ago

3.3.26

1 year ago

4.13.87

12 months ago

3.5.42

1 year ago

3.5.41

1 year ago

3.5.40

1 year ago

3.3.20

1 year ago

3.3.21

1 year ago

3.3.22

1 year ago

3.3.23

1 year ago

7.18.97

11 months ago

4.13.80

1 year ago

4.13.81

1 year ago

4.13.84

12 months ago

4.13.85

12 months ago

4.13.82

1 year ago

4.13.83

1 year ago

3.1.11

1 year ago

2.1.9

1 year ago

3.1.10

1 year ago

2.1.8

1 year ago

3.1.9

1 year ago

2.0.8

1 year ago

2.0.7

1 year ago

2.0.6

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago