projektgopher / whisky Goto Github PK
View Code? Open in Web Editor NEWWhisky is the simplest, framework agnostic, CLI tool for managing and enforcing a php project's git hooks across an entire team.
Whisky is the simplest, framework agnostic, CLI tool for managing and enforcing a php project's git hooks across an entire team.
Requested by @gpibarra
Can probably be achieved by doing something like this:
$globalWhiskyBasePath = ...
$version = (include($globalWhiskyBasePath.'/config/app.php'))['version'];
We should be taking advantage of Stan as a sanity check in the codebase
Not entirely an issue since none of the code in this repository needs to be loaded in, but this warning does get generated when installing Whisky over the standard laravel/laravel template that also uses the "App" namespace:
Warning: Ambiguous class resolution, "App\Providers\AppServiceProvider" was found in both "/home/vagrant/project/app/Providers/AppServiceProvider.php" and "/home/vagrant/project/vendor/projektgopher/whisky/app/Providers/AppServiceProvider.php", the first will be used.
โฏ whisky install
Creating whisky.json in project root...
In Filesystem.php line 59:
File does not exist at path /Users/gopher/Code/git-test/vendor/projektgopher/whisky/stubs/whisky.json.
git hook run pre-commit
.git/hooks/pre-commit: line 2: C:UsersmarkrSourceReposcampsvendor/projektgopher/whisky/bin/run-hook: No such file or directory
> composer global require projektgopher/whisky:0.5.0-alpha.1
> whisky validate
Whisky has not been initialized in this project, aborting...
Run `./vendor/bin/whisky install` to initialize Whisky in this project.
If Whisky::isRunningGlobally()
is true, the bin in that command output (and other similar ones) should be simply whisky
.
We have a project structure where the directory that should contain the Whisky dependency is a subfolder, not the root.
When using vendor/bin/whisky install
I get Git has not been initialized in this project, aborting...
. However, running git status
works fine.
Maybe this can be solved by using something like git rev-parse --is-inside-work-tree
and git rev-parse --absolute-git-dir
to make Whisky directory-agnostic?
whisky install
Creating whisky.json in project root...
'chmod' is not recognized as an internal or external command,
operable program or batch file.
'chmod' is not recognized as an internal or external command,
operable program or batch file.
Git hooks installed successfully.
I tried to run whisky
in a new Laravel project but I got the following errors:
.git/hooks/pre-commit: line 3: In: command not found
.git/hooks/pre-commit: eval: line 5: syntax error near unexpected token `:'
.git/hooks/pre-commit: eval: line 5: ` in_array(): Argument #2 ($haystack) must be of type array, null given '
I used the same code as in example.
Hi, that's not an issue.
I searched for a way to run commitlint
using whisky without luck.
My whisky.json is:
{
"disabled": [],
"hooks": {
"pre-commit": [
"npx --no -- commitlint --edit ${1}",
"composer format",
"bash ./local/pre-commit/prettier.sh",
"bash ./local/pre-commit/stylelint.sh"
],
"pre-push": [
"composer test"
]
}
}
I am getting the following errors. I am 100% missing something, but I can't get it.
/Users/dev/local.test/node_modules/@commitlint/cli/lib/cli.js:123
throw err;
^
[Error: ENOENT: no such file or directory, open '/Users/dev/local.test/pre-commit'] {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/Users/dev/local.test/pre-commit'
}
Thank you
# install global
composer global require projektgopher/whisky
# new repo
mkdir test
cd test
git init
composer init -n --name=test/test --autoload=src/
echo /vendor/ >> .gitignore
git add .
git commit -m "first commit"
# install whisky.json using global package
whisky install
Error
In Filesystem.php line 59:
File does not exist at path C:/develop/projects/gepe/vendor/projektgopher/whisky/stubs/whisky.json.
key | value |
---|---|
- Whisky - | |
installed globally? | yes |
running globally? | no |
dogfooding? | no |
base path | C:/develop/projects/test/vendor/projektgopher/whisky/ |
bin path | C:/develop/projects/test/vendor/bin/whisky |
- Platform - | |
cwd | C:/develop/projects/test |
getGlobalComposerHome | C:\Wamp.NET\bin.php\composerHome |
getGlobalComposerBinDir | C:\Wamp.NET\bin.php\composerHome/vendor/bin |
isWindows | yes |
isNotWindows | no |
gitIsInitialized | yes |
gitIsNotInitialized | no |
- global - | |
base_path | phar://C:/Wamp.NET/bin/7-php_8.1.0_x64/composerHome/vendor/projektgopher/whisky/builds/whisky |
normalized base_path | phar://C:/Wamp.NET/bin/7-php_8.1.0_x64/composerHome/vendor/projektgopher/whisky/builds/whisky |
The app builds well on Linux but when I try building it on Windows for testing/developing I got an error related to SIGINT
and it is coming from laravel-zero/framework
, when I checked it I found that they have fixed it on PR, but not yet released.
laravel-zero/framework
needs a bump, I'll wait for the release to do it.
After installing this package and setting it up, I'm getting my global architecture tests failing. I get this error:
./vendor/bin/pest tests/Feature/ArchTest.php
FAIL Tests\Feature\ArchTest
โ controllers 0.21s
โจฏ globals 0.34s
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
FAILED Tests\Feature\ArchTest > globals Error
Typed property PHPUnit\Architecture\Asserts\Dependencies\ObjectDependenciesDescription::$uses must not be accessed before initialization
at vendor/ta-tikoma/phpunit-architecture-test/src/Asserts/Dependencies/DependenciesAsserts.php:70
66โ $result = [];
67โ
68โ foreach ($layers as $layer) {
69โ foreach ($layer as $object) {
โ 70โ foreach ($object->uses as $use) {
71โ foreach ($layersToSearch as $layerToSearch) {
72โ // do not test layer with self
73โ if ($layer->equals($layerToSearch)) {
74โ continue;
Tests: 1 failed, 1 passed (7 assertions)
Duration: 0.61s
https://pestphp.com/docs/arch-testing
Here is the whole test:
<?php
test('controllers')
->expect('App\Http\Controllers')
->not->toUse('Illuminate\Http\Request');
test('globals')
->expect(['dd', 'dump', 'ray'])
->not->toBeUsed();
Prior to whisky install, they all pass:
php artisan test
PASS Tests\Unit\ExampleTest
โ that true is true 0.01s
PASS Tests\Feature\ArchTest
โ controllers 0.08s
โ globals 0.03s
PASS Tests\Feature\ExampleTest
โ it returns a successful response 0.02s
Tests: 4 passed (12 assertions)
Duration: 0.18s
I created this repo that can be used to replicate the problem:
https://github.com/TappNetwork/whisky-pest
To replicate:
composer install
php artisan test
See the failure.
Whisky installed globally, but switched to branch where whisky has not been required through composer, and whisky.json is not present, however the hooks have been installed.
Because the hooks directory, and the vendor bin directory remain untouched when switching between branches, we can still run whisky, but get the following output:
โฏ git hook run pre-commit
.git/hooks/pre-commit: line 3: In: command not found
does: cannot open `does' (No such file or directory)
not: cannot open `not' (No such file or directory)
exist: cannot open `exist' (No such file or directory)
at: cannot open `at' (No such file or directory)
path: cannot open `path' (No such file or directory)
/Users/gopher/Code/EXACTsports/camps/whisky.jso: cannot open `/Users/gopher/Code/EXACTsports/camps/whisky.jso' (No such file or directory)
.git/hooks/pre-commit: line 6: n.: command not found
both global whisky, and vendor/bin/whisky run, returning the correct version.
This should be as easy as having the get-run-cmd Command check for whisky.json just like the Install/Uninstall/Update commands do.
โฏ ./vendor/bin/whisky get-run-cmd pre-commit
In Filesystem.php line 59:
File does not exist at path /Users/gopher/Code/EXACTsports/camps/whisky.json.
edit:
I think we could take two approaches here. Either fail silently by not returning anything in the get-run-cmd
output, or we'll have to rewrite the snippet that gets added to the git hook file, and support another new snippet in Whisky::isInstalled()
et all. This could be a bit tougher due to the multi-line nature the new snippet would implement. Needs discussion.
Hi, I'm experiencing an issue where a failed unit test isn't preventing a push.
It's also worth noting that I get the two following lines before the tests start running:
stty: stdin isn't a terminal
stty: stdin isn't a terminal
Here's my whisky.json
file contents:
{
"disabled": [],
"hooks": {
"pre-commit": [
"./vendor/bin/pint"
],
"pre-push": [
"php artisan test --parallel",
"./vendor/bin/phpstan analyse"
],
"post-checkout": [
"composer install",
"php artisan optimize:clear"
]
}
}
And here's the command line output:
11:03:40 in vapour on ๎ feature/bottling-module [โก]
โ git push
stty: stdin isn't a terminal
stty: stdin isn't a terminal
ParaTest v7.2.0 upon PHPUnit 10.2.2 by Sebastian Bergmann and contributors.
Processes: 8
Runtime: PHP 8.2.5
Configuration: /Users/stephenhamilton/Sites/vapour/phpunit.xml
............................................................... 63 / 416 ( 15%)
............................................................... 126 / 416 ( 30%)
............................................................... 189 / 416 ( 45%)
..........................................................I.... 252 / 416 ( 60%)
.......I.I..................................................... 315 / 416 ( 75%)
................................F.............................. 378 / 416 ( 90%)
...................................... 416 / 416 (100%)
Time: 01:25.270, Memory: 62.50 MB
There was 1 failure:
1) Tests\Feature\Tasks\SampleTest::test_completing_sample_task
Failed asserting that 13.1 matches expected 13.100000000000001.
/Users/stephenhamilton/Sites/vapour/tests/Feature/Tasks/SampleTest.php:184
/Users/stephenhamilton/Sites/vapour/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:174
FAILURES!
Tests: 416, Assertions: 57498, Failures: 1, Incomplete: 3.
Note: Using configuration file /Users/stephenhamilton/Sites/vapour/phpstan.neon.
753/753 [โโโโโโโโโโโโโโโโโโโโโโโโโโโโ] 100%
[OK] No errors
Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 8 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (6/6), 623 bytes | 623.00 KiB/s, done.
Total 6 (delta 4), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (4/4), completed with 4 local objects.
To github.com:speysidelabs/vapour.git
8dbae0ea..054f9095 feature/bottling-module -> feature/bottling-module
We should define a code style, apply it using our own hooks, and enforce it in CI
Should be as simple as creating a command that calls FileJson::read()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.