Skip to content

Commit

Permalink
fix: create the npm dir in the app data directory on windows, as npx …
Browse files Browse the repository at this point in the history
…needs it (#458)

* fix: create the npm dir in the app data directory on windows, as npx needs it
  • Loading branch information
neilcampbell authored Mar 19, 2024
1 parent 4560c9d commit 3195a1c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/algokit/core/typed_client_generation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import abc
import json
import logging
import os
import re
import shutil
from pathlib import Path
Expand Down Expand Up @@ -98,6 +99,25 @@ def __init__(self) -> None:
if not npx_path:
raise click.ClickException("Typescript generator requires Node.js and npx to be installed.")

# Create the npm directory inside %APPDATA% if it doesn't exist, as npx on windows needs this.
# See https://github.com/npm/cli/issues/7089 for more details.
if is_windows():
appdata_dir = os.getenv("APPDATA")
if appdata_dir is not None:
appdata_dir_path = Path(appdata_dir).expanduser()
npm_dir = appdata_dir_path / "npm"
try:
if not npm_dir.exists():
npm_dir.mkdir(parents=True)
except OSError as ex:
logger.debug(ex)
raise click.ClickException(
f"Failed to create the `npm` directory in {appdata_dir_path}.\n"
"This command uses `npx`, which requires the `npm` directory to exist "
"in the above path, otherwise an ENOENT 4058 error will occur.\n"
"Please create this directory manually and try again."
) from ex

def generate(self, app_spec: Path, output: Path) -> None:
cmd = [
"npx" if not is_windows() else "npx.cmd",
Expand Down

1 comment on commit 3195a1c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/algokit
   __init__.py15753%6–13, 17–24, 32–34
   __main__.py440%1–7
src/algokit/cli
   completions.py108298%83, 98
   deploy.py72790%44, 46, 92–94, 158, 182
   dispenser.py121199%77
   doctor.py49394%143–145
   explore.py501276%34–39, 41–46
   generate.py67396%74–75, 140
   goal.py44198%71
   init.py2752591%384–385, 440, 443–445, 456, 460, 516, 542, 571, 604, 613–615, 618–623, 636, 653, 665–666, 683–686
   localnet.py1191587%74–78, 111, 123, 138–148, 161, 206, 227–228
   task.py34391%25–28
src/algokit/cli/common
   utils.py26292%120, 123
src/algokit/cli/tasks
   analyze.py81199%81
   assets.py821384%65–66, 72, 74–75, 105, 119, 125–126, 132, 134, 136–137
   ipfs.py51884%52, 80, 92, 94–95, 105–107
   mint.py66494%48, 70, 91, 250
   send_transaction.py651085%52–53, 57, 89, 158, 170–174
   sign_transaction.py59886%21, 28–30, 71–72, 109, 123
   transfer.py39392%26, 90, 117
   utils.py994555%26–34, 40–43, 75–76, 100–101, 125–133, 152–162, 209, 258–259, 279–290, 297–299
   vanity_address.py561082%41, 45–48, 112, 114, 121–123
   wallet.py79495%21, 66, 136, 162
src/algokit/core
   bootstrap.py1171191%41, 105–106, 128, 155, 183–188
   conf.py661577%12, 24, 28, 36, 38, 72–74, 92–100
   deploy.py691184%61–64, 73–75, 79, 84, 91–93
   dispenser.py2022687%91, 123–124, 141–149, 191–192, 198–200, 218–219, 259–260, 318, 332–334, 345–346, 356, 369, 384
   doctor.py65789%67–69, 92–94, 134
   generate.py48394%44, 81, 99
   goal.py60395%30–31, 41
   init.py39685%59, 63–68, 76
   log_handlers.py68790%50–51, 63, 112–116, 125
   proc.py45198%98
   sandbox.py2181892%62, 73–75, 96, 142–149, 160, 457, 473, 498, 506
   typed_client_generation.py921386%57–59, 72, 77, 107–114
   utils.py1073072%44–45, 49–68, 129, 132, 138–151
   version_prompt.py921485%37–38, 68, 87–90, 108, 118–125, 148
src/algokit/core/compile
   python.py31584%19–20, 25, 48–49
src/algokit/core/tasks
   analyze.py93397%105–112, 187
   ipfs.py63789%58–64, 140, 144, 146, 152
   nfd.py491373%25, 31, 34–41, 70–72, 99–101
   vanity_address.py903462%49–50, 54, 59–75, 92–108, 128–131
   wallet.py71593%37, 129, 155–157
src/algokit/core/tasks/mint
   mint.py781087%123–133, 187
   models.py901188%50, 52, 57, 71–74, 85–88
TOTAL370044488% 

Tests Skipped Failures Errors Time
428 0 💤 0 ❌ 0 🔥 27.690s ⏱️

Please sign in to comment.