create-spfx-tailwind-app 1.0.16 โ 1.0.17
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/index.js +25 -27
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -8,11 +8,6 @@ const ora = require("ora");
|
|
|
8
8
|
const inquirer = require("inquirer");
|
|
9
9
|
const figlet = require("figlet");
|
|
10
10
|
const gradient = require("gradient-string").default;
|
|
11
|
-
const setupPath = path.join(targetDir, "setup.js");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// ๐จ Banner
|
|
15
|
-
|
|
16
11
|
|
|
17
12
|
console.log(
|
|
18
13
|
gradient.instagram(figlet.textSync("SPFx CLI", { horizontalLayout: "full" })),
|
|
@@ -21,11 +16,8 @@ console.log(
|
|
|
21
16
|
async function run() {
|
|
22
17
|
try {
|
|
23
18
|
const args = process.argv.slice(2);
|
|
24
|
-
|
|
25
|
-
// ๐น detect flags
|
|
26
19
|
const noInstallFlag = args.includes("--no-install");
|
|
27
20
|
|
|
28
|
-
// ๐น get project name
|
|
29
21
|
let projectName = args.find((arg) => !arg.startsWith("--"));
|
|
30
22
|
|
|
31
23
|
if (!projectName) {
|
|
@@ -47,6 +39,7 @@ async function run() {
|
|
|
47
39
|
|
|
48
40
|
const templateDir = path.join(__dirname, "Template");
|
|
49
41
|
const targetDir = path.join(process.cwd(), projectName);
|
|
42
|
+
const setupPath = path.join(targetDir, "setup.js");
|
|
50
43
|
|
|
51
44
|
console.log(chalk.cyan("\n๐ Creating your SPFx project...\n"));
|
|
52
45
|
|
|
@@ -55,33 +48,39 @@ async function run() {
|
|
|
55
48
|
// ๐ Copy template
|
|
56
49
|
fs.cpSync(templateDir, targetDir, { recursive: true });
|
|
57
50
|
|
|
58
|
-
spinner.text = "
|
|
51
|
+
spinner.text = "Running setup...";
|
|
59
52
|
|
|
60
|
-
// โ Run setup
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
53
|
+
// โ Run setup.js if exists
|
|
54
|
+
if (fs.existsSync(setupPath)) {
|
|
55
|
+
execSync(`node setup.js "${projectName}"`, {
|
|
56
|
+
cwd: targetDir,
|
|
57
|
+
stdio: "inherit",
|
|
58
|
+
});
|
|
59
|
+
}
|
|
65
60
|
|
|
66
|
-
spinner.
|
|
61
|
+
spinner.text = "Cleaning up...";
|
|
67
62
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
63
|
+
// ๐งน Remove setup.js after execution
|
|
64
|
+
try {
|
|
65
|
+
if (fs.existsSync(setupPath)) {
|
|
66
|
+
fs.unlinkSync(setupPath);
|
|
67
|
+
// optional log
|
|
68
|
+
// console.log(chalk.gray("๐งน setup.js removed"));
|
|
69
|
+
}
|
|
70
|
+
} catch (err) {
|
|
71
|
+
console.log(chalk.yellow("โ ๏ธ Could not remove setup.js"));
|
|
72
|
+
}
|
|
76
73
|
|
|
77
|
-
|
|
74
|
+
spinner.succeed(chalk.green("โ Project setup complete"));
|
|
75
|
+
|
|
76
|
+
// ๐ detect Tailwind
|
|
78
77
|
let hasTailwind = false;
|
|
79
78
|
try {
|
|
80
79
|
const pkg = require(path.join(targetDir, "package.json"));
|
|
81
80
|
hasTailwind = !!pkg.scripts?.["build:tailwind"];
|
|
82
81
|
} catch {}
|
|
83
82
|
|
|
84
|
-
// โ Ask install
|
|
83
|
+
// โ Ask install
|
|
85
84
|
let install = true;
|
|
86
85
|
|
|
87
86
|
if (noInstallFlag) {
|
|
@@ -114,7 +113,7 @@ async function run() {
|
|
|
114
113
|
}
|
|
115
114
|
}
|
|
116
115
|
|
|
117
|
-
// ๐
|
|
116
|
+
// ๐ Done
|
|
118
117
|
console.log("\n" + chalk.bold.green("๐ Project created successfully!\n"));
|
|
119
118
|
|
|
120
119
|
console.log(chalk.yellow("๐ Next steps:"));
|
|
@@ -138,7 +137,6 @@ async function run() {
|
|
|
138
137
|
}
|
|
139
138
|
|
|
140
139
|
console.log("\n" + chalk.gray("Happy coding ๐\n"));
|
|
141
|
-
|
|
142
140
|
} catch (err) {
|
|
143
141
|
console.log(chalk.red("\nโ Something went wrong\n"));
|
|
144
142
|
console.error(err);
|