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

Switching to Bun for dev #783

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
6b69ac1
feat(parameters-tools): add yargsParse type
joshuayoes Aug 25, 2022
4cbbed9
feat(package.json): add watch:debug script
joshuayoes Aug 25, 2022
0ac6162
feat(parameters-tools.test): add coalesce boolean flag tests
joshuayoes Aug 25, 2022
0a365c4
feat(parameter-tools): normalize boolean strings to boolean type
joshuayoes Aug 25, 2022
7690bd1
fix(runtime-parameters.test): update 'true' assert to true
joshuayoes Aug 25, 2022
52bc87b
Only support generating TypeScript CLIs; switch to bun
jamonholmgren Sep 16, 2023
5f717ea
README shenanigans
jamonholmgren Sep 16, 2023
6315c9c
Readme yay
jamonholmgren Sep 16, 2023
ca6711c
Clean up some open handles
jamonholmgren Sep 16, 2023
85ae57d
Use Bun.spawn if available
jamonholmgren Sep 16, 2023
3bee2aa
ts issues, rename gluegun-bun
jamonholmgren Sep 16, 2023
5c2324e
Try to get circleci to run bun
jamonholmgren Sep 16, 2023
10bae78
bump for ci
jamonholmgren Sep 16, 2023
709bd01
bun-orb/setup i think
jamonholmgren Sep 16, 2023
eed9a7b
lean into bun
jamonholmgren Sep 16, 2023
33deb4d
Tweaks
jamonholmgren Sep 16, 2023
6b603ed
module.exports instead of export default I guess
jamonholmgren Sep 16, 2023
db3bf2e
More bunification
jamonholmgren Sep 16, 2023
f1f1c6a
Allow running with node again locally -- for testing!
jamonholmgren Sep 16, 2023
97959ae
More bunning
jamonholmgren Sep 16, 2023
781e6bb
Bumping a bunch of deps
jamonholmgren Sep 16, 2023
276324a
Don't check for updates?
jamonholmgren Sep 16, 2023
c728909
bump CI for Azure
jamonholmgren Sep 16, 2023
6e2f07e
uhh maybe?
jamonholmgren Sep 16, 2023
e511f7a
ci windows
jamonholmgren Sep 16, 2023
4db15c4
ci:test:windows?
jamonholmgren Sep 16, 2023
a5e090d
progress...
jamonholmgren Sep 16, 2023
fb2d353
OK I guess I should have done this too
jamonholmgren Sep 16, 2023
3e9019e
isolate windows even more
jamonholmgren Sep 16, 2023
384f814
use windows:test
jamonholmgren Sep 16, 2023
0f6b556
Looser test for Windows
jamonholmgren Sep 19, 2023
0a135dd
Someday this will stop
jamonholmgren Sep 19, 2023
ea58a45
Maybe if I didn't suck at this
jamonholmgren Sep 19, 2023
ea55544
um maybe
jamonholmgren Sep 19, 2023
69be338
Don't clean types after build
jamonholmgren Sep 20, 2023
2ba994b
One binary
jamonholmgren Sep 21, 2023
eedc052
Merge branch 'master' into bunification
jamonholmgren Sep 28, 2023
826c0a7
Bump bun-orb
jamonholmgren Sep 28, 2023
826fe1e
Merge branch 'master' into bunification
jamonholmgren Sep 28, 2023
520cd4b
Merge branch 'master' into feat/normalize-flag-values
jamonholmgren Sep 28, 2023
a085be6
Merge branch 'feat/normalize-flag-values' into bunification
jamonholmgren Sep 28, 2023
bed7a4b
Merge master
jamonholmgren Sep 28, 2023
2943189
Fix typescript errors, boolean types
jamonholmgren Sep 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 19 additions & 23 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,61 +9,57 @@ defaults: &defaults
- image: cimg/node:18.17.1
working_directory: ~/repo

version: 2
version: 2.1
orbs:
# https://circleci.com/developer/orbs/orb/cmgriffing/bun-orb
bun-orb: cmgriffing/[email protected]
jobs:
setup:
<<: *defaults
steps:
- checkout
- bun-orb/setup
- restore_cache:
name: Restore node modules
keys:
- v1-dependencies-{{ checksum "yarn.lock" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- v1-bun-deps-{{ checksum "bun.lockb" }}
- v1-bun-deps-
- run:
name: Install dependencies
command: |
yarn install --frozen-lockfile
bun install
- save_cache:
name: Save node modules
key: v1-bun-deps-{{ checksum "bun.lockb" }}
paths:
- ~/.bun/install/cache
- node_modules
key: v1-dependencies-{{ checksum "yarn.lock" }}

tests:
<<: *defaults
steps:
- checkout
- bun-orb/setup
- restore_cache:
name: Restore node modules
keys:
- v1-dependencies-{{ checksum "yarn.lock" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: Install React Native CLI and Ignite CLI
command: |
sudo npm i -g ignite-cli react-native-cli
- v1-bun-deps-{{ checksum "bun.lockb" }}
- v1-bun-deps-
- run:
name: Run tests
command: yarn ci:test # this command will be added to/found in your package.json scripts
command: bun run ci:test

publish:
<<: *defaults
steps:
- checkout
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- bun-orb/setup
- restore_cache:
name: Restore node modules
keys:
- v1-dependencies-{{ checksum "yarn.lock" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- v1-bun-deps-{{ checksum "bun.lockb" }}
- v1-bun-deps-
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
# Run semantic-release after all the above is set.
- run:
name: Publish to NPM
command: yarn ci:publish # this will be added to your package.json scripts
command: bun run ci:publish # this will be added to your package.json scripts

workflows:
version: 2
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged
bun run lint-staged
4 changes: 2 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
package.json
package-lock.json
yarn.lock
readme.md
README.md
dist/
build/
docs/readme.md
docs/README.md
*.ejs
14 changes: 7 additions & 7 deletions readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ npx gluegun new movies
cd movies

# and link your new executable
yarn link
bun link

# and run it!
movies help
Expand Down Expand Up @@ -119,7 +119,7 @@ See the [runtime docs](./docs/runtime.md) for more details on building your own
- [Graph CLI](https://github.com/graphprotocol/graph-cli) - CLI for building and managing subgraphs that index data from Ethereum and IPFS - [https://thegraph.com/explorer](https://thegraph.com/explorer)
- [Vts](https://github.com/snowfrogdev/Vts) - Vanilla TypeScript library starter CLI tool

*Additionally, the first versions of the [AWS Amplify CLI](https://github.com/aws-amplify/amplify-cli) (a CLI toolchain for simplifying serverless web and mobile development) used Gluegun. They've since integrated Gluegun's functionality into their CLI in a bespoke way, but you can still see Gluegun patterns in their CLI.*
_Additionally, the first versions of the [AWS Amplify CLI](https://github.com/aws-amplify/amplify-cli) (a CLI toolchain for simplifying serverless web and mobile development) used Gluegun. They've since integrated Gluegun's functionality into their CLI in a bespoke way, but you can still see Gluegun patterns in their CLI._

# What's under the hood?

Expand Down Expand Up @@ -151,8 +151,8 @@ While Gluegun is no longer actively developed by [Infinite Red](https://infinite

If you're looking for alternatives, here's a list:

* [Rust CLI](https://rust-cli.github.io/book/index.html) -- Rust is a rapidly growing community and hot language, and has the benefit of speed and not needing to rely on a local Node engine.
* [oclif](https://oclif.io/) - oclif is used by some large CLIs and is very actively maintained
* [commander](https://github.com/tj/commander.js/) and [yeoman](https://yeoman.io/) - commander and yeoman have been around a long time and have very large communities. Keep in mind that we built Gluegun to avoid Commander and Yeoman, so YMMV
* [vorpal](https://vorpal.js.org/) - unfortunately looks like it isn't actively maintained
* [just make your own](https://www.twilio.com/blog/how-to-build-a-cli-with-node-js) - you don't need a framework to make a Node CLI. Check out this article from Twilio
- [Rust CLI](https://rust-cli.github.io/book/index.html) -- Rust is a rapidly growing community and hot language, and has the benefit of speed and not needing to rely on a local Node engine.
- [oclif](https://oclif.io/) - oclif is used by some large CLIs and is very actively maintained
- [commander](https://github.com/tj/commander.js/) and [yeoman](https://yeoman.io/) - commander and yeoman have been around a long time and have very large communities. Keep in mind that we built Gluegun to avoid Commander and Yeoman, so YMMV
- [vorpal](https://vorpal.js.org/) - unfortunately looks like it isn't actively maintained
- [just make your own](https://www.twilio.com/blog/how-to-build-a-cli-with-node-js) - you don't need a framework to make a Node CLI. Check out this article from Twilio
39 changes: 20 additions & 19 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@ pool:
vmImage: 'windows-latest'

steps:
- task: NodeTool@0
inputs:
versionSpec: '14.x'
displayName: 'Install Node.js'
- task: NodeTool@0
inputs:
versionSpec: '20.x'
displayName: 'Install Node.js'

- script: |
choco install yarn -y
displayName: 'install yarn'
- script: |
choco install yarn -y
displayName: 'install yarn'

- script: |
yarn install
displayName: 'yarn install'
- script: |
yarn install
displayName: 'yarn install'

- script: |
yarn ci:test
displayName: 'yarn ci:test'

- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/build/'
includeRootFolder: false
- script: |
set USE_YARN=true
yarn windows:test
displayName: 'yarn windows:test'

- task: PublishBuildArtifacts@1
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/build/'
includeRootFolder: false

- task: PublishBuildArtifacts@1
14 changes: 9 additions & 5 deletions bin/gluegun
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ var devMode = require('fs').existsSync(`${__dirname}/../src`)
var wantsCompiled = process.argv.indexOf('--compiled-gluegun') >= 0

if (devMode && !wantsCompiled) {
// hook into ts-node so we can run typescript on the fly
require('ts-node').register({
project: `${__dirname}/../tsconfig.json`,
compiler: require.resolve('typescript', { paths: [__dirname] }),
})
if (typeof Bun === 'undefined') {
console.log('You may want to run gluegun-bun instead.')

require('ts-node').register({
project: `${__dirname}/../tsconfig.json`,
compiler: require.resolve('typescript', { paths: [__dirname] }),
})
}

// kick off gluegun
require(`${__dirname}/../src/cli/cli`).run(process.argv)
} else {
Expand Down
Binary file added bun.lockb
Binary file not shown.
24 changes: 13 additions & 11 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ Bug fixes, features, docs, marketing, and issue support are all contributions. W

If you're reading this, you might be interested in pitching in from a code point of view.

`gluegun` is powered by Node (7.6 or above). Install Node using `brew` (if on macOS) or by following the instructions here: [https://nodejs.org/en/download/current/](https://nodejs.org/en/download/current/)
`gluegun` is powered by Bun or Node in production, and Bun only during development. Your CLI users may be running via Node, so having both is important so you can test both.

Also install yarn: `brew install yarn` or [https://yarnpkg.com](https://yarnpkg.com).
Install Node using `brew` (if on macOS) or by following the instructions here: [https://nodejs.org/en/download/current/](https://nodejs.org/en/download/current/)

Also install Bun: `curl -fsSL https://bun.sh/install | bash` or [https://bun.sh](https://bun.sh).

## Installing `gluegun`

Expand All @@ -24,7 +26,7 @@ Install all the dependencies.

```
cd gluegun
yarn
bun install
```

Gluegun's source files are mostly in `./src` and are written in [TypeScript](www.typescriptlang.org). Documentation lives in `/docs`.
Expand All @@ -34,26 +36,26 @@ Gluegun's source files are mostly in `./src` and are written in [TypeScript](www
On macOS or Linux:

```sh
yarn test
yarn lint
yarn watch
yarn integration
bun run test
bun run lint
bun run watch
bun run integration
```

On windows:

```sh
yarn lint
yarn windows:test
bun run lint
bun run windows:test
```

## Features & Fixes

```sh
git branch feature/fun
# furious typing
yarn test
yarn lint
bun run test
bun run lint
git commit -m "Adds fun"
git push -u origin --HEAD
```
Expand Down
42 changes: 11 additions & 31 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,30 @@ The fastest way to get started is to use the built-in Gluegun CLI (very meta!) t

## Creating a new Gluegun-powered CLI

Gluegun works on macOS, Linux, and Windows 10. First, ensure you have Node installed and that you can access it (minimum version 7.6):
Gluegun works on macOS, Linux, and Windows 10. First, ensure you have Node OR Bun installed and that you can access it (Node minimum version 7.6, Bun minimum version 1.0.0):

```
$ node --version
$ bun --version
```

We will also be using [yarn](https://yarnpkg.com/) in this guide rather than `npm`. You can use `npm` if you want.
We will also be using [bun](https://bun.sh/) in this guide rather than `npm`. You can use `npm` or `yarn` if you want.

Install `gluegun` globally.
Navigate to the folder you'd like to create your CLI in and generate it.

```
$ yarn global add gluegun
bunx gluegun --bun new mycli
```

Next, navigate to the folder you'd like to create your CLI in and generate it.

```
$ gluegun new mycli
```

Gluegun will ask if you want to use TypeScript or modern JavaScript:

```
? Which language would you like to use? (Use arrow keys)
TypeScript - Gives you a build pipeline out of the box (default)
Modern JavaScript - Node 8.2+ and ES2016+ (https://node.green/)
```

You can also pass in `--typescript` or `--javascript` (or `-t` or `-j` for short) to bypass the prompt:

```
$ gluegun new mycli -t
$ gluegun new mycli -j
```

_Note: We recommend TypeScript, but you don't have to use it! Gluegun works great with modern JavaScript._
Gluegun will ask if you want to use bun or yarn or npm when developing your app. Choose the one you want to use.

## Linking your CLI so you can access it

Navigate to the new `mycli` folder and run `yarn link` to have it available globally on your command line.
Navigate to the new `mycli` folder and run `bun link` to have it available globally on your command line.

```
$ cd mycli
$ yarn link
$ bun link
$ mycli --help
```

Expand All @@ -58,7 +38,7 @@ Your Gluegun-powered CLI isn't very useful without a command! In your CLI, creat
```js
// src/commands/hello.js
module.exports = {
run: async toolbox => {
run: async (toolbox) => {
toolbox.print.info('Hello, world!')
},
}
Expand Down Expand Up @@ -91,7 +71,7 @@ You can add more tools into the `toolbox` for _all_ of your commands to use by c

```js
// src/extensions/hello-extension.js
module.exports = async toolbox => {
module.exports async (toolbox) => {
toolbox.hello = () => {
toolbox.print.info('Hello from an extension!')
}
Expand All @@ -115,7 +95,7 @@ Then, in your `hello` command, use that function instead:
```js
// src/commands/hello.js
module.exports = {
run: toolbox => {
run: (toolbox) => {
const { hello } = toolbox

hello()
Expand Down
10 changes: 5 additions & 5 deletions docs/guide-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ _Do this_
module.exports = {
name: 'world',
alias: ['w', 'earth'],
run: async toolbox => {
run: async (toolbox) => {
// in this case, `hello` is provided by an extension
const { hello, prompt } = toolbox

Expand Down Expand Up @@ -84,7 +84,7 @@ As of Gluegun 4.1.0, you can also nest commands in a `build` folder, if for exam
Think of extensions as "drawers" full of tools in your Gluegun toolbox. In the above example, the `hello` extension adds two functions, `greetEarthling` and `greetAlien`.

```js
module.exports = toolbox => {
module.exports = (toolbox) => {
const { print } = toolbox
toolbox.hello = {
greetEarthling: () => print.info('Hello, earthling!'),
Expand Down Expand Up @@ -131,7 +131,7 @@ const earthling = require('../toolbox/greetings/earthling')
const martian = require('../toolbox/greetings/martian')
const venusian = require('../toolbox/greetings/venusian')

module.exports = toolbox => {
module.exports = (toolbox) => {
toolbox.hello = { earthling, martian, venusian }
}
```
Expand All @@ -147,7 +147,7 @@ const R = require('ramda')

module.exports = {
name: 'mycommand',
run: async toolbox => {
run: async (toolbox) => {
// use Ramda
},
}
Expand All @@ -158,7 +158,7 @@ _Do this_
```js
module.exports = {
name: 'mycommand',
run: async toolbox => {
run: async (toolbox) => {
const R = require('ramda')
// use Ramda
},
Expand Down
Loading