github.com/replit/upm@v0.0.0-20240423230255-9ce4fc3ea24c/internal/api/util.go (about) 1 package api 2 3 // QuirksIsNotReproducible returns true if the language backend 4 // specifies QuirksNotReproducible, i.e. the package manager doesn't 5 // support a lockfile and one must be generated after install. 6 func (b *LanguageBackend) QuirksIsNotReproducible() bool { 7 return (b.Quirks & QuirksNotReproducible) != 0 8 } 9 10 // QuirksIsNotReproducible returns true if the language backend does 11 // *not* specify QuirksNotReproducible, i.e. the package manager 12 // supports a lockfile, as expected. 13 func (b *LanguageBackend) QuirksIsReproducible() bool { 14 return (b.Quirks & QuirksNotReproducible) == 0 15 } 16 17 // QuirksDoesAddRemoveAlsoInstall returns true if the language backend 18 // specifies QuirksAddRemoveAlsoInstalls, i.e. it also runs lock and 19 // install when running add or remove. 20 func (b *LanguageBackend) QuirksDoesAddRemoveAlsoInstall() bool { 21 return (b.Quirks & QuirksAddRemoveAlsoInstalls) != 0 22 } 23 24 // QuirksDoesAddRemoveNotAlsoInstall returns true if the language 25 // backend does *not* specify QuirksAddRemoveAlsoInstalls, i.e. 26 // running add or remove does *not* also run install (though it might 27 // run lock; see QuirksDoesAddRemoveAlsoLock). 28 func (b *LanguageBackend) QuirksDoesAddRemoveNotAlsoInstall() bool { 29 return (b.Quirks & QuirksAddRemoveAlsoInstalls) == 0 30 } 31 32 // QuirksDoesAddRemoveAlsoLock returns true if the language backend 33 // specifies QuirksAddRemoveAlsoLocks, i.e. it also runs lock (but not 34 // install) when running add or remove. 35 func (b *LanguageBackend) QuirksDoesAddRemoveAlsoLock() bool { 36 return (b.Quirks & QuirksAddRemoveAlsoLocks) != 0 37 } 38 39 // QuirksDoesAddRemoveNotAlsoLock returns true if the language backend 40 // does *not* specify QuirksAddRemoveAlsoLocks, i.e. running add or 41 // remove does *not* also run lock or install. 42 func (b *LanguageBackend) QuirksDoesAddRemoveNotAlsoLock() bool { 43 return (b.Quirks & QuirksAddRemoveAlsoLocks) == 0 44 } 45 46 // QuirksDoesLockAlsoInstall returns true if the language backend 47 // specifies QuirksLockAlsoInstalls, i.e. running lock also runs 48 // install. 49 func (b *LanguageBackend) QuirksDoesLockAlsoInstall() bool { 50 return (b.Quirks & QuirksLockAlsoInstalls) != 0 51 } 52 53 // QuirksDoesLockNotAlsoInstall returns true if the language backend 54 // does *not* specify QuirksLockAlsoInstalls, i.e. running lock does 55 // *not* also run install. 56 func (b *LanguageBackend) QuirksDoesLockNotAlsoInstall() bool { 57 return (b.Quirks & QuirksLockAlsoInstalls) == 0 58 } 59 60 // QuirkRemoveNeedsLockfile returns true if the language backend 61 // cannot run lock without a valid lockfile 62 func (b *LanguageBackend) QuirkRemoveNeedsLockfile() bool { 63 return (b.Quirks & QuirkRemoveNeedsLockfile) != 0 64 }