@swizzyweb/swerve-manager 0.1.9 → 0.3.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.
- package/README.md +4 -0
- package/deno.lock +1229 -0
- package/dist/swerve.d.ts +1 -1
- package/dist/swerve.js +6 -6
- package/dist/utils/getPackageJson.js +1 -0
- package/eslint.config.js +10 -19
- package/package.json +12 -6
- package/src/swerve.ts +7 -11
- package/src/utils/getPackageJson.ts +1 -0
- package/src/utils/installWebservice.ts +1 -10
package/dist/swerve.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Application } from "
|
|
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
|
-
|
|
2
|
-
import
|
|
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";
|
|
@@ -155,7 +154,7 @@ export class SwerveManager {
|
|
|
155
154
|
const { app, appDataRoot, packageName, port, gLogger, serviceArgs, servicePath, serviceKey, } = props;
|
|
156
155
|
try {
|
|
157
156
|
gLogger.info(`Getting webservice package ${packageName} and will run on port ${port}`);
|
|
158
|
-
if (packageName) {
|
|
157
|
+
if (servicePath ?? packageName) {
|
|
159
158
|
gLogger.debug(`Getting web service with name ${packageName}`);
|
|
160
159
|
}
|
|
161
160
|
else {
|
|
@@ -163,10 +162,11 @@ export class SwerveManager {
|
|
|
163
162
|
}
|
|
164
163
|
let firstTool;
|
|
165
164
|
try {
|
|
166
|
-
firstTool = await import(
|
|
165
|
+
firstTool = await import(servicePath ?? packageName);
|
|
166
|
+
gLogger.info(`Imported from raw path ${servicePath}`);
|
|
167
167
|
}
|
|
168
168
|
catch (e) {
|
|
169
|
-
gLogger.warn(`Unable to import from raw tool path ${
|
|
169
|
+
gLogger.warn(`Unable to import from raw tool path ${servicePath ?? packageName}, trying with import name. Err: ${e?.message}. Stack: ${e?.stack}`);
|
|
170
170
|
}
|
|
171
171
|
const fullPath = await this.getImportName(packageName, servicePath);
|
|
172
172
|
const tool = firstTool ?? (await import(fullPath));
|
|
@@ -41,6 +41,7 @@ export function getPackageJson(packageNameOrPath) {
|
|
|
41
41
|
// console.log(entrypoint);
|
|
42
42
|
// console.error(`Entrypoint is ${entrypoint}`);
|
|
43
43
|
// throw `Entrypoint is ${entrypoint}`;
|
|
44
|
+
console.log(`dir name in ${entrypoint}`);
|
|
44
45
|
return { packageJson, servicePath: entrypoint };
|
|
45
46
|
}
|
|
46
47
|
dir = path.dirname(dir);
|
package/eslint.config.js
CHANGED
|
@@ -1,32 +1,23 @@
|
|
|
1
1
|
// eslint.config.js
|
|
2
|
-
import
|
|
3
|
-
|
|
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
|
-
|
|
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
|
|
11
|
+
parser,
|
|
20
12
|
parserOptions: {
|
|
21
|
-
|
|
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.
|
|
3
|
+
"version": "0.3.0",
|
|
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
|
-
"@
|
|
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.
|
|
27
|
-
"
|
|
28
|
-
"deno": "^2.5.2"
|
|
33
|
+
"@swizzyweb/swizzy-web-service": "^0.6.0",
|
|
34
|
+
"express": "^5.2.1"
|
|
29
35
|
},
|
|
30
36
|
"repository": {
|
|
31
37
|
"type": "git",
|
package/src/swerve.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
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:
|
|
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}`]) {
|
|
@@ -269,17 +264,18 @@ export class SwerveManager implements ISwerveManager {
|
|
|
269
264
|
`Getting webservice package ${packageName} and will run on port ${port}`,
|
|
270
265
|
);
|
|
271
266
|
|
|
272
|
-
if (packageName) {
|
|
267
|
+
if (servicePath ?? packageName) {
|
|
273
268
|
gLogger.debug(`Getting web service with name ${packageName}`);
|
|
274
269
|
} else {
|
|
275
270
|
gLogger.debug(`Getting webservice with path: ${servicePath}`);
|
|
276
271
|
}
|
|
277
272
|
let firstTool;
|
|
278
273
|
try {
|
|
279
|
-
firstTool = await import(
|
|
274
|
+
firstTool = await import(servicePath ?? packageName);
|
|
275
|
+
gLogger.info(`Imported from raw path ${servicePath}`);
|
|
280
276
|
} catch (e: any) {
|
|
281
277
|
gLogger.warn(
|
|
282
|
-
`Unable to import from raw tool path ${
|
|
278
|
+
`Unable to import from raw tool path ${servicePath ?? packageName}, trying with import name. Err: ${e?.message}. Stack: ${e?.stack}`,
|
|
283
279
|
);
|
|
284
280
|
}
|
|
285
281
|
const fullPath = await this.getImportName(packageName, servicePath);
|
|
@@ -45,6 +45,7 @@ export function getPackageJson(
|
|
|
45
45
|
// console.log(entrypoint);
|
|
46
46
|
// console.error(`Entrypoint is ${entrypoint}`);
|
|
47
47
|
// throw `Entrypoint is ${entrypoint}`;
|
|
48
|
+
console.log(`dir name in ${entrypoint}`);
|
|
48
49
|
return { packageJson, servicePath: entrypoint };
|
|
49
50
|
}
|
|
50
51
|
dir = path.dirname(dir);
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
|
|
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
|
|