shipit-cli 0.2.0__py3-none-any.whl → 0.2.2__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/cli.py +75 -20
- shipit/version.py +2 -2
- {shipit_cli-0.2.0.dist-info → shipit_cli-0.2.2.dist-info}/METADATA +1 -1
- {shipit_cli-0.2.0.dist-info → shipit_cli-0.2.2.dist-info}/RECORD +6 -6
- {shipit_cli-0.2.0.dist-info → shipit_cli-0.2.2.dist-info}/WHEEL +0 -0
- {shipit_cli-0.2.0.dist-info → shipit_cli-0.2.2.dist-info}/entry_points.txt +0 -0
shipit/cli.py
CHANGED
|
@@ -40,6 +40,7 @@ app = typer.Typer(invoke_without_command=True)
|
|
|
40
40
|
DIR_PATH = Path(__file__).resolve().parent
|
|
41
41
|
ASSETS_PATH = DIR_PATH / "assets"
|
|
42
42
|
|
|
43
|
+
|
|
43
44
|
@dataclass
|
|
44
45
|
class Mount:
|
|
45
46
|
name: str
|
|
@@ -134,7 +135,9 @@ class MapperItem(TypedDict):
|
|
|
134
135
|
|
|
135
136
|
|
|
136
137
|
class Builder(Protocol):
|
|
137
|
-
def build(
|
|
138
|
+
def build(
|
|
139
|
+
self, env: Dict[str, str], mounts: List[Mount], steps: List[Step]
|
|
140
|
+
) -> None: ...
|
|
138
141
|
def build_assets(self, assets: Dict[str, str]) -> None: ...
|
|
139
142
|
def build_prepare(self, serve: Serve) -> None: ...
|
|
140
143
|
def build_serve(self, serve: Serve) -> None: ...
|
|
@@ -310,7 +313,9 @@ RUN chmod {oct(mode)[2:]} {path.absolute()}
|
|
|
310
313
|
else:
|
|
311
314
|
self.docker_file_contents += f"RUN pkgm install {dependency.name}\n"
|
|
312
315
|
|
|
313
|
-
def build(
|
|
316
|
+
def build(
|
|
317
|
+
self, env: Dict[str, str], mounts: List[Mount], steps: List[Step]
|
|
318
|
+
) -> None:
|
|
314
319
|
base_path = self.docker_path
|
|
315
320
|
shutil.rmtree(base_path, ignore_errors=True)
|
|
316
321
|
base_path.mkdir(parents=True, exist_ok=True)
|
|
@@ -325,10 +330,10 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
|
|
325
330
|
RUN curl https://pkgx.sh | sh
|
|
326
331
|
"""
|
|
327
332
|
# docker_file_contents += "RUN curl https://mise.run | sh\n"
|
|
328
|
-
# self.docker_file_contents += """
|
|
329
|
-
# RUN curl https://get.wasmer.io -sSfL | sh -s "v6.1.0-rc.3"
|
|
330
|
-
# ENV PATH="/root/.wasmer/bin:${PATH}"
|
|
331
|
-
# """
|
|
333
|
+
# self.docker_file_contents += """
|
|
334
|
+
# RUN curl https://get.wasmer.io -sSfL | sh -s "v6.1.0-rc.3"
|
|
335
|
+
# ENV PATH="/root/.wasmer/bin:${PATH}"
|
|
336
|
+
# """
|
|
332
337
|
for mount in mounts:
|
|
333
338
|
self.docker_file_contents += f"RUN mkdir -p {mount.build_path.absolute()}\n"
|
|
334
339
|
|
|
@@ -363,7 +368,9 @@ RUN curl https://pkgx.sh | sh
|
|
|
363
368
|
FROM scratch
|
|
364
369
|
"""
|
|
365
370
|
for mount in mounts:
|
|
366
|
-
self.docker_file_contents +=
|
|
371
|
+
self.docker_file_contents += (
|
|
372
|
+
f"COPY --from=build {mount.build_path} {mount.build_path}\n"
|
|
373
|
+
)
|
|
367
374
|
|
|
368
375
|
self.docker_ignore_path.write_text("""
|
|
369
376
|
.shipit
|
|
@@ -507,7 +514,9 @@ class LocalBuilder:
|
|
|
507
514
|
else:
|
|
508
515
|
raise Exception(f"Unknown step type: {type(step)}")
|
|
509
516
|
|
|
510
|
-
def build(
|
|
517
|
+
def build(
|
|
518
|
+
self, env: Dict[str, str], mounts: List[Mount], steps: List[Step]
|
|
519
|
+
) -> None:
|
|
511
520
|
console.print(f"\n[bold]Building package[/bold]")
|
|
512
521
|
base_path = self.local_path
|
|
513
522
|
shutil.rmtree(base_path, ignore_errors=True)
|
|
@@ -700,7 +709,9 @@ class WasmerBuilder:
|
|
|
700
709
|
def getenv(self, name: str) -> Optional[str]:
|
|
701
710
|
return self.inner_builder.getenv(name) or self.default_env.get(name)
|
|
702
711
|
|
|
703
|
-
def build(
|
|
712
|
+
def build(
|
|
713
|
+
self, env: Dict[str, str], mounts: List[Mount], build: List[Step]
|
|
714
|
+
) -> None:
|
|
704
715
|
return self.inner_builder.build(env, mounts, build)
|
|
705
716
|
|
|
706
717
|
def build_assets(self, assets: Dict[str, str]) -> None:
|
|
@@ -711,7 +722,7 @@ class WasmerBuilder:
|
|
|
711
722
|
|
|
712
723
|
def build_prepare(self, serve: Serve) -> None:
|
|
713
724
|
print("Building prepare")
|
|
714
|
-
prepare_dir =
|
|
725
|
+
prepare_dir = self.wasmer_dir_path / "prepare"
|
|
715
726
|
prepare_dir.mkdir(parents=True, exist_ok=True)
|
|
716
727
|
env = serve.env or {}
|
|
717
728
|
for dep in serve.deps:
|
|
@@ -741,7 +752,7 @@ class WasmerBuilder:
|
|
|
741
752
|
inner.finalize_build(serve)
|
|
742
753
|
|
|
743
754
|
def prepare(self, env: Dict[str, str], prepare: List[PrepareStep]) -> None:
|
|
744
|
-
prepare_dir =
|
|
755
|
+
prepare_dir = self.wasmer_dir_path / "prepare"
|
|
745
756
|
self.run_serve_command(
|
|
746
757
|
"bash",
|
|
747
758
|
extra_args=[
|
|
@@ -808,7 +819,10 @@ class WasmerBuilder:
|
|
|
808
819
|
# fs.add("/app", str(inner.get_build_path().absolute()))
|
|
809
820
|
if serve.mounts:
|
|
810
821
|
for mount in serve.mounts:
|
|
811
|
-
fs.add(
|
|
822
|
+
fs.add(
|
|
823
|
+
str(mount.serve_path.absolute()),
|
|
824
|
+
str(self.inner_builder.get_serve_mount_path(mount.name).absolute()),
|
|
825
|
+
)
|
|
812
826
|
|
|
813
827
|
doc.add(nl())
|
|
814
828
|
if serve.commands:
|
|
@@ -895,7 +909,13 @@ class WasmerBuilder:
|
|
|
895
909
|
extra_args = [f"--registry={self.wasmer_registry}"] + extra_args
|
|
896
910
|
self.run_command(
|
|
897
911
|
self.bin,
|
|
898
|
-
[
|
|
912
|
+
[
|
|
913
|
+
"run",
|
|
914
|
+
str(self.wasmer_dir_path.absolute()),
|
|
915
|
+
"--net",
|
|
916
|
+
f"--command={command}",
|
|
917
|
+
*extra_args,
|
|
918
|
+
],
|
|
899
919
|
)
|
|
900
920
|
|
|
901
921
|
def serve_mount(self, name: str) -> str:
|
|
@@ -907,7 +927,9 @@ class WasmerBuilder:
|
|
|
907
927
|
def run_command(
|
|
908
928
|
self, command: str, extra_args: Optional[List[str]] | None = None
|
|
909
929
|
) -> Any:
|
|
910
|
-
sh.Command(command)(
|
|
930
|
+
sh.Command(command)(
|
|
931
|
+
*(extra_args or []), _out=write_stdout, _err=write_stderr, _env=os.environ
|
|
932
|
+
)
|
|
911
933
|
|
|
912
934
|
def deploy(
|
|
913
935
|
self, app_owner: Optional[str] = None, app_name: Optional[str] = None
|
|
@@ -1034,7 +1056,9 @@ class Ctx:
|
|
|
1034
1056
|
commands=commands,
|
|
1035
1057
|
prepare=prepare_steps,
|
|
1036
1058
|
workers=workers,
|
|
1037
|
-
mounts=self.get_refs([mount["ref"] for mount in mounts])
|
|
1059
|
+
mounts=self.get_refs([mount["ref"] for mount in mounts])
|
|
1060
|
+
if mounts
|
|
1061
|
+
else None,
|
|
1038
1062
|
env=env,
|
|
1039
1063
|
)
|
|
1040
1064
|
return self.add_serve(serve)
|
|
@@ -1121,6 +1145,10 @@ def auto(
|
|
|
1121
1145
|
None,
|
|
1122
1146
|
help="Use a specific Docker client (such as depot, podman, etc.)",
|
|
1123
1147
|
),
|
|
1148
|
+
skip_prepare: bool = typer.Option(
|
|
1149
|
+
False,
|
|
1150
|
+
help="Run the prepare command after building (defaults to True).",
|
|
1151
|
+
),
|
|
1124
1152
|
start: bool = typer.Option(
|
|
1125
1153
|
False,
|
|
1126
1154
|
help="Run the start command after building.",
|
|
@@ -1154,10 +1182,22 @@ def auto(
|
|
|
1154
1182
|
help="Name of the Wasmer app.",
|
|
1155
1183
|
),
|
|
1156
1184
|
):
|
|
1185
|
+
if not path.exists():
|
|
1186
|
+
raise Exception(f"The path {path} does not exist")
|
|
1187
|
+
|
|
1157
1188
|
if not (path / "Shipit").exists() or regenerate or regenerate_path is not None:
|
|
1158
1189
|
generate(path, out=regenerate_path)
|
|
1159
1190
|
|
|
1160
|
-
build(
|
|
1191
|
+
build(
|
|
1192
|
+
path,
|
|
1193
|
+
wasmer=(wasmer or wasmer_deploy),
|
|
1194
|
+
docker=docker,
|
|
1195
|
+
docker_client=docker_client,
|
|
1196
|
+
wasmer_registry=wasmer_registry,
|
|
1197
|
+
wasmer_token=wasmer_token,
|
|
1198
|
+
wasmer_bin=wasmer_bin,
|
|
1199
|
+
skip_prepare=skip_prepare,
|
|
1200
|
+
)
|
|
1161
1201
|
if start or wasmer_deploy:
|
|
1162
1202
|
serve(
|
|
1163
1203
|
path,
|
|
@@ -1187,6 +1227,9 @@ def generate(
|
|
|
1187
1227
|
help="Output path (defaults to the Shipit file in the provided path).",
|
|
1188
1228
|
),
|
|
1189
1229
|
):
|
|
1230
|
+
if not path.exists():
|
|
1231
|
+
raise Exception(f"The path {path} does not exist")
|
|
1232
|
+
|
|
1190
1233
|
if out is None:
|
|
1191
1234
|
out = path / "Shipit"
|
|
1192
1235
|
content = generate_shipit(path)
|
|
@@ -1261,6 +1304,9 @@ def serve(
|
|
|
1261
1304
|
help="Name of the Wasmer app.",
|
|
1262
1305
|
),
|
|
1263
1306
|
) -> None:
|
|
1307
|
+
if not path.exists():
|
|
1308
|
+
raise Exception(f"The path {path} does not exist")
|
|
1309
|
+
|
|
1264
1310
|
builder: Builder
|
|
1265
1311
|
if docker or docker_client:
|
|
1266
1312
|
builder = DockerBuilder(path, docker_client)
|
|
@@ -1291,6 +1337,10 @@ def build(
|
|
|
1291
1337
|
False,
|
|
1292
1338
|
help="Use Wasmer to build and serve the project.",
|
|
1293
1339
|
),
|
|
1340
|
+
skip_prepare: bool = typer.Option(
|
|
1341
|
+
False,
|
|
1342
|
+
help="Run the prepare command after building (defaults to True).",
|
|
1343
|
+
),
|
|
1294
1344
|
wasmer_bin: Optional[Path] = typer.Option(
|
|
1295
1345
|
None,
|
|
1296
1346
|
help="The path to the Wasmer binary.",
|
|
@@ -1312,10 +1362,13 @@ def build(
|
|
|
1312
1362
|
help="Use a specific Docker client (such as depot, podman, etc.)",
|
|
1313
1363
|
),
|
|
1314
1364
|
) -> None:
|
|
1365
|
+
if not path.exists():
|
|
1366
|
+
raise Exception(f"The path {path} does not exist")
|
|
1367
|
+
|
|
1315
1368
|
ab_file = path / "Shipit"
|
|
1316
1369
|
if not ab_file.exists():
|
|
1317
1370
|
raise FileNotFoundError(
|
|
1318
|
-
f"Shipit file not found at {ab_file}.
|
|
1371
|
+
f"Shipit file not found at {ab_file}. Run `shipit generate {path}` to create it."
|
|
1319
1372
|
)
|
|
1320
1373
|
source = open(ab_file).read()
|
|
1321
1374
|
builder: Builder
|
|
@@ -1324,7 +1377,9 @@ def build(
|
|
|
1324
1377
|
else:
|
|
1325
1378
|
builder = LocalBuilder(path)
|
|
1326
1379
|
if wasmer:
|
|
1327
|
-
builder = WasmerBuilder(
|
|
1380
|
+
builder = WasmerBuilder(
|
|
1381
|
+
builder, path, registry=wasmer_registry, token=wasmer_token, bin=wasmer_bin
|
|
1382
|
+
)
|
|
1328
1383
|
|
|
1329
1384
|
ctx = Ctx(builder)
|
|
1330
1385
|
glb = sl.Globals.standard()
|
|
@@ -1371,7 +1426,7 @@ def build(
|
|
|
1371
1426
|
builder.build_assets(serve.assets)
|
|
1372
1427
|
builder.build_serve(serve)
|
|
1373
1428
|
builder.finalize_build(serve)
|
|
1374
|
-
if serve.prepare:
|
|
1429
|
+
if serve.prepare and not skip_prepare:
|
|
1375
1430
|
builder.prepare(env, serve.prepare)
|
|
1376
1431
|
|
|
1377
1432
|
|
|
@@ -1386,7 +1441,7 @@ def main() -> None:
|
|
|
1386
1441
|
app()
|
|
1387
1442
|
except Exception as e:
|
|
1388
1443
|
console.print(f"[bold red]{type(e).__name__}[/bold red]: {e}")
|
|
1389
|
-
|
|
1444
|
+
raise e
|
|
1390
1445
|
|
|
1391
1446
|
|
|
1392
1447
|
if __name__ == "__main__":
|
shipit/version.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
shipit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
shipit/cli.py,sha256=
|
|
2
|
+
shipit/cli.py,sha256=669h6yIG1PDvC2amWQDG3qIYiDbVPYttKQbBn4nUaoM,48328
|
|
3
3
|
shipit/generator.py,sha256=iBkVcs44dd_xYKitM_zNVLnpiZ3KrV__xVswPMCZ97Y,5570
|
|
4
|
-
shipit/version.py,sha256=
|
|
4
|
+
shipit/version.py,sha256=gaVNYQn_PHvqIqhz8HHQn0u9y3P_7Etl2g48HwhMqpc,95
|
|
5
5
|
shipit/assets/php/php.ini,sha256=f4irndAjB4GuuouEImRkNV22Q-yw1KqR-43jAMDw730,2531
|
|
6
6
|
shipit/providers/base.py,sha256=bqh1k7TSPJo7hOnxgdI6PIJmrqzQkZhgUoV0bbYIWrw,2403
|
|
7
7
|
shipit/providers/gatsby.py,sha256=VUGhE7xtQJHsYzEzdkXi3n5mbpgg868wbUVOU4MWN5s,2173
|
|
@@ -13,7 +13,7 @@ shipit/providers/php.py,sha256=HxxgfXmA0U6PeTLyFMbyXWm05G_IQqdFz4Liq1d_VBM,2635
|
|
|
13
13
|
shipit/providers/python.py,sha256=ep8qflY_9J-F_zei4Lt0zeDWFEHUf-lOr4F-LBgYPiE,4870
|
|
14
14
|
shipit/providers/registry.py,sha256=V6CAOK5gEX0RhWhr-lcAkvlwRuMom7YY2ZeAyRy1Eck,672
|
|
15
15
|
shipit/providers/staticfile.py,sha256=9Ksi9WO_52Dnj_hqNn_cYVjTniJ3tBjVr5kBvgCPF-0,1908
|
|
16
|
-
shipit_cli-0.2.
|
|
17
|
-
shipit_cli-0.2.
|
|
18
|
-
shipit_cli-0.2.
|
|
19
|
-
shipit_cli-0.2.
|
|
16
|
+
shipit_cli-0.2.2.dist-info/METADATA,sha256=NX5U-DnP5Y8nuanj9qC2fVVNrY_-UGDcSAyOu_5rgwc,462
|
|
17
|
+
shipit_cli-0.2.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
18
|
+
shipit_cli-0.2.2.dist-info/entry_points.txt,sha256=7AE1NjSrHaSDfbfsRRO50KKnHFTbB0Imsccd1WynzAQ,72
|
|
19
|
+
shipit_cli-0.2.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|