Adam Cameron
box install
not having an equiv of a composer.lock
/ package-lock.json
file but box install
changed the version constraint on testbox I had said to use ("^4.2.1+400"
) to... um... a version constraint based on the version it actually installed: "^4.5.0+5"
.
Now I get that version 4.5.0+5
matches the constraint I specified, but looks to me like box install
doesn't quite understand the differences between constraints and versions. It should not be updating my constraint.Adam Cameron
domwatson
05/30/2022, 8:15 AM$ box install testbox@^4.2.1+400
√ | Installing package [forgebox:testbox@^4.2.1+400]
| √ | Installing package [forgebox:cbstreams@^1.5.0]
| √ | Installing package [forgebox:mockdatacfc@^3.3.0+22]
$ cat box.json
{
"dependencies":{
"testbox":"^4.2.1+400"
},
"installPaths":{
"testbox":"testbox/"
}
}
$ box install
√ | Installing ALL dependencies
| √ | Installing package [forgebox:testbox@^4.2.1+400]
$ cat box.json
{
"dependencies":{
"testbox":"^4.2.1+400"
},
"installPaths":{
"testbox":"testbox/"
}
}
$ box install testbox
√ | Installing package [forgebox:testbox]
$ cat box.json
{
"dependencies":{
"testbox":"^4.5.0+5"
},
"installPaths":{
"testbox":"testbox/"
}
}
domwatson
05/30/2022, 9:20 AMAdam Cameron
when I have explicitly asked to install the latest testboxThat is not what you did though:
box install testbox
That does not say anything about versions one way or the other.
Here are my tests. First with `box install`:
root@37d6a8a217c4:/var/www# ls
Application.cfc LICENSE README.md box.json cfml docker test var
root@37d6a8a217c4:/var/www# cat box.json
{
"dependencies":{
},
"devDependencies":{
"testbox":"^4.2.1+400"
},
"installPaths":{
"testbox":"testbox/"
},
"testbox":{
"runner":"<http://localhost:8888/test/runTests.cfm?reportFormat=testbox.system.reports.TextReporter>"
}
}
root@37d6a8a217c4:/var/www# box install
√ | Installing ALL dependencies
| √ | Installing package [forgebox:testbox@^4.2.1+400]
| | √ | Installing package [forgebox:cbstreams@^1.5.0]
| | √ | Installing package [forgebox:mockdatacfc@^3.3.0+22]
root@37d6a8a217c4:/var/www# cat box.json
{
"dependencies":{
},
"devDependencies":{
"testbox":"^4.2.1+400"
},
"installPaths":{
"testbox":"testbox/"
},
"testbox":{
"runner":"<http://localhost:8888/test/runTests.cfm?reportFormat=testbox.system.reports.TextReporter>"
}
}
root@37d6a8a217c4:/var/www#
It doesn't monkey with my constraint.Adam Cameron
root@37d6a8a217c4:/var/www# rm -rf testbox
root@37d6a8a217c4:/var/www# ls
Application.cfc LICENSE README.md box.json cfml docker test var
root@37d6a8a217c4:/var/www# cat box.json
{
"dependencies":{
},
"devDependencies":{
"testbox":"^4.2.1+400"
},
"installPaths":{
"testbox":"testbox/"
},
"testbox":{
"runner":"<http://localhost:8888/test/runTests.cfm?reportFormat=testbox.system.reports.TextReporter>"
}
}
root@37d6a8a217c4:/var/www# box install testbox
√ | Installing package [forgebox:testbox]
| √ | Installing package [forgebox:cbstreams@^1.5.0]
| √ | Installing package [forgebox:mockdatacfc@^3.3.0+22]
root@37d6a8a217c4:/var/www# cat box.json
{
"dependencies":{},
"devDependencies":{
"testbox":"^4.5.0+5"
},
"installPaths":{
"testbox":"testbox/"
},
"testbox":{
"runner":"<http://localhost:8888/test/runTests.cfm?reportFormat=testbox.system.reports.TextReporter>"
}
}
root@37d6a8a217c4:/var/www#
This does monkey with my constraint. It shouldn't. Irrespective of what version it installs, it should never monkey with my version constraint. It's a constraint, it's not "the actual version". That is not the information being imparted there.domwatson
05/30/2022, 12:44 PMdomwatson
05/30/2022, 12:45 PMdomwatson
05/30/2022, 12:46 PMbox install
to install all my packages at the versions specificed in my box.json. OR, box install <somepackage>
to install a specific package - either latest version if no version specified, or a specific version/range, etc. if specified.domwatson
05/30/2022, 12:50 PM$ npm install int@0.1.2
added 1 package from 3 contributors and audited 1 package in 2.013s
$ cat package-lock.json
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"int": {
"version": "0.1.2",
"resolved": "<https://registry.npmjs.org/int/-/int-0.1.2.tgz>",
"integrity": "sha512-zmTKKSGQnruBcvkVdI+dBCE/JUMUou9kCNOpdiQb70kXpHtMM9LZo2A5sXlFwS0QrVOwSbgmsdYNoIxaQhxB8A=="
}
}
}
$ npm install int
+ int@0.2.0
updated 1 package and audited 1 package in 1.333s
$ cat package-lock.json
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"int": {
"version": "0.2.0",
"resolved": "<https://registry.npmjs.org/int/-/int-0.2.0.tgz>",
"integrity": "sha512-DpVz1YLYteAWaNsgbDXzzggi+7dplHBCWXqTHp85erZ6qJjDqbM+LC29hkCBC+zeHfFd7ig8gGYbcqLpJdcuLQ=="
}
}
}
domwatson
05/30/2022, 12:51 PMAdam Cameron
0.1.2
and 0.2.0
are versions, not version constraints.
package.json: specifies constraints
package-lock.json: specifies versions.
npm does not update package.json. Because it... has been implemented properly.
I am actually surprised that npm install
works that way though. I come from a php environment and using composer, and composer install
first time around reads the constraint (from composer.json
) and installs the most recent version that fulfils that constraint, and writes that version to composer.lock
. Subsequent calls to composer install
will continue to use the exact version specified in composer.lock
, even if there are more recent versions available within the constraint. One needs to call composer update
to recheck for more recent versions.
Still: fair cop that box install
will grab a more recent version than previously had been installed (same as npm), even if that's not how I'd do it (Composer seems better than npm in this regard, so I'm with Composer on this one).
It still shouldn't monkey with the box.json constraints though.Adam Cameron
npm
example above to be:
npm install
# all deps are installed at their latest constraint-fulfilling versions
# time passes, a dependency version has been updated
npm install
Does that second one just install the versions already in package-lock.json
, or does it also look for updates to everything? IE I guess I'm asking if the update process only happens when one goes npm install dependency_name
or is that npm install
default behaviour?domwatson
05/30/2022, 1:39 PMpackage.json
- was just running in an empty dir and it then updated to latest in package-lock.json
which it created (it does not create a package.json).domwatson
05/30/2022, 1:40 PMbox install package
is equivalent to box install package@stable
. And it should be expected to do what it is doing.domwatson
05/30/2022, 1:41 PMAdam Cameron
pi()
returns 3
, and celebrate that when we call pi()
we get 3
because that's exactly what it says it does in the docs. But π
is an actual thing, and it's not 3
.
---
I've had the requirement for handling version locking with @bdw429s previously, and he is aware of the shortfall. What was new to me (or I had forgotten I once knew? Unsure. It seemed surprising to me when I saw it this time, anyhow) was that it was changing box.json.Adam Cameron
domwatson
05/30/2022, 2:09 PMbox install somepackage
and expecting it to be constrained though. This is useful for just installing what you have defined of a single package, rather than installing what you have defined for all packages right? I certainly could have used that in the past, but absolutely haven't as I have always expected it to be equivalent to box install somepackage@stable
.domwatson
05/30/2022, 2:09 PMdomwatson
05/30/2022, 2:16 PMbox install <package>
argument/convention that says "install the version as specified in my box.json" file (only IF @bdw429s was concerned enough around breaking changes). That way, the package manager catches up with features of others, albeit with a slightly different convention.
box install testbox@boxjson
box install testbox --constrained
^^ both quite yucky, I agreedomwatson
05/30/2022, 2:28 PMAdam Cameron
composer install
. All it does is to read composer.lock
and install everything listed there. If there's no composer.lock
, it will start with composer.json
. If there's a composer.lock
and a composer.json
and they don't match, it will give a warning, but will still only refer to composer.lock
.
If one goes composer require someone/something
, then it'll write an entry to composer.json
with a ^
constraint of the current available version of the package, install that, and write that version to composer.lock
. It also has a --dev
switch to make it a dev dependency, not a prod one.
If one wishes to re-scan for newer versions (ignoring the ones in composer.lock
) one does composer update
or composer update someone/something
. Again, this writes the updated version(s) to composer.lock
again.
TBH, the package installer app doesn't need to be backwards compatible does it? If they want to add version-locking, that in itself is a big change in how the thing works, so the syntax for using it can / must change anyhow.
Maybe for a single transition version there could be a --oldskool
switch one gives to the box
commands and it uses the old syntax, but that is marked as deprecated immediately, with a retirement date of six months hence or something.domwatson
05/30/2022, 2:29 PMdomwatson
05/30/2022, 2:29 PMAdam Cameron
composer install
nor compose update
write to composer.json
. Only composer require
does.Adam Cameron
domwatson
05/30/2022, 2:31 PM--save=false
right? (that composer
syntax is nice for sure, but I think so long as the features are available, then the syntax is less important.Adam Cameron
domwatson
05/30/2022, 2:34 PMAdam Cameron
Adam Cameron
domwatson
05/30/2022, 2:34 PMAdam Cameron
Adam Cameron
domwatson
05/30/2022, 2:35 PMdomwatson
05/30/2022, 2:36 PMAdam Cameron
Adam Cameron
domwatson
05/30/2022, 2:37 PMdomwatson
05/30/2022, 2:37 PMAdam Cameron
wil-shiftinsert
05/31/2022, 3:25 PMbdw429s
05/31/2022, 6:32 PMWould be interesting to see if there are any plans for a package locking mechanism in the future and what that might mean for the expected behaviour.@domwatson Yes, Eric Peterson asks me about this every few months and Adam has as well. It's in the backlog and something I'll tackle when I have some time.
bdw429s
05/31/2022, 6:33 PMbdw429s
05/31/2022, 6:34 PMI think box took its inspiration from npm,This is correct
bdw429s
05/31/2022, 6:34 PM(I might be wrong on that, but I recall Brad was unaware of composer even existing (I think) last time we spoke about it)This is incorrect. I don't live under a rock, mate 🙂 That said, I have never looked to composer for much guidance outside of checking out their terms and rules around package ownership in the past.
bdw429s
05/31/2022, 6:38 PMCommandBox absolutely knows the difference, except I don't tend to use the word "constraint", I'll usually say a "semnatic version range" which is perhaps more of an npm term. https://commandbox.ortusbooks.com/package-management/semantic-versioning#ranges When you specify an exact and full version such asdoesn't quite understand the differences between constraints and versionsbox install
install foobar@1.2.3
then there is no question what you want. That exact version is installed, and the exact version is stored in box.json
and you will never get anything else.
Each of the following examples would be considered a range-- meaning, go find the highest vesrion that satisfies the range
install foobar
install foobar@be
install foobar@stable
install foobar@*
install foobar@1
install foobar@1.2
install foobar@1.x
install "foobar@>=2.0.0 <=2.5.0"
install "foobar@2.0.0 - 2.5.0"
install foobar@~1.2.3
install foobar@^1.2.3
install "foobar@1.0.0 || 2.0.0 || 3.0.0"
bdw429s
05/31/2022, 6:41 PMbdw429s
05/31/2022, 6:42 PMbdw429s
05/31/2022, 6:43 PMbdw429s
05/31/2022, 6:44 PMstable
so
install foobar
is the same as
install foobar@stable
but I'm 100% ok with the suggestion in Dom's ticket to default it to the version or range found in the box.json
for that package, if it exists.