revine 0.5.0 → 0.7.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.
@@ -2,8 +2,8 @@ import path from "path";
2
2
  import { fileURLToPath } from "url";
3
3
  import { updatePackageJson } from "../config/package.js";
4
4
  import { updateReadme } from "../config/readme.js";
5
+ import { askForTailwindSetup, initGit, runProject } from "../prompts/index.js";
5
6
  import { installDependencies } from "../setup/dependencies.js";
6
- import { askForTailwindSetup } from "../prompts/tailwind.js";
7
7
  import { setupTailwind } from "../setup/tailwind.js";
8
8
  import { copyTemplate } from "../utils/file.js";
9
9
  import { logError, logInfo } from "../utils/logger.js";
@@ -41,6 +41,10 @@ export async function createProject(projectName, options) {
41
41
  if (!isCurrentDir)
42
42
  console.log(` cd ${projectName}`);
43
43
  console.log(" npm run dev\n");
44
+ // Check if Git exists and initialize repository if user agrees
45
+ await initGit(projectDir);
46
+ // Prompt to run project
47
+ await runProject(projectDir);
44
48
  }
45
49
  catch (error) {
46
50
  logError("Error during project creation:", error);
@@ -0,0 +1,56 @@
1
+ import inquirer from "inquirer";
2
+ import { execSync } from "child_process";
3
+ import { logInfo, logError } from "../utils/logger.js";
4
+ /**
5
+ * Check if Git is installed on the system.
6
+ * @returns {boolean} true if Git exists, false otherwise.
7
+ */
8
+ function checkGitInstalled() {
9
+ try {
10
+ execSync("git --version", { stdio: "ignore" });
11
+ return true;
12
+ }
13
+ catch {
14
+ return false;
15
+ }
16
+ }
17
+ /**
18
+ * Initialize a Git repository in the project directory.
19
+ * @param projectDir - The directory where the project was set up.
20
+ */
21
+ export default async function initGit(projectDir) {
22
+ if (!checkGitInstalled()) {
23
+ logError("Git is not installed. Please install Git to use version control.");
24
+ return;
25
+ }
26
+ const { initializeGit } = await inquirer.prompt([
27
+ {
28
+ type: "confirm",
29
+ name: "initializeGit",
30
+ message: "Do you want to initialize a Git repository?",
31
+ default: true,
32
+ },
33
+ ]);
34
+ if (initializeGit) {
35
+ const { commitMessage } = await inquirer.prompt([
36
+ {
37
+ type: "input",
38
+ name: "commitMessage",
39
+ message: "Enter the initial commit message:",
40
+ default: "chore: initial setup from revine",
41
+ },
42
+ ]);
43
+ try {
44
+ execSync("git init", { cwd: projectDir, stdio: "inherit" });
45
+ execSync("git add .", { cwd: projectDir, stdio: "inherit" });
46
+ execSync(`git commit -m "${commitMessage}"`, {
47
+ cwd: projectDir,
48
+ stdio: "inherit",
49
+ });
50
+ logInfo("Git repository initialized and initial commit created.");
51
+ }
52
+ catch (error) {
53
+ logError("Failed to initialize Git repository or create commit.");
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,3 @@
1
+ export { default as askForTailwindSetup } from "./tailwind.js";
2
+ export { default as runProject } from "./project.js";
3
+ export { default as initGit } from "./git.js";
@@ -0,0 +1,27 @@
1
+ import inquirer from "inquirer";
2
+ import { execSync } from "child_process";
3
+ import { logInfo } from "../utils/logger.js";
4
+ /**
5
+ * Ask the user if they want to run the project after setup is complete.
6
+ * If the user confirms, it will run `npm run dev` or the equivalent command.
7
+ * @param projectDir - The directory where the project was set up.
8
+ */
9
+ export default async function runProject(projectDir) {
10
+ const { runProject } = await inquirer.prompt([
11
+ {
12
+ type: "confirm",
13
+ name: "runProject",
14
+ message: "Do you want to run the project now?",
15
+ default: true,
16
+ },
17
+ ]);
18
+ if (runProject) {
19
+ logInfo("Running your Revine project on dev server...");
20
+ try {
21
+ execSync("npm run dev", { cwd: projectDir, stdio: "inherit" });
22
+ }
23
+ catch (error) {
24
+ logInfo("Failed to start the project. You can manually run `npm run dev`.");
25
+ }
26
+ }
27
+ }
@@ -1,5 +1,5 @@
1
1
  import inquirer from "inquirer";
2
- export async function askForTailwindSetup() {
2
+ export default async function askForTailwindSetup() {
3
3
  const { useTailwind } = await inquirer.prompt([
4
4
  {
5
5
  type: "confirm",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "revine",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "A react framework, but better.",
5
5
  "license": "ISC",
6
6
  "author": "Rachit Bharadwaj",
@@ -2,8 +2,8 @@ import path from "path";
2
2
  import { fileURLToPath } from "url";
3
3
  import { updatePackageJson } from "../config/package.js";
4
4
  import { updateReadme } from "../config/readme.js";
5
+ import { askForTailwindSetup, initGit, runProject } from "../prompts/index.js";
5
6
  import { installDependencies } from "../setup/dependencies.js";
6
- import { askForTailwindSetup } from "../prompts/tailwind.js";
7
7
  import { setupTailwind } from "../setup/tailwind.js";
8
8
  import { copyTemplate } from "../utils/file.js";
9
9
  import { logError, logInfo } from "../utils/logger.js";
@@ -52,6 +52,12 @@ export async function createProject(
52
52
  logInfo("\nStart developing with:");
53
53
  if (!isCurrentDir) console.log(` cd ${projectName}`);
54
54
  console.log(" npm run dev\n");
55
+
56
+ // Check if Git exists and initialize repository if user agrees
57
+ await initGit(projectDir);
58
+
59
+ // Prompt to run project
60
+ await runProject(projectDir);
55
61
  } catch (error) {
56
62
  logError("Error during project creation:", error);
57
63
  process.exit(1);
@@ -0,0 +1,61 @@
1
+ import inquirer from "inquirer";
2
+ import { execSync } from "child_process";
3
+ import { logInfo, logError } from "../utils/logger.js";
4
+
5
+ /**
6
+ * Check if Git is installed on the system.
7
+ * @returns {boolean} true if Git exists, false otherwise.
8
+ */
9
+ function checkGitInstalled() {
10
+ try {
11
+ execSync("git --version", { stdio: "ignore" });
12
+ return true;
13
+ } catch {
14
+ return false;
15
+ }
16
+ }
17
+
18
+ /**
19
+ * Initialize a Git repository in the project directory.
20
+ * @param projectDir - The directory where the project was set up.
21
+ */
22
+ export default async function initGit(projectDir: string) {
23
+ if (!checkGitInstalled()) {
24
+ logError(
25
+ "Git is not installed. Please install Git to use version control."
26
+ );
27
+ return;
28
+ }
29
+
30
+ const { initializeGit } = await inquirer.prompt([
31
+ {
32
+ type: "confirm",
33
+ name: "initializeGit",
34
+ message: "Do you want to initialize a Git repository?",
35
+ default: true,
36
+ },
37
+ ]);
38
+
39
+ if (initializeGit) {
40
+ const { commitMessage } = await inquirer.prompt([
41
+ {
42
+ type: "input",
43
+ name: "commitMessage",
44
+ message: "Enter the initial commit message:",
45
+ default: "chore: initial setup from revine",
46
+ },
47
+ ]);
48
+
49
+ try {
50
+ execSync("git init", { cwd: projectDir, stdio: "inherit" });
51
+ execSync("git add .", { cwd: projectDir, stdio: "inherit" });
52
+ execSync(`git commit -m "${commitMessage}"`, {
53
+ cwd: projectDir,
54
+ stdio: "inherit",
55
+ });
56
+ logInfo("Git repository initialized and initial commit created.");
57
+ } catch (error) {
58
+ logError("Failed to initialize Git repository or create commit.");
59
+ }
60
+ }
61
+ }
@@ -0,0 +1,3 @@
1
+ export { default as askForTailwindSetup } from "./tailwind.js";
2
+ export { default as runProject } from "./project.js";
3
+ export { default as initGit } from "./git.js";
@@ -0,0 +1,31 @@
1
+ import inquirer from "inquirer";
2
+ import { execSync } from "child_process";
3
+ import { logInfo } from "../utils/logger.js";
4
+
5
+ /**
6
+ * Ask the user if they want to run the project after setup is complete.
7
+ * If the user confirms, it will run `npm run dev` or the equivalent command.
8
+ * @param projectDir - The directory where the project was set up.
9
+ */
10
+ export default async function runProject(projectDir: string) {
11
+ const { runProject } = await inquirer.prompt([
12
+ {
13
+ type: "confirm",
14
+ name: "runProject",
15
+ message: "Do you want to run the project now?",
16
+ default: true,
17
+ },
18
+ ]);
19
+
20
+ if (runProject) {
21
+ logInfo("Running your Revine project on dev server...");
22
+
23
+ try {
24
+ execSync("npm run dev", { cwd: projectDir, stdio: "inherit" });
25
+ } catch (error) {
26
+ logInfo(
27
+ "Failed to start the project. You can manually run `npm run dev`."
28
+ );
29
+ }
30
+ }
31
+ }
@@ -1,6 +1,6 @@
1
1
  import inquirer from "inquirer";
2
2
 
3
- export async function askForTailwindSetup(): Promise<boolean> {
3
+ export default async function askForTailwindSetup(): Promise<boolean> {
4
4
  const { useTailwind } = await inquirer.prompt([
5
5
  {
6
6
  type: "confirm",