create-fa-react 1.0.2 → 1.0.4
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/create-fa-react-1.0.3.tgz +0 -0
- package/index.js +12 -12
- package/package.json +1 -1
- package/removePlaceholders.js +22 -0
- package/template/src/app/.gitkeep +0 -0
|
Binary file
|
package/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import pc from "picocolors";
|
|
6
6
|
import { fileURLToPath } from "url";
|
|
7
|
+
import { removePlaceholders } from "./removePlaceholders.js";
|
|
7
8
|
|
|
8
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
10
|
const __dirname = path.dirname(__filename);
|
|
@@ -11,7 +12,7 @@ const __dirname = path.dirname(__filename);
|
|
|
11
12
|
const projectName = process.argv[2];
|
|
12
13
|
|
|
13
14
|
if (!projectName) {
|
|
14
|
-
console.log(pc.red("
|
|
15
|
+
console.log(pc.red("Debes proporcionar un nombre de proyecto."));
|
|
15
16
|
process.exit(1);
|
|
16
17
|
}
|
|
17
18
|
|
|
@@ -19,22 +20,21 @@ const projectPath = path.join(process.cwd(), projectName);
|
|
|
19
20
|
const templatePath = path.join(__dirname, "template");
|
|
20
21
|
|
|
21
22
|
if (fs.existsSync(projectPath)) {
|
|
22
|
-
console.log(pc.red("
|
|
23
|
+
console.log(pc.red("La carpeta ya existe."));
|
|
23
24
|
process.exit(1);
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
console.log(pc.cyan("
|
|
27
|
+
console.log(pc.cyan("Creando proyecto...\n"));
|
|
27
28
|
|
|
28
|
-
// crear carpeta
|
|
29
29
|
fs.mkdirSync(projectPath);
|
|
30
30
|
|
|
31
|
-
// copiar template
|
|
32
31
|
fs.cpSync(templatePath, projectPath, { recursive: true });
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
removePlaceholders(projectPath);
|
|
35
34
|
|
|
36
|
-
console.log(pc.
|
|
37
|
-
|
|
38
|
-
console.log(pc.
|
|
39
|
-
console.log(pc.
|
|
40
|
-
console.log("");
|
|
35
|
+
console.log(pc.green("Proyecto creado correctamente!\n"));
|
|
36
|
+
|
|
37
|
+
console.log(pc.yellow("Siguientes pasos:"));
|
|
38
|
+
console.log(pc.white(` cd ${projectName}`));
|
|
39
|
+
console.log(pc.white(" npm install"));
|
|
40
|
+
console.log(pc.white(" npm run dev"));
|
package/package.json
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
export function removePlaceholders(dir) {
|
|
5
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
6
|
+
|
|
7
|
+
for (const entry of entries) {
|
|
8
|
+
const fullPath = path.join(dir, entry.name);
|
|
9
|
+
|
|
10
|
+
if (entry.isDirectory()) {
|
|
11
|
+
removePlaceholders(fullPath);
|
|
12
|
+
} else {
|
|
13
|
+
if (
|
|
14
|
+
entry.name === ".gitkeep" ||
|
|
15
|
+
entry.name === ".keep" ||
|
|
16
|
+
entry.name === ".placeholder"
|
|
17
|
+
) {
|
|
18
|
+
fs.unlinkSync(fullPath);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
File without changes
|