@saws/cli 1.0.11 → 2.0.0-beta.2
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 -0
- package/dist/bin/saws.d.ts +1 -0
- package/dist/bin/saws.d.ts.map +1 -0
- package/dist/bin/saws.js +51 -36
- package/dist/commands/deploy/command.d.ts +8 -0
- package/dist/commands/deploy/command.d.ts.map +1 -0
- package/dist/commands/deploy/command.js +21 -0
- package/dist/{src/commands/dev → commands/deploy}/index.d.ts +1 -0
- package/dist/commands/deploy/index.d.ts.map +1 -0
- package/dist/commands/deploy/index.js +9 -0
- package/dist/commands/dev/command.d.ts +7 -0
- package/dist/commands/dev/command.d.ts.map +1 -0
- package/dist/commands/dev/command.js +63 -0
- package/dist/{src/commands/execute → commands/dev}/index.d.ts +1 -0
- package/dist/commands/dev/index.d.ts.map +1 -0
- package/dist/commands/dev/index.js +8 -0
- package/dist/commands/dev/tui/dev-tui.d.ts +18 -0
- package/dist/commands/dev/tui/dev-tui.d.ts.map +1 -0
- package/dist/commands/dev/tui/dev-tui.js +146 -0
- package/dist/commands/host/command.d.ts +8 -0
- package/dist/commands/host/command.d.ts.map +1 -0
- package/dist/commands/host/command.js +24 -0
- package/dist/commands/host/command.test.d.ts +2 -0
- package/dist/commands/host/command.test.d.ts.map +1 -0
- package/dist/commands/host/command.test.js +13 -0
- package/dist/{src/commands/init → commands/host}/index.d.ts +1 -0
- package/dist/commands/host/index.d.ts.map +1 -0
- package/dist/commands/host/index.js +10 -0
- package/dist/commands/init/command.d.ts +7 -0
- package/dist/commands/init/command.d.ts.map +1 -0
- package/dist/commands/init/command.js +15 -0
- package/dist/commands/init/command.test.d.ts +2 -0
- package/dist/commands/init/command.test.d.ts.map +1 -0
- package/dist/commands/init/command.test.js +40 -0
- package/dist/{src/commands/deploy → commands/init}/index.d.ts +1 -0
- package/dist/commands/init/index.d.ts.map +1 -0
- package/dist/commands/init/index.js +10 -0
- package/dist/commands/secrets/command.d.ts +8 -0
- package/dist/commands/secrets/command.d.ts.map +1 -0
- package/dist/commands/secrets/command.js +16 -0
- package/dist/commands/secrets/index.d.ts +3 -0
- package/dist/commands/secrets/index.d.ts.map +1 -0
- package/dist/commands/secrets/index.js +9 -0
- package/dist/hosts.d.ts +4 -0
- package/dist/hosts.d.ts.map +1 -0
- package/dist/hosts.js +17 -0
- package/package.json +24 -18
- package/README.md +0 -62
- package/dist/src/commands/deploy/command.d.ts +0 -3
- package/dist/src/commands/deploy/command.js +0 -16
- package/dist/src/commands/deploy/index.js +0 -11
- package/dist/src/commands/dev/command.d.ts +0 -1
- package/dist/src/commands/dev/command.js +0 -22
- package/dist/src/commands/dev/index.js +0 -10
- package/dist/src/commands/execute/command.d.ts +0 -3
- package/dist/src/commands/execute/command.js +0 -41
- package/dist/src/commands/execute/index.js +0 -12
- package/dist/src/commands/init/command.d.ts +0 -1
- package/dist/src/commands/init/command.js +0 -23
- package/dist/src/commands/init/index.js +0 -9
- package/dist/src/commands/init/templates/gitignore.template.d.ts +0 -1
- package/dist/src/commands/init/templates/gitignore.template.js +0 -13
- package/dist/src/commands/init/templates/saws-js.template.d.ts +0 -3
- package/dist/src/commands/init/templates/saws-js.template.js +0 -12
- package/dist/src/commands/init/templates/tsconfig-json.template.d.ts +0 -1
- package/dist/src/commands/init/templates/tsconfig-json.template.js +0 -25
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/commands/init/command.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAsB,WAAW,CAC/B,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,OAAO,EAAE,kBAAkB,iBAiB5B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { findServiceDefinition, getSawsConfig, InitContext, } from "@saws/core";
|
|
2
|
+
export async function initCommand(serviceName, path, options) {
|
|
3
|
+
const rootDir = options.rootDir ?? process.cwd();
|
|
4
|
+
const rootService = await getSawsConfig(options.config ?? path);
|
|
5
|
+
const service = findServiceDefinition(rootService, serviceName);
|
|
6
|
+
await service.init(new InitContext({
|
|
7
|
+
stage: "local",
|
|
8
|
+
rootDir,
|
|
9
|
+
dryRun: options.dryRun ?? false,
|
|
10
|
+
env: process.env,
|
|
11
|
+
logSink: ({ stream, chunk }) => {
|
|
12
|
+
(stream === "stderr" ? process.stderr : process.stdout).write(chunk);
|
|
13
|
+
},
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.test.d.ts","sourceRoot":"","sources":["../../../src/commands/init/command.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdtemp, readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import test from "node:test";
|
|
6
|
+
import { pathToFileURL } from "node:url";
|
|
7
|
+
import { initCommand } from "./command.js";
|
|
8
|
+
test("initializes only the selected service branch in dependency order", async () => {
|
|
9
|
+
const directory = await mkdtemp(path.join(os.tmpdir(), "saws-init-"));
|
|
10
|
+
const configPath = path.join(directory, "saws.mjs");
|
|
11
|
+
const packageUrl = pathToFileURL(path.resolve("../core/dist/index.js")).href;
|
|
12
|
+
await writeFile(configPath, `
|
|
13
|
+
import { appendFile } from "node:fs/promises";
|
|
14
|
+
import path from "node:path";
|
|
15
|
+
import { ServiceDefinition } from ${JSON.stringify(packageUrl)};
|
|
16
|
+
|
|
17
|
+
class InitializableService extends ServiceDefinition {
|
|
18
|
+
async onInit(context) {
|
|
19
|
+
await appendFile(path.join(context.rootDir, "initialized.txt"), this.name + "\\n");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const shared = new InitializableService({ name: "shared" });
|
|
24
|
+
const api = new InitializableService({
|
|
25
|
+
name: "api",
|
|
26
|
+
dependencies: [shared],
|
|
27
|
+
});
|
|
28
|
+
const worker = new InitializableService({ name: "worker" });
|
|
29
|
+
|
|
30
|
+
export default new InitializableService({
|
|
31
|
+
name: "app",
|
|
32
|
+
dependencies: [api, worker],
|
|
33
|
+
});
|
|
34
|
+
`);
|
|
35
|
+
await initCommand("api", undefined, {
|
|
36
|
+
config: configPath,
|
|
37
|
+
rootDir: directory,
|
|
38
|
+
});
|
|
39
|
+
assert.equal(await readFile(path.join(directory, "initialized.txt"), "utf8"), "shared\napi\n");
|
|
40
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,eAAO,MAAM,aAAa,eAQF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { initCommand } from "./command.js";
|
|
3
|
+
export const createCommand = () => new Command("init")
|
|
4
|
+
.description("bootstrap one configured service and its dependencies")
|
|
5
|
+
.argument("<service>", "name of the service to initialize")
|
|
6
|
+
.argument("[config]", "path to service definition")
|
|
7
|
+
.option("--root-dir <string>", "project root used for generated files")
|
|
8
|
+
.option("--config <string>", "path to service definition")
|
|
9
|
+
.option("--dry-run", "allow service initializers to preview their changes")
|
|
10
|
+
.action(initCommand);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/commands/secrets/command.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,qBAAqB,iBAkB/B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SecretsManager } from "@saws/secrets";
|
|
2
|
+
export async function secretsCommand(name, options) {
|
|
3
|
+
const manager = new SecretsManager({
|
|
4
|
+
stage: options.stage ?? "local",
|
|
5
|
+
rootDir: options.rootDir ?? process.cwd(),
|
|
6
|
+
});
|
|
7
|
+
if (options.get) {
|
|
8
|
+
console.log(await manager.get(name));
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (options.set == null) {
|
|
12
|
+
throw new Error("secrets requires either --get or --set <value>");
|
|
13
|
+
}
|
|
14
|
+
await manager.set(name, options.set);
|
|
15
|
+
console.log("Set secret");
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/secrets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,eAAO,MAAM,aAAa,eAOC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { secretsCommand } from "./command.js";
|
|
3
|
+
export const createCommand = () => new Command("secrets")
|
|
4
|
+
.argument("<string>", "secret name")
|
|
5
|
+
.option("--stage <string>", "stage", "local")
|
|
6
|
+
.option("--set <string>", "set secret value")
|
|
7
|
+
.option("--get", "get secret value")
|
|
8
|
+
.option("--root-dir <string>", "project root used for local secrets")
|
|
9
|
+
.action(secretsCommand);
|
package/dist/hosts.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosts.d.ts","sourceRoot":"","sources":["../src/hosts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,UAkB1D"}
|
package/dist/hosts.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Host } from "@saws/host";
|
|
2
|
+
export function findConfiguredHosts(root) {
|
|
3
|
+
const hosts = new Set();
|
|
4
|
+
const visited = new Set();
|
|
5
|
+
const visit = (service) => {
|
|
6
|
+
if (visited.has(service))
|
|
7
|
+
return;
|
|
8
|
+
visited.add(service);
|
|
9
|
+
const host = service.docker?.host;
|
|
10
|
+
if (host instanceof Host)
|
|
11
|
+
hosts.add(host);
|
|
12
|
+
for (const dependency of service.dependencies)
|
|
13
|
+
visit(dependency);
|
|
14
|
+
};
|
|
15
|
+
visit(root);
|
|
16
|
+
return [...hosts];
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,28 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saws/cli",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "2.0.0-beta.2",
|
|
4
|
+
"description": "Command-line interface for SAWS",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/shichongrui/saws.git",
|
|
8
|
+
"directory": "packages/cli"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
5
11
|
"bin": {
|
|
6
|
-
"saws": "
|
|
12
|
+
"saws": "dist/bin/saws.js"
|
|
7
13
|
},
|
|
8
14
|
"files": [
|
|
9
|
-
"
|
|
15
|
+
"dist"
|
|
10
16
|
],
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
"scripts": {
|
|
18
|
+
"prebuild": "node -e \"fs.rmSync('dist', { recursive: true, force: true })\"",
|
|
19
|
+
"build": "tsc -p tsconfig.json",
|
|
20
|
+
"postbuild": "chmod +x dist/bin/saws.js",
|
|
21
|
+
"test": "npm run build && node --test dist/commands/**/*.test.js",
|
|
22
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
23
|
+
},
|
|
14
24
|
"dependencies": {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"@saws/secrets": "^1.0.11"
|
|
25
|
+
"@saws/core": "2.0.0-beta.2",
|
|
26
|
+
"@saws/host": "2.0.0-beta.2",
|
|
27
|
+
"@saws/secrets": "2.0.0-beta.2",
|
|
28
|
+
"commander": "^14.0.3"
|
|
20
29
|
},
|
|
21
30
|
"devDependencies": {
|
|
22
|
-
"@types/
|
|
23
|
-
"
|
|
24
|
-
},
|
|
25
|
-
"peerDependencies": {
|
|
26
|
-
"@saws/core": ">=1.0.0"
|
|
31
|
+
"@types/node": "^20.11.19",
|
|
32
|
+
"typescript": "^5.3.3"
|
|
27
33
|
}
|
|
28
|
-
}
|
|
34
|
+
}
|
package/README.md
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
<div align='center'>
|
|
2
|
-
|
|
3
|
-
# SAWS CLI
|
|
4
|
-
|
|
5
|
-
CLI for interacting with your SAWS application.
|
|
6
|
-
|
|
7
|
-
</div>
|
|
8
|
-
|
|
9
|
-
## Table of Contents
|
|
10
|
-
- [Installation](#installation)
|
|
11
|
-
- [Commands](#commands)
|
|
12
|
-
|
|
13
|
-
## Installation <a id='installation'>
|
|
14
|
-
|
|
15
|
-
From the command line run:
|
|
16
|
-
```bash
|
|
17
|
-
npm install @saws/cli
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Then run `npx saws init` to initialize your SAWS application in your current directory.
|
|
21
|
-
|
|
22
|
-
## Commands <a id='commands'>
|
|
23
|
-
|
|
24
|
-
These commands are the base commands that come with the `saws` cli. But other services in your `saws.js` can add additional commands to the `saws` cli. For example: [`secrets` command](../secrets/README.md#commands).
|
|
25
|
-
|
|
26
|
-
### `init`
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
npx saws init
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
This command will initialize a SAWS application in your current working directory.
|
|
33
|
-
|
|
34
|
-
It will
|
|
35
|
-
- Install any needed dependencies
|
|
36
|
-
- Create a `.gitignore`
|
|
37
|
-
- Create a `tsconfig.json`
|
|
38
|
-
- Create your `saws.js` config file
|
|
39
|
-
|
|
40
|
-
### `dev`
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
npx saws dev
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
This command will intitialize any new services in your `saws.js` file and stand up a local development environment for your application.
|
|
47
|
-
|
|
48
|
-
### `deploy`
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
npx saws deploy --stage <stage>
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
This command will deploy all the services in your `saws.js` file to AWS. You will need to have your AWS session configured in your terminal for this command to succeed.
|
|
55
|
-
|
|
56
|
-
### `execute`
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
npx saws execute ./path/to/script.ts --stage <stage>
|
|
60
|
-
|
|
61
|
-
```
|
|
62
|
-
This command will execute a script against your application. `stage` by default will be local. If your script depends on services being running locally, you will need to run them using `npx saws dev` in another terminal tab/window.
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deployCommand = void 0;
|
|
4
|
-
const create_directories_1 = require("@saws/utils/create-directories");
|
|
5
|
-
const core_1 = require("@saws/core");
|
|
6
|
-
const deployCommand = async (path, { stage }) => {
|
|
7
|
-
if (stage === "local") {
|
|
8
|
-
console.warn("Can not deploy to local stage");
|
|
9
|
-
process.exit();
|
|
10
|
-
}
|
|
11
|
-
await (0, create_directories_1.createCacheDir)();
|
|
12
|
-
const serviceDefinition = await (0, core_1.getSawsConfig)(path);
|
|
13
|
-
await serviceDefinition.deploy(stage);
|
|
14
|
-
};
|
|
15
|
-
exports.deployCommand = deployCommand;
|
|
16
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWFuZC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb21tYW5kcy9kZXBsb3kvY29tbWFuZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSx1RUFBZ0U7QUFDaEUscUNBQTJDO0FBRXBDLE1BQU0sYUFBYSxHQUFHLEtBQUssRUFBRSxJQUFZLEVBQUUsRUFBRSxLQUFLLEVBQXFCLEVBQUUsRUFBRTtJQUNoRixJQUFJLEtBQUssS0FBSyxPQUFPLEVBQUUsQ0FBQztRQUN0QixPQUFPLENBQUMsSUFBSSxDQUFDLCtCQUErQixDQUFDLENBQUM7UUFDOUMsT0FBTyxDQUFDLElBQUksRUFBRSxDQUFDO0lBQ2pCLENBQUM7SUFFRCxNQUFNLElBQUEsbUNBQWMsR0FBRSxDQUFDO0lBRXZCLE1BQU0saUJBQWlCLEdBQUcsTUFBTSxJQUFBLG9CQUFhLEVBQUMsSUFBSSxDQUFDLENBQUM7SUFFcEQsTUFBTSxpQkFBaUIsQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLENBQUM7QUFDeEMsQ0FBQyxDQUFDO0FBWFcsUUFBQSxhQUFhLGlCQVd4QiJ9
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCommand = void 0;
|
|
4
|
-
const commander_1 = require("commander");
|
|
5
|
-
const command_1 = require("./command");
|
|
6
|
-
const createCommand = () => new commander_1.Command("deploy")
|
|
7
|
-
.option("--stage <string>", "stage to deploy")
|
|
8
|
-
.argument("[string]", "path to service definition")
|
|
9
|
-
.action(command_1.deployCommand);
|
|
10
|
-
exports.createCommand = createCommand;
|
|
11
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvY29tbWFuZHMvZGVwbG95L2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLHlDQUFvQztBQUNwQyx1Q0FBMEM7QUFFbkMsTUFBTSxhQUFhLEdBQUcsR0FBRyxFQUFFLENBQ2hDLElBQUksbUJBQU8sQ0FBQyxRQUFRLENBQUM7S0FDbEIsTUFBTSxDQUFDLGtCQUFrQixFQUFFLGlCQUFpQixDQUFDO0tBQzdDLFFBQVEsQ0FBQyxVQUFVLEVBQUUsNEJBQTRCLENBQUM7S0FDbEQsTUFBTSxDQUFDLHVCQUFhLENBQUMsQ0FBQztBQUpkLFFBQUEsYUFBYSxpQkFJQyJ9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const devCommand: (path: string) => Promise<void>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.devCommand = void 0;
|
|
4
|
-
const create_directories_1 = require("@saws/utils/create-directories");
|
|
5
|
-
const on_exit_1 = require("@saws/utils/on-exit");
|
|
6
|
-
const core_1 = require("@saws/core");
|
|
7
|
-
const devCommand = async (path) => {
|
|
8
|
-
process.env.NODE_ENV = "development";
|
|
9
|
-
process.env.STAGE = "local";
|
|
10
|
-
process.env.AWS_REGION = 'us-west-2';
|
|
11
|
-
await (0, create_directories_1.createCacheDir)();
|
|
12
|
-
const serviceDefinition = await (0, core_1.getSawsConfig)(path);
|
|
13
|
-
(0, on_exit_1.onProcessExit)(() => {
|
|
14
|
-
serviceDefinition.exit();
|
|
15
|
-
});
|
|
16
|
-
await serviceDefinition.dev();
|
|
17
|
-
serviceDefinition.forEachDependency(async (dependency) => {
|
|
18
|
-
dependency.getStdOut()?.pipe(process.stdout);
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
exports.devCommand = devCommand;
|
|
22
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWFuZC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb21tYW5kcy9kZXYvY29tbWFuZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSx1RUFBZ0U7QUFDaEUsaURBQW9EO0FBQ3BELHFDQUEyQztBQUVwQyxNQUFNLFVBQVUsR0FBRyxLQUFLLEVBQUUsSUFBWSxFQUFFLEVBQUU7SUFDL0MsT0FBTyxDQUFDLEdBQUcsQ0FBQyxRQUFRLEdBQUcsYUFBYSxDQUFDO0lBQ3JDLE9BQU8sQ0FBQyxHQUFHLENBQUMsS0FBSyxHQUFHLE9BQU8sQ0FBQztJQUM1QixPQUFPLENBQUMsR0FBRyxDQUFDLFVBQVUsR0FBRyxXQUFXLENBQUM7SUFFckMsTUFBTSxJQUFBLG1DQUFjLEdBQUUsQ0FBQztJQUV2QixNQUFNLGlCQUFpQixHQUFHLE1BQU0sSUFBQSxvQkFBYSxFQUFDLElBQUksQ0FBQyxDQUFDO0lBRXBELElBQUEsdUJBQWEsRUFBQyxHQUFHLEVBQUU7UUFDakIsaUJBQWlCLENBQUMsSUFBSSxFQUFFLENBQUM7SUFDM0IsQ0FBQyxDQUFDLENBQUM7SUFFSCxNQUFNLGlCQUFpQixDQUFDLEdBQUcsRUFBRSxDQUFDO0lBRTlCLGlCQUFpQixDQUFDLGlCQUFpQixDQUFDLEtBQUssRUFBRSxVQUFVLEVBQUUsRUFBRTtRQUN2RCxVQUFVLENBQUMsU0FBUyxFQUFFLEVBQUUsSUFBSSxDQUFDLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQTtJQUM5QyxDQUFDLENBQUMsQ0FBQTtBQUNKLENBQUMsQ0FBQztBQWxCVyxRQUFBLFVBQVUsY0FrQnJCIn0=
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCommand = void 0;
|
|
4
|
-
const commander_1 = require("commander");
|
|
5
|
-
const command_1 = require("./command");
|
|
6
|
-
const createCommand = () => new commander_1.Command("dev")
|
|
7
|
-
.argument("[string]", "path to service definition")
|
|
8
|
-
.action(command_1.devCommand);
|
|
9
|
-
exports.createCommand = createCommand;
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvY29tbWFuZHMvZGV2L2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLHlDQUFvQztBQUNwQyx1Q0FBdUM7QUFFaEMsTUFBTSxhQUFhLEdBQUcsR0FBRyxFQUFFLENBQ2hDLElBQUksbUJBQU8sQ0FBQyxLQUFLLENBQUM7S0FDZixRQUFRLENBQUMsVUFBVSxFQUFFLDRCQUE0QixDQUFDO0tBQ2xELE1BQU0sQ0FBQyxvQkFBVSxDQUFDLENBQUM7QUFIWCxRQUFBLGFBQWEsaUJBR0YifQ==
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.executeCommand = void 0;
|
|
7
|
-
const core_1 = require("@saws/core");
|
|
8
|
-
const constants_1 = require("@saws/utils/constants");
|
|
9
|
-
const stage_outputs_1 = require("@saws/utils/stage-outputs");
|
|
10
|
-
const child_process_1 = require("child_process");
|
|
11
|
-
const esbuild_1 = __importDefault(require("esbuild"));
|
|
12
|
-
const path_1 = __importDefault(require("path"));
|
|
13
|
-
const executeCommand = async (scriptPath, sawsPath, { stage = "local" }) => {
|
|
14
|
-
process.env.STAGE = stage;
|
|
15
|
-
const serviceDefinition = await (0, core_1.getSawsConfig)(sawsPath);
|
|
16
|
-
const stageOutputs = await (0, stage_outputs_1.getStageOutputs)(stage);
|
|
17
|
-
const services = serviceDefinition.getAllDependencies();
|
|
18
|
-
let environment = {
|
|
19
|
-
NODE_ENV: stage === "local" ? "development" : "production",
|
|
20
|
-
STAGE: stage,
|
|
21
|
-
};
|
|
22
|
-
for (const service of services) {
|
|
23
|
-
await service.setOutputs(stageOutputs[service.name], stage);
|
|
24
|
-
environment = {
|
|
25
|
-
...environment,
|
|
26
|
-
...await (service.getEnvironmentVariables(stage))
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
const outFile = path_1.default.join(constants_1.BUILD_DIR, "script.js");
|
|
30
|
-
await esbuild_1.default.build({
|
|
31
|
-
entryPoints: [scriptPath],
|
|
32
|
-
bundle: true,
|
|
33
|
-
outfile: outFile,
|
|
34
|
-
platform: "node",
|
|
35
|
-
});
|
|
36
|
-
(0, child_process_1.fork)(outFile, {
|
|
37
|
-
env: environment,
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
exports.executeCommand = executeCommand;
|
|
41
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWFuZC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb21tYW5kcy9leGVjdXRlL2NvbW1hbmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEscUNBQTJDO0FBQzNDLHFEQUFrRDtBQUNsRCw2REFBNEQ7QUFDNUQsaURBQXFDO0FBQ3JDLHNEQUE4QjtBQUM5QixnREFBd0I7QUFFakIsTUFBTSxjQUFjLEdBQUcsS0FBSyxFQUNqQyxVQUFrQixFQUNsQixRQUFnQixFQUNoQixFQUFFLEtBQUssR0FBRyxPQUFPLEVBQXFCLEVBQ3RDLEVBQUU7SUFDRixPQUFPLENBQUMsR0FBRyxDQUFDLEtBQUssR0FBRyxLQUFLLENBQUM7SUFFMUIsTUFBTSxpQkFBaUIsR0FBRyxNQUFNLElBQUEsb0JBQWEsRUFBQyxRQUFRLENBQUMsQ0FBQztJQUV4RCxNQUFNLFlBQVksR0FBRyxNQUFNLElBQUEsK0JBQWUsRUFBQyxLQUFLLENBQUMsQ0FBQztJQUNsRCxNQUFNLFFBQVEsR0FBRyxpQkFBaUIsQ0FBQyxrQkFBa0IsRUFBRSxDQUFBO0lBQ3ZELElBQUksV0FBVyxHQUEyQjtRQUN4QyxRQUFRLEVBQUUsS0FBSyxLQUFLLE9BQU8sQ0FBQyxDQUFDLENBQUMsYUFBYSxDQUFDLENBQUMsQ0FBQyxZQUFZO1FBQzFELEtBQUssRUFBRSxLQUFLO0tBQ2IsQ0FBQTtJQUNELEtBQUssTUFBTSxPQUFPLElBQUksUUFBUSxFQUFFLENBQUM7UUFDL0IsTUFBTSxPQUFPLENBQUMsVUFBVSxDQUFDLFlBQVksQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLEVBQUUsS0FBSyxDQUFDLENBQUE7UUFDM0QsV0FBVyxHQUFHO1lBQ1osR0FBRyxXQUFXO1lBQ2QsR0FBRyxNQUFLLENBQUMsT0FBTyxDQUFDLHVCQUF1QixDQUFDLEtBQUssQ0FBQyxDQUFDO1NBQ2pELENBQUE7SUFDSCxDQUFDO0lBRUQsTUFBTSxPQUFPLEdBQUcsY0FBSSxDQUFDLElBQUksQ0FBQyxxQkFBUyxFQUFFLFdBQVcsQ0FBQyxDQUFDO0lBRWxELE1BQU0saUJBQU8sQ0FBQyxLQUFLLENBQUM7UUFDbEIsV0FBVyxFQUFFLENBQUMsVUFBVSxDQUFDO1FBQ3pCLE1BQU0sRUFBRSxJQUFJO1FBQ1osT0FBTyxFQUFFLE9BQU87UUFDaEIsUUFBUSxFQUFFLE1BQU07S0FDakIsQ0FBQyxDQUFDO0lBRUgsSUFBQSxvQkFBSSxFQUFDLE9BQU8sRUFBRTtRQUNaLEdBQUcsRUFBRSxXQUFXO0tBQ2pCLENBQUMsQ0FBQTtBQUNKLENBQUMsQ0FBQztBQW5DVyxRQUFBLGNBQWMsa0JBbUN6QiJ9
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCommand = void 0;
|
|
4
|
-
const commander_1 = require("commander");
|
|
5
|
-
const command_1 = require("./command");
|
|
6
|
-
const createCommand = () => new commander_1.Command("execute")
|
|
7
|
-
.option("--stage <string>", "Stage")
|
|
8
|
-
.argument("<string>", "The path to the script to execute")
|
|
9
|
-
.argument("[string]", "The path to the saws file")
|
|
10
|
-
.action(command_1.executeCommand);
|
|
11
|
-
exports.createCommand = createCommand;
|
|
12
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvY29tbWFuZHMvZXhlY3V0ZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSx5Q0FBb0M7QUFDcEMsdUNBQTJDO0FBRXBDLE1BQU0sYUFBYSxHQUFHLEdBQUcsRUFBRSxDQUNoQyxJQUFJLG1CQUFPLENBQUMsU0FBUyxDQUFDO0tBQ25CLE1BQU0sQ0FBQyxrQkFBa0IsRUFBRSxPQUFPLENBQUM7S0FDbkMsUUFBUSxDQUFDLFVBQVUsRUFBRSxtQ0FBbUMsQ0FBQztLQUN6RCxRQUFRLENBQUMsVUFBVSxFQUFFLDJCQUEyQixDQUFDO0tBQ2pELE1BQU0sQ0FBQyx3QkFBYyxDQUFDLENBQUM7QUFMZixRQUFBLGFBQWEsaUJBS0UifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const initCommand: () => Promise<void>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.initCommand = void 0;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
const dependency_management_1 = require("@saws/utils/dependency-management");
|
|
9
|
-
const tsconfig_json_template_1 = require("./templates/tsconfig-json.template");
|
|
10
|
-
const saws_js_template_1 = require("./templates/saws-js.template");
|
|
11
|
-
const create_file_if_not_exists_1 = require("@saws/utils/create-file-if-not-exists");
|
|
12
|
-
const gitignore_template_1 = require("./templates/gitignore.template");
|
|
13
|
-
const initCommand = async () => {
|
|
14
|
-
const name = node_path_1.default.parse(node_path_1.default.resolve('.')).name;
|
|
15
|
-
// not used for now
|
|
16
|
-
await (0, dependency_management_1.installMissingDependencies)([]);
|
|
17
|
-
await (0, dependency_management_1.installMissingDependencies)(['@saws/core', 'typescript'], { development: true });
|
|
18
|
-
(0, create_file_if_not_exists_1.createFileIfNotExists)('./tsconfig.json', (0, tsconfig_json_template_1.tsconfigJsonTemplate)());
|
|
19
|
-
(0, create_file_if_not_exists_1.createFileIfNotExists)('./saws.js', (0, saws_js_template_1.sawsJsTemplate)({ name }));
|
|
20
|
-
(0, create_file_if_not_exists_1.createFileIfNotExists)('./.gitignore', (0, gitignore_template_1.gitignoreTemplate)());
|
|
21
|
-
};
|
|
22
|
-
exports.initCommand = initCommand;
|
|
23
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWFuZC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb21tYW5kcy9pbml0L2NvbW1hbmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEsMERBQTRCO0FBQzVCLDZFQUE4RTtBQUM5RSwrRUFBeUU7QUFDekUsbUVBQTZEO0FBQzdELHFGQUE2RTtBQUM3RSx1RUFBa0U7QUFFM0QsTUFBTSxXQUFXLEdBQUcsS0FBSyxJQUFJLEVBQUU7SUFDcEMsTUFBTSxJQUFJLEdBQUcsbUJBQUksQ0FBQyxLQUFLLENBQUMsbUJBQUksQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUE7SUFFL0MsbUJBQW1CO0lBQ25CLE1BQU0sSUFBQSxrREFBMEIsRUFBQyxFQUFFLENBQUMsQ0FBQTtJQUNwQyxNQUFNLElBQUEsa0RBQTBCLEVBQUMsQ0FBQyxZQUFZLEVBQUUsWUFBWSxDQUFDLEVBQUUsRUFBRSxXQUFXLEVBQUUsSUFBSSxFQUFFLENBQUMsQ0FBQTtJQUVyRixJQUFBLGlEQUFxQixFQUFDLGlCQUFpQixFQUFFLElBQUEsNkNBQW9CLEdBQUUsQ0FBQyxDQUFBO0lBQ2hFLElBQUEsaURBQXFCLEVBQUMsV0FBVyxFQUFFLElBQUEsaUNBQWMsRUFBQyxFQUFFLElBQUksRUFBRSxDQUFDLENBQUMsQ0FBQTtJQUM1RCxJQUFBLGlEQUFxQixFQUFDLGNBQWMsRUFBRSxJQUFBLHNDQUFpQixHQUFFLENBQUMsQ0FBQTtBQUM1RCxDQUFDLENBQUE7QUFWWSxRQUFBLFdBQVcsZUFVdkIifQ==
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCommand = void 0;
|
|
4
|
-
const commander_1 = require("commander");
|
|
5
|
-
const command_1 = require("./command");
|
|
6
|
-
const createCommand = () => new commander_1.Command("init")
|
|
7
|
-
.action(command_1.initCommand);
|
|
8
|
-
exports.createCommand = createCommand;
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvY29tbWFuZHMvaW5pdC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSx5Q0FBb0M7QUFDcEMsdUNBQXdDO0FBRWpDLE1BQU0sYUFBYSxHQUFHLEdBQUcsRUFBRSxDQUNoQyxJQUFJLG1CQUFPLENBQUMsTUFBTSxDQUFDO0tBQ2hCLE1BQU0sQ0FBQyxxQkFBVyxDQUFDLENBQUM7QUFGWixRQUFBLGFBQWEsaUJBRUQifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const gitignoreTemplate: () => string;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gitignoreTemplate = void 0;
|
|
4
|
-
const gitignoreTemplate = () => `node_modules
|
|
5
|
-
.saws/postgres
|
|
6
|
-
.saws/cognito
|
|
7
|
-
.saws/saws-*-local-output.json
|
|
8
|
-
.saws/cache
|
|
9
|
-
.saws/build
|
|
10
|
-
.saws/.secrets
|
|
11
|
-
.DS_Store`;
|
|
12
|
-
exports.gitignoreTemplate = gitignoreTemplate;
|
|
13
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2l0aWdub3JlLnRlbXBsYXRlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vc3JjL2NvbW1hbmRzL2luaXQvdGVtcGxhdGVzL2dpdGlnbm9yZS50ZW1wbGF0ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBTyxNQUFNLGlCQUFpQixHQUFHLEdBQUcsRUFBRSxDQUFDOzs7Ozs7O1VBTzdCLENBQUE7QUFQRyxRQUFBLGlCQUFpQixxQkFPcEIifQ==
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sawsJsTemplate = void 0;
|
|
4
|
-
const sawsJsTemplate = ({ name }) => `const { ServiceDefinition } = require('@saws/core')
|
|
5
|
-
|
|
6
|
-
module.exports = new ServiceDefinition({
|
|
7
|
-
name: '${name}',
|
|
8
|
-
dependencies: []
|
|
9
|
-
})
|
|
10
|
-
`;
|
|
11
|
-
exports.sawsJsTemplate = sawsJsTemplate;
|
|
12
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2F3cy1qcy50ZW1wbGF0ZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9jb21tYW5kcy9pbml0L3RlbXBsYXRlcy9zYXdzLWpzLnRlbXBsYXRlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFPLE1BQU0sY0FBYyxHQUFHLENBQUMsRUFBRSxJQUFJLEVBQW1CLEVBQUUsRUFBRSxDQUFDOzs7V0FHbEQsSUFBSTs7O0NBR2QsQ0FBQTtBQU5ZLFFBQUEsY0FBYyxrQkFNMUIifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const tsconfigJsonTemplate: () => string;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tsconfigJsonTemplate = void 0;
|
|
4
|
-
const tsconfigJsonTemplate = () => `{
|
|
5
|
-
"include": ["**/*.ts", "*.ts", "**/*.tsx", "global.d.ts"],
|
|
6
|
-
"exclude": [".saws", "node_modules"],
|
|
7
|
-
"compilerOptions": {
|
|
8
|
-
"lib": ["DOM", "DOM.Iterable", "ES2022"],
|
|
9
|
-
"isolatedModules": true,
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"jsx": "react-jsx",
|
|
12
|
-
"target": "ES2022",
|
|
13
|
-
"module": "Node16",
|
|
14
|
-
"resolveJsonModule": true,
|
|
15
|
-
"strict": true,
|
|
16
|
-
"allowJs": true,
|
|
17
|
-
"forceConsistentCasingInFileNames": true,
|
|
18
|
-
"noEmit": true,
|
|
19
|
-
"skipLibCheck": true
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
`;
|
|
24
|
-
exports.tsconfigJsonTemplate = tsconfigJsonTemplate;
|
|
25
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHNjb25maWctanNvbi50ZW1wbGF0ZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9jb21tYW5kcy9pbml0L3RlbXBsYXRlcy90c2NvbmZpZy1qc29uLnRlbXBsYXRlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFPLE1BQU0sb0JBQW9CLEdBQUcsR0FBRyxFQUFFLENBQUM7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Q0FtQnpDLENBQUE7QUFuQlksUUFBQSxvQkFBb0Isd0JBbUJoQyJ9
|