Skip to content
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

Support comparing semver ranges that have top-level || operators. #7919

Merged
merged 2 commits into from Feb 25, 2020

Conversation

jasongrout
Copy link
Contributor

References

When working on supporting multiple versions of jlab with a single extension codebase (see #7893), I ran into a problem that JupyterLab tries to check compatibility of extensions, but cannot handle an || top-level operator.

Code changes

This allows us to have an extension that supports multiple versions of JLab (i.e., a semver range of ^1 || ^2 for a jlab dependency)

User-facing changes

Should be none

Backwards-incompatible changes

Should be none.

This allows us to have an extension that supports multiple versions of JLab (i.e., ^1 || ^2)
@jasongrout jasongrout added this to the 2.0 milestone Feb 24, 2020
@jupyterlab-dev-mode
Copy link

Thanks for making a pull request to JupyterLab!

To try out this branch on binder, follow this link: Binder

@jasongrout
Copy link
Contributor Author

The test failures look totally unrelated, but on the other hand I haven't seen these particular test failures before. Thoughts?

@blink1073
Copy link
Member

The usage test failure is an intermittent one. Unfortunately we can't restart the job until the other ones finish...

@jasongrout
Copy link
Contributor Author

If we can merge this, I can push out another rc so we can test extensions targeting jlab 1 and 2, as well as the icon stuff just merged.

@jasongrout
Copy link
Contributor Author

With this PR on top of jlab 2.0.0rc1, I can generate an extension from the ts cookiecutter, apply the following diff, and have an extension that works in jlab 1.2.6 and jlab 2.0:

diff --git a/package.json b/package.json
index 95c6095..256226c 100644
--- a/package.json
+++ b/package.json
@@ -31,11 +31,13 @@
     "watch": "tsc -w"
   },
   "dependencies": {
-    "@jupyterlab/application": "^1.0.0"
+    "@jupyterlab/application": "^1.2.1 || ^2.0.0-rc.0",
+    "@jupyterlab/apputils": "^1.2.1 || ^2.0.0-rc.0",
+    "@phosphor/widgets": "^1.9.3"
   },
   "devDependencies": {
     "rimraf": "^2.6.1",
-    "typescript": "~3.5.2"
+    "typescript": "~3.7.2"
   },
   "sideEffects": [
     "style/*.css"
diff --git a/src/index.ts b/src/index.ts
index 8952150..600acb0 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,16 +1,45 @@
 import {
-  JupyterFrontEnd, JupyterFrontEndPlugin
-} from '@jupyterlab/application';
+  JupyterFrontEnd,
+  JupyterFrontEndPlugin,
+  ILabShell,
+} from "@jupyterlab/application";
 
+import {
+  MainAreaWidget
+} from "@jupyterlab/apputils";
+
+import { Widget } from "@phosphor/widgets";
 
 /**
  * Initialization data for the myextension extension.
  */
 const extension: JupyterFrontEndPlugin<void> = {
-  id: 'myextension',
+  id: "myextension",
   autoStart: true,
-  activate: (app: JupyterFrontEnd) => {
-    console.log('JupyterLab extension myextension is activated!');
+  requires: [ILabShell],
+  activate: (app: JupyterFrontEnd, labShell: ILabShell) => {
+    const w = new Widget();
+    w.id = 'My widget';
+    w.title.label = 'My Widget';
+    w.node.textContent = "My widget!";
+    const mw = new MainAreaWidget({content: w as any});
+    app.restored.then(() => {
+      labShell.add(mw, 'main');
+    })
+
+    const w2 = new Widget();
+    w2.id = 'My widget2';
+    w2.title.label = 'My Widget2';
+    w2.node.textContent = "My widget2!";
+    labShell.add(w2 as any, 'right');
+
+    const w3 = new Widget();
+    w3.id = 'My widget3';
+    w3.title.label = 'My Widget3';
+    w3.node.textContent = "My widget3!";
+    labShell.add(w3 as any, 'right');
+
+    console.log('my widget added!');
   }
 };
 

Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@blink1073 blink1073 merged commit 1263446 into jupyterlab:master Feb 25, 2020
@blink1073
Copy link
Member

Nice, and thanks for taking on the publish step!

@lock lock bot added the status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Mar 27, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants