@swizzyweb/swerve-manager 0.2.0 → 0.3.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.
package/dist/swerve.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Application } from "@swizzyweb/express";
1
+ import { Application } from "express";
2
2
  import { SwerveArgs } from "./utils/index.js";
3
3
  import { AnyServer, IWebService, WebService } from "@swizzyweb/swizzy-web-service";
4
4
  import { ILogger } from "@swizzyweb/swizzy-common";
package/dist/swerve.js CHANGED
@@ -1,6 +1,5 @@
1
- // @ts-ignore
2
- import express from "@swizzyweb/express";
3
- import { getLoggerForService, } from "./utils/index.js";
1
+ import express from "express";
2
+ import { getLoggerForService } from "./utils/index.js";
4
3
  import { SwizzyWinstonLogger, } from "@swizzyweb/swizzy-web-service";
5
4
  import os from "node:os";
6
5
  import process from "node:process";
package/eslint.config.js CHANGED
@@ -1,32 +1,23 @@
1
1
  // eslint.config.js
2
- import tsParser from "@typescript-eslint/parser";
3
- import tsPlugin from "@typescript-eslint/eslint-plugin";
2
+ import { defineConfig } from "eslint/config";
3
+
4
+ import tseslint from "@typescript-eslint/eslint-plugin";
5
+ import parser from "@typescript-eslint/parser";
4
6
 
5
7
  export default [
6
8
  {
7
- ignores: [
8
- "dist/**", // Now ignores all of dist
9
- "coverage/**", // Resolves unused eslint-disable warnings
10
- "test/**",
11
- ],
12
- },
13
- {
14
- files: ["**/*.ts", "**/*.tsx"],
15
- plugins: {
16
- "@typescript-eslint": tsPlugin,
17
- },
9
+ files: ["**/*.ts"],
18
10
  languageOptions: {
19
- parser: tsParser,
11
+ parser,
20
12
  parserOptions: {
21
- // Update the project to point to your new file
22
- project: "./tsconfig.eslint.json",
23
- ecmaVersion: "latest",
24
- sourceType: "module",
13
+ project: "./tsconfig.json",
25
14
  },
26
15
  },
16
+ plugins: {
17
+ "@typescript-eslint": tseslint,
18
+ },
27
19
  rules: {
28
20
  "@typescript-eslint/no-floating-promises": "error",
29
- // ... other TypeScript rules
30
21
  },
31
22
  },
32
23
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swizzyweb/swerve-manager",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "swizzy-swerve is a bootstrapper for swizzy web services. This package will bootstrap and run independent swizzy web services.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,20 +12,26 @@
12
12
  "test:node": "node --test ./test**/*.spec.ts",
13
13
  "test:deno": "deno test test/** --allow-env --allow-write --allow-read",
14
14
  "test:bun": "bun test",
15
- "coverage": "jest --coverage"
15
+ "coverage": "jest --coverage",
16
+ "lint": "eslint .",
17
+ "lint:fix": "eslint . --fix"
16
18
  },
17
19
  "author": "Jason Gallagher",
18
20
  "license": "Apache-2.0",
19
21
  "devDependencies": {
20
- "@swizzyweb/express": "^4.19.2",
22
+ "@types/express": "^5.0.6",
21
23
  "@types/node": "^22.18.6",
24
+ "@typescript-eslint/eslint-plugin": "^8.54.0",
25
+ "@typescript-eslint/parser": "^8.54.0",
26
+ "bun": "^1.3.8",
27
+ "deno": "^2.6.8",
28
+ "eslint": "^9.39.2",
22
29
  "typescript": "^5.9.2"
23
30
  },
24
31
  "dependencies": {
25
32
  "@swizzyweb/swizzy-common": "^0.3.3",
26
- "@swizzyweb/swizzy-web-service": "^0.5.5",
27
- "bun": "^1.2.22",
28
- "deno": "^2.5.2"
33
+ "@swizzyweb/swizzy-web-service": "^0.6.1",
34
+ "express": "^5.2.1"
29
35
  },
30
36
  "repository": {
31
37
  "type": "git",
package/src/swerve.ts CHANGED
@@ -1,10 +1,5 @@
1
- // @ts-ignore
2
- import express, { Application } from "@swizzyweb/express";
3
- import {
4
- getLoggerForService,
5
- installWebService,
6
- SwerveArgs,
7
- } from "./utils/index.js";
1
+ import express, { Application } from "express";
2
+ import { getLoggerForService, SwerveArgs } from "./utils/index.js";
8
3
  import {
9
4
  AnyServer,
10
5
  IWebService,
@@ -130,7 +125,7 @@ export class SwerveManager implements ISwerveManager {
130
125
 
131
126
  try {
132
127
  const webServices: WebService<any>[] = [];
133
- const newApps: { [port: number]: Application } = {};
128
+ const newApps: Apps = {};
134
129
  for (const serviceEntry of Object.entries(args.services)) {
135
130
  const port = serviceEntry[1].port ?? args.port;
136
131
  if (!this.apps[`${port}`]) {
@@ -19,17 +19,12 @@ export function getPackageJson(
19
19
  ): { packageJson: Record<string, any>; servicePath: string } | null {
20
20
  try {
21
21
  // Step 1: Resolve to an absolute path
22
- // const resolvedEntry = isPath(packageNameOrPath)
23
- // ? require.resolve(path.resolve(packageNameOrPath))
24
- // : // : require.resolve(packageNameOrPath);
25
- // require.resolve(packageNameOrPath, { paths: [process.cwd()] });
26
22
  const resolvedEntry = isPath(packageNameOrPath)
27
23
  ? pathToFileURL(path.resolve(packageNameOrPath)).href
28
24
  : import.meta.resolve(packageNameOrPath);
29
25
 
30
26
  // Step 2: Traverse upward to find the nearest package.json
31
27
  let dir = fileURLToPath(resolvedEntry); //path.dirname(resolvedEntry);
32
- // console.log(dir);
33
28
  while (dir !== path.parse(dir).root) {
34
29
  const pkgPath = path.join(dir, "package.json");
35
30
  if (fs.existsSync(pkgPath)) {
@@ -40,12 +35,8 @@ export function getPackageJson(
40
35
  } else if (dir.startsWith(".")) {
41
36
  dir = path.join(process.cwd(), dir);
42
37
  }
43
- // console.log(dir);
38
+
44
39
  const entrypoint = path.join(dir, packageJson.main);
45
- // console.log(entrypoint);
46
- // console.error(`Entrypoint is ${entrypoint}`);
47
- // throw `Entrypoint is ${entrypoint}`;
48
- console.log(`dir name in ${entrypoint}`);
49
40
  return { packageJson, servicePath: entrypoint };
50
41
  }
51
42
  dir = path.dirname(dir);
@@ -85,7 +76,6 @@ export function getPackageJsonOrig(
85
76
 
86
77
  return null;
87
78
  } catch (error) {
88
- //console.error(`Failed to resolve package "${packageName}":`, error);
89
79
  return null;
90
80
  }
91
81
  }
@@ -1,16 +1,7 @@
1
- // @ts-ignore
2
- import express, { Request, Response } from "@swizzyweb/express";
3
- import {
4
- BrowserLogger,
5
- getPackageJsonFromDirectory,
6
- ILogger,
7
- } from "@swizzyweb/swizzy-common";
8
- import { SwizzyWinstonLogger } from "@swizzyweb/swizzy-web-service";
9
- import { readFileSync } from "fs";
1
+ import { ILogger } from "@swizzyweb/swizzy-common";
10
2
  import path from "node:path";
11
3
  import os from "node:os";
12
4
  import process from "node:process";
13
- import { getServiceNameFromCurrentDirPackage } from "./getArgs.js";
14
5
  import { mkdirSync } from "node:fs";
15
6
  import { fileURLToPath } from "node:url";
16
7