shipit-cli 0.2.1__py3-none-any.whl → 0.2.3__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 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(self, env: Dict[str, str], mounts: List[Mount], steps: List[Step]) -> None: ...
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(self, env: Dict[str, str], mounts: List[Mount], steps: List[Step]) -> None:
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 += f"COPY --from=build {mount.build_path} {mount.build_path}\n"
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(self, env: Dict[str, str], mounts: List[Mount], steps: List[Step]) -> None:
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)
@@ -687,7 +696,7 @@ class WasmerBuilder:
687
696
  self.src_dir = src_dir
688
697
  self.inner_builder = inner_builder
689
698
  # The path where we store the directory of the wasmer app in the inner builder
690
- self.wasmer_dir_path = Path(self.src_dir / ".shipit" / "wasmer")
699
+ self.wasmer_dir_path = self.src_dir / ".shipit" / "wasmer"
691
700
  self.wasmer_registry = registry
692
701
  self.wasmer_token = token
693
702
  self.bin = bin.absolute() if bin else "wasmer"
@@ -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(self, env: Dict[str, str], mounts: List[Mount], build: List[Step]) -> None:
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 = (self.wasmer_dir_path / "prepare")
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 = (self.wasmer_dir_path / "prepare")
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(str(mount.serve_path.absolute()), str(self.inner_builder.get_serve_mount_path(mount.name).absolute()))
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:
@@ -881,10 +895,6 @@ class WasmerBuilder:
881
895
 
882
896
  # self.inner_builder.build_serve(serve)
883
897
 
884
- @property
885
- def wasmer_path(self) -> Path:
886
- return self.wasmer_dir_path.read_text()
887
-
888
898
  def run_serve_command(
889
899
  self, command: str, extra_args: Optional[List[str]] = None
890
900
  ) -> None:
@@ -895,7 +905,13 @@ class WasmerBuilder:
895
905
  extra_args = [f"--registry={self.wasmer_registry}"] + extra_args
896
906
  self.run_command(
897
907
  self.bin,
898
- ["run", str(self.wasmer_dir_path.absolute()), "--net", f"--command={command}", *extra_args],
908
+ [
909
+ "run",
910
+ str(self.wasmer_dir_path.absolute()),
911
+ "--net",
912
+ f"--command={command}",
913
+ *extra_args,
914
+ ],
899
915
  )
900
916
 
901
917
  def serve_mount(self, name: str) -> str:
@@ -907,7 +923,9 @@ class WasmerBuilder:
907
923
  def run_command(
908
924
  self, command: str, extra_args: Optional[List[str]] | None = None
909
925
  ) -> Any:
910
- sh.Command(command)(*(extra_args or []), _out=write_stdout, _err=write_stderr, _env=os.environ)
926
+ sh.Command(command)(
927
+ *(extra_args or []), _out=write_stdout, _err=write_stderr, _env=os.environ
928
+ )
911
929
 
912
930
  def deploy(
913
931
  self, app_owner: Optional[str] = None, app_name: Optional[str] = None
@@ -924,7 +942,7 @@ class WasmerBuilder:
924
942
  [
925
943
  "package",
926
944
  "push",
927
- self.wasmer_path,
945
+ self.wasmer_dir_path,
928
946
  "--namespace",
929
947
  app_owner,
930
948
  "--non-interactive",
@@ -937,7 +955,7 @@ class WasmerBuilder:
937
955
  "deploy",
938
956
  "--publish-package",
939
957
  "--dir",
940
- self.wasmer_path,
958
+ self.wasmer_dir_path,
941
959
  "--app-name",
942
960
  app_name,
943
961
  "--owner",
@@ -1034,7 +1052,9 @@ class Ctx:
1034
1052
  commands=commands,
1035
1053
  prepare=prepare_steps,
1036
1054
  workers=workers,
1037
- mounts=self.get_refs([mount["ref"] for mount in mounts]) if mounts else None,
1055
+ mounts=self.get_refs([mount["ref"] for mount in mounts])
1056
+ if mounts
1057
+ else None,
1038
1058
  env=env,
1039
1059
  )
1040
1060
  return self.add_serve(serve)
@@ -1121,6 +1141,10 @@ def auto(
1121
1141
  None,
1122
1142
  help="Use a specific Docker client (such as depot, podman, etc.)",
1123
1143
  ),
1144
+ skip_prepare: bool = typer.Option(
1145
+ False,
1146
+ help="Run the prepare command after building (defaults to True).",
1147
+ ),
1124
1148
  start: bool = typer.Option(
1125
1149
  False,
1126
1150
  help="Run the start command after building.",
@@ -1154,10 +1178,22 @@ def auto(
1154
1178
  help="Name of the Wasmer app.",
1155
1179
  ),
1156
1180
  ):
1181
+ if not path.exists():
1182
+ raise Exception(f"The path {path} does not exist")
1183
+
1157
1184
  if not (path / "Shipit").exists() or regenerate or regenerate_path is not None:
1158
1185
  generate(path, out=regenerate_path)
1159
1186
 
1160
- build(path, wasmer=(wasmer or wasmer_deploy), docker=docker, docker_client=docker_client, wasmer_registry=wasmer_registry, wasmer_token=wasmer_token, wasmer_bin=wasmer_bin)
1187
+ build(
1188
+ path,
1189
+ wasmer=(wasmer or wasmer_deploy),
1190
+ docker=docker,
1191
+ docker_client=docker_client,
1192
+ wasmer_registry=wasmer_registry,
1193
+ wasmer_token=wasmer_token,
1194
+ wasmer_bin=wasmer_bin,
1195
+ skip_prepare=skip_prepare,
1196
+ )
1161
1197
  if start or wasmer_deploy:
1162
1198
  serve(
1163
1199
  path,
@@ -1187,6 +1223,9 @@ def generate(
1187
1223
  help="Output path (defaults to the Shipit file in the provided path).",
1188
1224
  ),
1189
1225
  ):
1226
+ if not path.exists():
1227
+ raise Exception(f"The path {path} does not exist")
1228
+
1190
1229
  if out is None:
1191
1230
  out = path / "Shipit"
1192
1231
  content = generate_shipit(path)
@@ -1261,6 +1300,9 @@ def serve(
1261
1300
  help="Name of the Wasmer app.",
1262
1301
  ),
1263
1302
  ) -> None:
1303
+ if not path.exists():
1304
+ raise Exception(f"The path {path} does not exist")
1305
+
1264
1306
  builder: Builder
1265
1307
  if docker or docker_client:
1266
1308
  builder = DockerBuilder(path, docker_client)
@@ -1291,6 +1333,10 @@ def build(
1291
1333
  False,
1292
1334
  help="Use Wasmer to build and serve the project.",
1293
1335
  ),
1336
+ skip_prepare: bool = typer.Option(
1337
+ False,
1338
+ help="Run the prepare command after building (defaults to True).",
1339
+ ),
1294
1340
  wasmer_bin: Optional[Path] = typer.Option(
1295
1341
  None,
1296
1342
  help="The path to the Wasmer binary.",
@@ -1312,10 +1358,13 @@ def build(
1312
1358
  help="Use a specific Docker client (such as depot, podman, etc.)",
1313
1359
  ),
1314
1360
  ) -> None:
1361
+ if not path.exists():
1362
+ raise Exception(f"The path {path} does not exist")
1363
+
1315
1364
  ab_file = path / "Shipit"
1316
1365
  if not ab_file.exists():
1317
1366
  raise FileNotFoundError(
1318
- f"Shipit file not found at {ab_file}. Please run `shipit generate {path}` to create it."
1367
+ f"Shipit file not found at {ab_file}. Run `shipit generate {path}` to create it."
1319
1368
  )
1320
1369
  source = open(ab_file).read()
1321
1370
  builder: Builder
@@ -1324,7 +1373,9 @@ def build(
1324
1373
  else:
1325
1374
  builder = LocalBuilder(path)
1326
1375
  if wasmer:
1327
- builder = WasmerBuilder(builder, path, registry=wasmer_registry, token=wasmer_token, bin=wasmer_bin)
1376
+ builder = WasmerBuilder(
1377
+ builder, path, registry=wasmer_registry, token=wasmer_token, bin=wasmer_bin
1378
+ )
1328
1379
 
1329
1380
  ctx = Ctx(builder)
1330
1381
  glb = sl.Globals.standard()
@@ -1371,7 +1422,7 @@ def build(
1371
1422
  builder.build_assets(serve.assets)
1372
1423
  builder.build_serve(serve)
1373
1424
  builder.finalize_build(serve)
1374
- if serve.prepare:
1425
+ if serve.prepare and not skip_prepare:
1375
1426
  builder.prepare(env, serve.prepare)
1376
1427
 
1377
1428
 
@@ -1386,7 +1437,7 @@ def main() -> None:
1386
1437
  app()
1387
1438
  except Exception as e:
1388
1439
  console.print(f"[bold red]{type(e).__name__}[/bold red]: {e}")
1389
- # raise e
1440
+ raise e
1390
1441
 
1391
1442
 
1392
1443
  if __name__ == "__main__":
shipit/version.py CHANGED
@@ -1,5 +1,5 @@
1
1
  __all__ = ["version", "version_info"]
2
2
 
3
3
 
4
- version = "0.2.1"
5
- version_info = (0, 2, 1, "final", 0)
4
+ version = "0.2.3"
5
+ version_info = (0, 2, 3, "final", 0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shipit-cli
3
- Version: 0.2.1
3
+ Version: 0.2.3
4
4
  Summary: Add your description here
5
5
  Project-URL: homepage, https://wasmer.io
6
6
  Project-URL: repository, https://github.com/wasmerio/shipit
@@ -1,7 +1,7 @@
1
1
  shipit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- shipit/cli.py,sha256=jeL3NOkpInk0t5o7mkKMqwyE1X3Q-7rRnArJz8HWK4E,47263
2
+ shipit/cli.py,sha256=J6EsxHjDgUVwgftiZYqz6GtkV2C_UOSSnxRni1ByOtU,48232
3
3
  shipit/generator.py,sha256=iBkVcs44dd_xYKitM_zNVLnpiZ3KrV__xVswPMCZ97Y,5570
4
- shipit/version.py,sha256=iiC3XVOrqOpEsnDmqt5bwypq0_Awz7jUa80HHEAUGH8,95
4
+ shipit/version.py,sha256=PNN0ywrz5joL0Hg0VsSUv1Z4nLOEF_6DBNJIPdeEuHA,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.1.dist-info/METADATA,sha256=-JXEKtPvJ0b6A3vXOGh1PUNKQek4nSzn4lDGqRoFl8A,462
17
- shipit_cli-0.2.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
- shipit_cli-0.2.1.dist-info/entry_points.txt,sha256=7AE1NjSrHaSDfbfsRRO50KKnHFTbB0Imsccd1WynzAQ,72
19
- shipit_cli-0.2.1.dist-info/RECORD,,
16
+ shipit_cli-0.2.3.dist-info/METADATA,sha256=uPpUcVzeUp9ciSM-ctnVA6AfRdp0c3QpgGCSVGkTVKQ,462
17
+ shipit_cli-0.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
18
+ shipit_cli-0.2.3.dist-info/entry_points.txt,sha256=7AE1NjSrHaSDfbfsRRO50KKnHFTbB0Imsccd1WynzAQ,72
19
+ shipit_cli-0.2.3.dist-info/RECORD,,