create-spfx-tailwind-app 1.0.11 → 1.0.13

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/Template/setup.js CHANGED
@@ -1,9 +1,9 @@
1
1
  const fs = require("fs");
2
2
  const path = require("path");
3
- const { v4: uuidv4 } = require("uuid");
3
+ const { randomUUID } = require("crypto");
4
4
 
5
- const solutionId = uuidv4();
6
- const webpartId = uuidv4();
5
+ const solutionId = randomUUID();
6
+ const webpartId = randomUUID();
7
7
 
8
8
  const projectName = process.argv[2];
9
9
 
@@ -14,8 +14,17 @@ if (!projectName) {
14
14
 
15
15
  const projectNameLower = projectName.toLowerCase();
16
16
 
17
+
18
+
19
+
20
+ // ✅ Only process safe text files
21
+ const allowedExtensions = [".json", ".js", ".ts", ".tsx", ".scss", ".md"];
22
+
17
23
  // 🔁 Replace content inside files
18
24
  function replaceInFile(filePath) {
25
+ const ext = path.extname(filePath);
26
+ if (!allowedExtensions.includes(ext)) return;
27
+
19
28
  let content = fs.readFileSync(filePath, "utf8");
20
29
 
21
30
  content = content
@@ -27,12 +36,16 @@ function replaceInFile(filePath) {
27
36
  fs.writeFileSync(filePath, content);
28
37
  }
29
38
 
30
- // 🔁 Walk and process files
39
+ // 🔁 Walk and process files safely
31
40
  function walk(dir) {
32
- fs.readdirSync(dir).forEach(file => {
41
+ if (!fs.existsSync(dir)) return;
42
+
43
+ fs.readdirSync(dir).forEach((file) => {
33
44
  const fullPath = path.join(dir, file);
34
45
 
35
- if (fs.statSync(fullPath).isDirectory()) {
46
+ const stat = fs.statSync(fullPath);
47
+
48
+ if (stat.isDirectory()) {
36
49
  walk(fullPath);
37
50
  } else {
38
51
  replaceInFile(fullPath);
@@ -40,23 +53,24 @@ function walk(dir) {
40
53
  });
41
54
  }
42
55
 
43
- // 🔁 Rename files (IMPORTANT FIX)
56
+ // 🔁 Rename files safely
44
57
  function renameFiles(dir) {
45
- fs.readdirSync(dir).forEach(file => {
58
+ if (!fs.existsSync(dir)) return;
59
+
60
+ fs.readdirSync(dir).forEach((file) => {
46
61
  const fullPath = path.join(dir, file);
47
62
 
48
- if (fs.statSync(fullPath).isDirectory()) {
63
+ const stat = fs.statSync(fullPath);
64
+
65
+ if (stat.isDirectory()) {
49
66
  renameFiles(fullPath);
50
67
  } else {
51
- let newName = file
68
+ const newName = file
52
69
  .replace(/__PROJECT_NAME__/g, projectName)
53
70
  .replace(/__PROJECT_NAME_LOWER__/g, projectNameLower);
54
71
 
55
72
  if (newName !== file) {
56
- fs.renameSync(
57
- fullPath,
58
- path.join(dir, newName)
59
- );
73
+ fs.renameSync(fullPath, path.join(dir, newName));
60
74
  }
61
75
  }
62
76
  });
@@ -65,27 +79,30 @@ function renameFiles(dir) {
65
79
  // 🔁 Run replacements
66
80
  walk("./");
67
81
 
82
+ // 🔁 Force update package.json name
68
83
  const pkgPath = path.join("./package.json");
69
84
 
70
85
  if (fs.existsSync(pkgPath)) {
71
86
  const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
72
-
73
- pkg.name = projectNameLower; // force update
74
-
87
+ pkg.name = projectNameLower;
75
88
  fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
76
89
  }
77
90
 
78
91
  // 🔁 Rename files AFTER replacing content
79
92
  renameFiles("./");
80
93
 
81
- // 🔁 Rename webpart folder (adjust based on your original name)
94
+ // 🔁 Rename webpart folder safely
82
95
  const webpartsDir = "./src/webparts";
83
96
 
84
- fs.readdirSync(webpartsDir).forEach((folder) => {
85
- if (folder.includes("PROJECT_NAME_LOWER")) {
86
- const oldPath = path.join(webpartsDir, folder);
87
- const newPath = path.join(webpartsDir, projectNameLower);
97
+ if (fs.existsSync(webpartsDir)) {
98
+ fs.readdirSync(webpartsDir).forEach((folder) => {
99
+ if (folder.includes("__PROJECT_NAME_LOWER__")) {
100
+ const oldPath = path.join(webpartsDir, folder);
101
+ const newPath = path.join(webpartsDir, projectNameLower);
102
+
103
+ fs.renameSync(oldPath, newPath);
104
+ }
105
+ });
106
+ }
88
107
 
89
- fs.renameSync(oldPath, newPath);
90
- }
91
- });
108
+ console.log("🎉 Setup complete!");
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
3
- "id": "__WEBPART_ID__",
3
+ "id": "aa77f8d0-89f1-4335-816c-cb8bffa03b3c",
4
4
  "alias": "TemplateSpfxWebPart",
5
5
  "componentType": "WebPart",
6
6
 
@@ -12,24 +12,17 @@
12
12
  // Components that allow authors to embed arbitrary script code should set this to true.
13
13
  // https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
14
14
  "requiresCustomScript": false,
15
- "supportedHosts": [
16
- "SharePointWebPart",
17
- "TeamsPersonalApp",
18
- "TeamsTab",
19
- "SharePointFullPage"
20
- ],
15
+ "supportedHosts": ["SharePointWebPart", "TeamsPersonalApp", "TeamsTab", "SharePointFullPage"],
21
16
  "supportsThemeVariants": true,
22
17
 
23
- "preconfiguredEntries": [
24
- {
25
- "groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Advanced
26
- "group": { "default": "Advanced" },
27
- "title": { "default": "__PROJECT_NAME__" },
28
- "description": { "default": "__PROJECT_NAME__ description" },
29
- "officeFabricIconFontName": "Page",
30
- "properties": {
31
- "description": "__PROJECT_NAME__"
32
- }
18
+ "preconfiguredEntries": [{
19
+ "groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Advanced
20
+ "group": { "default": "Advanced" },
21
+ "title": { "default": "__PROJECT_NAME__" },
22
+ "description": { "default": "__PROJECT_NAME__ description" },
23
+ "officeFabricIconFontName": "Page",
24
+ "properties": {
25
+ "description": "__PROJECT_NAME__"
33
26
  }
34
- ]
27
+ }]
35
28
  }
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  const fs = require("fs");
4
4
  const path = require("path");
@@ -58,7 +58,7 @@ async function run() {
58
58
  // ⚙ Run setup script
59
59
  execSync(`node setup.js "${projectName}"`, {
60
60
  cwd: targetDir,
61
- stdio: "ignore",
61
+ stdio: "inherit",
62
62
  });
63
63
 
64
64
  spinner.succeed(chalk.green("✔ Project setup complete"));
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "engines": {
4
4
  "node": ">=22"
5
5
  },
6
- "version": "1.0.11",
6
+ "version": "1.0.13",
7
7
  "main": "index.js",
8
8
  "scripts": {
9
9
  "test": "echo \"Error: no test specified\" && exit 1"