Skip to content

Commit 00eff37

Browse files
committed
feat: add tinker
wip
1 parent 037a3d4 commit 00eff37

File tree

8 files changed

+165
-0
lines changed

8 files changed

+165
-0
lines changed

.stacks/core/actions/src/tinker.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { parseArgs, runCommands } from '@stacksjs/cli'
2+
3+
const options = parseArgs()
4+
5+
console.log('options are:', options)
6+
7+
// await runCommands([
8+
// 'npx tinker',
9+
// ], { verbose: true })

.stacks/core/buddy/src/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export * from './seed'
2121
export * from './setting'
2222
export * from './setup'
2323
export * from './test'
24+
export * from './tinker'
2425
export * from './types'
2526
export * from './upgrade'
2627
export * from './version'
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import type { CLI, TinkerOptions } from '@stacksjs/types'
2+
import { runAction } from '@stacksjs/actions'
3+
import { intro, outro } from '@stacksjs/cli'
4+
import { Action, ExitCode } from '@stacksjs/types'
5+
6+
async function tinker(buddy: CLI) {
7+
const descriptions = {
8+
tinker: 'Tinker with your code',
9+
verbose: 'Enable verbose output',
10+
}
11+
12+
buddy
13+
.command('tinker', descriptions.tinker)
14+
.option('--verbose', descriptions.verbose, { default: false })
15+
.action(async (options: TinkerOptions) => {
16+
const perf = await intro('buddy tinker')
17+
const result = await runAction(Action.Tinker, options)
18+
19+
if (result.isErr()) {
20+
outro('While running the tinker command, there was an issue', { startTime: perf, useSeconds: true, isError: true }, result.error || undefined)
21+
process.exit()
22+
}
23+
24+
outro('Tinker mode exited.', { startTime: perf, useSeconds: true })
25+
process.exit(ExitCode.Success)
26+
})
27+
}
28+
29+
export { tinker }

.stacks/core/tinker/README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Stacks Tinker
2+
3+
A powerful TypeScript REPL, powered by TSX.
4+
5+
## ☘️ Features
6+
7+
- Blazing fast on-demand TypeScript & ESM compilation
8+
- Works in both [CommonJS and ESM packages](https://nodejs.org/api/packages.html#type)
9+
- Supports next-gen TypeScript extensions (`.cts` & `.mts`)
10+
- Supports `node:` import prefixes
11+
- Hides experimental feature warnings
12+
- TypeScript REPL
13+
- Resolves `tsconfig.json` [`paths`](https://www.typescriptlang.org/tsconfig#paths)
14+
- Tested on Linux & Windows with Node.js v12~18
15+
16+
## 🤖 Usage
17+
18+
```bash
19+
pnpm i -D @stacksjs/tinker
20+
```
21+
22+
Now, you can easily access it in your project:
23+
24+
```bash
25+
npx tinker
26+
```
27+
28+
To learn more, visit [`tsx`](https://github.com/esbuild-kit/tsx).
29+
30+
## 📈 Changelog
31+
32+
Please see our [releases](https://github.com/stacksjs/stacks/releases) page for more information on what has changed recently.
33+
34+
## 🚜 Contributing
35+
36+
Please review the [Contributing Guide](https://github.com/stacksjs/contributing) for details.
37+
38+
## 🏝 Community
39+
40+
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
41+
42+
[Discussions on GitHub](https://github.com/stacksjs/stacks/discussions)
43+
44+
For casual chit-chat with others using this package:
45+
46+
[Join the Stacks Discord Server](https://discord.ow3.org)
47+
48+
## 🙏🏼 Credits
49+
50+
Many thanks to the following core technologies & people who have contributed to this package:
51+
52+
- [tsx](https://github.com/esbuild-kit/tsx)
53+
- [esno](https://github.com/esbuild-kit/esno)
54+
- [Chris Breuer](https://github.com/chrisbbreuer)
55+
- [All Contributors](../../contributors)
56+
57+
## 📄 License
58+
59+
The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/stacks/tree/main/LICENSE.md) for more information.
60+
61+
Made with ❤️

.stacks/core/tinker/package.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "@stacksjs/tinker",
3+
"type": "module",
4+
"version": "0.51.0",
5+
"packageManager": "pnpm@8.3.1",
6+
"description": "The Stacks way to tinker.",
7+
"author": "Chris Breuer",
8+
"license": "MIT",
9+
"funding": "https://github.com/sponsors/chrisbbreuer",
10+
"homepage": "https://github.com/stacksjs/stacks/tree/main/.stacks/core/tinker#readme",
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/stacksjs/stacks.git",
14+
"directory": "./.stacks/core/tinker"
15+
},
16+
"bugs": {
17+
"url": "https://github.com/stacksjs/stacks/issues"
18+
},
19+
"keywords": [
20+
"tinker",
21+
"repl",
22+
"typescript",
23+
"tsx",
24+
"zero-config",
25+
"stacks"
26+
],
27+
"module": "dist/index.mjs",
28+
"types": "dist/index.d.ts",
29+
"contributors": [
30+
"Chris Breuer <chris@ow3.org>"
31+
],
32+
"bin": {
33+
"tinker": "tinker.js"
34+
},
35+
"files": [
36+
"dist",
37+
"README.md"
38+
],
39+
"scripts": {
40+
"build": "unbuild",
41+
"dev": "unbuild --stub",
42+
"prepublishOnly": "pnpm run build",
43+
"typecheck": "tsc --noEmit"
44+
},
45+
"dependencies": {
46+
"tsx": "^3.12.7"
47+
},
48+
"devDependencies": {
49+
"@stacksjs/development": "workspace:*"
50+
}
51+
}

.stacks/core/tinker/tinker.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
import('tsx/cli')

.stacks/core/types/src/cli.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ export interface InspireOptions extends CliOptions {}
181181
export interface ReleaseOptions extends CliOptions {}
182182
export interface PreinstallOptions extends CliOptions {}
183183
export interface PrepublishOptions extends CliOptions {}
184+
export interface TinkerOptions extends CliOptions {}
184185
export interface TypesOptions extends CliOptions {}
185186

186187
export type LibEntryType = 'vue-components' | 'web-components' | 'functions' | 'all'
@@ -269,6 +270,7 @@ export const enum Action {
269270
TestUnit = 'test-unit', // wip
270271
TestFeature = 'test-feature', // wip
271272
TestCoverage = 'test-coverage', // wip
273+
Tinker = 'tinker',
272274
Typecheck = 'typecheck', // wip
273275
Upgrade = 'upgrade/index', // wip
274276
UpgradeNode = 'upgrade/node', // wip

pnpm-lock.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)