Using the CLI
File Architect's core is open-source and available from NPM as a command-line interface.
Installation
bash
npm install -g @filearchitect/cli
# or
pnpm add -g @filearchitect/cli
# or
yarn global add @filearchitect/cliQuick Start
- Create a structure file (
structure.txt):
txt
src
components
Button.tsx
Card.tsx
styles
global.css- Create the structure:
bash
filearchitect create structure.txt my-projectCLI Usage
bash
# Create a structure
filearchitect create structure.txt output
# Preview operations without creating
filearchitect show structure.txt outputSyntax Guide
| Syntax | Description | Example |
|---|---|---|
name.ext | Creates an empty file | file.txt |
name | Creates a directory | folder |
[source] | Copies a file or folder with its contents | [~/path/to/config.json] |
[souce] > name.ext | Copies and renames a file or folder | [~/path/to/config.json] > config.json |
(source) | Moves (imports) a file or folder with its contents | (~/path/to/file.txt) |
(source) > name.ext | Moves and renames a file or folder | (~/old.txt) > new.txt |
YAML Frontmatter
You can include YAML frontmatter at the start of your structure file to configure replacements:
yaml
---
fileReplacements:
- search: ".js"
replace: ".ts"
folderReplacements:
- search: "api"
replace: "rest"
---
src
api
index.jsComplete Example
txt
---
fileReplacements:
- search: ".js"
replace: ".ts"
---
src
components
Button.tsx
Card.tsx
forms
LoginForm.tsx
SignupForm.tsx
styles
global.css
components.css
utils
[~/templates/api.js] > api.ts
helpers.ts
types
index.d.ts
# Copy configuration files
config
[~/configs/base.json] > base.json
[~/templates/react] > template
# Import existing files
tests
(~/old-project/components/Button.test.tsx) > components/Button.test.tsx
(~/old-project/utils/helpers.test.ts) > utils/helpers.test.tsThis creates:
my-project/
├── src/
│ ├── components/
│ │ ├── Button.tsx
│ │ ├── Card.tsx
│ │ └── forms/
│ │ ├── LoginForm.tsx
│ │ └── SignupForm.tsx
│ ├── styles/
│ │ ├── global.css
│ │ └── components.css
│ ├── utils/
│ │ ├── api.ts # Copied and renamed from ~/templates/api.js
│ │ └── helpers.ts
│ └── types/
│ └── index.d.ts
├── config/
│ ├── base.json # Copied from ~/configs/base.json
│ └── template/ # Copied from ~/templates/react
└── tests/
├── components/
│ └── Button.test.tsx # Moved from ~/old-project/components/Button.test.tsx
└── utils/
└── helpers.test.ts # Moved from ~/old-project/utils/helpers.test.tsPractical Examples
Generate a React Component
txt
src
components
Button
Button.tsx
Button.module.css
index.ts
Button.test.tsxCreate a Project Scaffold
txt
---
fileReplacements:
- search: "MyProject"
replace: "TaskManager"
---
MyProject
src
index.ts
models
User.ts
Task.ts
services
api.ts
components
layout
Header.tsx
Footer.tsx
shared
Button.tsx
Card.tsx
public
index.html
assets
logo.svg
tests
unit
models
User.test.ts
README.md
package.json
tsconfig.jsonImport from an Existing Project
txt
# Create a new project with files from multiple sources
new-project
# Copy configuration files
[~/templates/typescript/tsconfig.json]
[~/templates/eslint/.eslintrc.js]
# Import key components from another project
src
components
(~/old-project/src/components/Button.tsx)
(~/old-project/src/components/Card.tsx)
# Add new files
pages
Home.tsx
About.tsx
Contact.tsxContributing
- Clone the repository:
bash
git clone https://github.com/filearchitect/filearchitect.git
cd filearchitect- Install dependencies:
bash
pnpm install- Build the packages:
bash
pnpm build- Try it out:
bash
pnpm cli create structure.txt output