@regressionproof/cli 0.4.0 → 0.5.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.
@@ -23,7 +23,7 @@ export default async function acceptInvite(token) {
23
23
  url: data.url,
24
24
  token: data.token,
25
25
  });
26
- writeLocalConfig(process.cwd(), projectName, data.url);
26
+ configManager.writeLocalConfig(projectName, data.url);
27
27
  ensureMirrorCloned(configManager.getConfigDir(projectName), data.url, data.token);
28
28
  console.log('Project URL:', data.url);
29
29
  console.log('Project token:', data.token);
@@ -36,16 +36,6 @@ function deriveProjectNameFromUrl(url) {
36
36
  }
37
37
  return name;
38
38
  }
39
- function writeLocalConfig(cwd, projectName, url) {
40
- const configPath = path.join(cwd, '.regressionproof.json');
41
- const payload = {
42
- projectName,
43
- remote: {
44
- url,
45
- },
46
- };
47
- fs.writeFileSync(configPath, JSON.stringify(payload, null, 2));
48
- }
49
39
  function ensureMirrorCloned(configDir, url, token) {
50
40
  const mirrorPath = path.join(configDir, 'mirror');
51
41
  if (fs.existsSync(mirrorPath)) {
@@ -1,6 +1,5 @@
1
1
  import { spawnSync } from 'node:child_process';
2
- import { existsSync, readFileSync, writeFileSync } from 'node:fs';
3
- import path from 'node:path';
2
+ import { existsSync, readFileSync } from 'node:fs';
4
3
  import { buildRegressionProofClient } from '@regressionproof/client';
5
4
  import { Box, Text, useApp } from 'ink';
6
5
  import BigText from 'ink-big-text';
@@ -115,7 +114,7 @@ class InitComponent extends React.Component {
115
114
  const credentials = await this.apiClient.registerProject({ name });
116
115
  this.setState({ credentials });
117
116
  this.configManager.saveCredentials(name, credentials);
118
- this.writeLocalConfig(name, credentials.url);
117
+ this.configManager.writeLocalConfig(name, credentials.url);
119
118
  await this.installAndConfigure();
120
119
  }
121
120
  catch (err) {
@@ -180,16 +179,6 @@ class InitComponent extends React.Component {
180
179
  }
181
180
  return { success: true };
182
181
  }
183
- writeLocalConfig(projectName, url) {
184
- const configPath = path.join(process.cwd(), '.regressionproof.json');
185
- const payload = {
186
- projectName,
187
- remote: {
188
- url,
189
- },
190
- };
191
- writeFileSync(configPath, JSON.stringify(payload, null, 2));
192
- }
193
182
  getPackageManager() {
194
183
  if (existsSync('pnpm-lock.yaml')) {
195
184
  return { command: 'pnpm', args: ['add', '-D'] };
@@ -1,6 +1,5 @@
1
1
  import { spawnSync } from 'node:child_process'
2
- import { existsSync, readFileSync, writeFileSync } from 'node:fs'
3
- import path from 'node:path'
2
+ import { existsSync, readFileSync } from 'node:fs'
4
3
  import type { RegressionProofClient } from '@regressionproof/client'
5
4
  import { buildRegressionProofClient } from '@regressionproof/client'
6
5
  import { Box, Text, useApp } from 'ink'
@@ -136,7 +135,7 @@ class InitComponent extends React.Component<Props, State> {
136
135
  this.setState({ credentials })
137
136
 
138
137
  this.configManager.saveCredentials(name, credentials)
139
- this.writeLocalConfig(name, credentials.url)
138
+ this.configManager.writeLocalConfig(name, credentials.url)
140
139
  await this.installAndConfigure()
141
140
  } catch (err) {
142
141
  this.setState({
@@ -227,17 +226,6 @@ class InitComponent extends React.Component<Props, State> {
227
226
  return { success: true }
228
227
  }
229
228
 
230
- private writeLocalConfig(projectName: string, url: string): void {
231
- const configPath = path.join(process.cwd(), '.regressionproof.json')
232
- const payload = {
233
- projectName,
234
- remote: {
235
- url,
236
- },
237
- }
238
- writeFileSync(configPath, JSON.stringify(payload, null, 2))
239
- }
240
-
241
229
  private getPackageManager(): PackageManager {
242
230
  if (existsSync('pnpm-lock.yaml')) {
243
231
  return { command: 'pnpm', args: ['add', '-D'] }
@@ -4,6 +4,7 @@ export default class ConfigManager {
4
4
  getConfigDir(projectName: string): string;
5
5
  saveCredentials(projectName: string, credentials: Credentials): void;
6
6
  loadCredentials(projectName: string): Credentials | null;
7
+ writeLocalConfig(projectName: string, url: string): void;
7
8
  }
8
9
  export interface Credentials {
9
10
  url: string;
@@ -1,6 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import os from 'os';
3
3
  import path from 'path';
4
+ import { getCliVersion } from '../utilities/version.js';
4
5
  export default class ConfigManager {
5
6
  baseDir;
6
7
  constructor(baseDir = path.join(os.homedir(), '.regressionproof')) {
@@ -32,4 +33,15 @@ export default class ConfigManager {
32
33
  token: config.remote.token,
33
34
  };
34
35
  }
36
+ writeLocalConfig(projectName, url) {
37
+ const configPath = path.join(process.cwd(), '.regressionproof.json');
38
+ const payload = {
39
+ version: getCliVersion(),
40
+ projectName,
41
+ remote: {
42
+ url,
43
+ },
44
+ };
45
+ fs.writeFileSync(configPath, JSON.stringify(payload, null, 2));
46
+ }
35
47
  }
@@ -34,7 +34,7 @@ export default function acceptInvite(token) {
34
34
  url: data.url,
35
35
  token: data.token,
36
36
  });
37
- writeLocalConfig(process.cwd(), projectName, data.url);
37
+ configManager.writeLocalConfig(projectName, data.url);
38
38
  ensureMirrorCloned(configManager.getConfigDir(projectName), data.url, data.token);
39
39
  console.log('Project URL:', data.url);
40
40
  console.log('Project token:', data.token);
@@ -49,16 +49,6 @@ function deriveProjectNameFromUrl(url) {
49
49
  }
50
50
  return name;
51
51
  }
52
- function writeLocalConfig(cwd, projectName, url) {
53
- const configPath = path.join(cwd, '.regressionproof.json');
54
- const payload = {
55
- projectName,
56
- remote: {
57
- url,
58
- },
59
- };
60
- fs.writeFileSync(configPath, JSON.stringify(payload, null, 2));
61
- }
62
52
  function ensureMirrorCloned(configDir, url, token) {
63
53
  const mirrorPath = path.join(configDir, 'mirror');
64
54
  if (fs.existsSync(mirrorPath)) {
@@ -9,8 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  var _a;
11
11
  import { spawnSync } from 'node:child_process';
12
- import { existsSync, readFileSync, writeFileSync } from 'node:fs';
13
- import path from 'node:path';
12
+ import { existsSync, readFileSync } from 'node:fs';
14
13
  import { buildRegressionProofClient } from '@regressionproof/client';
15
14
  import { Box, Text, useApp } from 'ink';
16
15
  import BigText from 'ink-big-text';
@@ -126,7 +125,7 @@ class InitComponent extends React.Component {
126
125
  const credentials = yield this.apiClient.registerProject({ name });
127
126
  this.setState({ credentials });
128
127
  this.configManager.saveCredentials(name, credentials);
129
- this.writeLocalConfig(name, credentials.url);
128
+ this.configManager.writeLocalConfig(name, credentials.url);
130
129
  yield this.installAndConfigure();
131
130
  }
132
131
  catch (err) {
@@ -195,16 +194,6 @@ class InitComponent extends React.Component {
195
194
  }
196
195
  return { success: true };
197
196
  }
198
- writeLocalConfig(projectName, url) {
199
- const configPath = path.join(process.cwd(), '.regressionproof.json');
200
- const payload = {
201
- projectName,
202
- remote: {
203
- url,
204
- },
205
- };
206
- writeFileSync(configPath, JSON.stringify(payload, null, 2));
207
- }
208
197
  getPackageManager() {
209
198
  if (existsSync('pnpm-lock.yaml')) {
210
199
  return { command: 'pnpm', args: ['add', '-D'] };
@@ -4,6 +4,7 @@ export default class ConfigManager {
4
4
  getConfigDir(projectName: string): string;
5
5
  saveCredentials(projectName: string, credentials: Credentials): void;
6
6
  loadCredentials(projectName: string): Credentials | null;
7
+ writeLocalConfig(projectName: string, url: string): void;
7
8
  }
8
9
  export interface Credentials {
9
10
  url: string;
@@ -1,6 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import os from 'os';
3
3
  import path from 'path';
4
+ import { getCliVersion } from '../utilities/version.js.js';
4
5
  export default class ConfigManager {
5
6
  constructor(baseDir = path.join(os.homedir(), '.regressionproof')) {
6
7
  this.baseDir = baseDir;
@@ -31,4 +32,15 @@ export default class ConfigManager {
31
32
  token: config.remote.token,
32
33
  };
33
34
  }
35
+ writeLocalConfig(projectName, url) {
36
+ const configPath = path.join(process.cwd(), '.regressionproof.json');
37
+ const payload = {
38
+ version: getCliVersion(),
39
+ projectName,
40
+ remote: {
41
+ url,
42
+ },
43
+ };
44
+ fs.writeFileSync(configPath, JSON.stringify(payload, null, 2));
45
+ }
34
46
  }
@@ -0,0 +1 @@
1
+ export declare function getCliVersion(): string;
@@ -0,0 +1,9 @@
1
+ import { readFileSync } from 'node:fs';
2
+ export function getCliVersion() {
3
+ const packageUrl = new URL('../../package.json', import.meta.url);
4
+ const packageJson = JSON.parse(readFileSync(packageUrl, 'utf-8'));
5
+ if (!packageJson.version) {
6
+ throw new Error('Unable to determine CLI version from package.json');
7
+ }
8
+ return packageJson.version;
9
+ }
@@ -0,0 +1 @@
1
+ export declare function getCliVersion(): string;
@@ -0,0 +1,9 @@
1
+ import { readFileSync } from 'node:fs';
2
+ export function getCliVersion() {
3
+ const packageUrl = new URL('../../package.json', import.meta.url);
4
+ const packageJson = JSON.parse(readFileSync(packageUrl, 'utf-8'));
5
+ if (!packageJson.version) {
6
+ throw new Error('Unable to determine CLI version from package.json');
7
+ }
8
+ return packageJson.version;
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@regressionproof/cli",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -38,7 +38,7 @@
38
38
  "watch.tsc": "tsc -w"
39
39
  },
40
40
  "dependencies": {
41
- "@regressionproof/client": "^0.4.0",
41
+ "@regressionproof/client": "^0.5.0",
42
42
  "dotenv": "^17.2.3",
43
43
  "ink": "^5.1.0",
44
44
  "ink-big-text": "^2.0.0",
@@ -84,5 +84,5 @@
84
84
  "^#spruce/(.*)$": "<rootDir>/build/.spruce/$1"
85
85
  }
86
86
  },
87
- "gitHead": "dc7c7eaa3342fcb4fdfae1d3c11a69b7e08dace4"
87
+ "gitHead": "ab68e3b894ee0e1bed01d35bc6f42bd1d4a2487f"
88
88
  }