npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cleanup-react-app

v1.1.3

Published

Cleanup your create-react-app. Removes commonly deleted files and boilerplate content from templates generated by create-react-app.

Downloads

16

Readme

🧼 Cleanup-react-app

Cleanup your create-react-app. Removes commonly deleted files and boilerplate content from templates generated by create-react-app.

Similar packages exist. The contribution of this package is that it is simple, careful, and thorough. For example, the package performs checks to ensure the application being cleaned is an instance of create-react-app.

Instructions

Global installation is recommended:

npm i -g cleanup-react-app

or

yarn global add cleanup-react-app

To use the package navigate to the directory to be cleaned up and run:

cleanup-react-app

Intended use

It is intended that the package is run directly after running create-react-app.

create-react-app app-name

cd app-name

cleanup-react-app

Operations

The package performs four operations.

1. Check Directory

To ensure the directory being cleaned is an instance of create-react-app, its contents are checked.

If missing or modified files are detected, a warning is thrown:

⚠️ Warning: Directory does not match create-react-app template.

Missing files:

<list of missing files>

Modified files:

<list of modified files>

Attempting to cleanup: /directory/being/cleaned

Pay attention to the printed directory if this warning is thrown. Attempting to clean a directory that is not a template instance of create-react-app may result in unintended files being overwritten or deleted.

The package checks the existence of:

node_modules
public
public/favicon.ico
public/index.html
public/logo192.png
public/logo512.png
public/manifest.json
public/robots.txt
src
src/App.js
src/App.test.js
src/index.css
src/index.js
src/logo.svg
src/serviceWorker.js
src/setupTests.js
.gitignore
package.json
README.md
yarn.lock

and the content of:

src/App.js
src/App.css
src/index.js
src/index.css
public/index.html
public/manifest.json
README.md
serviceWorker.js

2. Remove files

It removes:

public/favicon.ico
public/logo192.png
public/logo512.png
src/logo.svg

3. Rename files

It renames:

App.js

to

App.jsx

4. Rewrite files

It empties the content of:

src/App.css
src/index.css
README.md

It modifies the content of:

src/App.jsx
src/App.test.js
public/manifest.json

The contents of these files are modified as follows.

Most of the boilerplate content is removed from src/App.jsx. A novel starting message is also given.

The new content is:

import React from 'react';
import './App.css';

function App() {
  return (
    <p>
      Cleanedup React App
    </p>
  );
}

export default App;

The test included in src/App.test.js fails because the content of src/App.jsx is modified. A new test is written. The new test checks that the newly given message is present. If yarn test is run on a freshly cleanedup app, the new test should pass.

The new content is:

import React from 'react';
import { render } from '@testing-library/react';
import App from './App';

test('renders cleanup react app message', () => {
  const { getByText } = render(<App />);
  const cleanupMessage = getByText(/Cleanedup React App/i);
  expect(cleanupMessage).toBeInTheDocument();
});

The icons paths in public/manifest.json do not exist after cleanup because the icons have been removed. To avoid console errors the src values of the icon objects are set to empty strings.

The new content is:

{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
  {
    "src": "",
    "sizes": "64x64 32x32 24x24 16x16",
    "type": "image/x-icon"
  },
  {
    "src": "",
    "type": "image/png",
    "sizes": "192x192"
  },
  {
    "src": "",
    "type": "image/png",
    "sizes": "512x512"
  }
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}