@highstate/common 0.6.1 → 0.7.0

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.
@@ -3,7 +3,7 @@ import { forUnit, output } from '@highstate/pulumi';
3
3
  import { remote } from '@pulumi/command';
4
4
  import '@noble/hashes/utils';
5
5
  import 'micro-key-producer/password.js';
6
- import { c as createSshTerminal } from '../ssh-D_6u85qC.js';
6
+ import { c as createSshTerminal } from '../ssh-CNgI5FJI.js';
7
7
 
8
8
  const { args, inputs, secrets, outputs } = forUnit(common.existingServer);
9
9
  const privateKey = inputs.sshKeyPair?.privateKey ?? secrets.sshPrivateKey;
@@ -20,25 +20,25 @@ const hostnameResult = new remote.Command("hostname", {
20
20
  triggers: [Date.now()]
21
21
  });
22
22
  const hostname = hostnameResult.stdout.apply((x) => x.trim());
23
- const sshCredentials = output({
24
- user: args.sshUser,
25
- port: args.sshPort,
26
- password: secrets.sshPassword,
27
- privateKey
23
+ const server = output({
24
+ endpoint: args.endpoint,
25
+ hostname,
26
+ sshCredentials: {
27
+ user: args.sshUser,
28
+ port: args.sshPort,
29
+ password: secrets.sshPassword,
30
+ privateKey
31
+ }
28
32
  });
29
33
  var index = outputs({
30
- server: {
31
- endpoint: args.endpoint,
32
- hostname,
33
- sshCredentials
34
- },
34
+ server,
35
35
  $status: {
36
36
  hostname: {
37
37
  value: hostname
38
38
  }
39
39
  },
40
40
  $terminals: {
41
- ssh: sshCredentials.apply((credentials) => createSshTerminal(credentials, args.endpoint))
41
+ ssh: server.apply(createSshTerminal)
42
42
  }
43
43
  });
44
44
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { types, remote } from '@pulumi/command';
2
2
  import { Input, Output, InputOrArray, Resource, ComponentResource, ResourceOptions, Unwrap, InstanceTerminal } from '@highstate/pulumi';
3
- import { common, ssh } from '@highstate/library';
3
+ import { common } from '@highstate/library';
4
4
 
5
5
  declare function getServerConnection(server: Input<common.Server>): Output<types.input.remote.ConnectionArgs>;
6
6
  interface CommandOptions {
@@ -57,6 +57,6 @@ declare abstract class DnsRecord extends ComponentResource {
57
57
 
58
58
  declare function generatePassword(): string;
59
59
 
60
- declare function createSshTerminal(credentials: ssh.Credentials, fallbackEndpoint: string): InstanceTerminal;
60
+ declare function createSshTerminal(server: common.Server): InstanceTerminal;
61
61
 
62
62
  export { type CommandOptions, DnsRecord, type DnsRecordArgs, Server, createSshTerminal, generatePassword, getServerConnection };
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { output, ComponentResource } from '@highstate/pulumi';
3
3
  import '@highstate/library';
4
4
  import { randomBytes } from '@noble/hashes/utils';
5
5
  import { secureMask } from 'micro-key-producer/password.js';
6
- export { c as createSshTerminal } from './ssh-D_6u85qC.js';
6
+ export { c as createSshTerminal } from './ssh-CNgI5FJI.js';
7
7
 
8
8
  function getServerConnection(server) {
9
9
  return output(server).apply((server2) => ({
@@ -1,15 +1,15 @@
1
- function createSshTerminal(credentials, fallbackEndpoint) {
1
+ function createSshTerminal(server) {
2
2
  const command = ["ssh", "-tt", "-o", "StrictHostKeyChecking=no"];
3
- if (credentials.port) {
4
- command.push("-p", credentials.port.toString());
3
+ if (server.sshCredentials?.port) {
4
+ command.push("-p", server.sshCredentials.port.toString());
5
5
  }
6
- if (credentials.privateKey) {
6
+ if (server.sshCredentials?.privateKey) {
7
7
  command.push("-i", "/private-key");
8
8
  }
9
- const endpoint = credentials.endpoint ?? fallbackEndpoint;
10
- const user = credentials.user ?? "root";
9
+ const endpoint = server.sshCredentials?.endpoint ?? server.endpoint;
10
+ const user = server.sshCredentials?.user ?? "root";
11
11
  command.push(`${user}@${endpoint}`);
12
- if (credentials.password) {
12
+ if (server.sshCredentials?.password) {
13
13
  command.unshift("sshpass", "-f", "/password");
14
14
  }
15
15
  return {
@@ -19,9 +19,9 @@ function createSshTerminal(credentials, fallbackEndpoint) {
19
19
  image: "ghcr.io/exeteres/highstate/terminal-ssh",
20
20
  command,
21
21
  files: {
22
- "/password": credentials.password,
22
+ "/password": server.sshCredentials?.password,
23
23
  "/private-key": {
24
- content: credentials.privateKey,
24
+ content: server.sshCredentials?.privateKey,
25
25
  mode: 384
26
26
  }
27
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@highstate/common",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -22,7 +22,7 @@
22
22
  "build": "pkgroll --tsconfig=tsconfig.build.json"
23
23
  },
24
24
  "dependencies": {
25
- "@highstate/pulumi": "^0.6.1",
25
+ "@highstate/pulumi": "^0.7.0",
26
26
  "@noble/hashes": "^1.7.1",
27
27
  "@pulumi/command": "^1.0.2",
28
28
  "micro-key-producer": "^0.7.3"
@@ -33,5 +33,5 @@
33
33
  "devDependencies": {
34
34
  "pkgroll": "^2.5.1"
35
35
  },
36
- "gitHead": "afe736f7e93b7fcfbae97e2d6e35b07175a8fc76"
36
+ "gitHead": "2f5227f7b88cf38946e490fc4cdb96127bd8b174"
37
37
  }