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

Rename project from thoughtbelt to Belt #32

Merged
merged 5 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: thoughtbelt CI
name: Belt CI

on:
push:
Expand Down
16 changes: 4 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ yarn dev

## Test changes locally

In thoughtbelt directory:
In Belt project directory:

```bash
yarn link
Expand All @@ -33,11 +33,11 @@ yarn link
In some other directory:

```bash
yarn add thoughtbelt
yarn link thoughtbelt
yarn add create-belt-app
yarn link create-belt-app

# or whatever command
yarn thoughtbelt NewApp
yarn belt NewApp
```

## Creating a pull request
Expand Down Expand Up @@ -65,11 +65,3 @@ Push to your fork. Write a [good commit message][commit]. Submit a pull request.
Others will give constructive feedback. This is a time for discussion and
improvements, and making the necessary changes will be required before we can
merge the contribution.

## Running the project locally

To run a local version of the codebase locally against a project, follow these steps:

- [in thoughtbelt directory] `yarn link`
- [in project directory] `yarn link thoughtbelt`
- Run CLI, eg; `yarn thoughtbelt`
33 changes: 20 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,52 @@ Here are some of what gets configured when you start a new Belt app:
- Custom test "render" function to facilitate testing
- MSW for mocking
- Directory structure
- Tanstack Query (for REST APIs) or Apollo Client (for GraphQL)
- React Navigation
- Tanstack Query (for REST APIs) or Apollo Client (for GraphQL) (coming soon!)
- Redux for global state (coming soon!)

## Usage

Create a new React Native, Expo app using Belt with:
Create a new React Native Expo app using Belt with:

```
```sh
# With NPM
npx create-belt-app

# With Yarn
yarn create belt-app
npx create-belt-app --yarn

# With pnpm (experimental)
pnpm create belt-app
npx create-belt-app --pnpm

# With Bun (experimental)
bunx create-belt-app
npx create-belt-app --bun
```

Or, if you already have an app and want to configure ESLint, Prettier, TypeScript, React Native Testing Library, etc, run:
Or, if you already have an app and want to use Belt, run:

```
```sh
# with NPM
npm install --save-dev create-belt-app

# with Yarn
yarn install --dev create-belt-app
yarn add --dev create-belt-app

# with PNPM
pnpm install --save-dev create-belt-app
```

then run the command you'd like to perform:

```
```sh
# eg. add TypeScript to the project
yarn belt typescript

# or, with NPM
npm belt typescript
npx belt typescript

# or, with PNPM
pnpm belt typescript
```

## Contributing
Expand All @@ -61,14 +68,14 @@ See the [CONTRIBUTING](./CONTRIBUTING.md) document. Thank you, [contributors](ht

## License

thoughtbelt is Copyright Β© 2024 thoughtbot. It is free software, and may be
Belt is Copyright Β© 2024 thoughtbot. It is free software, and may be
redistributed under the terms specified in the [LICENSE](/LICENSE) file.

### About thoughtbot

<img src="https://thoughtbot.com/thoughtbot-logo-for-readmes.svg" width="375" />

thoughtbelt is maintained and funded by thoughtbot, inc.
Belt is maintained and funded by thoughtbot, inc.
The names and logos for thoughtbot are trademarks of thoughtbot, inc.

We love open source software! See [our other projects][community] or
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "thoughtbelt",
"name": "create-belt-app",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what causes the package to be renamed. After making this change, I published to npm with:

npm version minor
yarn pub:release

"author": "thoughtbot, Inc.",
"license": "MIT",
"version": "0.1.9",
"description": "React Native project starter and generator CLI",
"version": "0.2.1",
"description": "React Native Expo project starter and generator CLI",
"type": "module",
"exports": "./dist/index.js",
"bin": {
"thoughtbelt": "./dist/index.js",
"create-belt-app": "./dist/index.js",
"belt": "./dist/index.js"
},
"files": [
Expand Down
2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import printWelcome from './util/print/printWelcome';

export default function runCli() {
program
.name('thoughtbelt')
.name('Belt')
.description(
'Perform React Native and Expo setup and redundant tasks without your pants falling down!',
)
Expand Down
25 changes: 19 additions & 6 deletions src/commands/createApp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { confirm, input } from '@inquirer/prompts';
import chalk from 'chalk';
import fs from 'fs-extra';
import ora from 'ora';
import { globals } from '../constants';
import addDependency from '../util/addDependency';
Expand Down Expand Up @@ -35,9 +36,10 @@ export async function createApp(name: string | undefined, options: Options) {
globals.isCreateApp = true;

const appName = name || (await getAppName());
await printIntro();

const spinner = ora('Creating new app with create-expo-app').start();
await ensureDirectoryDoesNotExist(appName);
await printIntro();
const spinner = ora('Creating new app with create-expo').start();
await createExpoApp(appName, options);
spinner.succeed('Created new app with Expo');

Expand All @@ -55,7 +57,7 @@ export async function createApp(name: string | undefined, options: Options) {
'npx expo install @react-native-async-storage/async-storage react-native-safe-area-context',
);
await addDependency('react-native-keyboard-aware-scrollview');
await addDependency('thoughtbelt', { dev: true });
await addDependency('create-belt-app', { dev: true });
await commit('Add dependencies');
spinner.succeed('Added dependencies');

Expand All @@ -69,7 +71,7 @@ export async function createApp(name: string | undefined, options: Options) {
await addEslint();
await commit('Add and configure ESLint');

await exec('yarn fix:prettier');
await exec('npm run fix:prettier');
await commit('Run Prettier on project');

await addDependency('npm-run-all', { dev: true });
Expand All @@ -96,7 +98,7 @@ export async function createApp(name: string | undefined, options: Options) {
print(`
Your pants are now secure! Each tool was configured as an individual commit.
Take a look at the commits to understand what all was done. For more information
about thoughtbelt, visit https://github.com/thoughtbot/thoughtbelt.
about Belt, visit https://github.com/thoughtbot/belt.
`);
}

Expand Down Expand Up @@ -153,7 +155,7 @@ async function commit(message: string) {
}
// Installs Expo using the specified package manager, or if no package manager
// option specified, try to determine based on which packager is running
// thoughtbelt eg. `npx thoughtbelt` vs. `bunx thoughtbelt`
// create-belt-app eg. `npx create-belt-app` vs. `bunx create-belt-app`
async function createExpoApp(appName: string, options: Options) {
const mgr = options.bun
? 'bun'
Expand All @@ -179,3 +181,14 @@ async function createExpoApp(appName: string, options: Options) {
const fullCommand = `${command} ${appName}`;
await exec(fullCommand);
}

async function ensureDirectoryDoesNotExist(appName: string) {
if (await fs.exists(appName)) {
print(
chalk.yellow(
`Whoopsy. The directory ${process.cwd()}/${appName} already exists. Please choose a different name or delete the existing directory.\n`,
),
);
process.exit(0);
}
}
2 changes: 1 addition & 1 deletion src/util/print/printWelcome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import chalk from 'chalk';
import print from '../print';

export default function printWelcome() {
print(chalk.bold('\n\n\tπŸ‘– thoughtbelt πŸ‘–\n'));
print(chalk.bold('\n\n\tπŸ‘– Belt πŸ‘–\n'));
print(
'Perform project setup and redundant tasks\n without your pants falling down!\n\n',
);
Expand Down
Loading