@swizzyweb/swerve-manager 0.3.4 → 0.3.5

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
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": "5",
3
3
  "specifiers": {
4
- "npm:@swizzyweb/swizzy-common@~0.3.3": "0.3.3",
5
4
  "npm:@types/express@^5.0.6": "5.0.6",
6
5
  "npm:@types/node@^22.18.6": "22.19.7",
7
6
  "npm:@typescript-eslint/eslint-plugin@^8.54.0": "8.54.0_@typescript-eslint+parser@8.54.0__eslint@9.39.2__typescript@5.9.3_eslint@9.39.2_typescript@5.9.3",
@@ -1211,8 +1210,8 @@
1211
1210
  "workspace": {
1212
1211
  "packageJson": {
1213
1212
  "dependencies": [
1214
- "npm:@swizzyweb/swizzy-common@~0.3.3",
1215
- "npm:@swizzyweb/swizzy-web-service@0.6.2",
1213
+ "npm:@swizzyweb/swizzy-common@~0.3.5",
1214
+ "npm:@swizzyweb/swizzy-web-service@~0.6.3",
1216
1215
  "npm:@types/express@^5.0.6",
1217
1216
  "npm:@types/node@^22.18.6",
1218
1217
  "npm:@typescript-eslint/eslint-plugin@^8.54.0",
package/dist/swerve.d.ts CHANGED
@@ -52,6 +52,7 @@ export interface SwerveManagerProps {
52
52
  webServices?: WebService<any>[];
53
53
  nodeModulesPath?: string;
54
54
  logger?: ILogger<any> | undefined;
55
+ noLogFile?: boolean;
55
56
  }
56
57
  export interface WebServiceConfiguration {
57
58
  }
package/dist/swerve.js CHANGED
@@ -28,6 +28,7 @@ export class SwerveManager {
28
28
  appName: "swerve-manager",
29
29
  port: -1,
30
30
  hostName: os.hostname(),
31
+ noLogFile: props.noLogFile ?? true,
31
32
  });
32
33
  }
33
34
  async run(request) {
@@ -49,6 +50,7 @@ export class SwerveManager {
49
50
  hostName: os.hostname(),
50
51
  ownerName: "swerve",
51
52
  pid: process.pid,
53
+ noLogFile: args.noLogFile,
52
54
  });
53
55
  try {
54
56
  const webServices = [];
@@ -108,21 +110,14 @@ export class SwerveManager {
108
110
  const { app, args } = props;
109
111
  let gLogger = new SwizzyWinstonLogger({
110
112
  port: 0,
111
- logLevel: process.env.LOG_LEVEL ?? "info",
113
+ logLevel: process.env.LOG_LEVEL ?? args.logLevel ?? "info",
112
114
  appDataRoot: args.appDataRoot,
113
115
  appName: `swerve`,
114
116
  hostName: os.hostname(),
115
117
  pid: process.pid,
118
+ noLogFile: args.noLogFile,
116
119
  });
117
120
  try {
118
- gLogger = new SwizzyWinstonLogger({
119
- logLevel: args.serviceArgs.logLevel ?? process.env.LOG_LEVEL ?? "info",
120
- port: args.port,
121
- logDir: args.appDataRoot,
122
- appName: `swerve`,
123
- hostName: os.hostname(),
124
- pid: process.pid,
125
- });
126
121
  gLogger.debug(`Swerve Args: ${JSON.stringify(args)}`);
127
122
  const PORT = args.port ?? 3005;
128
123
  const webServices = [];
@@ -187,7 +182,7 @@ export class SwerveManager {
187
182
  serviceArgs: { ...serviceArgs },
188
183
  logger,
189
184
  });
190
- logger.debug(`Got web service`);
185
+ gLogger.debug(`Got web service`);
191
186
  gLogger.debug(`Installing web service...`);
192
187
  await service.install({});
193
188
  gLogger.debug(`Installed web service ${packageName}`);
@@ -7,6 +7,7 @@ export interface SwerveArgs extends IConfig {
7
7
  appDataRoot?: string;
8
8
  serviceArgs?: KeyValue<any>;
9
9
  logLevel: string;
10
+ noLogFile: boolean;
10
11
  [key: string]: any;
11
12
  }
12
13
  export declare function getArgs(args: string[], logger: ILogger<any>): Promise<SwerveArgs>;
@@ -81,6 +81,7 @@ function getDefaultArgs() {
81
81
  services: {},
82
82
  port: 3005,
83
83
  serviceArgs: {},
84
+ noLogFile: false,
84
85
  };
85
86
  }
86
87
  const ARG_PREFIX = "--";
@@ -117,6 +118,12 @@ function tryParseNumberArg(val) {
117
118
  }
118
119
  function parseArgValue(val, logger) {
119
120
  try {
121
+ if (`${val}`.toLocaleLowerCase() == "true") {
122
+ return true;
123
+ }
124
+ else if (`${val}`.toLocaleLowerCase() == "false") {
125
+ return false;
126
+ }
120
127
  return JSON.parse(val);
121
128
  }
122
129
  catch (e) {
@@ -127,7 +134,8 @@ function parseArgValue(val, logger) {
127
134
  const DEFAULT_PORT = 3005;
128
135
  export async function getArgs(args, logger) {
129
136
  let argKey = undefined;
130
- let swerveArgs = getDefaultArgs();
137
+ let defaultArgs = getDefaultArgs();
138
+ let swerveArgs = defaultArgs;
131
139
  let configFromFile;
132
140
  const serviceCounts = new Map();
133
141
  for (let i = 2; i < args.length; i++) {
@@ -141,6 +149,9 @@ export async function getArgs(args, logger) {
141
149
  argKey = undefined;
142
150
  continue;
143
151
  }
152
+ if (Object.keys(defaultArgs).includes(argKey)) {
153
+ swerveArgs[argKey] = parseArgValue(nextVal, logger);
154
+ }
144
155
  swerveArgs.serviceArgs[argKey] = parseArgValue(nextVal, logger);
145
156
  argKey = undefined;
146
157
  continue;
@@ -73,6 +73,7 @@ export function getLoggerForService(serviceArgs, appName, port, gLogger) {
73
73
  const hostName = os.hostname();
74
74
  const logDir = serviceArgs.logDir;
75
75
  const appDataRoot = serviceArgs.appDataRoot;
76
+ const noLogFile = serviceArgs.noLogFile ?? gLogger.getLoggerProps().noLogFile;
76
77
  return gLogger.clone({
77
78
  port,
78
79
  appName,
@@ -83,5 +84,6 @@ export function getLoggerForService(serviceArgs, appName, port, gLogger) {
83
84
  logLevel,
84
85
  ownerName,
85
86
  logFileName,
87
+ noLogFile,
86
88
  });
87
89
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swizzyweb/swerve-manager",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
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,9 +12,10 @@
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": "node --test --experimental-test-coverage ./test/**.spec.ts",
16
16
  "lint": "eslint .",
17
- "lint:fix": "eslint . --fix"
17
+ "lint:fix": "eslint . --fix",
18
+ "docs": "npx typedoc src/index.ts"
18
19
  },
19
20
  "author": "Jason Gallagher",
20
21
  "license": "Apache-2.0",
@@ -29,8 +30,8 @@
29
30
  "typescript": "^5.9.2"
30
31
  },
31
32
  "dependencies": {
32
- "@swizzyweb/swizzy-common": "^0.3.3",
33
- "@swizzyweb/swizzy-web-service": "0.6.2",
33
+ "@swizzyweb/swizzy-common": "^0.3.5",
34
+ "@swizzyweb/swizzy-web-service": "^0.6.3",
34
35
  "express": "^5.2.1"
35
36
  },
36
37
  "repository": {
package/src/swerve.ts CHANGED
@@ -75,6 +75,7 @@ export interface SwerveManagerProps {
75
75
  webServices?: WebService<any>[];
76
76
  nodeModulesPath?: string;
77
77
  logger?: ILogger<any> | undefined;
78
+ noLogFile?: boolean;
78
79
  }
79
80
 
80
81
  export interface WebServiceConfiguration {}
@@ -99,6 +100,7 @@ export class SwerveManager implements ISwerveManager {
99
100
  appName: "swerve-manager",
100
101
  port: -1,
101
102
  hostName: os.hostname(),
103
+ noLogFile: props.noLogFile ?? true,
102
104
  });
103
105
  }
104
106
 
@@ -122,6 +124,7 @@ export class SwerveManager implements ISwerveManager {
122
124
  hostName: os.hostname(),
123
125
  ownerName: "swerve",
124
126
  pid: process.pid,
127
+ noLogFile: args.noLogFile,
125
128
  });
126
129
 
127
130
  try {
@@ -190,23 +193,15 @@ export class SwerveManager implements ISwerveManager {
190
193
  const { app, args } = props;
191
194
  let gLogger = new SwizzyWinstonLogger({
192
195
  port: 0,
193
- logLevel: process.env.LOG_LEVEL ?? "info",
196
+ logLevel: process.env.LOG_LEVEL ?? args.logLevel ?? "info",
194
197
  appDataRoot: args.appDataRoot,
195
198
  appName: `swerve`,
196
199
  hostName: os.hostname(),
197
200
  pid: process.pid,
201
+ noLogFile: args.noLogFile,
198
202
  });
199
203
 
200
204
  try {
201
- gLogger = new SwizzyWinstonLogger({
202
- logLevel: args.serviceArgs.logLevel ?? process.env.LOG_LEVEL ?? "info",
203
- port: args.port,
204
- logDir: args.appDataRoot,
205
- appName: `swerve`,
206
- hostName: os.hostname(),
207
- pid: process.pid,
208
- });
209
-
210
205
  gLogger.debug(`Swerve Args: ${JSON.stringify(args)}`);
211
206
 
212
207
  const PORT = args.port ?? 3005;
@@ -306,7 +301,7 @@ export class SwerveManager implements ISwerveManager {
306
301
  logger,
307
302
  });
308
303
 
309
- logger.debug(`Got web service`);
304
+ gLogger.debug(`Got web service`);
310
305
 
311
306
  gLogger.debug(`Installing web service...`);
312
307
  await service.install({});
@@ -86,6 +86,7 @@ export interface SwerveArgs extends IConfig {
86
86
  appDataRoot?: string;
87
87
  serviceArgs?: KeyValue<any>;
88
88
  logLevel: string;
89
+ noLogFile: boolean;
89
90
  [key: string]: any;
90
91
  }
91
92
 
@@ -97,6 +98,7 @@ function getDefaultArgs(): SwerveArgs {
97
98
  services: {},
98
99
  port: 3005,
99
100
  serviceArgs: {},
101
+ noLogFile: false,
100
102
  };
101
103
  }
102
104
  const ARG_PREFIX = "--";
@@ -140,6 +142,11 @@ function tryParseNumberArg(val): number | boolean {
140
142
 
141
143
  function parseArgValue(val: string, logger: ILogger<any>) {
142
144
  try {
145
+ if (`${val}`.toLocaleLowerCase() == "true") {
146
+ return true;
147
+ } else if (`${val}`.toLocaleLowerCase() == "false") {
148
+ return false;
149
+ }
143
150
  return JSON.parse(val);
144
151
  } catch (e) {
145
152
  logger.warn(
@@ -156,7 +163,8 @@ export async function getArgs(
156
163
  logger: ILogger<any>,
157
164
  ): Promise<SwerveArgs> {
158
165
  let argKey = undefined;
159
- let swerveArgs = getDefaultArgs();
166
+ let defaultArgs = getDefaultArgs();
167
+ let swerveArgs = defaultArgs;
160
168
  let configFromFile: IConfig;
161
169
  const serviceCounts = new Map<string, number>();
162
170
  for (let i = 2; i < args.length; i++) {
@@ -172,8 +180,12 @@ export async function getArgs(
172
180
  argKey = undefined;
173
181
  continue;
174
182
  }
183
+ if (Object.keys(defaultArgs).includes(argKey)) {
184
+ swerveArgs[argKey] = parseArgValue(nextVal, logger);
185
+ }
175
186
  swerveArgs.serviceArgs[argKey] = parseArgValue(nextVal, logger);
176
187
  argKey = undefined;
188
+
177
189
  continue;
178
190
  }
179
191
  if (nextVal.startsWith(ARG_PREFIX)) {
@@ -105,7 +105,7 @@ export function getLoggerForService(
105
105
  const hostName = os.hostname();
106
106
  const logDir = serviceArgs.logDir;
107
107
  const appDataRoot = serviceArgs.appDataRoot;
108
-
108
+ const noLogFile = serviceArgs.noLogFile ?? gLogger.getLoggerProps().noLogFile;
109
109
  return gLogger.clone({
110
110
  port,
111
111
  appName,
@@ -116,5 +116,6 @@ export function getLoggerForService(
116
116
  logLevel,
117
117
  ownerName,
118
118
  logFileName,
119
+ noLogFile,
119
120
  });
120
121
  }