fm-starter-cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENCE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Arthur Gehlen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # fm-starter-cli
2
+
3
+ CLI tool to automate the setup of React projects from Frontend Mentor challenges.
4
+
5
+ This tool automatically creates a new React project using Vite and copies the relevant challenge files into the new project structure, removing the need for manual setup every time you start a new Frontend Mentor project.
6
+
7
+ ---
8
+
9
+ ## Features
10
+
11
+ When provided with the directory of a Frontend Mentor challenge, the CLI will:
12
+
13
+ - Create a new React project using Vite
14
+ - Move the `assets` folder into `src/assets`, replacing the existing one
15
+ - Copy the following folder:
16
+ - `design`
17
+ - Copy the following files:
18
+ - `preview.jpg`
19
+ - `README.md`
20
+ - `README-template.md`
21
+ - `style-guide.md`
22
+ - Merge the challenge `.gitignore` with the generated project's `.gitignore`
23
+ - Extract all textual content from `index.html` and generate a `.txt` file
24
+ - Automatically install project dependencies
25
+
26
+ ---
27
+
28
+ ## Requirements
29
+
30
+ - Node.js version 18 or higher
31
+
32
+ ---
33
+
34
+ ## Installation (Global)
35
+
36
+ Inside the project directory:
37
+
38
+ ```bash
39
+ npm install
40
+ npm install -g .
41
+ ```
42
+
43
+ ---
44
+
45
+ ## Usage
46
+ Run the command and provide the path to your Frontend Mentor challenge folder:
47
+ ```bash
48
+ fm-scaffold C:\path\to\frontend-mentor-challenge
49
+ ```
50
+ A new folder will be created in your current working directory:
51
+ ```bash
52
+ challenge-name-react/
53
+ ```
54
+
55
+ ## License
56
+ This project is licensed under the MIT License.
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "fs-extra";
4
+ import path from "path";
5
+ import { execa } from "execa";
6
+
7
+ const fm_path = process.argv[2];
8
+ const project_name = path.basename(fm_path) + "-react"; // configurando o nome da pasta :)
9
+
10
+ async function run() {
11
+ await execa(
12
+ "npx",
13
+ ["create-vite@latest", project_name, "--template", "react"],
14
+ {
15
+ stdio: "ignore",
16
+ },
17
+ );
18
+
19
+ const vite_path = path.join(process.cwd(), project_name);
20
+
21
+ // substituindo a pasta assets
22
+ await fs.remove(path.join(vite_path, "src/assets"));
23
+ await fs.copy(
24
+ path.join(fm_path, "assets"),
25
+ path.join(vite_path, "src/assets"),
26
+ );
27
+
28
+ await fs.copy(path.join(fm_path, "design"), path.join(vite_path, "design"));
29
+
30
+ const files = [
31
+ "README.md",
32
+ "README-template.md",
33
+ "style-guide.md",
34
+ "preview.jpg",
35
+ ];
36
+
37
+ for (const file of files) {
38
+ await fs.copy(path.join(fm_path, file), path.join(vite_path, file), {
39
+ overwrite: true,
40
+ });
41
+ }
42
+
43
+ // lendo o arquivo git pra mesclar com o vite + react
44
+ const fm_git = await fs.readFile(path.join(fm_path, ".gitignore"), "utf-8");
45
+
46
+ const vite_git_path = path.join(vite_path, ".gitignore");
47
+ const vite_git = await fs.readFile(vite_git_path, "utf-8");
48
+
49
+ await fs.writeFile(vite_git_path, vite_git + "\n" + fm_git);
50
+
51
+ // extraindo o HTML
52
+ const html = await fs.readFile(path.join(fm_path, "index.html"), "utf-8");
53
+
54
+ const text = html
55
+ .replace(/<script[\s\S]*?<\/script>/gi, "")
56
+ .replace(/<style[\s\S]*?<\/style>/gi, "")
57
+ .replace(/<[^>]+>/g, "\n")
58
+ .replace(/\n+/g, "\n")
59
+ .trim();
60
+
61
+ await fs.writeFile(path.join(vite_path, "text-content-txt"), text);
62
+
63
+ // instalando node_modules
64
+ await execa("npm", ["install"], {
65
+ cwd: vite_path,
66
+ stdio: "inherit",
67
+ });
68
+ }
69
+
70
+ run();
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "fm-starter-cli",
3
+ "version": "1.0.0",
4
+ "description": "CLI que automatiza a criação de um projeto React com Vite a partir de um desafio do Frontend Mentor, copiando e organizando automaticamente os arquivos necessários dentro da nova estrutura.",
5
+ "author": "Arthur Gehlen",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "bin": {
9
+ "fm-starter-cli": "fm-starter-cli.js"
10
+ },
11
+ "files": [
12
+ "fm-starter-cli.js"
13
+ ],
14
+ "scripts": {},
15
+ "dependencies": {
16
+ "execa": "^9.6.1",
17
+ "fs-extra": "^11.3.3"
18
+ },
19
+ "engines": {
20
+ "node": ">=18"
21
+ }
22
+ }