@jahia/cypress 3.26.0 → 3.28.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.
@@ -0,0 +1,15 @@
1
+ import { SSHExecCommandResponse } from 'node-ssh';
2
+ interface connection {
3
+ hostname: string;
4
+ port: string;
5
+ username: string;
6
+ password: string;
7
+ }
8
+ /**
9
+ * Execute SSH commands on a specific host. Returns a promise that resolves to the command result.
10
+ * Rejects if the commands fail (exit code is not 0).
11
+ * @param commands Array of SSH commands to execute
12
+ * @param connection Connection details
13
+ */
14
+ export declare const sshCommands: (commands: Array<string>, connection: connection) => Promise<SSHExecCommandResponse>;
15
+ export {};
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.sshCommands = void 0;
4
+ var node_ssh_1 = require("node-ssh");
5
+ /**
6
+ * Execute SSH commands on a specific host. Returns a promise that resolves to the command result.
7
+ * Rejects if the commands fail (exit code is not 0).
8
+ * @param commands Array of SSH commands to execute
9
+ * @param connection Connection details
10
+ */
11
+ var sshCommands = function (commands, connection) {
12
+ return new Promise(function (resolve, reject) {
13
+ var ssh = new node_ssh_1.NodeSSH();
14
+ console.info('[SSH] connection to:', connection.hostname, ' (port: ', connection.port, ')');
15
+ console.info('[SSH] commands:', commands);
16
+ console.info('[SSH] ', connection);
17
+ ssh.connect({
18
+ host: connection.hostname,
19
+ port: parseInt(connection.port, 10),
20
+ username: connection.username,
21
+ password: connection.password
22
+ })
23
+ .then(function () {
24
+ ssh.exec(commands.join(';'), [], { stream: 'both' })
25
+ .then(function (result) {
26
+ console.info('[SSH] Successfully executed commands: ', commands);
27
+ console.info('[SSH] Result: ', result);
28
+ if (result.code === 0) {
29
+ resolve(result); // Resolve to command result
30
+ }
31
+ else {
32
+ reject(new Error("Commands \"" + commands + "\" failed with exit code " + result.code + " on host " + connection.hostname + ". Stdout:" + result.stdout + ", Stderr: " + result.stderr));
33
+ }
34
+ })["catch"](function (reason) {
35
+ console.error('[SSH] Failed to execute commands: ', commands);
36
+ reject(reason);
37
+ });
38
+ })["catch"](function (reason) {
39
+ console.error('[SSH] Failed to connect to: ', connection.hostname);
40
+ reject(reason);
41
+ });
42
+ });
43
+ };
44
+ exports.sshCommands = sshCommands;
@@ -1,9 +1,10 @@
1
+ export * from './ClusterHelper';
2
+ export * from './GraphQLHelper';
3
+ export * from './JahiaPlatformHelper';
1
4
  export * from './JCRHelper';
2
5
  export * from './PublicationAndWorkflowHelper';
6
+ export * from './SAMHelper';
3
7
  export * from './SiteHelper';
8
+ export * from './SSHHelper';
4
9
  export * from './UsersHelper';
5
10
  export * from './VanityUrlHelper';
6
- export * from './ClusterHelper';
7
- export * from './JahiaPlatformHelper';
8
- export * from './GraphQLHelper';
9
- export * from './SAMHelper';
@@ -10,12 +10,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  exports.__esModule = true;
13
+ __exportStar(require("./ClusterHelper"), exports);
14
+ __exportStar(require("./GraphQLHelper"), exports);
15
+ __exportStar(require("./JahiaPlatformHelper"), exports);
13
16
  __exportStar(require("./JCRHelper"), exports);
14
17
  __exportStar(require("./PublicationAndWorkflowHelper"), exports);
18
+ __exportStar(require("./SAMHelper"), exports);
15
19
  __exportStar(require("./SiteHelper"), exports);
20
+ __exportStar(require("./SSHHelper"), exports);
16
21
  __exportStar(require("./UsersHelper"), exports);
17
22
  __exportStar(require("./VanityUrlHelper"), exports);
18
- __exportStar(require("./ClusterHelper"), exports);
19
- __exportStar(require("./JahiaPlatformHelper"), exports);
20
- __exportStar(require("./GraphQLHelper"), exports);
21
- __exportStar(require("./SAMHelper"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jahia/cypress",
3
- "version": "3.26.0",
3
+ "version": "3.28.0",
4
4
  "scripts": {
5
5
  "build": "tsc",
6
6
  "lint": "eslint src -c .eslintrc.json --ext .ts"
@@ -32,7 +32,8 @@
32
32
  "@apollo/client": "^3.4.9",
33
33
  "cypress-real-events": "^1.11.0",
34
34
  "graphql": "^15.5.0",
35
- "graphql-tag": "^2.11.0"
35
+ "graphql-tag": "^2.11.0",
36
+ "node-ssh": "^13.2.0"
36
37
  },
37
38
  "packageManager": "yarn@4.5.0"
38
39
  }
@@ -0,0 +1,49 @@
1
+ import {NodeSSH, SSHExecCommandResponse} from 'node-ssh';
2
+
3
+ interface connection {
4
+ hostname: string
5
+ port: string
6
+ username: string
7
+ password: string
8
+ }
9
+
10
+ /**
11
+ * Execute SSH commands on a specific host. Returns a promise that resolves to the command result.
12
+ * Rejects if the commands fail (exit code is not 0).
13
+ * @param commands Array of SSH commands to execute
14
+ * @param connection Connection details
15
+ */
16
+ export const sshCommands = (commands: Array<string>, connection: connection): Promise<SSHExecCommandResponse> => {
17
+ return new Promise((resolve, reject) => {
18
+ const ssh = new NodeSSH();
19
+ console.info('[SSH] connection to:', connection.hostname, ' (port: ', connection.port, ')');
20
+ console.info('[SSH] commands:', commands);
21
+ console.info('[SSH] ', connection);
22
+ ssh.connect({
23
+ host: connection.hostname,
24
+ port: parseInt(connection.port, 10),
25
+ username: connection.username,
26
+ password: connection.password
27
+ })
28
+ .then(() => {
29
+ ssh.exec(commands.join(';'), [], {stream: 'both'})
30
+ .then(function (result) {
31
+ console.info('[SSH] Successfully executed commands: ', commands);
32
+ console.info('[SSH] Result: ', result);
33
+ if (result.code === 0) {
34
+ resolve(result); // Resolve to command result
35
+ } else {
36
+ reject(new Error(`Commands "${commands}" failed with exit code ${result.code} on host ${connection.hostname}. Stdout:${result.stdout}, Stderr: ${result.stderr}`));
37
+ }
38
+ })
39
+ .catch(reason => {
40
+ console.error('[SSH] Failed to execute commands: ', commands);
41
+ reject(reason);
42
+ });
43
+ })
44
+ .catch(reason => {
45
+ console.error('[SSH] Failed to connect to: ', connection.hostname);
46
+ reject(reason);
47
+ });
48
+ });
49
+ };
@@ -1,9 +1,10 @@
1
+ export * from './ClusterHelper';
2
+ export * from './GraphQLHelper';
3
+ export * from './JahiaPlatformHelper';
1
4
  export * from './JCRHelper';
2
5
  export * from './PublicationAndWorkflowHelper';
6
+ export * from './SAMHelper';
3
7
  export * from './SiteHelper';
8
+ export * from './SSHHelper';
4
9
  export * from './UsersHelper';
5
10
  export * from './VanityUrlHelper';
6
- export * from './ClusterHelper';
7
- export * from './JahiaPlatformHelper';
8
- export * from './GraphQLHelper';
9
- export * from './SAMHelper';