Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the npm/yarn install for mac users #183

Merged
merged 1 commit into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Add documentation cookbook for using pg_activity
* Forward CI env vars in Docker containers
* Run the npm/yarn/webpack commands on the host for all mac users (even the ones not using Dinghy)

## 3.7.0 (2022-05-24)

Expand Down
3 changes: 3 additions & 0 deletions invoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
'builder',
]
dinghy = False
macos = False
power_shell = False
user_id = 1000
root_dir = '.'
Expand All @@ -46,6 +47,8 @@ def __extract_runtime_configuration(config):
config['composer_cache_dir'] = composer_cache_dir_from_host.strip()

if platform == "darwin":
config['macos'] = True

try:
docker_kernel = run('docker version --format "{{.Server.KernelVersion}}"', hide=True).stdout
except:
Expand Down
8 changes: 4 additions & 4 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ def install(c):
if os.path.isfile(c.root_dir + '/' + c.project_directory + '/composer.json'):
docker_compose_run(c, 'composer install -n --prefer-dist --optimize-autoloader', no_deps=True)
if os.path.isfile(c.root_dir + '/' + c.project_directory + '/yarn.lock'):
run_in_docker_or_locally_for_dinghy(c, 'yarn', no_deps=True)
run_in_docker_or_locally_for_mac(c, 'yarn', no_deps=True)
elif os.path.isfile(c.root_dir + '/' + c.project_directory + '/package.json'):
run_in_docker_or_locally_for_dinghy(c, 'npm install', no_deps=True)
run_in_docker_or_locally_for_mac(c, 'npm install', no_deps=True)


@task
Expand Down Expand Up @@ -244,11 +244,11 @@ def generate_certificates(c, force=False):
print('Please restart the infrastructure to use the new certificates with "inv up" or "inv start".')


def run_in_docker_or_locally_for_dinghy(c, command, no_deps=False):
def run_in_docker_or_locally_for_mac(c, command, no_deps=False):
"""
Mac users have a lot of problems running Yarn / Webpack on the Docker stack so this func allow them to run these tools on their host
"""
if c.dinghy:
if c.macos:
with c.cd(c.project_directory):
c.run(command)
else:
Expand Down