@swizzyweb/swerve-manager 0.3.3 → 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/dist/utils/getArgs.js +12 -4
- package/package.json +1 -1
- package/src/utils/getArgs.ts +13 -4
- package/test/config/serviceConfig.json +1 -1
package/dist/utils/getArgs.js
CHANGED
|
@@ -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
|
-
|
|
172
|
-
|
|
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);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swizzyweb/swerve-manager",
|
|
3
|
-
"version": "0.3.
|
|
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",
|
package/src/utils/getArgs.ts
CHANGED
|
@@ -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
|
-
|
|
206
|
-
|
|
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;
|