declapract-typescript-ehmpathy 0.47.65 → 0.47.67

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.
@@ -3,6 +3,7 @@ import { createGetVariables } from 'declapract';
3
3
  export const getProjectVariables = createGetVariables({
4
4
  organizationName: 'awesum',
5
5
  projectName: 'svc-awesome-thing',
6
+ reviewers: { users: ['user1', 'user2'] },
6
7
  });
7
8
 
8
9
  export const getServiceVariables = createGetVariables({
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "devDependencies": {
3
- "declastruct": "@declapract{check.minVersion('1.7.3')}",
4
- "declastruct-aws": "@declapract{check.minVersion('1.4.3')}",
3
+ "declastruct": "@declapract{check.minVersion('1.9.1')}",
4
+ "declastruct-aws": "@declapract{check.minVersion('1.5.0')}",
5
5
  "declastruct-unix-network": "@declapract{check.minVersion('1.0.5')}"
6
6
  }
7
7
  }
@@ -10,11 +10,37 @@ export const fix: FileFixFunction = (contents, context) => {
10
10
  .replace(/\/domain\/objects\//g, '/domain.objects/')
11
11
  .replace(/\/domain\//g, '/domain.objects/');
12
12
 
13
+ let fixedContents = contents;
14
+
15
+ // fix relative imports for files DIRECTLY in domain/objects/ that move to domain.objects/
16
+ // these files move UP one directory level, so reduce ../ by one
17
+ // note: nested files (domain/objects/nested/Deep.ts) stay at same depth, no transform
18
+ const isDirectChildOfDomainObjects = /\/domain\/objects\/[^/]+$/.test(
19
+ context.relativeFilePath,
20
+ );
21
+ if (fixedContents && isDirectChildOfDomainObjects) {
22
+ fixedContents = fixedContents.replace(
23
+ /((?:import|export)[^'"]*['"])((?:\.\.\/)+)/g,
24
+ (match, importPrefix, dotDots) => {
25
+ const count = dotDots.split('../').length - 1;
26
+ if (count === 1) {
27
+ // '../X' → './X'
28
+ return `${importPrefix}./`;
29
+ }
30
+ // '../../X' → '../X', '../../../X' → '../../X', etc.
31
+ return `${importPrefix}${'../'.repeat(count - 1)}`;
32
+ },
33
+ );
34
+ }
35
+
13
36
  // fix internal export paths in index files
14
37
  // when domain/index.ts moves to domain.objects/index.ts,
15
38
  // exports like './objects/User' should become './User'
16
- let fixedContents = contents;
17
- if (fixedContents && context.relativeFilePath.includes('/domain/index.ts')) {
39
+ if (
40
+ fixedContents &&
41
+ context.relativeFilePath.includes('/domain/') &&
42
+ context.relativeFilePath.endsWith('/index.ts')
43
+ ) {
18
44
  fixedContents = fixedContents
19
45
  // export * from './objects' → remove (objects dir flattened to root)
20
46
  .replace(/export\s+\*\s+from\s+['"]\.\/objects['"];?\n?/g, '')
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "devDependencies": {
3
- "declastruct": "@declapract{check.minVersion('1.7.3')}",
4
- "declastruct-github": "@declapract{check.minVersion('1.3.5')}"
3
+ "declastruct": "@declapract{check.minVersion('1.9.1')}",
4
+ "declastruct-github": "@declapract{check.minVersion('1.4.0')}"
5
5
  }
6
6
  }
@@ -2,6 +2,7 @@ import type { DeclastructProvider } from 'declastruct';
2
2
  import {
3
3
  type DeclaredGithubBranch,
4
4
  DeclaredGithubBranchProtection,
5
+ DeclaredGithubEnvironment,
5
6
  DeclaredGithubRepo,
6
7
  DeclaredGithubRepoConfig,
7
8
  getDeclastructGithubProvider,
@@ -119,6 +120,32 @@ export const getResources = async (): Promise<DomainEntity<any>[]> => {
119
120
  restrictions: null,
120
121
  });
121
122
 
123
+ // declare environment for production deployments from main (auto-approved)
124
+ const envProductionOnMain = DeclaredGithubEnvironment.as({
125
+ repo,
126
+ name: 'production-on-main',
127
+ reviewers: null, // no approval required — PR merge is the gate
128
+ waitTimer: null, // no delay
129
+ deploymentBranchPolicy: { customBranches: ['main'] }, // only main branch
130
+ preventSelfReview: false,
131
+ });
132
+
133
+ // declare environment for production deployments from other branches (requires approval)
134
+ const envProductionOnElse = DeclaredGithubEnvironment.as({
135
+ repo,
136
+ name: 'production-on-else',
137
+ reviewers: { users: @declapract{variable.reviewers.users}, teams: null },
138
+ waitTimer: null, // no delay once approved
139
+ deploymentBranchPolicy: null, // any branch
140
+ preventSelfReview: false, // self-approval allowed if in reviewers list
141
+ });
142
+
122
143
  // and return the full set
123
- return [repo, repoConfig, branchMainProtection];
144
+ return [
145
+ repo,
146
+ repoConfig,
147
+ branchMainProtection,
148
+ envProductionOnMain,
149
+ envProductionOnElse,
150
+ ];
124
151
  };
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.65",
5
+ "version": "0.47.67",
6
6
  "license": "MIT",
7
7
  "main": "src/index.js",
8
8
  "repository": "ehmpathy/declapract-typescript-ehmpathy",
@@ -69,8 +69,8 @@
69
69
  "@types/jest": "30.0.0",
70
70
  "@types/node": "22.15.21",
71
71
  "cz-conventional-changelog": "3.3.0",
72
- "declastruct": "1.7.0",
73
- "declastruct-github": "1.0.7",
72
+ "declastruct": "1.9.1",
73
+ "declastruct-github": "1.4.0",
74
74
  "depcheck": "1.4.3",
75
75
  "esbuild-register": "3.6.0",
76
76
  "husky": "8.0.3",