shipit-cli 0.13.4__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.
@@ -1,5 +1,3 @@
1
- from __future__ import annotations
2
-
3
1
  from pathlib import Path
4
2
  from typing import Dict, Optional
5
3
 
@@ -12,65 +10,76 @@ from .base import (
12
10
  ServiceSpec,
13
11
  VolumeSpec,
14
12
  CustomCommands,
13
+ Config,
15
14
  )
15
+ from .php import PhpConfig, PhpProvider
16
+ from .node_static import NodeStaticConfig, NodeStaticProvider
17
+ from pydantic_settings import SettingsConfigDict
18
+
19
+
20
+ class LaravelConfig(PhpConfig, NodeStaticConfig):
21
+ model_config = SettingsConfigDict(extra="ignore", env_prefix="SHIPIT_")
16
22
 
17
23
 
18
- class LaravelProvider:
19
- def __init__(self, path: Path, custom_commands: CustomCommands):
24
+ class LaravelProvider(PhpProvider):
25
+ def __init__(self, path: Path, config: LaravelConfig):
20
26
  self.path = path
21
- self.custom_commands = custom_commands
27
+ self.node_provider = NodeStaticProvider(path, config, only_build=True)
28
+ self.config = config
29
+
30
+ @classmethod
31
+ def load_config(cls, path: Path, base_config: Config) -> LaravelConfig:
32
+ config = super().load_config(path, base_config)
33
+ node_config = NodeStaticProvider.load_config(path, base_config)
34
+ node_config.static_dir = None
35
+ node_config.static_generator = None
36
+ return LaravelConfig(
37
+ **(
38
+ config.model_dump()
39
+ | node_config.model_dump()
40
+ | base_config.model_dump()
41
+ )
42
+ )
22
43
 
23
44
  @classmethod
24
45
  def name(cls) -> str:
25
46
  return "laravel"
26
47
 
27
48
  @classmethod
28
- def detect(cls, path: Path, custom_commands: CustomCommands) -> Optional[DetectResult]:
49
+ def detect(cls, path: Path, config: Config) -> Optional[DetectResult]:
29
50
  if _exists(path, "artisan") and _exists(path, "composer.json"):
30
51
  return DetectResult(cls.name(), 95)
31
52
  return None
32
53
 
33
- def initialize(self) -> None:
34
- pass
35
-
36
- def serve_name(self) -> str:
37
- return self.path.name
38
-
39
- def platform(self) -> Optional[str]:
40
- return "laravel"
54
+ def serve_name(self) -> Optional[str]:
55
+ return None
41
56
 
42
57
  def dependencies(self) -> list[DependencySpec]:
43
58
  return [
44
59
  DependencySpec(
45
60
  "php",
46
- env_var="SHIPIT_PHP_VERSION",
47
- default_version="8.3",
61
+ var_name="config.php_version",
48
62
  use_in_build=True,
49
63
  use_in_serve=True,
50
64
  ),
51
65
  DependencySpec("composer", use_in_build=True),
52
- DependencySpec("pie", use_in_build=True),
53
- DependencySpec("pnpm", use_in_build=True),
66
+ # DependencySpec("pie", use_in_build=True),
67
+ *self.node_provider.dependencies(),
54
68
  DependencySpec("bash", use_in_serve=True),
55
69
  ]
56
70
 
57
- def declarations(self) -> Optional[str]:
58
- return "HOME = getenv(\"HOME\")"
59
-
60
71
  def build_steps(self) -> list[str]:
61
72
  return [
62
- "env(HOME=HOME, COMPOSER_FUND=\"0\")",
63
- "workdir(app[\"build\"])",
64
- "run(\"pie install php/pdo_pgsql\")",
65
- "run(\"composer install --optimize-autoloader --no-scripts --no-interaction\", inputs=[\"composer.json\", \"composer.lock\", \"artisan\"], outputs=[\".\"], group=\"install\")",
66
- "run(\"pnpm install\", inputs=[\"package.json\", \"package-lock.json\"], outputs=[\".\"], group=\"install\")",
67
- "copy(\".\", \".\", ignore=[\".git\"])",
68
- "run(\"pnpm run build\", outputs=[\".\"], group=\"build\")",
73
+ 'env(COMPOSER_HOME="/tmp", COMPOSER_FUND="0")',
74
+ 'workdir(app.path)',
75
+ # "run(\"pie install php/pdo_pgsql\")",
76
+ 'run("composer install --optimize-autoloader --no-scripts --no-interaction", inputs=["composer.json", "composer.lock", "artisan"], outputs=["."], group="install")',
77
+ *self.node_provider.build_steps(),
69
78
  ]
70
79
 
71
80
  def prepare_steps(self) -> Optional[list[str]]:
72
81
  return [
73
- 'workdir(app["serve"])',
82
+ 'workdir(app.serve_path)',
74
83
  'run("mkdir -p storage/framework/{sessions,views,cache,testing} storage/logs bootstrap/cache")',
75
84
  'run("php artisan config:cache")',
76
85
  'run("php artisan event:cache")',
@@ -85,13 +94,13 @@ class LaravelProvider:
85
94
  }
86
95
 
87
96
  def mounts(self) -> list[MountSpec]:
88
- return [MountSpec("app")]
97
+ return [MountSpec("app"), *self.node_provider.mounts()]
89
98
 
90
99
  def volumes(self) -> list[VolumeSpec]:
91
100
  return []
92
101
 
93
102
  def env(self) -> Optional[Dict[str, str]]:
94
103
  return None
95
-
104
+
96
105
  def services(self) -> list[ServiceSpec]:
97
106
  return []
@@ -1,5 +1,3 @@
1
- from __future__ import annotations
2
-
3
1
  from pathlib import Path
4
2
  from typing import Dict, Optional
5
3
 
@@ -12,35 +10,52 @@ from .base import (
12
10
  ServiceSpec,
13
11
  VolumeSpec,
14
12
  CustomCommands,
13
+ Config,
15
14
  )
16
- from .staticfile import StaticFileProvider
17
- from .python import PythonProvider
15
+ from .staticfile import StaticFileProvider, StaticFileConfig
16
+ from .python import PythonProvider, PythonConfig
17
+ from pydantic_settings import SettingsConfigDict
18
+
19
+
20
+ class MkdocsConfig(PythonConfig, StaticFileConfig):
21
+ model_config = SettingsConfigDict(extra="ignore", env_prefix="SHIPIT_")
22
+
23
+ mkdocs_version: Optional[str] = None
18
24
 
19
25
 
20
26
  class MkdocsProvider(StaticFileProvider):
21
- def __init__(self, path: Path, custom_commands: CustomCommands):
27
+ def __init__(self, path: Path, config: MkdocsConfig):
22
28
  self.path = path
23
- self.python_provider = PythonProvider(path, custom_commands, only_build=True, extra_dependencies={"mkdocs"})
29
+ self.python_provider = PythonProvider(path, config, only_build=True)
30
+
31
+ @classmethod
32
+ def load_config(cls, path: Path, base_config: Config) -> MkdocsConfig:
33
+ python_config = PythonProvider.load_config(
34
+ path, base_config, must_have_deps={"mkdocs"}
35
+ )
36
+ staticfile_config = StaticFileProvider.load_config(path, base_config)
37
+
38
+ return MkdocsConfig(
39
+ **(
40
+ python_config.model_dump()
41
+ | staticfile_config.model_dump()
42
+ | base_config.model_dump()
43
+ )
44
+ )
24
45
 
25
46
  @classmethod
26
47
  def name(cls) -> str:
27
48
  return "mkdocs"
28
49
 
29
50
  @classmethod
30
- def detect(cls, path: Path, custom_commands: CustomCommands) -> Optional[DetectResult]:
51
+ def detect(cls, path: Path, config: Config) -> Optional[DetectResult]:
31
52
  if _exists(path, "mkdocs.yml", "mkdocs.yaml"):
32
53
  return DetectResult(cls.name(), 85)
33
- if custom_commands.build and custom_commands.build.startswith("mkdocs "):
54
+ if config.commands.build and config.commands.build.startswith("mkdocs "):
34
55
  return DetectResult(cls.name(), 85)
35
56
  return None
36
57
 
37
- def initialize(self) -> None:
38
- pass
39
-
40
- def serve_name(self) -> str:
41
- return self.path.name
42
-
43
- def platform(self) -> Optional[str]:
58
+ def serve_name(self) -> Optional[str]:
44
59
  return None
45
60
 
46
61
  def dependencies(self) -> list[DependencySpec]:
@@ -50,25 +65,25 @@ class MkdocsProvider(StaticFileProvider):
50
65
  ]
51
66
 
52
67
  def declarations(self) -> Optional[str]:
53
- return "mkdocs_version = getenv(\"SHIPIT_MKDOCS_VERSION\") or \"1.6.1\"\n" + (self.python_provider.declarations() or "")
68
+ return self.python_provider.declarations() or ""
54
69
 
55
70
  def build_steps(self) -> list[str]:
56
71
  return [
57
72
  *self.python_provider.build_steps(),
58
- "run(\"uv run mkdocs build --site-dir={}\".format(app[\"build\"]), outputs=[\".\"], group=\"build\")",
73
+ 'run("uv run mkdocs build --site-dir={}".format(static_app.path), outputs=["."], group="build")',
59
74
  ]
60
75
 
61
76
  def prepare_steps(self) -> Optional[list[str]]:
62
77
  return self.python_provider.prepare_steps()
63
78
 
64
79
  def mounts(self) -> list[MountSpec]:
65
- return [MountSpec("app"), *self.python_provider.mounts()]
80
+ return [*self.python_provider.mounts(), *super().mounts()]
66
81
 
67
82
  def volumes(self) -> list[VolumeSpec]:
68
83
  return []
69
84
 
70
85
  def env(self) -> Optional[Dict[str, str]]:
71
86
  return self.python_provider.env()
72
-
87
+
73
88
  def services(self) -> list[ServiceSpec]:
74
89
  return []