@townco/cli 0.1.105 → 0.1.106

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.
@@ -2,15 +2,30 @@ declare const _default: {
2
2
  def: import("@optique/core").Parser<{
3
3
  readonly command: "deploy";
4
4
  readonly agent: string;
5
+ readonly agentUser: string | undefined;
6
+ readonly agentPass: string | undefined;
7
+ readonly env: readonly {
8
+ [x: string]: string;
9
+ }[] | undefined;
5
10
  readonly debug: boolean;
6
11
  }, ["matched", string] | ["parsing", {
7
12
  readonly command: "deploy";
8
13
  readonly agent: import("@optique/core").ValueParserResult<string> | undefined;
14
+ readonly agentUser: [import("@optique/core").ValueParserResult<string> | undefined] | undefined;
15
+ readonly agentPass: [import("@optique/core").ValueParserResult<string> | undefined] | undefined;
16
+ readonly env: [readonly (import("@optique/core").ValueParserResult<{
17
+ [x: string]: string;
18
+ }> | undefined)[]] | undefined;
9
19
  readonly debug: import("@optique/core").ValueParserResult<boolean> | undefined;
10
20
  }] | undefined>;
11
21
  impl: (def: {
12
22
  readonly command: "deploy";
13
23
  readonly agent: string;
24
+ readonly agentUser: string | undefined;
25
+ readonly agentPass: string | undefined;
26
+ readonly env: readonly {
27
+ [x: string]: string;
28
+ }[] | undefined;
14
29
  readonly debug: boolean;
15
30
  }) => unknown;
16
31
  };
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import afs from "node:fs/promises";
3
3
  import { join } from "node:path";
4
- import { command, constant, message, object, option, string, } from "@optique/core";
4
+ import { command, constant, message, multiple, object, option, optional, string, } from "@optique/core";
5
5
  import { isInsideTownProject } from "@townco/agent/storage";
6
6
  import { createClient } from "@townco/apiclient";
7
7
  import { findRoot } from "@townco/core/path";
@@ -14,12 +14,32 @@ export default createCommand({
14
14
  def: command("deploy", object({
15
15
  command: constant("deploy"),
16
16
  agent: option("-a", "--agent", string()),
17
+ agentUser: optional(option("-u", "--user", string())),
18
+ agentPass: optional(option("-p", "--pass", string())),
19
+ env: optional(multiple(option("-e", "--env", {
20
+ metavar: "ENV=val",
21
+ parse: (raw) => {
22
+ if (Array.from(raw.matchAll(/=/g)).length !== 1)
23
+ return {
24
+ success: false,
25
+ error: message `${raw} must contain exactly one equal sign`,
26
+ };
27
+ const [k, v] = raw.split("=");
28
+ if (!k || !v)
29
+ return {
30
+ success: false,
31
+ error: message `${raw} must be of the form FOO=bar`,
32
+ };
33
+ return { success: true, value: { [k]: v } };
34
+ },
35
+ format: (v) => Object.entries(v).map((e) => e.join("="))[0],
36
+ }))),
17
37
  debug: option("-d", "--debug"),
18
38
  }), {
19
39
  brief: message `Deploy agents.`,
20
40
  description: message `Deploy agents to the Town cloud.`,
21
41
  }),
22
- impl: async ({ agent, debug }) => {
42
+ impl: async ({ agent, debug, agentUser, agentPass, env }) => {
23
43
  const projectRoot = await isInsideTownProject();
24
44
  if (!projectRoot)
25
45
  throw new Error("Not inside a Town project");
@@ -57,7 +77,14 @@ export default createCommand({
57
77
  const { sha256, cached } = await client.uploadArchive.mutate(await done);
58
78
  console.log(`Archive uploaded: ${sha256} (${cached ? "cached" : "new"})`);
59
79
  console.log("Deploying...");
60
- client.deploy.subscribe({ sha256, agent, shedUrl }, {
80
+ client.deploy.subscribe({
81
+ sha256,
82
+ agent,
83
+ shedUrl,
84
+ agentUser,
85
+ agentPass,
86
+ env: env ? Object.assign({}, ...env) : undefined,
87
+ }, {
61
88
  onData: ({ status, error }) => console.log(status ? status : error),
62
89
  onError: (err) => console.error(err),
63
90
  onComplete: () => console.log("\n✓ Deployment complete!"),
package/dist/index.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@townco/cli",
3
- "version": "0.1.105",
3
+ "version": "0.1.106",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "town": "./dist/index.js"
@@ -15,7 +15,7 @@
15
15
  "build": "tsgo"
16
16
  },
17
17
  "devDependencies": {
18
- "@townco/tsconfig": "0.1.97",
18
+ "@townco/tsconfig": "0.1.98",
19
19
  "@types/archiver": "^7.0.0",
20
20
  "@types/bun": "^1.3.1",
21
21
  "@types/ignore-walk": "^4.0.3",
@@ -24,13 +24,13 @@
24
24
  "dependencies": {
25
25
  "@optique/core": "^0.6.2",
26
26
  "@optique/run": "^0.6.2",
27
- "@townco/agent": "0.1.108",
28
- "@townco/apiclient": "0.0.20",
29
- "@townco/core": "0.0.78",
30
- "@townco/debugger": "0.1.56",
31
- "@townco/env": "0.1.50",
32
- "@townco/secret": "0.1.100",
33
- "@townco/ui": "0.1.100",
27
+ "@townco/agent": "0.1.109",
28
+ "@townco/apiclient": "0.0.21",
29
+ "@townco/core": "0.0.79",
30
+ "@townco/debugger": "0.1.57",
31
+ "@townco/env": "0.1.51",
32
+ "@townco/secret": "0.1.101",
33
+ "@townco/ui": "0.1.101",
34
34
  "@trpc/client": "^11.7.2",
35
35
  "archiver": "^7.0.1",
36
36
  "eventsource": "^4.1.0",