Skip to content

Commit

Permalink
Yarn: skip unplugging dependencies in the regular workflow
Browse files Browse the repository at this point in the history
Set the "enableScripts" .yarnrc.yml option to false, which avoids the
unplugging of dependencies that have postinstall scripts.

The unplugged content is necessary for the Yarn project to run, but
since a "yarn install" is expected to happen during the build phase for
a regular workflow project, this content will still be generated as
expected.

For more info, see:
- https://v3.yarnpkg.com/cli/install (--mode=skip-build section)

Signed-off-by: Bruno Pimentel <[email protected]>
  • Loading branch information
brunoapimentel committed Nov 7, 2023
1 parent efd2695 commit 258e04e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions cachi2/core/package_managers/yarn/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def _set_yarnrc_configuration(project: Project, output_dir: RootedPath) -> None:
yarn_rc.enable_immutable_cache = True
else:
yarn_rc.enable_mirror = True
yarn_rc.enable_scripts = False
yarn_rc.global_folder = str(output_dir)

yarn_rc.write()
Expand Down
9 changes: 9 additions & 0 deletions cachi2/core/package_managers/yarn/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ def enable_mirror(self) -> Optional[bool]:
def enable_mirror(self, enable_mirror: Optional[bool]) -> None:
self._data["enableMirror"] = enable_mirror

@property
def enable_scripts(self) -> Optional[bool]:
"""Get the enableScripts configuration."""
return self._data.get("enableScripts", None)

@enable_scripts.setter
def enable_scripts(self, enable_scripts: Optional[bool]) -> None:
self._data["enableScripts"] = enable_scripts

@property
def enable_strict_ssl(self) -> Optional[bool]:
"""Get the enableStrictSsl configuration."""
Expand Down
1 change: 1 addition & 0 deletions tests/unit/package_managers/yarn/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def test_set_yarnrc_configuration(mock_write: mock.Mock, is_zero_installs: bool)
expected_data["enableImmutableCache"] = True
else:
expected_data["enableMirror"] = True
expected_data["enableScripts"] = False
expected_data["globalFolder"] = "/tmp/output"

assert yarn_rc._data == expected_data
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/package_managers/yarn/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
enableImmutableInstalls: true
enableInlineBuilds: true
enableMirror: false
enableScripts: false
enableStrictSsl: false
enableTelemetry: false
globalFolder: /a/global/folder
Expand Down Expand Up @@ -83,6 +84,7 @@ def test_parse_yarnrc(rooted_tmp_path: RootedPath) -> None:
assert yarn_rc.enable_immutable_cache is True
assert yarn_rc.enable_immutable_installs is True
assert yarn_rc.enable_mirror is False
assert yarn_rc.enable_scripts is False
assert yarn_rc.enable_strict_ssl is False
assert yarn_rc.enable_telemetry is False
assert yarn_rc.global_folder == "/a/global/folder"
Expand All @@ -103,6 +105,7 @@ def test_parse_empty_yarnrc(rooted_tmp_path: RootedPath) -> None:
assert yarn_rc.enable_immutable_cache is None
assert yarn_rc.enable_immutable_installs is None
assert yarn_rc.enable_mirror is None
assert yarn_rc.enable_scripts is None
assert yarn_rc.enable_strict_ssl is None
assert yarn_rc.enable_telemetry is None
assert yarn_rc.global_folder is None
Expand Down

0 comments on commit 258e04e

Please sign in to comment.