Skip to content

Commit c3502be

Browse files
authored
Devlink V1 (#744)
* Devlink wip * Devlink wip * Devlink v1 * Docs
1 parent 2027389 commit c3502be

24 files changed

+1267
-619
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"wikimedia/composer-merge-plugin": "^2.1"
5151
},
5252
"require-dev": {
53+
"moox/devlink": "*",
5354
"fakerphp/faker": "^1.23.1",
5455
"larastan/larastan": "^3.0",
5556
"laravel/pint": "^1.0",
@@ -145,4 +146,4 @@
145146
},
146147
"minimum-stability": "dev",
147148
"prefer-stable": false
148-
}
149+
}

packages/devlink/CLASSES.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Classes
2+
3+
## Commands
4+
5+
- `DeployCommand`: Deploy the packages
6+
- `UnlinkCommand`: Unlink the packages
7+
- `LinkCommand`: Link the packages
8+
- `StatusCommand`: Show the status of Devlink
9+
10+
## Traits
11+
12+
- `Art`: Artistic output
13+
- `Backup`: Backup composer.json
14+
- `Check`: Check the status of Devlink
15+
- `Cleanup`: Cleanup the packages
16+
- `Deploy`: Deploy the packages
17+
- `Finalize`: Finalize the packages
18+
- `Link`: Create symlinks for the packages
19+
- `Prepare`: Prepare the folder
20+
- `Restore`: Restore composer.json
21+
- `Show`: Read the JSON and show the status
22+
- `Status`: Write the JSON status file
23+
- `Unlink`: Remove symlinks for the packages
24+
25+
## Other
26+
27+
- `devlink.php`: The config file
28+
- `devlink.json`: The generated status file
29+
- `deploy.sh`: The shell script

packages/devlink/README.md

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
# Moox Devlink
22

3-
This package is only for internal use.
4-
5-
It is used to link the packages from the `moox` monorepo into a project. It runs on MacOS, Linux and Windows.
3+
Moox Devlink is used to link packages a monorepo into any project and to deploy a production-ready composer.json. That allows us to develop Moox packages in any project. It runs on MacOS and Linux, Windows with special configuration.
64

75
## Installation
86

97
```bash
10-
cp .env.example .env
118
composer require moox/devlink
129
php artisan vendor:publish --tag="devlink-config"
1310
```
@@ -33,10 +30,18 @@ packages/*
3330

3431
```
3532

36-
2. Configure your paths and packages in the `config/devlink.php` file and the `.env` file, if needed (Windows users for example).
33+
2. Configure your paths and packages in the `config/devlink.php` file and change the package path in the `.env` file, if needed (Windows users should set the `DEVLINK_PACKAGES_PATH` variable to `packageslocal`).
34+
35+
3. When running `devlink:status`:
36+
37+
- Lists all packages that are currently devlinked
38+
- Lists all packages that are configured but not devlinked
39+
- Lists all packages that are not configured, but devlinked
40+
- Shows the configuration and the deploy status of each package
3741

38-
3. When running `devlink:link`:
42+
4. When running `devlink:link`:
3943

44+
- Creates the packages folder, if it does not exist
4045
- Creates backup of original composer.json → composer.json.original
4146
- Creates symlinks for all configured packages
4247
- Updates composer.json with development configuration
@@ -45,15 +50,31 @@ packages/*
4550
- Asks to run `php artisan optimize:clear`
4651
- Asks to run `php artisan queue:restart`
4752

48-
4. When running `devlink:deploy`:
53+
5. When running `devlink:unlink`:
54+
55+
- Removes all symlinks
56+
- Deletes the packages folder, if empty
57+
- Creates a backup of composer.json to composer.json-backup
58+
- Restores original composer.json from composer.json-original
59+
- Asks to run `composer install`
60+
- Asks to run `php artisan optimize:clear`
61+
- Asks to run `php artisan queue:restart`
62+
63+
6. When running `devlink:deploy`:
4964

5065
- Removes all symlinks
5166
- Deletes the packages folder, if empty
67+
- Creates a backup of composer.json to composer.json-backup
5268
- Restores production-ready composer.json from composer.json-deploy
69+
- Asks to run `composer install`
70+
- Asks to run `php artisan optimize:clear`
71+
- Asks to run `php artisan queue:restart`
72+
73+
7. CI Safety Net - `deploy.sh`:
5374

54-
5. CI Safety Net - `deploy.sh`:
5575
- If composer.json-deploy exists in the repository:
56-
- The script will restore it as composer.json
76+
- the script will restore it as composer.json
77+
- rename composer.json-original to composer.json-backup
5778
- Commit and push the change in GH action
5879
- This ensures no development configuration reaches production
5980

@@ -74,24 +95,23 @@ Mac works out of the box. You can have local packages mixed with the symlinked p
7495

7596
On Windows there are most probably some issues with the symlinks. If you run into issues, you can either globally or project-wise disable the symlinks or do the following:
7697

77-
```php
98+
```env
99+
DEVLINK_PACKAGES_PATH=packages-linked
100+
```
78101

79-
'packages_path' => 'packages-linked',
102+
Devlink will then link the packages into the `packages-linked` folder instead of mixing them into packages.
80103

81-
```
104+
## Classes
82105

83-
Devlink will then link the packages into the `packages-linked` folder.
106+
Please see the [CLASSES.md](./CLASSES.md) file for a quick class overview.
84107

85108
## Roadmap
86109

87-
- [ ] Test on Mac
88-
- [ ] Test on Windows
89-
- [ ] Test Deployment on Mac
90-
- [ ] Test Deployment on Windows
91-
- [ ] Implement automatic Deployment
92-
- [ ] Implement all 3 types of packages
93-
- [ ] If package is a symlink itself, ...?
94-
- [ ] If package is in multiple base paths...?
110+
Please see the [ROADMAP.md](./ROADMAP.md) file for what is planned.
111+
112+
## Changelog
113+
114+
Please see the [CHANGELOG.md](./CHANGELOG.md) file for what has changed.
95115

96116
## Security Vulnerabilities
97117

packages/devlink/ROADMAP.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Roadmap
2+
3+
## Current tasks
4+
5+
- [ ] Private packages are not yet handled (copied and wired with path)
6+
- [ ] Need to delete private packages in the link and unlink steps then
7+
- [ ] There is probably an unclear state, because we do not yet use `-backup` yet
8+
- [ ] For the shell script, we also need to check if `-original` and `-backup` are correct
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"status": {
3+
"linked": true,
4+
"deploy": false,
5+
"error": false,
6+
"error_message": "Devlink is active, currently not ready for deployment"
7+
},
8+
"packages": {
9+
"devlink": {
10+
"active": true,
11+
"linked": true,
12+
"deployed": false
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)