Skip to content

Commit f57cf96

Browse files
committed
Update command to run npm install for updateplotlyjs
1 parent 1f26820 commit f57cf96

2 files changed

Lines changed: 38 additions & 14 deletions

File tree

CONTRIBUTING.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,21 @@ python commands.py updateplotlyjs
274274

275275
This downloads new versions of `plot-schema.json` and `plotly.min.js` from the `plotly/plotly.js` GitHub repository
276276
and places them in `plotly/package_data`.
277-
It then regenerates all of the `graph_objs` classes based on the new schema.
277+
It then regenerates all of the `graph_objs` classes based on the new schema,
278+
and finally runs `npm install` in `js/` to refresh `js/package-lock.json` against the new `plotly.js`.
279+
Commit the updated `js/package-lock.json` along with the regenerated files.
280+
281+
The JupyterLab extension and FigureWidget bundles in `plotly/labextension` and `plotly/package_data/widgetbundle.js`
282+
are rebuilt as part of the release flow (see [RELEASE.md](RELEASE.md)) rather than on every plotly.js bump.
283+
284+
If you need to skip the `npm install` step entirely (e.g. `npm` isn't available),
285+
set the `SKIP_NPM=1` environment variable:
286+
287+
```bash
288+
SKIP_NPM=1 python commands.py updateplotlyjs
289+
```
290+
291+
If you do skip it, you'll need to run `npm install` in `js/` yourself before committing so the lockfile stays in sync.
278292

279293
### Using a Development Branch of Plotly.js
280294

@@ -319,6 +333,6 @@ Usage: `python commands.py <subcommand> <args>`
319333
| `codegen [--noformat]` | Regenerate Python files according to `plot-schema.json`.`--noformat` skips formatter step. |
320334
| `lint` | Lint all Python code in `plotly/`. |
321335
| `format` | Format all Python code in `plotly/`. |
322-
| `updateplotlyjs` | Update `plotly.min.js` and `plot-schema.json` to match the `plotly.js` version specified in `js/package.json`. Then, run codegen to regenerate the Python files. |
336+
| `updateplotlyjs` | Update `plotly.min.js` and `plot-schema.json` to match the `plotly.js` version specified in `js/package.json`, run codegen to regenerate the Python files, then run `npm install` in `js/` to refresh `js/package-lock.json`. Set `SKIP_NPM=1` to skip the npm step. |
323337
| `updateplotlyjsdev [--devrepo REPONAME --devbranch BRANCHNAME] \| [--local PATH]` | Update `plot-schema.json` and `plotly.min.js` to match the version in the provided plotly.js repo name and branch name, OR local path. Then, run codegen to regenerate the Python files. |
324338
| `bumpversion X.Y.Z` | Update the plotly.py version number to X.Y.Z across all files where it needs to be updated. |

commands.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,15 @@ def plotly_js_version():
4444
return version
4545

4646

47-
def install_js_deps(local):
48-
"""Install package.json dependencies using npm."""
47+
def install_js_deps(local, build=True):
48+
"""Install package.json dependencies using npm.
49+
50+
When ``build`` is True (the default), also runs ``npm run build`` to
51+
rebuild the JupyterLab extension and FigureWidget bundles and verifies
52+
that the widget bundle exists. Pass ``build=False`` when you only need
53+
to refresh ``node_modules`` / ``package-lock.json`` (e.g. after a
54+
plotly.js version bump) and don't need the bundles rebuilt.
55+
"""
4956

5057
npmName = "npm"
5158
if platform.system() == "Windows":
@@ -86,18 +93,20 @@ def install_js_deps(local):
8693
stdout=sys.stdout,
8794
stderr=sys.stderr,
8895
)
89-
check_call(
90-
[npmName, "run", "build"],
91-
cwd=NODE_ROOT,
92-
stdout=sys.stdout,
93-
stderr=sys.stderr,
94-
)
96+
if build:
97+
check_call(
98+
[npmName, "run", "build"],
99+
cwd=NODE_ROOT,
100+
stdout=sys.stdout,
101+
stderr=sys.stderr,
102+
)
95103
os.utime(NODE_MODULES, None)
96104

97-
for target in WIDGET_TARGETS:
98-
if not os.path.exists(target):
99-
msg = "Missing file: %s" % target
100-
raise ValueError(msg)
105+
if build:
106+
for target in WIDGET_TARGETS:
107+
if not os.path.exists(target):
108+
msg = "Missing file: %s" % target
109+
raise ValueError(msg)
101110

102111

103112
def overwrite_schema_local(uri):
@@ -215,6 +224,7 @@ def update_plotlyjs(plotly_js_version, outdir):
215224
update_bundle(plotly_js_version)
216225
update_schema(plotly_js_version)
217226
perform_codegen(outdir)
227+
install_js_deps(local=None, build=False)
218228

219229

220230
# FIXME: switch to argparse

0 commit comments

Comments
 (0)