shipit-cli 0.7.0__py3-none-any.whl → 0.7.1__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
@@ -36,6 +36,7 @@ from shipit.version import version as shipit_version
36
36
  from shipit.generator import generate_shipit
37
37
  from shipit.providers.base import CustomCommands
38
38
  from shipit.procfile import Procfile
39
+ from dotenv import dotenv_values
39
40
 
40
41
 
41
42
  console = Console()
@@ -877,10 +878,10 @@ class WasmerBuilder:
877
878
  )
878
879
 
879
880
  def build_serve(self, serve: Serve) -> None:
880
- from tomlkit import comment, document, nl, table, aot, string
881
+ from tomlkit import comment, document, nl, table, aot, string, array
881
882
 
882
883
  doc = document()
883
- doc.add(comment(f"File generated by Shipit {shipit_version}"))
884
+ doc.add(comment(f"Wasmer manifest generated with Shipit v{shipit_version}"))
884
885
  package = table()
885
886
  doc.add("package", package)
886
887
  package.add("entrypoint", "start")
@@ -953,14 +954,14 @@ class WasmerBuilder:
953
954
  wasi_args = table()
954
955
  if serve.cwd:
955
956
  wasi_args.add("cwd", serve.cwd)
956
- wasi_args.add("main-args", parts[1:])
957
+ wasi_args.add("main-args", array(parts[1:]).multiline(True))
957
958
  env = program_binary.get("env") or {}
958
959
  if serve.env:
959
960
  env.update(serve.env)
960
961
  if env:
962
+ arr = array([f"{k}={v}" for k, v in env.items()]).multiline(True)
961
963
  wasi_args.add(
962
- "env",
963
- [f"{k}={v}" for k, v in env.items()],
964
+ "env", arr
964
965
  )
965
966
  title = string("annotations.wasi", literal=False)
966
967
  command.add(title, wasi_args)
@@ -1038,7 +1039,7 @@ class WasmerBuilder:
1038
1039
  )
1039
1040
  yaml_config["jobs"] = jobs
1040
1041
 
1041
- app_yaml = yaml.dump(yaml_config)
1042
+ app_yaml = yaml.dump(yaml_config,)
1042
1043
 
1043
1044
  console.print(f"\n[bold]Created app.yaml manifest ✅[/bold]")
1044
1045
  app_yaml_panel = Panel(
@@ -1385,6 +1386,10 @@ def auto(
1385
1386
  None,
1386
1387
  help="The start command to use (overwrites the default)",
1387
1388
  ),
1389
+ env_name: Optional[str] = typer.Option(
1390
+ None,
1391
+ help="The environment to use (defaults to `.env`, it will use .env.<env_name> if provided)",
1392
+ ),
1388
1393
  ):
1389
1394
  if not path.exists():
1390
1395
  raise Exception(f"The path {path} does not exist")
@@ -1408,6 +1413,7 @@ def auto(
1408
1413
  wasmer_token=wasmer_token,
1409
1414
  wasmer_bin=wasmer_bin,
1410
1415
  skip_prepare=skip_prepare,
1416
+ env_name=env_name,
1411
1417
  )
1412
1418
  if start or wasmer_deploy:
1413
1419
  serve(
@@ -1612,6 +1618,10 @@ def build(
1612
1618
  None,
1613
1619
  help="Use a specific Docker client (such as depot, podman, etc.)",
1614
1620
  ),
1621
+ env_name: Optional[str] = typer.Option(
1622
+ None,
1623
+ help="The environment to use (defaults to `.env`, it will use .env.<env_name> if provided)",
1624
+ ),
1615
1625
  ) -> None:
1616
1626
  if not path.exists():
1617
1627
  raise Exception(f"The path {path} does not exist")
@@ -1664,6 +1674,14 @@ def build(
1664
1674
  "CLICOLOR": os.environ.get("CLICOLOR", "0"),
1665
1675
  }
1666
1676
  serve = next(iter(ctx.serves.values()))
1677
+ serve.env = serve.env or {}
1678
+ if (path / ".env").exists():
1679
+ env_vars = dotenv_values(path / ".env")
1680
+ serve.env.update(env_vars)
1681
+
1682
+ if (path / f".env.{env_name}").exists():
1683
+ env_vars = dotenv_values(path / f".env.{env_name}")
1684
+ serve.env.update(env_vars)
1667
1685
 
1668
1686
  # Build and serve
1669
1687
  builder.build(env, serve.mounts, serve.build)
@@ -1691,3 +1709,6 @@ def main() -> None:
1691
1709
 
1692
1710
  if __name__ == "__main__":
1693
1711
  main()
1712
+
1713
+ def flatten(xss):
1714
+ return [x for xs in xss for x in xs]
shipit/version.py CHANGED
@@ -1,5 +1,5 @@
1
1
  __all__ = ["version", "version_info"]
2
2
 
3
3
 
4
- version = "0.7.0"
5
- version_info = (0, 7, 0, "final", 0)
4
+ version = "0.7.1"
5
+ version_info = (0, 7, 1, "final", 0)
@@ -1,11 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shipit-cli
3
- Version: 0.7.0
3
+ Version: 0.7.1
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
7
7
  Project-URL: Changelog, https://github.com/wasmerio/shipit/changelog
8
8
  Requires-Python: >=3.10
9
+ Requires-Dist: dotenv>=0.9.9
9
10
  Requires-Dist: pyyaml>=6.0.2
10
11
  Requires-Dist: requests>=2.32.5
11
12
  Requires-Dist: rich>=14.1.0
@@ -1,9 +1,8 @@
1
1
  shipit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- shipit/cli.py,sha256=cLWFBrY24w--GQj_YtRo7U7jnGITEG_TWo4D9W6XH1Q,57549
3
- shipit/env.py,sha256=Bede00-iFI67RZ0bx92JyX49XL7Q91HK-QoKRpwPaGQ,725
2
+ shipit/cli.py,sha256=1U65pviCsaH-fZO3hGYWoyO1WqXCfOxnGwPIomwc5Fg,58363
4
3
  shipit/generator.py,sha256=GFsuqZG83gn7yxphE4GHwZjEB3sToJn24yNDE-zrTtM,6400
5
4
  shipit/procfile.py,sha256=GlfdwzFUr0GWGKaaiXlLKNFInWaRNMy_wN14UEyU_5Q,2974
6
- shipit/version.py,sha256=myhj6JcZUHlBRvAyfRYaJ_bv3PrzoXvUd5ppXAZh014,95
5
+ shipit/version.py,sha256=-1rPwQ4VEhKG8LAXODaAwzxwpFY9hDgohd2s_aRySc4,95
7
6
  shipit/assets/php/php.ini,sha256=f4irndAjB4GuuouEImRkNV22Q-yw1KqR-43jAMDw730,2531
8
7
  shipit/assets/wordpress/install.sh,sha256=GOIwJX3qPp7VuZXjkKVFFY6Mo9k7VFWfobS6aZYitPg,817
9
8
  shipit/assets/wordpress/wp-config.php,sha256=IdGQoeg8E89JiqwxO2i8WnGMzmhNWgRz80X6lbU5GXc,4134
@@ -18,7 +17,7 @@ shipit/providers/python.py,sha256=n0748miZ5RpQyQUCmkq3_G2Nnub8SaogZoJTNNFalZc,20
18
17
  shipit/providers/registry.py,sha256=lHUViVuPJf1OIZD8I_NTX4LP7E3Uo5-MmLfarmAA_cM,729
19
18
  shipit/providers/staticfile.py,sha256=O1D0cXa_cFZH4OXRFLjBG3e-LbjMDo7ZBC2D3CvrPo4,2218
20
19
  shipit/providers/wordpress.py,sha256=wMIcBpICqcEpbOgJCufrnM-r76AVI7_xC-NUlh9XMmE,3016
21
- shipit_cli-0.7.0.dist-info/METADATA,sha256=Ang6CnPqUUcKRovpIAMHMsnccw640bQUYlpPOZ3MNoA,494
22
- shipit_cli-0.7.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
23
- shipit_cli-0.7.0.dist-info/entry_points.txt,sha256=7AE1NjSrHaSDfbfsRRO50KKnHFTbB0Imsccd1WynzAQ,72
24
- shipit_cli-0.7.0.dist-info/RECORD,,
20
+ shipit_cli-0.7.1.dist-info/METADATA,sha256=uW1Lt7b6mOl7H5k3CPpaPPWNNr-0DHY6p5dxE4Z9B6g,523
21
+ shipit_cli-0.7.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
22
+ shipit_cli-0.7.1.dist-info/entry_points.txt,sha256=7AE1NjSrHaSDfbfsRRO50KKnHFTbB0Imsccd1WynzAQ,72
23
+ shipit_cli-0.7.1.dist-info/RECORD,,
shipit/env.py DELETED
@@ -1,30 +0,0 @@
1
- import shlex
2
- import re
3
-
4
- def parse(content):
5
- """
6
- Parse the content of a .env file (a line-delimited KEY=value format) into a
7
- dictionary mapping keys to values.
8
- """
9
- values = {}
10
- for line in content.splitlines():
11
- lexer = shlex.shlex(line, posix=True)
12
- tokens = list(lexer)
13
-
14
- # parses the assignment statement
15
- if len(tokens) < 3:
16
- continue
17
-
18
- name, op = tokens[:2]
19
- value = ''.join(tokens[2:])
20
-
21
- if op != '=':
22
- continue
23
- if not re.match(r'[A-Za-z_][A-Za-z_0-9]*', name):
24
- continue
25
-
26
- value = value.replace(r'\n', '\n')
27
- value = value.replace(r'\t', '\t')
28
- values[name] = value
29
-
30
- return values