proteum 2.1.0 → 2.1.2
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/AGENTS.md +44 -98
- package/README.md +143 -10
- package/agents/framework/AGENTS.md +146 -886
- package/agents/project/AGENTS.md +73 -127
- package/agents/project/client/AGENTS.md +22 -93
- package/agents/project/client/pages/AGENTS.md +24 -26
- package/agents/project/server/routes/AGENTS.md +10 -8
- package/agents/project/server/services/AGENTS.md +22 -159
- package/agents/project/tests/AGENTS.md +11 -8
- package/cli/app/config.ts +7 -20
- package/cli/bin.js +8 -0
- package/cli/commands/command.ts +243 -0
- package/cli/commands/commandLocalRunner.js +198 -0
- package/cli/commands/create.ts +5 -0
- package/cli/commands/deploy/web.ts +1 -2
- package/cli/commands/dev.ts +98 -2
- package/cli/commands/doctor.ts +8 -74
- package/cli/commands/explain.ts +8 -186
- package/cli/commands/init.ts +2 -94
- package/cli/commands/trace.ts +228 -0
- package/cli/compiler/artifacts/commands.ts +217 -0
- package/cli/compiler/artifacts/manifest.ts +35 -21
- package/cli/compiler/artifacts/services.ts +300 -1
- package/cli/compiler/client/index.ts +43 -8
- package/cli/compiler/common/commands.ts +175 -0
- package/cli/compiler/common/index.ts +1 -1
- package/cli/compiler/common/proteumManifest.ts +15 -114
- package/cli/compiler/index.ts +25 -2
- package/cli/compiler/server/index.ts +31 -6
- package/cli/index.ts +1 -4
- package/cli/paths.ts +16 -1
- package/cli/presentation/commands.ts +104 -14
- package/cli/presentation/devSession.ts +22 -3
- package/cli/presentation/proteum_logo_400x400_square_icon.txt +400 -0
- package/cli/runtime/commands.ts +121 -4
- package/cli/scaffold/index.ts +720 -0
- package/cli/scaffold/templates.ts +344 -0
- package/cli/scaffold/types.ts +26 -0
- package/cli/tsconfig.json +4 -1
- package/cli/utils/check.ts +1 -1
- package/client/app/component.tsx +13 -9
- package/client/dev/profiler/index.tsx +2511 -0
- package/client/dev/profiler/noop.tsx +5 -0
- package/client/dev/profiler/runtime.noop.ts +116 -0
- package/client/dev/profiler/runtime.ts +840 -0
- package/client/services/router/components/router.tsx +30 -2
- package/client/services/router/index.tsx +27 -3
- package/client/services/router/request/api.ts +133 -17
- package/commands/proteum/diagnostics.ts +11 -0
- package/common/dev/commands.ts +50 -0
- package/common/dev/diagnostics.ts +298 -0
- package/common/dev/profiler.ts +92 -0
- package/common/dev/proteumManifest.ts +135 -0
- package/common/dev/requestTrace.ts +115 -0
- package/common/env/proteumEnv.ts +284 -0
- package/common/router/index.ts +4 -22
- package/docs/dev-commands.md +93 -0
- package/docs/diagnostics.md +88 -0
- package/docs/request-tracing.md +132 -0
- package/eslint.js +11 -6
- package/package.json +3 -3
- package/server/app/commands.ts +35 -370
- package/server/app/commandsManager.ts +393 -0
- package/server/app/container/config.ts +11 -49
- package/server/app/container/console/index.ts +2 -3
- package/server/app/container/index.ts +5 -2
- package/server/app/container/trace/index.ts +364 -0
- package/server/app/devCommands.ts +192 -0
- package/server/app/devDiagnostics.ts +53 -0
- package/server/app/index.ts +29 -6
- package/server/index.ts +0 -1
- package/server/services/auth/index.ts +525 -61
- package/server/services/auth/router/index.ts +106 -7
- package/server/services/cron/CronTask.ts +73 -5
- package/server/services/cron/index.ts +34 -11
- package/server/services/fetch/index.ts +3 -10
- package/server/services/prisma/index.ts +66 -4
- package/server/services/router/http/index.ts +173 -6
- package/server/services/router/index.ts +200 -12
- package/server/services/router/request/api.ts +30 -1
- package/server/services/router/response/index.ts +83 -10
- package/server/services/router/response/page/document.tsx +16 -0
- package/server/services/router/response/page/index.tsx +27 -1
- package/skills/clean-project-code/SKILL.md +7 -2
- package/test-results/.last-run.json +4 -0
- package/types/aliases.d.ts +6 -0
- package/types/global/utils.d.ts +7 -14
- package/Rte.zip +0 -0
- package/agents/project/agents.md.zip +0 -0
- package/doc/TODO.md +0 -71
- package/doc/front/router.md +0 -27
- package/doc/workspace/workspace.png +0 -0
- package/doc/workspace/workspace2.png +0 -0
- package/doc/workspace/workspace_26.01.22.png +0 -0
- package/server/services/router/http/session.ts.old +0 -40
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
/*----------------------------------
|
|
2
|
+
- DEPENDANCES
|
|
3
|
+
----------------------------------*/
|
|
4
|
+
|
|
5
|
+
import { Cli, Command as ClipanionCommand, Option, UsageError } from 'clipanion';
|
|
6
|
+
|
|
7
|
+
import type { Application } from './index';
|
|
8
|
+
import Service from '@server/app/service';
|
|
9
|
+
import { InputError, NotFound } from '@common/errors';
|
|
10
|
+
|
|
11
|
+
/*----------------------------------
|
|
12
|
+
- TYPES
|
|
13
|
+
----------------------------------*/
|
|
14
|
+
|
|
15
|
+
type CommandCallback<TArgs extends any[]> = (...args: TArgs) => Promise<any>;
|
|
16
|
+
|
|
17
|
+
export type CommandsList = { [commandName: string]: RuntimeCommand };
|
|
18
|
+
|
|
19
|
+
export type RuntimeCommand<TArgs extends any[] = any[]> = {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
run?: CommandCallback<TArgs>;
|
|
23
|
+
childrens: CommandsList;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/*----------------------------------
|
|
27
|
+
- SERVICE TYPES
|
|
28
|
+
----------------------------------*/
|
|
29
|
+
|
|
30
|
+
const LogPrefix = `[commands]`;
|
|
31
|
+
|
|
32
|
+
export type Config = { debug: boolean };
|
|
33
|
+
|
|
34
|
+
export type Hooks = {};
|
|
35
|
+
|
|
36
|
+
type TCommandArgumentValue = string | number | boolean;
|
|
37
|
+
type TParsedCommandArgs = { [key: string]: TCommandArgumentValue | TCommandArgumentValue[] };
|
|
38
|
+
|
|
39
|
+
const commandValuePattern = /^-?(?:\d+|\d*\.\d+)$/;
|
|
40
|
+
|
|
41
|
+
const tokenizeCommandString = (commandString: string) => {
|
|
42
|
+
const tokens: string[] = [];
|
|
43
|
+
let currentToken = '';
|
|
44
|
+
let quote: '"' | "'" | undefined;
|
|
45
|
+
let escaping = false;
|
|
46
|
+
|
|
47
|
+
for (const character of commandString) {
|
|
48
|
+
if (escaping) {
|
|
49
|
+
currentToken += character;
|
|
50
|
+
escaping = false;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (character === '\\') {
|
|
55
|
+
escaping = true;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (quote) {
|
|
60
|
+
if (character === quote) {
|
|
61
|
+
quote = undefined;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
currentToken += character;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (character === '"' || character === "'") {
|
|
70
|
+
quote = character;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (/\s/.test(character)) {
|
|
75
|
+
if (!currentToken) continue;
|
|
76
|
+
|
|
77
|
+
tokens.push(currentToken);
|
|
78
|
+
currentToken = '';
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
currentToken += character;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (escaping) currentToken += '\\';
|
|
86
|
+
if (currentToken) tokens.push(currentToken);
|
|
87
|
+
|
|
88
|
+
return tokens;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const isOptionToken = (token: string) => /^-(?!\d+(\.\d+)?$).+/.test(token);
|
|
92
|
+
|
|
93
|
+
const normalizeCommandValue = (value: string): TCommandArgumentValue => {
|
|
94
|
+
if (value === 'true') return true;
|
|
95
|
+
if (value === 'false') return false;
|
|
96
|
+
if (commandValuePattern.test(value)) return Number(value);
|
|
97
|
+
|
|
98
|
+
return value;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const addParsedArgValue = (args: TParsedCommandArgs, key: string, value: TCommandArgumentValue) => {
|
|
102
|
+
const existingValue = args[key];
|
|
103
|
+
|
|
104
|
+
if (existingValue === undefined) {
|
|
105
|
+
args[key] = value;
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
args[key] = Array.isArray(existingValue) ? [...existingValue, value] : [existingValue, value];
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const parseCommandOptionTokens = (tokens: string[]) => {
|
|
113
|
+
const namedArguments: TParsedCommandArgs = {};
|
|
114
|
+
const positionalArguments: string[] = [];
|
|
115
|
+
|
|
116
|
+
let usePositionalOnly = false;
|
|
117
|
+
|
|
118
|
+
for (let index = 0; index < tokens.length; index++) {
|
|
119
|
+
const token = tokens[index];
|
|
120
|
+
|
|
121
|
+
if (usePositionalOnly) {
|
|
122
|
+
positionalArguments.push(token);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (token === '--') {
|
|
127
|
+
usePositionalOnly = true;
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (token === '--help' || token === '-h') return { help: true as const, args: namedArguments, positionalArguments };
|
|
132
|
+
|
|
133
|
+
if (token.startsWith('--') && token.length > 2) {
|
|
134
|
+
const body = token.slice(2);
|
|
135
|
+
|
|
136
|
+
if (body.startsWith('no-') && body.length > 3) {
|
|
137
|
+
addParsedArgValue(namedArguments, body.slice(3), false);
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const equalsIndex = body.indexOf('=');
|
|
142
|
+
|
|
143
|
+
if (equalsIndex >= 0) {
|
|
144
|
+
addParsedArgValue(
|
|
145
|
+
namedArguments,
|
|
146
|
+
body.slice(0, equalsIndex),
|
|
147
|
+
normalizeCommandValue(body.slice(equalsIndex + 1)),
|
|
148
|
+
);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const nextToken = tokens[index + 1];
|
|
153
|
+
|
|
154
|
+
if (nextToken !== undefined && !isOptionToken(nextToken)) {
|
|
155
|
+
addParsedArgValue(namedArguments, body, normalizeCommandValue(nextToken));
|
|
156
|
+
index++;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
addParsedArgValue(namedArguments, body, true);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (token.startsWith('-') && token.length > 1 && !commandValuePattern.test(token)) {
|
|
165
|
+
const body = token.slice(1);
|
|
166
|
+
const equalsIndex = body.indexOf('=');
|
|
167
|
+
|
|
168
|
+
if (equalsIndex >= 0) {
|
|
169
|
+
addParsedArgValue(
|
|
170
|
+
namedArguments,
|
|
171
|
+
body.slice(0, equalsIndex),
|
|
172
|
+
normalizeCommandValue(body.slice(equalsIndex + 1)),
|
|
173
|
+
);
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const nextToken = tokens[index + 1];
|
|
178
|
+
|
|
179
|
+
if (body.length === 1 && nextToken !== undefined && !isOptionToken(nextToken)) {
|
|
180
|
+
addParsedArgValue(namedArguments, body, normalizeCommandValue(nextToken));
|
|
181
|
+
index++;
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
for (const shortFlag of body) addParsedArgValue(namedArguments, shortFlag, true);
|
|
186
|
+
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
positionalArguments.push(token);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return { help: false as const, args: namedArguments, positionalArguments };
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
/*----------------------------------
|
|
197
|
+
- SERVICE
|
|
198
|
+
----------------------------------*/
|
|
199
|
+
|
|
200
|
+
export default class CommandsManager extends Service<Config, Hooks, Application> {
|
|
201
|
+
public priority = 2 as 2;
|
|
202
|
+
|
|
203
|
+
public commandsIndex: CommandsList = {};
|
|
204
|
+
|
|
205
|
+
private runtimeCli?: Cli;
|
|
206
|
+
|
|
207
|
+
public command<TArgs extends any[]>(
|
|
208
|
+
...args:
|
|
209
|
+
| [name: string, description: string, childrens: RuntimeCommand[]]
|
|
210
|
+
| [name: string, description: string, run: CommandCallback<TArgs>, childrens?: RuntimeCommand[]]
|
|
211
|
+
): RuntimeCommand {
|
|
212
|
+
let name: string, description: string;
|
|
213
|
+
let childrens: RuntimeCommand[] | undefined;
|
|
214
|
+
let run: CommandCallback<TArgs> | undefined;
|
|
215
|
+
|
|
216
|
+
if (typeof args[2] === 'object') [name, description, childrens] = args;
|
|
217
|
+
else [name, description, run, childrens] = args;
|
|
218
|
+
|
|
219
|
+
const command: RuntimeCommand = { name, description, run, childrens: childrens ? this.indexFromList(childrens) : {} };
|
|
220
|
+
|
|
221
|
+
return command;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
private indexFromList(list: RuntimeCommand[]): CommandsList {
|
|
225
|
+
const index: CommandsList = {};
|
|
226
|
+
for (const command of list) index[command.name] = command;
|
|
227
|
+
|
|
228
|
+
return index;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
private invalidateRuntimeCli() {
|
|
232
|
+
this.runtimeCli = undefined;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
private createRuntimeCommandClass(command: RuntimeCommand, path: string[]) {
|
|
236
|
+
const manager = this;
|
|
237
|
+
const usage = ClipanionCommand.Usage({ description: command.description });
|
|
238
|
+
|
|
239
|
+
if (command.run === undefined) {
|
|
240
|
+
class RuntimeNamespaceCommand extends ClipanionCommand {
|
|
241
|
+
public static override paths = [path];
|
|
242
|
+
public static override usage = usage;
|
|
243
|
+
|
|
244
|
+
public async execute() {
|
|
245
|
+
throw new NotFound(`This command isn't runnable.`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
Object.defineProperty(RuntimeNamespaceCommand, 'name', {
|
|
250
|
+
value: `${path.map((segment) => segment.replace(/[^A-Za-z0-9]/g, '_')).join('_') || 'Root'}NamespaceCommand`,
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
return RuntimeNamespaceCommand;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
class RuntimeRunnableCommand extends ClipanionCommand {
|
|
257
|
+
public static override paths = [path];
|
|
258
|
+
public static override usage = usage;
|
|
259
|
+
|
|
260
|
+
public proxy = Option.Proxy({ name: 'args' });
|
|
261
|
+
|
|
262
|
+
public async execute() {
|
|
263
|
+
return manager.executeRegisteredCommand(command, path, this.proxy);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
Object.defineProperty(RuntimeRunnableCommand, 'name', {
|
|
268
|
+
value: `${path.map((segment) => segment.replace(/[^A-Za-z0-9]/g, '_')).join('_') || 'Root'}RunnableCommand`,
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
return RuntimeRunnableCommand;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
private createRuntimeCli() {
|
|
275
|
+
const cli = new Cli({
|
|
276
|
+
binaryName: this.app.identity.identifier || 'app',
|
|
277
|
+
enableCapture: false,
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const registerCommands = (commands: CommandsList, parentPath: string[] = []) => {
|
|
281
|
+
for (const command of Object.values(commands)) {
|
|
282
|
+
const path = [...parentPath, command.name];
|
|
283
|
+
|
|
284
|
+
cli.register(this.createRuntimeCommandClass(command, path));
|
|
285
|
+
|
|
286
|
+
if (Object.keys(command.childrens).length > 0) registerCommands(command.childrens, path);
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
registerCommands(this.commandsIndex);
|
|
291
|
+
|
|
292
|
+
return cli;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
private getRuntimeCli() {
|
|
296
|
+
this.runtimeCli ??= this.createRuntimeCli();
|
|
297
|
+
|
|
298
|
+
return this.runtimeCli;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
private async executeRegisteredCommand(command: RuntimeCommand, path: string[], proxyTokens: string[]) {
|
|
302
|
+
if (command.run === undefined) throw new NotFound(`This command isn't runnable.`);
|
|
303
|
+
|
|
304
|
+
const { help, args, positionalArguments } = parseCommandOptionTokens(proxyTokens);
|
|
305
|
+
|
|
306
|
+
this.config.debug &&
|
|
307
|
+
console.log(LogPrefix, `Run command path: ${path.join(' ')} | Parsed proxy tokens:`, {
|
|
308
|
+
proxyTokens,
|
|
309
|
+
args,
|
|
310
|
+
positionalArguments,
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
if (help) {
|
|
314
|
+
const cli = this.getRuntimeCli();
|
|
315
|
+
const runtimeCommand = cli.process(path, Cli.defaultContext);
|
|
316
|
+
|
|
317
|
+
return cli.usage(runtimeCommand, { detailed: true });
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (positionalArguments.length > 0) {
|
|
321
|
+
throw new UsageError(
|
|
322
|
+
`Unexpected positional arguments for "${path.join(' ')}": ${positionalArguments.join(', ')}.`,
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const argsList = Object.values(args);
|
|
327
|
+
|
|
328
|
+
return command.run(...(argsList as Parameters<NonNullable<typeof command.run>>));
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
private createRuntimeCliApi(cli: Cli) {
|
|
332
|
+
return {
|
|
333
|
+
binaryLabel: cli.binaryLabel,
|
|
334
|
+
binaryName: cli.binaryName,
|
|
335
|
+
binaryVersion: cli.binaryVersion,
|
|
336
|
+
enableCapture: cli.enableCapture,
|
|
337
|
+
enableColors: cli.enableColors,
|
|
338
|
+
definitions: () => cli.definitions(),
|
|
339
|
+
definition: (commandClass: any) => cli.definition(commandClass),
|
|
340
|
+
error: (error: Error, opts?: any) => cli.error(error, opts),
|
|
341
|
+
format: (colored?: boolean) => cli.format(colored),
|
|
342
|
+
process: (input: string[]) => cli.process(input, Cli.defaultContext),
|
|
343
|
+
run: (input: string[]) => cli.run(input, Cli.defaultContext),
|
|
344
|
+
usage: (command?: any, opts?: any) => cli.usage(command, opts),
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/*----------------------------------
|
|
349
|
+
- REGISTER
|
|
350
|
+
----------------------------------*/
|
|
351
|
+
public fromList(list: RuntimeCommand[]) {
|
|
352
|
+
for (const command of list) {
|
|
353
|
+
if (this.commandsIndex[command.name] !== undefined)
|
|
354
|
+
throw new Error(`Tried to register command "${command.name}", but it already has been defined.`);
|
|
355
|
+
|
|
356
|
+
this.commandsIndex[command.name] = command;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
this.invalidateRuntimeCli();
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/*----------------------------------
|
|
363
|
+
- RUN
|
|
364
|
+
----------------------------------*/
|
|
365
|
+
public async run(commandString: string) {
|
|
366
|
+
const tokens = tokenizeCommandString(commandString);
|
|
367
|
+
|
|
368
|
+
this.config.debug && console.log(LogPrefix, `Run command: ${commandString} | Tokens:`, tokens);
|
|
369
|
+
|
|
370
|
+
if (tokens.length === 0) throw new NotFound(`Command not found.`);
|
|
371
|
+
|
|
372
|
+
const cli = this.getRuntimeCli();
|
|
373
|
+
|
|
374
|
+
try {
|
|
375
|
+
const command = cli.process(tokens, Cli.defaultContext);
|
|
376
|
+
|
|
377
|
+
if (command.help) return cli.usage(command, { detailed: true });
|
|
378
|
+
|
|
379
|
+
command.context = Cli.defaultContext;
|
|
380
|
+
command.cli = this.createRuntimeCliApi(cli);
|
|
381
|
+
|
|
382
|
+
return await command.validateAndExecute();
|
|
383
|
+
} catch (error) {
|
|
384
|
+
if (error instanceof UsageError) throw new InputError(error.message);
|
|
385
|
+
|
|
386
|
+
if (error instanceof Error && ['UnknownSyntaxError', 'AmbiguousSyntaxError'].includes(error.name)) {
|
|
387
|
+
throw new NotFound(error.message);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
throw error;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
@@ -12,10 +12,10 @@ import fs from 'fs-extra';
|
|
|
12
12
|
import yaml from 'yaml';
|
|
13
13
|
|
|
14
14
|
// Types
|
|
15
|
-
import type
|
|
16
|
-
import type { TLogProfile } from './console';
|
|
15
|
+
import { parseProteumEnvConfig, type TProteumLoadedEnvConfig } from '../../../common/env/proteumEnv';
|
|
17
16
|
|
|
18
|
-
declare const
|
|
17
|
+
declare const PROTEUM_PORT_OVERRIDE: number | null;
|
|
18
|
+
declare const BUILD_DATE: string;
|
|
19
19
|
|
|
20
20
|
/*----------------------------------
|
|
21
21
|
- TYPES
|
|
@@ -31,43 +31,8 @@ declare global {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
/*
|
|
35
|
-
name: server
|
|
36
|
-
profile: prod
|
|
37
|
-
|
|
38
|
-
router:
|
|
39
|
-
port: 80
|
|
40
|
-
domains:
|
|
41
|
-
current: 'https://recruiters.becrosspath.com'
|
|
42
|
-
recruiters: 'https://recruiters.becrosspath.com'
|
|
43
|
-
landing: 'https://becrosspath.com'
|
|
44
|
-
employers: 'https://employers.becrosspath.com'
|
|
45
|
-
candidates: 'https://candidates.becrosspath.com'
|
|
46
|
-
csm: 'https://csm.becrosspath.com'
|
|
47
|
-
|
|
48
|
-
database:
|
|
49
|
-
name: 'aws'
|
|
50
|
-
databases: [railway]
|
|
51
|
-
host: 'mysql-z7vp.railway.internal'
|
|
52
|
-
port: 3306
|
|
53
|
-
login: root
|
|
54
|
-
password: "GMnVsczoyYkyzwvVqDkMUOAIjVsumEev"
|
|
55
|
-
|
|
56
|
-
console:
|
|
57
|
-
enable: false
|
|
58
|
-
debug: false
|
|
59
|
-
bufferLimit: 10000
|
|
60
|
-
level: 'log'
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
34
|
export type TEnvName = TEnvConfig['name'];
|
|
64
|
-
export type TEnvConfig =
|
|
65
|
-
name: 'local' | 'server';
|
|
66
|
-
profile: 'dev' | 'testing' | 'prod';
|
|
67
|
-
|
|
68
|
-
router: { port: number; domains: TDomainsList };
|
|
69
|
-
console: { enable: boolean; debug: boolean; bufferLimit: number; level: TLogProfile };
|
|
70
|
-
};
|
|
35
|
+
export type TEnvConfig = TProteumLoadedEnvConfig;
|
|
71
36
|
|
|
72
37
|
type AppIdentityConfig = {
|
|
73
38
|
name: string;
|
|
@@ -98,8 +63,7 @@ export type AppConfig = { env: Config.Env; identity: Config.Identity };
|
|
|
98
63
|
const debug = false;
|
|
99
64
|
|
|
100
65
|
const getRouterPortOverride = () => {
|
|
101
|
-
if (typeof
|
|
102
|
-
return PROTEUM_ROUTER_PORT_OVERRIDE;
|
|
66
|
+
if (typeof PROTEUM_PORT_OVERRIDE !== 'undefined' && PROTEUM_PORT_OVERRIDE !== null) return PROTEUM_PORT_OVERRIDE;
|
|
103
67
|
|
|
104
68
|
return undefined;
|
|
105
69
|
};
|
|
@@ -120,15 +84,13 @@ export default class ConfigParser {
|
|
|
120
84
|
}
|
|
121
85
|
|
|
122
86
|
public env(): TEnvConfig {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
debug && console.info('[app] Using environment:', process.env.NODE_ENV);
|
|
126
|
-
const envFileName = this.appDir + '/env.yaml';
|
|
127
|
-
const envFile = this.loadYaml(envFileName);
|
|
128
|
-
const routerPortOverride = getRouterPortOverride();
|
|
87
|
+
debug && console.info('[app] Loading Proteum env vars from process.env');
|
|
88
|
+
|
|
129
89
|
return {
|
|
130
|
-
...
|
|
131
|
-
|
|
90
|
+
...parseProteumEnvConfig({
|
|
91
|
+
appDir: this.appDir,
|
|
92
|
+
routerPortOverride: getRouterPortOverride(),
|
|
93
|
+
}),
|
|
132
94
|
version: BUILD_DATE,
|
|
133
95
|
};
|
|
134
96
|
}
|
|
@@ -23,9 +23,10 @@ import type ServerRequest from '@server/services/router/request';
|
|
|
23
23
|
- SERVICE CONFIG
|
|
24
24
|
----------------------------------*/
|
|
25
25
|
|
|
26
|
-
export type TLogProfile = 'silly' | 'info' | 'warn' | 'error';
|
|
26
|
+
export type TLogProfile = 'silly' | 'log' | 'info' | 'warn' | 'error';
|
|
27
27
|
|
|
28
28
|
export type Config = { debug?: boolean; enable: boolean; bufferLimit: number; level: TLogProfile };
|
|
29
|
+
export const defaultConsoleConfig: Config = { enable: false, debug: false, bufferLimit: 10000, level: 'log' };
|
|
29
30
|
|
|
30
31
|
export type Hooks = {};
|
|
31
32
|
|
|
@@ -134,8 +135,6 @@ export default class Console {
|
|
|
134
135
|
private container: typeof ApplicationContainer,
|
|
135
136
|
private config: Config,
|
|
136
137
|
) {
|
|
137
|
-
console.log('Setting up Console shell module.');
|
|
138
|
-
|
|
139
138
|
const origLog = console.log;
|
|
140
139
|
|
|
141
140
|
const Env = container.Environment;
|
|
@@ -14,7 +14,8 @@ import type Application from '..';
|
|
|
14
14
|
import type { StartedServicesIndex } from '../service';
|
|
15
15
|
import Services, { ServicesContainer } from '../service/container';
|
|
16
16
|
import ConfigParser, { TEnvConfig } from './config';
|
|
17
|
-
import Console from './console';
|
|
17
|
+
import Console, { defaultConsoleConfig } from './console';
|
|
18
|
+
import Trace from './trace';
|
|
18
19
|
import type ServerRequest from '@server/services/router/request';
|
|
19
20
|
|
|
20
21
|
/*----------------------------------
|
|
@@ -29,6 +30,7 @@ export class ApplicationContainer<TServicesIndex extends StartedServicesIndex =
|
|
|
29
30
|
public Environment: TEnvConfig;
|
|
30
31
|
public Identity: Config.Identity;
|
|
31
32
|
public Console: Console;
|
|
33
|
+
public Trace: Trace;
|
|
32
34
|
|
|
33
35
|
public application?: Application;
|
|
34
36
|
|
|
@@ -51,7 +53,8 @@ export class ApplicationContainer<TServicesIndex extends StartedServicesIndex =
|
|
|
51
53
|
const configParser = new ConfigParser(this.path.root);
|
|
52
54
|
this.Environment = configParser.env();
|
|
53
55
|
this.Identity = configParser.identity();
|
|
54
|
-
this.Console = new Console(this,
|
|
56
|
+
this.Console = new Console(this, defaultConsoleConfig);
|
|
57
|
+
this.Trace = new Trace(this, this.Environment.trace);
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
/*----------------------------------
|