@saws/core 1.0.2 → 1.0.4
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 +5 -2
- package/src/ServiceDefinition.ts +0 -120
- package/src/get-saws-config.ts +0 -8
- package/src/index.ts +0 -2
- package/tsconfig.json +0 -12
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saws/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/src/index.js",
|
|
6
6
|
"types": "./dist/src/index.d.ts",
|
|
7
7
|
"keywords": [],
|
|
8
8
|
"author": "",
|
|
9
9
|
"license": "MIT",
|
|
10
|
+
"files": [
|
|
11
|
+
"./dist"
|
|
12
|
+
],
|
|
10
13
|
"dependencies": {
|
|
11
|
-
"@saws/utils": "^1.0.
|
|
14
|
+
"@saws/utils": "^1.0.4"
|
|
12
15
|
}
|
|
13
16
|
}
|
package/src/ServiceDefinition.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { Readable } from "stream";
|
|
2
|
-
import { writeStageOutputs, type Outputs } from "@saws/utils/stage-outputs";
|
|
3
|
-
import type { AWSPermission } from "@saws/utils/aws-permission";
|
|
4
|
-
import { parameterizedEnvVarName } from "@saws/utils/parameterized-env-var-name"
|
|
5
|
-
|
|
6
|
-
export interface ServiceDefinitionConfig {
|
|
7
|
-
name: string;
|
|
8
|
-
dependencies?: ServiceDefinition[];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class ServiceDefinition {
|
|
12
|
-
name: string;
|
|
13
|
-
dependencies: ServiceDefinition[];
|
|
14
|
-
outputs: Outputs = {};
|
|
15
|
-
deved: boolean = false
|
|
16
|
-
deployed: boolean = false
|
|
17
|
-
|
|
18
|
-
constructor(config: ServiceDefinitionConfig) {
|
|
19
|
-
this.name = config.name;
|
|
20
|
-
this.dependencies = config.dependencies ?? [];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async init() {
|
|
24
|
-
return
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async dev() {
|
|
28
|
-
console.log("Start dev", this.name);
|
|
29
|
-
await this.init()
|
|
30
|
-
await this.forEachDependencyAsync(async (dependency) => {
|
|
31
|
-
if (dependency.deved) return
|
|
32
|
-
await dependency.dev();
|
|
33
|
-
dependency.deved = true
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async deploy(stage: string) {
|
|
38
|
-
console.log("Start deploy", this.name);
|
|
39
|
-
await this.forEachDependencyAsync(async (dependency) => {
|
|
40
|
-
if (dependency.deployed) return
|
|
41
|
-
await dependency.deploy(stage);
|
|
42
|
-
dependency.deployed = true;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
getOutputs() {
|
|
47
|
-
return this.outputs;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async setOutputs(outputs: Outputs, stage: string) {
|
|
51
|
-
this.outputs = {
|
|
52
|
-
...this.outputs,
|
|
53
|
-
...outputs,
|
|
54
|
-
};
|
|
55
|
-
await writeStageOutputs(
|
|
56
|
-
{
|
|
57
|
-
[this.name]: this.outputs,
|
|
58
|
-
},
|
|
59
|
-
stage
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
forEachDependency(callback: (serviceDefinition: ServiceDefinition) => void) {
|
|
64
|
-
for (const dependency of this.dependencies) {
|
|
65
|
-
callback(dependency);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async forEachDependencyAsync(
|
|
70
|
-
callback: (serviceDefinition: ServiceDefinition) => Promise<void>
|
|
71
|
-
) {
|
|
72
|
-
for (const dependency of this.dependencies) {
|
|
73
|
-
await callback(dependency);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
getAllDependencies(): ServiceDefinition[] {
|
|
78
|
-
const all: ServiceDefinition[] = [this]
|
|
79
|
-
for (const dependency of this.dependencies) {
|
|
80
|
-
all.push(dependency)
|
|
81
|
-
all.push(...dependency.getAllDependencies())
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return all
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// this needs to be recursive down dependencies
|
|
88
|
-
exit() {
|
|
89
|
-
this.forEachDependency((dependency) => dependency.exit());
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
parameterizedEnvVarName(envVarName: string) {
|
|
93
|
-
return parameterizedEnvVarName(this.name, envVarName);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// this needs to be recursive down dependencies
|
|
97
|
-
async getEnvironmentVariables(stage: string): Promise<Record<string, string>> {
|
|
98
|
-
return {}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
async getDependenciesEnvironmentVariables(stage: string): Promise<Record<string, string>> {
|
|
102
|
-
const environmentVariables: Record<string, string> = {};
|
|
103
|
-
await this.forEachDependencyAsync(async (definition) => {
|
|
104
|
-
Object.assign(
|
|
105
|
-
environmentVariables,
|
|
106
|
-
await definition.getEnvironmentVariables(stage)
|
|
107
|
-
);
|
|
108
|
-
});
|
|
109
|
-
return environmentVariables;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
getStdOut(): Readable | null | undefined {
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
getPermissions(stage: string): AWSPermission[] {
|
|
118
|
-
return [];
|
|
119
|
-
}
|
|
120
|
-
}
|
package/src/get-saws-config.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type ServiceDefinition } from "./ServiceDefinition";
|
|
2
|
-
import { resolve } from "path";
|
|
3
|
-
|
|
4
|
-
export async function getSawsConfig(path: string = './saws.js'): Promise<ServiceDefinition> {
|
|
5
|
-
const pathToConfig = resolve(path);
|
|
6
|
-
const serviceDefinition = await import(pathToConfig);
|
|
7
|
-
return serviceDefinition.default as ServiceDefinition
|
|
8
|
-
}
|
package/src/index.ts
DELETED
package/tsconfig.json
DELETED