revine 0.6.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.
- package/dist/commands/createProject.js +5 -3
- package/dist/prompts/git.js +56 -0
- package/dist/prompts/index.js +2 -1
- package/dist/prompts/project.js +1 -1
- package/package.json +1 -1
- package/src/commands/createProject.ts +6 -3
- package/src/prompts/git.ts +61 -0
- package/src/prompts/index.ts +2 -1
- package/src/prompts/project.ts +1 -1
|
@@ -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, initiateProject } from "../prompts/index.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,8 +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
|
-
//
|
|
45
|
-
await
|
|
44
|
+
// Check if Git exists and initialize repository if user agrees
|
|
45
|
+
await initGit(projectDir);
|
|
46
|
+
// Prompt to run project
|
|
47
|
+
await runProject(projectDir);
|
|
46
48
|
}
|
|
47
49
|
catch (error) {
|
|
48
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
|
+
}
|
package/dist/prompts/index.js
CHANGED
package/dist/prompts/project.js
CHANGED
|
@@ -6,7 +6,7 @@ import { logInfo } from "../utils/logger.js";
|
|
|
6
6
|
* If the user confirms, it will run `npm run dev` or the equivalent command.
|
|
7
7
|
* @param projectDir - The directory where the project was set up.
|
|
8
8
|
*/
|
|
9
|
-
export default async function
|
|
9
|
+
export default async function runProject(projectDir) {
|
|
10
10
|
const { runProject } = await inquirer.prompt([
|
|
11
11
|
{
|
|
12
12
|
type: "confirm",
|
package/package.json
CHANGED
|
@@ -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, initiateProject } from "../prompts/index.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";
|
|
@@ -53,8 +53,11 @@ export async function createProject(
|
|
|
53
53
|
if (!isCurrentDir) console.log(` cd ${projectName}`);
|
|
54
54
|
console.log(" npm run dev\n");
|
|
55
55
|
|
|
56
|
-
//
|
|
57
|
-
await
|
|
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);
|
|
58
61
|
} catch (error) {
|
|
59
62
|
logError("Error during project creation:", error);
|
|
60
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
|
+
}
|
package/src/prompts/index.ts
CHANGED
package/src/prompts/project.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { logInfo } from "../utils/logger.js";
|
|
|
7
7
|
* If the user confirms, it will run `npm run dev` or the equivalent command.
|
|
8
8
|
* @param projectDir - The directory where the project was set up.
|
|
9
9
|
*/
|
|
10
|
-
export default async function
|
|
10
|
+
export default async function runProject(projectDir: string) {
|
|
11
11
|
const { runProject } = await inquirer.prompt([
|
|
12
12
|
{
|
|
13
13
|
type: "confirm",
|