@swizzyweb/swerve-manager 0.3.2 → 0.3.4

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/deno.lock CHANGED
@@ -1212,7 +1212,7 @@
1212
1212
  "packageJson": {
1213
1213
  "dependencies": [
1214
1214
  "npm:@swizzyweb/swizzy-common@~0.3.3",
1215
- "npm:@swizzyweb/swizzy-web-service@~0.6.1",
1215
+ "npm:@swizzyweb/swizzy-web-service@0.6.2",
1216
1216
  "npm:@types/express@^5.0.6",
1217
1217
  "npm:@types/node@^22.18.6",
1218
1218
  "npm:@typescript-eslint/eslint-plugin@^8.54.0",
package/dist/swerve.js CHANGED
@@ -1,3 +1,4 @@
1
+ // @deno-types="npm:@types/express@5"
1
2
  import express from "express";
2
3
  import { getLoggerForService } from "./utils/index.js";
3
4
  import { SwizzyWinstonLogger, } from "@swizzyweb/swizzy-web-service";
@@ -1,8 +1,9 @@
1
1
  import path from "node:path";
2
- import process from "node:process";
2
+ import process, { cwd } from "node:process";
3
3
  import { SwerveConfigParser } from "../config/config-parser.js";
4
4
  import { deepMerge } from "@swizzyweb/swizzy-common";
5
5
  import { getPackageJson } from "./getPackageJson.js";
6
+ import { existsSync, readFileSync } from "node:fs";
6
7
  function getHelpText() {
7
8
  return `Help --
8
9
  npm run server <serviceName> <port (optional)>
@@ -168,9 +169,16 @@ export async function getArgs(args, logger) {
168
169
  // serviceEntry[1].servicePath ?? serviceEntry[1].packageName;
169
170
  if (!servicePath) {
170
171
  serviceEntry[1].servicePath = packageName;
171
- // throw new Error(
172
- // `servicePath or packageName must be set in service configurations`,
173
- // );
172
+ const localPackage = path.join(cwd(), "node_modules", packageName);
173
+ const packageJsonPath = path.join(localPackage, "package.json");
174
+ if (existsSync(path.join(packageJsonPath))) {
175
+ const json = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
176
+ const main = json.main;
177
+ serviceEntry[1].servicePath = path.join(localPackage, main);
178
+ }
179
+ else {
180
+ serviceEntry[1].servicePath = getPackageJson(packageName).servicePath;
181
+ }
174
182
  }
175
183
  else {
176
184
  const serviceData = getService(servicePath, logger);
@@ -1,3 +1,4 @@
1
1
  export * from "./getArgs.js";
2
2
  export * from "./installWebservice.js";
3
3
  export * from "./getFullImportPath.js";
4
+ export * from "./getPackageJson.js";
@@ -1,3 +1,4 @@
1
1
  export * from "./getArgs.js";
2
2
  export * from "./installWebservice.js";
3
3
  export * from "./getFullImportPath.js";
4
+ export * from "./getPackageJson.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swizzyweb/swerve-manager",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
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",
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@swizzyweb/swizzy-common": "^0.3.3",
33
- "@swizzyweb/swizzy-web-service": "^0.6.1",
33
+ "@swizzyweb/swizzy-web-service": "0.6.2",
34
34
  "express": "^5.2.1"
35
35
  },
36
36
  "repository": {
package/src/swerve.ts CHANGED
@@ -1,3 +1,4 @@
1
+ // @deno-types="npm:@types/express@5"
1
2
  import express, { Application } from "express";
2
3
  import { getLoggerForService, SwerveArgs } from "./utils/index.js";
3
4
  import {
@@ -1,11 +1,12 @@
1
1
  // @ts-ignore
2
2
  import { ILogger } from "@swizzyweb/swizzy-common";
3
3
  import path from "node:path";
4
- import process from "node:process";
4
+ import process, { cwd } from "node:process";
5
5
  import { IConfig, IService, KeyValue } from "../config/index.js";
6
6
  import { SwerveConfigParser } from "../config/config-parser.js";
7
7
  import { deepMerge } from "@swizzyweb/swizzy-common";
8
8
  import { getPackageJson } from "./getPackageJson.js";
9
+ import { existsSync, readFileSync } from "node:fs";
9
10
 
10
11
  function getHelpText() {
11
12
  return `Help --
@@ -202,9 +203,17 @@ export async function getArgs(
202
203
  // serviceEntry[1].servicePath ?? serviceEntry[1].packageName;
203
204
  if (!servicePath) {
204
205
  serviceEntry[1].servicePath = packageName!;
205
- // throw new Error(
206
- // `servicePath or packageName must be set in service configurations`,
207
- // );
206
+ const localPackage = path.join(cwd(), "node_modules", packageName);
207
+ const packageJsonPath = path.join(localPackage, "package.json");
208
+ if (existsSync(path.join(packageJsonPath))) {
209
+ const json = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
210
+ const main = json.main;
211
+ serviceEntry[1].servicePath = path.join(localPackage, main);
212
+ } else {
213
+ serviceEntry[1].servicePath = getPackageJson(
214
+ packageName!,
215
+ ).servicePath;
216
+ }
208
217
  } else {
209
218
  const serviceData = getService(servicePath, logger);
210
219
  serviceEntry[1].packageName = serviceData.packageJson?.name;
@@ -1,3 +1,4 @@
1
1
  export * from "./getArgs.js";
2
2
  export * from "./installWebservice.js";
3
3
  export * from "./getFullImportPath.js";
4
+ export * from "./getPackageJson.js";
@@ -9,7 +9,7 @@
9
9
  "hello": "world",
10
10
  "none": false
11
11
  },
12
- "packageName": "@swizzyweb/my-first-web-service",
12
+ "packageName": "@swizzyweb/swizzy-web-service",
13
13
  "serviceConfiguration": {
14
14
  "port": 3001,
15
15
  "tableName": "someString"