Skip to content

Commit c7da61c

Browse files
committed
More Changes Needed to Support Lumino
1 parent 9a791b4 commit c7da61c

File tree

4 files changed

+26
-37
lines changed

4 files changed

+26
-37
lines changed

jupyter_releaser/cli.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -295,19 +295,14 @@ def build_python(dist_dir):
295295

296296
@main.command()
297297
@add_options(dist_dir_options)
298-
@click.option(
299-
"--test-cmd",
300-
envvar="RH_PY_TEST_COMMAND",
301-
help="The command to run in the test venvs",
302-
)
303298
@use_checkout_dir()
304-
def check_python(dist_dir, test_cmd):
299+
def check_python(dist_dir):
305300
"""Check Python dist files"""
306301
for dist_file in glob(f"{dist_dir}/*"):
307302
if Path(dist_file).suffix not in [".gz", ".whl"]:
308303
util.log(f"Skipping non-python dist file {dist_file}")
309304
continue
310-
python.check_dist(dist_file, test_cmd=test_cmd)
305+
python.check_dist(dist_file)
311306

312307

313308
@main.command()
@@ -324,18 +319,13 @@ def build_npm(package, dist_dir):
324319

325320
@main.command()
326321
@add_options(dist_dir_options)
327-
@click.option(
328-
"--test-cmd",
329-
envvar="RH_NPM_TEST_COMMAND",
330-
help="The command to run in isolated install.",
331-
)
332322
@use_checkout_dir()
333-
def check_npm(dist_dir, test_cmd):
323+
def check_npm(dist_dir):
334324
"""Check npm package"""
335325
if not osp.exists("./package.json"):
336326
util.log("Skipping check-npm since there is no package.json file")
337327
return
338-
npm.check_dist(dist_dir, test_cmd=test_cmd)
328+
npm.check_dist(dist_dir)
339329

340330

341331
@main.command()

jupyter_releaser/npm.py

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ def build_dist(package, dist_dir):
4242

4343
if "workspaces" in data:
4444
all_data = dict()
45-
packages = data["workspaces"].get("packages", [])
46-
for pattern in packages:
45+
for pattern in _get_workspace_packages(data):
4746
for path in glob(osp.join(basedir, pattern), recursive=True):
4847
path = Path(path)
4948
package_json = path / "package.json"
@@ -91,16 +90,18 @@ def extract_dist(dist_dir, target):
9190
tar.extractall(target)
9291
tar.close()
9392

93+
if "main" in data:
94+
main = osp.join(target, "package", data["main"])
95+
if not osp.exists(main):
96+
raise ValueError(f"{name} is missing 'main' file {data['main']}")
97+
9498
shutil.move(str(target / "package"), str(pkg_dir))
9599

96100
return names
97101

98102

99-
def check_dist(dist_dir, test_cmd=None):
103+
def check_dist(dist_dir):
100104
"""Check npm dist file(s) in a dist dir"""
101-
if not test_cmd:
102-
test_cmd = "node index.js"
103-
104105
tmp_dir = Path(TemporaryDirectory().name)
105106
os.makedirs(tmp_dir)
106107

@@ -114,11 +115,6 @@ def check_dist(dist_dir, test_cmd=None):
114115

115116
util.run(f"npm install {install_str}", cwd=tmp_dir)
116117

117-
text = "\n".join([f'require("{name}")' for name in names])
118-
tmp_dir.joinpath("index.js").write_text(text, encoding="utf-8")
119-
120-
util.run(test_cmd, cwd=tmp_dir)
121-
122118
shutil.rmtree(str(tmp_dir), ignore_errors=True)
123119

124120

@@ -152,15 +148,7 @@ def get_package_versions(version):
152148
message += f'\nnpm version: {data["name"]}: {data["version"]}'
153149
if "workspaces" in data:
154150
message += "\nnpm workspace versions:"
155-
156-
if isinstance(data["workspaces"], dict):
157-
packages = []
158-
for value in data["workspaces"].values():
159-
packages.extend(value)
160-
else:
161-
packages = data["workspaces"]
162-
163-
for pattern in packages:
151+
for pattern in _get_workspace_packages(data):
164152
for path in glob(pattern, recursive=True):
165153
text = Path(path).joinpath("package.json").read_text()
166154
data = json.loads(text)
@@ -178,8 +166,7 @@ def tag_workspace_packages():
178166
if not "workspaces" in data:
179167
return
180168

181-
packages = data["workspaces"].get("packages", [])
182-
for pattern in packages:
169+
for pattern in _get_workspace_packages(data):
183170
for path in glob(pattern, recursive=True):
184171
sub_package_json = Path(path) / "package.json"
185172
sub_data = json.loads(sub_package_json.read_text(encoding="utf-8"))
@@ -188,3 +175,14 @@ def tag_workspace_packages():
188175
util.log(f"Skipping existing tag {tag_name}")
189176
else:
190177
util.run(f"git tag {tag_name}")
178+
179+
180+
def _get_workspace_packages(data):
181+
"""Get the workspace packages for a package given package data"""
182+
if isinstance(data["workspaces"], dict):
183+
packages = []
184+
for value in data["workspaces"].values():
185+
packages.extend(value)
186+
else:
187+
packages = data["workspaces"]
188+
return packages

jupyter_releaser/tests/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,13 @@ def workspace_package(npm_package):
9999
pkg_json = new_dir / "package.json"
100100
sub_data = json.loads(pkg_json.read_text(encoding="utf-8"))
101101
sub_data["dependencies"] = dict(bar="*")
102+
sub_data["main"] = "index.js"
102103
pkg_json.write_text(json.dumps(sub_data), encoding="utf-8")
103104
elif name == "baz":
104105
pkg_json = new_dir / "package.json"
105106
sub_data = json.loads(pkg_json.read_text(encoding="utf-8"))
106107
sub_data["dependencies"] = dict(foo="*")
108+
sub_data["main"] = "index.js"
107109
pkg_json.write_text(json.dumps(sub_data), encoding="utf-8")
108110
os.chdir(prev_dir)
109111
util.run("git add .")

jupyter_releaser/tests/test_cli.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ def test_list_envvars(runner):
130130
repo: RH_REPOSITORY
131131
resolve-backports: RH_RESOLVE_BACKPORTS
132132
since: RH_SINCE
133-
test-cmd: RH_NPM_TEST_COMMAND
134133
twine-cmd: TWINE_COMMAND
135134
username: GITHUB_ACTOR
136135
version-cmd: RH_VERSION_COMMAND

0 commit comments

Comments
 (0)