gent-cli 1.1.0 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gent-cli",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "A Git-like version control CLI tool with cloud authentication",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -22,12 +22,25 @@ async function init(options) {
22
22
  try {
23
23
  const cwd = process.cwd();
24
24
  const gentPath = path.join(cwd, GENT_DIR);
25
+ let isReinit = false;
25
26
 
26
27
  // Check if already initialized
27
28
  if (await pathExists(gentPath)) {
28
- spinner.fail(chalk.red('Gent repository already exists!'));
29
- console.log(chalk.yellow('\nℹ Use gent status to see the current state'));
30
- return;
29
+ spinner.stop();
30
+ const { reinitialize } = await inquirer.prompt([
31
+ {
32
+ type: 'confirm',
33
+ name: 'reinitialize',
34
+ message: 'Gent repository already exists. Re-initialize? (This preserves your history)',
35
+ default: true
36
+ }
37
+ ]);
38
+
39
+ if (!reinitialize) {
40
+ console.log(chalk.yellow('\nℹ Use gent status to see the current state'));
41
+ return;
42
+ }
43
+ isReinit = true;
31
44
  }
32
45
 
33
46
  // Get user configuration if not using defaults
@@ -44,7 +57,7 @@ async function init(options) {
44
57
  };
45
58
 
46
59
  if (!options.yes) {
47
- spinner.stop();
60
+ spinner.stop(); // Ensure spinner is stopped before prompt
48
61
 
49
62
  const answers = await inquirer.prompt([
50
63
  {
@@ -82,7 +95,7 @@ async function init(options) {
82
95
  config.repository.name = answers.repoName;
83
96
  config.repository.description = answers.repoDescription;
84
97
 
85
- spinner.start('Creating repository structure...');
98
+ spinner.start(isReinit ? 'Re-initializing repository...' : 'Creating repository structure...');
86
99
  }
87
100
 
88
101
  // Create directory structure
@@ -91,25 +104,44 @@ async function init(options) {
91
104
  await ensureDir(path.join(gentPath, 'refs', 'heads'));
92
105
  await ensureDir(path.join(gentPath, 'refs', 'tags'));
93
106
 
94
- // Create initial files
107
+ // Create/Update configuration
95
108
  await writeJSON(path.join(gentPath, CONFIG_FILE), config);
96
- await writeJSON(path.join(gentPath, STAGING_FILE), { files: [] });
97
- await writeJSON(path.join(gentPath, COMMITS_FILE), { commits: [], branches: { main: null }, currentBranch: 'main' });
98
109
 
99
- // Create HEAD file
100
- await fs.writeFile(path.join(gentPath, 'HEAD'), 'ref: refs/heads/main\n');
110
+ // Create initial files only if they don't exist (preserve history on re-init)
111
+ const stagingPath = path.join(gentPath, STAGING_FILE);
112
+ if (!isReinit || !(await pathExists(stagingPath))) {
113
+ await writeJSON(stagingPath, { files: [] });
114
+ }
115
+
116
+ const commitsPath = path.join(gentPath, COMMITS_FILE);
117
+ if (!isReinit || !(await pathExists(commitsPath))) {
118
+ await writeJSON(commitsPath, { commits: [], branches: { main: null }, currentBranch: 'main' });
119
+ }
101
120
 
102
- // Create .gentignore
103
- const gentignore = `# Gent ignore patterns
121
+ // Create HEAD file only if it doesn't exist
122
+ const headPath = path.join(gentPath, 'HEAD');
123
+ if (!isReinit || !(await pathExists(headPath))) {
124
+ await fs.writeFile(headPath, 'ref: refs/heads/main\n');
125
+ }
126
+
127
+ // Create .gentignore only if it doesn't exist
128
+ const ignorePath = path.join(cwd, '.gentignore');
129
+ if (!isReinit || !(await pathExists(ignorePath))) {
130
+ const gentignore = `# Gent ignore patterns
104
131
  node_modules/
105
132
  .DS_Store
106
133
  *.log
107
134
  .env
108
135
  .gent/
109
136
  `;
110
- await fs.writeFile(path.join(cwd, '.gentignore'), gentignore);
137
+ await fs.writeFile(ignorePath, gentignore);
138
+ }
111
139
 
112
- spinner.succeed(chalk.green('✓ Gent repository initialized successfully!'));
140
+ if (isReinit) {
141
+ spinner.succeed(chalk.green('✓ Gent repository re-initialized successfully!'));
142
+ } else {
143
+ spinner.succeed(chalk.green('✓ Gent repository initialized successfully!'));
144
+ }
113
145
 
114
146
  // Display success message
115
147
  const message = chalk.white(`
@@ -13,7 +13,7 @@ const apiClient = axios.create({
13
13
  headers: {
14
14
  'Content-Type': 'application/json'
15
15
  },
16
- timeout: 30000 // 30 seconds
16
+ timeout: 60000 // 60 seconds
17
17
  });
18
18
 
19
19
  // Track if we're currently refreshing token to avoid multiple refresh requests