@swizzyweb/swerve-manager 0.1.8 → 0.2.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/LICENSE CHANGED
@@ -187,7 +187,7 @@
187
187
  same "printed page" as the copyright notice for easier
188
188
  identification within third-party archives.
189
189
 
190
- Copyright [yyyy] [name of copyright owner]
190
+ Copyright 2025 SwizzyWeb
191
191
 
192
192
  Licensed under the Apache License, Version 2.0 (the "License");
193
193
  you may not use this file except in compliance with the License.
package/dist/swerve.js CHANGED
@@ -155,14 +155,22 @@ export class SwerveManager {
155
155
  const { app, appDataRoot, packageName, port, gLogger, serviceArgs, servicePath, serviceKey, } = props;
156
156
  try {
157
157
  gLogger.info(`Getting webservice package ${packageName} and will run on port ${port}`);
158
- if (packageName) {
158
+ if (servicePath ?? packageName) {
159
159
  gLogger.debug(`Getting web service with name ${packageName}`);
160
160
  }
161
161
  else {
162
162
  gLogger.debug(`Getting webservice with path: ${servicePath}`);
163
163
  }
164
+ let firstTool;
165
+ try {
166
+ firstTool = await import(servicePath ?? packageName);
167
+ gLogger.info(`Imported from raw path ${servicePath}`);
168
+ }
169
+ catch (e) {
170
+ gLogger.warn(`Unable to import from raw tool path ${servicePath ?? packageName}, trying with import name. Err: ${e?.message}. Stack: ${e?.stack}`);
171
+ }
164
172
  const fullPath = await this.getImportName(packageName, servicePath);
165
- const tool = await import(fullPath);
173
+ const tool = firstTool ?? (await import(fullPath));
166
174
  gLogger.debug(`Got service with require: ${JSON.stringify(tool)}`);
167
175
  gLogger.debug(`Getting web service from tool...`);
168
176
  const appDataPath = path.join(appDataRoot, "appdata", serviceKey);
@@ -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);
@@ -0,0 +1,32 @@
1
+ // eslint.config.js
2
+ import tsParser from "@typescript-eslint/parser";
3
+ import tsPlugin from "@typescript-eslint/eslint-plugin";
4
+
5
+ export default [
6
+ {
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
+ },
18
+ languageOptions: {
19
+ parser: tsParser,
20
+ parserOptions: {
21
+ // Update the project to point to your new file
22
+ project: "./tsconfig.eslint.json",
23
+ ecmaVersion: "latest",
24
+ sourceType: "module",
25
+ },
26
+ },
27
+ rules: {
28
+ "@typescript-eslint/no-floating-promises": "error",
29
+ // ... other TypeScript rules
30
+ },
31
+ },
32
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swizzyweb/swerve-manager",
3
- "version": "0.1.8",
3
+ "version": "0.2.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",
@@ -22,8 +22,8 @@
22
22
  "typescript": "^5.9.2"
23
23
  },
24
24
  "dependencies": {
25
- "@swizzyweb/swizzy-common": "^0.3.2",
26
- "@swizzyweb/swizzy-web-service": "^0.5.4",
25
+ "@swizzyweb/swizzy-common": "^0.3.3",
26
+ "@swizzyweb/swizzy-web-service": "^0.5.5",
27
27
  "bun": "^1.2.22",
28
28
  "deno": "^2.5.2"
29
29
  },
package/src/swerve.ts CHANGED
@@ -269,14 +269,22 @@ export class SwerveManager implements ISwerveManager {
269
269
  `Getting webservice package ${packageName} and will run on port ${port}`,
270
270
  );
271
271
 
272
- if (packageName) {
272
+ if (servicePath ?? packageName) {
273
273
  gLogger.debug(`Getting web service with name ${packageName}`);
274
274
  } else {
275
275
  gLogger.debug(`Getting webservice with path: ${servicePath}`);
276
276
  }
277
-
277
+ let firstTool;
278
+ try {
279
+ firstTool = await import(servicePath ?? packageName);
280
+ gLogger.info(`Imported from raw path ${servicePath}`);
281
+ } catch (e: any) {
282
+ gLogger.warn(
283
+ `Unable to import from raw tool path ${servicePath ?? packageName}, trying with import name. Err: ${e?.message}. Stack: ${e?.stack}`,
284
+ );
285
+ }
278
286
  const fullPath = await this.getImportName(packageName, servicePath);
279
- const tool = await import(fullPath);
287
+ const tool = firstTool ?? (await import(fullPath));
280
288
 
281
289
  gLogger.debug(`Got service with require: ${JSON.stringify(tool)}`);
282
290
  gLogger.debug(`Getting web service from tool...`);
@@ -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);
@@ -0,0 +1,13 @@
1
+ // tsconfig.eslint.json
2
+ {
3
+ "extends": "./tsconfig.json",
4
+ "include": [
5
+ "test/**/*", // Include your test files
6
+ "src/**/*" // Include your source files
7
+ ],
8
+ "exclude": [
9
+ // Ensure you exclude the dist folder, test files from build, etc.
10
+ "dist/**/*",
11
+ "**/*.spec.ts"
12
+ ]
13
+ }