@saws/core 2.0.0-beta.2 → 2.0.0-beta.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/dist/.tsbuildinfo +1 -1
- package/dist/Host.d.ts +62 -0
- package/dist/Host.js +202 -0
- package/dist/ServiceDefinition.d.ts +46 -0
- package/dist/ServiceDefinition.js +119 -0
- package/dist/find-service-definition.d.ts +1 -8
- package/dist/find-service-definition.js +0 -6
- package/dist/get-saws-config.d.ts +7 -3
- package/dist/get-saws-config.js +6 -56
- package/dist/host-readiness.d.ts +12 -0
- package/dist/host-readiness.js +230 -0
- package/dist/index.d.ts +4 -5
- package/dist/index.js +4 -4
- package/dist/secrets-manager.d.ts +63 -0
- package/dist/secrets-manager.js +323 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils/constants.d.ts +4 -0
- package/dist/utils/constants.js +5 -0
- package/dist/utils/create-directories.d.ts +2 -0
- package/dist/utils/create-directories.js +20 -0
- package/dist/utils/create-file-if-not-exists.d.ts +1 -0
- package/dist/utils/create-file-if-not-exists.js +12 -0
- package/dist/utils/create-file-if-note-exists.d.ts +1 -0
- package/dist/utils/create-file-if-note-exists.js +11 -0
- package/dist/utils/dependency-management.d.ts +16 -0
- package/dist/utils/dependency-management.js +111 -0
- package/dist/utils/file-exists.d.ts +1 -0
- package/dist/utils/file-exists.js +12 -0
- package/dist/utils/generate-token.d.ts +1 -0
- package/dist/utils/generate-token.js +13 -0
- package/dist/utils/get-project-name.d.ts +1 -0
- package/dist/utils/get-project-name.js +5 -0
- package/dist/utils/get-service-path.js +1 -0
- package/dist/utils/list-files.d.ts +1 -0
- package/dist/utils/list-files.js +17 -0
- package/dist/utils/on-exit.d.ts +1 -0
- package/dist/utils/on-exit.js +14 -0
- package/dist/utils/parameterized-env-var-name.d.ts +1 -0
- package/dist/utils/parameterized-env-var-name.js +1 -0
- package/dist/utils/recursively-read-dir.d.ts +1 -0
- package/dist/utils/recursively-read-dir.js +15 -0
- package/dist/utils/retry-until.d.ts +1 -0
- package/dist/utils/retry-until.js +9 -0
- package/dist/utils/run-local.d.ts +8 -0
- package/dist/utils/run-local.js +86 -0
- package/dist/utils/shell-quote.d.ts +1 -0
- package/dist/utils/shell-quote.js +3 -0
- package/dist/utils/stage-outputs.d.ts +3 -0
- package/dist/utils/stage-outputs.js +24 -0
- package/dist/utils/uppercase.d.ts +1 -0
- package/dist/utils/uppercase.js +4 -0
- package/package.json +32 -24
- package/dist/context.d.ts +0 -41
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js +0 -38
- package/dist/context.test.d.ts +0 -2
- package/dist/context.test.d.ts.map +0 -1
- package/dist/context.test.js +0 -13
- package/dist/find-service-definition.d.ts.map +0 -1
- package/dist/find-service-definition.test.d.ts +0 -2
- package/dist/find-service-definition.test.d.ts.map +0 -1
- package/dist/find-service-definition.test.js +0 -44
- package/dist/get-saws-config.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/service-commands.d.ts +0 -10
- package/dist/service-commands.d.ts.map +0 -1
- package/dist/service-commands.js +0 -25
- package/dist/service-commands.test.d.ts +0 -2
- package/dist/service-commands.test.d.ts.map +0 -1
- package/dist/service-commands.test.js +0 -26
- package/dist/service-definition.d.ts +0 -36
- package/dist/service-definition.d.ts.map +0 -1
- package/dist/service-definition.js +0 -104
- package/dist/service-types.d.ts +0 -9
- package/dist/service-types.d.ts.map +0 -1
- /package/dist/{service-types.js → utils/get-service-path.d.ts} +0 -0
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { DeployContext, DevContext, ExitContext, InitContext, } from "./context.js";
|
|
2
|
-
export class ServiceDefinition {
|
|
3
|
-
static getCommands() {
|
|
4
|
-
return [];
|
|
5
|
-
}
|
|
6
|
-
name;
|
|
7
|
-
dependencies;
|
|
8
|
-
initializedStages = new Set();
|
|
9
|
-
devedStages = new Set();
|
|
10
|
-
deployedStages = new Set();
|
|
11
|
-
outputsByStage = new Map();
|
|
12
|
-
constructor(config) {
|
|
13
|
-
this.name = config.name;
|
|
14
|
-
this.dependencies = config.dependencies ?? [];
|
|
15
|
-
}
|
|
16
|
-
async init(context = new InitContext({ stage: "local" })) {
|
|
17
|
-
if (this.initializedStages.has(context.stage))
|
|
18
|
-
return;
|
|
19
|
-
for (const dependency of this.dependencies) {
|
|
20
|
-
await dependency.init(initContextForService(context, dependency.name));
|
|
21
|
-
}
|
|
22
|
-
await this.onInit(initContextForService(context, this.name));
|
|
23
|
-
this.initializedStages.add(context.stage);
|
|
24
|
-
}
|
|
25
|
-
async dev(context = new DevContext({ stage: "local" })) {
|
|
26
|
-
if (this.devedStages.has(context.stage))
|
|
27
|
-
return;
|
|
28
|
-
await this.init(initContextForService(context, this.name));
|
|
29
|
-
for (const dependency of this.dependencies) {
|
|
30
|
-
await dependency.dev(devContextForService(context, dependency.name));
|
|
31
|
-
}
|
|
32
|
-
await this.onDev(devContextForService(context, this.name));
|
|
33
|
-
this.devedStages.add(context.stage);
|
|
34
|
-
}
|
|
35
|
-
async deploy(contextOrStage) {
|
|
36
|
-
const context = typeof contextOrStage === "string"
|
|
37
|
-
? new DeployContext({ stage: contextOrStage })
|
|
38
|
-
: contextOrStage;
|
|
39
|
-
if (this.deployedStages.has(context.stage))
|
|
40
|
-
return;
|
|
41
|
-
for (const dependency of this.dependencies) {
|
|
42
|
-
await dependency.deploy(context);
|
|
43
|
-
}
|
|
44
|
-
await this.onDeploy(context);
|
|
45
|
-
this.deployedStages.add(context.stage);
|
|
46
|
-
}
|
|
47
|
-
async exit(context = new ExitContext({ stage: "local" })) {
|
|
48
|
-
await this.onExit(context);
|
|
49
|
-
for (const dependency of this.dependencies) {
|
|
50
|
-
await dependency.exit(context);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
setOutputs(stage, outputs) {
|
|
54
|
-
this.outputsByStage.set(stage, {
|
|
55
|
-
...this.outputsByStage.get(stage),
|
|
56
|
-
...outputs,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
async getOutputs(context) {
|
|
60
|
-
return this.outputsByStage.get(context.stage) ?? {};
|
|
61
|
-
}
|
|
62
|
-
async getEnvironmentVariables(context, _target = "host") {
|
|
63
|
-
return {};
|
|
64
|
-
}
|
|
65
|
-
async getDependenciesEnvironmentVariables(context, target = "host") {
|
|
66
|
-
const environment = {};
|
|
67
|
-
for (const dependency of this.dependencies) {
|
|
68
|
-
Object.assign(environment, await dependency.getEnvironmentVariables(context, target));
|
|
69
|
-
}
|
|
70
|
-
return environment;
|
|
71
|
-
}
|
|
72
|
-
async getPermissions(context) {
|
|
73
|
-
return [];
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Bootstrap application-owned files or dependencies required by this
|
|
77
|
-
* service. Implementations must be safe to run again in a later process and
|
|
78
|
-
* should resolve generated paths from context.rootDir.
|
|
79
|
-
*/
|
|
80
|
-
async onInit(_context) { }
|
|
81
|
-
async onDev(_context) { }
|
|
82
|
-
async onDeploy(_context) { }
|
|
83
|
-
async onExit(_context) { }
|
|
84
|
-
}
|
|
85
|
-
function initContextForService(context, serviceName) {
|
|
86
|
-
return new InitContext({
|
|
87
|
-
stage: context.stage,
|
|
88
|
-
rootDir: context.rootDir,
|
|
89
|
-
env: context.env,
|
|
90
|
-
dryRun: context.dryRun,
|
|
91
|
-
logSink: context.logSink,
|
|
92
|
-
currentServiceName: serviceName,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
function devContextForService(context, serviceName) {
|
|
96
|
-
return new DevContext({
|
|
97
|
-
stage: context.stage,
|
|
98
|
-
rootDir: context.rootDir,
|
|
99
|
-
env: context.env,
|
|
100
|
-
dryRun: context.dryRun,
|
|
101
|
-
logSink: context.logSink,
|
|
102
|
-
currentServiceName: serviceName,
|
|
103
|
-
});
|
|
104
|
-
}
|
package/dist/service-types.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type ServiceOutputs = Record<string, string | number | boolean | undefined>;
|
|
2
|
-
export type EnvironmentVariables = Record<string, string>;
|
|
3
|
-
export type EnvironmentVariableTarget = "host" | "container";
|
|
4
|
-
export interface ServicePermission {
|
|
5
|
-
provider: string;
|
|
6
|
-
actions: string[];
|
|
7
|
-
resources: string[];
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=service-types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service-types.d.ts","sourceRoot":"","sources":["../src/service-types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;AACnF,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1D,MAAM,MAAM,yBAAyB,GAAG,MAAM,GAAG,WAAW,CAAC;AAE7D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB"}
|
|
File without changes
|