https://github.com/pyymenta/spacecraft-cli
Let's build a rocket together! Our rocket, Spacecraft, is a simple CLI Project made with typescript
https://github.com/pyymenta/spacecraft-cli
beginner-friendly challenge cli help-wanted javascript spacecraft typescript
Last synced: 3 months ago
JSON representation
Let's build a rocket together! Our rocket, Spacecraft, is a simple CLI Project made with typescript
- Host: GitHub
- URL: https://github.com/pyymenta/spacecraft-cli
- Owner: pyymenta
- License: mit
- Created: 2020-10-02T21:51:37.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-03-05T14:07:06.000Z (over 3 years ago)
- Last Synced: 2025-11-18T06:24:03.826Z (7 months ago)
- Topics: beginner-friendly, challenge, cli, help-wanted, javascript, spacecraft, typescript
- Language: TypeScript
- Homepage:
- Size: 3.93 MB
- Stars: 10
- Watchers: 1
- Forks: 28
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Spacecraft-CLI
[](https://github.com/pyymenta/spacecraft-cli/actions/workflows/build.yml)
[](https://github.com/pyymenta/spacecraft-cli/blob/master/LICENSE)
[](https://github.com/pyymenta/spacecraft-cli/graphs/contributors)
[](https://www.npmjs.com/package/spacecraft-app-cli)
A simple CLI to solve the Spacecraft Problem, made with [TypeScript](https://www.typescriptlang.org/)
Let's build a rocket together!

## The Problem
Say, the Canadian Space Agency is building an unmanned spacecraft that’ll go to the moon.

Here’s some more info about the project.
* The ship’s starting coordinates are `(0, 0)`, which is on Earth.
* The ship’s final destination is `(0, 250)`, which is on the moon.
* The ship will be controlled over a CLI using a standard keyboard as follows:
* The ship starts at `(0, 0)` at 0 speed, i.e. at complete rest.
The ship only moves when a valid key is pressed.
* Pressing `W` increases the ship’s speed and then moves it forward by speed units.
* The ship’s maximum speed is 5.
* Pressing `S` decreases the ship’s speed and then moves it forward by speed units.
* The ship’s minimum speed is 0.
* After launch, the ship cannot go below speed 1, i.e. it always moves forward until it reaches the moon.
* Pressing `A` and `D` move the ship left and right by one unit respectively.
* The ship also moves forward by speed units.
## Problem
Write a CLI program in your preferred language to simulate the above spacecraft. Display output as follows:
* Begin with `(0, 0) ready for launch`.
* After every movement, display the updated position.
* If the ship goes more than 5 points to the left/right, display `wrong trajectory`.
* If the ship tries to decrease the speed below 1, display `minimum speed`.
* If the ship tries to increase the speed over 5, display `maximum speed`.
* When the ship reaches `(0, 250)` display `on the moon`.
* If the ship goes beyond 250 on the y-axis, display `contact lost`.
## Demo

## Sample output
```none
(0, 0) # Begin with original position.
(0, 1) # W increases the speed to 1 and moves forward.
(0, 3) # W increases the speed to 2 and moves forward.
(-1, 5) # A moves the ship left and forward.
(0, 7) # D moves the ship right and forward.
(0, 8) # S decreases the speed to 1 and moves forward.
...
(0, 250) on the moon # Ship reaches the moon
```
## Install Globally
```sh
npm i -g spacecraft-app-cli
```
or
You can run directly with `npx`
```sh
npx spacecraft-app-cli
```
## Getting started - Local Development
### Requirements
* NodeJS 16.0.0
* Npm 7.10.0
See [nvm](https://github.com/nvm-sh/nvm) or [asdf](https://github.com/asdf-vm/asdf-nodejs)
### Installation
To get started locally, follow these instructions:
1. Clone to your local computer using `git`.
2. Make sure you have Node installed; see instructions [here](https://nodejs.org/en/download/).
### Usage
```sh
# starts 🚀 on coordinates (0,0) - Earth
yarn start
# Use W, A, S, or D to starting control 🚀 .
```
### Build the CLI bundle
```sh
yarn build
```
### Run tests
```sh
yarn test
```
## Contributors
## Docs
- [Contribution Guidelines](./docs/contributor-guidelines.md)
## License
Copyright (c) 2021 pyymenta
Spacecraft is licensed under the [MIT](LICENSE) license.