What is the meaning of ~ in composer package?
example in composer.json symfony
"symfony/symfony": "~2.4",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~2.3",
"sensio/framework-extra-bundle": "~2.3",
"sensio/generator-bundle": "~2.3",
See http://getcomposer.org/doc/01-basic-usage.md#next-significant-release-tilde-operator-
The ~ operator is best explained by example: ~1.2 is equivalent to >=1.2,<2.0, while ~1.2.3 is equivalent to >=1.2.3,<1.3. As you can see it is mostly useful for projects respecting semantic versioning. A common usage would be to mark the minimum minor version you depend on, like ~1.2 (which allows anything up to, but not including, 2.0). Since in theory there should be no backwards compatibility breaks until 2.0, that works well. Another way of looking at it is that using ~ specifies a minimum version, but allows the last digit specified to go up.
Related
I have a yarn 2 workspaces project with two workspaces:
|-foo
\-bar
Now, in the root package.json, I pull in common dev-depenencies:
"devDependencies": {
"#rollup/plugin-commonjs": "^14.0.0",
"#rollup/plugin-node-resolve": "^8.4.0",
"#rollup/plugin-replace": "^2.3.3",
"#rollup/plugin-typescript": "^5.0.2",
"#types/jest": "^26.0.13",
"nollup": "^0.13.10",
"rimraf": "^3.0.2",
"rollup": "^2.23.1",
"ts-jest": "^26.3.0",
"tslib": "^2.0.1",
"typescript": "^4.0.2"
}
How can I easily (without too much boilerplate) now reference rollup, etc. from scripts in the package.json of foo and bar?
Example: foo/package.json
"build": "rollup ...",
Writing "../node_modules/.bin/rollup" sucks.
Note, I don't want to install rollup etc globally.
To run executable installed in root workspace, you can say:
"build": "run -T rollup",
-T is for --top-level and is not currently documented anywhere. I was informed about its existence on Yarn discord server by one of the maintainers.
https://github.com/yarnpkg/berry/blob/bef203949d9acbd42da9b47b2a2dfe3615764eaf/packages/plugin-essentials/sources/commands/run.ts#L47-L49
So, I found a not-too-bad solution. In the workspace root, I add some executable files for the commands I want to use in my scripts, e.g.:
tsc:
#!/bin/bash
$(dirname "${BASH_SOURCE[0]}")/node_modules/.bin/tsc -b -f "$#"
rollup:
#!/bin/bash
$(dirname "${BASH_SOURCE[0]}")/node_modules/.bin/rollup "$#"
These basically "forward" the call to the actual binaries and may add some common parameters.
In my foo/bar package.json, I can now reference those scripts:
"dev:compile": "../tsc",
"build": "../tsc && ../rollup -c rollup.config.js",
I try to run in index.js of Cypress:
require('#cypress/code-coverage/task')
Getting this error:
Module not found: Error: Can't resolve '../self-coverage-helper' in 'C:\repo\patientstrength_codecover\node_modules\#cypress\code-coverage\node_modules\nyc'
Totally lost here. My package.json:
"nyc": "^15.1.0",
"cypress": "^5.0.0",
"cypress-istanbul": "^1.3.0",
"cypress-localstorage-commands": "^1.2.2",
"cypress-multi-reporters": "^1.2.4",
"#cypress/code-coverage": "^3.8.1",
"#babel/core": "^7.11.4",
"#babel/plugin-syntax-dynamic-import": "^7.8.3",
"#babel/plugin-syntax-jsx": "^7.10.4",
"#babel/preset-env": "^7.11.0",
"#babel/preset-react": "^7.10.4",
The issue was that we are using a "root" package.json with basic scripts like gulp, jest and well - also we tried to run Cypress from that root. And beside the coverage, it worked fine.
So we have:
/git/root/package.json
/git/root/solution1/package.json
/git/root/solution2/package.json
We solved the issue by simply install Cypress and all dependencies first (!) in the:
/git/root/solution1/package.json and /git/root/solution2/package.json solutions.
NOT in the /git/root/package.json.
The /git/root/package.json now only contains a script invoking the 2 Cypress installations. And later we merge the results. Sure some redundancy
The invoke script is as following:
"test:client1": "cd client1 && cd ClientApp && npm run coverage"
So very simple approach. What we couldn't solve is the redundancy regarding Cypress configuration and commands. That can be optimized.
I am trying to deploy a symfony4 app in cloudfoundry. I got an error with "composer/package-versions-deprecated":
Auto deploy(with gitlab-ci): I get this error below:
The same Error with cli local deploy(cf push)
composer.json:
"minimum-stability": "beta",
"prefer-stable": true,
"repositories": [
.......
{
"packagist": false
},
...
],
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"composer/package-versions-deprecated": "^1.10",
...
PHP version: 7.2; Symfony: 4.4.9; Composer Version: 1.7.2
That is a network problem. It's saying that Composer cannot resolve the DNS address for github.com.
This could be a temporary problem, like if Github is having issues, but that's unlikely. What's more probable is that your Cloud Foundry operators have restricted access to the Internet. Perhaps through Application Security Groups, which is something that only an Operator with "admin" permissions can adjust.
https://docs.cloudfoundry.org/concepts/asg.html
The other possibility is that you can access the Internet but you must do so through a proxy. You would need to confirm with your Operators if this is true and if so, what proxy information you'd need to use. If, and it is solely up to your Platform Operations team, you can access the Internet through a proxy then your Ops team would need to configure it. They can do that globally with these instructions.
https://docs.cloudfoundry.org/buildpacks/proxy-usage.html
or you can do the same thing with cf set-env on a per-application basis.
It caused by dist-Url(not authorized directly) in composer-lock.json
it fixed by changing the URL: private repository under api.github:
"dist": {
"type": "zip",
"url": "https://privateRepo... /api/composer/php-proxy-official/vcs-dists/zip/doctrine/reflection/55e71912dfcd824b2fdd16f2d9afe15684cfce79",
"reference": "55e71912dfcd824b2fdd16f2d9afe15684cfce79",
"shasum": ""
},
I'm trying to find a good, clean, way to test React components. I'm liking the idea of mochify as it looks like it abstracts a lot of the hassle of test runners, works with webdriver/saucelabs, etc.
The trouble is that I'm using Browserify with various transforms for jsx, coffee, less, etc from the command line. And can't find how get mochify to run those transforms.
How do I do this?
Or is there a better option out there... Karma maybe?
Thanks
Browserify transforms can also be specified in package.json, for example:
...
"devDependencies": {
"browserify": "*",
"coffeeify": "^0.6.0",
"mocha": "*",
"mochify": "*",
"reactify": "^0.13.1"
},
"browserify": {
"transform": [
"coffeeify",
"reactify"
]
},
...
In your test files, just requires the actual component file using relative path, and write tests as you normally do with mocha:
var React = require('react/addons');
var TestUtils = React.addons.TestUtils;
var MyComponent = require('../src/app/MyComponent');
...
Edit: Mochify now supports additional transforms and plugins with --transform and --plugin.
This problem will be addressed in a future release of Mochify.
Make sure to watch the issue on GitHub.
I've set up a Vagrant box (precise32) to run the usual Grunt stuff but it's taking way too long.
Running "watch" task
Waiting...OK
>> File "../../home/vagrant/app/wp-content/themes/testcss/_vars.scss" changed.
Running "sass:dist" (sass) task
File "/home/vagrant/app/wp-content/themes/test/css/styles.css" created.
Done, without errors.
Completed in 40.392s at Mon Dec 02 2013 11:34:02 GMT+0000 (UTC) - Waiting...
OK
>> File "../../home/vagrant/app/wp-content/themes/test/css/styles.css" changed.
Completed in 0.000s at Mon Dec 02 2013 11:34:02 GMT+0000 (UTC) - Waiting...
I've tried this on the shared folder and a native folder within the VM with no change. I'm using the grunt-contrib-sass plugin although I've also tried grunt-sass and it takes a similar amount of time. The watch event fires quickly but then the VM consumes all spare CPU utilisation until the CSS compile completes.
Running sass manually takes ~2 seconds
Any idea where to go from here?
package.json
{
"name": "www",
"version": "0.0.0",
"dependencies": {},
"devDependencies": {
"grunt": "~0.4.2",
"grunt-autoprefixer": "~0.4.0",
"grunt-concurrent": "~0.4.1",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-coffee": "~0.7.0",
"grunt-contrib-compass": "~0.6.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-connect": "~0.5.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-cssmin": "~0.7.0",
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-imagemin": "~0.3.0",
"grunt-contrib-jshint": "~0.7.1",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-watch": "~0.5.2",
"grunt-google-cdn": "~0.2.0",
"grunt-newer": "~0.5.4",
"grunt-ngmin": "~0.0.2",
"grunt-rev": "~0.1.0",
"grunt-svgmin": "~0.2.0",
"grunt-usemin": "~2.0.0",
"jshint-stylish": "~0.1.3",
"load-grunt-tasks": "~0.2.0",
"time-grunt": "~0.2.1",
"karma-ng-scenario": "~0.1.0",
"grunt-karma": "~0.6.2",
"karma-chrome-launcher": "~0.1.0",
"karma-script-launcher": "~0.1.0",
"karma-firefox-launcher": "~0.1.0",
"karma-html2js-preprocessor": "~0.1.0",
"karma-jasmine": "~0.1.3",
"requirejs": "~2.1.9",
"karma-requirejs": "~0.2.0",
"karma-coffee-preprocessor": "~0.1.0",
"karma-phantomjs-launcher": "~0.1.0",
"karma": "~0.10.5",
"karma-ng-html2js-preprocessor": "~0.1.0",
"grunt-contrib-sass": "~0.5.1",
"grunt-php": "~0.3.0"
},
"engines": {
"node": ">=0.8.0"
},
"scripts": {
"test": "grunt test"
}
}
EDIT:
I've found out roughly where the problem lies. It is that whenever my grint-contrib-sass task is triggered from grunt-contrib-watch it actually reloads all of Grunt's modules. I cannot see why it is doing this nor why this would be necessary. I've changed the question title to reflect this.
Unless you are giving a lot of cpu to vagrant (normally it use 1 cpu core i believe), i will expect grunt to run slower than your host machine. If you are not using nfs then slow IO will be the next suspect.
We use grunt in vagrant as well but only with a small number of packages (mostly contrib plugin), on an iMac it takes about 2 second in vagrant, so your issue may indeed be the slow IO or certain package having to do a lot of file operations.
If you isolate your grunt watch to sass plugin alone, does it take the same amount of time when compare to running grunt sass manually? how about running on your host machine?
Another point to consider is try not to watch the files that will be generated by grunt, you might get into strange issues if a grunt task triggers another.
I've found out that this seems to be due to the spawn option. Setting this to false stops the whole reload.
I now have the problem that the watch reloads when the sass compiler task runs so that livereload on the watched css files isn't always working.
We've had mediocre success with this issue using jit-grunt. What we've done is we've replaced load-grunt-tasks with jit-gruntin Gruntfile.js. The execution of grunt serve went down from 20-30 seconds to less than 4 seconds. The bottleneck is now probably compass:server load and this is related to slow Shared folder.
Still doing Karma test runs without grunt (just using karma-cli) -- alot faster this way.