@saws/core 2.0.0-beta.0 → 2.0.0-beta.11
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 +66 -0
- package/dist/ServiceDefinition.js +182 -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 +14 -3
- package/dist/get-saws-config.js +16 -54
- package/dist/global-hosts.d.ts +8 -0
- package/dist/global-hosts.js +119 -0
- package/dist/host-readiness.d.ts +12 -0
- package/dist/host-readiness.js +230 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -4
- package/dist/secrets-manager.d.ts +66 -0
- package/dist/secrets-manager.js +325 -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 +132 -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 +9 -0
- package/dist/utils/run-local.js +87 -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 +34 -21
- 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,10 +0,0 @@
|
|
|
1
|
-
import type { Command } from "commander";
|
|
2
|
-
import { ServiceDefinition } from "./service-definition.js";
|
|
3
|
-
/**
|
|
4
|
-
* Collects commands contributed by the configured service types.
|
|
5
|
-
*
|
|
6
|
-
* A service class contributes its commands once even when several instances
|
|
7
|
-
* exist in the graph or a shared instance appears in multiple branches.
|
|
8
|
-
*/
|
|
9
|
-
export declare function getServiceCommands(root: ServiceDefinition): Command[];
|
|
10
|
-
//# sourceMappingURL=service-commands.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service-commands.d.ts","sourceRoot":"","sources":["../src/service-commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAI5D;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,EAAE,CAoBrE"}
|
package/dist/service-commands.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Collects commands contributed by the configured service types.
|
|
3
|
-
*
|
|
4
|
-
* A service class contributes its commands once even when several instances
|
|
5
|
-
* exist in the graph or a shared instance appears in multiple branches.
|
|
6
|
-
*/
|
|
7
|
-
export function getServiceCommands(root) {
|
|
8
|
-
const visitedServices = new Set();
|
|
9
|
-
const visitedConstructors = new Set();
|
|
10
|
-
const commands = [];
|
|
11
|
-
const visit = (service) => {
|
|
12
|
-
if (visitedServices.has(service))
|
|
13
|
-
return;
|
|
14
|
-
visitedServices.add(service);
|
|
15
|
-
const constructor = service.constructor;
|
|
16
|
-
if (!visitedConstructors.has(constructor)) {
|
|
17
|
-
visitedConstructors.add(constructor);
|
|
18
|
-
commands.push(...constructor.getCommands());
|
|
19
|
-
}
|
|
20
|
-
for (const dependency of service.dependencies)
|
|
21
|
-
visit(dependency);
|
|
22
|
-
};
|
|
23
|
-
visit(root);
|
|
24
|
-
return commands;
|
|
25
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service-commands.test.d.ts","sourceRoot":"","sources":["../src/service-commands.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import test from "node:test";
|
|
3
|
-
import { Command } from "commander";
|
|
4
|
-
import { ServiceDefinition } from "./service-definition.js";
|
|
5
|
-
import { getServiceCommands } from "./service-commands.js";
|
|
6
|
-
class CommandService extends ServiceDefinition {
|
|
7
|
-
static getCommands() {
|
|
8
|
-
return [new Command("custom")];
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
test("collects commands once per configured service type", () => {
|
|
12
|
-
const shared = new CommandService({ name: "shared" });
|
|
13
|
-
const first = new CommandService({
|
|
14
|
-
name: "first",
|
|
15
|
-
dependencies: [shared],
|
|
16
|
-
});
|
|
17
|
-
const second = new CommandService({
|
|
18
|
-
name: "second",
|
|
19
|
-
dependencies: [shared],
|
|
20
|
-
});
|
|
21
|
-
const root = new ServiceDefinition({
|
|
22
|
-
name: "root",
|
|
23
|
-
dependencies: [first, second],
|
|
24
|
-
});
|
|
25
|
-
assert.deepEqual(getServiceCommands(root).map((command) => command.name()), ["custom"]);
|
|
26
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { DeployContext, DevContext, ExitContext, InitContext, RuntimeContext } from "./context.js";
|
|
2
|
-
import type { Command } from "commander";
|
|
3
|
-
import type { EnvironmentVariables, EnvironmentVariableTarget, ServiceOutputs, ServicePermission } from "./service-types.js";
|
|
4
|
-
export interface ServiceDefinitionConfig {
|
|
5
|
-
name: string;
|
|
6
|
-
dependencies?: ServiceDefinition[];
|
|
7
|
-
}
|
|
8
|
-
export declare class ServiceDefinition {
|
|
9
|
-
static getCommands(): Command[];
|
|
10
|
-
readonly name: string;
|
|
11
|
-
readonly dependencies: ServiceDefinition[];
|
|
12
|
-
private initializedStages;
|
|
13
|
-
private devedStages;
|
|
14
|
-
private deployedStages;
|
|
15
|
-
private outputsByStage;
|
|
16
|
-
constructor(config: ServiceDefinitionConfig);
|
|
17
|
-
init(context?: InitContext): Promise<void>;
|
|
18
|
-
dev(context?: DevContext): Promise<void>;
|
|
19
|
-
deploy(contextOrStage: DeployContext | string): Promise<void>;
|
|
20
|
-
exit(context?: ExitContext): Promise<void>;
|
|
21
|
-
setOutputs(stage: string, outputs: ServiceOutputs): void;
|
|
22
|
-
getOutputs(context: RuntimeContext): Promise<ServiceOutputs>;
|
|
23
|
-
getEnvironmentVariables(context: RuntimeContext, _target?: EnvironmentVariableTarget): Promise<EnvironmentVariables>;
|
|
24
|
-
getDependenciesEnvironmentVariables(context: RuntimeContext, target?: EnvironmentVariableTarget): Promise<EnvironmentVariables>;
|
|
25
|
-
getPermissions(context: RuntimeContext): Promise<ServicePermission[]>;
|
|
26
|
-
/**
|
|
27
|
-
* Bootstrap application-owned files or dependencies required by this
|
|
28
|
-
* service. Implementations must be safe to run again in a later process and
|
|
29
|
-
* should resolve generated paths from context.rootDir.
|
|
30
|
-
*/
|
|
31
|
-
protected onInit(_context: InitContext): Promise<void>;
|
|
32
|
-
protected onDev(_context: DevContext): Promise<void>;
|
|
33
|
-
protected onDeploy(_context: DeployContext): Promise<void>;
|
|
34
|
-
protected onExit(_context: ExitContext): Promise<void>;
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=service-definition.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service-definition.d.ts","sourceRoot":"","sources":["../src/service-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,UAAU,EACV,WAAW,EACX,WAAW,EACX,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EACV,oBAAoB,EACpB,yBAAyB,EACzB,cAAc,EACd,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACpC;AAED,qBAAa,iBAAiB;IAC5B,MAAM,CAAC,WAAW,IAAI,OAAO,EAAE;IAI/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,iBAAiB,EAAE,CAAC;IAE3C,OAAO,CAAC,iBAAiB,CAAqB;IAC9C,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,cAAc,CAAqC;gBAE/C,MAAM,EAAE,uBAAuB;IAKrC,IAAI,CAAC,OAAO,cAAsC;IAWlD,GAAG,CAAC,OAAO,aAAqC;IAYhD,MAAM,CAAC,cAAc,EAAE,aAAa,GAAG,MAAM;IAgB7C,IAAI,CAAC,OAAO,cAAsC;IAQxD,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc;IAO3C,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;IAI5D,uBAAuB,CAC3B,OAAO,EAAE,cAAc,EACvB,OAAO,GAAE,yBAAkC,GAC1C,OAAO,CAAC,oBAAoB,CAAC;IAI1B,mCAAmC,CACvC,OAAO,EAAE,cAAc,EACvB,MAAM,GAAE,yBAAkC,GACzC,OAAO,CAAC,oBAAoB,CAAC;IAa1B,cAAc,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAI3E;;;;OAIG;cACa,MAAM,CAAC,QAAQ,EAAE,WAAW;cAC5B,KAAK,CAAC,QAAQ,EAAE,UAAU;cAC1B,QAAQ,CAAC,QAAQ,EAAE,aAAa;cAChC,MAAM,CAAC,QAAQ,EAAE,WAAW;CAC7C"}
|
|
@@ -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
|