shipit-cli 0.14.0__py3-none-any.whl → 0.15.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- shipit/builders/__init__.py +9 -0
- shipit/builders/base.py +14 -0
- shipit/builders/docker.py +250 -0
- shipit/builders/local.py +161 -0
- shipit/cli.py +288 -1322
- shipit/generator.py +54 -36
- shipit/procfile.py +4 -72
- shipit/providers/base.py +49 -10
- shipit/providers/hugo.py +62 -12
- shipit/providers/jekyll.py +48 -21
- shipit/providers/laravel.py +38 -29
- shipit/providers/mkdocs.py +33 -18
- shipit/providers/node_static.py +205 -139
- shipit/providers/php.py +41 -37
- shipit/providers/python.py +282 -226
- shipit/providers/registry.py +0 -2
- shipit/providers/staticfile.py +44 -25
- shipit/providers/wordpress.py +25 -26
- shipit/runners/__init__.py +9 -0
- shipit/runners/base.py +17 -0
- shipit/runners/local.py +105 -0
- shipit/runners/wasmer.py +470 -0
- shipit/shipit_types.py +103 -0
- shipit/ui.py +14 -0
- shipit/utils.py +10 -0
- shipit/version.py +2 -2
- {shipit_cli-0.14.0.dist-info → shipit_cli-0.15.0.dist-info}/METADATA +6 -3
- shipit_cli-0.15.0.dist-info/RECORD +34 -0
- {shipit_cli-0.14.0.dist-info → shipit_cli-0.15.0.dist-info}/WHEEL +1 -1
- shipit_cli-0.14.0.dist-info/RECORD +0 -23
- {shipit_cli-0.14.0.dist-info → shipit_cli-0.15.0.dist-info}/entry_points.txt +0 -0
shipit/providers/php.py
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
1
|
import json
|
|
4
2
|
from pathlib import Path
|
|
5
|
-
from typing import Dict, Optional
|
|
3
|
+
from typing import Dict, Optional, Literal
|
|
6
4
|
|
|
7
5
|
from .base import (
|
|
8
6
|
DetectResult,
|
|
@@ -12,17 +10,35 @@ from .base import (
|
|
|
12
10
|
MountSpec,
|
|
13
11
|
ServiceSpec,
|
|
14
12
|
VolumeSpec,
|
|
15
|
-
|
|
13
|
+
Config,
|
|
16
14
|
)
|
|
15
|
+
from pydantic_settings import SettingsConfigDict
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class PhpConfig(Config):
|
|
19
|
+
model_config = SettingsConfigDict(extra="ignore", env_prefix="SHIPIT_")
|
|
20
|
+
|
|
21
|
+
use_composer: bool = False
|
|
22
|
+
php_version: Optional[str] = "8.3"
|
|
23
|
+
php_architecture: Optional[Literal["64-bit", "32-bit"]] = "64-bit"
|
|
17
24
|
|
|
18
25
|
|
|
19
26
|
class PhpProvider:
|
|
20
|
-
def __init__(self, path: Path,
|
|
27
|
+
def __init__(self, path: Path, config: PhpConfig):
|
|
21
28
|
self.path = path
|
|
22
|
-
self.
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
self.config = config
|
|
30
|
+
|
|
31
|
+
@classmethod
|
|
32
|
+
def load_config(cls, path: Path, base_config: Config) -> PhpConfig:
|
|
33
|
+
use_composer = (
|
|
34
|
+
_exists(path, "composer.json", "composer.lock")
|
|
35
|
+
or (
|
|
36
|
+
base_config.commands.install
|
|
37
|
+
and base_config.commands.install.startswith("composer ")
|
|
38
|
+
)
|
|
39
|
+
or False
|
|
25
40
|
)
|
|
41
|
+
return PhpConfig(use_composer=use_composer, **base_config.model_dump())
|
|
26
42
|
|
|
27
43
|
@classmethod
|
|
28
44
|
def name(cls) -> str:
|
|
@@ -30,7 +46,7 @@ class PhpProvider:
|
|
|
30
46
|
|
|
31
47
|
@classmethod
|
|
32
48
|
def detect(
|
|
33
|
-
cls, path: Path,
|
|
49
|
+
cls, path: Path, config: Config
|
|
34
50
|
) -> Optional[DetectResult]:
|
|
35
51
|
if _exists(path, "composer.json") and _exists(path, "public/index.php"):
|
|
36
52
|
return DetectResult(cls.name(), 60)
|
|
@@ -40,55 +56,46 @@ class PhpProvider:
|
|
|
40
56
|
or _exists(path, "app/index.php")
|
|
41
57
|
):
|
|
42
58
|
return DetectResult(cls.name(), 10)
|
|
43
|
-
if
|
|
59
|
+
if config.commands.start and config.commands.start.startswith("php "):
|
|
44
60
|
return DetectResult(cls.name(), 70)
|
|
45
|
-
if
|
|
61
|
+
if config.commands.install and config.commands.install.startswith("composer "):
|
|
46
62
|
return DetectResult(cls.name(), 30)
|
|
47
63
|
return None
|
|
48
64
|
|
|
49
|
-
def initialize(self) -> None:
|
|
50
|
-
pass
|
|
51
|
-
|
|
52
65
|
def serve_name(self) -> Optional[str]:
|
|
53
66
|
return None
|
|
54
67
|
|
|
55
|
-
def platform(self) -> Optional[str]:
|
|
56
|
-
return None
|
|
57
|
-
|
|
58
68
|
def dependencies(self) -> list[DependencySpec]:
|
|
59
69
|
deps = [
|
|
60
70
|
DependencySpec(
|
|
61
71
|
"php",
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
architecture_var="SHIPIT_PHP_ARCHITECTURE",
|
|
72
|
+
var_name="config.php_version",
|
|
73
|
+
architecture_var_name="config.php_architecture",
|
|
65
74
|
use_in_build=True,
|
|
66
75
|
use_in_serve=True,
|
|
67
76
|
),
|
|
68
77
|
]
|
|
69
|
-
if self.
|
|
78
|
+
if self.config.use_composer:
|
|
70
79
|
deps.append(DependencySpec("composer", use_in_build=True))
|
|
71
80
|
deps.append(DependencySpec("bash", use_in_serve=True))
|
|
72
81
|
return deps
|
|
73
82
|
|
|
74
83
|
def declarations(self) -> Optional[str]:
|
|
75
|
-
if self.has_composer:
|
|
76
|
-
return 'HOME = getenv("HOME")\n'
|
|
77
84
|
return None
|
|
78
85
|
|
|
79
86
|
def build_steps(self) -> list[str]:
|
|
80
87
|
steps = [
|
|
81
|
-
'workdir(app
|
|
88
|
+
'workdir(app.path)',
|
|
82
89
|
]
|
|
83
90
|
if _exists(self.path, "php.ini"):
|
|
84
|
-
steps.append('copy("php.ini", "{}/php.ini".format(assets
|
|
91
|
+
steps.append('copy("php.ini", "{}/php.ini".format(assets.path))')
|
|
85
92
|
else:
|
|
86
93
|
steps.append(
|
|
87
|
-
'copy("php/php.ini", "{}/php.ini".format(assets
|
|
94
|
+
'copy("php/php.ini", "{}/php.ini".format(assets.path), base="assets")'
|
|
88
95
|
)
|
|
89
96
|
|
|
90
|
-
if self.
|
|
91
|
-
steps.append('env(
|
|
97
|
+
if self.config.use_composer:
|
|
98
|
+
steps.append('env(COMPOSER_HOME="/tmp", COMPOSER_FUND="0")')
|
|
92
99
|
steps.append(
|
|
93
100
|
'run("composer install --optimize-autoloader --no-scripts --no-interaction", inputs=["composer.json", "composer.lock"], outputs=["."], group="install")'
|
|
94
101
|
)
|
|
@@ -100,24 +107,21 @@ class PhpProvider:
|
|
|
100
107
|
return None
|
|
101
108
|
|
|
102
109
|
def commands(self) -> Dict[str, str]:
|
|
103
|
-
|
|
104
|
-
if self.custom_commands.start:
|
|
105
|
-
commands["start"] = json.dumps(self.custom_commands.start)
|
|
106
|
-
return commands
|
|
110
|
+
return self.base_commands()
|
|
107
111
|
|
|
108
112
|
def base_commands(self) -> Dict[str, str]:
|
|
109
113
|
if _exists(self.path, "public/index.php"):
|
|
110
114
|
return {
|
|
111
|
-
"start": '"php -S localhost:{} -t {}/public".format(PORT, app
|
|
115
|
+
"start": '"php -S localhost:{} -t {}/public".format(PORT, app.serve_path)'
|
|
112
116
|
}
|
|
113
117
|
elif _exists(self.path, "app/index.php"):
|
|
114
118
|
return {
|
|
115
|
-
"start": '"php -S localhost:{} -t {}/app".format(PORT, app
|
|
119
|
+
"start": '"php -S localhost:{} -t {}/app".format(PORT, app.serve_path)'
|
|
116
120
|
}
|
|
117
121
|
elif _exists(self.path, "index.php"):
|
|
118
|
-
return {"start": '"php -S localhost:{} -t {}".format(PORT, app
|
|
122
|
+
return {"start": '"php -S localhost:{} -t {}".format(PORT, app.serve_path)'}
|
|
119
123
|
return {
|
|
120
|
-
"start": '"php -S localhost:{} -t {}".format(PORT, app
|
|
124
|
+
"start": '"php -S localhost:{} -t {}".format(PORT, app.serve_path)',
|
|
121
125
|
}
|
|
122
126
|
|
|
123
127
|
def mounts(self) -> list[MountSpec]:
|
|
@@ -131,7 +135,7 @@ class PhpProvider:
|
|
|
131
135
|
|
|
132
136
|
def env(self) -> Optional[Dict[str, str]]:
|
|
133
137
|
return {
|
|
134
|
-
"PHP_INI_SCAN_DIR": '"{}".format(assets
|
|
138
|
+
"PHP_INI_SCAN_DIR": '"{}".format(assets.serve_path)',
|
|
135
139
|
}
|
|
136
140
|
|
|
137
141
|
def services(self) -> list[ServiceSpec]:
|