@regressionproof/cli 0.3.5 → 0.3.7
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 +6 -3
- package/.nvmrc +0 -1
- package/.vscode/launch.json +0 -58
- package/.vscode/settings.json +0 -67
- package/.vscode/tasks.json +0 -112
- package/CHANGELOG.md +0 -314
- package/eslint.config.mjs +0 -3
- package/src/.spruce/settings.json +0 -16
- package/src/cli.ts +0 -53
- package/src/commands/invite/AcceptInvite.ts +0 -21
- package/src/commands/invite/CreateInvite.ts +0 -60
- package/src/commands/invite/ListInvites.ts +0 -33
- package/src/commands/invite/RevokeInvite.ts +0 -18
- package/src/components/Init.tsx +0 -436
- package/src/config/ConfigManager.ts +0 -64
- package/src/index.ts +0 -1
- package/src/jest/JestConfigurator.ts +0 -92
- package/src/utilities/slug.ts +0 -22
- package/terms.md +0 -3
- package/tsconfig.json +0 -42
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import fs from 'fs'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
|
|
4
|
-
export default class JestConfigurator {
|
|
5
|
-
private cwd: string
|
|
6
|
-
private reporterPackage = '@regressionproof/jest-reporter'
|
|
7
|
-
|
|
8
|
-
public constructor(cwd: string = process.cwd()) {
|
|
9
|
-
this.cwd = cwd
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
public configure(): JestConfigResult {
|
|
13
|
-
return (
|
|
14
|
-
this.tryConfigurePackageJson() ??
|
|
15
|
-
this.tryConfigureJestConfig('jest.config.ts') ??
|
|
16
|
-
this.tryConfigureJestConfig('jest.config.js') ?? {
|
|
17
|
-
configured: false,
|
|
18
|
-
location: '',
|
|
19
|
-
}
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
private tryConfigurePackageJson(): JestConfigResult | null {
|
|
24
|
-
const packageJsonPath = path.join(this.cwd, 'package.json')
|
|
25
|
-
if (!fs.existsSync(packageJsonPath)) {
|
|
26
|
-
return null
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const packageJson = JSON.parse(
|
|
30
|
-
fs.readFileSync(packageJsonPath, 'utf-8')
|
|
31
|
-
)
|
|
32
|
-
if (!packageJson.jest) {
|
|
33
|
-
return null
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (!packageJson.jest.reporters) {
|
|
37
|
-
packageJson.jest.reporters = ['default']
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (!packageJson.jest.reporters.includes(this.reporterPackage)) {
|
|
41
|
-
packageJson.jest.reporters.push(this.reporterPackage)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
fs.writeFileSync(
|
|
45
|
-
packageJsonPath,
|
|
46
|
-
JSON.stringify(packageJson, null, 2) + '\n'
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
return { configured: true, location: 'package.json' }
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
private tryConfigureJestConfig(filename: string): JestConfigResult | null {
|
|
53
|
-
const configPath = path.join(this.cwd, filename)
|
|
54
|
-
if (!fs.existsSync(configPath)) {
|
|
55
|
-
return null
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
let content = fs.readFileSync(configPath, 'utf-8')
|
|
59
|
-
|
|
60
|
-
if (content.includes(this.reporterPackage)) {
|
|
61
|
-
return {
|
|
62
|
-
configured: true,
|
|
63
|
-
location: `${filename} (already configured)`,
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (content.includes('reporters:')) {
|
|
68
|
-
content = content.replace(
|
|
69
|
-
/(reporters:\s*\[)/,
|
|
70
|
-
`$1'${this.reporterPackage}', `
|
|
71
|
-
)
|
|
72
|
-
} else {
|
|
73
|
-
const exportPattern = filename.endsWith('.ts')
|
|
74
|
-
? /(export\s+default\s*\{)/
|
|
75
|
-
: /(module\.exports\s*=\s*\{)/
|
|
76
|
-
|
|
77
|
-
content = content.replace(
|
|
78
|
-
exportPattern,
|
|
79
|
-
`$1\n reporters: ['default', '${this.reporterPackage}'],`
|
|
80
|
-
)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
fs.writeFileSync(configPath, content)
|
|
84
|
-
|
|
85
|
-
return { configured: true, location: filename }
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export interface JestConfigResult {
|
|
90
|
-
configured: boolean
|
|
91
|
-
location: string
|
|
92
|
-
}
|
package/src/utilities/slug.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { execSync } from 'child_process'
|
|
2
|
-
|
|
3
|
-
export function toSlug(input: string): string {
|
|
4
|
-
return input
|
|
5
|
-
.toLowerCase()
|
|
6
|
-
.replace(/\s+/g, '-')
|
|
7
|
-
.replace(/[^a-z0-9-_]/g, '')
|
|
8
|
-
.replace(/-+/g, '-')
|
|
9
|
-
.replace(/^-|-$/g, '')
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function getRepoNameFromGit(): string {
|
|
13
|
-
try {
|
|
14
|
-
const remoteUrl = execSync('git remote get-url origin', {
|
|
15
|
-
encoding: 'utf-8',
|
|
16
|
-
}).trim()
|
|
17
|
-
const match = remoteUrl.match(/[/:]([^/:]+?)(\.git)?$/)
|
|
18
|
-
return toSlug(match?.[1] ?? '')
|
|
19
|
-
} catch {
|
|
20
|
-
return ''
|
|
21
|
-
}
|
|
22
|
-
}
|
package/terms.md
DELETED
package/tsconfig.json
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"skipLibCheck": true,
|
|
4
|
-
"module": "nodenext",
|
|
5
|
-
"esModuleInterop": true,
|
|
6
|
-
"target": "ES2022",
|
|
7
|
-
"lib": [
|
|
8
|
-
"DOM",
|
|
9
|
-
"ES2022"
|
|
10
|
-
],
|
|
11
|
-
"jsx": "react",
|
|
12
|
-
"declaration": true,
|
|
13
|
-
"noImplicitAny": true,
|
|
14
|
-
"allowJs": true,
|
|
15
|
-
"forceConsistentCasingInFileNames": true,
|
|
16
|
-
"noImplicitReturns": true,
|
|
17
|
-
"strict": true,
|
|
18
|
-
"noUnusedLocals": true,
|
|
19
|
-
"resolveJsonModule": true,
|
|
20
|
-
"moduleResolution": "nodenext",
|
|
21
|
-
"sourceMap": false,
|
|
22
|
-
"outDir": "build",
|
|
23
|
-
"baseUrl": "src",
|
|
24
|
-
"experimentalDecorators": true,
|
|
25
|
-
"paths": {
|
|
26
|
-
"#spruce/*": [
|
|
27
|
-
".spruce/*"
|
|
28
|
-
]
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"include": [
|
|
32
|
-
"./src/*.ts",
|
|
33
|
-
"./src/**/*.ts",
|
|
34
|
-
"./src/*.tsx",
|
|
35
|
-
"./src/**/*.tsx",
|
|
36
|
-
"./src/.spruce/**/*"
|
|
37
|
-
],
|
|
38
|
-
"exclude": [
|
|
39
|
-
"build",
|
|
40
|
-
"esm"
|
|
41
|
-
]
|
|
42
|
-
}
|