Skip to content

Commit 8c8a55a

Browse files
authored
🔢 print version numbers (#772)
1 parent 4b7434e commit 8c8a55a

File tree

14 files changed

+44
-18
lines changed

14 files changed

+44
-18
lines changed

.changeset/cyan-weeks-cheer.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'thebe-react': patch
3+
'thebe': patch
4+
'thebe-core': patch
5+
'thebe-lite': patch
6+
---
7+
8+
Version numbers are printed in debug messages to aid in debugging

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ junit.xml
2323

2424
.turbo
2525
.ipynb_checkpoints
26-
.yalc/
26+
.yalc/
27+
28+
packages/**/src/version.ts

packages/core/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@
1313
"scripts": {
1414
"clean": "rm -rf dist",
1515
"prepublish": "npm run build",
16+
"copy:version": "echo \"const version = '\"$npm_package_version\"';\nexport default version;\" > src/version.ts",
1617
"build:css": "node ./esbuild.css.js",
1718
"build:cjs": "tsc --project ./tsconfig.json --outDir ./dist/cjs",
1819
"build:esm": "tsc --project ./tsconfig.json --module ES2020 --outDir ./dist/esm",
1920
"build:bundle:dev": "webpack --config webpack.dev.js",
2021
"build:bundle": "webpack --config webpack.prod.js",
2122
"declarations": "tsc --project ./tsconfig.json --declaration --emitDeclarationOnly --outDir dist/types",
22-
"build:dev": "npm-run-all -l clean -p declarations build:cjs build:esm build:css build:bundle:dev",
23-
"build": "npm-run-all -l clean -p declarations build:cjs build:esm build:css build:bundle",
23+
"build:dev": "npm-run-all -l clean copy:version -p declarations build:cjs build:esm build:css build:bundle:dev",
24+
"build": "npm-run-all -l clean copy:version -p declarations build:cjs build:esm build:css build:bundle",
2425
"build:watch": "concurrently 'npm run build:cjs -- -w' 'npm run copy:css' 'npm run build:bundle -- --watch'",
25-
"dev": "npm run build:watch",
26+
"dev": "npm run copy:version && npm run build:watch",
2627
"start": "webpack serve --open --config webpack.dev.js",
2728
"test:watch": "vitest",
2829
"test": "vitest run",

packages/core/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export { default as ThebeNotebook, CodeBlock } from './notebook';
44
export { default as ThebeCodeCell } from './cell';
55
export { default as ThebeMarkdownCell } from './markdown';
66
export { default as PassiveCellRenderer } from './passive';
7+
export { default as version } from './version';
78

89
export * from './options';
910
export * from './events';
@@ -14,4 +15,5 @@ export * from './manager';
1415
export * from './rendermime';
1516
export * from './types';
1617
export * from './config';
18+
1719
export { clearAllSavedSessions, clearSavedSession } from './sessions';

packages/core/src/thebe/api.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { makeConfiguration } from '../options';
88
import { makeRenderMimeRegistry } from '../rendermime';
99
import * as coreModule from '../index';
1010
import type { IRenderMimeRegistry } from '@jupyterlab/rendermime';
11+
import version from '../version';
1112

1213
export function connectToBinder(config: Config): ThebeServer {
1314
const server: ThebeServer = new ThebeServer(config);
@@ -55,7 +56,7 @@ export function setupNotebookFromIpynb(
5556
}
5657

5758
export function setupThebeCore() {
58-
console.debug(`thebe:api:setupThebeCore`, { coreModule });
59+
console.debug(`thebe-core (v${version})`, { coreModule });
5960
window.thebeCore = Object.assign(window.thebeCore ?? {}, {
6061
module: coreModule,
6162
api: {
@@ -69,5 +70,6 @@ export function setupThebeCore() {
6970
setupNotebookFromBlocks,
7071
setupNotebookFromIpynb,
7172
},
73+
version,
7274
});
7375
}

packages/core/src/thebe/entrypoint.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export type ThebeCore = typeof coreModule;
4646
export interface ThebeCoreGlobal {
4747
module: ThebeCore;
4848
api: JsApi;
49+
version: string;
4950
}
5051

5152
declare global {

packages/lite/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
],
1111
"scripts": {
1212
"clean": "rm -rf ./dist",
13+
"copy:version": "echo \"const version = '\"$npm_package_version\"';\nexport default version;\" > src/version.ts",
1314
"build:bundle": "webpack --config webpack.config.cjs",
1415
"build:post:shuffle": "./bin/shufflePyolitePaths.sh",
1516
"build:post:contents": "./bin/stubContentsApi.js",
1617
"declarations": "tsc --project ./tsconfig.json --declaration --emitDeclarationOnly --outDir dist/types",
17-
"build": "npm-run-all -l clean -p build:bundle declarations",
18-
"dev": "npm run build:bundle -- -w"
18+
"build": "npm-run-all -l clean copy:version -p build:bundle declarations",
19+
"dev": "npm run copy:version && npm run build:bundle -- -w"
1920
},
2021
"repository": {
2122
"type": "git",

packages/lite/src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { startJupyterLiteServer } from './jlite';
22
import type { ThebeLiteGlobal } from './types';
3+
import version from './version';
34

45
declare global {
56
interface Window {
@@ -8,13 +9,13 @@ declare global {
89
}
910

1011
function setupThebeLite() {
11-
window.thebeLite = Object.assign(window.thebeLite ?? {}, { startJupyterLiteServer });
12+
window.thebeLite = Object.assign(window.thebeLite ?? {}, { startJupyterLiteServer, version });
1213
}
1314

1415
if (typeof window !== 'undefined') {
1516
console.debug('window is defined, setting up thebe-lite');
1617
setupThebeLite();
17-
console.debug('window.thebeLite', window.thebeLite);
18+
console.debug(`thebe-lite (v${window.thebeLite?.version ?? 0})`, window.thebeLite);
1819
}
1920

2021
export * from './types';

packages/lite/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ export type LiteServerConfig = {
2020

2121
export interface ThebeLiteGlobal {
2222
startJupyterLiteServer: (config?: LiteServerConfig) => Promise<ServiceManager>;
23+
version: string;
2324
}

packages/react/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@
2929
},
3030
"scripts": {
3131
"clean": "rm -rf dist",
32+
"copy:version": "echo \"const version = '\"$npm_package_version\"';\nexport default version;\" > src/version.ts",
3233
"prepublish": "npm run build",
3334
"build:cjs": "tsc --project ./tsconfig.json --outDir ./dist",
3435
"declarations": "tsc --project ./tsconfig.json --declaration --emitDeclarationOnly --outDir dist",
35-
"build": "npm run declarations; npm run build:cjs",
36-
"dev": "concurrently 'npm run declarations -- -w' 'npm run build:cjs -- -w'",
36+
"build": "npm run copy:version; npm run declarations; npm run build:cjs",
37+
"dev": "npm copy:version; concurrently 'npm run declarations -- -w' 'npm run build:cjs -- -w'",
3738
"test": "vitest run",
3839
"test:watch": "vitest"
3940
},

0 commit comments

Comments
 (0)