@crossdelta/infrastructure 0.2.3 → 0.2.5
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/helpers/index.d.ts +0 -1
- package/dist/index.cjs +3 -36
- package/dist/index.js +3 -36
- package/package.json +1 -1
- package/dist/helpers/generate-service-env.d.ts +0 -16
package/dist/helpers/index.d.ts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -32,7 +32,6 @@ __export(exports_lib, {
|
|
|
32
32
|
getServiceUrl: () => getServiceUrl,
|
|
33
33
|
getServicePort: () => getServicePort2,
|
|
34
34
|
getImage: () => getImage,
|
|
35
|
-
generateServiceEnvFile: () => generateServiceEnvFile,
|
|
36
35
|
ensureDot: () => ensureDot,
|
|
37
36
|
dockerHubImage: () => dockerHubImage,
|
|
38
37
|
discoverServices: () => discoverServices,
|
|
@@ -109,8 +108,9 @@ function discoverServices(servicesDir) {
|
|
|
109
108
|
const resolvedDir = import_node_path.isAbsolute(servicesDir) ? servicesDir : import_node_path.resolve(process.cwd(), servicesDir);
|
|
110
109
|
const files = import_node_fs.readdirSync(resolvedDir).filter((file) => file.endsWith(".ts") && file !== "index.ts");
|
|
111
110
|
const configs = files.map((file) => {
|
|
112
|
-
const
|
|
113
|
-
|
|
111
|
+
const filePath = import_node_path.join(resolvedDir, file);
|
|
112
|
+
const module2 = require(filePath);
|
|
113
|
+
return module2.default ?? module2;
|
|
114
114
|
});
|
|
115
115
|
validateNoDuplicatePorts(configs);
|
|
116
116
|
return configs;
|
|
@@ -129,39 +129,6 @@ var dockerHubImage = (repository, tag, registry = "library") => ({
|
|
|
129
129
|
repository,
|
|
130
130
|
tag
|
|
131
131
|
});
|
|
132
|
-
// lib/helpers/generate-service-env.ts
|
|
133
|
-
function generateServiceEnvFile(serviceName) {
|
|
134
|
-
const envKey = serviceName.toUpperCase().replace(/-/g, "_");
|
|
135
|
-
return `/**
|
|
136
|
-
* Service environment configuration.
|
|
137
|
-
* Auto-generated by: bun run generate-env
|
|
138
|
-
* DO NOT EDIT MANUALLY - changes will be overwritten!
|
|
139
|
-
*/
|
|
140
|
-
|
|
141
|
-
import {
|
|
142
|
-
getServicePort as _getServicePort,
|
|
143
|
-
getServiceUrl as _getServiceUrl,
|
|
144
|
-
} from '@crossdelta/infrastructure/env'
|
|
145
|
-
|
|
146
|
-
/** This service's name */
|
|
147
|
-
export const SERVICE_NAME = '${serviceName}' as const
|
|
148
|
-
export type ServiceName = typeof SERVICE_NAME
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Get the port for this service from environment variables.
|
|
152
|
-
* Reads from ${envKey}_PORT
|
|
153
|
-
*/
|
|
154
|
-
export const getServicePort = (defaultPort = 8080): number =>
|
|
155
|
-
_getServicePort(SERVICE_NAME, defaultPort)
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Get the URL for this service from environment variables.
|
|
159
|
-
* Reads from ${envKey}_URL
|
|
160
|
-
*/
|
|
161
|
-
export const getServiceUrl = (): string | undefined =>
|
|
162
|
-
_getServiceUrl(SERVICE_NAME)
|
|
163
|
-
`;
|
|
164
|
-
}
|
|
165
132
|
// lib/helpers/image.ts
|
|
166
133
|
var scopeImageTagsRaw = process.env.SCOPE_IMAGE_TAGS ?? "";
|
|
167
134
|
var scopeImageTags = (() => {
|
package/dist/index.js
CHANGED
|
@@ -60,8 +60,9 @@ function discoverServices(servicesDir) {
|
|
|
60
60
|
const resolvedDir = isAbsolute(servicesDir) ? servicesDir : resolve(process.cwd(), servicesDir);
|
|
61
61
|
const files = readdirSync(resolvedDir).filter((file) => file.endsWith(".ts") && file !== "index.ts");
|
|
62
62
|
const configs = files.map((file) => {
|
|
63
|
-
const
|
|
64
|
-
|
|
63
|
+
const filePath = join(resolvedDir, file);
|
|
64
|
+
const module = __require(filePath);
|
|
65
|
+
return module.default ?? module;
|
|
65
66
|
});
|
|
66
67
|
validateNoDuplicatePorts(configs);
|
|
67
68
|
return configs;
|
|
@@ -80,39 +81,6 @@ var dockerHubImage = (repository, tag, registry = "library") => ({
|
|
|
80
81
|
repository,
|
|
81
82
|
tag
|
|
82
83
|
});
|
|
83
|
-
// lib/helpers/generate-service-env.ts
|
|
84
|
-
function generateServiceEnvFile(serviceName) {
|
|
85
|
-
const envKey = serviceName.toUpperCase().replace(/-/g, "_");
|
|
86
|
-
return `/**
|
|
87
|
-
* Service environment configuration.
|
|
88
|
-
* Auto-generated by: bun run generate-env
|
|
89
|
-
* DO NOT EDIT MANUALLY - changes will be overwritten!
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
import {
|
|
93
|
-
getServicePort as _getServicePort,
|
|
94
|
-
getServiceUrl as _getServiceUrl,
|
|
95
|
-
} from '@crossdelta/infrastructure/env'
|
|
96
|
-
|
|
97
|
-
/** This service's name */
|
|
98
|
-
export const SERVICE_NAME = '${serviceName}' as const
|
|
99
|
-
export type ServiceName = typeof SERVICE_NAME
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Get the port for this service from environment variables.
|
|
103
|
-
* Reads from ${envKey}_PORT
|
|
104
|
-
*/
|
|
105
|
-
export const getServicePort = (defaultPort = 8080): number =>
|
|
106
|
-
_getServicePort(SERVICE_NAME, defaultPort)
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Get the URL for this service from environment variables.
|
|
110
|
-
* Reads from ${envKey}_URL
|
|
111
|
-
*/
|
|
112
|
-
export const getServiceUrl = (): string | undefined =>
|
|
113
|
-
_getServiceUrl(SERVICE_NAME)
|
|
114
|
-
`;
|
|
115
|
-
}
|
|
116
84
|
// lib/helpers/image.ts
|
|
117
85
|
var scopeImageTagsRaw = process.env.SCOPE_IMAGE_TAGS ?? "";
|
|
118
86
|
var scopeImageTags = (() => {
|
|
@@ -248,7 +216,6 @@ export {
|
|
|
248
216
|
getServiceUrl,
|
|
249
217
|
getServicePort2 as getServicePort,
|
|
250
218
|
getImage,
|
|
251
|
-
generateServiceEnvFile,
|
|
252
219
|
ensureDot,
|
|
253
220
|
dockerHubImage,
|
|
254
221
|
discoverServices,
|
package/package.json
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generate service-specific env.ts content.
|
|
3
|
-
*
|
|
4
|
-
* @param serviceName - The name of the service (e.g., 'orders', 'api-gateway')
|
|
5
|
-
* @returns The content for the service's src/env.ts file
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* import { generateServiceEnvFile } from '@crossdelta/infrastructure'
|
|
10
|
-
* import { writeFileSync } from 'node:fs'
|
|
11
|
-
*
|
|
12
|
-
* const content = generateServiceEnvFile('orders')
|
|
13
|
-
* writeFileSync('services/orders/src/env.ts', content)
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export declare function generateServiceEnvFile(serviceName: string): string;
|