Skip to content

Commit 7d2d27b

Browse files
author
baymer
committed
Добавить макрос INJECT_PEERS()
commit_hash:1284210f3d36c02044ff90213c56cd83c2a2a497
1 parent 33293a9 commit 7d2d27b

File tree

11 files changed

+73
-25
lines changed

11 files changed

+73
-25
lines changed

build/conf/ts/a.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,8 @@ ci:
6060
redirect_stderr_to_stdout: true
6161
stdout_ci_badge: true
6262
cmd_line: |
63-
set -ex
64-
grep -r 'TS_USE_PREBUILT_NOTS_TOOL=yes' $ARCADIA_PATH/build/conf/ts/ts.conf
63+
set -x
64+
if grep -r 'TS_USE_PREBUILT_NOTS_TOOL=no' $ARCADIA_PATH/build/conf/ts/ts.conf; then
65+
echo "TS_USE_PREBUILT_NOTS_TOOL=no found in ts.conf"
66+
exit 1
67+
fi

build/conf/ts/node_modules.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ _NODE_MODULES_INOUTS=
99
_NODE_MODULES_BUNDLE_ARG=
1010
_YATOOL_PREBUILDER_ARG=
1111
_USE_LEGACY_PNPM_VIRTUAL_STORE_ARG=
12+
_INJECT_PEERS_ARG=
1213

1314
macro _TS_ADD_NODE_MODULES_FOR_BUILDER() {
1415
# Calculate inputs and outputs of node_modules, fill `_NODE_MODULES_INOUTS` variable
@@ -82,3 +83,7 @@ macro USE_LEGACY_PNPM_VIRTUAL_STORE() {
8283
MESSAGE(WARN Module $MODDIR uses USE_LEGACY_PNPM_VIRTUAL_STORE(). Consider to fix your build to work without it.)
8384
SET(_USE_LEGACY_PNPM_VIRTUAL_STORE_ARG --use-legacy-pnpm-virtual-store yes)
8485
}
86+
87+
macro INJECT_PEERS() {
88+
SET(_INJECT_PEERS_ARG --inject-peers yes)
89+
}

build/conf/ts/ts.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ NOTS_TOOL_BASE_ARGS=\
4646
--nodejs-bin $NODEJS_BIN \
4747
--pm-script $PM_SCRIPT \
4848
--pm-type $PM_TYPE \
49+
$_INJECT_PEERS_ARG \
4950
$_YATOOL_PREBUILDER_ARG $_NODE_MODULES_BUNDLE_ARG $_USE_LEGACY_PNPM_VIRTUAL_STORE_ARG
5051

5152
NOTS_TOOL_BUILD_ENV=

build/plugins/lib/nots/package_manager/package_manager.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def __init__(
157157
script_path,
158158
module_path=None,
159159
sources_root=None,
160+
inject_peers=False,
160161
verbose=False,
161162
):
162163
self.module_path = build_path[len(build_root) + 1 :] if module_path is None else module_path
@@ -166,6 +167,7 @@ def __init__(
166167
self.sources_root = sources_path[: -len(self.module_path) - 1] if sources_root is None else sources_root
167168
self.nodejs_bin_path = nodejs_bin_path
168169
self.script_path = script_path
170+
self.inject_peers = inject_peers
169171
self.verbose = verbose
170172

171173
@classmethod
@@ -319,10 +321,12 @@ def create_node_modules(
319321

320322
# Pure `tier 0` logic - isolated stores in the `build_root` (works in `distbuild` and `CI autocheck`)
321323
store_dir = self._get_pnpm_store()
322-
virtual_store_dir = self._nm_path(VIRTUAL_STORE_DIRNAME) if use_legacy_pnpm_virtual_store else None
324+
virtual_store_dir = (
325+
self._nm_path(VIRTUAL_STORE_DIRNAME) if self.inject_peers or use_legacy_pnpm_virtual_store else None
326+
)
323327
global_virtual_store_dir = os.path.join(store_dir, "v10", "links")
324328

325-
self._run_pnpm_install(store_dir, self.build_path, local_cli, virtual_store_dir)
329+
self._run_pnpm_install(store_dir, self.build_path, local_cli, virtual_store_dir, self.inject_peers)
326330

327331
self._run_apply_addons_if_need(yatool_prebuilder_path, virtual_store_dir or global_virtual_store_dir)
328332
self._restore_original_lockfile(original_lf_path, virtual_store_dir)
@@ -353,7 +357,9 @@ def create_node_modules(
353357
"""
354358

355359
@timeit
356-
def _run_pnpm_install(self, store_dir: str, cwd: str, local_cli: bool, virtual_store_dir: str | None):
360+
def _run_pnpm_install(
361+
self, store_dir: str, cwd: str, local_cli: bool, virtual_store_dir: str | None, inject_peers: bool
362+
):
357363
# Use fcntl to lock a temp file
358364

359365
def execute_install_cmd():
@@ -379,6 +385,11 @@ def execute_install_cmd():
379385
else:
380386
install_cmd.extend(["--config.enableGlobalVirtualStore=true"])
381387

388+
if inject_peers:
389+
install_cmd.extend(
390+
["--config.injectWorkspacePackages=true", "--config.sharedWorkspaceLockfile=false", "--filter", "."]
391+
)
392+
382393
self._exec_command(install_cmd, cwd=cwd)
383394

384395
mutex_file = os.path.join(store_dir, LOCAL_PNPM_INSTALL_MUTEX_FILENAME)
@@ -519,10 +530,11 @@ def _build_merged_pre_lockfile(self, tarballs_store, dep_paths, local_cli: bool)
519530
if not local_cli:
520531
lf.update_tarball_resolutions(lambda p: self._tarballs_store_path(p, tarballs_store))
521532

522-
for dep_path in dep_paths:
523-
pre_lf_path = build_pre_lockfile_path(dep_path)
524-
if os.path.isfile(pre_lf_path):
525-
lf.merge(self.load_lockfile(pre_lf_path))
533+
if self.inject_peers is False:
534+
for dep_path in dep_paths:
535+
pre_lf_path = build_pre_lockfile_path(dep_path)
536+
if os.path.isfile(pre_lf_path):
537+
lf.merge(self.load_lockfile(pre_lf_path))
526538

527539
lf.write()
528540

build/plugins/nots.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ def _create_pm(unit: NotsUnitType) -> 'PackageManager':
410410
nodejs_bin_path=None,
411411
script_path=None,
412412
module_path=module_path,
413+
inject_peers=unit.get("_INJECT_PEERS_ARG") is not None,
413414
)
414415

415416

devtools/frontend_build_platform/nots/builder/api/create_node_modules.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def create_node_modules(args: BaseOptions, original_lf_path=None):
3131
sources_path=args.curdir,
3232
nodejs_bin_path=args.nodejs_bin,
3333
script_path=args.pm_script,
34+
inject_peers=args.inject_peers,
3435
verbose=args.verbose,
3536
)
3637

devtools/frontend_build_platform/nots/builder/api/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ class BaseOptions:
3434
use_legacy_pnpm_virtual_store: bool
3535
"""Use legacy pnpm virtual store"""
3636

37+
inject_peers: bool
38+
"""Inject peers"""
39+
3740
command: str
3841
"""builder `command` argument, used only in log messages"""
3942

devtools/frontend_build_platform/nots/builder/cli/cli_args.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ def register_base_args(parser: ArgumentParser) -> None:
4444
help="Use legacy pnpm virtual store",
4545
)
4646

47+
parser.add_argument(
48+
"--inject-peers",
49+
action=YesNoAction,
50+
required=False,
51+
default=False,
52+
help="Inject peers",
53+
)
54+
4755
# Flags
4856
parser.add_argument(
4957
'--local-cli', action=YesNoAction, default=False, help="Is run locally (from `nots`) or on the distbuild"

devtools/frontend_build_platform/nots/builder/cli/tests/test_cli_args.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def test_create_node_modules_args():
4545
pm_type='pnpm',
4646
yatool_prebuilder_path=None,
4747
use_legacy_pnpm_virtual_store=False,
48+
inject_peers=False,
4849
# Flags
4950
local_cli=False,
5051
nm_bundle=False,
@@ -86,6 +87,7 @@ def test_create_node_modules_bundle_args():
8687
pm_type='pnpm',
8788
yatool_prebuilder_path=None,
8889
use_legacy_pnpm_virtual_store=False,
90+
inject_peers=False,
8991
# Flags
9092
local_cli=False,
9193
nm_bundle=True,
@@ -130,6 +132,7 @@ def test_build_library_args():
130132
pm_type='pnpm',
131133
yatool_prebuilder_path=None,
132134
use_legacy_pnpm_virtual_store=False,
135+
inject_peers=False,
133136
env=['NODE_ENV=production'],
134137
# Flags
135138
local_cli=False,
@@ -174,6 +177,7 @@ def test_build_package_args():
174177
pm_type='pnpm',
175178
yatool_prebuilder_path=None,
176179
use_legacy_pnpm_virtual_store=False,
180+
inject_peers=False,
177181
env=[],
178182
# Flags
179183
local_cli=False,
@@ -220,6 +224,7 @@ def test_build_package_nm_args():
220224
pm_type='pnpm',
221225
yatool_prebuilder_path=None,
222226
use_legacy_pnpm_virtual_store=False,
227+
inject_peers=False,
223228
env=[],
224229
# Flags
225230
local_cli=False,
@@ -269,6 +274,7 @@ def test_build_tsc_args():
269274
yatool_prebuilder_path=None,
270275
env=[],
271276
use_legacy_pnpm_virtual_store=False,
277+
inject_peers=False,
272278
# Flags
273279
local_cli=True,
274280
nm_bundle=False,
@@ -319,6 +325,7 @@ def test_build_tsc_nm_args():
319325
yatool_prebuilder_path=None,
320326
env=[],
321327
use_legacy_pnpm_virtual_store=False,
328+
inject_peers=False,
322329
# Flags
323330
local_cli=True,
324331
nm_bundle=True,
@@ -371,6 +378,7 @@ def test_build_next_args():
371378
yatool_prebuilder_path=None,
372379
env=[],
373380
use_legacy_pnpm_virtual_store=False,
381+
inject_peers=False,
374382
# Flags
375383
local_cli=True,
376384
nm_bundle=False,
@@ -426,6 +434,7 @@ def test_build_vite_args():
426434
yatool_prebuilder_path=None,
427435
env=[],
428436
use_legacy_pnpm_virtual_store=False,
437+
inject_peers=False,
429438
# Flags
430439
local_cli=True,
431440
nm_bundle=False,
@@ -481,6 +490,7 @@ def test_build_webpack_args():
481490
yatool_prebuilder_path=None,
482491
env=[],
483492
use_legacy_pnpm_virtual_store=False,
493+
inject_peers=False,
484494
# Flags
485495
local_cli=True,
486496
nm_bundle=False,
@@ -540,6 +550,7 @@ def test_build_webpack_with_env_args():
540550
yatool_prebuilder_path=None,
541551
env=["VAR1=value", "VAR2=value"],
542552
use_legacy_pnpm_virtual_store=False,
553+
inject_peers=False,
543554
# Flags
544555
local_cli=True,
545556
nm_bundle=False,
@@ -601,6 +612,7 @@ def test_build_webpack_with_after_build():
601612
yatool_prebuilder_path=None,
602613
env=[],
603614
use_legacy_pnpm_virtual_store=False,
615+
inject_peers=False,
604616
# Flags
605617
local_cli=True,
606618
nm_bundle=False,
@@ -658,6 +670,7 @@ def test_build_rspack_args():
658670
yatool_prebuilder_path=None,
659671
env=[],
660672
use_legacy_pnpm_virtual_store=False,
673+
inject_peers=False,
661674
# Flags
662675
local_cli=True,
663676
nm_bundle=False,
@@ -707,6 +720,7 @@ def test_build_verbose_args():
707720
pm_type='pnpm',
708721
yatool_prebuilder_path=None,
709722
use_legacy_pnpm_virtual_store=False,
723+
inject_peers=False,
710724
env=[],
711725
# Flags
712726
local_cli=False,
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{
22
"info": {
3-
"created": "2026-02-09T08:19:15Z",
3+
"created": "2026-02-13T15:46:23.940Z",
44
"pr": {
5-
"id": 11625411,
6-
"author": "zaverden",
7-
"summary": "feat(builder): use --dry-run for pnpm pack"
5+
"id": 11691246,
6+
"author": "baymer",
7+
"summary": "FBP-2876: Добавить макрос INJECT_PEERS()"
88
}
99
},
1010
"by_platform": {
1111
"darwin": {
12-
"uri": "sbr:11040849860"
12+
"uri": "sbr:11099087810"
1313
},
1414
"darwin-arm64": {
15-
"uri": "sbr:11040847294"
15+
"uri": "sbr:11099085339"
1616
},
1717
"linux": {
18-
"uri": "sbr:11040854947"
18+
"uri": "sbr:11099093175"
1919
},
2020
"linux-aarch64": {
21-
"uri": "sbr:11040852393"
21+
"uri": "sbr:11099090229"
2222
}
2323
}
2424
}

0 commit comments

Comments
 (0)