Skip to content

Commit 8840a18

Browse files
committed
upgrades some old packages in project that were causing build issues
1 parent e37682f commit 8840a18

File tree

8 files changed

+3172
-2752
lines changed

8 files changed

+3172
-2752
lines changed

src/packages/pnpm-lock.yaml

Lines changed: 3114 additions & 2743 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/packages/project/browser-websocket/symmetric_channel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export async function browser_symmetric_channel(
7171
return name;
7272
}
7373

74-
class SymmetricChannel extends EventEmitter {
74+
export class SymmetricChannel extends EventEmitter {
7575
channel: any;
7676

7777
constructor(channel?: any) {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// BSD 2-clause
2+
3+
import { SpawnOptions } from 'node:child_process';
4+
5+
type DaemonizeProcessOpts = {
6+
/** The path to the script to be executed. Default: The current script. */
7+
script?: string;
8+
/** The command line arguments to be used. Default: The current arguments. */
9+
arguments?: string[];
10+
/** The path to the Node.js binary to be used. Default: The current Node.js binary. */
11+
node?: string;
12+
/** The exit code to be used when exiting the parent process. Default: `0`. */
13+
exitCode?: number;
14+
} & SpawnOptions;
15+
export declare function daemonizeProcess(opts?: DaemonizeProcessOpts): void;
16+
export {};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// BSD 2-clause
2+
3+
// This is just https://www.npmjs.com/package/daemonize-process
4+
// but they stopped supporting commonjs, and we need commonjs or
5+
// to build via typescript, and I don't have the time to stress
6+
// for hours about a 20 line function!
7+
8+
import { spawn } from 'node:child_process';
9+
import { env, cwd, execPath, argv, exit } from 'node:process';
10+
11+
const id = "_DAEMONIZE_PROCESS";
12+
function daemonizeProcess(opts = {}) {
13+
if (id in env) {
14+
delete env[id];
15+
} else {
16+
const o = {
17+
// spawn options
18+
env: Object.assign(env, opts.env, { [id]: "1" }),
19+
cwd: cwd(),
20+
stdio: "ignore",
21+
detached: true,
22+
// custom options
23+
node: execPath,
24+
script: argv[1],
25+
arguments: argv.slice(2),
26+
exitCode: 0,
27+
...opts
28+
};
29+
const args = [o.script, ...o.arguments];
30+
const proc = spawn(o.node, args, o);
31+
proc?.unref?.();
32+
exit(o.exitCode);
33+
}
34+
}
35+
36+
export { daemonizeProcess };

src/packages/project/named-servers/control.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
* License: MS-RSL – see LICENSE.md for details
44
*/
55

6-
import getPort from "get-port";
76
import { exec } from "node:child_process";
87
import { mkdir, readFile, writeFile } from "node:fs/promises";
98
import { join } from "node:path";
10-
119
import basePath from "@cocalc/backend/base-path";
1210
import { data } from "@cocalc/backend/data";
1311
import { project_id } from "@cocalc/project/data";
@@ -26,6 +24,7 @@ export async function start(name: NamedServerName): Promise<number> {
2624
winston.debug(`${name} is already running`);
2725
return s.port;
2826
}
27+
const getPort = (await import("get-port")).default; // since esm only
2928
const port = await getPort({ port: preferredPort(name) });
3029
// For servers that need a basePath, they will use this one.
3130
// Other servers (e.g., Pluto, code-server) that don't need

src/packages/project/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@
3838
"body-parser": "^1.20.3",
3939
"commander": "^7.2.0",
4040
"compression": "^1.7.4",
41-
"daemonize-process": "^3.0.0",
4241
"debug": "^4.3.2",
43-
"diskusage": "^1.1.3",
42+
"diskusage": "^1.2.0",
4443
"expect": "^26.6.2",
4544
"express": "^4.20.0",
4645
"express-rate-limit": "^7.4.0",

src/packages/project/project.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
* License: MS-RSL – see LICENSE.md for details
44
*/
55

6-
import daemonizeProcess from "daemonize-process";
7-
86
import { init as initBugCounter } from "./bug-counter";
97
import { init as initClient } from "./client";
108
import initInfoJson from "./info-json";
@@ -13,6 +11,7 @@ import { getOptions } from "./init-program";
1311
import { cleanup as cleanupEnvironmentVariables } from "./project-setup";
1412
import initPublicPaths from "./public-paths";
1513
import initServers from "./servers/init";
14+
import { daemonizeProcess } from "./daemonize-process";
1615

1716
import { getLogger } from "./logger";
1817
const logger = getLogger("project-main");

src/packages/project/upload.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ export default function init(): Router {
3737

3838
const router = Router();
3939

40-
router.get("/.smc/upload", function (_, res) {
40+
router.get("/.smc/upload", (_, res) => {
4141
logger.http("upload GET");
42-
return res.send("hello");
42+
res.send("hello");
4343
});
4444

4545
router.post("/.smc/upload", async function (req, res): Promise<void> {

0 commit comments

Comments
 (0)