Skip to content

Commit a4d429d

Browse files
committed
node: Added -S option to set the split size
Signed-off-by: Hubert Figuière <[email protected]>
1 parent 8ac44d5 commit a4d429d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

node/flatpak_node_generator/main.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ async def _async_main() -> None:
9595
action='store_true',
9696
help='Split the sources file to fit onto GitHub.',
9797
)
98+
parser.add_argument(
99+
'-S',
100+
'--split-size',
101+
type=int,
102+
default=49 * 1000, # GITHUB has 49MB limit.
103+
dest='split_size',
104+
help='If splitting the sources file, split at this size in KB. Default is 49000KB.',
105+
)
98106
parser.add_argument(
99107
'--node-chromedriver-from-electron',
100108
help='Use the ChromeDriver version associated with the given '
@@ -206,6 +214,7 @@ async def _async_main() -> None:
206214
print(f'{len(packages)} packages read.')
207215

208216
gen = ManifestGenerator()
217+
gen.split_size = args.split_size * 1000
209218
with gen:
210219
options = SpecialSourceProvider.Options(
211220
node_chromedriver_from_electron=args.node_chromedriver_from_electron
@@ -267,7 +276,7 @@ async def _async_main() -> None:
267276
indent=ManifestGenerator.JSON_INDENT,
268277
)
269278

270-
if fp.tell() >= ManifestGenerator.MAX_GITHUB_SIZE:
279+
if fp.tell() >= gen.split_size:
271280
print(
272281
'WARNING: generated-sources.json is too large for GitHub.',
273282
file=sys.stderr,

node/flatpak_node_generator/manifest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def __init__(self) -> None:
2727
# That way, we ensure uniqueness.
2828
self._sources: Set[Tuple[Tuple[str, Any], ...]] = set()
2929
self._commands: List[str] = []
30+
self.split_size = ManifestGenerator.MAX_GITHUB_SIZE
3031

3132
def __exit__(
3233
self,
@@ -66,7 +67,7 @@ def split_sources(self) -> Iterator[List[Dict[Any, Any]]]:
6667
# opening brackets.
6768
source_json = json.dumps([source], indent=ManifestGenerator.JSON_INDENT)
6869
source_json_len = len('\n'.join(source_json.splitlines()[1:-1]))
69-
if current_size + source_json_len >= ManifestGenerator.MAX_GITHUB_SIZE:
70+
if current_size + source_json_len >= self.split_size:
7071
yield current
7172
current = []
7273
current_size = BASE_CURRENT_SIZE

0 commit comments

Comments
 (0)