# scratch-sr-cli

> The Scratch CLI is a command-line tool designed to enhance your workflow while working with the Scratch PHP framework and React applications.

Latest version **1.0.0-beta.1** (published 2023-08-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install scratch-sr-cli
pnpm add scratch-sr-cli
yarn add scratch-sr-cli
bun add scratch-sr-cli
```

Provides the command `scratch`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0-beta.1 |
| Published | 2023-08-07 |
| First published | 2023-08-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 29 |
| Unpacked size | 360.8 KB |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| Author | Djemai Samy |
| Maintainers | djemai-samy |
| Keywords | scratch, php, react, ssr, Djemai Samy |

## Links

- npm: https://www.npmjs.com/package/scratch-sr-cli
- npm.io page: https://npm.io/package/scratch-sr-cli

## Dependencies (29)

- [ora](https://npm.io/package/ora.md) ^6.1.2
- [meow](https://npm.io/package/meow.md) ^11.0.0
- [chalk](https://npm.io/package/chalk.md) ^5.2.0
- [mem-fs](https://npm.io/package/mem-fs.md) ^2.2.1
- [i18next](https://npm.io/package/i18next.md) ^23.4.1
- [webpack](https://npm.io/package/webpack.md) ^5.88.2
- [fs-extra](https://npm.io/package/fs-extra.md) ^10.1.0
- [inquirer](https://npm.io/package/inquirer.md) ^9.0.2
- [cli-alerts](https://npm.io/package/cli-alerts.md) ^1.2.2
- [css-loader](https://npm.io/package/css-loader.md) ^6.8.1
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.22.9
- [cli-welcome](https://npm.io/package/cli-welcome.md) ^2.2.2
- [file-loader](https://npm.io/package/file-loader.md) *
- [json-loader](https://npm.io/package/json-loader.md) ^0.5.7
- [webpack-cli](https://npm.io/package/webpack-cli.md) ^5.1.4
- [babel-loader](https://npm.io/package/babel-loader.md) ^9.1.3
- [style-loader](https://npm.io/package/style-loader.md) ^3.3.3
- [cli-meow-help](https://npm.io/package/cli-meow-help.md) ^3.1.0
- [mem-fs-editor](https://npm.io/package/mem-fs-editor.md) ^9.6.0
- [command-exists](https://npm.io/package/command-exists.md) ^1.2.9
- [cli-handle-error](https://npm.io/package/cli-handle-error.md) ^4.4.0
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.22.9
- [i18next-fs-backend](https://npm.io/package/i18next-fs-backend.md) ^2.1.5
- [webpack-dev-server](https://npm.io/package/webpack-dev-server.md) ^4.15.1
- [@babel/preset-react](https://npm.io/package/@babel/preset-react.md) ^7.22.5
- [html-webpack-plugin](https://npm.io/package/html-webpack-plugin.md) *
- [cli-handle-unhandled](https://npm.io/package/cli-handle-unhandled.md) ^1.1.1
- [webpack-node-externals](https://npm.io/package/webpack-node-externals.md) ^3.0.0
- [mini-css-extract-plugin](https://npm.io/package/mini-css-extract-plugin.md) ^2.7.6

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.0-beta.1 (latest) — 2023-08-07
- 1.0.0-beta.4 (beta) — 2023-08-07
- 1.0.0-beta.3 — 2023-08-07
- 1.0.0-beta.2 — 2023-08-07

## README

# Scratch CLI

NOTE: This is just a fun project i'm working on, and should not be used for production !

![Logo of Scratch Frameword](https://djemai-samy.com/projects/personal/scratch/scratch.png)

The Scratch CLI is a command-line tool designed to enhance your workflow and simplify the process of starting and building React applications using Server-Side Rendering (SSR) and client-side rendering.

With a set of simple commands, you can create, configure, start and build your React App.

It's better used with Scratch Framework, [you can explore the official page for a quick start](https://djemai-samy.com/projects/scratch)

This document provides a detailed guide on installing and using the Scratch CLI.

## Table of Contents

1. Installation
2. Basic Usage
3. Development Workflow
4. Production Build
5. Integration with PHP
6. Deployment
7. Examples

---

## Installation

To use the Scratch CLI, you need to have Node.js installed.

You can install the CLI globally using the following command:

```bash
npm install -g scratch-sr-cli
```

Alternatively, you can use the CLI without installing it globally by running:

```bash
Copy code
npx scratch-sr-cli <command>
```

## Basic Usage

1. Create a Scratch App with all the necessary dependencies installed, run:

    ```bash
    scratch-cli create
    ```


2. Start Development Server
To start the development server, which serves the client assets and watches for changes, run:

    ```bash
    npx scratch-sr-cli start
    ```

    This command launches the webpack development server and also watches the server entry for changes.

3. Build for Production

    To build your Scratch app for production, use the following command:

    ```bash
    npx scratch-sr-cli scratch-cli build
    ```

    This command creates optimized production-ready assets in the public folder and generates the server entry in a specified folder.

---

## Development Workflow

For efficient development:

1. Start with scratch-cli start to launch the development server.
2. Make changes to your React app and PHP backend.
3. Use hot-reloading and browser refresh to see live updates.
4. Once development is complete, proceed to building for production.

---

## Configuration

This configuration file defines the server and client entry points, output paths, and development server settings.

```json
{
  "folder": "src/React",
  "server": {
    "entry": "main.js",
    "output": {
      "name": "server.js",
      "folder": ".scratch/entries"
    }
  },
  "client": {
    "entry": "main.js",
    "output": {
      "name": "client.js",
      "folder": "public",
      "styles": "styles.css"
    },
    "dev": {
      "url": "http://localhost:3000",
      "port": "3000"
    }
  }
}
```

---

## Integration

The Scratch CLI integrates seamlessly with Scratch PHP backend using scratch-ssr package.

Exemples of usage with multiple backends wil be added here soon.

---

---
_Source: https://npm.io/package/scratch-sr-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
