Skip to content

Commit

Permalink
🔢 print version numbers (#772)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejpurves authored Sep 6, 2024
1 parent 4b7434e commit 8c8a55a
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 18 deletions.
8 changes: 8 additions & 0 deletions .changeset/cyan-weeks-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'thebe-react': patch
'thebe': patch
'thebe-core': patch
'thebe-lite': patch
---

Version numbers are printed in debug messages to aid in debugging
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ junit.xml

.turbo
.ipynb_checkpoints
.yalc/
.yalc/

packages/**/src/version.ts
7 changes: 4 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@
"scripts": {
"clean": "rm -rf dist",
"prepublish": "npm run build",
"copy:version": "echo \"const version = '\"$npm_package_version\"';\nexport default version;\" > src/version.ts",
"build:css": "node ./esbuild.css.js",
"build:cjs": "tsc --project ./tsconfig.json --outDir ./dist/cjs",
"build:esm": "tsc --project ./tsconfig.json --module ES2020 --outDir ./dist/esm",
"build:bundle:dev": "webpack --config webpack.dev.js",
"build:bundle": "webpack --config webpack.prod.js",
"declarations": "tsc --project ./tsconfig.json --declaration --emitDeclarationOnly --outDir dist/types",
"build:dev": "npm-run-all -l clean -p declarations build:cjs build:esm build:css build:bundle:dev",
"build": "npm-run-all -l clean -p declarations build:cjs build:esm build:css build:bundle",
"build:dev": "npm-run-all -l clean copy:version -p declarations build:cjs build:esm build:css build:bundle:dev",
"build": "npm-run-all -l clean copy:version -p declarations build:cjs build:esm build:css build:bundle",
"build:watch": "concurrently 'npm run build:cjs -- -w' 'npm run copy:css' 'npm run build:bundle -- --watch'",
"dev": "npm run build:watch",
"dev": "npm run copy:version && npm run build:watch",
"start": "webpack serve --open --config webpack.dev.js",
"test:watch": "vitest",
"test": "vitest run",
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export { default as ThebeNotebook, CodeBlock } from './notebook';
export { default as ThebeCodeCell } from './cell';
export { default as ThebeMarkdownCell } from './markdown';
export { default as PassiveCellRenderer } from './passive';
export { default as version } from './version';

export * from './options';
export * from './events';
Expand All @@ -14,4 +15,5 @@ export * from './manager';
export * from './rendermime';
export * from './types';
export * from './config';

export { clearAllSavedSessions, clearSavedSession } from './sessions';
4 changes: 3 additions & 1 deletion packages/core/src/thebe/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { makeConfiguration } from '../options';
import { makeRenderMimeRegistry } from '../rendermime';
import * as coreModule from '../index';
import type { IRenderMimeRegistry } from '@jupyterlab/rendermime';
import version from '../version';

export function connectToBinder(config: Config): ThebeServer {
const server: ThebeServer = new ThebeServer(config);
Expand Down Expand Up @@ -55,7 +56,7 @@ export function setupNotebookFromIpynb(
}

export function setupThebeCore() {
console.debug(`thebe:api:setupThebeCore`, { coreModule });
console.debug(`thebe-core (v${version})`, { coreModule });
window.thebeCore = Object.assign(window.thebeCore ?? {}, {
module: coreModule,
api: {
Expand All @@ -69,5 +70,6 @@ export function setupThebeCore() {
setupNotebookFromBlocks,
setupNotebookFromIpynb,
},
version,
});
}
1 change: 1 addition & 0 deletions packages/core/src/thebe/entrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type ThebeCore = typeof coreModule;
export interface ThebeCoreGlobal {
module: ThebeCore;
api: JsApi;
version: string;
}

declare global {
Expand Down
5 changes: 3 additions & 2 deletions packages/lite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
],
"scripts": {
"clean": "rm -rf ./dist",
"copy:version": "echo \"const version = '\"$npm_package_version\"';\nexport default version;\" > src/version.ts",
"build:bundle": "webpack --config webpack.config.cjs",
"build:post:shuffle": "./bin/shufflePyolitePaths.sh",
"build:post:contents": "./bin/stubContentsApi.js",
"declarations": "tsc --project ./tsconfig.json --declaration --emitDeclarationOnly --outDir dist/types",
"build": "npm-run-all -l clean -p build:bundle declarations",
"dev": "npm run build:bundle -- -w"
"build": "npm-run-all -l clean copy:version -p build:bundle declarations",
"dev": "npm run copy:version && npm run build:bundle -- -w"
},
"repository": {
"type": "git",
Expand Down
5 changes: 3 additions & 2 deletions packages/lite/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { startJupyterLiteServer } from './jlite';
import type { ThebeLiteGlobal } from './types';
import version from './version';

declare global {
interface Window {
Expand All @@ -8,13 +9,13 @@ declare global {
}

function setupThebeLite() {
window.thebeLite = Object.assign(window.thebeLite ?? {}, { startJupyterLiteServer });
window.thebeLite = Object.assign(window.thebeLite ?? {}, { startJupyterLiteServer, version });
}

if (typeof window !== 'undefined') {
console.debug('window is defined, setting up thebe-lite');
setupThebeLite();
console.debug('window.thebeLite', window.thebeLite);
console.debug(`thebe-lite (v${window.thebeLite?.version ?? 0})`, window.thebeLite);
}

export * from './types';
Expand Down
1 change: 1 addition & 0 deletions packages/lite/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export type LiteServerConfig = {

export interface ThebeLiteGlobal {
startJupyterLiteServer: (config?: LiteServerConfig) => Promise<ServiceManager>;
version: string;
}
5 changes: 3 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
},
"scripts": {
"clean": "rm -rf dist",
"copy:version": "echo \"const version = '\"$npm_package_version\"';\nexport default version;\" > src/version.ts",
"prepublish": "npm run build",
"build:cjs": "tsc --project ./tsconfig.json --outDir ./dist",
"declarations": "tsc --project ./tsconfig.json --declaration --emitDeclarationOnly --outDir dist",
"build": "npm run declarations; npm run build:cjs",
"dev": "concurrently 'npm run declarations -- -w' 'npm run build:cjs -- -w'",
"build": "npm run copy:version; npm run declarations; npm run build:cjs",
"dev": "npm copy:version; concurrently 'npm run declarations -- -w' 'npm run build:cjs -- -w'",
"test": "vitest run",
"test:watch": "vitest"
},
Expand Down
12 changes: 7 additions & 5 deletions packages/react/src/ThebeLoaderProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useEffect, useState } from 'react';
import version from './version';

// eslint-disable-next-line @typescript-eslint/consistent-type-imports
export type ThebeCore = typeof import('thebe-core');
Expand All @@ -21,10 +22,10 @@ export function ThebeLoaderProvider({
// if already loaded do nothing
if (!startLoad || core) return;
setLoading(true);
console.debug('importing thebe-core...');
console.debug(`thebe-react (v${version}) importing thebe-core...`);
import('thebe-core')
.then((thebeCore) => {
console.debug('thebe-core loaded');
console.debug(`thebe-core (v${thebeCore.version}) loaded`);
setCore(thebeCore);
setLoading(false);
})
Expand Down Expand Up @@ -63,7 +64,7 @@ export function ThebeBundleLoaderProvider({
// if already loaded do nothing
if (!startLoad || core) return;
setLoading(true);
console.debug('importing thebe-core...');
console.debug(`thebe-react (v${version}) importing thebe-core...`);

if (typeof document !== 'undefined' && typeof window !== 'undefined') {
try {
Expand All @@ -88,8 +89,9 @@ export function ThebeBundleLoaderProvider({
if (window.thebeCore && (window.thebeLite || !loadThebeLite)) {
setLoading(false);
setCore((window as any).thebeCore?.module);
console.debug('thebe-core loaded');
if (window.thebeLite) console.debug('thebe-lite loaded');
console.debug(`thebe-core (v${(window as any).thebeCore?.version ?? '0'}) loaded`);
if (window.thebeLite)
console.debug(`thebe-lite (v${window.thebeLite?.version ?? '0'}) loaded`);
clearInterval(timer);
}
if (attempts > (options?.attempts ?? 50)) {
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './ThebeServerProvider';
export * from './ThebeSessionProvider';
export * from './ThebeRenderMimeRegistryProvider';
export * from './hooks';
export { default as version } from './version';
5 changes: 3 additions & 2 deletions packages/thebe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@
},
"scripts": {
"clean": "rm -rf ./lib",
"copy:version": "echo \"const version = '\"$npm_package_version\"';\nexport default version;\" > src/version.ts",
"build:bundle:dev": "webpack --mode development --devtool inline-source-map --progress --color",
"build:bundle": "webpack --mode production --devtool source-map",
"build:mkdir": "mkdir -p lib",
"build:css": "node ./esbuild.css.js",
"build:dev": "npm-run-all -l clean -p build:css build:bundle:dev declarations",
"build": "npm-run-all -l clean -p build:css build:bundle declarations",
"build": "npm-run-all -l clean copy:version -p build:css build:bundle declarations",
"declarations": "tsc --project ./tsconfig.json --declaration --emitDeclarationOnly --outDir lib/types",
"build:watch": "npm run build:bundle:dev -- --watch",
"build:publish": "NODE_PREPUBLISH=true npm run build",
"serve": "http-server -c-1 -a 127.0.0.1 -o development/binder.html",
"serve:local": "http-server -c-1 -a 127.0.0.1 -o development/local.html",
"serve:examples": "http-server -c-1 -a 127.0.0.1 -o docs/_static/html_examples/index.html",
"dev": "npm run build:watch",
"dev": "npm run copy:version && npm run build:watch",
"develop": "concurrently \"yarn run build:watch\" \"yarn run serve\"",
"develop:local": "concurrently \"yarn run build:watch\" \"yarn run serve:local\"",
"disabled-test": "jest --detectOpenHandles",
Expand Down
2 changes: 2 additions & 0 deletions packages/thebe/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ThebeEvents, setupThebeCore } from 'thebe-core';
import * as thebe from './thebe';
import version from './version';

export * from './types';
export * from './thebe';
Expand All @@ -8,6 +9,7 @@ export function setupGlobals() {
const events = new ThebeEvents();

window.thebe = Object.assign(window.thebe ?? {}, {
version,
...thebe,
events,
trigger: events.trigger.bind(events),
Expand Down

0 comments on commit 8c8a55a

Please sign in to comment.