declapract-typescript-ehmpathy 0.47.71 → 0.47.72
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/practices/environments/bad-practices/old-stage-enum/src/<star><star>/<star>.ts.declapract.ts +1 -1
- package/dist/practices/provision-github/bad-practices/deprecated-reviewers-variable/declapract.use.yml.declapract.ts +41 -0
- package/dist/practices/provision-github/best-practice/provision/github.repo/resources.ts +1 -1
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ export const check: FileCheckFunction = (contents) => {
|
|
|
17
17
|
export const fix: FileFixFunction = (contents) => {
|
|
18
18
|
if (!contents) return { contents };
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
const fixed = contents
|
|
21
21
|
// replace enum values with string literals
|
|
22
22
|
.replace(/Stage\.PRODUCTION/g, "'prod'")
|
|
23
23
|
.replace(/Stage\.DEVELOPMENT/g, "'prep'")
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { FileCheckFunction, FileFixFunction } from 'declapract';
|
|
2
|
+
import yaml from 'yaml';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* .what = removes deprecated reviewers.users variable from declapract.use.yml
|
|
6
|
+
* .why = production-on-else environment now uses team:releaser instead of user list
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const check: FileCheckFunction = (contents) => {
|
|
10
|
+
if (!contents) throw new Error('no file found');
|
|
11
|
+
|
|
12
|
+
const parsed = yaml.parse(contents) as {
|
|
13
|
+
variables?: Record<string, unknown>;
|
|
14
|
+
};
|
|
15
|
+
const variables = parsed?.variables ?? {};
|
|
16
|
+
|
|
17
|
+
// check if reviewers or reviewers.users exists
|
|
18
|
+
if ('reviewers' in variables) return; // bad practice detected
|
|
19
|
+
|
|
20
|
+
throw new Error('no deprecated reviewers variable found');
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const fix: FileFixFunction = (contents) => {
|
|
24
|
+
if (!contents) return { contents };
|
|
25
|
+
|
|
26
|
+
// parse with parseDocument to preserve comments and format
|
|
27
|
+
const doc = yaml.parseDocument(contents);
|
|
28
|
+
const parsed = doc.toJSON() as { variables?: Record<string, unknown> };
|
|
29
|
+
|
|
30
|
+
if (!parsed?.variables || !('reviewers' in parsed.variables)) {
|
|
31
|
+
return { contents };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// remove the reviewers key from variables
|
|
35
|
+
const variablesNode = doc.get('variables') as yaml.YAMLMap | undefined;
|
|
36
|
+
if (variablesNode) {
|
|
37
|
+
variablesNode.delete('reviewers');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return { contents: doc.toString() };
|
|
41
|
+
};
|
|
@@ -134,7 +134,7 @@ export const getResources = async (): Promise<DomainEntity<any>[]> => {
|
|
|
134
134
|
const envProductionOnElse = DeclaredGithubEnvironment.as({
|
|
135
135
|
repo,
|
|
136
136
|
name: 'production-on-else',
|
|
137
|
-
reviewers: { users:
|
|
137
|
+
reviewers: { users: null, teams: ['releasers'] },
|
|
138
138
|
waitTimer: null, // no delay once approved
|
|
139
139
|
deploymentBranchPolicy: null, // any branch
|
|
140
140
|
preventSelfReview: false, // self-approval allowed if in reviewers list
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "declapract-typescript-ehmpathy",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
4
|
"description": "declapract best practices declarations for typescript",
|
|
5
|
-
"version": "0.47.
|
|
5
|
+
"version": "0.47.72",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"repository": "ehmpathy/declapract-typescript-ehmpathy",
|