@geode/opengeodeweb-front 10.26.2 → 10.26.3-rc.1

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.
@@ -99,22 +99,13 @@ watch(
99
99
  </v-list>
100
100
  </v-menu>
101
101
  <ActionButton
102
- v-if="!isCollapsed"
103
- tooltip="Collapse All"
104
- icon="mdi-collapse-all-outline"
102
+ data-testid="CollapseOrExpandAll"
103
+ :tooltip="isCollapsed ? 'Expand All' : 'Collapse All'"
104
+ :icon="isCollapsed ? 'mdi-expand-all-outline' : 'mdi-collapse-all-outline'"
105
105
  variant="text"
106
106
  color="black"
107
107
  tooltipLocation="bottom"
108
- @click="emit('collapse-all')"
109
- />
110
- <ActionButton
111
- v-else
112
- tooltip="Expand All"
113
- icon="mdi-expand-all-outline"
114
- variant="text"
115
- color="black"
116
- tooltipLocation="bottom"
117
- @click="emit('expand-all')"
108
+ @click="isCollapsed ? emit('expand-all') : emit('collapse-all')"
118
109
  />
119
110
  </div>
120
111
  </div>
@@ -5,22 +5,18 @@ import path from "node:path";
5
5
 
6
6
  // Third party imports
7
7
  import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_schemas.json" with { type: "json" };
8
- import { getPort } from "get-port-please";
9
- import pTimeout from "p-timeout";
10
8
 
11
9
  // Local imports
12
- import { commandExistsSync, waitForReady } from "./scripts.js";
10
+ import { commandExistsSync, getAvailablePort, waitForReady } from "./scripts.js";
13
11
  import { microservicesMetadatasPath, projectMicroservices } from "./cleanup.js";
14
12
  import { executablePath } from "./path.js";
15
13
 
16
- const DEFAULT_TIMEOUT_SECONDS = 120;
17
14
  const MILLISECONDS_PER_SECOND = 1000;
15
+ const DEFAULT_TIMEOUT_SECONDS = 30;
18
16
 
19
- function getAvailablePort() {
20
- return getPort({
21
- host: "localhost",
22
- random: true,
23
- });
17
+ function resolveCommand(execPath, execName) {
18
+ const command = commandExistsSync(execName) ? execName : executablePath(execPath, execName);
19
+ return command;
24
20
  }
25
21
 
26
22
  async function runScript(
@@ -30,33 +26,31 @@ async function runScript(
30
26
  expectedResponse,
31
27
  timeoutSeconds = DEFAULT_TIMEOUT_SECONDS,
32
28
  ) {
33
- let command = "";
34
- if (commandExistsSync(execName)) {
35
- command = execName;
36
- } else {
37
- command = path.join(executablePath(execPath, execName));
38
- }
29
+ const command = resolveCommand(execPath, execName);
39
30
  console.log("runScript", command, args);
40
31
 
41
- const child = child_process.spawn(process.platform === "win32" ? command : `"${command}"`, args, {
42
- encoding: "utf8",
43
- shell: true,
32
+ const child = child_process.spawn(command, args, {
33
+ stdio: ["ignore", "pipe", "pipe"],
44
34
  });
45
- child.stdout.on("data", (data) => console.log(`[${execName}] ${data.toString()}`));
46
- child.stderr.on("data", (data) => console.log(`[${execName}] ${data.toString()}`));
47
35
 
48
- child.on("close", (code) => console.log(`[${execName}] exited with code ${code}`));
49
- child.on("kill", () => {
50
- console.log(`[${execName}] process killed`);
51
- });
52
36
  child.name = command.replace(/^.*[\\/]/u, "");
53
37
 
38
+ child.on("spawn", () => {
39
+ console.log(`[${child.name}] spawned, pid=${child.pid}`);
40
+ });
41
+
42
+ const controller = new AbortController();
43
+ const timer = setTimeout(() => controller.abort(), timeoutSeconds * MILLISECONDS_PER_SECOND);
44
+ if (typeof timer.unref === "function") {
45
+ timer.unref();
46
+ }
47
+
54
48
  try {
55
- return await pTimeout(waitForReady(child, expectedResponse), {
56
- milliseconds: timeoutSeconds * MILLISECONDS_PER_SECOND,
57
- message: `Timed out after ${timeoutSeconds} seconds`,
58
- });
49
+ const result = await waitForReady(child, expectedResponse, controller.signal);
50
+ clearTimeout(timer);
51
+ return result;
59
52
  } catch (error) {
53
+ clearTimeout(timer);
60
54
  child.kill();
61
55
  throw error;
62
56
  }
@@ -73,11 +67,16 @@ async function runBack(execName, execPath, args = {}) {
73
67
  }
74
68
  const port = await getAvailablePort();
75
69
  const backArgs = [
76
- `--port ${port}`,
77
- `--data_folder_path ${projectFolderPath}`,
78
- `--upload_folder_path ${uploadFolderPath}`,
79
- `--allowed_origin http://localhost:*`,
80
- `--timeout ${0}`,
70
+ "--port",
71
+ String(port),
72
+ "--data_folder_path",
73
+ projectFolderPath,
74
+ "--upload_folder_path",
75
+ uploadFolderPath,
76
+ "--allowed_origin",
77
+ "http://localhost:*",
78
+ "--timeout",
79
+ "0",
81
80
  ];
82
81
  if (process.env.NODE_ENV === "development" || !process.env.NODE_ENV) {
83
82
  backArgs.push("--debug");
@@ -94,9 +93,12 @@ async function runViewer(execName, execPath, args = {}) {
94
93
  }
95
94
  const port = await getAvailablePort();
96
95
  const viewerArgs = [
97
- `--port ${port}`,
98
- `--data_folder_path ${projectFolderPath}`,
99
- `--timeout ${0}`,
96
+ "--port",
97
+ String(port),
98
+ "--data_folder_path",
99
+ projectFolderPath,
100
+ "--timeout",
101
+ "0",
100
102
  ];
101
103
  console.log("runViewer", execPath, execName, viewerArgs);
102
104
  await runScript(execPath, execName, viewerArgs, "Starting factory");
@@ -121,4 +123,4 @@ function addMicroserviceMetadatas(projectFolderPath, serviceObj) {
121
123
  );
122
124
  }
123
125
 
124
- export { addMicroserviceMetadatas, getAvailablePort, runBack, runViewer };
126
+ export { addMicroserviceMetadatas, runBack, runViewer };
@@ -3,24 +3,100 @@ import child_process from "node:child_process";
3
3
  import fs from "node:fs";
4
4
  import { on } from "node:events";
5
5
  import path from "node:path";
6
+ import readline from "node:readline";
6
7
 
8
+ // Third party imports
9
+ import { getPort } from "get-port-please";
10
+
11
+ // Local imports
7
12
  import { appMode } from "./app_mode.js";
8
13
 
14
+ const BYTES_PER_KIBIBYTE = 1024;
15
+ const MAX_ERROR_BUFFER_KIBIBYTES = 64;
16
+ const MAX_ERROR_BUFFER_BYTES = MAX_ERROR_BUFFER_KIBIBYTES * BYTES_PER_KIBIBYTE;
17
+
18
+ function getAvailablePort() {
19
+ return getPort({
20
+ host: "localhost",
21
+ random: true,
22
+ });
23
+ }
24
+
9
25
  function commandExistsSync(execName) {
10
26
  const envPath = process.env.PATH || "";
11
- return envPath.split(path.delimiter).some((dir) => {
12
- const filePath = path.join(dir, execName);
27
+ return envPath.split(path.delimiter).some((directory) => {
28
+ const filePath = path.join(directory, execName);
13
29
  return fs.existsSync(filePath) && fs.statSync(filePath).isFile();
14
30
  });
15
31
  }
16
32
 
17
- async function waitForReady(child, expectedResponse) {
18
- for await (const [data] of on(child.stdout, "data")) {
19
- if (data.toString().includes(expectedResponse)) {
20
- return child;
33
+ function waitForReady(child, expectedResponse, signal) {
34
+ // oxlint-disable-next-line promise/avoid-new
35
+ return new Promise((resolve, reject) => {
36
+ const readlineStdout = readline.createInterface({ input: child.stdout });
37
+ const readlineStderr = readline.createInterface({ input: child.stderr });
38
+
39
+ let recentOutput = "";
40
+ function recordOutput(line) {
41
+ recentOutput = `${recentOutput} ${line} \n`.slice(-MAX_ERROR_BUFFER_BYTES);
21
42
  }
22
- }
23
- throw new Error("Process closed before signal");
43
+
44
+ function cleanup() {
45
+ readlineStdout.removeAllListeners();
46
+ readlineStdout.close();
47
+ readlineStderr.removeAllListeners();
48
+ readlineStderr.close();
49
+ child.removeListener("error", onError);
50
+ child.removeListener("close", onClose);
51
+ if (signal) {
52
+ signal.removeEventListener("abort", onAbort);
53
+ }
54
+ }
55
+
56
+ function onLine(line) {
57
+ console.log(`[${child.name}] ${line}`);
58
+ recordOutput(line);
59
+ if (line.includes(expectedResponse)) {
60
+ cleanup();
61
+ resolve(child);
62
+ }
63
+ }
64
+
65
+ function onErrLine(line) {
66
+ console.log(`[${child.name}] ${line}`);
67
+ recordOutput(line);
68
+ }
69
+
70
+ function onError(err) {
71
+ cleanup();
72
+ reject(err);
73
+ }
74
+
75
+ function onClose(code) {
76
+ console.log(`[${child.name}] exited with code ${code}`);
77
+ cleanup();
78
+ reject(
79
+ new Error(
80
+ `[${child.name}] exited with code ${code} before becoming ready.${
81
+ recentOutput ? `\nRecent output:\n${recentOutput}` : ""
82
+ }`,
83
+ ),
84
+ );
85
+ }
86
+
87
+ function onAbort() {
88
+ cleanup();
89
+ reject(new Error(`[${child.name}] timed out waiting for "${expectedResponse}"`));
90
+ }
91
+
92
+ readlineStdout.on("line", onLine);
93
+ readlineStderr.on("line", onErrLine);
94
+ child.once("error", onError);
95
+ child.once("close", onClose);
96
+ if (signal) {
97
+ signal.addEventListener("abort", onAbort, { once: true });
98
+ }
99
+ });
24
100
  }
25
101
 
26
102
  async function waitNuxt(nuxtProcess) {
@@ -49,11 +125,17 @@ async function waitNuxt(nuxtProcess) {
49
125
  async function runBrowser(scriptName) {
50
126
  process.env.MODE = appMode.BROWSER;
51
127
 
128
+ const port = await getAvailablePort();
129
+
52
130
  const nuxtProcess = child_process.spawn("npm", ["run", scriptName], {
53
131
  shell: true,
54
132
  FORCE_COLOR: true,
133
+ env: {
134
+ ...process.env,
135
+ PORT: port,
136
+ },
55
137
  });
56
138
  return await waitNuxt(nuxtProcess);
57
139
  }
58
140
 
59
- export { runBrowser, waitForReady, commandExistsSync };
141
+ export { commandExistsSync, getAvailablePort, runBrowser, waitForReady };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geode/opengeodeweb-front",
3
- "version": "10.26.2",
3
+ "version": "10.26.3-rc.1",
4
4
  "description": "OpenSource Vue/Nuxt/Pinia/Vuetify framework for web applications",
5
5
  "homepage": "https://github.com/Geode-solutions/OpenGeodeWeb-Front",
6
6
  "bugs": {
@@ -34,8 +34,8 @@
34
34
  "build": ""
35
35
  },
36
36
  "dependencies": {
37
- "@geode/opengeodeweb-back": "latest",
38
- "@geode/opengeodeweb-viewer": "latest",
37
+ "@geode/opengeodeweb-back": "next",
38
+ "@geode/opengeodeweb-viewer": "next",
39
39
  "@google-cloud/run": "3.2.0",
40
40
  "@kitware/vtk.js": "33.3.0",
41
41
  "@mdi/font": "7.4.47",