feat: deepnote-cli skeleton (#219) · deepnote/deepnote@b0eaeeb · GitHub
Skip to content

Commit b0eaeeb

Browse files
authored
feat: deepnote-cli skeleton (#219)
1 parent 8f38388 commit b0eaeeb

16 files changed

Lines changed: 516 additions & 1 deletion

File tree

‎.github/workflows/ci.yml‎

Lines changed: 31 additions & 0 deletions

‎biome.json‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,17 @@
123123
"assist": {
124124
"enabled": true,
125125
"actions": { "source": { "organizeImports": "on" } }
126-
}
126+
},
127+
"overrides": [
128+
{
129+
"includes": ["packages/cli/**"],
130+
"linter": {
131+
"rules": {
132+
"suspicious": {
133+
"noConsole": "off"
134+
}
135+
}
136+
}
137+
}
138+
]
127139
}

‎packages/cli/.npmignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
src/
2+
*.ts
3+
!*.d.ts
4+
tsdown.config.ts
5+
.npmignore

‎packages/cli/CONTRIBUTING.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Contributing to @deepnote/cli
2+
3+
## Development
4+
5+
```bash
6+
# Install dependencies (from repo root)
7+
pnpm install
8+
9+
# Build the CLI
10+
pnpm build
11+
12+
# Run the CLI in development mode (without building)
13+
pnpm dev --help
14+
pnpm dev --version
15+
pnpm dev inspect path/to/file.deepnote
16+
17+
# Run tests
18+
pnpm test
19+
```

‎packages/cli/README.md‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# @deepnote/cli
2+
3+
Command-line interface for running Deepnote projects locally and on Deepnote Cloud.
4+
5+
This project is under active development and is not ready for use. Expect breaking changes.
6+
7+
## Quick Start
8+
9+
```bash
10+
# Show help
11+
deepnote --help
12+
13+
# Show version
14+
deepnote --version
15+
16+
# Inspect a .deepnote file
17+
deepnote inspect path/to/file.deepnote
18+
```
19+
20+
## Commands
21+
22+
### `inspect <path>`
23+
24+
Inspect and display metadata from a `.deepnote` file.
25+
26+
```bash
27+
deepnote inspect my-project.deepnote
28+
```
29+
30+
This command displays:
31+
32+
- File path
33+
- Project name and ID
34+
- File format version
35+
- Creation, modification, and export timestamps
36+
- Number of notebooks and blocks
37+
- List of notebooks with their block counts

‎packages/cli/package.json‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"name": "@deepnote/cli",
3+
"version": "0.1.0",
4+
"description": "Command-line interface for running Deepnote projects locally and on Deepnote Cloud",
5+
"keywords": [
6+
"cli",
7+
"deepnote",
8+
"notebook",
9+
"data-science"
10+
],
11+
"repository": {
12+
"type": "git",
13+
"url": "https://github.com/deepnote/deepnote.git",
14+
"directory": "packages/cli"
15+
},
16+
"license": "Apache-2.0",
17+
"type": "module",
18+
"exports": {
19+
".": {
20+
"types": "./dist/index.d.ts",
21+
"import": "./dist/index.js",
22+
"require": "./dist/index.cjs"
23+
}
24+
},
25+
"main": "./dist/index.cjs",
26+
"module": "./dist/index.js",
27+
"types": "./dist/index.d.ts",
28+
"bin": {
29+
"deepnote": "./dist/bin.js"
30+
},
31+
"files": [
32+
"dist",
33+
"README.md",
34+
"LICENSE",
35+
"package.json"
36+
],
37+
"scripts": {
38+
"build": "tsdown",
39+
"dev": "tsx src/bin.ts",
40+
"test": "vitest",
41+
"watch": "tsdown --watch"
42+
},
43+
"dependencies": {
44+
"@deepnote/blocks": "workspace:*",
45+
"chalk": "^5.4.1",
46+
"commander": "^14.0.2"
47+
},
48+
"devDependencies": {
49+
"tsx": "^4.20.6"
50+
},
51+
"publishConfig": {
52+
"access": "public",
53+
"registry": "https://registry.npmjs.org"
54+
}
55+
}

‎packages/cli/src/bin.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { afterEach, describe, expect, it, vi } from 'vitest'
2+
3+
vi.mock('./cli', () => ({
4+
run: vi.fn(),
5+
}))
6+
7+
describe('bin', () => {
8+
afterEach(() => {
9+
vi.clearAllMocks()
10+
})
11+
12+
it('calls run() when imported', async () => {
13+
vi.resetModules()
14+
15+
const { run } = await import('./cli')
16+
17+
await import('./bin')
18+
19+
expect(run).toHaveBeenCalledTimes(1)
20+
expect(run).toHaveBeenCalledWith()
21+
})
22+
})

‎packages/cli/src/bin.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env node
2+
import { run } from './cli'
3+
4+
run()

‎packages/cli/src/cli.test.ts‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { describe, expect, it } from 'vitest'
2+
import { createProgram, run } from './cli'
3+
import { version } from './version'
4+
5+
describe('CLI', () => {
6+
describe('createProgram', () => {
7+
it('creates a program with correct name', () => {
8+
const program = createProgram()
9+
expect(program.name()).toBe('deepnote')
10+
})
11+
12+
it('has version set', () => {
13+
const program = createProgram()
14+
expect(program.version()).toBe(version)
15+
})
16+
17+
it('has expected commands registered', () => {
18+
const program = createProgram()
19+
const commandNames = program.commands.map(cmd => cmd.name())
20+
21+
expect(commandNames).toContain('inspect')
22+
})
23+
})
24+
25+
describe('commands', () => {
26+
it('inspect command is properly configured', () => {
27+
const program = createProgram()
28+
const inspectCmd = program.commands.find(cmd => cmd.name() === 'inspect')
29+
30+
expect(inspectCmd).toBeDefined()
31+
expect(inspectCmd?.description()).toBe('Inspect and display metadata from a .deepnote file')
32+
})
33+
})
34+
35+
describe('run', () => {
36+
it('is exported and callable', () => {
37+
expect(typeof run).toBe('function')
38+
})
39+
})
40+
})

‎packages/cli/src/cli.ts‎

Lines changed: 61 additions & 0 deletions

0 commit comments

Comments
 (0)