-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.php
More file actions
executable file
·116 lines (99 loc) · 5.09 KB
/
install.php
File metadata and controls
executable file
·116 lines (99 loc) · 5.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
use Pushword\Core\PushwordCoreBundle;
use Pushword\Installer\PostInstall;
/**
* Execute via Pushword\Installer\PostInstall::postUpdateCommand.
*/
if (! PostInstall::isRoot()) {
throw new Exception('installer mus be run from root');
}
PostInstall::remove([
'templates/base.html.twig',
'config/packages/security.yaml',
'config/packages/doctrine.yaml',
'config/packages/vich_uploader.yaml',
]);
// Set pushword bundle first to avoid errors
PostInstall::replace('config/bundles.php', PushwordCoreBundle::class."::class => ['all' => true],", '');
PostInstall::replace('config/bundles.php', 'return [', 'return [
'.PushwordCoreBundle::class."::class => ['all' => true],");
// echo '~~ Copy Entities in ./src/Entity'.chr(10);
// PostInstall::mirror('vendor/pushword/skeleton/src/Entity', 'src/Entity');
@unlink('src/DataFixtures/AppFixtures.php');
PostInstall::mirror('vendor/pushword/skeleton/src/DataFixtures', 'src/DataFixtures');
echo '~~ Adding Puswhord Routes'.chr(10);
PostInstall::insertIn(
'config/routes.yaml',
"\npushword:\n resource: '@PushwordCoreBundle/Resources/config/routes.yaml'\n",
PostInstall::INSERT_AT_END
);
echo '~~ Create database'.chr(10);
// if it's a default symfony installation, switch from postgresql to sqlite
PostInstall::replace('.env', 'postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8', 'sqlite:///%kernel.project_dir%/var/app.db');
// and define an APP_SECRET
PostInstall::replace('.env', "APP_SECRET=\n", 'APP_SECRET='.sha1(md5(uniqid())).chr(10));
PostInstall::mirror('vendor/pushword/skeleton/media~', 'media');
$freshInstall = ! file_exists('var/app.db');
$commands = 'php bin/console doctrine:schema:update --force -q';
if ($freshInstall) {
$commands .= ' && php bin/console doctrine:fixtures:load --no-interaction -q';
}
$commands .= ' && php bin/console pw:image:cache -q';
echo '~~ Symlinking assets'.chr(10);
$commands .= ' && php bin/console assets:install --symlink --relative -q';
exec($commands);
PostInstall::dumpFile('public/build/manifest.json', '{}');
echo '~~ Copy assets file in ./assets'.chr(10);
PostInstall::remove(['package.json', 'webpack.config.js', 'assets']);
PostInstall::mirror('vendor/pushword/skeleton/assets', 'assets');
PostInstall::copy('vendor/pushword/skeleton/vite.config.js', 'vite.config.js');
PostInstall::copy('vendor/pushword/skeleton/package.json', 'package.json');
PostInstall::copy('vendor/pushword/skeleton/Caddyfile', 'Caddyfile');
$defaultConfig = 'pushword:'.chr(10)
.' # Documention'.chr(10)
.' # https://pushword.piedweb.com/installation'.chr(10)
.' # Example'.chr(10)
.' # https://github.com/Pushword/Pushword/blob/main/packages/skeleton/config/packages/pushword.php'.chr(10);
PostInstall::dumpFile('config/packages/pushword.yaml', $defaultConfig);
// Install phpstan
// ---------------
PostInstall::copy('vendor/pushword/skeleton/phpstan.dist.neon', 'phpstan.dist.neon');
PostInstall::copy('vendor/pushword/skeleton/bin/console-test.php', 'bin/console-test.php');
PostInstall::replace('bin/console-test.php', "'/../../../vendor/autoload.php'", "'/../vendor/autoload.php'");
PostInstall::copy('vendor/pushword/skeleton/bin/object-test.php', 'bin/object-test.php');
PostInstall::replace('bin/object-test.php', "'/../../../vendor/autoload.php'", "'/../vendor/autoload.php'");
// À tester si appeler composer depuis composer ne fout pas le bordel
exec('composer config --no-plugins allow-plugins.phpstan/extension-installer true');
exec('composer config --no-plugins scripts.stan "vendor/bin/phpstan"');
if (! file_exists('vendor/phpstan/phpstan/phpstan.phar')) {
exec('composer require --dev phpstan/extension-installer:* phpstan/phpstan:* phpstan/phpstan-doctrine:* phpstan/phpstan-phpunit:* phpstan/phpstan-strict-rules:* phpstan/phpstan-symfony:*');
}
// Install php-cs-fixer
// -------------------
PostInstall::copy('vendor/pushword/skeleton/.php-cs-fixer.dist.php~', '.php-cs-fixer.dist.php');
exec('composer config --no-plugins scripts.format "vendor/bin/php-cs-fixer fix"');
if (! file_exists('vendor/friendsofphp/php-cs-fixer/php-cs-fixer')) {
exec('composer require --no-plugins --dev friendsofphp/php-cs-fixer:*');
}
// Install RECTOR
// -------------------
// Rector is a bit too expensive on a cheap VPS with 4Gb of RAM
/*
cp vendor/pushword/skeleton/rector.php rector.php && \
cp vendor/pushword/skeleton/tests/symfonyContainer.php tests/symfonyContainer.php && \
composer config --no-plugins scripts.rector "vendor/bin/rector process && composer format" && \
composer require --no-plugins --dev rector/rector:*
*/
// PostInstall::copy('vendor/pushword/skeleton/rector.php', 'rector.php');
// PostInstall::copy('vendor/pushword/skeleton/tests/symfonyContainer.php', 'tests/symfonyContainer.php');
// exec('composer config --no-plugins scripts.rector "vendor/bin/rector process && composer format"');
// exec('composer require --no-plugins --dev rector/rector:*');
PostInstall::replace('.gitignore', '/var/', '/var/*');
PostInstall::insertIn('.gitignore', '###> pushword ###
public/assets
public/media
public/sw.js
static/
!/var/installer/
###< pushword ###
', PostInstall::INSERT_AT_END);