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/runners/wasmer.py
ADDED
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import hashlib
|
|
2
|
+
import json
|
|
3
|
+
import os
|
|
4
|
+
import shlex
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Any, Dict, List, Optional, Set, TypedDict, cast
|
|
7
|
+
|
|
8
|
+
import sh # type: ignore[import-untyped]
|
|
9
|
+
import yaml
|
|
10
|
+
from rich import box
|
|
11
|
+
from rich.panel import Panel
|
|
12
|
+
from rich.syntax import Syntax
|
|
13
|
+
from tomlkit import array, aot, comment, document, nl, string, table
|
|
14
|
+
|
|
15
|
+
from shipit.builders.base import BuildBackend
|
|
16
|
+
from shipit.runners.base import Runner
|
|
17
|
+
from shipit.shipit_types import Package, PrepareStep, RunStep, Serve, WorkdirStep
|
|
18
|
+
from shipit.ui import console, write_stderr, write_stdout
|
|
19
|
+
from shipit.version import version as shipit_version
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class MapperItem(TypedDict, total=False):
|
|
23
|
+
dependencies: Dict[str, str]
|
|
24
|
+
scripts: Set[str]
|
|
25
|
+
env: Dict[str, str]
|
|
26
|
+
aliases: Dict[str, str]
|
|
27
|
+
architecture_dependencies: Dict[str, Dict[str, str]]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class WasmerRunner:
|
|
31
|
+
rewrite_binaries: Dict[str, str] = {
|
|
32
|
+
"python": "python",
|
|
33
|
+
"python3": "python",
|
|
34
|
+
"python3.13": "python",
|
|
35
|
+
"daphne": "python -m daphne",
|
|
36
|
+
"gunicorn": "python -m gunicorn",
|
|
37
|
+
"uvicorn": "python -m uvicorn",
|
|
38
|
+
"hypercorn": "python -m hypercorn",
|
|
39
|
+
"fastapi": "python -m fastapi",
|
|
40
|
+
"streamlit": "python -m streamlit",
|
|
41
|
+
"flask": "python -m flask",
|
|
42
|
+
"mcp": "python -m mcp",
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
mapper: Dict[str, MapperItem] = {
|
|
46
|
+
"python": {
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"latest": "python/python@=3.13.3",
|
|
49
|
+
"3.13": "python/python@=3.13.3",
|
|
50
|
+
},
|
|
51
|
+
"scripts": {"python"},
|
|
52
|
+
"aliases": {},
|
|
53
|
+
"env": {
|
|
54
|
+
"PYTHONEXECUTABLE": "/bin/python",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
"pandoc": {
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"latest": "wasmer/pandoc@=0.0.1",
|
|
60
|
+
"3.5": "wasmer/pandoc@=0.0.1",
|
|
61
|
+
},
|
|
62
|
+
"scripts": {"pandoc"},
|
|
63
|
+
},
|
|
64
|
+
"ffmpeg": {
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"latest": "wasmer/ffmpeg@=1.0.5",
|
|
67
|
+
"N-111519": "wasmer/ffmpeg@=1.0.5",
|
|
68
|
+
},
|
|
69
|
+
"scripts": {"ffmpeg"},
|
|
70
|
+
},
|
|
71
|
+
"php": {
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"latest": "php/php-32@=8.3.2102",
|
|
74
|
+
"8.3": "php/php-32@=8.3.2102",
|
|
75
|
+
"8.2": "php/php-32@=8.2.2801",
|
|
76
|
+
"8.1": "php/php-32@=8.1.3201",
|
|
77
|
+
"7.4": "php/php-32@=7.4.3301",
|
|
78
|
+
},
|
|
79
|
+
"architecture_dependencies": {
|
|
80
|
+
"64-bit": {
|
|
81
|
+
"latest": "php/php-64@=8.3.2102",
|
|
82
|
+
"8.3": "php/php-64@=8.3.2102",
|
|
83
|
+
"8.2": "php/php-64@=8.2.2801",
|
|
84
|
+
"8.1": "php/php-64@=8.1.3201",
|
|
85
|
+
"7.4": "php/php-64@=7.4.3301",
|
|
86
|
+
},
|
|
87
|
+
"32-bit": {
|
|
88
|
+
"latest": "php/php-32@=8.3.2102",
|
|
89
|
+
"8.3": "php/php-32@=8.3.2102",
|
|
90
|
+
"8.2": "php/php-32@=8.2.2801",
|
|
91
|
+
"8.1": "php/php-32@=8.1.3201",
|
|
92
|
+
"7.4": "php/php-32@=7.4.3301",
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
"scripts": {"php"},
|
|
96
|
+
"aliases": {},
|
|
97
|
+
"env": {},
|
|
98
|
+
},
|
|
99
|
+
"bash": {
|
|
100
|
+
"dependencies": {
|
|
101
|
+
"latest": "wasmer/bash@=1.0.24",
|
|
102
|
+
"8.3": "wasmer/bash@=1.0.24",
|
|
103
|
+
},
|
|
104
|
+
"scripts": {"bash", "sh"},
|
|
105
|
+
"aliases": {},
|
|
106
|
+
"env": {},
|
|
107
|
+
},
|
|
108
|
+
"static-web-server": {
|
|
109
|
+
"dependencies": {
|
|
110
|
+
"latest": "wasmer/static-web-server@=1.1.0",
|
|
111
|
+
"2.38.0": "wasmer/static-web-server@=1.1.0",
|
|
112
|
+
"0.1": "wasmer/static-web-server@=1.1.0",
|
|
113
|
+
},
|
|
114
|
+
"scripts": {"webserver"},
|
|
115
|
+
"aliases": {"static-web-server": "webserver"},
|
|
116
|
+
"env": {},
|
|
117
|
+
},
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
def __init__(
|
|
121
|
+
self,
|
|
122
|
+
build_backend: BuildBackend,
|
|
123
|
+
src_dir: Path,
|
|
124
|
+
registry: Optional[str] = None,
|
|
125
|
+
token: Optional[str] = None,
|
|
126
|
+
bin: Optional[str] = None,
|
|
127
|
+
) -> None:
|
|
128
|
+
self.build_backend = build_backend
|
|
129
|
+
self.src_dir = src_dir
|
|
130
|
+
self.wasmer_dir_path = self.src_dir / ".shipit" / "wasmer"
|
|
131
|
+
self.wasmer_registry = registry
|
|
132
|
+
self.wasmer_token = token
|
|
133
|
+
self.bin = bin or "wasmer"
|
|
134
|
+
|
|
135
|
+
def get_serve_mount_path(self, name: str) -> Path:
|
|
136
|
+
if name == "app":
|
|
137
|
+
return Path("/app")
|
|
138
|
+
else:
|
|
139
|
+
return Path("/opt") / name
|
|
140
|
+
|
|
141
|
+
def prepare_config(self, provider_config: Any) -> Any:
|
|
142
|
+
from shipit.providers.python import PythonConfig
|
|
143
|
+
|
|
144
|
+
if isinstance(provider_config, PythonConfig):
|
|
145
|
+
provider_config.python_extra_index_url = (
|
|
146
|
+
"https://pythonindex.wasix.org/simple"
|
|
147
|
+
)
|
|
148
|
+
provider_config.cross_platform = "wasix_wasm32"
|
|
149
|
+
provider_config.precompile_python = True
|
|
150
|
+
return provider_config
|
|
151
|
+
|
|
152
|
+
def build(self, serve: Serve) -> None:
|
|
153
|
+
self.build_prepare(serve)
|
|
154
|
+
self.build_serve(serve)
|
|
155
|
+
|
|
156
|
+
def build_prepare(self, serve: Serve) -> None:
|
|
157
|
+
if not serve.prepare:
|
|
158
|
+
return
|
|
159
|
+
prepare_dir = self.wasmer_dir_path / "prepare"
|
|
160
|
+
prepare_dir.mkdir(parents=True, exist_ok=True)
|
|
161
|
+
env = serve.env or {}
|
|
162
|
+
for dep in serve.deps:
|
|
163
|
+
if dep.name in self.mapper:
|
|
164
|
+
dep_env = self.mapper[dep.name].get("env")
|
|
165
|
+
if dep_env is not None:
|
|
166
|
+
env.update(dep_env)
|
|
167
|
+
if env:
|
|
168
|
+
env_lines = [f"export {k}={v}" for k, v in env.items()]
|
|
169
|
+
env_lines = "\n".join(env_lines)
|
|
170
|
+
else:
|
|
171
|
+
env_lines = ""
|
|
172
|
+
|
|
173
|
+
commands: List[str] = []
|
|
174
|
+
if serve.cwd:
|
|
175
|
+
commands.append(f"cd {serve.cwd}")
|
|
176
|
+
|
|
177
|
+
if serve.prepare:
|
|
178
|
+
for step in serve.prepare:
|
|
179
|
+
commands.append(step.command)
|
|
180
|
+
|
|
181
|
+
body = "\n".join(filter(None, [env_lines, *commands]))
|
|
182
|
+
content = f"#!/bin/bash\n\n{body}"
|
|
183
|
+
console.print(
|
|
184
|
+
f"\n[bold]Created prepare.sh script to run before packaging ✅[/bold]"
|
|
185
|
+
)
|
|
186
|
+
manifest_panel = Panel(
|
|
187
|
+
Syntax(
|
|
188
|
+
content,
|
|
189
|
+
"bash",
|
|
190
|
+
theme="monokai",
|
|
191
|
+
background_color="default",
|
|
192
|
+
line_numbers=True,
|
|
193
|
+
),
|
|
194
|
+
box=box.SQUARE,
|
|
195
|
+
border_style="bright_black",
|
|
196
|
+
expand=False,
|
|
197
|
+
)
|
|
198
|
+
console.print(manifest_panel, markup=False, highlight=True)
|
|
199
|
+
|
|
200
|
+
(prepare_dir / "prepare.sh").write_text(content)
|
|
201
|
+
(prepare_dir / "prepare.sh").chmod(0o755)
|
|
202
|
+
|
|
203
|
+
def prepare(self, env: Dict[str, str], prepare: List[PrepareStep]) -> None:
|
|
204
|
+
prepare_dir = self.wasmer_dir_path / "prepare"
|
|
205
|
+
self.run_serve_command(
|
|
206
|
+
"bash",
|
|
207
|
+
extra_args=[
|
|
208
|
+
f"--mapdir=/prepare:{prepare_dir}",
|
|
209
|
+
"--",
|
|
210
|
+
"/prepare/prepare.sh",
|
|
211
|
+
],
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
def build_serve(self, serve: Serve) -> None:
|
|
215
|
+
doc = document()
|
|
216
|
+
doc.add(comment(f"Wasmer manifest generated with Shipit v{shipit_version}"))
|
|
217
|
+
package = table()
|
|
218
|
+
doc.add("package", package)
|
|
219
|
+
package.add("entrypoint", "start")
|
|
220
|
+
dependencies = table()
|
|
221
|
+
doc.add("dependencies", dependencies)
|
|
222
|
+
|
|
223
|
+
binaries: Dict[str, Dict[str, Optional[Dict[str, str]]]] = {}
|
|
224
|
+
|
|
225
|
+
deps = serve.deps or []
|
|
226
|
+
if serve.prepare and not any(dep.name == "bash" for dep in deps):
|
|
227
|
+
deps.append(Package("bash"))
|
|
228
|
+
|
|
229
|
+
if deps:
|
|
230
|
+
console.print(f"[bold]Mapping dependencies to Wasmer packages:[/bold]")
|
|
231
|
+
for dep in deps:
|
|
232
|
+
if dep.name in self.mapper:
|
|
233
|
+
version = dep.version or "latest"
|
|
234
|
+
mapped_dependencies = self.mapper[dep.name]["dependencies"]
|
|
235
|
+
if dep.architecture:
|
|
236
|
+
architecture_dependencies = (
|
|
237
|
+
self.mapper[dep.name]
|
|
238
|
+
.get("architecture_dependencies", {})
|
|
239
|
+
.get(dep.architecture, {})
|
|
240
|
+
)
|
|
241
|
+
if architecture_dependencies:
|
|
242
|
+
mapped_dependencies = architecture_dependencies
|
|
243
|
+
if version in mapped_dependencies:
|
|
244
|
+
console.print(
|
|
245
|
+
f"* {dep.name}@{version} mapped to {self.mapper[dep.name]['dependencies'][version]}"
|
|
246
|
+
)
|
|
247
|
+
package_name, version = mapped_dependencies[version].split("@")
|
|
248
|
+
dependencies.add(package_name, version)
|
|
249
|
+
scripts = self.mapper[dep.name].get("scripts") or []
|
|
250
|
+
for script in scripts:
|
|
251
|
+
binaries[script] = {
|
|
252
|
+
"script": f"{package_name}:{script}",
|
|
253
|
+
"env": self.mapper[dep.name].get("env"),
|
|
254
|
+
}
|
|
255
|
+
aliases = self.mapper[dep.name].get("aliases") or {}
|
|
256
|
+
for alias, script in aliases.items():
|
|
257
|
+
binaries[alias] = {
|
|
258
|
+
"script": f"{package_name}:{script}",
|
|
259
|
+
"env": self.mapper[dep.name].get("env"),
|
|
260
|
+
}
|
|
261
|
+
else:
|
|
262
|
+
raise Exception(
|
|
263
|
+
f"Dependency {dep.name}@{version} not found in Wasmer"
|
|
264
|
+
)
|
|
265
|
+
else:
|
|
266
|
+
raise Exception(f"Dependency {dep.name} not found in Wasmer")
|
|
267
|
+
|
|
268
|
+
fs = table()
|
|
269
|
+
doc.add("fs", fs)
|
|
270
|
+
if serve.mounts:
|
|
271
|
+
for mount in serve.mounts:
|
|
272
|
+
fs.add(
|
|
273
|
+
str(mount.serve_path.absolute()),
|
|
274
|
+
str(
|
|
275
|
+
self.build_backend.get_artifact_mount_path(
|
|
276
|
+
mount.name
|
|
277
|
+
).absolute()
|
|
278
|
+
),
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
doc.add(nl())
|
|
282
|
+
if serve.commands:
|
|
283
|
+
commands = aot()
|
|
284
|
+
doc.add("command", commands)
|
|
285
|
+
for command_name, command_line in serve.commands.items():
|
|
286
|
+
command = table()
|
|
287
|
+
commands.append(command)
|
|
288
|
+
parts = shlex.split(command_line)
|
|
289
|
+
program = parts[0]
|
|
290
|
+
if program in self.rewrite_binaries:
|
|
291
|
+
rewritten_program = shlex.split(self.rewrite_binaries[program])
|
|
292
|
+
program = rewritten_program[0]
|
|
293
|
+
parts[:1] = rewritten_program
|
|
294
|
+
elif program not in binaries:
|
|
295
|
+
raise Exception(f"Binary {program} not runable in Wasmer yet")
|
|
296
|
+
command.add("name", command_name)
|
|
297
|
+
program_binary = binaries.get(program)
|
|
298
|
+
if not program_binary:
|
|
299
|
+
raise Exception(f"Command {command_name} is trying to run {program} but it is not available (dependencies: {', '.join(dependencies.keys())}, programs: {', '.join(binaries.keys())})")
|
|
300
|
+
command.add("module", program_binary["script"])
|
|
301
|
+
command.add("runner", "wasi")
|
|
302
|
+
wasi_args = table()
|
|
303
|
+
if serve.cwd:
|
|
304
|
+
wasi_args.add("cwd", serve.cwd)
|
|
305
|
+
wasi_args.add("main-args", array(parts[1:]).multiline(True))
|
|
306
|
+
env = program_binary.get("env") or {}
|
|
307
|
+
if serve.env:
|
|
308
|
+
env.update(serve.env)
|
|
309
|
+
if env:
|
|
310
|
+
arr = array([f"{k}={v}" for k, v in env.items()]).multiline(True)
|
|
311
|
+
wasi_args.add("env", arr)
|
|
312
|
+
title = string("annotations.wasi", literal=False)
|
|
313
|
+
command.add(title, wasi_args)
|
|
314
|
+
|
|
315
|
+
self.wasmer_dir_path.mkdir(parents=True, exist_ok=True)
|
|
316
|
+
|
|
317
|
+
manifest = doc.as_string().replace(
|
|
318
|
+
'[command."annotations.wasi"]', "[command.annotations.wasi]"
|
|
319
|
+
)
|
|
320
|
+
console.print(f"\n[bold]Created wasmer.toml manifest ✅[/bold]")
|
|
321
|
+
manifest_panel = Panel(
|
|
322
|
+
Syntax(
|
|
323
|
+
manifest.strip(),
|
|
324
|
+
"toml",
|
|
325
|
+
theme="monokai",
|
|
326
|
+
background_color="default",
|
|
327
|
+
line_numbers=True,
|
|
328
|
+
),
|
|
329
|
+
box=box.SQUARE,
|
|
330
|
+
border_style="bright_black",
|
|
331
|
+
expand=False,
|
|
332
|
+
)
|
|
333
|
+
console.print(manifest_panel, markup=False, highlight=True)
|
|
334
|
+
(self.wasmer_dir_path / "wasmer.toml").write_text(manifest)
|
|
335
|
+
|
|
336
|
+
original_app_yaml_path = self.src_dir / "app.yaml"
|
|
337
|
+
if original_app_yaml_path.exists():
|
|
338
|
+
console.print(
|
|
339
|
+
f"[bold]Using original app.yaml found in source directory[/bold]"
|
|
340
|
+
)
|
|
341
|
+
yaml_config = yaml.safe_load(original_app_yaml_path.read_text())
|
|
342
|
+
else:
|
|
343
|
+
yaml_config = {
|
|
344
|
+
"kind": "wasmer.io/App.v0",
|
|
345
|
+
}
|
|
346
|
+
yaml_config["package"] = "."
|
|
347
|
+
if serve.services:
|
|
348
|
+
capabilities = yaml_config.get("capabilities", {})
|
|
349
|
+
has_mysql = any(service.provider == "mysql" for service in serve.services)
|
|
350
|
+
if has_mysql:
|
|
351
|
+
capabilities["database"] = {"engine": "mysql"}
|
|
352
|
+
yaml_config["capabilities"] = capabilities
|
|
353
|
+
|
|
354
|
+
if serve.volumes:
|
|
355
|
+
volumes_yaml = yaml_config.get("volumes", [])
|
|
356
|
+
for vol in serve.volumes:
|
|
357
|
+
volumes_yaml.append(
|
|
358
|
+
{
|
|
359
|
+
"name": vol.name,
|
|
360
|
+
"mount": str(vol.serve_path),
|
|
361
|
+
}
|
|
362
|
+
)
|
|
363
|
+
yaml_config["volumes"] = volumes_yaml
|
|
364
|
+
|
|
365
|
+
has_php = any(dep.name == "php" for dep in serve.deps)
|
|
366
|
+
if has_php:
|
|
367
|
+
scaling = yaml_config.get("scaling", {})
|
|
368
|
+
scaling["mode"] = "single_concurrency"
|
|
369
|
+
yaml_config["scaling"] = scaling
|
|
370
|
+
|
|
371
|
+
if "after_deploy" in serve.commands:
|
|
372
|
+
jobs = yaml_config.get("jobs", [])
|
|
373
|
+
jobs.append(
|
|
374
|
+
{
|
|
375
|
+
"name": "after_deploy",
|
|
376
|
+
"trigger": "post-deployment",
|
|
377
|
+
"action": {"execute": {"command": "after_deploy"}},
|
|
378
|
+
}
|
|
379
|
+
)
|
|
380
|
+
yaml_config["jobs"] = jobs
|
|
381
|
+
|
|
382
|
+
app_yaml = yaml.dump(yaml_config)
|
|
383
|
+
|
|
384
|
+
console.print(f"\n[bold]Created app.yaml manifest ✅[/bold]")
|
|
385
|
+
app_yaml_panel = Panel(
|
|
386
|
+
Syntax(
|
|
387
|
+
app_yaml.strip(),
|
|
388
|
+
"yaml",
|
|
389
|
+
theme="monokai",
|
|
390
|
+
background_color="default",
|
|
391
|
+
line_numbers=True,
|
|
392
|
+
),
|
|
393
|
+
box=box.SQUARE,
|
|
394
|
+
border_style="bright_black",
|
|
395
|
+
expand=False,
|
|
396
|
+
)
|
|
397
|
+
console.print(app_yaml_panel, markup=False, highlight=True)
|
|
398
|
+
(self.wasmer_dir_path / "app.yaml").write_text(app_yaml)
|
|
399
|
+
|
|
400
|
+
def run_serve_command(
|
|
401
|
+
self, command: str, extra_args: Optional[List[str]] = None
|
|
402
|
+
) -> None:
|
|
403
|
+
console.print(f"\n[bold]Serving site[/bold]: running {command} command")
|
|
404
|
+
extra_args = extra_args or []
|
|
405
|
+
|
|
406
|
+
if self.wasmer_registry:
|
|
407
|
+
extra_args = [f"--registry={self.wasmer_registry}"] + extra_args
|
|
408
|
+
self.run_command(
|
|
409
|
+
self.bin,
|
|
410
|
+
[
|
|
411
|
+
"run",
|
|
412
|
+
str(self.wasmer_dir_path.absolute()),
|
|
413
|
+
"--net",
|
|
414
|
+
f"--command={command}",
|
|
415
|
+
*extra_args,
|
|
416
|
+
],
|
|
417
|
+
)
|
|
418
|
+
|
|
419
|
+
def run_command(
|
|
420
|
+
self, command: str, extra_args: Optional[List[str]] | None = None
|
|
421
|
+
) -> Any:
|
|
422
|
+
sh.Command(command)(
|
|
423
|
+
*(extra_args or []), _out=write_stdout, _err=write_stderr, _env=os.environ
|
|
424
|
+
)
|
|
425
|
+
|
|
426
|
+
def deploy_config(self, config_path: Path) -> None:
|
|
427
|
+
package_webc_path = self.wasmer_dir_path / "package.webc"
|
|
428
|
+
app_yaml_path = self.wasmer_dir_path / "app.yaml"
|
|
429
|
+
package_webc_path.parent.mkdir(parents=True, exist_ok=True)
|
|
430
|
+
self.run_command(
|
|
431
|
+
self.bin,
|
|
432
|
+
["package", "build", self.wasmer_dir_path, "--out", package_webc_path],
|
|
433
|
+
)
|
|
434
|
+
config_path.write_text(
|
|
435
|
+
json.dumps(
|
|
436
|
+
{
|
|
437
|
+
"app_yaml_path": str(app_yaml_path.absolute()),
|
|
438
|
+
"package_webc_path": str(package_webc_path.absolute()),
|
|
439
|
+
"package_webc_size": package_webc_path.stat().st_size,
|
|
440
|
+
"package_webc_sha256": hashlib.sha256(
|
|
441
|
+
package_webc_path.read_bytes()
|
|
442
|
+
).hexdigest(),
|
|
443
|
+
}
|
|
444
|
+
)
|
|
445
|
+
)
|
|
446
|
+
console.print(f"\n[bold]Saved deploy config to {config_path}[/bold]")
|
|
447
|
+
|
|
448
|
+
def deploy(
|
|
449
|
+
self, app_owner: Optional[str] = None, app_name: Optional[str] = None
|
|
450
|
+
) -> None:
|
|
451
|
+
extra_args: List[str] = []
|
|
452
|
+
if self.wasmer_registry:
|
|
453
|
+
extra_args += ["--registry", self.wasmer_registry]
|
|
454
|
+
if self.wasmer_token:
|
|
455
|
+
extra_args += ["--token", self.wasmer_token]
|
|
456
|
+
if app_owner:
|
|
457
|
+
extra_args += ["--owner", app_owner]
|
|
458
|
+
if app_name:
|
|
459
|
+
extra_args += ["--app-name", app_name]
|
|
460
|
+
self.run_command(
|
|
461
|
+
self.bin,
|
|
462
|
+
[
|
|
463
|
+
"deploy",
|
|
464
|
+
"--publish-package",
|
|
465
|
+
"--dir",
|
|
466
|
+
self.wasmer_dir_path,
|
|
467
|
+
"--non-interactive",
|
|
468
|
+
*extra_args,
|
|
469
|
+
],
|
|
470
|
+
)
|
shipit/shipit_types.py
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Dict, List, Literal, Optional, Union
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class Mount:
|
|
8
|
+
name: str
|
|
9
|
+
build_path: Path
|
|
10
|
+
serve_path: Path
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass
|
|
14
|
+
class Volume:
|
|
15
|
+
name: str
|
|
16
|
+
serve_path: Path
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class Service:
|
|
21
|
+
name: str
|
|
22
|
+
provider: Literal["postgres", "mysql", "redis"]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass
|
|
26
|
+
class Serve:
|
|
27
|
+
name: str
|
|
28
|
+
provider: str
|
|
29
|
+
build: List["Step"]
|
|
30
|
+
deps: List["Package"]
|
|
31
|
+
commands: Dict[str, str]
|
|
32
|
+
cwd: Optional[str] = None
|
|
33
|
+
prepare: Optional[List["PrepareStep"]] = None
|
|
34
|
+
workers: Optional[List[str]] = None
|
|
35
|
+
mounts: Optional[List[Mount]] = None
|
|
36
|
+
volumes: Optional[List[Volume]] = None
|
|
37
|
+
env: Optional[Dict[str, str]] = None
|
|
38
|
+
services: Optional[List[Service]] = None
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@dataclass
|
|
42
|
+
class Package:
|
|
43
|
+
name: str
|
|
44
|
+
version: Optional[str] = None
|
|
45
|
+
architecture: Optional[Literal["64-bit", "32-bit"]] = None
|
|
46
|
+
|
|
47
|
+
def __str__(self) -> str:
|
|
48
|
+
name = f"{self.name}({self.architecture})" if self.architecture else self.name
|
|
49
|
+
if self.version is None:
|
|
50
|
+
return name
|
|
51
|
+
return f"{name}@{self.version}"
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@dataclass
|
|
55
|
+
class RunStep:
|
|
56
|
+
command: str
|
|
57
|
+
inputs: Optional[List[str]] = None
|
|
58
|
+
outputs: Optional[List[str]] = None
|
|
59
|
+
group: Optional[str] = None
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@dataclass
|
|
63
|
+
class WorkdirStep:
|
|
64
|
+
path: Path
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@dataclass
|
|
68
|
+
class CopyStep:
|
|
69
|
+
source: str
|
|
70
|
+
target: str
|
|
71
|
+
ignore: Optional[List[str]] = None
|
|
72
|
+
base: Literal["source", "assets"] = "source"
|
|
73
|
+
|
|
74
|
+
def is_download(self) -> bool:
|
|
75
|
+
return self.source.startswith("http://") or self.source.startswith("https://")
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@dataclass
|
|
79
|
+
class EnvStep:
|
|
80
|
+
variables: Dict[str, str]
|
|
81
|
+
|
|
82
|
+
def __str__(self) -> str:
|
|
83
|
+
return " ".join([f"{key}={value}" for key, value in self.variables.items()])
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@dataclass
|
|
87
|
+
class UseStep:
|
|
88
|
+
dependencies: List[Package]
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@dataclass
|
|
92
|
+
class PathStep:
|
|
93
|
+
path: str
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
Step = Union[RunStep, CopyStep, EnvStep, PathStep, UseStep, WorkdirStep]
|
|
97
|
+
PrepareStep = Union[RunStep]
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
@dataclass
|
|
101
|
+
class Build:
|
|
102
|
+
deps: List[Package]
|
|
103
|
+
steps: List[Step]
|
shipit/ui.py
ADDED
shipit/utils.py
ADDED
shipit/version.py
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: shipit-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.15.0
|
|
4
4
|
Summary: Shipit CLI is the best way to build, serve and deploy your projects anywhere.
|
|
5
5
|
Project-URL: homepage, https://wasmer.io
|
|
6
6
|
Project-URL: repository, https://github.com/wasmerio/shipit
|
|
7
7
|
Project-URL: Changelog, https://github.com/wasmerio/shipit/changelog
|
|
8
8
|
Requires-Python: >=3.10
|
|
9
9
|
Requires-Dist: dotenv>=0.9.9
|
|
10
|
+
Requires-Dist: pydantic-settings>=2.12.0
|
|
11
|
+
Requires-Dist: pydantic>=2.12.4
|
|
10
12
|
Requires-Dist: pyyaml>=6.0.2
|
|
11
13
|
Requires-Dist: requests>=2.32.5
|
|
12
14
|
Requires-Dist: rich>=14.1.0
|
|
13
15
|
Requires-Dist: semantic-version>=2.10.0
|
|
14
16
|
Requires-Dist: sh>=2.2.2
|
|
15
|
-
Requires-Dist:
|
|
17
|
+
Requires-Dist: toml>=0.10.2
|
|
16
18
|
Requires-Dist: tomlkit>=0.13.3
|
|
17
19
|
Requires-Dist: typer>=0.16.1
|
|
20
|
+
Requires-Dist: xingque>=0.2.1
|
|
18
21
|
Description-Content-Type: text/markdown
|
|
19
22
|
|
|
20
23
|
# Shipit
|
|
@@ -71,7 +74,7 @@ with `--use-provider`.
|
|
|
71
74
|
uvx shipit-cli plan --out plan.json
|
|
72
75
|
```
|
|
73
76
|
|
|
74
|
-
Evaluate the project and emit
|
|
77
|
+
Evaluate the project and emit config, derived commands, and required
|
|
75
78
|
services without building. Helpful for CI checks or debugging configuration.
|
|
76
79
|
|
|
77
80
|
### `build`
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
shipit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
shipit/cli.py,sha256=YPEyl6yjk2CH2YnjB1wmF3m_ZbJ0_Ktr2mmpFFLrsS4,33825
|
|
3
|
+
shipit/generator.py,sha256=CyAwWmwcd0JrRSlcux9X1ZWuAnzJK3QBjN5yKgmKVqQ,7526
|
|
4
|
+
shipit/procfile.py,sha256=bjsdG8aSbRhKvrN96OiSOh0xjJHnlZg42eadtlsLc0M,1129
|
|
5
|
+
shipit/shipit_types.py,sha256=wQzuYOIJMlovOq56ropf2T3j_Ye6Y8BYYdAuXfEGHbM,2062
|
|
6
|
+
shipit/ui.py,sha256=vqtuAYXwB_PqlcOchrPFTQ3yoCXRBqV_GnB5R2u-1-k,243
|
|
7
|
+
shipit/utils.py,sha256=XaiuaT_5mnzlXD9i1PAkaVc162y5Y_wj_oo1z2gUQBI,248
|
|
8
|
+
shipit/version.py,sha256=QJqEGC_YsFig0b6PsnwwJQh_zE-YL49JPlItpKrgL-U,97
|
|
9
|
+
shipit/assets/php/php.ini,sha256=SaR3wvssSROtxTY_CQ5-BspM_47_I971V5X2dsqe8sU,2579
|
|
10
|
+
shipit/assets/wordpress/install.sh,sha256=8sNe4w9F9y97JR-w5Q0ZHVgZvNm_vnd1CacY5fQjewI,3087
|
|
11
|
+
shipit/assets/wordpress/wp-config.php,sha256=q7KHB_TyLrodXzbg8EEPm42XWDIevtwL6wk3L0kbVrs,4809
|
|
12
|
+
shipit/builders/__init__.py,sha256=n1g3bZ_VaXVQIhwTlJnRWzDMCymVUjolykopnypyyyE,193
|
|
13
|
+
shipit/builders/base.py,sha256=mP8WdPs53oLiTQkYT1r7xpyNW5D_2gcTUFwOPkpPsHc,477
|
|
14
|
+
shipit/builders/docker.py,sha256=wnCJdOK-PR7TV3QpHTapDkOYx3G4P47YJeLihgifJ88,9613
|
|
15
|
+
shipit/builders/local.py,sha256=xWN-YevtXp63igycJU-lnIkZQHhhrX176RX6kFNfxKE,6014
|
|
16
|
+
shipit/providers/base.py,sha256=qKEarV37t7Zi2T8Mg0utjvVJN4gkiRCkOPG4w4NqFo4,4163
|
|
17
|
+
shipit/providers/hugo.py,sha256=OIjfRMY6BbEM5uhtVlHlMDZH0uxbrtEEIoMMqDZlX5U,3515
|
|
18
|
+
shipit/providers/jekyll.py,sha256=6XjTIklYfK_iez90j7YL1UDCreReGAaT3zH8fSYMguI,3968
|
|
19
|
+
shipit/providers/laravel.py,sha256=UjfG-CDLihxuWkvZ6Q8KfXOi1Fx71Vcy1NfdjW1Nwgo,3412
|
|
20
|
+
shipit/providers/mkdocs.py,sha256=PDg8gV8OVmlU89B8Fa2AfEgdC9c0x3JkpMUPFaBd0Ts,2662
|
|
21
|
+
shipit/providers/node_static.py,sha256=XCmWIV7OtKE0vg4lIba0Y3IvHuNMaFmJ4OCj3fev5kY,15463
|
|
22
|
+
shipit/providers/php.py,sha256=YL9bFVlTkQ3HgSQ7Vi9YJlkEWXl1M4dbeBMXP2G-EHc,4483
|
|
23
|
+
shipit/providers/python.py,sha256=gj4tfL4ewAU4mhzOrpcdVYx19JNFNBx3pRYE0IixTPM,22754
|
|
24
|
+
shipit/providers/registry.py,sha256=MSaKc3Eqs1vM04njGUyTtOeL8ffmmWyB3kSpvirqHfg,693
|
|
25
|
+
shipit/providers/staticfile.py,sha256=hpZVFBATiIUOD0miSE1aHtJurqCaPusRuj5MdJV2JU8,3447
|
|
26
|
+
shipit/providers/wordpress.py,sha256=e4GmelnW04F2_tChATnophAnQbchNOCKw0xaCm3bF30,3235
|
|
27
|
+
shipit/runners/__init__.py,sha256=s1kICs9W8Z5buF0dalgNNx2AzGAsiTw8OzCIgYiN_ps,157
|
|
28
|
+
shipit/runners/base.py,sha256=edXGW_4lngQS_Q110yy_6UnyOSKLbxxJm5vDIu8ge7Y,582
|
|
29
|
+
shipit/runners/local.py,sha256=OFWyI_IO_7q_QZrbEnXFRUVbNCwNYuxZTdA1PI2Icp4,4138
|
|
30
|
+
shipit/runners/wasmer.py,sha256=d2oL7x74yU6_q1cMYuu3M19XyGzDKnJZHirf1SBuF_k,17202
|
|
31
|
+
shipit_cli-0.15.0.dist-info/METADATA,sha256=RJ0Om2Z_PBlwYa7O6jG4F2aIFaEQK2xXPAs6NQ9hPkk,3773
|
|
32
|
+
shipit_cli-0.15.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
33
|
+
shipit_cli-0.15.0.dist-info/entry_points.txt,sha256=7AE1NjSrHaSDfbfsRRO50KKnHFTbB0Imsccd1WynzAQ,72
|
|
34
|
+
shipit_cli-0.15.0.dist-info/RECORD,,
|