declapract-typescript-ehmpathy 0.47.71 → 0.47.73
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/lint/best-practice/package.json +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 +8 -2
- 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'")
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"test:format:biome": "biome format",
|
|
11
11
|
"test:lint:biome": "biome check --diagnostic-level=error",
|
|
12
12
|
"test:lint:biome:all": "biome check",
|
|
13
|
-
"test:lint:cycles": "dpdm --no-warning --no-tree --exit-code circular:1 --exclude \"$(yq -r '.exclude |
|
|
13
|
+
"test:lint:cycles": "dpdm --no-warning --no-tree --exit-code circular:1 --exclude \"$(yq -r '.exclude | join(\"|\") // \"^$\"' .dpdmrc.yaml)\" 'src/**/*.ts'",
|
|
14
14
|
"test:lint:deps": "npx depcheck -c ./.depcheckrc.yml",
|
|
15
15
|
"test:lint": "npm run test:lint:biome && npm run test:lint:cycles && npm run test:lint:deps"
|
|
16
16
|
}
|
|
@@ -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
|
+
};
|
|
@@ -10,7 +10,13 @@ import {
|
|
|
10
10
|
import { type DomainEntity, RefByUnique } from 'domain-objects';
|
|
11
11
|
import { UnexpectedCodePathError } from 'helpful-errors';
|
|
12
12
|
|
|
13
|
-
import
|
|
13
|
+
import pkgJson from '../../package.json';
|
|
14
|
+
|
|
15
|
+
const pkg = pkgJson as {
|
|
16
|
+
description?: string;
|
|
17
|
+
private?: boolean;
|
|
18
|
+
homepage?: string;
|
|
19
|
+
};
|
|
14
20
|
|
|
15
21
|
export const getProviders = async (): Promise<DeclastructProvider[]> => [
|
|
16
22
|
getDeclastructGithubProvider(
|
|
@@ -134,7 +140,7 @@ export const getResources = async (): Promise<DomainEntity<any>[]> => {
|
|
|
134
140
|
const envProductionOnElse = DeclaredGithubEnvironment.as({
|
|
135
141
|
repo,
|
|
136
142
|
name: 'production-on-else',
|
|
137
|
-
reviewers: { users:
|
|
143
|
+
reviewers: { users: null, teams: ['releasers'] },
|
|
138
144
|
waitTimer: null, // no delay once approved
|
|
139
145
|
deploymentBranchPolicy: null, // any branch
|
|
140
146
|
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.73",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"repository": "ehmpathy/declapract-typescript-ehmpathy",
|