Skip to content

Commit 4c286f5

Browse files
author
Rishabh Karnad
committed
Improved CLI messages and replaced 'CRNA' with 'Expo' or 'expo-cli' in messages
1 parent aa3d845 commit 4c286f5

File tree

2 files changed

+31
-22
lines changed

2 files changed

+31
-22
lines changed

src/index.js

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ program.version(projectPackageJson.version, "-v, --version");
1717

1818
program
1919
.command("init <projectName>")
20-
.option("--no-crna", "Create Normal RN Project")
20+
// .command("init <projectName>", "create a Vue-Native project")
21+
.option("--no-crna", "use react-native-cli instead of expo-cli")
2122
.action(function (projectName, cmd) {
2223
let isCrnaProject = false;
2324
if (cmd.crna) {
@@ -26,13 +27,12 @@ program
2627
// check if Create-react-native-app dependency is present or not
2728
if (!isCrnaInstalledPackageVersion) {
2829
terminateTheProcess(
29-
"Please globally install create-react-native-app dependency"
30+
"Please globally install expo-cli"
3031
);
3132
return;
3233
} else {
3334
console.log(
34-
"Installed Crna Version",
35-
chalk.green(isCrnaInstalledPackageVersion)
35+
chalk.cyan("Using globally installed expo-cli " + isCrnaInstalledPackageVersion + "\n"),
3636
);
3737
}
3838
} else {
@@ -48,10 +48,12 @@ program
4848
);
4949
}
5050
}
51+
5152
const isProjectNameValidResponse = validationObjects.isProjectNameValid(
5253
projectName,
5354
isCrnaProject
5455
);
56+
5557
// if project Name is invalid Ask User, Do They Want to Continue
5658
if (!isProjectNameValidResponse) {
5759
promptModule.promptForInvalidProjectName(
@@ -103,7 +105,7 @@ function createReactNativeCLIProject(projectName, cmd) {
103105
if (fs.existsSync(projectName)) {
104106
removeExistingDirectory(projectName);
105107
}
106-
console.log(chalk.green(`Creating Vue-Native ${projectName} App`));
108+
console.log(chalk.green(`Creating Vue Native project ${chalk.bold(projectName)}`));
107109
createRNProjectSync(projectName, cmd);
108110
handleAndAddVueNativePackageDependencySync(projectName, cmd);
109111
setupVueNativeApp(projectName, cmd);
@@ -114,44 +116,50 @@ function createExpoProject(projectName, cmd) {
114116
if (fs.existsSync(projectName)) {
115117
removeExistingDirectory(projectName);
116118
}
117-
console.log(chalk.green(`Creating Vue-Native ${projectName} App`));
119+
console.log(chalk.green(`Creating Vue Native project ${chalk.bold(projectName)}\n`));
118120
createCrnaProjectSync(projectName, cmd);
119121
handleAndAddVueNativePackageDependencySync(projectName, cmd);
120122
setupVueNativeApp(projectName, cmd, true);
121123
}
122124

123125
function createCrnaProjectSync(projectName, cmd) {
124126
const spinner = ora(
125-
`Creating Crna ${chalk.green(projectName)} project \n`
127+
chalk.cyan("Creating project with expo-cli\n"),
126128
).start();
127129
const crnaProjectCreationResponse = spawnSync(
128130
constantObjects.crnaPackageName,
129131
['init', '--template=blank', projectName],
130132
{ stdio: "inherit", shell: true }
131133
);
132-
spinner.succeed(`Create Crna ${chalk.green(projectName)} project`);
134+
spinner.succeed(
135+
chalk.green("Created project with expo-cli\n"),
136+
);
133137
}
134138

135139
function createRNProjectSync(projectName, cmd) {
136140
const spinner = ora(
137-
`Creating react native app ${chalk.green(projectName)} project \n`
141+
chalk.cyan("Creating project with react-native-cli\n"),
138142
).start();
139143
const rnProjectCreationResponse = spawnSync(
140144
constantObjects.rnPackageName,
141145
["init", projectName, "--version", constantObjects.stableRNVersion],
142146
{ stdio: "inherit", shell: true }
143147
);
144-
spinner.succeed(`Create react-native ${chalk.green(projectName)} project`);
148+
spinner.succeed(
149+
chalk.green("Created project with react-native-cli\n"),
150+
);
145151
}
146152

147153
function removeExistingDirectory(directoryName) {
148154
const spinner = ora(
149-
`Removing ${chalk.green(directoryName)} project \n`
155+
chalk.yellow(`Removing pre-existing directory with name ${directoryName}\n`),
150156
).start();
151157
const crnaProjectCreationResponse = spawnSync("rm", ["-fr", directoryName], {
152158
stdio: "inherit"
153159
});
154-
spinner.succeed(`Removed ${chalk.green(directoryName)} project`);
160+
spinner.succeed(
161+
chalk.yellow(`Removed pre-existing directory with name ${directoryName}\n`),
162+
);
155163
}
156164

157165
function handleAndAddVueNativePackageDependencySync(projectName, cmd) {
@@ -163,30 +171,30 @@ function handleAndAddVueNativePackageDependencySync(projectName, cmd) {
163171

164172
function installVueNativeDependency() {
165173
const spinner = ora(
166-
`Installing ${chalk.green("Vue Native Dependency")} Packages \n`
174+
chalk.cyan("Installing Vue Native dependencies\n"),
167175
).start();
168176
const commandObj = getVueNativeDependencyPackageInstallationCommand();
169177
const crnaProjectCreationResponse = spawnSync(
170178
commandObj.commandName,
171179
commandObj.optionsArr,
172-
{ shell: true }
180+
{ shell: true, stdio: "inherit" }
173181
);
174182
spinner.succeed(
175-
`Installed ${chalk.green("Vue Native Dependency")} Packages \n`
183+
chalk.green("Installed Vue Native dependencies\n")
176184
);
177185
}
178186
function installVueNativeDevDependency() {
179187
const spinner = ora(
180-
`Installing ${chalk.green("Vue Native Dev-dependency")} Packages`
188+
chalk.cyan("Installing Vue Native devDependencies\n"),
181189
).start();
182190
const commandObj = getVueNativeDevDependencyPackageInstallationCommand();
183191
const crnaProjectCreationResponse = spawnSync(
184192
commandObj.commandName,
185193
commandObj.optionsArr,
186-
{ shell: true }
194+
{ shell: true, stdio: "inherit" }
187195
);
188196
spinner.succeed(
189-
`Installed ${chalk.green("Vue Native Dev-Dependency")} Packages`
197+
chalk.green("Installed Vue-Native devDependencies\n"),
190198
);
191199
}
192200

@@ -285,7 +293,7 @@ function setupVueNativeApp(projectName, cmd, isCrna = false) {
285293
appVueFileContent
286294
);
287295
console.log(
288-
chalk.green(`Completed Installing Vue Native ${projectName} App`)
296+
chalk.green("Setup complete!")
289297
);
290298
}
291299

src/prompt/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const chalk = require("chalk");
2+
23
function promptForInvalidProjectName(
34
promptObj,
45
onSuccessAnswer,
@@ -11,9 +12,9 @@ function promptForInvalidProjectName(
1112
const property = {
1213
name: "invalidProjectName",
1314
message:
14-
"Directory " + projectName + " Is InValid. Do You Want To Continue?",
15+
"Directory " + projectName + " is invalid. Do you want to continue?",
1516
validator: /y[es]*|n[o]?/,
16-
warning: "Must respond yes or no",
17+
warning: "Please respond with y(es) or n(o)",
1718
default: "no"
1819
};
1920

@@ -39,7 +40,7 @@ function createVueProjectAfterConfirmation(
3940
name: "directoryExistAndContinue",
4041
message: "Directory " + name + " already exists. Continue?",
4142
validator: /y[es]*|n[o]?/,
42-
warning: "Must respond yes or no",
43+
warning: "Please respond with y(es) or n(o)",
4344
default: "no"
4445
};
4546

0 commit comments

Comments
 (0)