From 9d4321646b857128b5b7198666dc979445610f09 Mon Sep 17 00:00:00 2001 From: Negar Abbasi Date: Wed, 25 Oct 2023 10:56:51 +1000 Subject: [PATCH 01/12] chore: update copier version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index daf2540d..b0b3d0a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ readme = "README.md" python = "^3.10" click = "^8.1.3" httpx = "^0.23.1" -copier = "^7.1.0" +copier = "^8.0.0" questionary = "^1.10.0" pyclip = "^0.7.0" shellingham = "^1.5.0.post1" From 38bfe7deee1a57cd458666775353167f8611ad44 Mon Sep 17 00:00:00 2001 From: Negar Abbasi Date: Mon, 30 Oct 2023 15:07:45 +1000 Subject: [PATCH 02/12] fix: fixing tests and syntax --- poetry.lock | 212 +++++++++++++----- pyproject.toml | 4 +- src/algokit/cli/init.py | 6 +- src/algokit/core/init.py | 1 - tests/init/test_init.py | 4 +- ..._init.test_init_ask_about_git.approved.txt | 2 +- ....test_init_input_template_url.approved.txt | 2 +- ...o_git_no_network_no_bootstrap.approved.txt | 2 +- ...n_required_yes_git_no_network.approved.txt | 2 +- ...ed_defaults_no_git_no_network.approved.txt | 2 +- ...t_init.test_init_project_name.approved.txt | 2 +- ...t_init_project_name_not_empty.approved.txt | 2 +- ...ject_name_reenter_folder_name.approved.txt | 2 +- ....test_init_template_selection.approved.txt | 2 +- ...test_init_use_existing_folder.approved.txt | 2 +- 15 files changed, 176 insertions(+), 71 deletions(-) diff --git a/poetry.lock b/poetry.lock index 661cd671..3d6ee993 100644 --- a/poetry.lock +++ b/poetry.lock @@ -175,6 +175,17 @@ files = [ [package.extras] test = ["pytest (>=6.0.1)", "pytest-md-report (>=0.3)"] +[[package]] +name = "annotated-types" +version = "0.6.0" +description = "Reusable constraint types to use with typing.Annotated" +optional = false +python-versions = ">=3.8" +files = [ + {file = "annotated_types-0.6.0-py3-none-any.whl", hash = "sha256:0641064de18ba7a25dee8f96403ebc39113d0cb953a01429249d5c7564666a43"}, + {file = "annotated_types-0.6.0.tar.gz", hash = "sha256:563339e807e53ffd9c267e99fc6d9ea23eb8443c08f112651963e24e22f84a5d"}, +] + [[package]] name = "anyio" version = "3.7.1" @@ -612,17 +623,18 @@ files = [ [[package]] name = "copier" -version = "7.2.0" +version = "8.3.0" description = "A library for rendering project templates." optional = false -python-versions = ">=3.7,<4.0" +python-versions = ">=3.8,<4.0" files = [ - {file = "copier-7.2.0-py3-none-any.whl", hash = "sha256:9f2546c085dd2ac0850467aa437f0c345d1ac056cade7358edffb642a3106052"}, - {file = "copier-7.2.0.tar.gz", hash = "sha256:b6b3933efc6325da184d3940dd57e9869641798cad95f52d5cc193c9b443b313"}, + {file = "copier-8.3.0-py3-none-any.whl", hash = "sha256:a708e9b7c0eb7363ee5935f7a96a63a6f39b6da1d36f1c931d1ebd7711bb2ecf"}, + {file = "copier-8.3.0.tar.gz", hash = "sha256:051149721c811bfa84023fca5c23827917ac5f42ab6c2696dcb522b17aee7cae"}, ] [package.dependencies] colorama = ">=0.4.3" +decorator = ">=5.1.1" dunamai = ">=1.7.0" funcy = ">=1.17" jinja2 = ">=3.1.1" @@ -630,7 +642,7 @@ jinja2-ansible-filters = ">=1.3.1" packaging = ">=23.0" pathspec = ">=0.9.0" plumbum = ">=1.6.9" -pydantic = ">=1.10.2" +pydantic = ">=2.0.3" pygments = ">=2.7.1" pyyaml = ">=5.3.1" pyyaml-include = ">=1.2" @@ -764,6 +776,17 @@ packageurl-python = ">=0.11" py-serializable = ">=0.11.1,<0.12.0" sortedcontainers = ">=2.4.0,<3.0.0" +[[package]] +name = "decorator" +version = "5.1.1" +description = "Decorators for Humans" +optional = false +python-versions = ">=3.5" +files = [ + {file = "decorator-5.1.1-py3-none-any.whl", hash = "sha256:b8c3f85900b9dc423225913c5aace94729fe1fa9763b38939a95226f02d37186"}, + {file = "decorator-5.1.1.tar.gz", hash = "sha256:637996211036b6385ef91435e4fae22989472f9d571faba8927ba8253acbc330"}, +] + [[package]] name = "defusedxml" version = "0.7.1" @@ -1969,55 +1992,140 @@ files = [ [[package]] name = "pydantic" -version = "1.10.12" -description = "Data validation and settings management using python type hints" +version = "2.4.2" +description = "Data validation using Python type hints" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pydantic-2.4.2-py3-none-any.whl", hash = "sha256:bc3ddf669d234f4220e6e1c4d96b061abe0998185a8d7855c0126782b7abc8c1"}, + {file = "pydantic-2.4.2.tar.gz", hash = "sha256:94f336138093a5d7f426aac732dcfe7ab4eb4da243c88f891d65deb4a2556ee7"}, +] + +[package.dependencies] +annotated-types = ">=0.4.0" +pydantic-core = "2.10.1" +typing-extensions = ">=4.6.1" + +[package.extras] +email = ["email-validator (>=2.0.0)"] + +[[package]] +name = "pydantic-core" +version = "2.10.1" +description = "" optional = false python-versions = ">=3.7" files = [ - {file = "pydantic-1.10.12-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:a1fcb59f2f355ec350073af41d927bf83a63b50e640f4dbaa01053a28b7a7718"}, - {file = "pydantic-1.10.12-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:b7ccf02d7eb340b216ec33e53a3a629856afe1c6e0ef91d84a4e6f2fb2ca70fe"}, - {file = "pydantic-1.10.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8fb2aa3ab3728d950bcc885a2e9eff6c8fc40bc0b7bb434e555c215491bcf48b"}, - {file = "pydantic-1.10.12-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:771735dc43cf8383959dc9b90aa281f0b6092321ca98677c5fb6125a6f56d58d"}, - {file = "pydantic-1.10.12-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:ca48477862372ac3770969b9d75f1bf66131d386dba79506c46d75e6b48c1e09"}, - {file = "pydantic-1.10.12-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:a5e7add47a5b5a40c49b3036d464e3c7802f8ae0d1e66035ea16aa5b7a3923ed"}, - {file = "pydantic-1.10.12-cp310-cp310-win_amd64.whl", hash = "sha256:e4129b528c6baa99a429f97ce733fff478ec955513630e61b49804b6cf9b224a"}, - {file = "pydantic-1.10.12-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b0d191db0f92dfcb1dec210ca244fdae5cbe918c6050b342d619c09d31eea0cc"}, - {file = "pydantic-1.10.12-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:795e34e6cc065f8f498c89b894a3c6da294a936ee71e644e4bd44de048af1405"}, - {file = "pydantic-1.10.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:69328e15cfda2c392da4e713443c7dbffa1505bc9d566e71e55abe14c97ddc62"}, - {file = "pydantic-1.10.12-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2031de0967c279df0d8a1c72b4ffc411ecd06bac607a212892757db7462fc494"}, - {file = "pydantic-1.10.12-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:ba5b2e6fe6ca2b7e013398bc7d7b170e21cce322d266ffcd57cca313e54fb246"}, - {file = "pydantic-1.10.12-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:2a7bac939fa326db1ab741c9d7f44c565a1d1e80908b3797f7f81a4f86bc8d33"}, - {file = "pydantic-1.10.12-cp311-cp311-win_amd64.whl", hash = "sha256:87afda5539d5140cb8ba9e8b8c8865cb5b1463924d38490d73d3ccfd80896b3f"}, - {file = "pydantic-1.10.12-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:549a8e3d81df0a85226963611950b12d2d334f214436a19537b2efed61b7639a"}, - {file = "pydantic-1.10.12-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:598da88dfa127b666852bef6d0d796573a8cf5009ffd62104094a4fe39599565"}, - {file = "pydantic-1.10.12-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ba5c4a8552bff16c61882db58544116d021d0b31ee7c66958d14cf386a5b5350"}, - {file = "pydantic-1.10.12-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:c79e6a11a07da7374f46970410b41d5e266f7f38f6a17a9c4823db80dadf4303"}, - {file = "pydantic-1.10.12-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:ab26038b8375581dc832a63c948f261ae0aa21f1d34c1293469f135fa92972a5"}, - {file = "pydantic-1.10.12-cp37-cp37m-win_amd64.whl", hash = "sha256:e0a16d274b588767602b7646fa05af2782576a6cf1022f4ba74cbb4db66f6ca8"}, - {file = "pydantic-1.10.12-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:6a9dfa722316f4acf4460afdf5d41d5246a80e249c7ff475c43a3a1e9d75cf62"}, - {file = "pydantic-1.10.12-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:a73f489aebd0c2121ed974054cb2759af8a9f747de120acd2c3394cf84176ccb"}, - {file = "pydantic-1.10.12-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6b30bcb8cbfccfcf02acb8f1a261143fab622831d9c0989707e0e659f77a18e0"}, - {file = "pydantic-1.10.12-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2fcfb5296d7877af406ba1547dfde9943b1256d8928732267e2653c26938cd9c"}, - {file = "pydantic-1.10.12-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:2f9a6fab5f82ada41d56b0602606a5506aab165ca54e52bc4545028382ef1c5d"}, - {file = "pydantic-1.10.12-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:dea7adcc33d5d105896401a1f37d56b47d443a2b2605ff8a969a0ed5543f7e33"}, - {file = "pydantic-1.10.12-cp38-cp38-win_amd64.whl", hash = "sha256:1eb2085c13bce1612da8537b2d90f549c8cbb05c67e8f22854e201bde5d98a47"}, - {file = "pydantic-1.10.12-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:ef6c96b2baa2100ec91a4b428f80d8f28a3c9e53568219b6c298c1125572ebc6"}, - {file = "pydantic-1.10.12-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:6c076be61cd0177a8433c0adcb03475baf4ee91edf5a4e550161ad57fc90f523"}, - {file = "pydantic-1.10.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2d5a58feb9a39f481eda4d5ca220aa8b9d4f21a41274760b9bc66bfd72595b86"}, - {file = "pydantic-1.10.12-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e5f805d2d5d0a41633651a73fa4ecdd0b3d7a49de4ec3fadf062fe16501ddbf1"}, - {file = "pydantic-1.10.12-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:1289c180abd4bd4555bb927c42ee42abc3aee02b0fb2d1223fb7c6e5bef87dbe"}, - {file = "pydantic-1.10.12-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5d1197e462e0364906cbc19681605cb7c036f2475c899b6f296104ad42b9f5fb"}, - {file = "pydantic-1.10.12-cp39-cp39-win_amd64.whl", hash = "sha256:fdbdd1d630195689f325c9ef1a12900524dceb503b00a987663ff4f58669b93d"}, - {file = "pydantic-1.10.12-py3-none-any.whl", hash = "sha256:b749a43aa51e32839c9d71dc67eb1e4221bb04af1033a32e3923d46f9effa942"}, - {file = "pydantic-1.10.12.tar.gz", hash = "sha256:0fe8a415cea8f340e7a9af9c54fc71a649b43e8ca3cc732986116b3cb135d303"}, -] - -[package.dependencies] -typing-extensions = ">=4.2.0" - -[package.extras] -dotenv = ["python-dotenv (>=0.10.4)"] -email = ["email-validator (>=1.0.3)"] + {file = "pydantic_core-2.10.1-cp310-cp310-macosx_10_7_x86_64.whl", hash = "sha256:d64728ee14e667ba27c66314b7d880b8eeb050e58ffc5fec3b7a109f8cddbd63"}, + {file = "pydantic_core-2.10.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:48525933fea744a3e7464c19bfede85df4aba79ce90c60b94d8b6e1eddd67096"}, + {file = "pydantic_core-2.10.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ef337945bbd76cce390d1b2496ccf9f90b1c1242a3a7bc242ca4a9fc5993427a"}, + {file = "pydantic_core-2.10.1-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:a1392e0638af203cee360495fd2cfdd6054711f2db5175b6e9c3c461b76f5175"}, + {file = "pydantic_core-2.10.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0675ba5d22de54d07bccde38997e780044dcfa9a71aac9fd7d4d7a1d2e3e65f7"}, + {file = "pydantic_core-2.10.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:128552af70a64660f21cb0eb4876cbdadf1a1f9d5de820fed6421fa8de07c893"}, + {file = "pydantic_core-2.10.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8f6e6aed5818c264412ac0598b581a002a9f050cb2637a84979859e70197aa9e"}, + {file = "pydantic_core-2.10.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:ecaac27da855b8d73f92123e5f03612b04c5632fd0a476e469dfc47cd37d6b2e"}, + {file = "pydantic_core-2.10.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:b3c01c2fb081fced3bbb3da78510693dc7121bb893a1f0f5f4b48013201f362e"}, + {file = "pydantic_core-2.10.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:92f675fefa977625105708492850bcbc1182bfc3e997f8eecb866d1927c98ae6"}, + {file = "pydantic_core-2.10.1-cp310-none-win32.whl", hash = "sha256:420a692b547736a8d8703c39ea935ab5d8f0d2573f8f123b0a294e49a73f214b"}, + {file = "pydantic_core-2.10.1-cp310-none-win_amd64.whl", hash = "sha256:0880e239827b4b5b3e2ce05e6b766a7414e5f5aedc4523be6b68cfbc7f61c5d0"}, + {file = "pydantic_core-2.10.1-cp311-cp311-macosx_10_7_x86_64.whl", hash = "sha256:073d4a470b195d2b2245d0343569aac7e979d3a0dcce6c7d2af6d8a920ad0bea"}, + {file = "pydantic_core-2.10.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:600d04a7b342363058b9190d4e929a8e2e715c5682a70cc37d5ded1e0dd370b4"}, + {file = "pydantic_core-2.10.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:39215d809470f4c8d1881758575b2abfb80174a9e8daf8f33b1d4379357e417c"}, + {file = "pydantic_core-2.10.1-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:eeb3d3d6b399ffe55f9a04e09e635554012f1980696d6b0aca3e6cf42a17a03b"}, + {file = "pydantic_core-2.10.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a7a7902bf75779bc12ccfc508bfb7a4c47063f748ea3de87135d433a4cca7a2f"}, + {file = "pydantic_core-2.10.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3625578b6010c65964d177626fde80cf60d7f2e297d56b925cb5cdeda6e9925a"}, + {file = "pydantic_core-2.10.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:caa48fc31fc7243e50188197b5f0c4228956f97b954f76da157aae7f67269ae8"}, + {file = "pydantic_core-2.10.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:07ec6d7d929ae9c68f716195ce15e745b3e8fa122fc67698ac6498d802ed0fa4"}, + {file = "pydantic_core-2.10.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e6f31a17acede6a8cd1ae2d123ce04d8cca74056c9d456075f4f6f85de055607"}, + {file = "pydantic_core-2.10.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:d8f1ebca515a03e5654f88411420fea6380fc841d1bea08effb28184e3d4899f"}, + {file = "pydantic_core-2.10.1-cp311-none-win32.whl", hash = "sha256:6db2eb9654a85ada248afa5a6db5ff1cf0f7b16043a6b070adc4a5be68c716d6"}, + {file = "pydantic_core-2.10.1-cp311-none-win_amd64.whl", hash = "sha256:4a5be350f922430997f240d25f8219f93b0c81e15f7b30b868b2fddfc2d05f27"}, + {file = "pydantic_core-2.10.1-cp311-none-win_arm64.whl", hash = "sha256:5fdb39f67c779b183b0c853cd6b45f7db84b84e0571b3ef1c89cdb1dfc367325"}, + {file = "pydantic_core-2.10.1-cp312-cp312-macosx_10_7_x86_64.whl", hash = "sha256:b1f22a9ab44de5f082216270552aa54259db20189e68fc12484873d926426921"}, + {file = "pydantic_core-2.10.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8572cadbf4cfa95fb4187775b5ade2eaa93511f07947b38f4cd67cf10783b118"}, + {file = "pydantic_core-2.10.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:db9a28c063c7c00844ae42a80203eb6d2d6bbb97070cfa00194dff40e6f545ab"}, + {file = "pydantic_core-2.10.1-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:0e2a35baa428181cb2270a15864ec6286822d3576f2ed0f4cd7f0c1708472aff"}, + {file = "pydantic_core-2.10.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:05560ab976012bf40f25d5225a58bfa649bb897b87192a36c6fef1ab132540d7"}, + {file = "pydantic_core-2.10.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d6495008733c7521a89422d7a68efa0a0122c99a5861f06020ef5b1f51f9ba7c"}, + {file = "pydantic_core-2.10.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:14ac492c686defc8e6133e3a2d9eaf5261b3df26b8ae97450c1647286750b901"}, + {file = "pydantic_core-2.10.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:8282bab177a9a3081fd3d0a0175a07a1e2bfb7fcbbd949519ea0980f8a07144d"}, + {file = "pydantic_core-2.10.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:aafdb89fdeb5fe165043896817eccd6434aee124d5ee9b354f92cd574ba5e78f"}, + {file = "pydantic_core-2.10.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:f6defd966ca3b187ec6c366604e9296f585021d922e666b99c47e78738b5666c"}, + {file = "pydantic_core-2.10.1-cp312-none-win32.whl", hash = "sha256:7c4d1894fe112b0864c1fa75dffa045720a194b227bed12f4be7f6045b25209f"}, + {file = "pydantic_core-2.10.1-cp312-none-win_amd64.whl", hash = "sha256:5994985da903d0b8a08e4935c46ed8daf5be1cf217489e673910951dc533d430"}, + {file = "pydantic_core-2.10.1-cp312-none-win_arm64.whl", hash = "sha256:0d8a8adef23d86d8eceed3e32e9cca8879c7481c183f84ed1a8edc7df073af94"}, + {file = "pydantic_core-2.10.1-cp37-cp37m-macosx_10_7_x86_64.whl", hash = "sha256:9badf8d45171d92387410b04639d73811b785b5161ecadabf056ea14d62d4ede"}, + {file = "pydantic_core-2.10.1-cp37-cp37m-macosx_11_0_arm64.whl", hash = "sha256:ebedb45b9feb7258fac0a268a3f6bec0a2ea4d9558f3d6f813f02ff3a6dc6698"}, + {file = "pydantic_core-2.10.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cfe1090245c078720d250d19cb05d67e21a9cd7c257698ef139bc41cf6c27b4f"}, + {file = "pydantic_core-2.10.1-cp37-cp37m-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e357571bb0efd65fd55f18db0a2fb0ed89d0bb1d41d906b138f088933ae618bb"}, + {file = "pydantic_core-2.10.1-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b3dcd587b69bbf54fc04ca157c2323b8911033e827fffaecf0cafa5a892a0904"}, + {file = "pydantic_core-2.10.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9c120c9ce3b163b985a3b966bb701114beb1da4b0468b9b236fc754783d85aa3"}, + {file = "pydantic_core-2.10.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:15d6bca84ffc966cc9976b09a18cf9543ed4d4ecbd97e7086f9ce9327ea48891"}, + {file = "pydantic_core-2.10.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:5cabb9710f09d5d2e9e2748c3e3e20d991a4c5f96ed8f1132518f54ab2967221"}, + {file = "pydantic_core-2.10.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:82f55187a5bebae7d81d35b1e9aaea5e169d44819789837cdd4720d768c55d15"}, + {file = "pydantic_core-2.10.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:1d40f55222b233e98e3921df7811c27567f0e1a4411b93d4c5c0f4ce131bc42f"}, + {file = "pydantic_core-2.10.1-cp37-none-win32.whl", hash = "sha256:14e09ff0b8fe6e46b93d36a878f6e4a3a98ba5303c76bb8e716f4878a3bee92c"}, + {file = "pydantic_core-2.10.1-cp37-none-win_amd64.whl", hash = "sha256:1396e81b83516b9d5c9e26a924fa69164156c148c717131f54f586485ac3c15e"}, + {file = "pydantic_core-2.10.1-cp38-cp38-macosx_10_7_x86_64.whl", hash = "sha256:6835451b57c1b467b95ffb03a38bb75b52fb4dc2762bb1d9dbed8de31ea7d0fc"}, + {file = "pydantic_core-2.10.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:b00bc4619f60c853556b35f83731bd817f989cba3e97dc792bb8c97941b8053a"}, + {file = "pydantic_core-2.10.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0fa467fd300a6f046bdb248d40cd015b21b7576c168a6bb20aa22e595c8ffcdd"}, + {file = "pydantic_core-2.10.1-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:d99277877daf2efe074eae6338453a4ed54a2d93fb4678ddfe1209a0c93a2468"}, + {file = "pydantic_core-2.10.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fa7db7558607afeccb33c0e4bf1c9a9a835e26599e76af6fe2fcea45904083a6"}, + {file = "pydantic_core-2.10.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:aad7bd686363d1ce4ee930ad39f14e1673248373f4a9d74d2b9554f06199fb58"}, + {file = "pydantic_core-2.10.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:443fed67d33aa85357464f297e3d26e570267d1af6fef1c21ca50921d2976302"}, + {file = "pydantic_core-2.10.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:042462d8d6ba707fd3ce9649e7bf268633a41018d6a998fb5fbacb7e928a183e"}, + {file = "pydantic_core-2.10.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:ecdbde46235f3d560b18be0cb706c8e8ad1b965e5c13bbba7450c86064e96561"}, + {file = "pydantic_core-2.10.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:ed550ed05540c03f0e69e6d74ad58d026de61b9eaebebbaaf8873e585cbb18de"}, + {file = "pydantic_core-2.10.1-cp38-none-win32.whl", hash = "sha256:8cdbbd92154db2fec4ec973d45c565e767ddc20aa6dbaf50142676484cbff8ee"}, + {file = "pydantic_core-2.10.1-cp38-none-win_amd64.whl", hash = "sha256:9f6f3e2598604956480f6c8aa24a3384dbf6509fe995d97f6ca6103bb8c2534e"}, + {file = "pydantic_core-2.10.1-cp39-cp39-macosx_10_7_x86_64.whl", hash = "sha256:655f8f4c8d6a5963c9a0687793da37b9b681d9ad06f29438a3b2326d4e6b7970"}, + {file = "pydantic_core-2.10.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:e570ffeb2170e116a5b17e83f19911020ac79d19c96f320cbfa1fa96b470185b"}, + {file = "pydantic_core-2.10.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:64322bfa13e44c6c30c518729ef08fda6026b96d5c0be724b3c4ae4da939f875"}, + {file = "pydantic_core-2.10.1-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:485a91abe3a07c3a8d1e082ba29254eea3e2bb13cbbd4351ea4e5a21912cc9b0"}, + {file = "pydantic_core-2.10.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f7c2b8eb9fc872e68b46eeaf835e86bccc3a58ba57d0eedc109cbb14177be531"}, + {file = "pydantic_core-2.10.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a5cb87bdc2e5f620693148b5f8f842d293cae46c5f15a1b1bf7ceeed324a740c"}, + {file = "pydantic_core-2.10.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:25bd966103890ccfa028841a8f30cebcf5875eeac8c4bde4fe221364c92f0c9a"}, + {file = "pydantic_core-2.10.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f323306d0556351735b54acbf82904fe30a27b6a7147153cbe6e19aaaa2aa429"}, + {file = "pydantic_core-2.10.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:0c27f38dc4fbf07b358b2bc90edf35e82d1703e22ff2efa4af4ad5de1b3833e7"}, + {file = "pydantic_core-2.10.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:f1365e032a477c1430cfe0cf2856679529a2331426f8081172c4a74186f1d595"}, + {file = "pydantic_core-2.10.1-cp39-none-win32.whl", hash = "sha256:a1c311fd06ab3b10805abb72109f01a134019739bd3286b8ae1bc2fc4e50c07a"}, + {file = "pydantic_core-2.10.1-cp39-none-win_amd64.whl", hash = "sha256:ae8a8843b11dc0b03b57b52793e391f0122e740de3df1474814c700d2622950a"}, + {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-macosx_10_7_x86_64.whl", hash = "sha256:d43002441932f9a9ea5d6f9efaa2e21458221a3a4b417a14027a1d530201ef1b"}, + {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:fcb83175cc4936a5425dde3356f079ae03c0802bbdf8ff82c035f8a54b333521"}, + {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:962ed72424bf1f72334e2f1e61b68f16c0e596f024ca7ac5daf229f7c26e4208"}, + {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2cf5bb4dd67f20f3bbc1209ef572a259027c49e5ff694fa56bed62959b41e1f9"}, + {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:e544246b859f17373bed915182ab841b80849ed9cf23f1f07b73b7c58baee5fb"}, + {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:c0877239307b7e69d025b73774e88e86ce82f6ba6adf98f41069d5b0b78bd1bf"}, + {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:53df009d1e1ba40f696f8995683e067e3967101d4bb4ea6f667931b7d4a01357"}, + {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:a1254357f7e4c82e77c348dabf2d55f1d14d19d91ff025004775e70a6ef40ada"}, + {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-macosx_10_7_x86_64.whl", hash = "sha256:524ff0ca3baea164d6d93a32c58ac79eca9f6cf713586fdc0adb66a8cdeab96a"}, + {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3f0ac9fb8608dbc6eaf17956bf623c9119b4db7dbb511650910a82e261e6600f"}, + {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:320f14bd4542a04ab23747ff2c8a778bde727158b606e2661349557f0770711e"}, + {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:63974d168b6233b4ed6a0046296803cb13c56637a7b8106564ab575926572a55"}, + {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:417243bf599ba1f1fef2bb8c543ceb918676954734e2dcb82bf162ae9d7bd514"}, + {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:dda81e5ec82485155a19d9624cfcca9be88a405e2857354e5b089c2a982144b2"}, + {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:14cfbb00959259e15d684505263d5a21732b31248a5dd4941f73a3be233865b9"}, + {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-macosx_10_7_x86_64.whl", hash = "sha256:631cb7415225954fdcc2a024119101946793e5923f6c4d73a5914d27eb3d3a05"}, + {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-macosx_11_0_arm64.whl", hash = "sha256:bec7dd208a4182e99c5b6c501ce0b1f49de2802448d4056091f8e630b28e9a52"}, + {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:149b8a07712f45b332faee1a2258d8ef1fb4a36f88c0c17cb687f205c5dc6e7d"}, + {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4d966c47f9dd73c2d32a809d2be529112d509321c5310ebf54076812e6ecd884"}, + {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:7eb037106f5c6b3b0b864ad226b0b7ab58157124161d48e4b30c4a43fef8bc4b"}, + {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:154ea7c52e32dce13065dbb20a4a6f0cc012b4f667ac90d648d36b12007fa9f7"}, + {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:e562617a45b5a9da5be4abe72b971d4f00bf8555eb29bb91ec2ef2be348cd132"}, + {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:f23b55eb5464468f9e0e9a9935ce3ed2a870608d5f534025cd5536bca25b1402"}, + {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-macosx_10_7_x86_64.whl", hash = "sha256:e9121b4009339b0f751955baf4543a0bfd6bc3f8188f8056b1a25a2d45099934"}, + {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:0523aeb76e03f753b58be33b26540880bac5aa54422e4462404c432230543f33"}, + {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2e0e2959ef5d5b8dc9ef21e1a305a21a36e254e6a34432d00c72a92fdc5ecda5"}, + {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:da01bec0a26befab4898ed83b362993c844b9a607a86add78604186297eb047e"}, + {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f2e9072d71c1f6cfc79a36d4484c82823c560e6f5599c43c1ca6b5cdbd54f881"}, + {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:f36a3489d9e28fe4b67be9992a23029c3cec0babc3bd9afb39f49844a8c721c5"}, + {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:f64f82cc3443149292b32387086d02a6c7fb39b8781563e0ca7b8d7d9cf72bd7"}, + {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:b4a6db486ac8e99ae696e09efc8b2b9fea67b63c8f88ba7a1a16c24a057a0776"}, + {file = "pydantic_core-2.10.1.tar.gz", hash = "sha256:0f8682dbdd2f67f8e1edddcbffcc29f60a6182b4901c367fc8c1c40d30bb0a82"}, +] + +[package.dependencies] +typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0" [[package]] name = "pydash" @@ -3170,4 +3278,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "045ecbf12ab12cb183f9bbcf5294079b6814881d5233bebc4dd623a589a71519" +content-hash = "3d3f6330f605b40cfada7b8725304f7b197a9279819a8cad13bcdb6af1021b98" diff --git a/pyproject.toml b/pyproject.toml index b0b3d0a1..1df7b1e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ readme = "README.md" python = "^3.10" click = "^8.1.3" httpx = "^0.23.1" -copier = "^8.0.0" +copier = "^8.3.0" questionary = "^1.10.0" pyclip = "^0.7.0" shellingham = "^1.5.0.post1" @@ -18,7 +18,7 @@ algokit-client-generator = "^1.0.3" tomli = { version = "^2.0.1", python = "<3.11" } python-dotenv = "^1.0.0" # workaround for issue with copier dependency spec allowing major upgrade to pydantic v2 -pydantic = "^1.10.2" +pydantic = "^2.4.0" mslex = "^1.1.0" keyring = "^24.2.0" pyjwt = "^2.8.0" diff --git a/src/algokit/cli/init.py b/src/algokit/cli/init.py index dc1d5db1..73b45560 100644 --- a/src/algokit/cli/init.py +++ b/src/algokit/cli/init.py @@ -220,17 +220,15 @@ def init_command( # noqa: PLR0913 # to their repo to include py.typed file from copier.main import Worker # type: ignore[import] - from algokit.core.init import populate_default_answers - with Worker( src_path=template.url, dst_path=project_path, data=answers_dict, quiet=True, vcs_ref=template.commit, + defaults=use_defaults, + unsafe=unsafe_security_accept_template_url, ) as copier_worker: - if use_defaults: - populate_default_answers(copier_worker) expanded_template_url = copier_worker.template.url_expanded logger.debug(f"final clone URL = {expanded_template_url}") copier_worker.run_copy() diff --git a/src/algokit/core/init.py b/src/algokit/core/init.py index 00593d69..aa25dccf 100644 --- a/src/algokit/core/init.py +++ b/src/algokit/core/init.py @@ -8,7 +8,6 @@ def populate_default_answers(worker: Worker) -> None: Used as a work-around for the behaviour of Worker(default=True, ...) which in >=7.1 raises an error instead of prompting if no default is provided""" answers = AnswersMap( - default=worker.template.default_answers, user_defaults=worker.user_defaults, init=worker.data, last=worker.subproject.last_answers, diff --git a/tests/init/test_init.py b/tests/init/test_init.py index a13049e3..e81270bb 100644 --- a/tests/init/test_init.py +++ b/tests/init/test_init.py @@ -560,8 +560,8 @@ def test_init_with_official_template_name_and_hash(tmp_path_factory: TempPathFac cwd = tmp_path_factory.mktemp("cwd") result = invoke( - "init --name myapp --no-git --template beaker_with_version --defaults -a run_poetry_install False " - "-a author_name None -a author_email None ", + "init --name myapp --no-git --template beaker_with_version --UNSAFE-SECURITY-accept-template-url" + " --defaults -a run_poetry_install False -a author_name None -a author_email None ", cwd=cwd, ) diff --git a/tests/init/test_init.test_init_ask_about_git.approved.txt b/tests/init/test_init.test_init_ask_about_git.approved.txt index af2590f0..2fc9c66a 100644 --- a/tests/init/test_init.test_init_ask_about_git.approved.txt +++ b/tests/init/test_init.test_init_ask_about_git.approved.txt @@ -4,8 +4,8 @@ Please inspect the template repository, and pay particular attention to the valu DEBUG: template source = {test_parent_directory}/copier-helloworld.bundle DEBUG: project path = {current_working_directory}/myapp Starting template copy and render... -No git tags found in template; using HEAD as ref DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle +No git tags found in template; using HEAD as ref Template render complete! DEBUG: Attempting to load project config from {current_working_directory}/myapp/.algokit.toml DEBUG: No .algokit.toml file found in the project directory. diff --git a/tests/init/test_init.test_init_input_template_url.approved.txt b/tests/init/test_init.test_init_input_template_url.approved.txt index 41c82588..297920ea 100644 --- a/tests/init/test_init.test_init_input_template_url.approved.txt +++ b/tests/init/test_init.test_init_input_template_url.approved.txt @@ -27,8 +27,8 @@ Valid examples: DEBUG: template source = {test_parent_directory}/copier-helloworld.bundle DEBUG: project path = {current_working_directory}/myapp Starting template copy and render... -No git tags found in template; using HEAD as ref DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle +No git tags found in template; using HEAD as ref Template render complete! DEBUG: Attempting to load project config from {current_working_directory}/myapp/.algokit.toml DEBUG: No .algokit.toml file found in the project directory. diff --git a/tests/init/test_init.test_init_minimal_interaction_required_no_git_no_network_no_bootstrap.approved.txt b/tests/init/test_init.test_init_minimal_interaction_required_no_git_no_network_no_bootstrap.approved.txt index 82faaf9f..a323e791 100644 --- a/tests/init/test_init.test_init_minimal_interaction_required_no_git_no_network_no_bootstrap.approved.txt +++ b/tests/init/test_init.test_init_minimal_interaction_required_no_git_no_network_no_bootstrap.approved.txt @@ -4,7 +4,7 @@ Please inspect the template repository, and pay particular attention to the valu DEBUG: template source = {test_parent_directory}/copier-helloworld.bundle DEBUG: project path = {current_working_directory}/myapp Starting template copy and render... -No git tags found in template; using HEAD as ref DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle +No git tags found in template; using HEAD as ref Template render complete! 🙌 Project initialized at `myapp`! For template specific next steps, consult the documentation of your selected template 🧐 diff --git a/tests/init/test_init.test_init_minimal_interaction_required_yes_git_no_network.approved.txt b/tests/init/test_init.test_init_minimal_interaction_required_yes_git_no_network.approved.txt index 1ea9f84e..73efd3cd 100644 --- a/tests/init/test_init.test_init_minimal_interaction_required_yes_git_no_network.approved.txt +++ b/tests/init/test_init.test_init_minimal_interaction_required_yes_git_no_network.approved.txt @@ -4,8 +4,8 @@ Please inspect the template repository, and pay particular attention to the valu DEBUG: template source = {test_parent_directory}/copier-helloworld.bundle DEBUG: project path = {current_working_directory}/myapp Starting template copy and render... -No git tags found in template; using HEAD as ref DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle +No git tags found in template; using HEAD as ref Template render complete! DEBUG: Attempting to load project config from {current_working_directory}/myapp/.algokit.toml DEBUG: No .algokit.toml file found in the project directory. diff --git a/tests/init/test_init.test_init_no_interaction_required_defaults_no_git_no_network.approved.txt b/tests/init/test_init.test_init_no_interaction_required_defaults_no_git_no_network.approved.txt index 8b548537..afd21db7 100644 --- a/tests/init/test_init.test_init_no_interaction_required_defaults_no_git_no_network.approved.txt +++ b/tests/init/test_init.test_init_no_interaction_required_defaults_no_git_no_network.approved.txt @@ -3,8 +3,8 @@ Please inspect the template repository, and pay particular attention to the valu DEBUG: template source = {test_parent_directory}/copier-helloworld.bundle DEBUG: project path = {current_working_directory}/myapp Starting template copy and render... -No git tags found in template; using HEAD as ref DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle +No git tags found in template; using HEAD as ref Template render complete! DEBUG: Attempting to load project config from {current_working_directory}/myapp/.algokit.toml DEBUG: No .algokit.toml file found in the project directory. diff --git a/tests/init/test_init.test_init_project_name.approved.txt b/tests/init/test_init.test_init_project_name.approved.txt index 456f91a0..b63c2d7f 100644 --- a/tests/init/test_init.test_init_project_name.approved.txt +++ b/tests/init/test_init.test_init_project_name.approved.txt @@ -4,8 +4,8 @@ DEBUG: template source = {test_parent_directory}/copier-helloworld.bundle ? Name of project / directory to create the project in: DEBUG: project path = {current_working_directory}/FAKE_PROJECT Starting template copy and render... -No git tags found in template; using HEAD as ref DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle +No git tags found in template; using HEAD as ref Template render complete! DEBUG: Attempting to load project config from {current_working_directory}/FAKE_PROJECT/.algokit.toml DEBUG: No .algokit.toml file found in the project directory. diff --git a/tests/init/test_init.test_init_project_name_not_empty.approved.txt b/tests/init/test_init.test_init_project_name_not_empty.approved.txt index 456f91a0..b63c2d7f 100644 --- a/tests/init/test_init.test_init_project_name_not_empty.approved.txt +++ b/tests/init/test_init.test_init_project_name_not_empty.approved.txt @@ -4,8 +4,8 @@ DEBUG: template source = {test_parent_directory}/copier-helloworld.bundle ? Name of project / directory to create the project in: DEBUG: project path = {current_working_directory}/FAKE_PROJECT Starting template copy and render... -No git tags found in template; using HEAD as ref DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle +No git tags found in template; using HEAD as ref Template render complete! DEBUG: Attempting to load project config from {current_working_directory}/FAKE_PROJECT/.algokit.toml DEBUG: No .algokit.toml file found in the project directory. diff --git a/tests/init/test_init.test_init_project_name_reenter_folder_name.approved.txt b/tests/init/test_init.test_init_project_name_reenter_folder_name.approved.txt index b587a995..3f10ec19 100644 --- a/tests/init/test_init.test_init_project_name_reenter_folder_name.approved.txt +++ b/tests/init/test_init.test_init_project_name_reenter_folder_name.approved.txt @@ -7,8 +7,8 @@ WARNING: Re-using existing directory, this is not recommended because if project ? Name of project / directory to create the project in: DEBUG: project path = {current_working_directory}/FAKE_PROJECT_2 Starting template copy and render... -No git tags found in template; using HEAD as ref DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle +No git tags found in template; using HEAD as ref Template render complete! DEBUG: Attempting to load project config from {current_working_directory}/FAKE_PROJECT_2/.algokit.toml DEBUG: No .algokit.toml file found in the project directory. diff --git a/tests/init/test_init.test_init_template_selection.approved.txt b/tests/init/test_init.test_init_template_selection.approved.txt index 99edbdaf..4c57c2d2 100644 --- a/tests/init/test_init.test_init_template_selection.approved.txt +++ b/tests/init/test_init.test_init_template_selection.approved.txt @@ -10,8 +10,8 @@ beaker_with_version DEBUG: template source = gh:robdmoore/copier-helloworld DEBUG: project path = {current_working_directory}/myapp Starting template copy and render... -No git tags found in template; using HEAD as ref DEBUG: final clone URL = https://github.com/robdmoore/copier-helloworld.git +No git tags found in template; using HEAD as ref Template render complete! DEBUG: Attempting to load project config from {current_working_directory}/myapp/.algokit.toml DEBUG: No .algokit.toml file found in the project directory. diff --git a/tests/init/test_init.test_init_use_existing_folder.approved.txt b/tests/init/test_init.test_init_use_existing_folder.approved.txt index 4513be3f..838b94f2 100644 --- a/tests/init/test_init.test_init_use_existing_folder.approved.txt +++ b/tests/init/test_init.test_init_use_existing_folder.approved.txt @@ -5,8 +5,8 @@ WARNING: Re-using existing directory, this is not recommended because if project ? Continue anyway? (y/N) DEBUG: project path = {current_working_directory}/myapp Starting template copy and render... -No git tags found in template; using HEAD as ref DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle +No git tags found in template; using HEAD as ref Template render complete! DEBUG: Attempting to load project config from {current_working_directory}/myapp/.algokit.toml DEBUG: No .algokit.toml file found in the project directory. From 9580eb17c8887f2b07948b6d8e5f163f2784269d Mon Sep 17 00:00:00 2001 From: Negar Abbasi Date: Wed, 1 Nov 2023 12:45:38 +1000 Subject: [PATCH 03/12] refactor: revert the code to original --- src/algokit/cli/init.py | 5 ++++- tests/init/test_init.test_init_ask_about_git.approved.txt | 2 +- .../init/test_init.test_init_input_template_url.approved.txt | 2 +- ...tion_required_no_git_no_network_no_bootstrap.approved.txt | 2 +- ...imal_interaction_required_yes_git_no_network.approved.txt | 2 +- ...eraction_required_defaults_no_git_no_network.approved.txt | 2 +- tests/init/test_init.test_init_project_name.approved.txt | 2 +- .../test_init.test_init_project_name_not_empty.approved.txt | 2 +- ...t.test_init_project_name_reenter_folder_name.approved.txt | 2 +- .../init/test_init.test_init_template_selection.approved.txt | 2 +- .../test_init.test_init_use_existing_folder.approved.txt | 2 +- 11 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/algokit/cli/init.py b/src/algokit/cli/init.py index 73b45560..64da344b 100644 --- a/src/algokit/cli/init.py +++ b/src/algokit/cli/init.py @@ -220,15 +220,18 @@ def init_command( # noqa: PLR0913 # to their repo to include py.typed file from copier.main import Worker # type: ignore[import] + from algokit.core.init import populate_default_answers # type: ignore[import] + with Worker( src_path=template.url, dst_path=project_path, data=answers_dict, quiet=True, vcs_ref=template.commit, - defaults=use_defaults, unsafe=unsafe_security_accept_template_url, ) as copier_worker: + if use_defaults: + populate_default_answers(copier_worker) expanded_template_url = copier_worker.template.url_expanded logger.debug(f"final clone URL = {expanded_template_url}") copier_worker.run_copy() diff --git a/tests/init/test_init.test_init_ask_about_git.approved.txt b/tests/init/test_init.test_init_ask_about_git.approved.txt index 2fc9c66a..af2590f0 100644 --- a/tests/init/test_init.test_init_ask_about_git.approved.txt +++ b/tests/init/test_init.test_init_ask_about_git.approved.txt @@ -4,8 +4,8 @@ Please inspect the template repository, and pay particular attention to the valu DEBUG: template source = {test_parent_directory}/copier-helloworld.bundle DEBUG: project path = {current_working_directory}/myapp Starting template copy and render... -DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle No git tags found in template; using HEAD as ref +DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle Template render complete! DEBUG: Attempting to load project config from {current_working_directory}/myapp/.algokit.toml DEBUG: No .algokit.toml file found in the project directory. diff --git a/tests/init/test_init.test_init_input_template_url.approved.txt b/tests/init/test_init.test_init_input_template_url.approved.txt index 297920ea..41c82588 100644 --- a/tests/init/test_init.test_init_input_template_url.approved.txt +++ b/tests/init/test_init.test_init_input_template_url.approved.txt @@ -27,8 +27,8 @@ Valid examples: DEBUG: template source = {test_parent_directory}/copier-helloworld.bundle DEBUG: project path = {current_working_directory}/myapp Starting template copy and render... -DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle No git tags found in template; using HEAD as ref +DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle Template render complete! DEBUG: Attempting to load project config from {current_working_directory}/myapp/.algokit.toml DEBUG: No .algokit.toml file found in the project directory. diff --git a/tests/init/test_init.test_init_minimal_interaction_required_no_git_no_network_no_bootstrap.approved.txt b/tests/init/test_init.test_init_minimal_interaction_required_no_git_no_network_no_bootstrap.approved.txt index a323e791..82faaf9f 100644 --- a/tests/init/test_init.test_init_minimal_interaction_required_no_git_no_network_no_bootstrap.approved.txt +++ b/tests/init/test_init.test_init_minimal_interaction_required_no_git_no_network_no_bootstrap.approved.txt @@ -4,7 +4,7 @@ Please inspect the template repository, and pay particular attention to the valu DEBUG: template source = {test_parent_directory}/copier-helloworld.bundle DEBUG: project path = {current_working_directory}/myapp Starting template copy and render... -DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle No git tags found in template; using HEAD as ref +DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle Template render complete! 🙌 Project initialized at `myapp`! For template specific next steps, consult the documentation of your selected template 🧐 diff --git a/tests/init/test_init.test_init_minimal_interaction_required_yes_git_no_network.approved.txt b/tests/init/test_init.test_init_minimal_interaction_required_yes_git_no_network.approved.txt index 73efd3cd..1ea9f84e 100644 --- a/tests/init/test_init.test_init_minimal_interaction_required_yes_git_no_network.approved.txt +++ b/tests/init/test_init.test_init_minimal_interaction_required_yes_git_no_network.approved.txt @@ -4,8 +4,8 @@ Please inspect the template repository, and pay particular attention to the valu DEBUG: template source = {test_parent_directory}/copier-helloworld.bundle DEBUG: project path = {current_working_directory}/myapp Starting template copy and render... -DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle No git tags found in template; using HEAD as ref +DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle Template render complete! DEBUG: Attempting to load project config from {current_working_directory}/myapp/.algokit.toml DEBUG: No .algokit.toml file found in the project directory. diff --git a/tests/init/test_init.test_init_no_interaction_required_defaults_no_git_no_network.approved.txt b/tests/init/test_init.test_init_no_interaction_required_defaults_no_git_no_network.approved.txt index afd21db7..8b548537 100644 --- a/tests/init/test_init.test_init_no_interaction_required_defaults_no_git_no_network.approved.txt +++ b/tests/init/test_init.test_init_no_interaction_required_defaults_no_git_no_network.approved.txt @@ -3,8 +3,8 @@ Please inspect the template repository, and pay particular attention to the valu DEBUG: template source = {test_parent_directory}/copier-helloworld.bundle DEBUG: project path = {current_working_directory}/myapp Starting template copy and render... -DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle No git tags found in template; using HEAD as ref +DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle Template render complete! DEBUG: Attempting to load project config from {current_working_directory}/myapp/.algokit.toml DEBUG: No .algokit.toml file found in the project directory. diff --git a/tests/init/test_init.test_init_project_name.approved.txt b/tests/init/test_init.test_init_project_name.approved.txt index b63c2d7f..456f91a0 100644 --- a/tests/init/test_init.test_init_project_name.approved.txt +++ b/tests/init/test_init.test_init_project_name.approved.txt @@ -4,8 +4,8 @@ DEBUG: template source = {test_parent_directory}/copier-helloworld.bundle ? Name of project / directory to create the project in: DEBUG: project path = {current_working_directory}/FAKE_PROJECT Starting template copy and render... -DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle No git tags found in template; using HEAD as ref +DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle Template render complete! DEBUG: Attempting to load project config from {current_working_directory}/FAKE_PROJECT/.algokit.toml DEBUG: No .algokit.toml file found in the project directory. diff --git a/tests/init/test_init.test_init_project_name_not_empty.approved.txt b/tests/init/test_init.test_init_project_name_not_empty.approved.txt index b63c2d7f..456f91a0 100644 --- a/tests/init/test_init.test_init_project_name_not_empty.approved.txt +++ b/tests/init/test_init.test_init_project_name_not_empty.approved.txt @@ -4,8 +4,8 @@ DEBUG: template source = {test_parent_directory}/copier-helloworld.bundle ? Name of project / directory to create the project in: DEBUG: project path = {current_working_directory}/FAKE_PROJECT Starting template copy and render... -DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle No git tags found in template; using HEAD as ref +DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle Template render complete! DEBUG: Attempting to load project config from {current_working_directory}/FAKE_PROJECT/.algokit.toml DEBUG: No .algokit.toml file found in the project directory. diff --git a/tests/init/test_init.test_init_project_name_reenter_folder_name.approved.txt b/tests/init/test_init.test_init_project_name_reenter_folder_name.approved.txt index 3f10ec19..b587a995 100644 --- a/tests/init/test_init.test_init_project_name_reenter_folder_name.approved.txt +++ b/tests/init/test_init.test_init_project_name_reenter_folder_name.approved.txt @@ -7,8 +7,8 @@ WARNING: Re-using existing directory, this is not recommended because if project ? Name of project / directory to create the project in: DEBUG: project path = {current_working_directory}/FAKE_PROJECT_2 Starting template copy and render... -DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle No git tags found in template; using HEAD as ref +DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle Template render complete! DEBUG: Attempting to load project config from {current_working_directory}/FAKE_PROJECT_2/.algokit.toml DEBUG: No .algokit.toml file found in the project directory. diff --git a/tests/init/test_init.test_init_template_selection.approved.txt b/tests/init/test_init.test_init_template_selection.approved.txt index 4c57c2d2..99edbdaf 100644 --- a/tests/init/test_init.test_init_template_selection.approved.txt +++ b/tests/init/test_init.test_init_template_selection.approved.txt @@ -10,8 +10,8 @@ beaker_with_version DEBUG: template source = gh:robdmoore/copier-helloworld DEBUG: project path = {current_working_directory}/myapp Starting template copy and render... -DEBUG: final clone URL = https://github.com/robdmoore/copier-helloworld.git No git tags found in template; using HEAD as ref +DEBUG: final clone URL = https://github.com/robdmoore/copier-helloworld.git Template render complete! DEBUG: Attempting to load project config from {current_working_directory}/myapp/.algokit.toml DEBUG: No .algokit.toml file found in the project directory. diff --git a/tests/init/test_init.test_init_use_existing_folder.approved.txt b/tests/init/test_init.test_init_use_existing_folder.approved.txt index 838b94f2..4513be3f 100644 --- a/tests/init/test_init.test_init_use_existing_folder.approved.txt +++ b/tests/init/test_init.test_init_use_existing_folder.approved.txt @@ -5,8 +5,8 @@ WARNING: Re-using existing directory, this is not recommended because if project ? Continue anyway? (y/N) DEBUG: project path = {current_working_directory}/myapp Starting template copy and render... -DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle No git tags found in template; using HEAD as ref +DEBUG: final clone URL = {test_parent_directory}/copier-helloworld.bundle Template render complete! DEBUG: Attempting to load project config from {current_working_directory}/myapp/.algokit.toml DEBUG: No .algokit.toml file found in the project directory. From b0e80f0c27fc310ade169b4ee722abe86b5dcc06 Mon Sep 17 00:00:00 2001 From: Negar Abbasi Date: Wed, 1 Nov 2023 13:18:23 +1000 Subject: [PATCH 04/12] chore: fix a test and updating copier to version 9 --- poetry.lock | 10 +++++----- pyproject.toml | 2 +- tests/init/test_init.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/poetry.lock b/poetry.lock index 13f885dc..839eb9f7 100644 --- a/poetry.lock +++ b/poetry.lock @@ -629,13 +629,13 @@ files = [ [[package]] name = "copier" -version = "8.3.0" +version = "9.0.1" description = "A library for rendering project templates." optional = false python-versions = ">=3.8,<4.0" files = [ - {file = "copier-8.3.0-py3-none-any.whl", hash = "sha256:a708e9b7c0eb7363ee5935f7a96a63a6f39b6da1d36f1c931d1ebd7711bb2ecf"}, - {file = "copier-8.3.0.tar.gz", hash = "sha256:051149721c811bfa84023fca5c23827917ac5f42ab6c2696dcb522b17aee7cae"}, + {file = "copier-9.0.1-py3-none-any.whl", hash = "sha256:0c5d0a0de372e1b0cb9f0f19988fadf6f652a5df78931ef5e9206b27fab8766e"}, + {file = "copier-9.0.1.tar.gz", hash = "sha256:eaf525bbccad7acc66fb11ff52f1a96bf32b2470389d3c077c21e339b755842e"}, ] [package.dependencies] @@ -648,7 +648,7 @@ jinja2-ansible-filters = ">=1.3.1" packaging = ">=23.0" pathspec = ">=0.9.0" plumbum = ">=1.6.9" -pydantic = ">=2.0.3" +pydantic = ">=2.4.2" pygments = ">=2.7.1" pyyaml = ">=5.3.1" pyyaml-include = ">=1.2" @@ -3336,4 +3336,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "92127dcae1d276ab7ccd92ecd0b1ce19588dc4d3497c307514e35b3c6fd952bd" +content-hash = "682201e4f76e28eabd67f47af20e176a1e5a9940acd93150b2e1d5ab984effec" diff --git a/pyproject.toml b/pyproject.toml index ef42d66b..7bf4dc43 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ readme = "README.md" python = "^3.10" click = "^8.1.3" httpx = "^0.23.1" -copier = "^8.3.0" +copier = "^9.0.0" questionary = "^1.10.0" pyclip = "^0.7.0" shellingham = "^1.5.0.post1" diff --git a/tests/init/test_init.py b/tests/init/test_init.py index e81270bb..b192b87c 100644 --- a/tests/init/test_init.py +++ b/tests/init/test_init.py @@ -488,7 +488,7 @@ def test_init_template_url_and_ref(tmp_path_factory: TempPathFactory, mocker: Mo ref = "abcdef123456" cwd = tmp_path_factory.mktemp("cwd") result = invoke( - "init --name myapp --no-git --no-bootstrap --defaults " + "init --name myapp --no-git --no-bootstrap " "--template-url gh:algorandfoundation/algokit-beaker-default-template " f"--template-url-ref {ref} " "--UNSAFE-SECURITY-accept-template-url", From 8fa90a1541d9f076ca191e1539464e83c2722d8b Mon Sep 17 00:00:00 2001 From: Negar Abbasi Date: Wed, 1 Nov 2023 13:22:19 +1000 Subject: [PATCH 05/12] chore: update pip dependency --- poetry.lock | 6 +++--- src/algokit/cli/init.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/poetry.lock b/poetry.lock index 839eb9f7..a92a1c35 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1751,13 +1751,13 @@ files = [ [[package]] name = "pip" -version = "23.2.1" +version = "23.3.1" description = "The PyPA recommended tool for installing Python packages." optional = false python-versions = ">=3.7" files = [ - {file = "pip-23.2.1-py3-none-any.whl", hash = "sha256:7ccf472345f20d35bdc9d1841ff5f313260c2c33fe417f48c30ac46cccabf5be"}, - {file = "pip-23.2.1.tar.gz", hash = "sha256:fb0bd5435b3200c602b5bf61d2d43c2f13c02e29c1707567ae7fbc514eb9faf2"}, + {file = "pip-23.3.1-py3-none-any.whl", hash = "sha256:55eb67bb6171d37447e82213be585b75fe2b12b359e993773aca4de9247a052b"}, + {file = "pip-23.3.1.tar.gz", hash = "sha256:1fcaa041308d01f14575f6d0d2ea4b75a3e2871fe4f9c694976f908768e14174"}, ] [[package]] diff --git a/src/algokit/cli/init.py b/src/algokit/cli/init.py index 64da344b..59e87559 100644 --- a/src/algokit/cli/init.py +++ b/src/algokit/cli/init.py @@ -220,7 +220,7 @@ def init_command( # noqa: PLR0913 # to their repo to include py.typed file from copier.main import Worker # type: ignore[import] - from algokit.core.init import populate_default_answers # type: ignore[import] + from algokit.core.init import populate_default_answers with Worker( src_path=template.url, From e56f136ceadb698cac7c9e5db5a45b2c096aeeab Mon Sep 17 00:00:00 2001 From: Negar Abbasi Date: Thu, 2 Nov 2023 13:10:34 +1000 Subject: [PATCH 06/12] fix: defining the algorand templated as trusted for copier --- src/algokit/cli/init.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/algokit/cli/init.py b/src/algokit/cli/init.py index 59e87559..db270fa5 100644 --- a/src/algokit/cli/init.py +++ b/src/algokit/cli/init.py @@ -204,6 +204,11 @@ def init_command( # noqa: PLR0913 commit=template_url_ref, unsafe_security_accept_template_url=unsafe_security_accept_template_url, ) + # if the template is a trusted Algorand template that has _tasks defined in copier.yml (e.g: fullstack template) + # we need to set the unsafe_security_accept_template_url to true for copier worker to trust the template + if not unsafe_security_accept_template_url: + unsafe_security_accept_template_url = _safe_template(template.url) + logger.debug(f"template source = {template}") project_path = _get_project_path(directory_name) @@ -403,6 +408,10 @@ def _get_template( return template +def _safe_template(url: str) -> bool: + return url.startswith(("gh:algorandfoundation/", "https://github.com/algorandfoundation/")) + + class GitRepoValidator(questionary.Validator): def validate(self, document: prompt_toolkit.document.Document) -> None: value = document.text.strip() From 125a9240d8f87ae7c098003416496133b8b12422 Mon Sep 17 00:00:00 2001 From: Negar Abbasi Date: Thu, 2 Nov 2023 16:42:54 +1000 Subject: [PATCH 07/12] fix: accepting path to algorand templates as a safe template --- src/algokit/cli/init.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/algokit/cli/init.py b/src/algokit/cli/init.py index db270fa5..ebdfd5d9 100644 --- a/src/algokit/cli/init.py +++ b/src/algokit/cli/init.py @@ -1,6 +1,7 @@ import logging import re import shutil +import subprocess from dataclasses import dataclass from pathlib import Path from typing import NoReturn @@ -207,7 +208,7 @@ def init_command( # noqa: PLR0913 # if the template is a trusted Algorand template that has _tasks defined in copier.yml (e.g: fullstack template) # we need to set the unsafe_security_accept_template_url to true for copier worker to trust the template if not unsafe_security_accept_template_url: - unsafe_security_accept_template_url = _safe_template(template.url) + unsafe_security_accept_template_url = _is_algorand_foundation_repo(template.url) logger.debug(f"template source = {template}") @@ -408,8 +409,20 @@ def _get_template( return template -def _safe_template(url: str) -> bool: - return url.startswith(("gh:algorandfoundation/", "https://github.com/algorandfoundation/")) +def _is_algorand_foundation_repo(url: str) -> bool: + url = url.replace("gh:", "https://github.com/").replace("gl:", "https://gitlab.com/") + http_ssh_match = re.match(r"(https?|git)://([^/]+)/([^/]+)", url) + if http_ssh_match: + domain, path = http_ssh_match.group(2), http_ssh_match.group(3) + return domain in {"github.com", "gitlab.com"} and path.startswith("algorandfoundation") + + if url.startswith(("/", "~", "\\"): + try: + remote_url = subprocess.check_output(["git", "-C", url, "remote", "get-url", "origin"], text=True).strip() + return _is_algorand_foundation_repo(remote_url) + except subprocess.CalledProcessError: + return False + return False class GitRepoValidator(questionary.Validator): From 14f5b0bb19ca2ccc7e88dc77772a66411b3fdd7a Mon Sep 17 00:00:00 2001 From: Negar Abbasi Date: Mon, 6 Nov 2023 11:14:37 +1000 Subject: [PATCH 08/12] fix: fix on unsafe mode of copier --- src/algokit/cli/init.py | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/src/algokit/cli/init.py b/src/algokit/cli/init.py index ebdfd5d9..ea61961d 100644 --- a/src/algokit/cli/init.py +++ b/src/algokit/cli/init.py @@ -1,7 +1,6 @@ import logging import re import shutil -import subprocess from dataclasses import dataclass from pathlib import Path from typing import NoReturn @@ -205,12 +204,6 @@ def init_command( # noqa: PLR0913 commit=template_url_ref, unsafe_security_accept_template_url=unsafe_security_accept_template_url, ) - # if the template is a trusted Algorand template that has _tasks defined in copier.yml (e.g: fullstack template) - # we need to set the unsafe_security_accept_template_url to true for copier worker to trust the template - if not unsafe_security_accept_template_url: - unsafe_security_accept_template_url = _is_algorand_foundation_repo(template.url) - - logger.debug(f"template source = {template}") project_path = _get_project_path(directory_name) logger.debug(f"project path = {project_path}") @@ -234,7 +227,7 @@ def init_command( # noqa: PLR0913 data=answers_dict, quiet=True, vcs_ref=template.commit, - unsafe=unsafe_security_accept_template_url, + unsafe=True, ) as copier_worker: if use_defaults: populate_default_answers(copier_worker) @@ -409,22 +402,6 @@ def _get_template( return template -def _is_algorand_foundation_repo(url: str) -> bool: - url = url.replace("gh:", "https://github.com/").replace("gl:", "https://gitlab.com/") - http_ssh_match = re.match(r"(https?|git)://([^/]+)/([^/]+)", url) - if http_ssh_match: - domain, path = http_ssh_match.group(2), http_ssh_match.group(3) - return domain in {"github.com", "gitlab.com"} and path.startswith("algorandfoundation") - - if url.startswith(("/", "~", "\\"): - try: - remote_url = subprocess.check_output(["git", "-C", url, "remote", "get-url", "origin"], text=True).strip() - return _is_algorand_foundation_repo(remote_url) - except subprocess.CalledProcessError: - return False - return False - - class GitRepoValidator(questionary.Validator): def validate(self, document: prompt_toolkit.document.Document) -> None: value = document.text.strip() From a36bd3561639bdd384bf2a9b7f88618fceb4d165 Mon Sep 17 00:00:00 2001 From: Negar Abbasi Date: Mon, 6 Nov 2023 11:23:04 +1000 Subject: [PATCH 09/12] fix: add a logger debug for template and revert a test --- src/algokit/cli/init.py | 1 + tests/init/test_init.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/algokit/cli/init.py b/src/algokit/cli/init.py index ea61961d..16e0b4de 100644 --- a/src/algokit/cli/init.py +++ b/src/algokit/cli/init.py @@ -204,6 +204,7 @@ def init_command( # noqa: PLR0913 commit=template_url_ref, unsafe_security_accept_template_url=unsafe_security_accept_template_url, ) + logger.debug(f"template source = {template}") project_path = _get_project_path(directory_name) logger.debug(f"project path = {project_path}") diff --git a/tests/init/test_init.py b/tests/init/test_init.py index b192b87c..7b402645 100644 --- a/tests/init/test_init.py +++ b/tests/init/test_init.py @@ -560,7 +560,7 @@ def test_init_with_official_template_name_and_hash(tmp_path_factory: TempPathFac cwd = tmp_path_factory.mktemp("cwd") result = invoke( - "init --name myapp --no-git --template beaker_with_version --UNSAFE-SECURITY-accept-template-url" + "init --name myapp --no-git --template beaker_with_version" " --defaults -a run_poetry_install False -a author_name None -a author_email None ", cwd=cwd, ) From ac2b15c15e9a3edb098f27affe0a80fa5c5509a4 Mon Sep 17 00:00:00 2001 From: Negar Abbasi Date: Mon, 6 Nov 2023 13:18:05 +1000 Subject: [PATCH 10/12] test: more test cases on passing a url --- tests/init/test_init.py | 74 +++++++++++++++++++ ...ate_url_get_community_warning.approved.txt | 4 + ...ate_url_get_community_warning.approved.txt | 16 ++++ ...unity_warning_with_unsafe_tag.approved.txt | 15 ++++ 4 files changed, 109 insertions(+) create mode 100644 tests/init/test_init.test_init_blessed_template_url_get_community_warning.approved.txt create mode 100644 tests/init/test_init.test_init_with_any_template_url_get_community_warning.approved.txt create mode 100644 tests/init/test_init.test_init_with_any_template_url_get_community_warning_with_unsafe_tag.approved.txt diff --git a/tests/init/test_init.py b/tests/init/test_init.py index 7b402645..e3f3d09f 100644 --- a/tests/init/test_init.py +++ b/tests/init/test_init.py @@ -499,6 +499,80 @@ def test_init_template_url_and_ref(tmp_path_factory: TempPathFactory, mocker: Mo assert mock_copier_worker_cls.call_args.kwargs["vcs_ref"] == ref +def test_init_blessed_template_url_get_community_warning( + tmp_path_factory: TempPathFactory, mock_questionary_input: PipeInput +) -> None: + cwd = tmp_path_factory.mktemp("cwd") + + mock_questionary_input.send_text("N") # community warning + result = invoke( + "init --name myapp --no-git " + "--template-url gh:algorandfoundation/algokit-beaker-default-template --defaults " + "-a author_name None -a author_email None ", + cwd=cwd, + ) + + assert result.exit_code == 1 + verify(result.output, scrubber=make_output_scrubber()) + + +def test_init_with_any_template_url_get_community_warning( + tmp_path_factory: TempPathFactory, mock_questionary_input: PipeInput +) -> None: + cwd = tmp_path_factory.mktemp("cwd") + mock_questionary_input.send_text("Y") + result = invoke( + "init --name myapp --no-git --no-bootstrap " + "--template-url gh:algorandfoundation/algokit-beaker-default-template --defaults " + "-a author_name None -a author_email None ", + cwd=cwd, + ) + + assert result.exit_code == 0 + paths = {p.relative_to(cwd) for p in cwd.rglob("*")} + assert paths.issuperset( + { + Path("myapp"), + Path("myapp") / "README.md", + Path("myapp") / "smart_contracts", + } + ) + env_template_file_contents = (cwd / "myapp" / ".env.template").read_text() + verify( + get_combined_verify_output( + result.output, additional_name=".env.template", additional_output=env_template_file_contents + ), + scrubber=make_output_scrubber(), + ) + + +def test_init_with_any_template_url_get_community_warning_with_unsafe_tag(tmp_path_factory: TempPathFactory) -> None: + cwd = tmp_path_factory.mktemp("cwd") + result = invoke( + "init --name myapp --no-git --no-bootstrap " + "--template-url gh:algorandfoundation/algokit-beaker-default-template --defaults " + "-a author_name None -a author_email None --UNSAFE-SECURITY-accept-template-url", + cwd=cwd, + ) + + assert result.exit_code == 0 + paths = {p.relative_to(cwd) for p in cwd.rglob("*")} + assert paths.issuperset( + { + Path("myapp"), + Path("myapp") / "README.md", + Path("myapp") / "smart_contracts", + } + ) + env_template_file_contents = (cwd / "myapp" / ".env.template").read_text() + verify( + get_combined_verify_output( + result.output, additional_name=".env.template", additional_output=env_template_file_contents + ), + scrubber=make_output_scrubber(), + ) + + def test_init_no_community_template(tmp_path_factory: TempPathFactory, mock_questionary_input: PipeInput) -> None: cwd = tmp_path_factory.mktemp("cwd") diff --git a/tests/init/test_init.test_init_blessed_template_url_get_community_warning.approved.txt b/tests/init/test_init.test_init_blessed_template_url_get_community_warning.approved.txt new file mode 100644 index 00000000..fb0f9b18 --- /dev/null +++ b/tests/init/test_init.test_init_blessed_template_url_get_community_warning.approved.txt @@ -0,0 +1,4 @@ +WARNING: Community templates have not been reviewed, and can execute arbitrary code. +Please inspect the template repository, and pay particular attention to the values of _tasks, _migrations and _jinja_extensions in copier.yml +? Continue anyway? (y/N) +🛑 Bailing out... 👋 diff --git a/tests/init/test_init.test_init_with_any_template_url_get_community_warning.approved.txt b/tests/init/test_init.test_init_with_any_template_url_get_community_warning.approved.txt new file mode 100644 index 00000000..126224ef --- /dev/null +++ b/tests/init/test_init.test_init_with_any_template_url_get_community_warning.approved.txt @@ -0,0 +1,16 @@ +WARNING: Community templates have not been reviewed, and can execute arbitrary code. +Please inspect the template repository, and pay particular attention to the values of _tasks, _migrations and _jinja_extensions in copier.yml +? Continue anyway? (y/N) +DEBUG: template source = gh:algorandfoundation/algokit-beaker-default-template +DEBUG: project path = {current_working_directory}/myapp +Starting template copy and render... +DEBUG: final clone URL = https://github.com/algorandfoundation/algokit-beaker-default-template.git +Template render complete! +🙌 Project initialized at `myapp`! For template specific next steps, consult the documentation of your selected template 🧐 +Your selected template comes from: +➡️ https://github.com/algorandfoundation/algokit-beaker-default-template +Your template includes a README.md file, you might want to review that as a next step. +---- +.env.template: +---- +# this file should contain environment variables common to all environments/networks diff --git a/tests/init/test_init.test_init_with_any_template_url_get_community_warning_with_unsafe_tag.approved.txt b/tests/init/test_init.test_init_with_any_template_url_get_community_warning_with_unsafe_tag.approved.txt new file mode 100644 index 00000000..0a9f7a89 --- /dev/null +++ b/tests/init/test_init.test_init_with_any_template_url_get_community_warning_with_unsafe_tag.approved.txt @@ -0,0 +1,15 @@ +WARNING: Community templates have not been reviewed, and can execute arbitrary code. +Please inspect the template repository, and pay particular attention to the values of _tasks, _migrations and _jinja_extensions in copier.yml +DEBUG: template source = gh:algorandfoundation/algokit-beaker-default-template +DEBUG: project path = {current_working_directory}/myapp +Starting template copy and render... +DEBUG: final clone URL = https://github.com/algorandfoundation/algokit-beaker-default-template.git +Template render complete! +🙌 Project initialized at `myapp`! For template specific next steps, consult the documentation of your selected template 🧐 +Your selected template comes from: +➡️ https://github.com/algorandfoundation/algokit-beaker-default-template +Your template includes a README.md file, you might want to review that as a next step. +---- +.env.template: +---- +# this file should contain environment variables common to all environments/networks From ce9fd61a5e4a890e3e6c0a246412bf4b8468a1e6 Mon Sep 17 00:00:00 2001 From: Negar Abbasi Date: Wed, 8 Nov 2023 11:58:49 +1000 Subject: [PATCH 11/12] chore: ignoring aiohttp vulnerability --- .github/workflows/check-python.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-python.yaml b/.github/workflows/check-python.yaml index c728fe29..8de12e30 100644 --- a/.github/workflows/check-python.yaml +++ b/.github/workflows/check-python.yaml @@ -31,7 +31,7 @@ jobs: # If a vulnerability is found in a dev dependency without an available fix, # it can be temporarily ignored by adding --ignore-vuln e.g. # --ignore-vuln "GHSA-hcpj-qp55-gfph" # GitPython vulnerability, dev only dependency - poetry run pip-audit --ignore-vuln "GHSA-wfm5-v35h-vwf4" --ignore-vuln "GHSA-cwvm-v4w8-q58c" + poetry run pip-audit --ignore-vuln "GHSA-wfm5-v35h-vwf4" --ignore-vuln "GHSA-cwvm-v4w8-q58c" --ignore-vuln "PYSEC-2022-43059" - name: Check formatting with Black run: | From 8293f993e897edc8bb5bb9df2935cbf0d68aa6cf Mon Sep 17 00:00:00 2001 From: Negar Abbasi Date: Wed, 8 Nov 2023 12:13:59 +1000 Subject: [PATCH 12/12] chore: ignoring aiohttp vulnerability --- .github/workflows/check-python.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check-python.yaml b/.github/workflows/check-python.yaml index 8de12e30..7d7d6d79 100644 --- a/.github/workflows/check-python.yaml +++ b/.github/workflows/check-python.yaml @@ -25,7 +25,8 @@ jobs: - name: Audit with pip-audit run: | # audit non dev dependencies, no exclusions - poetry export --without=dev > requirements.txt && poetry run pip-audit -r requirements.txt + # This is a temporary fix for PYSEC-2022-43059 as the vulnerability is withdrawn. See https://github.com/pypa/advisory-database/pull/169 + poetry export --without=dev > requirements.txt && poetry run pip-audit -r requirements.txt --ignore-vuln "PYSEC-2022-43059" # audit all dependencies, with exclusions. # If a vulnerability is found in a dev dependency without an available fix,