# file-structurer

> This package surfaces some utilities for structuring files in javascript projects.

Latest version **0.0.3** (published 2020-05-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install file-structurer
pnpm add file-structurer
yarn add file-structurer
bun add file-structurer
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2020-05-19 |
| First published | 2020-04-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | dronsfield |

## Links

- npm: https://www.npmjs.com/package/file-structurer
- Repository: https://github.com/dronsfield/file-structurer
- Homepage: https://github.com/dronsfield/file-structurer#readme
- Issues: https://github.com/dronsfield/file-structurer/issues
- npm.io page: https://npm.io/package/file-structurer

## Dependencies (4)

- [react](https://npm.io/package/react.md) ^16.13.1
- [@types/jest](https://npm.io/package/@types/jest.md) ^25.2.1
- [@types/node](https://npm.io/package/@types/node.md) ^13.11.1
- [@types/react](https://npm.io/package/@types/react.md) ^16.9.34

## Recent versions

- 0.0.3 (latest) — 2020-05-19
- 0.0.2 — 2020-04-21
- 0.0.1 — 2020-04-16

## README

# File Structurer

This package surfaces some utilities for structuring files in javascript projects.

At the moment it's just a couple of functions that are helpful when working with component folders.

Component folders are a familiar pattern in modern javascript development. A common use case is when a component has tests associated with it.

In this package, "component folder" refers to a file structure like the following:

```
├── Button
│   ├── Button.spec.tsx
│   ├── Button.tsx
│   └── index.tsx
├── Card
│   ├── Card.spec.tsx
│   ├── Card.tsx
│   └── index.tsx
```

Check out this [component folder VS Code extension](https://github.com/dronsfield/vscode-component-folder) for an example of this package in action.

## Installation

```sh
npm install file-structurer
```

## Usage

```typescript
import { createComponentFolder, converFileToFolder } from 'file-structurer'
```

## API

### createComponentFolder

Create a component folder.

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| props.path | string | absolute path to containing folder |
| props.name | string | name of component |
| props.ext | string | file extension to be used |
| props.mainFileData | string? | contents of main file |

**Returns**

An object with some details about the created files.

**Example**
```typescript
createComponentFolder({
    path: '/path/to/components/folder',
    name: 'Button',
    ext: 'tsx'
})
```

----------

### convertFileToFolder

Create a component folder from an existing file. Copies the content of the file and fixes the imports to work from within a folder. The new folder will have the same name as the original file and the new files will have the same extension.

**Parameters**

| Name | Type | Description |
| --- | --- | --- |
| props.path | string | absolute path to file |
| props.deleteFile | boolean? | if `true`: deletes the original file |

**Returns**

An object with some details about the created files.

**Example**
```typescript
convertFileToFolder({
    path: '/path/to/components/folder/Button',
    deleteFile: true
})
```

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