Skip to content

fix: add missing arguments to commands.py #5299

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

Merged
merged 4 commits into from
Jul 30, 2025
Merged
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
56 changes: 23 additions & 33 deletions commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,27 +244,10 @@ def update_plotlyjs(plotly_js_version, outdir):


# FIXME: switch to argparse
def update_schema_bundle_from_master():
def update_schema_bundle_from_master(args):
"""Update the plotly.js schema and bundle from master."""

if "--devrepo" in sys.argv:
devrepo = sys.argv[sys.argv.index("--devrepo") + 1]
else:
devrepo = "plotly/plotly.js"

if "--devbranch" in sys.argv:
devbranch = sys.argv[sys.argv.index("--devbranch") + 1]
else:
devbranch = "master"

if "--local" in sys.argv:
local = sys.argv[sys.argv.index("--local") + 1]
else:
local = None

if local is None:
build_info = get_latest_publish_build_info(devrepo, devbranch)

if args.local is None:
build_info = get_latest_publish_build_info(args.devrepo, args.devbranch)
archive_url, bundle_url, schema_url = get_bundle_schema_urls(
build_info["build_num"]
)
Expand All @@ -275,14 +258,14 @@ def update_schema_bundle_from_master():
# Update schema in package data
overwrite_schema(schema_url)
else:
# this info could be more informative but
# it doesn't seem as useful in a local context
# and requires dependencies and programming.
# this info could be more informative but it doesn't seem as
# useful in a local context and requires dependencies and
# programming.
build_info = {"vcs_revision": "local", "committer_date": str(time.time())}
devrepo = local
devbranch = ""
args.devrepo = args.local
args.devbranch = ""

archive_uri, bundle_uri, schema_uri = get_bundle_schema_local(local)
archive_uri, bundle_uri, schema_uri = get_bundle_schema_local(args.local)
overwrite_bundle_local(bundle_uri)
overwrite_schema_local(schema_uri)

Expand All @@ -293,23 +276,23 @@ def update_schema_bundle_from_master():

# Replace version with bundle url
package_json["dependencies"]["plotly.js"] = (
archive_url if local is None else archive_uri
archive_url if args.local is None else archive_uri
)
with open(package_json_path, "w") as f:
json.dump(package_json, f, indent=2)

# update plotly.js version in _plotlyjs_version
rev = build_info["vcs_revision"]
date = str(build_info["committer_date"])
version = "_".join([devrepo, devbranch, date[:10], rev[:8]])
version = "_".join([args.devrepo, args.devbranch, date[:10], rev[:8]])
overwrite_plotlyjs_version_file(version)
install_js_deps(local)
install_js_deps(args.local)


def update_plotlyjs_dev(outdir):
def update_plotlyjs_dev(args, outdir):
"""Update project to a new development version of plotly.js."""

update_schema_bundle_from_master()
update_schema_bundle_from_master(args)
perform_codegen(outdir)


Expand All @@ -328,7 +311,14 @@ def parse_args():

subparsers.add_parser("format", help="reformat code")

subparsers.add_parser("updateplotlyjsdev", help="update plotly.js for development")
p_update_dev = subparsers.add_parser(
"updateplotlyjsdev", help="update plotly.js for development"
)
p_update_dev.add_argument(
"--devrepo", default="plotly/plotly.js", help="repository"
)
p_update_dev.add_argument("--devbranch", default="master", help="branch")
p_update_dev.add_argument("--local", default=None, help="local path")

subparsers.add_parser("updateplotlyjs", help="update plotly.js")

Expand All @@ -353,7 +343,7 @@ def main():
lint_code(outdir)

elif args.cmd == "updateplotlyjsdev":
update_plotlyjs_dev(outdir)
update_plotlyjs_dev(args, outdir)

elif args.cmd == "updateplotlyjs":
version = plotly_js_version()
Expand Down